mirror of
https://github.com/kevinveenbirkenbach/docker-volume-backup.git
synced 2024-11-21 16:01:03 +01:00
Implemented draft
This commit is contained in:
parent
84489e7020
commit
4ab4fbeef3
@ -1,2 +1,4 @@
|
||||
# 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
18
scripts/backup.sh
Normal 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
|
Loading…
Reference in New Issue
Block a user