<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jerry Bell's World &#187; backup</title>
	<atom:link href="http://www.jerry-bell.com/tag/backup/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jerry-bell.com</link>
	<description>Intelligent discussion on politics, technology, and security. 100% less ads than the competition.</description>
	<lastBuildDate>Mon, 27 Apr 2009 13:40:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>WordPress backup script</title>
		<link>http://www.jerry-bell.com/wordpress-backup-script/</link>
		<comments>http://www.jerry-bell.com/wordpress-backup-script/#comments</comments>
		<pubDate>Tue, 29 Apr 2008 23:18:07 +0000</pubDate>
		<dc:creator>jerry</dc:creator>
				<category><![CDATA[automate]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[hosting]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.jerry-bell.com/?p=50</guid>
		<description><![CDATA[I was looking to upgrade wordpress today, and realized that there MUST be a better way.  So, I hit google up for a &#8220;wordpress upgrade script&#8221;.  Sure enough, I found a great script at http://pthree.org/2007/03/02/wordpress-upgrade-script/.  I played with it, but it still required a lot of work &#8211; looking up database usernames and whatnot.  I figured that [...]]]></description>
			<content:encoded><![CDATA[<p>I was looking to upgrade wordpress today, and realized that there MUST be a better way.  So, I hit google up for a &#8220;wordpress upgrade script&#8221;.  Sure enough, I found a great script at <a href="http://pthree.org/2007/03/02/wordpress-upgrade-script/">http://pthree.org/2007/03/02/wordpress-upgrade-script/</a>.  I played with it, but it still required a lot of work &#8211; looking up database usernames and whatnot.  I figured that I could pull the username, database name and password out of the wp-config.php file. And I could.</p>
<p>So, now the script just pauses to remind you to deactivate your plugins.  I tried to find a way to automate that, but have struck out so far.  If you know how, let me know!  I&#8217;ll give you credit.</p>
<p><span id="more-50"></span></p>
<p>Script follows:</p>
<pre>#!/bin/bash</pre>
<pre># Updated by: Jerry Bell
# License remains intact
# Changes:
# - Added a backup directory that is outside the document root. The previous script left copies of the database accessible
# - Added code to automatically determine the database name, database username, and database password from the wp-config.php file.</pre>
<pre># - Removed "read" prompts - they're not really needed any more</pre>
<pre># - Set tar to send the archive to the backup directory instead of document root.
#
# This program upgrades your existing WordPress installations that you are running on your server.
#
# You need to make the necessary adjustments to this script as needed for your situation.
#
# Make this script executable: 'chmod 777 wp_upgrade.sh'
# Run the script: './wp_upgrade.sh'
#
# Author: Aaron Toponce
# License: GPL v2
# Version: 0.1.2</pre>
<pre># =================== Start of Script =================== #</pre>
<pre># Provide the necessary directories to what WordPress installations need to be backed up space delimited
# Change as necessary and uncomment
# For example, if you had 3 sites in /var/www/site1, /var/www/site2 and /var/www/site3
# then it would look like below (do not add the trailing slash):
# directories=(/var/www/site1 /var/www/site2 /var/www/site3)
backupdir=/var/tmp
number=${#directories[@]}
# Testing that all directories specified above are valid before beginning
for (( i = 0 ; i &lt; number ; i++ )); do
        if [[ ! -d ${directories[$i]} ]]; then
                echo "Directory ${$directories[$i]} does not exist."
                return 1
        fi
done</pre>
<pre># First, we need to get the necessary file
cd ~</pre>
<pre>if [[ -f wordpress.tar.gz ]]; then
        echo "wordpress.tar.gz exists.  Please take notice to this upgrade before continuing."
        return 1
fi</pre>
<pre>wget -O latest.tar.gz <a href="http://wordpress.org/latest.tar.gz">http://wordpress.org/latest.tar.gz</a></pre>
<pre>echo "First disable all plugins on all installations before continuing."
echo "Press ENTER to continue..."
read blah</pre>
<pre>for (( i = 0 ; i &lt; number ; i++ )); do
        clear
        cd ${directories[$i]}
        back_ts=$(date +%s)
        mkdir ${backupdir}/backup_${back_ts}
        echo "We are backing up the full directory, in case anything goes wrong. Press ENTER..."
        read blah
        tar -cvvf ${backupdir}/backup_${back_ts}/backup.tar ${directories[$i]}
        gzip  ${backupdir}/backup_${back_ts}/backup.tar</pre>
<pre>        # Timestamp in unix epoch format to create unique backup directories</pre>
<pre>        echo "backing up database for ${directories[$i]}:"
        # Backing up the necessary WordPress database
        wp_db=`grep DB_NAME ${directories[$i]}/wp-config.php | cut -f 4 -d "'"`
        wp_user=`grep DB_USER ${directories[$i]}/wp-config.php | cut -f 4 -d "'"`
        wp_pass=`grep DB_PASSWORD ${directories[$i]}/wp-config.php | cut -f 4 -d "'"`
        mysqldump --add-drop-table -u ${wp_user} -p${wp_pass} ${wp_db} &gt; ${backupdir}/backup_${back_ts}/${wp_db}.sql
        # Make the necessary changes for what to backup.  This is the default as provided by WordPress.
        echo "Backing up the important files. Press ENTER..."
        read blah
        cp .htaccess wp-config.php ${backupdir}/backup_${back_ts}
        cp -r wp-content wp-images wp-includes/languages ${backupdir}/backup_${back_ts}</pre>
<pre>        # Time to copy the latest wordpress that we downloaded and overwrite all files
        echo "Getting the latest cp of wordpress. Press ENTER..."
        read blah
        cp ~/latest.tar.gz ./wordpress.tar.gz
        tar -zxvf wordpress.tar.gz</pre>
<pre>        # Overwrite all files
        echo "Overwriting all old WordPress files with the new."
        cd wordpress
        cp -rf * ../</pre>
<pre>        # Copy the files that we backed up back
        echo "Coping the important backed up files back in."

        cp -rf  ${backupdir}/backup_${back_ts}/.htaccess ${directories[$i]}
        cp -rf  ${backupdir}/backup_${back_ts}/wp-config.php ${directories[$i]}
        cp -rf  ${backupdir}/backup_${back_ts}/wp-content ${directories[$i]}/wp-content
        cp -rf  ${backupdir}/backup_${back_ts}/wp-images ${directories[$i]}/wp-images
        cp -rf  ${backupdir}/backup_${back_ts}/wp-includes/languages ${directories[$i]}/wp-includes/languages</pre>
<pre>        echo "Point your browser to the necessary site and run the upgrade script."
        echo "EG: <a href="http://example.com/wp-admin/upgrade.php">http://example.com/wp-admin/upgrade.php</a>"
        echo "Update your permalinks and .htaccess."
        echo "Install updated plugins and themes"
        echo "Reactivate plugins"
        echo "Press ENTER to continue..."
        read blah
done</pre>
<pre>clear
echo "Congratulations! You have successfully upgraded your WordPress."
echo "Please review that your browser resolves your site."
echo "Enjoy!"</pre>
<p> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.jerry-bell.com/wordpress-backup-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
