How to Backup a Web Server
Perhaps you use rsync, Time Machine or similar backup software mirroring your files to external drives for your PCs on a regular basis. What about your remote web server? Webmoney has written an article – Back Up a Web Server, which taught us the ways you can backup the HTML files, stylesheets, application files and databases on your remote web host. The only thing you’ll need is a remote web hosting service allowing SSH connections to the remote shell. The followings are the main topics.
The Backup Tools
Now we have a couple of bash scripts we can invoke from our terminal prompt and backup our files. Great, but who wants to do it manually? Instead, let’s set them up to run automatically once a day.
Long-running scripts like backups started through cron have a common problem. A new one may get fired off before the previous one is complete. This problem can be solved using a simple lock file.
Automated scripts should keep a log of what they do in case things go awry. This is an example of writing to a log file, with a start and end time.
Fancier Automatic Backups
Want to get really fancy and have your home machine automatically log in to your server and download those backup files for safe, off-site keeping?
Now you should have a shell script set up and a way to log in to your remote server sans password (whether by the insecure method above or the ssh-agent method). The last step in our automation process is to create a cron job on our local machine.
Source: Back Up a Web Server