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):
return run_rdiff('--test-server', '[email protected]%s::/' % self.hostname)
def test_directory(self):
# ensure destination is rdiff-backup target
try:
os.makedirs(self.destination)
except OSError as e:
if os.access(self.destination, os.F_OK):
pass
else:
raise e
run_rdiff('--list-increments', self.destination)
except subprocess.CalledProcessError:
# check if base directory exists
try:
os.makedirs(self.destination)
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):
# 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