1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-03-01 01:06:59 +00:00

borg upgrade - fix locking

because Repository.__init__ normally opens and locks the repo, and the upgrader just
inherited from (borg) Repository, it created a lock file there before the "backup copy"
was made.

No big problem, but a bit unclean.

Fixed it to not lock at the beginning, then make the copy, then lock.
This commit is contained in:
Thomas Waldmann 2015-12-10 11:11:06 +01:00
parent e9ab11be49
commit 7acda553ff

View file

@ -16,6 +16,10 @@
class AtticRepositoryUpgrader(Repository):
def __init__(self, *args, **kw):
kw['lock'] = False # do not create borg lock files (now) in attic repo
super().__init__(*args, **kw)
def upgrade(self, dryrun=True, inplace=False):
"""convert an attic repository to a borg repository
@ -34,8 +38,8 @@ def upgrade(self, dryrun=True, inplace=False):
if not dryrun:
shutil.copytree(self.path, backup, copy_function=os.link)
logger.info("opening attic repository with borg and converting")
# we need to open the repo to load configuration, keyfiles and segments
self.open(self.path, exclusive=False)
# 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()
segments = [filename for i, filename in self.io.segment_iterator()]
try:
keyfile = self.find_attic_keyfile()