mirror of
https://github.com/kevinveenbirkenbach/docker-volume-backup.git
synced 2024-11-24 09:11:04 +01:00
Compare commits
No commits in common. "7f383fcce2074ba013880cad11fd7d1f941fc4cb" and "407eddc2c323de551b72cdd26b7b44685618d3b7" have entirely different histories.
7f383fcce2
...
407eddc2c3
@ -161,29 +161,22 @@ def is_image_ignored(container, ignored_images):
|
|||||||
|
|
||||||
def backup_routine_for_volume(volume_name, containers, databases, version_dir, whitelisted_images, versions_dir):
|
def backup_routine_for_volume(volume_name, containers, databases, version_dir, whitelisted_images, versions_dir):
|
||||||
"""Perform backup routine for a given volume."""
|
"""Perform backup routine for a given volume."""
|
||||||
volume_dir=""
|
ignored_images = ['redis', 'memcached']
|
||||||
for container in containers:
|
|
||||||
|
|
||||||
# Skip ignored images
|
for container in containers:
|
||||||
if is_image_ignored(container, ['redis', 'memcached']):
|
if is_image_ignored(container, ignored_images):
|
||||||
print(f"Ignoring volume '{volume_name}' linked to container '{container}' with ignored image.")
|
print(f"Ignoring volume '{volume_name}' linked to container '{container}' with ignored image.")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Directory which contains files and sqls
|
|
||||||
volume_dir = create_volume_directory(version_dir, volume_name)
|
volume_dir = create_volume_directory(version_dir, volume_name)
|
||||||
|
|
||||||
# Execute MariaDB procedure
|
|
||||||
if has_image(container, 'mariadb'):
|
if has_image(container, 'mariadb'):
|
||||||
backup_database(container, databases, volume_dir, 'mariadb')
|
backup_database(container, databases, volume_dir, 'mariadb')
|
||||||
return
|
continue
|
||||||
|
|
||||||
# Execute Postgres procedure
|
|
||||||
if has_image(container, 'postgres'):
|
if has_image(container, 'postgres'):
|
||||||
backup_database(container, databases, volume_dir, 'postgres')
|
backup_database(container, databases, volume_dir, 'postgres')
|
||||||
return
|
continue
|
||||||
|
|
||||||
# Execute backup if image is not ignored
|
|
||||||
if volume_dir:
|
|
||||||
backup_volume(volume_name, volume_dir, versions_dir)
|
backup_volume(volume_name, volume_dir, versions_dir)
|
||||||
if is_any_image_not_whitelisted(containers, whitelisted_images):
|
if is_any_image_not_whitelisted(containers, whitelisted_images):
|
||||||
stop_containers(containers)
|
stop_containers(containers)
|
||||||
|
Loading…
Reference in New Issue
Block a user