For sometime now I was planning to try out some things/experimentation with this blog. But before that I wanted to take a backup of whole thing in case I mess up stuff.
Now when I say taking a backup, I am not much worried about wordpress files as such as I know I can just download and install wordpress anytime. Most of the cpanels come with wordpress installation these days or the software can be downloaded from http://wordpress.org/download/. In case you have a customized theme or images, you can simply ftp into your web root folder (www), and copy the wordpress directory to a location where you want to back it up.
For me the only important thing was database. Mostly posts, comments, category and tags. So here are the steps to do that.
- Login to your phpmyadmin (or any other way you access your database/ check with your service provider)
- Go to your wordpress database, it has tables most probably in form of wp_name. We are concerned about- wp_comments, wp_postmeta, wp_posts, wp_terms, wp_term_relationships, wp_term_taxonomy.
Note, I am not copying user related or wordpress related information as it is always good to create new information when installing new setup. I am only concerned about the real stuff- post related stuff to be backed up.
- Now Click export at the top panel in PHPMyAdmin. Use custom as export method.
Choose the tables you want to export (mentioned above), default format is sql, we can leave that as it is.
The only thing of concern on this page is “Maximal length of created query” field. I figured out that the default value was too low for me. Adding 2 extra zeros to default “50000” helped me. If your posts are larger, you might need one more zero. The way to check it, is to open the exported sql file and see wp_posts data is available.
- Click on Go and you have your backup sql script ready.
Getting the script is one thing and using it another. We need to make sure that the script we just created will actually work. That is simpler than taking backup.
I created a new wordpress installation locally and imported the sql file created above into my new installation.
mysql -u kamal -p -v -h localhost wordpress <D:\data.sql
And this is how my backup blog was ready. That’s it