<?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>FiddyP &#187; backup</title>
	<atom:link href="http://fiddyp.co.uk/tag/backup/feed/" rel="self" type="application/rss+xml" />
	<link>http://fiddyp.co.uk</link>
	<description>The personal blog of Andy Bailey</description>
	<lastBuildDate>Tue, 17 Jan 2012 09:02:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Configuring Hostgator VPS for automated CPanel backups to Amazon S3</title>
		<link>http://fiddyp.co.uk/cpanel-backups-to-amazon-s3/</link>
		<comments>http://fiddyp.co.uk/cpanel-backups-to-amazon-s3/#comments</comments>
		<pubDate>Sun, 04 Sep 2011 13:08:44 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Blog Tools]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[amazon]]></category>
		<category><![CDATA[automated]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[cpanel]]></category>
		<category><![CDATA[hostgator]]></category>
		<category><![CDATA[profit]]></category>
		<category><![CDATA[whm]]></category>

		<guid isPermaLink="false">http://fiddyp.co.uk/?p=2005</guid>
		<description><![CDATA[Warning! Geekiness ahead Ok, so just had a wonderful time trying to set up a way to automatically backup my hostgator VPS to Amazon S3. I did it [..]]]></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%2Ffiddyp.co.uk%2Fcpanel-backups-to-amazon-s3%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Ffiddyp.co.uk%2Fcpanel-backups-to-amazon-s3%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><img src="http://fiddyp.co.uk/wp-content/uploads/cpanel-to-amazon-s3.png" alt="" title="cpanel-to-amazon-s3" width="275" height="126" class="aligncenter size-full wp-image-2006" /></p>
<h2>Warning! Geekiness ahead</h2>
<p>Ok, so just had a wonderful time trying to set up a way to automatically backup my hostgator VPS to Amazon S3.</p>
<p>I did it with the help of some googling, head scratching and tricky bastardness so I thought I&#8217;d better document it here to remind me how to do it when I need to do it again.</p>
<p>I got most of the information from the <a href="http://jackal777.wordpress.com/2011/03/22/cpanel-backup-to-amazon-s3/">post here</a> and in the comments. Although, I had to piss about a lot to get it finally working. Mainly because of curly quotes in the original page, windoze line breaks and my monkey heritage.</p>
<p>(this is for VPS on Hostgator running Centos 5)</p>
<h2>1. Create AmazonS3 bucket</h2>
<p>Easy bit here, just create a bucket</p>
<h2>2. Install S3 client for Linux</h2>
<p>First need to install s3tools repo</p>
<pre class="brush: plain; title: ; notranslate">cd /etc/yum.repos.d
wget http://s3tools.org/repo/CentOS_5/s3tools.repo</pre>
<p>Next need to install</p>
<pre class="brush: plain; title: ; notranslate">yum install s3cmd</pre>
<p>Answer the questions with Y</p>
<h2>3. Configure s3cmd</h2>
<pre class="brush: plain; title: ; notranslate">s3cmd --configure</pre>
<p>Enter in the access key and secret key from Amazon Security Credentials</p>
<h2>4. Enable daily backups from WHM</h2>
<p>You can select which accounts by clicking the button marked &#8216;select&#8217;<br />
<a href="http://fiddyp.co.uk/wp-content/uploads/whm-backup-configure.png"><img src="http://fiddyp.co.uk/wp-content/uploads/whm-backup-configure-300x250.png" alt="" title="whm-backup-configure" width="300" height="250" class="aligncenter size-medium wp-image-2009" /></a><br />
If it&#8217;s already configured, find out the backup directory by typing</p>
<pre class="brush: plain; title: ; notranslate">grep BACKUPDIR /etc/cpbackup.conf</pre>
<h2>5. Create the log directories</h2>
<pre class="brush: plain; title: ; notranslate">mkdir /var/log/backuplogs</pre>
<h2>6. Write a script to automate the backup and save it as /root/dailybackup.sh</h2>
<p>You should change the email and bucket name to reflect your own values</p>
<pre class="brush: plain; title: ; notranslate">
#!/bin/bash

##Notification email address
_EMAIL=youremail@yourdomain.com

ERRORLOG=/var/log/backuplogs/backup.err`date +%F`
ACTIVITYLOG=/var/log/backuplogs/activity.log`date +%F`

##Directory which needs to be backed up
SOURCE=/backup/cpbackup/daily/*.gz

##Name of the backup in bucket
DESTINATION=`date +%F`

##Backup degree
DEGREE=3

#Clear the logs if the script is executed second time
:&gt; ${ERRORLOG}
:&gt; ${ACTIVITYLOG}

##Uploading the daily backup to Amazon s3
/usr/bin/s3cmd -r put ${SOURCE} s3://yourbucketname/${DESTINATION}/ 1&gt;&gt;${ACTIVITYLOG} 2&gt;&gt;${ERRORLOG}
ret2=$?

##Sent email alert
msg=&quot;BACKUP NOTIFICATION ALERT FROM `hostname`&quot;

if [ $ret2 -eq 0 ];then
msg1=&quot;Amazon s3 Backup Uploaded Successfully&quot;
else
msg1=&quot;Amazon s3 Backup Failed!!\n Check ${ERRORLOG} for more details&quot;
fi
echo -e &quot;$msg1&quot;|mail -s &quot;$msg&quot; ${_EMAIL}

#######################
##Deleting backup’s older than DEGREE days
## Delete from both server and amazon
#######################
DELETENAME=$(date --date=&quot;${DEGREE} days ago&quot; +%F)

/usr/bin/s3cmd -r --force del s3://yourbucketname/${DELETENAME} 1&gt;&gt;${ACTIVITYLOG} 2&gt;&gt;${ERRORLOG}
</pre>
<h2>7. Grant execute privilege to the script</h2>
<pre class="brush: plain; title: ; notranslate">chmod u+x /root/dailybackup.sh</pre>
<h2>8. Set up a cpanel hook to run the script after the backup has completed</h2>
<pre class="brush: plain; title: ; notranslate">nano /scripts/postcpbackup</pre>
<p>enter this as the contents</p>
<pre class="brush: plain; title: ; notranslate">#!/usr/bin/perl
system(&quot;/root/dailybackup.sh&quot;);</pre>
<p>make it executable</p>
<pre class="brush: plain; title: ; notranslate">chmod u+x /scripts/postcpbackup</pre>
<h2>That&#8217;s it!</h2>
<p>In case of disaster, copy the file from Amazon s3 with</p>
<pre class="brush: plain; title: ; notranslate">mkdir restore
s3cmd -r get s3://yourbucketname/2011-02-32/filename.gz restore</pre>
<p><strong>Notes</strong><br />
I changed the bash script so it only copies *.gz files<br />
I wanted to change the time at which the cpbackup occurs so I went to &#8216;manage plugins&#8217; in WHM and put &#8216;install and keep udpated&#8217; tick on &#8216;cronconfig&#8217; and then went to &#8216;configure cpanel cron times&#8217; and set the time I wanted cpbackup to run.</p>
]]></content:encoded>
			<wfw:commentRss>http://fiddyp.co.uk/cpanel-backups-to-amazon-s3/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>Never lose your source code, ever!</title>
		<link>http://fiddyp.co.uk/never-lose-your-source-code-ever/</link>
		<comments>http://fiddyp.co.uk/never-lose-your-source-code-ever/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 00:35:57 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Blog Tools]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[automatic]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[dropbox]]></category>
		<category><![CDATA[online]]></category>
		<category><![CDATA[profit]]></category>
		<category><![CDATA[recover]]></category>
		<category><![CDATA[revisions]]></category>
		<category><![CDATA[storage]]></category>

		<guid isPermaLink="false">http://fiddyp.co.uk/?p=1611</guid>
		<description><![CDATA[Twice. In 1 week. I lost my code and my awesome plugin edits when my hard drive crashed, I started writing it again and I formatted the wrong [..]]]></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%2Ffiddyp.co.uk%2Fnever-lose-your-source-code-ever%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Ffiddyp.co.uk%2Fnever-lose-your-source-code-ever%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Twice. In 1 week.</p>
<p>I lost my code and my awesome plugin edits when my hard drive crashed, I started writing it again and I formatted the wrong partition. Seriously gutted! I tried to recover the data with undelete apps but it was gone forever.</p>
<p><a href="http://ql2.me/1/dropbox/"><img src="http://fiddyp.co.uk/wp-content/uploads/2010/03/logo.png" alt="" title="DropBox" width="231" height="60" class="aligncenter size-full wp-image-1612" /></a></p>
<h2>No worry no more!</h2>
<p>Now, I don&#8217;t need to worry because I use <a href="http://ql2.me/1/dropbox/">Dropbox</a> and have configured my local server to use it as the document_root of my dev site. That way, all the developing work I&#8217;m doing gets saved automatically online and is accessible on any of my pc&#8217;s.</p>
<p>I don&#8217;t even need to worry about being able to access the SAMBA share if I want to edit a file, I just open it from my dropbox on the pc I&#8217;m using and save it back there, it&#8217;ll get automatically updated on my dev server.</p>
<p><a href="http://ql2.me/1/dropbox/"><img src="http://fiddyp.co.uk/wp-content/uploads/2010/03/dropboxrevisions.png" alt="" title="dropboxrevisions" width="418" height="452" class="aligncenter size-full wp-image-1615" /></a></p>
<h2>Oops no more!</h2>
<p>Another advantage is the revisions feature. You can go online and see the updates that you made to a file and revert it back to an earlier save. This has already saved me from crying, I always forget to rename a file before I start trying to add updates and before I know it, the whole thing is causing an error and I can&#8217;t remember how to put it back the way it was! just luvin the revision feature!!</p>
<h2>Get 2GB for FREE! (and help me out)</h2>
<p>You can apply for a Dropbox for FREE and get a full 2GB to use to store anything from simple documents to executable files to database backups or like me, use it as your code repository and never go through the pain of a lost bit of awesome code again!</p>
<p>You can even install it on Linux which is super helpful when it comes to transferring files between a windows->linux network. </p>
<p>If you <a href="http://ql2.me/1/dropbox">click this link</a> and install your dropbox for free, we both get extra bonus space which would help me out a lot <img src='http://fiddyp.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://fiddyp.co.uk/never-lose-your-source-code-ever/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>OMG I just formatted my server!</title>
		<link>http://fiddyp.co.uk/omg-i-just-formatted-my-server/</link>
		<comments>http://fiddyp.co.uk/omg-i-just-formatted-my-server/#comments</comments>
		<pubDate>Tue, 11 Mar 2008 22:56:02 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Blog News]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[dedicated server]]></category>
		<category><![CDATA[profit]]></category>

		<guid isPermaLink="false">http://www.fiddyp.co.uk/omg-i-just-formatted-my-server/</guid>
		<description><![CDATA[I can&#8217;t believe what I just did&#8230;.. I mistakenly restored an old backup of fiddyp&#8230; grrrrr. I have just moved to a dedicated server and its really helped [..]]]></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%2Ffiddyp.co.uk%2Fomg-i-just-formatted-my-server%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Ffiddyp.co.uk%2Fomg-i-just-formatted-my-server%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>I can&#8217;t believe what I just did&#8230;.. I mistakenly restored an old backup of fiddyp&#8230; grrrrr.</p>
<p>I have just moved to a dedicated server and its really helped the load times, I got everything working and then did a backup. &#8220;sweet&#8221; thought I&#8230;. let&#8217;s set up a scheduled backup&#8230; two wrong clicks later and I realise that it&#8217;s restoring the old back up. dammnit all to hell on a bicycle!!!!</p>
<p>Luckily, I managed to retrieve the last two posts I made by copying the source of the feed in google feedreader, amazingly, that still held the last two posts I made. Shame I missed the comments though, I&#8217;ll have to see if I can find a list of the entries of the Euromillions rollover contest in a history somewhere and get it from offline mode&#8230;.</p>
<p>silly silly me!</p>
<p>edit: I just realised that I can reconstruct the comments from my email notifications. I just got all the entries back on the euromillions contest post from a page view in the history, i&#8217;ll put the remainder up when I get over my heart attack!</p>
<p>newedit: I tried to change this hosting to exclusive IP on a dedicated server and I lost another couple of comments (sorry Sharon). I have had the most frustrating day playing with this server. I feel an indepth rant coming!&#8230;.</p>
<p>even newer edit: I think I&#8217;m changing too many things and not giving it time to work! I am now going to leave the nameservers as they are, leave the IP of the hosting the same and just sit back and wait for a few days for everything to settle. sorry for any interuptions to normal service.. I&#8217;m trying to get everything up and secure on a fast host so I can get my new plans in to gear and not worry about bandwidth affecting download times and other schtuff..</p>
<p>seeya soon!</p>
]]></content:encoded>
			<wfw:commentRss>http://fiddyp.co.uk/omg-i-just-formatted-my-server/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>

