How to backup WPMU

Backup. Everyone tells you to, but maybe you don’t know how. After all, your host does backups, right?

True – your host does backups, but can or will restore only in the event of a complete disaster, and it restores the entire web account. You should very much take your own backups and store them somewhere else.

There are two things you need backups of:
– the database, where settings and content live
– the wp-content folder, where plugins, themes, and uploaded files are stored. The rest of the files are replaceable, unless you made hacks to the core.

If you have phpMyAdmin on your server, database backups are easy. PhpMyAdmin has an Export function to backup the entire database or just a table, if you wish.

In the event your database is large and using phpMyAdmin gets too unwieldy, your host may have a database backup tool in the web account control panel.

If you have ssh access, making a database backup is even easier. After logging in, move to the folder where you want the backup to be stored for now. A good one woudl be a /backups/ folder on the same level as public_html for now. Run the following command:

mysqldump –opt -u dbuser -p dbname> dbname.sql

Replace dbuser, dbname with your own. This will give you a straight up SQL dump of the database, so let’s compress it. Run this:

gzip -c dbname.sql>dbname.sql.gz

I like doing it in two steps so I know it’s done right, but if you wanted to do it all in one go, try this:

mysqldump –opt -u dbuser -p dbname> dbname.sql | gzip > outputfile.sql.gz

Now you have the database backed up and not saved under public_html, because we don’t want the outside world to have access to it. :) If you did it in two steps as above, you’ll have a zip of the database as well as a SQL dump, so to free up some space, we can get rip of the dump since we already zipped it.

rm dbname.sql

Now navigate to the root of your install. It may be something like
cd /home/webaccountname/public_html/

Let’s archive the entire wp-content folder.

zip -r wp-content-backup-Dec-3.zip wp-content/

This puts everything under wp-content in a zip. The -r in there tells it to get all the subfolders too. I like to put the date I made the backup in the filename. Once filenames have stopped scrolling by, move this zip to the backup folder we made previously.

mv wp-content-backup-Dec-3.zip ../backups

This moves the file from where we are up one directory and down into the backups directory we made earlier. Now you’re ready to move both zip files somewhere else off the server for safekeeping, or continue with an upgrade.

Sources

Leave a Reply

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