WebAppers

/ best free open source web resources /

Shopify

How to Backup a Web Server

Posted · Category: Information

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
The first thing we’ll do is use tar and bzip2; two command lines tools for making compressed file copies, to back up HTML, CSS, Javascript or any other text files.

Automation
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.

Locking

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.

Logging
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?

Finishing Touches
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

6 Comments
Supported By

Deals

Web Browsers Icon Set
Food Icon Set
Flat Icon Set

Flat Icon Set

100 icons