<?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>*.hosting &#187; Kevin</title>
	<atom:link href="http://www.stardothosting.com/blog/author/admin/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.stardothosting.com/blog</link>
	<description>Star Dot Hosting : Technology, Security, Virtualization and Cloud Computing</description>
	<lastBuildDate>Wed, 16 May 2012 19:07:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Automated Amazon EBS snapshot backup script with 7 day retention</title>
		<link>http://www.stardothosting.com/blog/2012/05/16/automated-amazon-ebs-snapshot-backup-script-with-7-day-retention/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=automated-amazon-ebs-snapshot-backup-script-with-7-day-retention</link>
		<comments>http://www.stardothosting.com/blog/2012/05/16/automated-amazon-ebs-snapshot-backup-script-with-7-day-retention/#comments</comments>
		<pubDate>Wed, 16 May 2012 18:50:24 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[Amazon API]]></category>
		<category><![CDATA[Cloud Hosting]]></category>
		<category><![CDATA[Hosting]]></category>
		<category><![CDATA[Managed Hosting Services]]></category>
		<category><![CDATA[Managed VPS Hosting]]></category>
		<category><![CDATA[Shell Scripting]]></category>
		<category><![CDATA[amazon cloud]]></category>
		<category><![CDATA[amazon ebs]]></category>
		<category><![CDATA[amazon ebs snapshot]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[shell scripting]]></category>
		<category><![CDATA[systems administration]]></category>

		<guid isPermaLink="false">http://www.stardothosting.com/blog/?p=573</guid>
		<description><![CDATA[Hello there! We have recently been implementing several different backup strategies for properties that reside on the Amazon cloud platform. These strategies include scripts that incorporate s3sync and s3fs for offsite or redundant &#8220;limitless&#8221; backup storage capabilities. One of the more recent strategies we have implemented for several clients is an automated Amazon EBS volume [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2012%2F05%2F16%2Fautomated-amazon-ebs-snapshot-backup-script-with-7-day-retention%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2012%2F05%2F16%2Fautomated-amazon-ebs-snapshot-backup-script-with-7-day-retention%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Hello there!</p>
<p>We have recently been implementing several different backup strategies for properties that reside on the Amazon cloud platform.</p>
<p>These strategies include scripts that incorporate s3sync and s3fs for offsite or redundant &#8220;limitless&#8221; backup storage capabilities. One of the more recent strategies we have implemented for several clients is an automated Amazon EBS volume snapshot script that only keeps 7 day retention on all snapshot backups.</p>
<p>The script itself is fairly straightforward, but took several dry-runs in order to fine tune it so that it would reliably create the snapshots, but more importantly would clear out old snapshots older than 7 days. </p>
<p>You can see the for loop for deleting older snapshots. This is done by parsing snapshot dates, converting the dates to a pure numeric value and comparing said numeric value to a &#8220;7 days ago&#8221; date variable.</p>
<p>Take a look at the script below, hopefully it will be useful to you! There could be more error checking, but that should be fairly easy to do.</p>
<pre>
#!/bin/bash
# EBS Snapshot volume script
# Written by Star Dot Hosting
# www.stardothosting.com

# Constants
ec2_bin="/opt/aws/bin"
my_cert="/opt/aws/cert.txt"
my_key="/opt/aws/key.txt"
instance_id=`wget -q -O- http://169.254.169.254/latest/meta-data/instance-id`

# Dates
datecheck_7d=`date +%Y-%m-%d --date '7 days ago'`
datecheck_s_7d=`date --date="$datecheck_7d" +%s`

# Get all volume info and copy to temp file
$ec2_bin/ec2-describe-volumes -C $my_cert -K $my_key  --filter "attachment.instance-id=$instance_id" > /tmp/volume_info.txt 2>&#038;1

# Get all snapshot info
$ec2_bin/ec2-describe-snapshots -C $my_cert -K $my_key | grep "$instance_id" > /tmp/snap_info.txt 2>&#038;1

# Loop to remove any snapshots older than 7 days
for obj0 in $(cat /tmp/snap_info.txt)
do

        snapshot_name=`cat /tmp/snap_info.txt | grep "$obj0" | awk '{print $2}'`
        datecheck_old=`cat /tmp/snap_info.txt | grep "$snapshot_name" | awk '{print $5}' | awk -F "T" '{printf "%s\n", $1}'`
        datecheck_s_old=`date --date=$datecheck_old" +%s`

#       echo "snapshot name: $snapshot_name"
#       echo "datecheck 7d : $datecheck_7d"
#       echo "datecheck 7d s : $datecheck_s_7d"
#       echo "datecheck old s: $datecheck_s_old"

        if (( $datecheck_s_old <= $datecheck_s_7d ));
        then
                echo "deleting snapshot $snapshot_name ..."
                $ec2_bin/ec2-delete-snapshot -C $my_cert -K $my_key $snapshot_name
        else
                echo "not deleting snapshot $snapshot_name ..."

        fi

done

# Create snapshot
for volume in $(cat /tmp/volume_info.txt | grep "VOLUME" | awk '{print $2}')
do
        description="`hostname`_backup-`date +%Y-%m-%d`"
        echo "Creating Snapshot for the volume: $volume with description: $description"
        $ec2_bin/ec2-create-snapshot -C $my_cert -K $my_key -d $description $volume
done
</pre>
<p><a class="a2a_button_digg" href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2012%2F05%2F16%2Fautomated-amazon-ebs-snapshot-backup-script-with-7-day-retention%2F&amp;linkname=Automated%20Amazon%20EBS%20snapshot%20backup%20script%20with%207%20day%20retention" title="Digg" rel="nofollow" target="_blank"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2012%2F05%2F16%2Fautomated-amazon-ebs-snapshot-backup-script-with-7-day-retention%2F&amp;linkname=Automated%20Amazon%20EBS%20snapshot%20backup%20script%20with%207%20day%20retention" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_reddit" href="http://www.addtoany.com/add_to/reddit?linkurl=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2012%2F05%2F16%2Fautomated-amazon-ebs-snapshot-backup-script-with-7-day-retention%2F&amp;linkname=Automated%20Amazon%20EBS%20snapshot%20backup%20script%20with%207%20day%20retention" title="Reddit" rel="nofollow" target="_blank"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/icons/reddit.png" width="16" height="16" alt="Reddit"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2012%2F05%2F16%2Fautomated-amazon-ebs-snapshot-backup-script-with-7-day-retention%2F&amp;linkname=Automated%20Amazon%20EBS%20snapshot%20backup%20script%20with%207%20day%20retention" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_google_plusone addtoany_special_service" data-annotation="none" data-href="http://www.stardothosting.com/blog/2012/05/16/automated-amazon-ebs-snapshot-backup-script-with-7-day-retention/"></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2012%2F05%2F16%2Fautomated-amazon-ebs-snapshot-backup-script-with-7-day-retention%2F&amp;title=Automated%20Amazon%20EBS%20snapshot%20backup%20script%20with%207%20day%20retention" id="wpa2a_2"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.stardothosting.com/blog/2012/05/16/automated-amazon-ebs-snapshot-backup-script-with-7-day-retention/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Toronto Web Design : Shift8</title>
		<link>http://www.stardothosting.com/blog/2012/04/19/toronto-web-design-shift8/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=toronto-web-design-shift8</link>
		<comments>http://www.stardothosting.com/blog/2012/04/19/toronto-web-design-shift8/#comments</comments>
		<pubDate>Thu, 19 Apr 2012 19:26:19 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[Company Announcements]]></category>
		<category><![CDATA[shift8]]></category>
		<category><![CDATA[site relaunch]]></category>
		<category><![CDATA[toronto web design]]></category>
		<category><![CDATA[web design]]></category>

		<guid isPermaLink="false">http://www.stardothosting.com/blog/?p=570</guid>
		<description><![CDATA[Greetings, We are very proud to announce the full site redesign / relaunch of our toronto based web design partner Shift8 Web. They have done a fantastic job at redesigning their corporate website and we want all of you to check it out! Of course if you have a web design project and want a [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2012%2F04%2F19%2Ftoronto-web-design-shift8%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2012%2F04%2F19%2Ftoronto-web-design-shift8%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Greetings,</p>
<p>We are very proud to announce the full site redesign / relaunch of our toronto based web design partner <a href="http://www.shift8web.com" target="_new">Shift8 Web</a>.</p>
<p>They have done a fantastic job at redesigning their corporate website and we want all of you to check it out!</p>
<p>Of course if you have a web design project and want a good, reliable and attentive service, drop them a line or request a free quotation <img src='http://www.stardothosting.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><center><big><b><a href="http://www.shift8web.com" target="_new">Toronto Web Design : Shift8</a></b></big></center></p>
<p><a class="a2a_button_digg" href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2012%2F04%2F19%2Ftoronto-web-design-shift8%2F&amp;linkname=Toronto%20Web%20Design%20%3A%20Shift8" title="Digg" rel="nofollow" target="_blank"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2012%2F04%2F19%2Ftoronto-web-design-shift8%2F&amp;linkname=Toronto%20Web%20Design%20%3A%20Shift8" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_reddit" href="http://www.addtoany.com/add_to/reddit?linkurl=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2012%2F04%2F19%2Ftoronto-web-design-shift8%2F&amp;linkname=Toronto%20Web%20Design%20%3A%20Shift8" title="Reddit" rel="nofollow" target="_blank"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/icons/reddit.png" width="16" height="16" alt="Reddit"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2012%2F04%2F19%2Ftoronto-web-design-shift8%2F&amp;linkname=Toronto%20Web%20Design%20%3A%20Shift8" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_google_plusone addtoany_special_service" data-annotation="none" data-href="http://www.stardothosting.com/blog/2012/04/19/toronto-web-design-shift8/"></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2012%2F04%2F19%2Ftoronto-web-design-shift8%2F&amp;title=Toronto%20Web%20Design%20%3A%20Shift8" id="wpa2a_4"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.stardothosting.com/blog/2012/04/19/toronto-web-design-shift8/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Managed VPS hosting services from Star Dot Hosting</title>
		<link>http://www.stardothosting.com/blog/2012/02/15/managed-vps-hosting-services-from-star-dot-hosting/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=managed-vps-hosting-services-from-star-dot-hosting</link>
		<comments>http://www.stardothosting.com/blog/2012/02/15/managed-vps-hosting-services-from-star-dot-hosting/#comments</comments>
		<pubDate>Wed, 15 Feb 2012 21:49:09 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[Company Announcements]]></category>
		<category><![CDATA[Hosting]]></category>
		<category><![CDATA[Managed Hosting Services]]></category>
		<category><![CDATA[Managed VPS Hosting]]></category>
		<category><![CDATA[company announcements]]></category>
		<category><![CDATA[managd hosting services]]></category>
		<category><![CDATA[managed vps hosting]]></category>

		<guid isPermaLink="false">http://www.stardothosting.com/blog/?p=561</guid>
		<description><![CDATA[Click here for a free quote for managed vps hosting! Hello, I thought I&#8217;d update our blog to let everyone know that we offer our extensive managed services catalog on our VPS infrastructure! If you are looking for high quality managed services from systems administrators with extensive experience, then contact our sales department for a [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2012%2F02%2F15%2Fmanaged-vps-hosting-services-from-star-dot-hosting%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2012%2F02%2F15%2Fmanaged-vps-hosting-services-from-star-dot-hosting%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>
<center><big><b><a href="http://www.stardothosting.com/managed-hosting/" target="_new">Click here for a free quote for managed vps hosting!</a></b></big></center></p>
<p>Hello,</p>
<p>I thought I&#8217;d update our blog to let everyone know that we offer our extensive managed services catalog on our VPS infrastructure!</p>
<p>If you are looking for high quality managed services from systems administrators with extensive experience, then contact our sales department for a consultation / quotation!</p>
<p>Find below just a SAMPLE of some of the managed services we provide :</p>
<p><b><big>Support Services</b></big><br />
- 24/7/365 Technical Support (Ticketing system)<br />
- 24/7/365 Alert monitoring on-call rotation pager system<br />
- Online Customer Service Center 		</p>
<p><b><big>Linux Administration</b></big><br />
- Installs, reinstalls and updates<br />
- Trouble Shooting and configuration<br />
- Apache configuration, optimization &#038; Setup<br />
- Linux X64 installation, optimization and maintenance<br />
- Security optimizations<br />
- Proactive and reactive maintenance<br />
- Installs, reinstalls and updates<br />
- Trouble Shooting and configuration</p>
<p><b><big>Managed MySQL and MSSQL</b></big><br />
- MySQL and MS SQL first time install service<br />
- MySQL maintenance and troubleshooting</p>
<p><b><big>24/7/365 System Availability</b></big><br />
- Availability monitoring (Ping and Synthetic Transactions)<br />
- Performance monitoring of key server parameters<br />
- Graphing and trending		</p>
<p><b><big>Security Services</b></big><br />
- Routine Security Patching<br />
- Routine Security scanning and auditing<br />
- Penetration testing, SQL Injection<br />
- Quarterly security audit reporting<br />
- Dedicated hardware firewalls for all clients	</p>
<p><b><big>Hardware Maintenance</b></big><br />
- Hardware failure alerting and monitoring		</p>
<p><b><big>Offsite Backups</b></big><br />
- Remote off-site backups per 50gb nightly		</p>
<p>
<center><big><b><a href="http://www.stardothosting.com/managed-hosting/" target="_new">Click here for a free quote for managed vps hosting!</a></b></big></center></p>
<p><a class="a2a_button_digg" href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2012%2F02%2F15%2Fmanaged-vps-hosting-services-from-star-dot-hosting%2F&amp;linkname=Managed%20VPS%20hosting%20services%20from%20Star%20Dot%20Hosting" title="Digg" rel="nofollow" target="_blank"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2012%2F02%2F15%2Fmanaged-vps-hosting-services-from-star-dot-hosting%2F&amp;linkname=Managed%20VPS%20hosting%20services%20from%20Star%20Dot%20Hosting" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_reddit" href="http://www.addtoany.com/add_to/reddit?linkurl=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2012%2F02%2F15%2Fmanaged-vps-hosting-services-from-star-dot-hosting%2F&amp;linkname=Managed%20VPS%20hosting%20services%20from%20Star%20Dot%20Hosting" title="Reddit" rel="nofollow" target="_blank"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/icons/reddit.png" width="16" height="16" alt="Reddit"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2012%2F02%2F15%2Fmanaged-vps-hosting-services-from-star-dot-hosting%2F&amp;linkname=Managed%20VPS%20hosting%20services%20from%20Star%20Dot%20Hosting" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_google_plusone addtoany_special_service" data-annotation="none" data-href="http://www.stardothosting.com/blog/2012/02/15/managed-vps-hosting-services-from-star-dot-hosting/"></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2012%2F02%2F15%2Fmanaged-vps-hosting-services-from-star-dot-hosting%2F&amp;title=Managed%20VPS%20hosting%20services%20from%20Star%20Dot%20Hosting" id="wpa2a_6"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.stardothosting.com/blog/2012/02/15/managed-vps-hosting-services-from-star-dot-hosting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Massive Amazon Route53 API Bind Zone Import Script</title>
		<link>http://www.stardothosting.com/blog/2012/02/03/massive-amazon-route53-api-bind-zone-import-script/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=massive-amazon-route53-api-bind-zone-import-script</link>
		<comments>http://www.stardothosting.com/blog/2012/02/03/massive-amazon-route53-api-bind-zone-import-script/#comments</comments>
		<pubDate>Fri, 03 Feb 2012 16:39:31 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[Amazon API]]></category>
		<category><![CDATA[DNS]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Shell Scripting]]></category>
		<category><![CDATA[amazon]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[bind]]></category>
		<category><![CDATA[route53]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[systems administration]]></category>
		<category><![CDATA[systems automation]]></category>

		<guid isPermaLink="false">http://www.stardothosting.com/blog/?p=491</guid>
		<description><![CDATA[Hello there, Occasionally some of our managed services work has us dealing directly with other cloud providers such as Amazon. One of our clients set a requirement to migrate over 5,000 domain&#8217;s to Amazon&#8217;s Route53 DNS service. There was little doubt that this could be automated, but since we have never done this massive of [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2012%2F02%2F03%2Fmassive-amazon-route53-api-bind-zone-import-script%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2012%2F02%2F03%2Fmassive-amazon-route53-api-bind-zone-import-script%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Hello there,</p>
<p>Occasionally some of our managed services work has us dealing directly with other cloud providers such as Amazon. One of our clients set a requirement to migrate over 5,000 domain&#8217;s to Amazon&#8217;s Route53 DNS service. </p>
<p>There was little doubt that this could be automated, but since we have never done this massive of a deployment through Amazon&#8217;s API directly, we thought it might be interesting to post the process as well as the script through which we managed the import process.</p>
<p>Essentially the script utilizes a master domain name list file as its basis for looping through the import. The master list refers to the bind zone files and imports them into Amazon&#8217;s Route53 via the Cli53 tool package.</p>
<p>One final note, the script outputs all completed domain imports into a CSV file with the following format :</p>
<pre>
domain.com,ns1.nameserver.com,ns2.nameserver.com,ns3.nameserver.com,ns4.nameserver.com
</pre>
<p>This is because when facilitating the actual nameserver change request, all the nameservers assigned to domains when imported to Route53 are randomly generated, so the script has to keep track of these nameserver/domain associations.</p>
<p>The script isn&#8217;t perfect and could benefit from some optimizations and more error checking (it does a lot of error checking already, however), but here it is in its entirety. We hope you will have some use for it!</p>
<pre>
#!/bin/sh
# Import all zone files into amazon
# Star Dot Hosting 2012
# www.stardothosting.com

currentmonth=`date "+%Y-%m-%d"`

#sanitize input and verify input was given
command=`echo "$1" | sed 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`

if [ -z "$1" ];
then
        echo "AWS ZONE IMPORT"
        echo "---------------"
        echo ""
        echo "Usage : ./importzone.sh file.txt"
        echo ""
        exit 0
fi

echo "zone import log : $currentmonth" > /var/log/importzone.log 2>&#038;1
echo " " >> /var/log/importzone.log 2>&#038;1

for obj0 in $(cat $1);
do
        echo "checking if $obj0 was already migrated ..."
        ls -la /usr/local/zones/$1-zones/complete | grep -w $obj0 >> /dev/null 2>&#038;1
        if [ "$?" -eq 1 ]
        then
        echo "importing $obj0 ..."

        #check if zone file has NS records
        cat /usr/local/zones/$1-zones/$obj0.txt | grep NS >> /dev/null 2>&#038;1
        if [ "$?" -eq 0 ]
        then
                echo "Nameserver exists, continuing..."
        else
                echo "Adding nameserver to record..."
                echo "$obj0. 43201 IN NS ns1.nameserver.com." >> /usr/local/zones/$1-zones/$obj0.txt
        fi

        #check if zone exists
        /usr/local/zones/cli53/bin/cli53 info $obj0 >> /var/log/importzone.log 2>&#038;1
        if [ "$?" -eq 0 ]
        then
                # grab NAMESERVERS
                nameservers=`/usr/local/zones/cli53/bin/cli53 rrlist $obj0 | grep "NS" | awk -F "NS\t" '{printf "%s\n", $2}' | sed 's/.$/g' | sed ':a;N;$!ba;s/\n/,/g'`
   # import zone file
                /usr/local/zones/cli53/bin/cli53 import $obj0 -r -f /usr/local/zones/$1-zones/$obj0.txt
                if [ "$?" -eq 0 ]
                then
                        #move to complete folder
                        mv /usr/local/zones/$1-zones/$obj0.txt /usr/local/zones/$1-zones/complete
                else
                        echo "There was an error in importing the zone file!" >> /var/log/importzone.log
                        exit 1
                fi
        else
                #create on route53
                /usr/local/zones/cli53/bin/cli53 create $obj0 >> /var/log/importzone.log 2>&#038;1
                # grab NAMESERVERS
                nameservers=`/usr/local/zones/cli53/bin/cli53 rrlist $obj0 | grep "NS" | awk -F "NS\t" '{printf "%s\n", $2}' | sed 's/.$/g' | sed ':a;N;$!ba;s/\n/,/g'`
                # import zone file
                /usr/local/zones/cli53/bin/cli53 import $obj0 -r -f /usr/local/zones/$1-zones/$obj0.txt
                if [ "$?" -eq 0 ]
                then
                        #move to complete folder
                        mv /usr/local/zones/$1-zones/$obj0.txt /usr/local/zones/$1-zones/complete
                else
                        echo "There was an error in importing the zone file!" >> /var/log/importzone.log
                        exit 1
                fi
        fi

        # output domain + nameservers in a CSV with format : domain.com,ns1,ns2,ns3,ns4
        echo "$obj0,$nameservers" >> nameserver_registrar_request.txt 2&#038;>1
        else
                echo "Domain already migrated .. !"
        fi
done
</pre>
<p><a class="a2a_button_digg" href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2012%2F02%2F03%2Fmassive-amazon-route53-api-bind-zone-import-script%2F&amp;linkname=Massive%20Amazon%20Route53%20API%20Bind%20Zone%20Import%20Script" title="Digg" rel="nofollow" target="_blank"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2012%2F02%2F03%2Fmassive-amazon-route53-api-bind-zone-import-script%2F&amp;linkname=Massive%20Amazon%20Route53%20API%20Bind%20Zone%20Import%20Script" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_reddit" href="http://www.addtoany.com/add_to/reddit?linkurl=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2012%2F02%2F03%2Fmassive-amazon-route53-api-bind-zone-import-script%2F&amp;linkname=Massive%20Amazon%20Route53%20API%20Bind%20Zone%20Import%20Script" title="Reddit" rel="nofollow" target="_blank"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/icons/reddit.png" width="16" height="16" alt="Reddit"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2012%2F02%2F03%2Fmassive-amazon-route53-api-bind-zone-import-script%2F&amp;linkname=Massive%20Amazon%20Route53%20API%20Bind%20Zone%20Import%20Script" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_google_plusone addtoany_special_service" data-annotation="none" data-href="http://www.stardothosting.com/blog/2012/02/03/massive-amazon-route53-api-bind-zone-import-script/"></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2012%2F02%2F03%2Fmassive-amazon-route53-api-bind-zone-import-script%2F&amp;title=Massive%20Amazon%20Route53%20API%20Bind%20Zone%20Import%20Script" id="wpa2a_8"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.stardothosting.com/blog/2012/02/03/massive-amazon-route53-api-bind-zone-import-script/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Checking and repairing mysql replication automatically</title>
		<link>http://www.stardothosting.com/blog/2012/02/02/checking-and-repairing-mysql-replication-automatically/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=checking-and-repairing-mysql-replication-automatically</link>
		<comments>http://www.stardothosting.com/blog/2012/02/02/checking-and-repairing-mysql-replication-automatically/#comments</comments>
		<pubDate>Thu, 02 Feb 2012 17:15:02 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Hosting]]></category>
		<category><![CDATA[Shell Scripting]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[mysql replication]]></category>
		<category><![CDATA[systems administration]]></category>

		<guid isPermaLink="false">http://www.stardothosting.com/blog/?p=486</guid>
		<description><![CDATA[Hello! MySQL replication has been known to easily break, as a result of a large multitude of potential causes. Sometimes the replication can even break if an erroneous query is executed on the master server. With all the potential issues that may break replication, we thought it prudent to write an automated check script that [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2012%2F02%2F02%2Fchecking-and-repairing-mysql-replication-automatically%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2012%2F02%2F02%2Fchecking-and-repairing-mysql-replication-automatically%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Hello!</p>
<p>MySQL replication has been known to easily break, as a result of a large multitude of potential causes.</p>
<p>Sometimes the replication can even break if an erroneous query is executed on the master server.</p>
<p>With all the potential issues that may break replication, we thought it prudent to write an automated check script that can run on a scheduled basis (i.e. every 10-15 minutes), check the Slave status, report on any errors if applicable and attempt to repair replication.</p>
<p>We have built this script to exit and send mail alerts if any step of the checking and repairing process fails or generates an error in itself.</p>
<p>The script also generates a lock file to ensure that no more than one check process can run at any given time. We feel this script could be best used for scenarios for remote MySQL slaves, for example. Adding this extra layer may ensure a more reliable replication. </p>
<p>The repair process is simply 3 MySQL Commands :</p>
<pre>
stop slave;
reset slave;
slave start;
</pre>
<p>The above directives assume that you have a master.info with the mysql master server information statically set. No CHANGE MASTER commands have to be executed as a result. Resetting the slave clears the error and resumes replication, and all the queries missed during the time it failed should be queued and applied after it starts again.</p>
<p>Here is the script : </p>
<pre>
#!/bin/sh
# Slave replication auto recovery and alert
# Star Dot Hosting 2012

currentmonth=`date "+%Y-%m-%d"`
lock_file=/tmp/slave_alert.lck

echo "MySQL Replication Check Script" > /var/log/replication_check.log 2>&#038;1
echo "------------------------------" >> /var/log/replication_check.log 2>&#038;1
echo "$currentmonth" >> /var/log/replication_check.log 2>&#038;1
echo "" >> /var/log/replication_check.log 2>&#038;1

# Check if lock file exists
if [ -f $lock_file ];
then
        echo "Lock file exists! Possible conflict!" >> /var/log/replication_check.log 2>&#038;1
        mail_alert
        exit 1
else
        touch $lock_file
fi

# Fix slave
function fix_replication () {
        mysql -u root --password="XXXXX" -Bse "stop slave" >> /var/log/replication_check.log 2>&#038;1
        if [ "$?" -eq 0 ];
        then
                echo "Stop slave succeeded..." >> /var/log/replication_check.log 2>&#038;1
        else
                echo "Slave recover function failed" >> /var/log/replication_check.log 2>&#038;1
                mail_alert
                exit 1
        fi
        mysql -u root --password="XXXXX" -Bse "reset slave" >> /var/log/replication_check.log 2>&#038;1
        if [ "$?" -eq 0 ];
        then
                echo "Reset slave succeeded..." >> /var/log/replication_check.log 2>&#038;1
        else
                echo "Slave recover function failed" >> /var/log/replication_check.log 2>&#038;1
                mail_alert

                exit 1
        fi
        mysql -u root --password="XXXXX" -Bse "slave start" >> /var/log/replication_check.log 2>&#038;1
        if [ "$?" -eq 0 ];
        then
                echo "Slave start succeeded." >> /var/log/replication_check.log 2>&#038;1
        else
                echo "Slave recover function failed" >> /var/log/replication_check.log 2>&#038;1
                mail_alert
                exit 1
        fi
}

# Alert function
function mail_alert () {
        cat /var/log/replication_check.log | mail -s "Replication check errors!" kkutzko@n49.com
}

# Check if Slave is running properly
Slave_IO_Running=`mysql -u root --password="XXXXX" -Bse "show slave status\G" | grep Slave_IO_Running | awk '{ print $2 }'`
Slave_SQL_Running=`mysql -u root --password="XXXXX" -Bse "show slave status\G" | grep Slave_SQL_Running | awk '{ print $2 }'`
Last_error=`mysql -u root --password="XXXXX" -Bse "show slave status\G" | grep Last_error | awk -F \: '{ print $2 }'`

# If no values are returned, slave is not running
if [ -z $Slave_IO_Running -o -z $Slave_SQL_Running ];
then
        echo "Replication is not configured or you do not have the required access to MySQL"
        exit 1
fi

# If everythings running, remove lockfile if it exists and exit
if [ $Slave_IO_Running == 'Yes' ] &#038;&#038; [ $Slave_SQL_Running == 'Yes' ];
then
        rm $lock_file
        echo "Replication slave is running" >> /var/log/replication_check.log 2>&#038;1
        echo "Removed Alert Lock" >> /var/log/replication_check.log 2>&#038;1
elif [ $Slave_SQL_Running == 'No' ] || [ $Slave_IO_Running == 'No' ];
then
        echo "SQL thread not running on server `hostname -s`!" >> /var/log/replication_check.log 2>&#038;1
        echo "Last Error:" $Last_error >> /var/log/replication_check.log 2>&#038;1
        fix_replication
        mail_alert
        rm $lock_file
fi

echo "Script complete!" >> /var/log/replication_check.log 2>&#038;1
exit 0
</pre>
<p><a class="a2a_button_digg" href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2012%2F02%2F02%2Fchecking-and-repairing-mysql-replication-automatically%2F&amp;linkname=Checking%20and%20repairing%20mysql%20replication%20automatically" title="Digg" rel="nofollow" target="_blank"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2012%2F02%2F02%2Fchecking-and-repairing-mysql-replication-automatically%2F&amp;linkname=Checking%20and%20repairing%20mysql%20replication%20automatically" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_reddit" href="http://www.addtoany.com/add_to/reddit?linkurl=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2012%2F02%2F02%2Fchecking-and-repairing-mysql-replication-automatically%2F&amp;linkname=Checking%20and%20repairing%20mysql%20replication%20automatically" title="Reddit" rel="nofollow" target="_blank"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/icons/reddit.png" width="16" height="16" alt="Reddit"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2012%2F02%2F02%2Fchecking-and-repairing-mysql-replication-automatically%2F&amp;linkname=Checking%20and%20repairing%20mysql%20replication%20automatically" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_google_plusone addtoany_special_service" data-annotation="none" data-href="http://www.stardothosting.com/blog/2012/02/02/checking-and-repairing-mysql-replication-automatically/"></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2012%2F02%2F02%2Fchecking-and-repairing-mysql-replication-automatically%2F&amp;title=Checking%20and%20repairing%20mysql%20replication%20automatically" id="wpa2a_10"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.stardothosting.com/blog/2012/02/02/checking-and-repairing-mysql-replication-automatically/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Managed hosting services from Star Dot Hosting</title>
		<link>http://www.stardothosting.com/blog/2012/01/17/managed-hosting-services-from-star-dot-hosting/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=managed-hosting-services-from-star-dot-hosting</link>
		<comments>http://www.stardothosting.com/blog/2012/01/17/managed-hosting-services-from-star-dot-hosting/#comments</comments>
		<pubDate>Tue, 17 Jan 2012 14:36:51 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[Company Announcements]]></category>
		<category><![CDATA[company announcements]]></category>
		<category><![CDATA[managed hosting services]]></category>
		<category><![CDATA[star dot hosting]]></category>
		<category><![CDATA[stardothosting]]></category>

		<guid isPermaLink="false">http://blog.stardothosting.com/?p=481</guid>
		<description><![CDATA[Hello There, This update is to highlight the managed hosting services and systems administration services offered by Star Dot Hosting. We are proud to offer some of the highest standards of managed hosting services in the industry. Here are some of the services we offer : - 24x7x365 Monitoring, Alerting &#038; Trending - 24x7x365 ~15minute [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2012%2F01%2F17%2Fmanaged-hosting-services-from-star-dot-hosting%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2012%2F01%2F17%2Fmanaged-hosting-services-from-star-dot-hosting%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Hello There,</p>
<p>This update is to highlight the managed hosting services and systems administration services offered by Star Dot Hosting.</p>
<p>We are proud to offer some of the highest standards of managed hosting services in the industry. Here are some of the services we offer :</p>
<p>- 24x7x365 Monitoring, Alerting &#038; Trending<br />
- 24x7x365 ~15minute response time support ticketing system<br />
- Quarterly Security Auditing &#038; Reporting<br />
- Patch management &#038; Maintenance<br />
- Administration, troubleshooting, deployment and code pushes<br />
- Hardware upgrades, deployments, expansion<br />
- Dedicated load balancing<br />
- Dedicated firewalls<br />
- Database replication &#038; clustering<br />
- Dedicated edge content caching</p>
<p>Those are just some of the services we would provide to you! Our quotation process involves rigorous consultations which includes technology assessment and especially a complete understanding of how your scenario can be designed and where improvements can be made, if any.</p>
<p>Feel free to click the link below to visit our managed hosting page, and fill out a quotation request form! </p>
<p><center><br />
<a href="http://www.stardothosting.com/managed-hosting/" target="_new"><big><b>http://www.stardothosting.com/managed-hosting/</big></b></a><br />
</center></p>
<p><a class="a2a_button_digg" href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2012%2F01%2F17%2Fmanaged-hosting-services-from-star-dot-hosting%2F&amp;linkname=Managed%20hosting%20services%20from%20Star%20Dot%20Hosting" title="Digg" rel="nofollow" target="_blank"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2012%2F01%2F17%2Fmanaged-hosting-services-from-star-dot-hosting%2F&amp;linkname=Managed%20hosting%20services%20from%20Star%20Dot%20Hosting" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_reddit" href="http://www.addtoany.com/add_to/reddit?linkurl=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2012%2F01%2F17%2Fmanaged-hosting-services-from-star-dot-hosting%2F&amp;linkname=Managed%20hosting%20services%20from%20Star%20Dot%20Hosting" title="Reddit" rel="nofollow" target="_blank"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/icons/reddit.png" width="16" height="16" alt="Reddit"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2012%2F01%2F17%2Fmanaged-hosting-services-from-star-dot-hosting%2F&amp;linkname=Managed%20hosting%20services%20from%20Star%20Dot%20Hosting" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_google_plusone addtoany_special_service" data-annotation="none" data-href="http://www.stardothosting.com/blog/2012/01/17/managed-hosting-services-from-star-dot-hosting/"></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2012%2F01%2F17%2Fmanaged-hosting-services-from-star-dot-hosting%2F&amp;title=Managed%20hosting%20services%20from%20Star%20Dot%20Hosting" id="wpa2a_12"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.stardothosting.com/blog/2012/01/17/managed-hosting-services-from-star-dot-hosting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Backup, compress and encrpyt your git repository</title>
		<link>http://www.stardothosting.com/blog/2011/11/25/backup-compress-and-encrpyt-your-git-repository/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=backup-compress-and-encrpyt-your-git-repository</link>
		<comments>http://www.stardothosting.com/blog/2011/11/25/backup-compress-and-encrpyt-your-git-repository/#comments</comments>
		<pubDate>Fri, 25 Nov 2011 17:45:57 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[GIT]]></category>
		<category><![CDATA[Shell Scripting]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[git backup]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://blog.stardothosting.com/?p=471</guid>
		<description><![CDATA[Greetings, I thought I&#8217;d share a quick script in the scope of backing up GIT repositories for the purposes of encrypted and compressed off-site backups. Unfortunately git does not have an equivalent of svnadmin dump or export, which can conveniently be piped to stdout. What the above scenario would do is shorten the amount of [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2011%2F11%2F25%2Fbackup-compress-and-encrpyt-your-git-repository%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2011%2F11%2F25%2Fbackup-compress-and-encrpyt-your-git-repository%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Greetings,</p>
<p>I thought I&#8217;d share a quick script in the scope of backing up GIT repositories for the purposes of encrypted and compressed off-site backups.</p>
<p>Unfortunately git does not have an equivalent of svnadmin dump or export, which can conveniently be piped to stdout.</p>
<p>What the above scenario would do is shorten the amount of commands a script would require in order to accomplish a similar task.</p>
<p>Find below a quick bash script that clones a repository, tar/gzip&#8217;s it, encrypts the archive and keeps 7 days worth of archive files :</p>
<pre>
#!/bin/sh
# GIT Backup script
# Written by Star Dot Hosting

todaysdate=`date "+%Y-%m-%d"`

#check command input
if [ -z "$1" ];
then
        echo "GIT BACKUP SCRIPT"
        echo "-----------------"
        echo ""
        echo "Usage : ./backup.sh reponame , i.e. yourdomain.git"
        echo ""
        exit 0
fi

echo "GIT Backup Log: " $currentmonth > /var/log/backup.log
echo -e "----------------------------------------" >> /var/log/backup.log
echo -e "" >> /var/log/backup.log

# Find and remove files older than 7 days
/usr/bin/find /data/git/git-backups -type f -mtime +7 -delete >> /var/log/backup.log 2>&#038;1

# Begin creating working directory to clone into
/bin/mkdir /data/git/git-backup/working >> /var/log/backup.log 2>&#038;1
/usr/bin/git clone /data/git/$1 /data/git/git-backup/working >> /var/log/backup.log 2>&#038;1

# Archive working directory into repo name encrpyted tar file
/bin/tar -czvf - /data/git/git-backup/working | /usr/bin/openssl enc -aes-256-cbc -pass pass:abcABC123 -e | dd of=/data/git/git-backup/$1.tar.gz.enc >> /var/log/backup.log 2>&#038;1

# Remove working directory
/bin/rm -rf /data/git/git-backup/working >> /var/log/backup.log 2>&#038;1
</pre>
<p>FYI if you ever needed to decrypt the openssl encrypted backup archive, the command below should do the job :</p>
<pre>
openssl aes-256-cbc -d -pass pass:abcABC123 -in $1.tar.gz.enc -out decrypted.tar.gz
</pre>
<p><a class="a2a_button_digg" href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2011%2F11%2F25%2Fbackup-compress-and-encrpyt-your-git-repository%2F&amp;linkname=Backup%2C%20compress%20and%20encrpyt%20your%20git%20repository" title="Digg" rel="nofollow" target="_blank"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2011%2F11%2F25%2Fbackup-compress-and-encrpyt-your-git-repository%2F&amp;linkname=Backup%2C%20compress%20and%20encrpyt%20your%20git%20repository" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_reddit" href="http://www.addtoany.com/add_to/reddit?linkurl=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2011%2F11%2F25%2Fbackup-compress-and-encrpyt-your-git-repository%2F&amp;linkname=Backup%2C%20compress%20and%20encrpyt%20your%20git%20repository" title="Reddit" rel="nofollow" target="_blank"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/icons/reddit.png" width="16" height="16" alt="Reddit"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2011%2F11%2F25%2Fbackup-compress-and-encrpyt-your-git-repository%2F&amp;linkname=Backup%2C%20compress%20and%20encrpyt%20your%20git%20repository" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_google_plusone addtoany_special_service" data-annotation="none" data-href="http://www.stardothosting.com/blog/2011/11/25/backup-compress-and-encrpyt-your-git-repository/"></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2011%2F11%2F25%2Fbackup-compress-and-encrpyt-your-git-repository%2F&amp;title=Backup%2C%20compress%20and%20encrpyt%20your%20git%20repository" id="wpa2a_14"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.stardothosting.com/blog/2011/11/25/backup-compress-and-encrpyt-your-git-repository/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Clone a XEN VPS server that resides on a LVM / Logical Volume Manager</title>
		<link>http://www.stardothosting.com/blog/2011/08/25/clone-a-xen-vps-server-that-resides-on-a-lvm-logical-volume-manager/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=clone-a-xen-vps-server-that-resides-on-a-lvm-logical-volume-manager</link>
		<comments>http://www.stardothosting.com/blog/2011/08/25/clone-a-xen-vps-server-that-resides-on-a-lvm-logical-volume-manager/#comments</comments>
		<pubDate>Thu, 25 Aug 2011 20:38:35 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[Hosting]]></category>
		<category><![CDATA[Xen]]></category>
		<category><![CDATA[lvm]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[systems administration]]></category>
		<category><![CDATA[vps backup]]></category>
		<category><![CDATA[xen]]></category>
		<category><![CDATA[xen backup]]></category>

		<guid isPermaLink="false">http://blog.stardothosting.com/?p=467</guid>
		<description><![CDATA[Hello! We thought it would be important to share this information as it might be interesting to someone who wants to replicate the same VPS across many instances in order to create a farm of web servers (for example). This uses very similar concepts to our LVM XEN backup post a while back. Step 1: [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2011%2F08%2F25%2Fclone-a-xen-vps-server-that-resides-on-a-lvm-logical-volume-manager%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2011%2F08%2F25%2Fclone-a-xen-vps-server-that-resides-on-a-lvm-logical-volume-manager%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Hello!</p>
<p>We thought it would be important to share this information as it might be interesting to someone who wants to replicate the same VPS across many instances in order to create a farm of web servers (for example).</p>
<p>This uses very similar concepts to our <A href="http://blog.stardothosting.com/2010/03/19/how-to-backup-xen-with-logical-volume-mounts-works-with-hypervm-solusvm-fluidvm-and-more/">LVM XEN backup</a> post a while back.</p>
<p><big><b>Step 1: Take a snapshot of the current VPS</b></big></p>
<p>This is simple. Use the <b>lvcreate</b> command with the <b>-s</b> option to create a snapshot of the running VPS. We assume your VPS is 5GB in size, so just replace that with however large your VPS is :</p>
<pre>
lvcreate -s -L 5GB -n snapshot_name /dev/VolGroup00/running_vps_image
</pre>
<p><big><b>Step 2: Create your new VPS</b></big></p>
<p>This is important. You want to create a new vps, assign a MAC and IP address first and let the creation process fully finish. Then shut the VPS down.</p>
<p><big><b>Step 3: Copy the snapshot to the new VPS</b></big></p>
<p>All you have to do is use the <b>dd</b> command to transfer the snapshot image to the newly created VPS image :</p>
<pre>
dd if=/dev/VolGroup00/snapshot_name of=/dev/VolGroup00/new_vps_image
</pre>
<p>All done! Dont forget to remove the snapshot after your done with it :</p>
<pre>
lvremove -f /dev/VolGroup00/snapshot_name
</pre>
<p>Start up the new vps and you should have a carbon copy of the previous vps!</p>
<p><a class="a2a_button_digg" href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2011%2F08%2F25%2Fclone-a-xen-vps-server-that-resides-on-a-lvm-logical-volume-manager%2F&amp;linkname=Clone%20a%20XEN%20VPS%20server%20that%20resides%20on%20a%20LVM%20%2F%20Logical%20Volume%20Manager" title="Digg" rel="nofollow" target="_blank"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2011%2F08%2F25%2Fclone-a-xen-vps-server-that-resides-on-a-lvm-logical-volume-manager%2F&amp;linkname=Clone%20a%20XEN%20VPS%20server%20that%20resides%20on%20a%20LVM%20%2F%20Logical%20Volume%20Manager" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_reddit" href="http://www.addtoany.com/add_to/reddit?linkurl=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2011%2F08%2F25%2Fclone-a-xen-vps-server-that-resides-on-a-lvm-logical-volume-manager%2F&amp;linkname=Clone%20a%20XEN%20VPS%20server%20that%20resides%20on%20a%20LVM%20%2F%20Logical%20Volume%20Manager" title="Reddit" rel="nofollow" target="_blank"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/icons/reddit.png" width="16" height="16" alt="Reddit"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2011%2F08%2F25%2Fclone-a-xen-vps-server-that-resides-on-a-lvm-logical-volume-manager%2F&amp;linkname=Clone%20a%20XEN%20VPS%20server%20that%20resides%20on%20a%20LVM%20%2F%20Logical%20Volume%20Manager" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_google_plusone addtoany_special_service" data-annotation="none" data-href="http://www.stardothosting.com/blog/2011/08/25/clone-a-xen-vps-server-that-resides-on-a-lvm-logical-volume-manager/"></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2011%2F08%2F25%2Fclone-a-xen-vps-server-that-resides-on-a-lvm-logical-volume-manager%2F&amp;title=Clone%20a%20XEN%20VPS%20server%20that%20resides%20on%20a%20LVM%20%2F%20Logical%20Volume%20Manager" id="wpa2a_16"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.stardothosting.com/blog/2011/08/25/clone-a-xen-vps-server-that-resides-on-a-lvm-logical-volume-manager/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux VPS, Virtual Hosting, XEN VPS Hosting, CPanel VPS Hosting or Managed Hosting Services</title>
		<link>http://www.stardothosting.com/blog/2011/08/16/linux-vps-virtual-hosting-xen-vps-hosting-cpanel-vps-hosting-or-managed-hosting-services/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=linux-vps-virtual-hosting-xen-vps-hosting-cpanel-vps-hosting-or-managed-hosting-services</link>
		<comments>http://www.stardothosting.com/blog/2011/08/16/linux-vps-virtual-hosting-xen-vps-hosting-cpanel-vps-hosting-or-managed-hosting-services/#comments</comments>
		<pubDate>Tue, 16 Aug 2011 07:13:26 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[Company Announcements]]></category>
		<category><![CDATA[Hosting]]></category>
		<category><![CDATA[linux vps]]></category>
		<category><![CDATA[managed hosting services]]></category>
		<category><![CDATA[star dot hosting]]></category>
		<category><![CDATA[vps hosting]]></category>
		<category><![CDATA[web hosting]]></category>
		<category><![CDATA[xen vps]]></category>

		<guid isPermaLink="false">http://blog.stardothosting.com/?p=462</guid>
		<description><![CDATA[Hey there, Before I update regarding my continued experiences with Xen, KVM, Varnish, FreeBSD and all the other (exciting) things that I do, I thought I&#8217;d remind anyone here who is looking for linux vps hosting, virtual hosting or specifically xen vps hosting or even cpanel vps hosting to check out our company website : [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2011%2F08%2F16%2Flinux-vps-virtual-hosting-xen-vps-hosting-cpanel-vps-hosting-or-managed-hosting-services%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2011%2F08%2F16%2Flinux-vps-virtual-hosting-xen-vps-hosting-cpanel-vps-hosting-or-managed-hosting-services%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Hey there,</p>
<p>Before I update regarding my continued experiences with Xen, KVM, Varnish, FreeBSD and all the other (exciting) things that I do, I thought I&#8217;d remind anyone here who is looking for linux vps hosting, virtual hosting or specifically xen vps hosting or even cpanel vps hosting to check out our company website : <a href="http://www.stardothosting.com" target="_new">www.stardothosting.com</a></p>
<p>If you&#8217;re looking for managed hosting services, dedicated hosting or anything along those lines, feel free to fill out our managed hosting quotation form here : <a href="http://www.stardothosting.com/managed-hosting/" target="_new">www.stardothosting.com/managed-hosting</a></p>
<p>Thanks!</p>
<p><a class="a2a_button_digg" href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2011%2F08%2F16%2Flinux-vps-virtual-hosting-xen-vps-hosting-cpanel-vps-hosting-or-managed-hosting-services%2F&amp;linkname=Linux%20VPS%2C%20Virtual%20Hosting%2C%20XEN%20VPS%20Hosting%2C%20CPanel%20VPS%20Hosting%20or%20Managed%20Hosting%20Services" title="Digg" rel="nofollow" target="_blank"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2011%2F08%2F16%2Flinux-vps-virtual-hosting-xen-vps-hosting-cpanel-vps-hosting-or-managed-hosting-services%2F&amp;linkname=Linux%20VPS%2C%20Virtual%20Hosting%2C%20XEN%20VPS%20Hosting%2C%20CPanel%20VPS%20Hosting%20or%20Managed%20Hosting%20Services" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_reddit" href="http://www.addtoany.com/add_to/reddit?linkurl=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2011%2F08%2F16%2Flinux-vps-virtual-hosting-xen-vps-hosting-cpanel-vps-hosting-or-managed-hosting-services%2F&amp;linkname=Linux%20VPS%2C%20Virtual%20Hosting%2C%20XEN%20VPS%20Hosting%2C%20CPanel%20VPS%20Hosting%20or%20Managed%20Hosting%20Services" title="Reddit" rel="nofollow" target="_blank"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/icons/reddit.png" width="16" height="16" alt="Reddit"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2011%2F08%2F16%2Flinux-vps-virtual-hosting-xen-vps-hosting-cpanel-vps-hosting-or-managed-hosting-services%2F&amp;linkname=Linux%20VPS%2C%20Virtual%20Hosting%2C%20XEN%20VPS%20Hosting%2C%20CPanel%20VPS%20Hosting%20or%20Managed%20Hosting%20Services" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_google_plusone addtoany_special_service" data-annotation="none" data-href="http://www.stardothosting.com/blog/2011/08/16/linux-vps-virtual-hosting-xen-vps-hosting-cpanel-vps-hosting-or-managed-hosting-services/"></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2011%2F08%2F16%2Flinux-vps-virtual-hosting-xen-vps-hosting-cpanel-vps-hosting-or-managed-hosting-services%2F&amp;title=Linux%20VPS%2C%20Virtual%20Hosting%2C%20XEN%20VPS%20Hosting%2C%20CPanel%20VPS%20Hosting%20or%20Managed%20Hosting%20Services" id="wpa2a_18"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.stardothosting.com/blog/2011/08/16/linux-vps-virtual-hosting-xen-vps-hosting-cpanel-vps-hosting-or-managed-hosting-services/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Varnish Caching with Joomla</title>
		<link>http://www.stardothosting.com/blog/2011/08/08/varnish-caching-with-joomla/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=varnish-caching-with-joomla</link>
		<comments>http://www.stardothosting.com/blog/2011/08/08/varnish-caching-with-joomla/#comments</comments>
		<pubDate>Mon, 08 Aug 2011 21:05:50 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[Hosting]]></category>
		<category><![CDATA[Load Balancing]]></category>
		<category><![CDATA[Varnish Cache]]></category>
		<category><![CDATA[joomla]]></category>
		<category><![CDATA[systems administration]]></category>
		<category><![CDATA[varnish cache]]></category>
		<category><![CDATA[varnish joomla]]></category>

		<guid isPermaLink="false">http://blog.stardothosting.com/?p=437</guid>
		<description><![CDATA[Hello There! One of the exciting new technologies to come out in the last few years is a tremendously efficient and dynamic caching system called Varnish (see : http://www.varnish-cache.org). We have been employing the use of Varnish for high traffic websites for the purposes of user experience improvements as well as for redundancy and load [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2011%2F08%2F08%2Fvarnish-caching-with-joomla%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2011%2F08%2F08%2Fvarnish-caching-with-joomla%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Hello There!</p>
<p>One of the exciting new technologies to come out in the last few years is a tremendously efficient and dynamic caching system called Varnish (see : <a href="http://www.varnish-cache.org" target="_new">http://www.varnish-cache.org</a>).</p>
<p>We have been employing the use of Varnish for high traffic websites for the purposes of user experience improvements as well as for redundancy and load balancing purposes.</p>
<p>Varnish can do it all &#8211; complex load balancing and polling based on many different weighting methodologies for fail over, as well as holding on to a &#8220;stale&#8221; cache in the event of a back end web server outage, or perhaps for geographic redundancy (holding a stale cache in a secondary data center).</p>
<p>One of the challenges we have faced in the many different implementations of varnish into web stacks, is dealing with dynamic and user session (i.e. &#8220;logged in&#8221;) content. </p>
<p>If the Internet was full of only static (see 1995) html files, varnish would work beautifully out of the box. Unfortunately the web is a complicated mess of session based authentication, POSTS, GETS and query strings among a few things.</p>
<p>One of our recent accomplishments was getting the Joomla 1.5 content management system to work with Varnish 2.1.</p>
<p>The biggest challenge for Joomla was that it creates a session cookie for all users. This means the session is created and established for any guest visiting the site, and if they decide to log in , that same session is used to establish a logged in session through authentication. This is an apparent effort to deter or avoid session hijacking.</p>
<p>The problem with this is that Varnish ends up caching all the logged in session content, as well as the anonymous front page content. </p>
<p>I spent a significant amount of time fine tuning my VCL (varnish configuration language) to play nice with Joomla. Unfortunately it became apparent that some minor modifications to the Joomla code was necessary in order for it to communicate properly with Varnish.</p>
<p><big><u><b>Step 1 : Move the login form off the front page</big></u></b></p>
<p>I realize this might be a hard decision. I cant offer an alternative. If you have an integrated login form on the front page of your site, and you wish to cache that page with varnish, you will likely have to chose one or the other. It would probably be ideal to replace that login form with a button to bring the user to a secondary page off the main page. </p>
<p>For the sake of argument, lets call our site &#8220;example.com&#8221; and the login page url within Joomla should look like the following :</p>
<p><b>http://www.example.com/index.php?option=com_user&#038;view=login</b></p>
<p>Take note of <b>login</b> URI in this string.</p>
<p>The reason we need the login form on a secondary page is because we need an almost &#8220;sandboxed&#8221; section of the site where the anonymous session cookie can be established, and passed through the authentication process to a logged in session. We will tell varnish to essentially ignore this page.</p>
<p><big><u><b>Step 2 : Modify Joomla to send HTTP headers for user/guest sessions</big></u></b></p>
<p>This isn&#8217;t that hard. In the Joomla code, there is a section where it defines the HTTP headers it sends to the browser for cache variables such as expire times and whatnot. I&#8217;m going to assume you have turned off the built-in Joomla caching system. </p>
<p>What you need to do is tell Joomla to send a special HTTP header that will give either a True or False value if the user is logged in or not. This is useful information. It will allow varnish to not cache any logged in content such as &#8220;Welcome back, USERNAME&#8221; after the user is passed back to the front page from logging in.</p>
<p>In my joomla installation, I modified the following file :</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">libraries/joomla/environment/response.php</div></div>
<p>The parent folder being the public_html / root folder for your Joomla installation. In this file, please find the line that determines if the Joomla caching system is disabled :</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">if (JResponse::allowCache() === false)</div></div>
<p>After this line, you will see about 5 HTTP header declarations (expires, last-modified, cache-control, cache-control again and pragma). Above those declarations , add the following 6 lines of code :</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$user =&amp; JFactory::getUser();<br />
if (!$user-&gt;guest) {<br />
JResponse::setHeader( 'X-Logged-In', 'True', true);<br />
} else {<br />
JResponse::setHeader( 'X-Logged-In', 'False', true );<br />
}</div></div>
<p>If you read the above code, its fairly straight forward. I do a check to see if the user is a guest (aka anonymous) or not. If they are logged in I send an HTTP header called &#8220;X-Logged-In&#8221;, and assign a &#8220;True&#8221; value to it. If the user is not logged in, it sets it to &#8220;False&#8221;.</p>
<p>Pretty easy, right?</p>
<p>This will allow varnish to avoid caching a logged in user&#8217;s page.</p>
<p><big><u><b>Step 3 : Configure Varnish</big></u></b></p>
<p>This is the part that took the most time during this entire process. Mind you patching the Joomla code and whatnot took some time as well, this process took a lot of experimentation and long hours examining session cookies and host headers. </p>
<p>What I will do is break down the generalized configuration directives into two groups : VCL_RECV and VCL_FETCH.</p>
<p><big><b>VCL_RECV</big></b></p>
<p>In here, I set a bunch of IF statement directives to tell varnish what it should look up in the cache and what it should pipe to the backend and what it should pass. This could probably be optimized and improved upon, but it works for me :</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"># If user sends an http POST, pipe to backend<br />
if (req.request == &quot;POST&quot;) {<br />
set req.backend = iamloggedin;<br />
return(pipe);<br />
}<br />
<br />
# http authenticated sessions are piped<br />
if (req.http.Authenticate || req.http.Authorization) {<br />
set req.backend = iamloggedin;<br />
return(pipe);<br />
}<br />
<br />
# if the user is coming FROM the login page, pipe to backend <br />
if (req.http.referer ~ &quot;(?i)(com_user|login)&quot;) {<br />
set req.backend = iamloggedin;<br />
return(pipe);<br />
}</div></div>
<p><big><b>VCL_FETCH</big></b></p>
<p>The fetch section is a little bit easier. I only have about 5 directives. The first one is the most important one you want to look at. It &#8220;unsets&#8221; the cookie from any page on the site, EXCEPT the login page. This allows varnish to properly establish the logged in session. The subsequent rules determine what to deliver and what to pass based on URI or HTTP header checks :</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"># discard backend setcookie unless it equals the following<br />
if (!req.url ~ &quot;(?i)(login|com_user|user|logout)&quot;) {<br />
unset beresp.http.Set-Cookie;<br />
}<br />
<br />
if (req.http.referer ~ &quot;(?i)(com_user|login|logout)&quot;) {<br />
set req.backend = iamloggedin;<br />
return(pass);<br />
}<br />
<br />
if (beresp.http.x-logged-in ~ &quot;False&quot;){<br />
set req.backend = webfarm;<br />
return(deliver);<br />
}<br />
<br />
if (beresp.http.x-logged-in ~ &quot;True&quot;){<br />
set req.backend = iamloggedin;<br />
return(pass);<br />
}<br />
<br />
if (req.http.Authenticate || req.http.Authorization) {<br />
set req.backend = iamloggedin;<br />
return(pass);<br />
}</div></div>
<p>Thats it! I just saved you many sleepless nights (I hope!). Hopefully your headers will look something like this after you implement varnish in front of Joomla :</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Set-Cookie&nbsp; example_auth_129bf15asdfasdf52f3afaafawef; path=/<br />
P3P CP=&quot;NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM&quot;<br />
X-Logged-In False<br />
Expires Mon, 1 Jan 2001 00:00:00 GMT<br />
Last-Modified &nbsp; Mon, 08 Aug 2011 20:49:37 GMT<br />
Cache-Control &nbsp; post-check=0, pre-check=0<br />
Pragma&nbsp; no-cache<br />
Content-Type&nbsp; &nbsp; text/html; charset=utf-8<br />
Content-Length&nbsp; 85898<br />
Date&nbsp; &nbsp; Mon, 08 Aug 2011 21:01:52 GMT<br />
X-Varnish &nbsp; 761778669 761751685<br />
Age 735<br />
Via 1.1 varnish<br />
Connection&nbsp; keep-alive<br />
X-Cache-Svr cache.example.com<br />
X-Cache HIT<br />
X-Cache-Hits&nbsp; &nbsp; 121</div></div>
<p><b><big><u>UPDATE : 12/08/2011</b></big></u></p>
<p>I realize I made a mistake and have corrected this post. In vcl_fetch, i had the following :</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"># discard backend setcookie unless it equals the following<br />
if (!req.url ~ &quot;(?i)(login|com_user|user|logout)&quot;) {<br />
unset req.http.Set-Cookie;<br />
}</div></div>
<p>Well I realize I should be unsetting the response cookie, not the set cookie. For some reason, the above (erroneous) directive works only right after you login. If you start clicking around the site, your logged in session disappears. I suspect this is because either joomla or varnish is mistakenly unsetting a logged in session.</p>
<p>This is the correct entry (I have fixed it in my original post as well) :</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"># discard backend setcookie unless it equals the following<br />
if (!req.url ~ &quot;(?i)(login|com_user|user|logout)&quot;) {<br />
unset beresp.http.Set-Cookie;<br />
}</div></div>
<p>After making the above change, I can login and browse the site and my session stays intact. Mind you, the Joomla site I am testing with is definitely not a vanilla Joomla installation. </p>
<p>I&#8217;d love to hear from anyone who has accomplished the above scenario either way!</p>
<p><a class="a2a_button_digg" href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2011%2F08%2F08%2Fvarnish-caching-with-joomla%2F&amp;linkname=Varnish%20Caching%20with%20Joomla" title="Digg" rel="nofollow" target="_blank"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2011%2F08%2F08%2Fvarnish-caching-with-joomla%2F&amp;linkname=Varnish%20Caching%20with%20Joomla" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_reddit" href="http://www.addtoany.com/add_to/reddit?linkurl=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2011%2F08%2F08%2Fvarnish-caching-with-joomla%2F&amp;linkname=Varnish%20Caching%20with%20Joomla" title="Reddit" rel="nofollow" target="_blank"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/icons/reddit.png" width="16" height="16" alt="Reddit"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2011%2F08%2F08%2Fvarnish-caching-with-joomla%2F&amp;linkname=Varnish%20Caching%20with%20Joomla" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_google_plusone addtoany_special_service" data-annotation="none" data-href="http://www.stardothosting.com/blog/2011/08/08/varnish-caching-with-joomla/"></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.stardothosting.com%2Fblog%2F2011%2F08%2F08%2Fvarnish-caching-with-joomla%2F&amp;title=Varnish%20Caching%20with%20Joomla" id="wpa2a_20"><img src="http://www.stardothosting.com/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.stardothosting.com/blog/2011/08/08/varnish-caching-with-joomla/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

