WordPress is prime target for hackers due to its popularity across the globe. A robust backup strategy is a must for every professional or business blog. This helps you recover quickly from an unwanted incident that may cost you big money. There are several ways to backup a WordPress blog that directly affects your restoration strategy. If you're relying on a single backup option, probably you're making a big mistake. There should be at least two backup options so that if one of the options fails in the emergency, you always have a replacement to get back your blog as soon as possible. Let's see some of the popular backup strategies for a typical WordPress blog.
Tree Replication on Your Web ServerThis is the simplest and the fastest way to backup your WordPress blog. This methodology must be used in conjunction with other options. Relying only on this option is not a wise move as all of your data is saved on the same web server where your blog is running. To implement his technique, create a separate folder out of your install tree that is not publicly accessible. Create a simple database backup script that can be scheduled to backup all MySQL tables to this directory.
The next important part is copying the entire installation directory tree to the backup folder. This has two advantages. First the restoration is extremely fast and secondly there's no complexity involved to save your backup. You must copy the installation tree recursively so that it can be restored in the same way without any hassle. Here's the command to copy and save your installation recursively.
cp -r /your_site_root/html/install_tree_directory /your_site_root/backup
Never overwrite the infected directory tree and it may leave some extra infected files intact even after copying the backup tree. Always delete the entire infected tree (recursively of course) and then copy the backup tree back to its location. This technique only works when the infection is limited within the installation tree or the web server itself has no problem. It will not work if the server itself is down or it is experiencing system wide infection.
Cross-server ReplicationThis is yet another interesting backup strategy that's fast and reliable. This methodology requires two parties who mutually agree to provide their server space to backup each others data. Both parties sync the data stored on a remote server in their local directory. This way, if one of the web servers fails, the data can be easily restored from the other web server. The challenge to implement this solution is to find a trusting partner who is ready to be a part of this solution. Since both the parties are beneficiaries, mutual agreement may not be a big problem if both blogging buddies are in good terms with each other.
So let's get started and see how to implement this solution. First, let's assume that both the parties have zipped backup in a separate directory on their web servers. The goal is to simply sync this zipped backup across both servers periodically. In simple words, party A syncs and keeps a backup of party B on his own server and party B syncs and keeps a backup of party A on his own server. It's a win-win situation for both the ends.
If you don't know how to create a zipped archive for the entire installation tree, here's a simple command to do that. Make sure you're in the backup directory created specifically for storing these compressed archives.
zip -r archive_`date '+%Y-%m-%d'`.zip /your_site_root/html/*
Use the following rsync command to connect and sync your friend's archived data on your web server.
rsync -e ssh -a —delete email@example.com:/friends_site/backups /your_site/backups