Created
October 13, 2014 07:31
-
-
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
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
#!/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