On WebSites Explained, Erik posts the following ideas on how to backup your plesk server. In it, he writes:
If you have a Plesk server or virtual server, I’m sure you have though about how to backup that server. If you haven’t, please think about it now. Once your server dies on you you’ll be so sorry that you will be slamming your head against the wall.
I’ve researched and tried several options to backup my Plesk server and I’d like to share them with you, hopefully saving you some work and headaches.
The Plesk backup tool
With Plesk’s own backup tool, you can backup and restore an entire Plesk panel. This is something which is important to me. If you just want to have a copy of the data in your sites and database, you might want to skip this and go directly to the rsync and rdiff-backup tools below.
The backup tool provided by Plesk is really unreliable. In Plesk 7.5, you have psadump. I once had to actually restore a site. I found out the database of that site was not present in the backup. The database usually is the most important part of a site so I was really annoyed. Plesk 8.0 now provides another backup tool which is incompatible with psadump. I’ve heard several webhosters with the same kinds of compaints: it’s still unreliable and incompatible with 7.5 backups. Ouch.
If you want to use the psadump tool anyway, here’s the command I used to make a full backup:
ssh -f root@yourserver ‘/opt/psa/bin/psadump -f – –nostop –nostop-domain –do-not-dump-logs’ | split -b1000m – myserver_dump.`date +%F`.
This is for Debian / BSD servers. On Redhat servers, the tool is located at /usr/local/psa/bin/psadump so the command would be:
ssh -f root@yourserver ‘/usr/local/psa/bin/psadump -f – –nostop –nostop-domain –do-not-dump-logs’ | split -b1000m – myserver_dump.`date +%F`.
This command will login to your remove server and start psadump. The nostop options make sure that nothing is disabled while making the backup. do-not-dump-logs speaks for itself.. you don’t want to transfer gigabytes of logfiles so these are exluded from the backup.
4PSA Total Backup
Luckilly, the company 4PSA.com has stepped up and created a fantastic backup tool. 4PSA Total backup integrates with the Plesk control panel. You can schedule backups and store them at a remote server and local disk. The tool will let you make incremental backups, so you don’t have to upload multiple gigabytes of data on a daily basis. It uses tar but you may also choose to use the Plesk backup tool (not recommended!).
The only downside is that you have to pay for it. If you are a hoster or have a commercial site, the $99 is a small fee for the ease it offers you though.
Do-it-yourself
You can also backup your site data by using the usual unix tools. You have to know the important directories though. On Plesk, this is usually:
Site files:
- /var/www/vhosts/ (on debian)
- /home/httpd/vhosts/ (on red hat / centos)
Mysql databases:
- /var/lib/mysql/
Those are the most important files. I wouldn’t recommend you trying to backup more (like DNS zones, etc.) because it will get complicated to make a full Plesk backup on your own.
So how do you make copies of those files? You can either use rsync or a tool called rdiff-backup. rsync will sync files with a remote place. It detects files that did not change and will skip those. This saves time and resources. rdiff-backup works in the same way but has an additional feature: incremental backups. With rdiff-backup, you can for example restore a file as it was 3 days ago. I personally think this is a bit overkill. I’m happy with just having an X days old backup, because I usually run a full backup once every week and not daily.
A typical rsync backup command looks like:
rsync -aze ssh root@remoteserver:/var/lib/mysql /backup/mysql
This will reserve file properties (-a) and it will compress data (-z). It will get the files from the external server “removeserver” (-e) by using ssh. Go here for some more examples. There are some improvements you can make. For example, using keys you can allow your server to login without a password so you can automate this with a small bash script run by the cron daemon.
The following command would be a typical usage of rdiff-backup:
rdiff-backup user@hostname.net::/remote-dir local-dir
There are much more examples here.
Check out the original article here and be sure to leave a reply.