Docker volumes export function
This commit is contained in:
parent
234fe510db
commit
c47c48ed1e
@ -24,10 +24,10 @@ 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
|
|
||||||
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
|
docker_volumes=false #backup docker volumes
|
||||||
|
|
||||||
#Rsync
|
#Rsync
|
||||||
#Daily cron
|
#Daily cron
|
||||||
#Mysql dbs
|
#Mysql dbs
|
17
main.sh
17
main.sh
@ -114,8 +114,23 @@ function dockerbackup {
|
|||||||
save_dir="$tmpdir/containers/$container_name/$container_name-image.tar"
|
save_dir="$tmpdir/containers/$container_name/$container_name-image.tar"
|
||||||
docker save -o $save_dir $container_image
|
docker save -o $save_dir $container_image
|
||||||
echo "Finished" >&2
|
echo "Finished" >&2
|
||||||
done
|
done
|
||||||
fi
|
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
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user