Created
July 11, 2021 15:45
-
-
Save CodyKochmann/360762db36860107d0d651d19b5e9ee5 to your computer and use it in GitHub Desktop.
How to backup docker volumes on a docker host.
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/bash | |
# this script backs up all existing docker volumes to archives | |
# by: Cody Kochmann | |
cd $(mktemp -d) | |
docker volume ls \ | |
| grep -v 'volume-backups' \ | |
| awk '/local/ {print "docker run -i --rm -v "$2":/outside:ro -v volume-backups:/bak --workdir /outside registry.gitlab.com/icody/containers/debian tar czfv /bak/"strftime("%Y.%m.%d.%H.%M.%S-",systime())$2".tar.gz ./"}' \ | |
| tee backup-volumes.sh | |
bash -x backup-volumes.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment