Website Backups The Easy Way

Website backups can be painful (especially if you have to backup large databases). Everyone knows this. Because of that, a lot of companies make money offering this same service for a price. Fortunately there is a way to make backup process simple and fun.

Please be warned: This tutorial assumes you know what SSH is and that you are somewhat familiar with unix commands. If you are not, don’t attempt anything because the chances of accidentally deleting your website are high. Also, please read the whole tutorial. There is a catch at the end.

Open Terminal on the Mac and SSH into your server:

You will be prompted for a password. Type it in. You should be now logged into your server.

Next, lets generate a database backup:

Important things to note in the above command are:

  • dbuser – is YOUR database username
  • dbname – database you WANT to backup
  • /path/dbname.sql – is the path WHERE your server should put the backup for you to retrieve/download later.

I have a Backup folder setup in my user home directory and backup my database to that folder. My path looks similar to this one:

Next, lets zip public_html folder and place it in the same directory with the database:

The above command will zip your public_html folder.

The above commands will first copy your into the Backup folder (where your database is). Then, it will zip your Backup folder (where your database and your is). Whats cool about doing it this way, is that your SQL database will be compressed to a much smaller size.

Now we can download our complete backup with rsync:

Make sure to replace user@server-ip with your username and IP address. Enter your password and watch rsync download your complete backup to your Mac.

Here is the catch I was talking about. Obviously it is tedious to remember all these commands (not really) and the order you should execute them. Luckily there is an app (Mac) you can use to create keywords for each of these commands and have the application insert the actual commands for you.

For example: If I type

The app will insert this text:

You can assign keywords to all these commands and have the app do the heavy lifting for you. The app name is TextExpander.

Website Backups The Easy Way