Change umask to 0000 when running backup

This commit is contained in:
Eric Torres 2019-04-14 22:35:59 -07:00
parent 9b8760346e
commit dee233b25a
2 changed files with 11 additions and 4 deletions

7
README
View File

@ -57,19 +57,18 @@ Implementation Notes
* pathlib is used for path handling
* Only absolute paths are used internally for consistency
* Use --link-dest=
* Use --suffix=, --backup, and --backup-dir=
* When hardlinking, rbackup passes the entire path to avoid needing relative paths
* The backup script changes the process umask to 0000 to determine the file modes for the files it writes i.e. snapshots
To-do
-----
* Use --suffix=, --backup, and --backup-dir=
* Create config module
* Study how snapshots behave when --delete is passed
* Add __enter__ and __exit__ for PackageManager lockfiles to prevent transactions during backup
* Create snapshot manipulation script
* Interactive cleanup script
* Repository.__delitem__()
* Repository.delete_snapshot(name)
* Test functions in config module
* load_list_from_option()
Dependencies
------------

View File

@ -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)