mirror of
https://github.com/gdiepen/docker-convenience-scripts.git
synced 2025-05-24 21:26:13 +01:00
Merge 091edb0e3c
into fd6535b616
This commit is contained in:
commit
5918c2ed3e
2 changed files with 48 additions and 0 deletions
|
@ -11,6 +11,10 @@ to ensure I have the latest production data also at development.
|
||||||
|
|
||||||
You can find more details in my blog post [Cloning Docker Data Volumes](https://www.guidodiepen.nl/2016/05/cloning-docker-data-volumes/)
|
You can find more details in my blog post [Cloning Docker Data Volumes](https://www.guidodiepen.nl/2016/05/cloning-docker-data-volumes/)
|
||||||
|
|
||||||
|
## docker_gzip_volume.sh
|
||||||
|
|
||||||
|
The purpose for this script is that I can easily gzip a volume so that it can be backed up and restored on the same or different host.
|
||||||
|
|
||||||
## docker_get_data_volume_info.sh
|
## docker_get_data_volume_info.sh
|
||||||
|
|
||||||
The purpose for this script is that I can easily get a list of details for all data volumes
|
The purpose for this script is that I can easily get a list of details for all data volumes
|
||||||
|
|
44
docker_gzip_volume.sh
Normal file
44
docker_gzip_volume.sh
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
!/bin/bash
|
||||||
|
|
||||||
|
#Author: Guido Diepen
|
||||||
|
|
||||||
|
#Convenience script that can help me to easily create a gzip of a given
|
||||||
|
#data volume. The script is mainly useful if you are using named volumes
|
||||||
|
|
||||||
|
|
||||||
|
#First check if the user provided all needed arguments
|
||||||
|
if [ "$1" = "" ]
|
||||||
|
then
|
||||||
|
echo "Please provide a source volume name"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$2" = "" ]
|
||||||
|
then
|
||||||
|
echo "Please provide a destination volume name"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
#Check if the source volume name does exist
|
||||||
|
docker volume inspect $1 > /dev/null 2>&1
|
||||||
|
if [ "$?" != "0" ]
|
||||||
|
then
|
||||||
|
echo "The source volume \"$1\" does not exist"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
#Now check if the destination exists
|
||||||
|
if [ ! -d "$2" ]
|
||||||
|
then
|
||||||
|
echo "The destination \"$2\" doesn't exist"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Copying data from source volume \"$1\" to destination volume \"$2\"..."
|
||||||
|
docker run --rm \
|
||||||
|
-i \
|
||||||
|
-t \
|
||||||
|
-v $1:/from \
|
||||||
|
-v $2:/to \
|
||||||
|
alpine ash -c "cd /from ; tar zcvf \"/to/$1`date +%Y%m%d%H%M`.gz\" ."
|
Loading…
Add table
Reference in a new issue