Last active
July 27, 2025 15:37
-
-
Save Codycody31/2faf1b21f1e20a7ec0752e2f7b493b05 to your computer and use it in GitHub Desktop.
Backup volumes for CapRover
This file contains hidden or 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 | |
| # List all volumes starting with 'captain--' | |
| volumes=$(docker volume ls -q | grep '^captain--') | |
| totalvolumes=$(echo "$volumes" | wc -l) | |
| backedupvolumes=0 | |
| echo "Starting backup of $totalvolumes volumes." | |
| # Create a tarball of these volumes | |
| for volume in $volumes; do | |
| if docker run --rm -v $volume:/volume --log-driver none loomchild/volume-backup backup -c bz2 > ./$volume.tar.bz2; then | |
| backedupvolumes=$((backedupvolumes + 1)) | |
| echo "Successfully backed up: $volume" | |
| else | |
| echo "Failed to back up: $volume" | |
| fi | |
| done | |
| echo "Successfully backed up $backedupvolumes out of $totalvolumes volumes." | |
| # Tarball all individual volume tarballs into one file | |
| tar czf captain_volumes_backup.tar.gz captain--*.tar.bz2 | |
| # Clean up individual volume tarballs | |
| rm captain--*.tar.bz2 | |
| echo "Created tarball captain_volumes_backup.tar.gz containing all volume backups." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment