<?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; GIT</title>
	<atom:link href="http://www.stardothosting.com/blog/category/git/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>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_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/2011/11/25/backup-compress-and-encrpyt-your-git-repository/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

