2631871046_e876569317_z
Photo credit – williamhook2631871046

Offsite data storage for your website means copying your database, code, media and other files to a remote server so that in case of any disaster the server can be rebuilt using the data available on the remote server.

Copying your database and code backups and other files like images, etc to a remote/offsite server can be done for various reasons. It is mostly done for 2 reasons.

  1. Preparing for Disaster Recover where the server can be rebuild using the data from offsite data storage
  2. Redundancy (when the live server stops due to some reason, the remote server can take over)

Although below steps can work in both the cases, this particular article is written with a viewpoint of understanding how to setup an offsite data storage for Distaster Recovery.

For preparing disaster recovery the remote server should ideally follow below criteria

Backup server requirements

  1. The hosting provider should be different to your live/production server
  2. The hosting server should be in a different location to your live/production server
  3. Bandwidth may not be a crucial factor but Disk space is important so you need to plan a proper size server after studying your data and storage requirements

How to handle different file types for offsite data storage

1. Database backups

There are number of ways database can be copied/replicated on the remote server

  1. Real time: Techniques like mysql replication helps to achive real time data synchronization on live and remote server. Any updates performed on the live server will be replicated to the remote/slave server. Here is a documentation on how to set up mysql replication. For this method it is important that your database is accessible over the network.
  2. mysqldump: This is very simple way of copying the live server database to the remote server. Read how to create a script to copy database from the live server to the remote server automatically. For this method it is not required to have your database accessible over the network however the changes would not be realtime. It would depend on the cron job you set to achive this.
  3. Backup Utility: There are various 3rd party utilities. Read how Sypex Dumper (SXD) can create automatic backups for you which you can transfer to the remote server automatically on daily basis. The database can then be imported through the SXD installation on the remote server.

2. Application/code files and images

The best way to trasfer code files and images is using rsync (remote sync) command. Below rsync command runs on the origin/live server to copy the incremental changes to the remote server. This script can be set as cron job to run on daily basis.

3. Housekeeping on the remote server

If you are transferring database to the remote server on daily basis, soon your remote server disk might get full. It is important to set up some housekeeping script on the remote server.

Above script keeps last 10 days of database backup files and delates the rest. Again a cron job can be set up on the remote server to perform this automatically on daily basis.

Leave a Reply

Your email address will not be published. Required fields are marked *