<?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>Cory Collier &#187; migration</title>
	<atom:link href="http://corycollier.com/tag/migration/feed/" rel="self" type="application/rss+xml" />
	<link>http://corycollier.com</link>
	<description>Web Developer and System Administrator in Orlando, FL</description>
	<lastBuildDate>Tue, 10 Apr 2012 03:31:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Linux Deployment Scripts</title>
		<link>http://corycollier.com/2011/04/linux-deployment-scripts/</link>
		<comments>http://corycollier.com/2011/04/linux-deployment-scripts/#comments</comments>
		<pubDate>Sat, 16 Apr 2011 18:07:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[deploy]]></category>
		<category><![CDATA[deployment]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[migration]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://corycollier.com/?p=627</guid>
		<description><![CDATA[A common issue in web development is getting new code to production environments. Nobody wants their site down for long, and depending on who you are a long time could be seconds or less. If you&#8217;re production environment is running a versioned instance of your code, updating that environment is as simple as using your [...]]]></description>
			<content:encoded><![CDATA[<p>A common issue in web development is getting new code to production environments. Nobody wants their site down for long, and depending on who you are a long time could be seconds or less. If you&#8217;re production environment is running a versioned instance of your code, updating that environment is as simple as using your version control. If your moving to a new location however, this isn&#8217;t the case.</p>
<p>So if you&#8217;re moving your production environment, or even just adding another server to your production environment, bash scripts will be of great help to you. The reason for scripting out your deployment is simple: reproducibility. Don&#8217;t take chances migrating a live environment manually. Deployment scripts are testable and version-able.</p>
<p>WARNING: This isn&#8217;t a tutorial on bash-scripting. I presume you already know at least some of the basics.</p>
<p>The strategy of this script is simple: Setup all of the variables up front, then execute the following:</p>
<ol>
<li>Checkout all code into a holding folder (servername.hold)</li>
<li>Switch to the appropriate version of code (git checkout tags/release-0.1)</li>
<li>Create any necessary folders that are not versioned (like cache and log folders)</li>
<li>Apply any necessary ownership/permissions (apache, 0700)</li>
<li>Move the folder from the holding location, to the operating location</li>
</ol>
<style>
code {font-size:0.9em;}
.code-comment { color: #aaa; }
.code-string {color: #c00; }
.code-variable {color: #c0c; }
.code-keyword {color: #0cc; }</p>
</style>
<p>The strategy is simple enough in fact, that you could have multiple site deployment scripts that merely setup the variables for use with the same operational script. Anyways, here&#8217;s an example of how to get this done.<br />
<code><br />
<span class="code-comment">#!/bin/bash</span></p>
<p><span class="code-comment">###########################################################</span><br />
<span class="code-comment"># Setup section of code. Setup necessary values for use in operational section of code</span><br />
<span class="code-comment">###########################################################</span></p>
<p><span class="code-comment">#establish some base values for what the server name is and where to check it out at</span><br />
<span class="code-keyword">SERVER</span>="<span class="code-string">awesome.com</span>"<br />
<span class="code-keyword">PROD_LOCATION</span>="<span class="code-string">/var/www/html/<span class="code-variable">$SERVER</span></span>"<br />
<span class="code-keyword">HOLD_LOCATION</span>="<span class="code-string">/var/www/html/<span class="code-variable">$SERVER</span><span class="code-string">.hold</span>"</p>
<p><span class="code-comment">#establish base values for app and lib git repositories</span><br />
<span class="code-keyword">GIT_REPO_URL</span>="<span class="code-string">git@awesome.com</span>"<br />
<span class="code-keyword">GIT_APP_REPO</span>="<span class="code-string">awesome.git</span>"<br />
<span class="code-keyword">GIT_LIB_REPO</span>="<span class="code-string">awesome-library.git</span>"<br />
<span class="code-keyword">GIT_APP_BRANCH</span>="<span class="code-string">tags/release-1.0</span>"<br />
<span class="code-keyword">GIT_LIB_BRANCH</span>="<span class="code-string">tags/releases-1.0</span>"</p>
<p><span class="code-comment"># create a list of folders that will be used for apache access</span><br />
<span class="code-keyword">FOLDERS</span>="<span class="code-variable">$HOLD_LOCATION</span><span class="code-string">/app/var/log</span><br />
<span class="code-variable">$HOLD_LOCATION</span><span class="code-string">/app/var/cache</span><br />
<span class="code-variable">$HOLD_LOCATION</span><span class="code-string">/app/var/backup</span>"</p>
<p><span class="code-comment">###########################################################</span><br />
<span class="code-comment"># Operational section of code. Modify at your own risk</span><br />
<span class="code-comment">###########################################################</span></p>
<p><span class="code-comment"># echo some information for the user to see what's going on</span><br />
echo<br />
echo "<span class="code-string">DEPLOYMENT SCRIPT:</span> <span class="code-variable">$0</span>"<br />
echo</p>
<p><span class="code-comment"># if the folder already exists, then stop. We won't be able to checkout if the folder already exists </span><br />
if [ -e <span class="code-variable">$HOLD_LOCATION</span> ];<br />
then<br />
    echo "<span class="code-string">Folder already exists</span>"<br />
    exit<br />
fi</p>
<p><span class="code-comment"># echo the results of checking out the application code, and switching to the release tag</span><br />
echo <span class="code-variable">`git clone $GIT_REPO_URL:$GIT_APP_REPO $HOLD_LOCATION`</span><br />
cd <span class="code-variable">$HOLD_LOCATION</span><br />
echo <span class="code-variable">`git checkout $GIT_APP_BRANCH`</span><br />
echo</p>
<p><span class="code-comment"># echo the results of checking out the library code, and switching to it's release tag</span><br />
echo <span class="code-variable">`git clone $GIT_REPO_URL:$GIT_LIB_REPO $HOLD_LOCATION/lib`</span><br />
cd <span class="code-variable">$HOLD_LOCATION</span>"<span class="code-string">/lib"<br />
echo <span class="code-variable">`git checkout $GIT_LIB_BRANCH`</span><br />
echo</p>
<p><span class="code-comment"># iterate over the folders creating them, then assigning them to apache</span><br />
for folder in <span class="code-variable">$FOLDERS</span>;<br />
do<br />
    <span class="code-comment"># output what directory is currently being operated upon</span><br />
    echo "<span class="code-variable">$folder</span>"<br />
    mkdir "<span class="code-variable">$folder</span>"<br />
    chown -R apache: "<span class="code-variable">$folder</span>"<br />
    chmod -R <span class="code-string">0700</span> "<span class="code-variable">$folder</span>"<br />
    echo<br />
done</p>
<p><span class="code-comment">#move the files from the holding area, to the actual area</span><br />
echo <span class="code-variable">`mv $HOLD_LOCATION $PROD_LOCATION`</span><br />
</code></p>
<p>As you can see, everything from the operational section down is basically plug and play. The variables are set, and it&#8217;s off to the races. Note that the library repository is just something that&#8217;s common for what I typically deal with. That may not apply to your situation. This script shouldn&#8217;t serve as the definition of what a production deployment script should be. Rather, this is just an example of one that&#8217;s been quite helpful to me.</p>
]]></content:encoded>
			<wfw:commentRss>http://corycollier.com/2011/04/linux-deployment-scripts/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Up And Went WordPress</title>
		<link>http://corycollier.com/2008/05/up-and-went-wordpress/</link>
		<comments>http://corycollier.com/2008/05/up-and-went-wordpress/#comments</comments>
		<pubDate>Tue, 20 May 2008 22:16:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[change]]></category>
		<category><![CDATA[migration]]></category>
		<category><![CDATA[site]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://corycollier.com/?p=52</guid>
		<description><![CDATA[So, I had to rebuild my site lately. I&#8217;d heard a lot about the new version of WordPress lately. No my site is on wordpress. For a while, I&#8217;ve heckled folks who keep their blogs on wordpress. I guess I really shouldn&#8217;t have, since it really is an awesome tool. It&#8217;s lightweight, quick, and gets [...]]]></description>
			<content:encoded><![CDATA[<p><a  href="http://corycollier.com/wp-content/uploads/2008/05/i-use-wordpress.jpg"><img class="alignleft size-medium wp-image-53" title="i-use-wordpress" src="http://corycollier.com/wp-content/uploads/2008/05/i-use-wordpress-300x225.jpg" alt="I use WordPress" width="300" height="225" /></a>So, I had to rebuild my site lately. I&#8217;d heard a lot about the new version of WordPress lately. No my site is on wordpress.</p>
<p>For a while, I&#8217;ve heckled folks who keep their blogs on wordpress. I guess I really shouldn&#8217;t have, since it really is an awesome tool. It&#8217;s lightweight, quick, and gets the job done with super-ease.</p>
<p>I&#8217;ve settled on a pretty minimalistic, if not Gator-esque theme for the site. I don&#8217;t want people to have any sort of hassle to see what I&#8217;ve got to say, so I elected to not add too much to this.</p>
<p>Anyways, I just thought I&#8217;d say something about it&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://corycollier.com/2008/05/up-and-went-wordpress/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Moving On Up</title>
		<link>http://corycollier.com/2008/03/moving-on-up/</link>
		<comments>http://corycollier.com/2008/03/moving-on-up/#comments</comments>
		<pubDate>Sat, 22 Mar 2008 19:33:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[drupal]]></category>
		<category><![CDATA[microformat]]></category>
		<category><![CDATA[migration]]></category>
		<category><![CDATA[outage]]></category>

		<guid isPermaLink="false">http://corycollier.com/?p=49</guid>
		<description><![CDATA[I always act too quickly. I was at home the other night, learning up on microformats, and realized that I needed to update my site in order to take advantage of the support I can get for them, with Drupal 6. Instead of doing the migration via a development site, I immediately started changing the [...]]]></description>
			<content:encoded><![CDATA[<p>I always act too quickly. I was at home the other night, learning up on microformats, and realized that I needed to update my site in order to take advantage of the support I can get for them, with Drupal 6. Instead of doing the migration via a development site, I immediately started changing the live site. When things went south, my site was down.</p>
<p>It&#8217;s been a busy week, so the site has remained down since then. I&#8217;m just outside of Knoxville, TN right now, and the computer that I saved all of my old DB info (like, ummm, any content) is back home in Altamonte Springs, FL. So, this is the only content available right now. I should have everything up and running again sometime early this week.</p>
]]></content:encoded>
			<wfw:commentRss>http://corycollier.com/2008/03/moving-on-up/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Site Migration</title>
		<link>http://corycollier.com/2007/12/site-migration/</link>
		<comments>http://corycollier.com/2007/12/site-migration/#comments</comments>
		<pubDate>Wed, 05 Dec 2007 02:26:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[hosting]]></category>
		<category><![CDATA[migration]]></category>
		<category><![CDATA[site]]></category>

		<guid isPermaLink="false">http://corycollier.com/?p=45</guid>
		<description><![CDATA[Crazy times, crazy times &#8230; I checked my bank account this weekend and found my host, A2Hosting, had charged me for a year&#8217;s worth of hosting earlier than I expected. I was initially upset, but after some digging, I found that they had tried to contact me before hand. Well, I canced my account and [...]]]></description>
			<content:encoded><![CDATA[<p>Crazy times, crazy times &#8230;</p>
<p>I checked my bank account this weekend and found my host, A2Hosting, had charged me for a year&#8217;s worth of hosting earlier than I expected. I was initially upset, but after some digging, I found that they had tried to contact me before hand.</p>
<p>Well, I canced my account and moved to a cheaper host anyways. I guess it really pays to keep up with even your most obscure email accounts, just in case you have something important going there!</p>
<p>The site has been down for a few days while I make the migration. Of course, it&#8217;s been tough to complete, since the world hasn&#8217;t slowed down for me to get things done. I&#8217;m still working on getting all of the content back up, so if you&#8217;re favorite content isn&#8217;t around, don&#8217;t despair: I&#8217;m getting it.</p>
]]></content:encoded>
			<wfw:commentRss>http://corycollier.com/2007/12/site-migration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

