mirror of
https://github.com/borgbackup/borg.git
synced 2025-03-01 01:06:59 +00:00
borg upgrade - do not overwrite backup_repo/index.*, fixes #466
the code obviously wrote to both index.* files as they were hardlinked. now we make a normal copy of index (and also hints) to avoid this.
This commit is contained in:
parent
cd804e72b7
commit
60babd14c3
1 changed files with 10 additions and 0 deletions
|
@ -37,6 +37,16 @@ def upgrade(self, dryrun=True, inplace=False):
|
|||
logger.info('making a hardlink copy in %s', backup)
|
||||
if not dryrun:
|
||||
shutil.copytree(self.path, backup, copy_function=os.link)
|
||||
# we need to create a real copy (not hardlink copy) of index.* and hints.*
|
||||
# otherwise the backup copy will get modified.
|
||||
transaction_id = self.get_index_transaction_id()
|
||||
for name in ['index', 'hints']:
|
||||
fname = "%s.%d" % (name, transaction_id)
|
||||
fname_orig = os.path.join(self.path, fname)
|
||||
fname_backup = os.path.join(backup, fname)
|
||||
os.remove(fname_backup)
|
||||
shutil.copy(fname_orig, fname_backup)
|
||||
|
||||
logger.info("opening attic repository with borg and converting")
|
||||
# now lock the repo, after we have made the copy
|
||||
self.lock = UpgradableLock(os.path.join(self.path, 'lock'), exclusive=True, timeout=1.0).acquire()
|
||||
|
|
Loading…
Reference in a new issue