Commit 43d2b487 authored by David Adam's avatar David Adam

properly test if destination exists and create it if not

parent 7eb7d806
...@@ -28,13 +28,24 @@ class Host(object): ...@@ -28,13 +28,24 @@ class Host(object):
return run_rdiff('--test-server', '[email protected]%s::/' % self.hostname) return run_rdiff('--test-server', '[email protected]%s::/' % self.hostname)
def test_directory(self): def test_directory(self):
# ensure destination is rdiff-backup target
try: try:
os.makedirs(self.destination) run_rdiff('--list-increments', self.destination)
except OSError as e: except subprocess.CalledProcessError:
if os.access(self.destination, os.F_OK): # check if base directory exists
pass try:
else: os.makedirs(self.destination)
raise e except OSError as e:
if os.access(self.destination, os.X_OK):
pass
else:
raise e
# create baseline empty data directory
run_rdiff(*(self.run_backup_flags.split(' ') + [ '--exclude',
'**', '[email protected]%s::/' % (self.hostname), self.destination ] ) )
else:
pass
def remove_old(self): def remove_old(self):
# even with force, only increments are removed, never the most recent backup # even with force, only increments are removed, never the most recent backup
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment