OpenVZ Forum


Home » General » Support » VE Backups
VE Backups [message #1888] Sat, 04 March 2006 04:31 Go to next message
scooter is currently offline  scooter
Messages: 38
Registered: December 2005
Location: Texas
Member
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


Scooter Harris
Re: VE Backups [message #1894 is a reply to message #1888] Sat, 04 March 2006 09:51 Go to previous messageGo to next message
Valmont is currently offline  Valmont
Messages: 225
Registered: September 2005
Senior Member
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"
Re: VE Backups [message #1904 is a reply to message #1888] Sun, 05 March 2006 22:31 Go to previous messageGo to next message
scooter is currently offline  scooter
Messages: 38
Registered: December 2005
Location: Texas
Member
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


Scooter Harris
Re: VE Backups [message #1905 is a reply to message #1888] Sun, 05 March 2006 22:40 Go to previous messageGo to next message
Valmont is currently offline  Valmont
Messages: 225
Registered: September 2005
Senior Member
`date +%a`.tgz . will create weeks backups , so you need not to remove something manually Smile
# 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
Re: VE Backups [message #1906 is a reply to message #1888] Sun, 05 March 2006 22:56 Go to previous messageGo to next message
scooter is currently offline  scooter
Messages: 38
Registered: December 2005
Location: Texas
Member
Any way to do it where it will do all the ve's without having multiple crons?

And maybe keep less amount of days?


Scooter Harris
Re: VE Backups [message #1907 is a reply to message #1888] Sun, 05 March 2006 23:45 Go to previous messageGo to next message
Valmont is currently offline  Valmont
Messages: 225
Registered: September 2005
Senior Member
It is not complex Wink

#!/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.

[Updated on: Sun, 05 March 2006 23:53]

Report message to a moderator

Re: VE Backups [message #1908 is a reply to message #1888] Sun, 05 March 2006 23:53 Go to previous messageGo to next message
scooter is currently offline  scooter
Messages: 38
Registered: December 2005
Location: Texas
Member
What about keeping less days than a week, is that something simple?


Scooter Harris
Re: VE Backups [message #1909 is a reply to message #1888] Mon, 06 March 2006 00:04 Go to previous messageGo to next message
Valmont is currently offline  Valmont
Messages: 225
Registered: September 2005
Senior Member
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.
Re: VE Backups [message #1910 is a reply to message #1888] Mon, 06 March 2006 00:10 Go to previous messageGo to next message
scooter is currently offline  scooter
Messages: 38
Registered: December 2005
Location: Texas
Member
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


Scooter Harris
Re: VE Backups [message #1918 is a reply to message #1888] Tue, 07 March 2006 03:05 Go to previous messageGo to next message
phpfreak is currently offline  phpfreak
Messages: 47
Registered: January 2006
Member
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.



Re: VE Backups [message #1930 is a reply to message #1888] Wed, 08 March 2006 12:20 Go to previous message
Valmont is currently offline  Valmont
Messages: 225
Registered: September 2005
Senior Member
You can use

nice -n 20 ../backup.sh


and even

"tar cf ..." Instead of "tar czf ..."

Previous Topic: cPanel vs. Quotas
Next Topic: RedHat9 Template
Goto Forum:
  


Current Time: Thu Apr 25 11:54:38 GMT 2024

Total time taken to generate the page: 0.01584 seconds