^this. Migrations usually work flawlessly, though. Otherwise, better safe than sorry.Ask them for a "quick backup". Should take them less than one minute to get the process started for you, so any provider should be willing to do so.
Until you realize you're backing up the backup file and get stuck into a backup loop.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.
Except when there's lag, times out during the transfer and openvz has already killed your old vps.^this. Migrations usually work flawlessly, though. Otherwise, better safe than sorry.
#!/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)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]
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.* 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.
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.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.