{"id":335,"date":"2008-08-21T16:48:29","date_gmt":"2008-08-21T23:48:29","guid":{"rendered":"http:\/\/www.stevenbrown.ca\/blog\/?p=335"},"modified":"2008-08-21T17:40:17","modified_gmt":"2008-08-22T00:40:17","slug":"wordpress-upgrade-script","status":"publish","type":"post","link":"https:\/\/www.stevenbrown.ca\/blog\/archives\/335","title":{"rendered":"WordPress Upgrade Script"},"content":{"rendered":"<p>Even though the <a href=\"http:\/\/codex.wordpress.org\/Upgrading_WordPress\">WordPress upgrade<\/a> is easy, it&#8217;s troublesome.  So I wrote a script to do it for me.  Yep.  There&#8217;s lots of these out there.  And a lot of hosts (including mine) have a one-click install\/update thing.  But for some reason, I decided to write my own script.  In python.  Got to use a bunch of modules I&#8217;ve never used before, so it was a good experience.<\/p>\n<h3>How to Use<\/h3>\n<p>Run this script from the directory that contains your wordpress directory, on your server.  I think it requires Python version 2.3.  I ran it with 2.3.5.  Use <code>python -V<\/code> to check the version.  There&#8217;s two methods to run it.<\/p>\n<h4>With Prompts<\/h4>\n<p><strong>1: Be prompted to push the Enter key to continue at each major step.<\/strong>  Nice for the first time.<\/p>\n<pre lang=\"sh\">python wp-upgrade.py<\/pre>\n<p>Example output:<\/p>\n<pre lang=\"sh\">\r\npython ..\/src\/wp-upgrade\/wp-upgrade.py \r\nCurrent WordPress Version: '2.5'\r\nNewest WordPress Version:  2.6.1\r\nDownloading wordpress-2.6.1.tar.gz ...\r\n. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . \r\nCreate working wordpress directory... \r\n\t\t\t[[Press Enter to Continue]]\r\n\r\nUpdate WordPress root contents...  \r\n\t\t\t[[Press Enter to Continue]]\r\n\r\n'\/tmp\/tmprpJTKu\/wordpress' -> 'wordpress.working'\r\nwp-trackback.php,  wp-config-sample.php,  wp-settings.php,  wp-rss2.php,  readme.html,  index.php,  wp-links-opml.php,  wp-pass.php,  wp-feed.php,  wp-register.php,  wp-rdf.php,  wp-rss.php,  wp-commentsrss2.php,  license.txt,  wp-comments-post.php,  wp-blog-header.php,  wp-load.php,  wp-mail.php,  wp-atom.php,  wp-cron.php,  wp-app.php,  xmlrpc.php,  wp-login.php,  \r\nReplace wp-admin and wp-includes... \r\n\t\t\t[[Press Enter to Continue]]\r\n\r\n\r\nUpdate default themes and plugins...  \r\n\t\t\t[[Press Enter to Continue]]\r\n\r\n'\/tmp\/tmprpJTKu\/wordpress\/wp-content' -> 'wordpress.working\/wp-content'\r\nindex.php,  \r\n'\/tmp\/tmprpJTKu\/wordpress\/wp-content\/plugins' -> 'wordpress.working\/wp-content\/plugins'\r\nakismet,  hello.php,  \r\n'\/tmp\/tmprpJTKu\/wordpress\/wp-content\/themes' -> 'wordpress.working\/wp-content\/themes'\r\ndefault,  classic,  \r\n\r\nBackup original, Rename working....\r\n\t\t\t[[Press Enter to Continue]]\r\n\r\n\r\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \r\n### VISIT 'http:\/\/stevenbrown.ca\/blog\/wordpress\/wp-admin\/upgrade.php' in your browser. ###\r\nAfter that, you're All Done!\r\nGo re-enable all your plugins and make sure everything works.\r\nIf you need to, you can always roll back by renaming the backup to 'wordpress'.\r\n\r\n\r\n\t\t\t[[Press Enter to Continue]]\r\n<\/pre>\n<h4>Without Prompts<\/h4>\n<p><strong>2. Do everything without a prompt.<\/strong>  Do this by passing the <code>-q<\/code> option.  The <code>-q<\/code> is for <em>quiet<\/em> and prints the same messages, but doesn&#8217;t wait for the user to press Enter.  Blasts through the whole upgrade in one step.<\/p>\n<pre lang=\"sh\">python wp-upgrade.py -q<\/pre>\n<p>Example output would  be the same as the above, minus the &#8220;[[Push Enter to Continue]]&#8221; bits.<\/p>\n<h3>What&#8217;s it do?<\/h3>\n<p>If you look at the above output, which is from my own site, you can see what it does.  It will compare your installed wordpress version and to the latest available from <a href=\"http:\/\/www.wordpress.org\">http:\/\/www.wordpress.org<\/a>.  If your version is older, it will download the new one, extract it, perform the appropriate steps to update the old one.  Note that the default themes and plugins will be overwritten, which is fine as long as you didn&#8217;t customize them.  After it&#8217;s done, your <code>wordpress<\/code> directory should be up-to-date (you just have to visit the upgrade page), and you should have a <code>wordpress 2.5 backup<\/code> containing the directory as it was before running the script (and 2.5 would be the appropriate version).  Also, there&#8217;s two variables you will (probably) want to customize: <code>wpsite<\/code> and <code>wpdir<\/code>.  That&#8217;s it, basically.<\/p>\n<h3>Download<\/h3>\n<p>Browse the source and download the script <a href=\"http:\/\/stevenbrown.ca\/src\/wp-upgrade\/\"><strong>here<\/strong><\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Even though the WordPress upgrade is easy, it&#8217;s troublesome. So I wrote a script to do it for me. Yep. There&#8217;s lots of these out there. And a lot of hosts (including mine) have a one-click install\/update thing. But for some reason, I decided to write my own script. In python. Got to use a&hellip; <a class=\"more-link\" href=\"https:\/\/www.stevenbrown.ca\/blog\/archives\/335\">Continue reading <span class=\"screen-reader-text\">WordPress Upgrade Script<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[3,11,7],"tags":[48,46,176,14],"class_list":["post-335","post","type-post","status-publish","format-standard","hentry","category-geek","category-projects","category-website","tag-code","tag-python","tag-scripts","tag-wordpress","entry"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p4jEMb-5p","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/www.stevenbrown.ca\/blog\/wp-json\/wp\/v2\/posts\/335","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.stevenbrown.ca\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.stevenbrown.ca\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.stevenbrown.ca\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.stevenbrown.ca\/blog\/wp-json\/wp\/v2\/comments?post=335"}],"version-history":[{"count":6,"href":"https:\/\/www.stevenbrown.ca\/blog\/wp-json\/wp\/v2\/posts\/335\/revisions"}],"predecessor-version":[{"id":341,"href":"https:\/\/www.stevenbrown.ca\/blog\/wp-json\/wp\/v2\/posts\/335\/revisions\/341"}],"wp:attachment":[{"href":"https:\/\/www.stevenbrown.ca\/blog\/wp-json\/wp\/v2\/media?parent=335"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.stevenbrown.ca\/blog\/wp-json\/wp\/v2\/categories?post=335"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.stevenbrown.ca\/blog\/wp-json\/wp\/v2\/tags?post=335"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}