Created
December 5, 2022 09:55
-
-
Save axeII/ed27647ce7e5778f1255340d260c555b to your computer and use it in GitHub Desktop.
Backup docker volumes remotely using docker context
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
#!/usr/bin/env bash | |
set -o errexit | |
set -o pipefail | |
function backup-volume(){ | |
local volume | |
volume=$(docker volume ls | awk '$2 != "VOLUME" {print $2}' | fzf) | |
docker run --rm --name backup\ | |
-v "$volume":/backup-volume \ | |
busybox \ | |
/bin/sh -c \ | |
"tar zcf - /backup-volume | cat" > $volume.tar.gz | |
#"tar acf - /backup-volume | cat" > $volume.tar.zst | |
} | |
function main() { | |
backup-volume | |
} | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment