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
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"
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
`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
Any way to do it where it will do all the ve's without having multiple crons? And maybe keep less amount of days?
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.
What about keeping less days than a week, is that something simple?
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.
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
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.
You can use nice -n 20 ../backup.sh and even "tar cf ..." Instead of "tar czf ..."