Moved variables for better readability

This commit is contained in:
Kevin Veen-Birkenbach 2021-08-19 13:46:35 +02:00
parent 660c847383
commit 862797e51a

View File

@ -5,6 +5,9 @@
# #
backup_time="$(date '+%Y%m%d%H%M%S')"; backup_time="$(date '+%Y%m%d%H%M%S')";
backups_folder="/Backups/"; backups_folder="/Backups/";
repository_name="$(cd "$(dirname "$(readlink -f "${0}")")" && basename `git rev-parse --show-toplevel`)";
machine_id="$(sha256sum /etc/machine-id | head -c 64)";
backup_repository_folder="$backups_folder$machine_id/$repository_name/";
for volume_name in $(docker volume ls --format '{{.Name}}'); for volume_name in $(docker volume ls --format '{{.Name}}');
do do
for container_name in $(docker ps -a --filter volume=$volume_name --format '{{.Names}}'); for container_name in $(docker ps -a --filter volume=$volume_name --format '{{.Names}}');
@ -12,9 +15,6 @@ do
echo "stop container: $container_name" && docker stop "$container_name" echo "stop container: $container_name" && docker stop "$container_name"
for source_path in $(docker inspect --format '{{ range .Mounts }}{{ if eq .Type "volume" }}{{ println .Destination }}{{ end }}{{ end }}' "$container_name"); for source_path in $(docker inspect --format '{{ range .Mounts }}{{ if eq .Type "volume" }}{{ println .Destination }}{{ end }}{{ end }}' "$container_name");
do do
repository_name="$(cd "$(dirname "$(readlink -f "${0}")")" && basename `git rev-parse --show-toplevel`)";
machine_id="$(sha256sum /etc/machine-id | head -c 64)";
backup_repository_folder="$backups_folder$machine_id/$repository_name/";
destination_path="$backup_repository_folder""latest/$container_name$source_path"; destination_path="$backup_repository_folder""latest/$container_name$source_path";
log_path="$backup_repository_folder""log.txt"; log_path="$backup_repository_folder""log.txt";
backup_dir_path="$backup_repository_folder""diffs/$backup_time/$container_name$source_path"; backup_dir_path="$backup_repository_folder""diffs/$backup_time/$container_name$source_path";