Implemented draft

This commit is contained in:
Kevin Veen-Birkenbach 2020-10-11 18:39:06 +02:00
parent 84489e7020
commit 4ab4fbeef3
2 changed files with 21 additions and 1 deletions

View File

@ -1,2 +1,4 @@
# docker-manager # docker-manager
contains scripts to manage docker contains scripts to manage docker.
See https://blog.ssdnodes.com/blog/docker-backup-volumes/.

18
scripts/backup.sh Normal file
View File

@ -0,0 +1,18 @@
#!/bin/bash
host_backup_folder_path="$HOME/Backup/docker/"
docker_backup_folder_path="/Backup/docker/"
mkdir -p "$backup_folder_path"
docker_container_ids="$(docker ps)";
backup_folders=("/var/www/html/" "/var/lib/mysql/");
for docker_container_id in "${docker_container_ids[@]}";
do
#backup_dir_base_path="$docker_backup_folder_path""archive/$(date '+%Y%m%d%H%M%S')/""$docker_container_id/"
docker stop "$docker_container_id"
for rsync_source_path in "${backup_folders[@]}";
do
rsync_destination_path="$docker_backup_folder_path""last/""$docker_container_id/$rsync_source_path";
#backup_dir_path="$backup_dir_base_path$rsync_source_path";
docker run --rm --volumes-from "$docker_container_id" -v "$host_backup_folder_path:$docker_backup_folder_path" ubuntu bash -c “test -e $rsync_source_path && rsync -a --delete $rsync_source_path $rsync_destination_path
done
docker start "$docker_container_id"
done