WordPress Version Control –Programmer’s View
As a programmer you might have to manage several wordpress installs for your customers, when problem comes up, you also need to quickly setup a development environment to pinpoint the cause through debugging. In essence it is an issue of backup and restore of an application, by putting it into a repository of version control system, it gives us a safer option we can provide to our customer, and more importantly without a version control system it is impossible for multiple users to work on same wordpress project including customers who are making content contributions
One of the reasons that wordpress is so popular is that the architects of wordpress have done a superb job in terms of the ability of version controlling the whole system which is vital for a cms system. I have seen some other cms systems that do poorly in this respect, the contents are scattered all over the places, and the ids of entities are all in auto generated numbers which are dependent on the past history.
A simple anatomy of wordpress system:
- Database: all your contents like pages,posts etc
- File system
- Core system
- Site special- everything under wp-content, including plugins and themes
- Site configuration- wp-config.php
So the targets of version control are database and file system.
Step 1. To get the database backup through phpmyadmin- database export- export both data and structure, export it into sql file, put this sql file into repository
Step 2. Put whole file system into repository
Step 3. When restoring database, in phpmyadmin, create a blank database and a user account, and restore the database from your sql file backup in step 1 through import function, this import includes data, structure like tables, even indexes.
Step 4. FTP files of file system
Step 5. On step 3, the database and user account may or may not be the same as before, if they are different, you need update settings in wp-config.php to reflect the changes
Step 6. If site url has changed, then you have to update two records in database, table wp_options, the records are siteurl and home, replace them with the new url.
That is all you need to do to either restore your wordpress site or create a development environment that is the same as the production.
If you are not a programmer, but a site owner of wordpress, except the steps of putting files into a version control repository, other steps are all you need to do to backup your site and restore in time of need.
Update on 27/10/2010
The database export only includes the table and data which is great, not database name or any database user settings, when it is imported, the database name and user privileges of the original database will not be brought to new place. While this is different from MSSQL the backup of which includes database name and users and can be an issue when restored to a new place.