Home > how-to, wordpress > How to Backup Your WordPress Blog

How to Backup Your WordPress Blog

August 24th, 2009

Today I decided to backup this blog which uses WordPress hosted on WebFaction.com. This is my first time to backup my WordPress blog so I went directly to WordPress.org -> Docs and found the following in the Advanced Topics section:

Backup Your WordPress Database

Before doing a backup of my WordPress Database, I decided to change the MySQL database password of WordPress to add more security on my blog, then proceeded to make a backup of my WordPress database according to the instructions above (using phpMyAdmin).

I was able to save a SQL file of my WordPress’ MySQL database on my local disk with the file size of 2.9mb.

Backup Your WordPress Files

A WordPress blog consists of a lot of files and directories, to quote from WordPress’ Backing Up Your WordPress Files guide:

Your WordPress site consists of the following files:

  1. WordPress Core Installation
  2. WordPress Plugins
  3. WordPress Themes
  4. Images and Files
  5. Javascripts, PHP scripts, and other code files
  6. Additional Files and Static Web Pages

Everything that has anything to do with the look and feel of your site is in a file somewhere and needs to be backed up. Additionally, you must back up all of your files in your WordPress directory (including subdirectories) and your .htaccess file.

In order to sync remote files and directories to my local disk I have been using WinSCP In Windows XP but since I am using Ubuntu now, I decided it’s time to learn new tools to do this task.

I was told 2 months ago by Dan to use rsync (a fast, versatile, remote (and local) file-copying tool) for remote syncronization of files and directories.

I have never really tried it on a production server yet so I did some research, read the rsync manual, and found out the following useful rsync links:

If you are using Ubuntu or any Linux operating system variant, I would suggest you look at rsync’s manual because it explains everything there.  (just issue man rsync in your terminal)

Rsync finds files that need to be transferred using a “quick check” algorithm (by default) that looks for files that have changed in size or in last-modified time.

I ended up using the following command to sync my WordPress site locally:

rsync -avz -e ssh account@account.webfactional.com:/home/account/webapps/blog/ .
  • explanation for the switch options
    • a -> archive mode; equals -rlptgoD
      • r -> recursive
      • l -> copy symlinks as symlinks
      • p -> preserve permissions
      • t -> preserve modification times
      • g -> preserve group
      • o -> preserve owner
      • D -> same as –devices –specials
    • v -> increase verbosity
    • z -> compress file data during the transfer
    • e -> specify the remote shell to use (in this case I used ssh or secure shell)
  • account of course is your account name in your web hosting server
  • the period at the end of the command is the destination location which, in Ubuntu, means the current directory

You will be prompted for your password.  Then after successful login, rsync will start copying remote files to your destination directory.  The whole process took about 8 minutes to complete in my Smart Bro connection.

After that was finished, I issued the command again just to check and this time it took only a few seconds because there were no changes on my WordPress site.

In summary, rsync does the following:

  • synchronizes files and folders from source (remote WordPress server) to destination (my local disk)
  • preserves the files’ attributes
  • archives and compresses file data for faster downloads
  • uses a secure connection (using ssh or secure shell)

Just what you need to backup your WordPress blog.

Of course, rsync has no GUI stuff, just plain command-line interface (CLI).  If you want a graphical file synchronizer, try Unison.

Related Articles on the Net:

Author: Cyril Pauya Categories: how-to, wordpress Tags: , , ,
  1. No comments yet.
  1. No trackbacks yet.