Docker data backup

This commit is contained in:
gospodar 2023-02-10 20:53:40 +01:00
parent c47c48ed1e
commit 7dae7cb970
2 changed files with 13 additions and 0 deletions

View File

@ -24,9 +24,11 @@ push_clean=false # clean backup file after push
target_host="127.0.0.1" # rsync target host target_host="127.0.0.1" # rsync target host
target_user="backup" # rsync target user target_user="backup" # rsync target user
target_key='/home/xyz/.ssh/rsync' # rsync key target_key='/home/xyz/.ssh/rsync' # rsync key
docker_enabled=false # will you use docker backup docker_enabled=false # will you use docker backup
docker_images=false # backup docker images docker_images=false # backup docker images
docker_volumes=false #backup docker volumes docker_volumes=false #backup docker volumes
docker_data=false #backup container information
#Rsync #Rsync
#Daily cron #Daily cron

11
main.sh
View File

@ -131,6 +131,17 @@ function dockerbackup {
echo "Finished" >&2 echo "Finished" >&2
done done
fi fi
if [ "docker_data" = true ] then
echo "Backing up container information..." >&2
for i in `docker inspect --format='{{.Name}}' $(docker ps -q) | cut -f2 -d\/`
do container_name=$i
echo -n "$container_name - "
container_data=`docker inspect $container_name`
mkdir -p $tmpdir/containers/$container_name
echo $container_data > $tmpdir/containers/$container_name/$container_name-data.txt
echo "Finished" >&2
done
fi
fi fi
} }