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:
parent
e9ab11be49
commit
7acda553ff
1 changed files with 6 additions and 2 deletions
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue