<?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>SoftLayer Blog &#187; Ronald Steelman</title>
	<atom:link href="http://blog.softlayer.com/author/rsteelman/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.softlayer.com</link>
	<description>A Behind the Scenes Look at the Best Hosting Provider in the World</description>
	<lastBuildDate>Tue, 04 Jun 2013 20:27:40 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.1</generator>
		<item>
		<title>Using SoftLayer Object Storage to Back Up Your Server</title>
		<link>http://blog.softlayer.com/2012/using-softlayer-object-storage-to-back-up-your-server/</link>
		<comments>http://blog.softlayer.com/2012/using-softlayer-object-storage-to-back-up-your-server/#comments</comments>
		<pubDate>Thu, 27 Dec 2012 21:40:01 +0000</pubDate>
		<dc:creator>Ronald Steelman</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[SoftLayer]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[Backups]]></category>
		<category><![CDATA[client]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[object storage]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[SolusVM]]></category>
		<category><![CDATA[storage]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://blog.softlayer.com/?p=9795</guid>
		<description><![CDATA[Before I came to my senses and moved my personal servers to SoftLayer, I was one of many victims of a SolusVM exploit that resulted in the wide-scale attack of many nodes in my previous host&#8217;s Chicago data center. While I&#8217;m a firm believer in backing up my data, I could not have foreseen the [...]]]></description>
			<content:encoded><![CDATA[<p>Before I came to my senses and moved my personal servers to SoftLayer, I was one of many victims of a SolusVM exploit that resulted in the wide-scale attack of many nodes in my previous host&#8217;s Chicago data center. While I&#8217;m a firm believer in backing up my data, I could not have foreseen the situation I was faced with: Not only was my server in one data center compromised with all of its data deleted, but my backup server in one of the host&#8217;s other data centers was also attacked &#8230; This left me with old, stale backups on my local computer and not much else. I quickly relocated my data and decided that I should use <a href="http://www.softlayer.com/cloudlayer/storage/">SoftLayer Object Storage</a> to supplement and improve upon my backup and disaster recovery plans.</p>
<p>With <a href="https://github.com/softlayer/softlayer-object-storage-python">SoftLayer Object Storage Python Client</a> set up and the SoftLayer Object Storage Backup script &mdash; <a href="http://sldn.softlayer.com/blog/klandreth/Deglazing-slbackuppy-Usage-Object-Storage-Kitchen">slbackup.py</a> &mdash; in hand, I had the tools I needed to build a solid backup infrastructure easily. On Linux.org, I contributed an article about how to <a href="http://www.linux.org/article/view/mysql-backups-using-softlayer-object-storage">perform MySQL backups</a> with those resources, so the database piece is handled, but I also need to back up my web files, so I whipped up another quick <code>bash</code> script to run:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># The path the backups will be dumped to</span>
<span style="color: #007800;">DUMP_DIR</span>=<span style="color: #ff0000;">&quot;/home/backups/&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Path to the web files to be backed up</span>
<span style="color: #007800;">BACKUP_PATH</span>=<span style="color: #ff0000;">&quot;/var/www/sites /&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Back up folder name (mmddyyyy)</span>
<span style="color: #007800;">BACKUP_DIR</span>=<span style="color: #ff0000;">&quot;<span style="color: #780078;">`date +%m%d%Y`</span>&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Backup File Name</span>
<span style="color: #007800;">DUMP_FILE</span>=<span style="color: #ff0000;">&quot;<span style="color: #780078;">`date +%m_%d_%Y_%H_%M_%S`</span>_site_files&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># SL container name</span>
<span style="color: #007800;">CONTAINER</span>=<span style="color: #ff0000;">&quot;site_backups&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Create backup dir if doesn't exist</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-d</span> <span style="color: #007800;">$DUMP_DIR</span><span style="color: #007800;">$BACKUP_DIR</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #660033;">-p</span> <span style="color: #007800;">$DUMP_DIR</span><span style="color: #007800;">$BACKUP_DIR</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-zcvpf</span> <span style="color: #007800;">$DUMP_DIR</span><span style="color: #007800;">$BACKUP_DIR</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$DUMP_FILE</span>.tar.gz <span style="color: #007800;">$BACKUP_PATH</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Make sure the archive exists</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$DUMP_DIR</span><span style="color: #007800;">$BACKUP_DIR</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$DUMP_FILE</span>.tar.gz <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #000000; font-weight: bold;">/</span>root<span style="color: #000000; font-weight: bold;">/</span>slbackup.py <span style="color: #660033;">-s</span> <span style="color: #007800;">$DUMP_DIR</span><span style="color: #007800;">$BACKUP_DIR</span><span style="color: #000000; font-weight: bold;">/</span> <span style="color: #660033;">-o</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$CONTAINER</span>&quot;</span> <span style="color: #660033;">-r</span> <span style="color: #000000;">30</span>
&nbsp;
        <span style="color: #666666; font-style: italic;"># Remove the backup stored locally</span>
        <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> <span style="color: #007800;">$DUMP_DIR</span><span style="color: #007800;">$BACKUP_DIR</span>
&nbsp;
        <span style="color: #666666; font-style: italic;"># Success</span>
        <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span>
<span style="color: #000000; font-weight: bold;">else</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$DUMP_DIR</span><span style="color: #007800;">$BACKUP_DIR</span>/<span style="color: #007800;">$DUMP_FILE</span>.tar.gz does not exist.&quot;</span>
        <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></div></div>

<p>It&#8217;s not the prettiest <code>bash</code> script, but it gets the job done. By tweaking a few variables, you can easily generate backups for any important directory of files and push them to your SoftLayer Object Storage account. If you want to change the retention time of your backups to be longer or shorter, you can change the <code>30</code> after the <code>–r</code> in the line below to the number of days you want to keep each backup:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>root<span style="color: #000000; font-weight: bold;">/</span>slbackup.py <span style="color: #660033;">-s</span> <span style="color: #007800;">$DUMP_DIR</span><span style="color: #007800;">$BACKUP_DIR</span><span style="color: #000000; font-weight: bold;">/</span> <span style="color: #660033;">-o</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$CONTAINER</span>&quot;</span> <span style="color: #660033;">-r</span> <span style="color: #000000;">30</span></pre></div></div>

<p>I created a script for each website on my server, and I set a CRON (crontab –e) entry to run each one on Sundays staggered by 5 minutes:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000;">5</span> <span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000;">0</span>  <span style="color: #000000; font-weight: bold;">/</span>root<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>cron<span style="color: #000000; font-weight: bold;">/</span>CRON-site1.com_web_files <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
<span style="color: #000000;">10</span> <span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000;">0</span>  <span style="color: #000000; font-weight: bold;">/</span>root<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>cron<span style="color: #000000; font-weight: bold;">/</span>CRON-site2.com_web_files <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
<span style="color: #000000;">15</span> <span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000;">0</span>  <span style="color: #000000; font-weight: bold;">/</span>root<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>cron<span style="color: #000000; font-weight: bold;">/</span>CRON-site3.com_web_files <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null</pre></div></div>

<p>If you&#8217;re looking for an easy way to automate and solidify your backups, this little bit of code could make life easier on you. Had I taken the few minutes to put this script together prior to the attack I experienced at my previous host, I wouldn&#8217;t have lost any of my data. It&#8217;s easy to get lulled into &#8220;backup apathy&#8221; when you don&#8217;t <em>need</em> your backups, but just because nothing *has* happened to your data doesn&#8217;t mean nothing *can* happen to your data.</p>
<p>Take it from me &#8230; Be over-prepared and save yourself a lot of trouble.</p>
<p>-Ronald</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.softlayer.com/2012/using-softlayer-object-storage-to-back-up-your-server/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
