amuck-landowner

Best way to backup whole OVZ vps?

juan

New Member
The vps provider will be migrating my vps to another location, and i just want to be cautious and ready for bacup if anything happens, what's the best way to backup the whole vps? Thanks.
 

nunim

VPS Junkie
Well, if you're provide will make you a snapshot that's probably the easiest way.  I usually just backup my config files that are important like nginx, php, etc..

You can do tar -cxzf backup.tar.gz /   to backup the entire file system but there is going to be some files that are not exactly the same between the two.
 

mojeda

New Member
Well, if you're provide will make you a snapshot that's probably the easiest way.  I usually just backup my config files that are important like nginx, php, etc..

You can do tar -cxzf backup.tar.gz /   to backup the entire file system but there is going to be some files that are not exactly the same between the two.
Until you realize you're backing up the backup file and get stuck into a backup loop.
 

KuJoe

Well-Known Member
Verified Provider
Here's a script I use to backup my VPSs:

Code:
#!/bin/bash

mysqldump -hlocalhost -uusername -ppassword database1 | gzip > /backup/db1.sql.gz
mysqldump -hlocalhost -uusername -ppassword database2 | gzip > /backup/db2.sql.gz
tar -zcf /backup/bin.tar.gz /bin
tar -zcf /backup/boot.tar.gz /boot
tar -zcf /backup/etc.tar.gz /etc
tar -zcf /backup/home.tar.gz /home
tar -zcf /backup/root.tar.gz /root
tar -zcf /backup/sbin.tar.gz /sbin
tar -zcf /backup/usr.tar.gz /usr
tar -zcf /backup/var.tar.gz /var
rsync -avz -e "ssh -p 1234 -i /root/.ssh/id_rsa" /backup/ [email protected]:/home/backupuser/server1/backup

uptime | nail -s "Automated Backup for server1 finished." [email protected]
 
Last edited by a moderator:

devonblzx

New Member
Verified Provider
Here's a script I use to backup my VPSs:


#!/bin/bash

mysqldump -hlocalhost -uusername -ppassword database1 | gzip > /backup/db1.sql.gz
mysqldump -hlocalhost -uusername -ppassword database2 | gzip > /backup/db2.sql.gz
tar -zcf /backup/bin.tar.gz /bin
tar -zcf /backup/boot.tar.gz /boot
tar -zcf /backup/etc.tar.gz /etc
tar -zcf /backup/home.tar.gz /home
tar -zcf /backup/root.tar.gz /root
tar -zcf /backup/sbin.tar.gz /sbin
tar -zcf /backup/usr.tar.gz /usr
tar -zcf /backup/var.tar.gz /var
rsync -avz -e "ssh -p 1234 -i /root/.ssh/id_rsa" /backup/ [email protected]:/home/backupuser/server1/backup

uptime | nail -s "Automated Backup for server1 finished." [email protected]
* Edit: I didn't realize nail worked as well.  Interesting.   Nail/mail does require mailx though (yum install mailx)

You could also use --all-databases with root access for MySQL to make one backup of every single database rather than doing it per database.
 
Last edited by a moderator:

KuJoe

Well-Known Member
Verified Provider
* Edit: I didn't realize nail worked as well.  Interesting.   Nail/mail does require mailx though (yum install mailx)

You could also use --all-databases with root access for MySQL to make one backup of every single database rather than doing it per database.
I use nail/mailx on all of my servers. I don't know why, just a habit from when I first started using linux years ago. I also got in the habit of creating a new user for each database that had only read access for backups since I don't like the idea of having my MySQL root password in plain text but in reality it doesn't matter much these days so the --all-databases route it probably better.
 

devonblzx

New Member
Verified Provider
I use nail/mailx on all of my servers. I don't know why, just a habit from when I first started using linux years ago. I also got in the habit of creating a new user for each database that had only read access for backups since I don't like the idea of having my MySQL root password in plain text but in reality it doesn't matter much these days so the --all-databases route it probably better.
Making the file only readable by root would be a good step to take.   I use mailx too, I never knew that nail was an alias though.  I always used mail/mailx.
 
Top
amuck-landowner