Added exception catching

This commit is contained in:
Kevin Veen-Birkenbach 2024-01-14 01:46:47 +01:00
parent 42566815c4
commit e9588b0e31

View File

@ -150,6 +150,7 @@ def getFileRsyncDestinationPath(volume_dir):
return f"{path}/" return f"{path}/"
def backup_volume(volume_name, volume_dir): def backup_volume(volume_name, volume_dir):
try:
"""Backup files of a volume with incremental backups.""" """Backup files of a volume with incremental backups."""
print(f"Starting backup routine for volume: {volume_name}") print(f"Starting backup routine for volume: {volume_name}")
files_rsync_destination_path = getFileRsyncDestinationPath(volume_dir) files_rsync_destination_path = getFileRsyncDestinationPath(volume_dir)
@ -161,6 +162,11 @@ def backup_volume(volume_name, volume_dir):
source_dir = getStoragePath(volume_name) source_dir = getStoragePath(volume_name)
rsync_command = f"rsync -abP --delete --delete-excluded {link_dest_option} {source_dir} {files_rsync_destination_path}" rsync_command = f"rsync -abP --delete --delete-excluded {link_dest_option} {source_dir} {files_rsync_destination_path}"
execute_shell_command(rsync_command) execute_shell_command(rsync_command)
except BackupException as e:
if "file has vanished" in e.args[0]:
print("Warning: Some files vanished before transfer. Continuing.")
else:
raise
print(f"Backup routine for volume: {volume_name} completed.") print(f"Backup routine for volume: {volume_name} completed.")
def get_image_info(container): def get_image_info(container):