diff --git a/README.MD b/README.MD new file mode 100644 index 0000000..85a4aa0 --- /dev/null +++ b/README.MD @@ -0,0 +1 @@ +### TODO \ No newline at end of file diff --git a/backup.cfg b/backup.cfg index 8bee017..641d4ac 100644 --- a/backup.cfg +++ b/backup.cfg @@ -24,10 +24,10 @@ push_clean=false # clean backup file after push target_host="127.0.0.1" # rsync target host target_user="backup" # rsync target user target_key='/home/xyz/.ssh/rsync' # rsync key -#Docker docker_enabled=false # will you use docker backup docker_images=false # backup docker images -#Docker volumes +docker_volumes=false #backup docker volumes + #Rsync #Daily cron #Mysql dbs \ No newline at end of file diff --git a/main.sh b/main.sh index 488ec24..36f265a 100644 --- a/main.sh +++ b/main.sh @@ -114,8 +114,23 @@ function dockerbackup { save_dir="$tmpdir/containers/$container_name/$container_name-image.tar" docker save -o $save_dir $container_image echo "Finished" >&2 -done + done fi + if [ "docker_volumes" = true ] then + echo "Backing up Docker volumes..." >&2 + for i in `docker inspect --format='{{.Name}}' $(docker ps -q) | cut -f2 -d\/` + do container_name=$i + mkdir -p $tmpdir/containers/$container_name + echo -n "$container_name - " + docker run --rm --userns=host \ + --volumes-from $container_name \ + -v $backup_path:/backup \ + -e TAR_OPTS="$tar_opts" \ + piscue/docker-backup \ + backup "$tmpdir/containers/$container_name/$container_name-volume.tar.xz" + echo "Finished" >&2 + done + fi fi }