OpenVZ Forum - RDF feed
type: channel
items: VE Backups
items: Re: VE Backups

VE Backups
type: item
description: Anyone got any little scripts to run backups of ve's on the server? At this time, I'm just doing a rsync of /vz/private and the vz-scripts directory to a 2nd drive. Any suggestions would be appreciated. Scooter
creator: scooter
date: 2006-03-04T04:31:23-00:00

Re: VE Backups
type: item
description: If you backup your VPS'es on the same machine, you can do it more simple: By cron, on hardware node. # cat vps_backup.sh #!/bin/sh vps_id=$1 vzprivate="/run/vz/private/" backupdir="/run/backup/" cd $vzprivate/$vps_id/; tar czf $backupdir/vps/vps.$vps_id.`date +%a`.tgz . #crontab -l # Backup 00 03 * * * "/run/backup/vps/vps_backup.sh 109" 00 04 * * * "/run/backup/vps/vps_backup.sh 114" 00 05 * * * "/run/backup/vps/vps_backup.sh 111"
creator: Valmont
date: 2006-03-04T09:51:38-00:00

Re: VE Backups
type: item
description: Yes, that would work, but alot of work when you have quite a few ve's heh Also i would have to manually go remove old backups unfortunately. Scooter
creator: scooter
date: 2006-03-05T22:31:10-00:00

Re: VE Backups
type: item
description: `date +%a`.tgz . will create weeks backups , so you need not to remove something manually # ls -la /run/backup/vps/vps.114.* -rw-r--r-- 1 root root 331796688 Mar 3 03:02 /run/backup/vps/vps.114.Fri.tgz -rw-r--r-- 1 root root 334626104 Mar 4 03:02 /run/backup/vps/vps.114.Sat.tgz -rw-r--r-- 1 root root 334739946 Mar 5 03:03 /run/backup/vps/vps.114.Sun.tgz -rw-r--r-- 1 root root 327671111 Mar 2 03:02 /run/backup/vps/vps.114.Thu.tgz -rw------- 1 root root 332621673 Feb 28 21:42 /run/backup/vps/vps.114.Tue.tgz -rw-r--r-- 1 root root 332639290 Mar 1 03:03 /run/backup/vps/vps.114.Wed.tgz
creator: Valmont
date: 2006-03-05T22:40:03-00:00

Re: VE Backups
type: item
description: Any way to do it where it will do all the ve's without having multiple crons? And maybe keep less amount of days?
creator: scooter
date: 2006-03-05T22:56:02-00:00

Re: VE Backups
type: item
description: It is not complex #!/bin/sh vzprivate="/run/vz/private" backupdir="/run/backup" for x in `ls $vzprivate` ; do cd $vzprivate/$x; tar -czf $backupdir/vps.$x.`date +%a`.tgz . done And you could start it by cron so often, how much it is necessary for you. Also you could use nice for downturn of a priority of it.
creator: Valmont
date: 2006-03-05T23:45:01-00:00

Re: VE Backups
type: item
description: What about keeping less days than a week, is that something simple?
creator: scooter
date: 2006-03-05T23:53:44-00:00

Re: VE Backups
type: item
description: Yes it simple. But, I'm sorry. In this example backup's will be done every night, not a week. Just because it has name with day of week, it is stored only week, until it will be rewriten.
creator: Valmont
date: 2006-03-06T00:04:30-00:00

Re: VE Backups
type: item
description: Gotcha, i wasn't thinking of it happening that way. I'll write something to do it and remove older backups I guess heh Thank you, Scooter
creator: scooter
date: 2006-03-06T00:10:08-00:00

Re: VE Backups
type: item
description: You guys should really consider doing rsync instead. Your server loads would be dramatically less during a backup for i in `ls /vz/private/`; do rsync --progress -var /vz/private/$i /backup/daily --delete-after; done Then if you wanted weekly run this once a week: for i in `ls /vz/private/`; do rsync --progress -var /vz/private/$i /backup/weekly --delete-after; done That should do the trick, but keep in mind you might need some insane disk space to do this, depending on how many vps you have on the system.
creator: phpfreak
date: 2006-03-07T03:05:44-00:00

Re: VE Backups
type: item
description: You can use nice -n 20 ../backup.sh and even "tar cf ..." Instead of "tar czf ..."
creator: Valmont
date: 2006-03-08T12:20:37-00:00