mirror of
https://github.com/kevinveenbirkenbach/docker-volume-backup.git
synced 2024-11-24 17:21:03 +01:00
changed docker_container_name to container_name
This commit is contained in:
parent
c303a8b452
commit
660c847383
@ -7,17 +7,17 @@ backup_time="$(date '+%Y%m%d%H%M%S')";
|
|||||||
backups_folder="/Backups/";
|
backups_folder="/Backups/";
|
||||||
for volume_name in $(docker volume ls --format '{{.Name}}');
|
for volume_name in $(docker volume ls --format '{{.Name}}');
|
||||||
do
|
do
|
||||||
for docker_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}}');
|
||||||
do
|
do
|
||||||
echo "stop container: $docker_container_name" && docker stop "$docker_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 }}' "$docker_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`)";
|
repository_name="$(cd "$(dirname "$(readlink -f "${0}")")" && basename `git rev-parse --show-toplevel`)";
|
||||||
machine_id="$(sha256sum /etc/machine-id | head -c 64)";
|
machine_id="$(sha256sum /etc/machine-id | head -c 64)";
|
||||||
backup_repository_folder="$backups_folder$machine_id/$repository_name/";
|
backup_repository_folder="$backups_folder$machine_id/$repository_name/";
|
||||||
destination_path="$backup_repository_folder""latest/$docker_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/$docker_container_name$source_path";
|
backup_dir_path="$backup_repository_folder""diffs/$backup_time/$container_name$source_path";
|
||||||
if [ -d "$destination_path" ]
|
if [ -d "$destination_path" ]
|
||||||
then
|
then
|
||||||
echo "backup: $source_path";
|
echo "backup: $source_path";
|
||||||
@ -26,9 +26,9 @@ do
|
|||||||
mkdir -vp "$destination_path";
|
mkdir -vp "$destination_path";
|
||||||
mkdir -vp "$backup_dir_path";
|
mkdir -vp "$backup_dir_path";
|
||||||
fi
|
fi
|
||||||
docker run --rm --volumes-from "$docker_container_name" -v "$backups_folder:$backups_folder" "kevinveenbirkenbach/alpine-rsync" sh -c "
|
docker run --rm --volumes-from "$container_name" -v "$backups_folder:$backups_folder" "kevinveenbirkenbach/alpine-rsync" sh -c "
|
||||||
rsync -abP --delete --delete-excluded --log-file=$log_path --backup-dir=$backup_dir_path '$source_path/' $destination_path";
|
rsync -abP --delete --delete-excluded --log-file=$log_path --backup-dir=$backup_dir_path '$source_path/' $destination_path";
|
||||||
done
|
done
|
||||||
echo "start container: $docker_container_name" && docker start "$docker_container_name";
|
echo "start container: $container_name" && docker start "$container_name";
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
Loading…
Reference in New Issue
Block a user