{"id":702,"date":"2007-10-27T21:56:58","date_gmt":"2007-10-27T19:56:58","guid":{"rendered":"http:\/\/planetozh.com\/blog\/2007\/10\/wordpress-upgrade-script\/"},"modified":"2007-10-27T21:56:58","modified_gmt":"2007-10-27T19:56:58","slug":"wordpress-upgrade-script","status":"publish","type":"post","link":"https:\/\/planetozh.com\/blog\/2007\/10\/wordpress-upgrade-script\/","title":{"rendered":"WordPress Upgrade Script"},"content":{"rendered":"<p>If you have shell access to your webserver, upgrading to the latest WordPress build can be a matter of painless <em>seconds<\/em>. As usual there is more than one way to do it, and here is one of these ways &#8212; the script I am using.<\/p>\n<div id=\"ig-sh-1\" class=\"syntax_hilite\">\n\n\t\t<div class=\"toolbar\">\n\n\t\t<div class=\"view-different-container\">\n\t\t\t\t\t\t<a href=\"#\" class=\"view-different\">&lt; View <span>plain text<\/span> &gt;<\/a>\n\t\t\t\t\t<\/div>\n\n\t\t<div class=\"language-name\">code<\/div>\n\n\t\t\n\t\t<br clear=\"both\">\n\n\t<\/div>\n\t\n\t<div class=\"code\">\n\t\t<ol class=\"code\" style=\"font-family:monospace\"><li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">#!\/bin\/bash<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">CURDIR=$(pwd)<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">SITE=&quot;http:\/\/yoursite.com\/blog&quot;<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">echo Updating Wordpress in $CURDIR<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">echo 1. &nbsp;downloading latest build<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">wget -q http:\/\/wordpress.org\/latest.tar.gz<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">echo 2. &nbsp;unpacking latest build<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">tar zxf latest.tar.gz<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">cd wordpress\/<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">echo 3. &nbsp;replacing old files with fresh ones<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">tar cf - . | (cd $CURDIR; tar xf -)<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">echo 4. &nbsp;updating your blog<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">wget -q -O - ${SITE}\/wp-admin\/upgrade.php?step=1 &gt; \/dev\/null<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">echo 5. &nbsp;removing unneeded files and directory<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">rm -f ..\/latest.tar.gz<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">echo 6. &nbsp;all done !<\/div><\/li>\n<\/ol>\t<\/div>\n\n<\/div>\n\n<p>Modify line 3 to reflect your blog URL and here you go. The script downloads the latest build, unpacks it, overwrite your files and keeps file attributes, update your blog with the often forgotten <em>\/wp-admin\/upgrade.php<\/em> step, and removes temporary files. Literally takes seconds to upgrade.<\/p>\n<p><strong>Newbie how-to:<\/strong><\/p>\n<ol>\n<li>Go to the wordpress root, where <em>wp-config.php<\/em> sits<\/li>\n<li>Using your favorite editor (<em>pico<\/em> ?) create a new file named <em>updatewp<\/em><\/li>\n<li>Paste the code in the newly created file, save, exit<\/li>\n<li><em>chmod +x updatewp<\/em><\/li>\n<li>To upgrade WordPress: just type <em>.\/updatewp<\/em> in the root dir<\/li>\n<\/ol>\n<p><strong>Note:<\/strong> this is based on a script I found a couple of years ago, which introduced me to the wicked tar piped line (step 3). I completely forgot where I found this originally, so if you have the feeling you might be the original coder, feel free to raise your hand in the comments :)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you have shell access to your webserver, upgrading to the latest WordPress build can be a matter of painless seconds. As usual there is more than one way to do it, and here is one of these ways &#8212; the script I am using. &lt; View plain text &gt; code #!\/bin\/bash CURDIR=$(pwd) SITE=&quot;http:\/\/yoursite.com\/blog&quot; echo [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[5,2,3,258,245],"class_list":["post-702","post","type-post","status-publish","format-standard","hentry","category-published","tag-bash","tag-code","tag-linux","tag-upgrade","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/posts\/702","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/comments?post=702"}],"version-history":[{"count":0,"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/posts\/702\/revisions"}],"wp:attachment":[{"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/media?parent=702"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/categories?post=702"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/tags?post=702"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}