Change umask to 0000 when running backup
This commit is contained in:
@ -28,6 +28,7 @@ import rbackup.rsync
|
||||
from rbackup.struct.repository import Repository
|
||||
|
||||
# ========== Constants ==========
|
||||
SCRIPT_UMASK = 0000
|
||||
LOGFORMAT = "==> %(levelname)s %(message)s"
|
||||
EXTRA_RSYNC_OPTS = {
|
||||
"dry_run": "--dry-run",
|
||||
@ -103,6 +104,9 @@ def parse_cmdline_arguments(**kwargs):
|
||||
|
||||
# ========== Main Script ==========
|
||||
if __name__ == "__main__":
|
||||
# Create some sort of cleanup routine for resetting the umask to previous value
|
||||
old_umask = os.umask(SCRIPT_UMASK)
|
||||
|
||||
args = parse_cmdline_arguments()
|
||||
parsed_config = config.parse_configfile()
|
||||
repo = Repository(args.repository)
|
||||
@ -142,10 +146,12 @@ if __name__ == "__main__":
|
||||
)
|
||||
except ValueError as e:
|
||||
syslog.critical(e)
|
||||
os.umask(old_umask)
|
||||
exit(E_INVALID_SNAPSHOT_NAME)
|
||||
except CalledProcessError as e:
|
||||
syslog.critical("Backup process failed")
|
||||
syslog.critical(f"Failing command: {e.cmd}")
|
||||
os.umask(old_umask)
|
||||
exit(E_FAILED_PROCESS)
|
||||
|
||||
repo.symlink_snapshot(curr_snapshot)
|
||||
@ -153,3 +159,5 @@ if __name__ == "__main__":
|
||||
if args.run_post_sync:
|
||||
syslog.info("Running sync operation")
|
||||
os.sync()
|
||||
|
||||
os.umask(old_umask)
|
||||
|
Reference in New Issue
Block a user