How to have a rock solid Linux backup without pro budget V2
You can check my original article here: Backing up Linux web server live via SSH.
Since developing the first variant I've discovered several drawbacks to the method:
The entire backup is retransmitted each day causing huge bandwidth expenses.
- CPU load
Archiving and compressing the entire backup is not such a small task. You can imagine that the server gets pretty loaded during the backup which causes websites to be less responsive for extended periods of time.
- Duration of the backup
My old version of backup took up to 2 and a half hours to complete. This is a substantial amount of time.
All of these factors prompted me to experiment with rsync and attempt a solution that is incremental. The result is operational on my machine for several days and I'm very pleased with improvements in both speed and CPU load.
The solution that I've come up with is to simply rsync all the important data on the server to a folder on my home machine and then archive that folder. This leaves me with MySQL server that needs to be archived in a separate process. What I did with MySQL is to setup a master/slave replication setup.
In this setup my home machine runs a MySQL server that is a slave of my main MySQL server. This way all the data from the main server is almost immediately mirrored to the slave server. So archiving my database has been reduced to simply mysqldumping contents of the slave MySQL server on my home machine.
Not to delay you any further here is the script that I use to backup my server at the moment: