mirror of
https://github.com/kevinveenbirkenbach/docker-volume-backup.git
synced 2024-11-24 17:21:03 +01:00
Added exception catching
This commit is contained in:
parent
42566815c4
commit
e9588b0e31
@ -150,17 +150,23 @@ def getFileRsyncDestinationPath(volume_dir):
|
|||||||
return f"{path}/"
|
return f"{path}/"
|
||||||
|
|
||||||
def backup_volume(volume_name, volume_dir):
|
def backup_volume(volume_name, volume_dir):
|
||||||
"""Backup files of a volume with incremental backups."""
|
try:
|
||||||
print(f"Starting backup routine for volume: {volume_name}")
|
"""Backup files of a volume with incremental backups."""
|
||||||
files_rsync_destination_path = getFileRsyncDestinationPath(volume_dir)
|
print(f"Starting backup routine for volume: {volume_name}")
|
||||||
pathlib.Path(files_rsync_destination_path).mkdir(parents=True, exist_ok=True)
|
files_rsync_destination_path = getFileRsyncDestinationPath(volume_dir)
|
||||||
|
pathlib.Path(files_rsync_destination_path).mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
last_backup_dir = get_last_backup_dir(volume_name, files_rsync_destination_path)
|
last_backup_dir = get_last_backup_dir(volume_name, files_rsync_destination_path)
|
||||||
link_dest_option = f"--link-dest='{last_backup_dir}'" if last_backup_dir else ""
|
link_dest_option = f"--link-dest='{last_backup_dir}'" if last_backup_dir else ""
|
||||||
|
|
||||||
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):
|
||||||
|
Loading…
Reference in New Issue
Block a user