How to back up or migrate your blog.
The internet is not safe. If you have your data on a webhost, anywhere, it’s probably not safe. If you have a security specialist on your team (and none of us here do), then maybe it’s somewhat safe from malicious attacks, but even then, it’s still vulnerable to plain old hardware failure and general cockups. And the most vulnerable data of all is the data that is hosted on bottom-end hosts like Dreamhost where potentially hundreds of other people are sharing disk space and server resources with you, and as with everywhere on the internet, a sizable proportion of them are guaranteed to be some combination of incompetent and malicious. It’s only a matter of time before one of them accidentally or deliberately brings the server down, accidentally corrupts your files, or breaks in to your filespace and uses it to subsidise their pornography business. It’s happened to me, more than once. Moreover, as I’ve said before, if you are using FTP instead of SFTP, it means that you don’t really care about your data anyway, and pretty much anyone with enough dedication can come along and steal your password and make free with your files if they try hard enough.
Everyone needs backups. Backup. Backup all the time. Remember, I can’t give you extensions if the Ukrainian Pr0n Mafia eats your homework.
Those are the risks – but here is an clarifying certainty: when the semester is over, this web hosting will be turned off and your files will be deleted. So, quite aside from everything else, if you wish to keep your work, you will need to make at least one backup to get it off Dreamhost at the end of the class.
OK, that’s the motivation. Now… how to do this backup thing?
There’s a few options. Too many, as always. Personally, I store all the files I am working on using github, which keeps a record of every change I make, and is very very powerful. However, that’s a bit complicated, and it won’t work easily from UTS computers, so I’ll leave that one as an exercise for the advanced students.
More easy, you might want to keep all your work offline on your home computer, and only upload it at the last minute. That’s pretty possible too. You can run web servers on your home machine and just use whatever your normal home backup system is. (you do have a backup system for your home computer, right?) If you want to do that, you might find it easiest to download a preconfigured web server. There’s a free one for windows called XAMPP, and one for Mac called MAMP. I certainly do offline development myself, although I don’t use those preconfigured web server packages, since I don’t develop on Mac or Windows, but use a nice fresh linux system called Ubuntu which manages it for me automatically. All three of these systems are quite easy to use, although I should warn you that WordPress makes the uploading to a new server a bit fiddly.
But enough broad-brush options. I’m going to get down to the nitty gritty on the simplest option of all: Backing up over (S)FTP.
If you are uplaover cyberduck, you are already part of the way there. The trick is:remember that when you edit your files on the dreamhost server instead of your local computer, you now have some custom changes which you probably want to keep a copy of.
Same goes for wordpress’s built-in editor, and its plugin installer. Every time you use that, you are modifying files on the server which leaves them at the whim of Dreamhost. Nothing wrong with that, if you want to see the changes you make take instant effect, but it can be bad if you want to make sure you get to keep that change if something goes wrong.
So the trick to avoid losing stuff here is to use Cyberduck’s “Synchronise” feature, which will synchronise files on your local computer and the server, and keep them as similar as possible. This handy little feature exists on the “actions” menu of cyberduck
Once you click on that, you get to choose a local folder on your computer to keep in sync with the server.
Now, choose whether to do update the server with your local changes (“upload”), update your local copy with changes from the server (“download”), or both at once (“mirror”). Press “continue” then wait until it’s finished. And now you’ve backed up your files. Hurray!
Note that Dreamweaver can also do this. The adventurous among you are welcome to try that, but I’m not going to show you. Why? Well, for a start, all the staff here use Cyberduck in preference to Dreamweaver. For another, just because dreamweaver can do almost everything doesn’t mean it can do everything well, and one of the things that annoys me is how incredibly slow its file synchronisation system can be. For a final reason, it doesn’t hurt to learn how to use a couple of different tools, especially free, open-source ones like Cyberduck.
But, are you done here? Well, no. Not unless you are building a site in pure HTML. The thing about WordPress, or joomla, or any of these modern blogs and things is that they store information in a database on the server (in our case, MySQL) which is completely distinct from the files on the server. It’s a whole other way of storing information, and it’s completely different to back up. We won’t be going in to MySQL in detail this semester, but you will need to know at least that it’s there and how to make copies of the stuff it stores on your behalf. Here goes:
You need to find the admin interface for you database. The easiest way to do this is to log in to the dreamhost control panel and go right there.
You’re looking for the “web administration” link, which for all of our databases is though a special web application called “phpMyAdmin”. You can also usually work out how to get there, if you rememebrd your MySQL hostname, by just putting “mysql” in front of your site address. So for my site, at http://dan.map-netcultures.net, the databse admin is at http://mysql.dan.map-netcultures.net. It will be different for you, mind. You’ll need your database username and password to login, mind. You did write it down, didn’t you?
That will take you into the convoluted bowels of phpMyAdmin. There’s lots of buttons here, which you can gleefully ignore. The key thing is to select the database that you are using for your blog (you did write that down, right?) In my case it’s “dan123″.
Next, you want to do an “export” of that database, which is, predictably, under the “export” menu – the little guy highlighted in red below.
Now, finally, it’s time to do the deed. The expor menu has terrifyingly many options, most of which you don’t need. But you do probably want to “save as a file” and moreover a “zipped” file. Select those options and press the “go” button.
Bam! you now have a database backup called something like yourname.sql.zip
Where this downloads to depends on your browser. the important thing is that you should put it somewhere safe so that you can find it again later. And while we’re here- you can also restore backups. This is handy if you make a horrible mistake while you are editing your blog and want it to go back the way it was. That part is straightforward if you’ve gotten this far – to reload your exported database, you simply “import” it:
Too easy. Now, go forth and make radical changes to your blog, secure in the knowledge you can always put it back the way it was.
Bonus points – wordpress-specific tips
These instructions so far have been completely generic. But if you are using wordpress, you have a couple of extra options, and a couple of extra difficulties.
Firstly, let me re-iterate that full blown wordpress install is a bit fiddly, but the instructions are
here. If you’ve done anything at all complex to your blog, this is the avenue open to you. It’s pretty well documented, but takes a few minutes.