Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Backup docker volumes to minio
#!/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
@airbornelamb
Copy link
Author

airbornelamb commented Nov 7, 2018

  1. Download and setup minio client with mc config
  2. Edit this script, place it somewhere and chmod +x
  3. Set cron up (ex. everyday at 12:30 a.m 29 0 * * * /bin/bash /path/dockertominio.sh)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment