don't clobber existing borg cache

This commit is contained in:
Antoine Beaupré 2015-10-01 16:27:19 -04:00
parent 55f79b4999
commit 8022e563a9
1 changed files with 7 additions and 4 deletions

View File

@ -154,10 +154,13 @@ class AtticRepositoryConverter(Repository):
if not os.path.exists(borg_cache_dir):
os.makedirs(borg_cache_dir)
borg_cache = os.path.join(borg_cache_dir, cache)
print("copying attic cache from %s to %s" % (attic_cache, borg_cache))
if not dryrun:
shutil.copy(attic_cache, borg_cache)
caches += [borg_cache]
if os.path.exists(borg_cache):
print("borg cache already exists in %s, skipping conversion of %s" % (borg_cache, attic_cache))
else:
print("copying attic cache from %s to %s" % (attic_cache, borg_cache))
if not dryrun:
shutil.copyfile(attic_cache, borg_cache)
caches += [borg_cache]
else:
print("no %s cache found in %s" % (cache, attic_cache))