Skip to content

Instantly share code, notes, and snippets.

@avin
Created October 13, 2014 07:31
Show Gist options
  • Save avin/3150dbf8b85552490048 to your computer and use it in GitHub Desktop.
Save avin/3150dbf8b85552490048 to your computer and use it in GitHub Desktop.
Dump running openvz containers using LVM and upload to backup server using scp
#!/bin/sh
#-------VARIABLES-------
VZLIST_CMD=/usr/sbin/vzlist
VZDUMP_CMD=/usr/sbin/vzdump
DUMP_PATH=/var/backup/vzdump/current
SCP_UPLOAD_ENABLE=0
[email protected]:/backup
SCP_KEY=/root/.ssh/backup_id_rsa
#----------MAIN----------
###: Make dumps
$VZLIST_CMD -o ctid | grep -v "CTID" | awk '{print $1}' | while read -r CTID ; do
echo "Dumping $CTID..."
$VZDUMP_CMD --dumpdir $DUMP_PATH --snapshot $CTID
done
###: Upload dumps to backup-server
if [ $SCP_UPLOAD_ENABLE -eq 1 ]; then
echo "Uploading to backup server..."
scp -i $SCP_KEY $DUMP_PATH/* $SCP_BACKUP_DESTINATION
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment