properly test if destination exists and create it if not
... | ... | @@ -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 | ||
... | ... |
Please register or sign in to comment