Do not create backup if no changes were found
This commit is contained in:
parent
dae1398f49
commit
d521ef3c89
@ -90,6 +90,7 @@ def initiate_backup(sources,
|
|||||||
|
|
||||||
rsync_func = fs.rsync_ext if external_rsync else fs.rsync
|
rsync_func = fs.rsync_ext if external_rsync else fs.rsync
|
||||||
|
|
||||||
|
backup_changed = False
|
||||||
for src in sources:
|
for src in sources:
|
||||||
src_abs = os.path.abspath(src)
|
src_abs = os.path.abspath(src)
|
||||||
src_name = os.path.basename(src_abs)
|
src_name = os.path.basename(src_abs)
|
||||||
@ -102,9 +103,17 @@ def initiate_backup(sources,
|
|||||||
entry_relpath=os.path.join(src_name, entry_relpath),
|
entry_relpath=os.path.join(src_name, entry_relpath),
|
||||||
action=action
|
action=action
|
||||||
)
|
)
|
||||||
|
backup_changed = True
|
||||||
|
|
||||||
|
# do not create backup on dry-run
|
||||||
if dry_run:
|
if dry_run:
|
||||||
_lg.info("Dry-run, removing created backup: %s", cur_backup_name)
|
_lg.info("Dry-run, removing created backup: %s", cur_backup_name)
|
||||||
shutil.rmtree(cur_backup, ignore_errors=True)
|
shutil.rmtree(cur_backup, ignore_errors=True)
|
||||||
|
# do not create backup if no change from previous one
|
||||||
|
elif latest_backup is not None and not backup_changed:
|
||||||
|
_lg.info("Newly created backup %s is the same as previous one %s, removing",
|
||||||
|
cur_backup_name, os.path.basename(latest_backup))
|
||||||
|
shutil.rmtree(cur_backup, ignore_errors=True)
|
||||||
else:
|
else:
|
||||||
_lg.info("Backup created: %s", cur_backup_name)
|
_lg.info("Backup created: %s", cur_backup_name)
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user