Why Subversion is not a complete way to update WordPress

While WordPress offers the functionality of upgrading core files, themes and plugins via the Dashboard, this feature cannot be used with some webhosts who are keen on security. Upgrading via FTP is time-consuming and error prone. FTP is also not very secure. To quote one webhost, “Its 2012, and you shouldn’t be using FTP for anything.” Subversion offers the promise of one-click one-command, lightning-fast, server side upgrades. Is Subversion the way to go or has Subversion yet to grow up for the casual WordPress user? Please note that this posting is more of a documentation of experiential learning in an area that really needs documentation. This is not to be read as a manual. And I am not in a position to offer support.

Note: For an Introduction to Subversion, please read my article on its promises and challenges for the casual WordPress user.

What is Subversion?

Subversion is a version control system for software. The basic concept is to host the most recent copy of the software on a publicly accessible web server, known as a repository. Using a few shell based commands, a user can download or upgrade to the latest version of the software. A user can also downgrade to a previous version of the software if he or she finds that previous release more stable. A developer can also access the latest “nightly build” of the software for testing purposes (referred to in subversion as the “trunk” version). All approved developers of the software can commit changes to the trunk version of the software in real-time, making the trunk version of the software a working copy of latest code changes. This is especially helpful for software like WordPress, whose total developers number in four digits.

For a long time, repositories were the only painful way to get software and patches for Linux (in the interest of security). Later distributions of Linux added GUIs to make this process more interactive. However, Linux now allows downloading and installing software from websites, provided the installer file has a .apt extension.

How is subversion different from FTP?

FTP involves dumping files from your own computer onto the web server. Subversion works strictly on the web server side (and must be supported by your web server). You issue shell commands to the web server to download software onto your web server.

There are complex ways to make Subversion work locally as well. For example, you could download and install the Tortoise SVN client, which creates a repository of desired software on your hard drive. And this in turn, is synced with your web server. The Tortoise SVN client provides a very intuitive interface for Subversion. We won’t be using it because it is strictly a client. It can be used for browsing Subversion repositories and downloading them to your local hard-drive. And one WordPress user has managed to find a convoluted way to automate WordPress updates using Tortoise SVN. He created his own Subversion repository in his webspace, which in turn downloads wordpress as well as select themes and plugins from the official WordPress Subversion repository. And by doing this, he updates a customized WordPress installation. However, this requires creating special folders for WordPress in the root, and enaging in .htaccess acrobatics to deal with these folders. And Tortoise SVN can only be used to download repository files to your hard drive (its a client, remember). It cannot be used to directly transfer/FTP them to your webspace. This means that your updated WordPress files will have to be FTP’d back to your webspace from your hard drive. And this defeats the purpose of making installation and upgrade strictly web based. And its not as simple as it sounds. Certainly, Tortoise SVN’s interface is very alluring, especially the ease with which svn:externals can be modified. But until FTP is integrated with Tortoise SVN, I would not recommend it for automating WordPress updates. It is a tool for committing code to projects, and thats what its best at.

How is a Subversion WordPress Installation different from a Traditional FTP one?

A Subversion WordPress Installation has a folder called .svn in the main root directory. Similar .svn folders can be found in the Themes and plugins directory, as well as for each and every theme and plugin folder.

The .svn folders store files with the extension of .svn. They contain version information about WordPress and its components. This information is necessary for future Subversion upgrades or downgrades.  These files can be downloaded via FTP and viewed with an editor such as Notepad++. But it is not possible not recommended to edit these files in any way. Doing so can “break” Subversion upgrades. It is also not recommended to move them around using FTP, as they store path information which may not be correctly updated.  These files are only meant to be handled using a shell-based command line interface. Removing these files makes your WordPress installation identical to a traditional FTP one.

A Subversion WordPress Installation is expected to be only upgraded through subversion. Later doing an FTP upgrade of the Subversion WordPress installation will not impact WordPress functionality in any way. But Subversion will get broken and may not be used again. Installing themes and plugins via FTP on a Subversion WordPress installation will not impact the functionality of these components in any way. Neither will it break Subversion for the core WordPress installation. And neither will such themes and plugins be lost when WordPress is upgraded via Subversion. Likewise, such themes and plugins can only be updated via FTP, not Subversion.

What are the advantages of Subversion

The primary advantage of Subversion is for developers, who need access to latest “bleeding edge” versions of WordPress, WordPress plugins and WordPress themes. There is no other way of accessing this stuff.

For the casual user, WordPress can also be installed for the first time using Subversion. Compared to an FTP install, a Subversion install takes only a fraction of the time (around 15 seconds). Upgrading WordPress via Subversion also takes around 15 seconds. And requires only entering a command. This means your blog will be offline for a lot less longer. And this can be done remotely, as long as you have the right credentials. Upgrading WordPress via FTP requires care. The latest version needs to be downloaded and unzipped. Some files and folders in the existing installation have to be deleted and new ones are then uploaded to replace them. There is always the danger of deleting the wrong files, which can jeopardize the blog.

How to Install WordPress via Subversion

Once you have made sure your host supports Subversion, all you need to do is to connect to your FTP account using a terminal. A free software such as Putty can be used for this purpose.

  1. Connect to your website by typing your FTP credentials into the terminal window
  2. In a browser, go to WordPress.org and note the version number of the latest stable release (in this case, it is 3.3.1).
  3. Go to your root folder using the cd (change directory) command.
  4. If you want to install WordPress into a folder such that your blog will be accessible at example.com/blog, type
    • mkdir blog
    • Then navigate to it by typing cd blog
  5. If you want to install WordPress to the root directory, ignore the previous step.
  6. Type svn co http://core.svn.wordpress.org/tags/3.3.1 .  Note the trailing dot preceded by a single space.
  7. Files will start being downloaded and unzipped. You should be done in less than a minute.

Needless to say, Subversion is not the only way to make a fast install of WordPress. A non-SVN version can also be installed via command line using the following procedure,

  1. Connect to your website by typing your FTP credentials into the terminal window
  2. In a browser, go to WordPress.org and note the version number of the latest stable release (in this case, it is 3.3.1).
  3. Go to your root folder using the cd (change directory) command.
  4. If you want to install WordPress into a folder such that your blog will be accessible at example.com/blog, type
    • mkdir blog
    • Then navigate to it by typing cd blog
  5. If you want to install WordPress to the root directory, ignore the previous step.
  6. Type wget http://wordpress.org/latest.tar.gz
  7. Files will start being downloaded. To unzip them, type tar -xzvf latest.tar.gz
  8. Then remove the zipped file typing rm latest.tar.gz

Once you are finished installing via Subversion, wget or plain old FTP, make sure you are in the WordPress directory, and type the following commands to set up permissions properly:

  • chgrp web index.php
  • cd wp-content
  • mkdir uploads
  • cd ..
  • chmod -R 775 wp-content
  • chgrp -R web wp-content
  • mkdir tmp
  • chgrp web tmp
  • chmod 775 tmp

To enable media uploads via the WordPress Dashboard, you will need to change some group ownership permissions

  • chgrp web wp-admin/async-upload.php
  • chgrp web wp-admin/media-upload.php

Further information on activating your WordPress install and connecting it to your MySQL database can be found here.

How to convert an existing WordPress Installation to Subversion

This is beyond the scope of this article. Please note that converting existing blogs to Subversion can be nightmarish if WordPress was installed in the root folder of the public directory. Although WordPress provides detailed steps and further information can be found, some web hosts do not allow renaming/swapping of the root directory.

How to upgrade WordPress via Subversion

Only a WordPress Installation that was installed via Subversion can be upgraded using Subversion.

  1. Connect to your website by typing your FTP credentials into the terminal window
  2. In a browser, go to WordPress.org and note the version number of the latest stable release (in this case, it is 3.3.1).
  3. Go to the folder that contains the WordPress installation using the cd (change directory) command.
  4. Type svn sw http://core.svn.wordpress.org/tags/3.3.1/ . Note the trailing dot preceded by a single space. Note that this is slightly different from the earlier install command.
  5. Files will start downloading and unzipping. You should be done in less than a minute. Unlike an FTP upgrade, an SVN upgrade only downloads and updates specific files and components that have been upgraded, and is therefore less time consuming.
  6. Login to your WordPress Dashboard using your browser and make sure everything is OK.

How to install additional plugins via Subversion

This is the part where Subversion falters. The WordPress Subversion installation comes bundled only with the Akismet plugin. To install additional plugins, you have to engage in command line acrobatics.

  1. Go to WordPress.org and note the latest version of the plugin (In this case, 1.6.13.8).
  2. Go to the WordPress plugin Subversion repository and note the name of the plugin. For example, the plugin All in One SEO Pack will be listed as all-in-one-seo-pack.
  3. Download and install Vim on your computer. Installing text editors on your computer will do no good because the text editor must run within the shell environment. Find out from your webhost what shell-based text editors he/she has installed on the server. If Pico is installed, your are in luck as it is fairly intuitive. On the other hand, Vim is fairly difficult to understand. Don’t bother learning to use it because we will only make use of it in an indirect, limited way.
  4. Connect to your website by typing your FTP credentials into the terminal window
  5. Go to the folder that contains the WordPress plugins using the cd (change directory) command.
  6. We need to set Vim as the command line text editor. Type export SVN_EDITOR=vi (Or export SVN_EDITOR=pico if you are using pico).
  7. Type svn propedit svn:externals . Note the trailing dot preceded by a single space and the single quotation marks.
  8. This will open an editable file in command line. Interestingly, a graphical FTP program like Filezilla shows that a new .tmp file in the plugins directory is created when this command is typed. This file can also be edited from within Filezilla (using Notepad++), but it will disappear when the edit is finished (either through Notepad++ or command line). This confirms that a graphical FTP program is indeed unsuitable for Subversion. Before you proceed, please note that you will have to use Vim-specific (or Pico specific) keyboard commands. The mouse will not work. A handy guide to Vim-specific commands can be found here.
  9. Go to the line below it using Vim-specific (or Pico-specific) commands and type
  10. all-in-one-seo-pack http://plugins.svn.wordpress.org/all-in-one-seo-pack/tags/1.6.13.8/
  11. Save the file by typing Vim-specific commands ( : followed by x followed by [return]). Or type Pico-specific commands if using Pico.
  12. Type svn update
  13. Go to your WordPress Dashboard and activate the plugin.

How to install additional themes via Subversion

This is another part where Subversion falters. The WordPress Subversion installation comes bundled only with two basic themes. To install additional themes, you have to engage in command line acrobatics.

  1. Go to WordPress.org and note the latest version of the plugin (In this case, 1.2).
  2. Go to the WordPress theme Subversion repository and note the name of the theme. For example, the theme Coraline will be listed as coraline.
  3. Download and install Vim on your computer. Installing text editors on your computer will do no good because the text editor must run within the shell environment. Find out from your webhost what shell-based text editors he/she has installed on the server. If Pico is installed, your are in luck as it is fairly intuitive. On the other hand, Vim is fairly difficult to understand. Don’t bother learning to use it because we will only make use of it in an indirect, limited way.
  4. Connect to your website by typing your FTP credentials into the terminal window
  5. Go to the folder that contains the WordPress themes using the cd (change directory) command.
  6. We need to set Vim as the command line text editor. Type export SVN_EDITOR=vi (Or export SVN_EDITOR=pico if you are using pico).
  7. Type svn propedit svn:externals .  Note the trailing dot preceded by a single space and the single quotation marks.
  8. This will open an editable file in command line. Interestingly, a graphical FTP program like Filezilla shows that a new .tmp file in the themes directory is created when this command is typed. This file can also be edited from within Filezilla (using Notepad++), but it will disappear when the edit is finished (either through Notepad++ or command line). This confirms that a graphical FTP program is indeed unsuitable for Subversion. Before you proceed, please note that you will have to use Vim-specific (or Pico specific) keyboard commands. The mouse will not work. A handy guide to Vim-specific commands can be found here.
  9. Go to the line below it using Vim-specific (or Pico-specific) commands and type
  10. coraline http://themes.svn.wordpress.org/coraline/1.2/
  11. Save the file by typing Vim-specific commands ( : followed by x followed by [return]).  Or type Pico-specific commands if using Pico.
  12. Type svn update
  13. Go to your WordPress Dashboard and activate the theme.

How to upgrade additional themes and plugins via Subversion

When you upgrade WordPress via Subversion, only the Akismet plugin and the two default themes will also be upgraded. The additional themes and plugins have to be separately upgraded via command line acrobatics.

  1. Login to your WordPress Dashboard. Your dashboard should indicate which plugins/themes are out of date and what are the version numbers of the new version. Alternatively, this can be done by checking the WordPress plugin and theme Subversion repositories (which is safer, because Subversion can only update to version numbers listed in the repository; For example, the WordPress Dashboard may indicate the new version as version 2.31 whereas the correct format (as listed in the repository) is 2.3.1.
  2. Download and install Vim on your computer. Installing text editors on your computer will do no good because the text editor must run within the shell environment. Find out from your webhost what shell-based text editors he/she has installed on the server. If Pico is installed, your are in luck as it is fairly intuitive. On the other hand, Vim is fairly difficult to understand. Don’t bother learning to use it because we will only make use of it in an indirect, limited way.
  3. Connect to your website by typing your FTP credentials into the terminal window
  4. Go to the folder that contains the WordPress plugins (or themes) using the cd (change directory) command.
  5. We need to set Vim as the command line text editor. Type export SVN_EDITOR=vi (Or export SVN_EDITOR=pico if you are using pico).
  6. Type svn propedit svn:externals .Note the trailing dot preceded by a single space and the single quotation marks.
  7. This will open an editable file in command line. This is the same .tmp file you previously edited to add additional plugins (which should be listed in the file). Or if you are updating themes, it is the same .tmp file you previously edited to add additional themes (which should be listed in the file). Before you proceed, please note that you will have to use Vim-specific (or Pico specific) keyboard commands. The mouse will not work. A handy guide to Vim-specific commands can be found here.
  8. Go to the line on which your plugin/theme is listed using Vim-specific (or Pico-specific) commands. Then move your mouse to the version number using Vim-specific (or Pico specific) commands. And replace the existing version number with the new version number, using Vim-specific (or Pico-specific) commands.
  9. Save the file by typing Vim-specific commands ( : followed by x followed by [return]). Or type Pico-specific commands if using Pico.
  10. Type svn update
  11. Go to your WordPress Dashboard and make sure everything is right.

Conclusion

While updating WordPress through SVN is a breeze, the same does not apply to updating (or installing) additional themes and plugins.

Nowhere is the casual WordPress user near the dream of updating WordPress and all plugins/themes using one command. Rather than a step towards automation for the casual user, SVN as it stands today, is still a developer tool that is best suited for updating to the “trunk”versions. Updating to latest stable releases requires manually entering the version number of the latest stable release. There is no command for automatically updating to the latest stable release.

Clearly, Subversion for WordPress has a long way to go before it can truly replace FTP as a solution to update WordPress. In fact, installing/updating additional themes via FTP may be less time consuming in certain cases (Putty does not remember login credentials). Also, there is quite a margin of error when typing in text via command line, using the convoluted Vim (or Pico) interface.

The precarious typing also takes out the joy of trying out new plugins on whim.

There are of course, complicated ways to create a unified update process for both WordPress and additional themes and plugins. These are clearly beyond the scope of the casual user.

But until Subversion for WordPress grows up, a hybrid solution can be pursued. While WordPress may be be installed and updated via Subversion, additional themes and plugins may be installed using FTP. The two can coexist, and even updating WordPress through Subversion will not affect the functionality of the additional themes and plugins installed via FTP.

Further Reading (Subversion How-To’s)

What WordPress has to say on Subversion

Upgrading WordPress via Suubversion

Useful SVN Commands

Installing additional plugins via subversion

svn:externals command line wizardry (1 & 2)

What is your stance on Subversion for Wordpress?

View Results

Loading ... Loading ...
Share

You may also like...

10 Responses

  1. Otto says:

    Howdy!

    I use SVN to update my own sites. Works swell. Don’t need FTP at all.

    We also use SVN to update WordPress.org itself. Works perfectly. 🙂

  2. pescadito says:

    very complete information,

    have you any comment to say about
    worpdrive.com (a svn backup solution?)

    • Hamad Subani says:

      worpdrive.com appears yet to be released…wouldn\’t bother unless it was for free. Currently experimented with a plugin that back ups wp to dropbox, but that requires 64 MB of PHP memory.

    • Dave says:

      Hi, I’m from the team over at Worpit, the developer of Worpdrive. Obviously I’m biased, but I would say you should try it out. It’s a fully managed and hosted solution so obviously couldn’t be for free. I can’t understand why it would need to be free to be even considered. 😯

      Anyway, on a higher level view it functions very similar to how you would use Apple’s Time Machine backup system….except for your website.
      It’s efficient in transfer and space usage. We’ve recently been receiving great testimonials from people who have tried countless backup systems, and so far ours has been the only one capable of handling their sites with large content.

      The underlying storage engine is SVN, but will soon be converted to GIT. but in actual fact how it is stored has no impact on usability.

      I’ll leave it up to you guys to make up your own opinion. But it’s worth a look if you need a robust premium backup solution.

      Dave.

  3. Will says:

    Thanks for the write up. Would be good if WP switched git and allowed you to install plugins/themes as sub-modules.

  1. February 29, 2012

    […] the casual user, the lure of using Subversion is being able to update WordPress using a single command. A Subversion update only adds and overwrites pertinent files, and therefore takes the fraction of […]

  2. December 9, 2012

    […] Your only option to update WordPress and WordPress plugins is through an FTP program, or by running Subversion scripts in a terminal (provided, you installed WordPress and its plugins via […]

Leave a Reply to Hamad SubaniCancel reply