Last active
May 8, 2021 02:36
-
-
Save k8scat/1259cbb4ddd98be6b82eede536a8f20a to your computer and use it in GitHub Desktop.
Backup data from a volume.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# Backup data from a volume. | |
# Maintainer: k8scat@gmail.com | |
data_volume=$1 | |
data_dir=$2 | |
if [[ "${data_volume}" = "" || "${data_dir}" = "" ]]; then | |
echo "usage: $0 <data_volume> <data_dir>" | |
exit 1 | |
fi | |
docker run --rm \ | |
--volumes-from ${data_volume} \ | |
-v $(pwd):/backup busybox \ | |
tar -C $(dirname ${data_dir}) \ | |
-zcf /backup/backup-$(date +"%s").tgz \ | |
$(basename ${data_dir}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment