Przeglądaj źródła

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.
Thomas Waldmann 9 lat temu
rodzic
commit
60babd14c3
1 zmienionych plików z 10 dodań i 0 usunięć
  1. 10 0
      borg/upgrader.py

+ 10 - 0
borg/upgrader.py

@@ -37,6 +37,16 @@ class AtticRepositoryUpgrader(Repository):
             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()