If you own a website, you might be thinking of ways to restore your website if your server goes down. Backup is very critical, I highly recommend to have a backup procedure in place while you are building your stuff. You do not want to lose your data/changes while you are working, depending on the type of issue you might lose all your data or you may not be able to access for hours/days etc.
There are few scenarios-
- You have a website which is hosted by hosting providers like Hostgator, inmotion etc.. They probably have hot-hot setup there is nothing much you can do, but I highly recommend you take backups from the control panel. Some providers provide backup services for extra fees (highly recommended). I have seen cases where data is lost or service is not available for few days. With a backup, you can launch your site with a different provider or with the same provider on different servers.
- If you are hosting on a self-managed host (like provided by Google cloud, AWS, Azure, Digitalocean.. etc) there are endless options (But some work needs to be done, ie you will have to script and create a cron job.).
- gzip and upload (via a cron job) to google drive or on a filesystem which can be mounted on any other box (EBS, EFS on AWS). For backup EFS is better as it can be mounted on multiple machines. It’s possible that your box is hung and you may not be able to unmount EBS (unless you shutdown the box).
- Upload (automatic) to Amazon S3 (I will highly recommend this approach), S3 has options to clean old stuff, move stuff to cheaper storage etc.
Free Git repository
If you are just planning to store code or a small set of data then you can also try gitlab, bitbucket etc. You can create free repo!
For critical applications where you have a lot of traffic, you might have to replicate/sync data between two sites. Depending on type and complexity of your code:
- You might be replicating databases, data caches etc.
- You might be pushing code changes globally using a proprietary tool which mimics NFS behavior (like if a change is made on Site A then tool will sync similar change on all other sites and then return)
Small Business Owners
For small business owners who have few static pages where changes are rarely made, you can just zip your entire directory and email to yourself. If you have a dynamic website with some data and you are a hands-on person then you can even make a backup on your home machine. Just set up a Linux server on your machine and make a backup on hourly/daily/weekly basis.
- Besides data, you might have to backup your custom server setup like apache configurations, scripts, tools, code etc. You can use git repo for that. It’s easier to manage. For WordPress users, there are several free plugins available which can run scheduled backups. Like UpdraftPlus, It can backup your WordPress site to various destinations like S3, Azure, Google Cloud, DropBox etc (Highly recommended).
- Backing up is 50% of the work, restoring from backup may not be easy. Suppose you have a full website running on a single server and you lose access to the server? You have backup but restoring backup requires few things – Launching new instance in Cloud, Pointing DNS to new IP (depends on your cloud provider if you have elsatic IP), deploying packages (Php, python, mysql/mariadb, apache,nginx etc..), creating and mounting filesystems etc.. then from backup you will probably load config files, system configs etc. (Few hours of work unless it’s automated).