Last active
November 7, 2018 05:47
-
-
Save airbornelamb/eeb9a7d756bdc487a1676792a331cf34 to your computer and use it in GitHub Desktop.
Backup docker volumes to minio
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 | |
BACKUPTIME=`date +%Y-%m-%d` | |
BACKUPNAME=dockervolumes-$BACKUPTIME.tar.gz | |
SOURCEFOLDER=/var/lib/docker/volumes | |
DESTINATIONFOLDER=/tmp/dockerbackup | |
BACKUPFULLPATH=$DESTINATIONFOLDER/$BACKUPNAME | |
MINIOBUCKET=minio/dockervolumebackup | |
# Create the backup | |
mkdir -p $DESTINATIONFOLDER | |
sudo tar -cpzf $BACKUPFULLPATH $SOURCEFOLDER | |
/usr/local/bin/mc cp $BACKUPFULLPATH $MINIOBUCKET | |
rm -f $BACKUPFULLPATH | |
# Remove everything except the last 10 days | |
/usr/local/bin/mc rm --recursive --force --older-than=10 $MINIOBUCKET/* | |
#ls -1 /root/backup_* | sort -r | tail -n +8 | xargs rm > /dev/null 2>&1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
mc config
chmod +x
29 0 * * * /bin/bash /path/dockertominio.sh
)