<?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>Weird rocketry &#187; backup</title>
	<atom:link href="http://webapp.org.ua/tag/backup/feed" rel="self" type="application/rss+xml" />
	<link>https://webapp.org.ua</link>
	<description>Flights to outer code</description>
	<lastBuildDate>Sat, 16 Jul 2016 11:12:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>How to setup TimeMachine on a network drive with disk quota</title>
		<link>https://webapp.org.ua/hardware/how-to-setup-timemachine-on-a-network-drive-with-disk-quota/</link>
		<comments>https://webapp.org.ua/hardware/how-to-setup-timemachine-on-a-network-drive-with-disk-quota/#comments</comments>
		<pubDate>Wed, 17 Oct 2012 21:45:37 +0000</pubDate>
		<dc:creator>bananos</dc:creator>
				<category><![CDATA[hardware]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[access rights]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[Buffalo]]></category>
		<category><![CDATA[disk quota]]></category>
		<category><![CDATA[LS-WXL]]></category>
		<category><![CDATA[NAS]]></category>
		<category><![CDATA[Network drive]]></category>
		<category><![CDATA[Time Machine]]></category>

		<guid isPermaLink="false">http://webapp.org.ua/?p=283</guid>
		<description><![CDATA[Well, once you bought your NAS or configured a dedicated PC with network drive you&#8217;ll obviously want to setup Time Machine. The problem is, once configured to backup to a networked drive your TimeMachine will eat all available space. For those lucky ones, who shared a dedicated disk partition on their drive — there&#8217;s no problem [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://webapp.org.ua/wp-content/uploads/2012/10/tm-logo.png"><img class="alignleft size-medium wp-image-285" title="tm-logo" src="http://webapp.org.ua/wp-content/uploads/2012/10/tm-logo-300x300.png" alt="" width="300" height="300" /></a>Well, once you bought your <a href="http://en.wikipedia.org/wiki/Network-attached_storage">NAS</a> or configured a dedicated PC with network drive you&#8217;ll obviously want to setup Time Machine.  The problem is, once configured to backup to a networked drive your TimeMachine will eat all available space.</p>
<p>For those lucky ones, who shared a dedicated disk partition on their drive — there&#8217;s no problem at all. But I was not one of them. Recently, I&#8217;ve purchased a used <a href="http://www.buffalo-technology.com/en/ls-wxl-linkstation-duo.html">Buffalo LS-WXL Linkstation duo</a> inserted two new 1TB drives and configured it as a RAID0 array. As a result, almost whole 2Tb partition became available for sharing — despite how hard I tried to figure out <a href="http://en.wikipedia.org/wiki/XFS">xfs</a> quotas on target partition, no success.</p>
<p>Well, there are bad and good news.</p>
<ul>
<li>The good news is that you may limit your Time Machine disk quota by using something called <a href="http://en.wikipedia.org/wiki/Sparse_image">sparse disk bundles</a>.</li>
<li>The bad news is that you&#8217;ll need <a href="http://buffalo.nas-central.org/wiki/Category:LS-WXL#Gain_SSH_Access">root access to your NAS</a> in order to apply permissions hack to make it work with latest versions of Time Machine</li>
</ul>
<p><br style="clear: both;" /><br />
<span id="more-283"></span></p>
<p>Let&#8217;s proceed!</p>
<h2>Create sparse bundle on your mac</h2>
<p>Open terminal, and create 1024g sparse disk:</p>
<pre><code class="bash">
# Get the MACADDR of network port
$ MAC=$(ifconfig en0 | perl -ne 's/.*ether (\w+:\w+:\w+:\w+:\w+:\w+).*/$1/ &amp;&amp; s/://g &amp;&amp; print;')
$ echo $MAC
001122334455

# Create name of sparsebundle
$ SBNAME=$(hostname)_$MAC.sparsebundle
$ echo $SBNAME
amber_001122334455.sparsebundle

# Create sparse image
# You should modify 1024g to the size of your maximum Time Machine backup size.
$ hdiutil create -fs HFS+J -size 1024g -type SPARSEBUNDLE -volname "Time Machine" $SBNAME
$ ls $SBNAME
Info.bckup    Info.plist    bands        token
</code></pre>
<p>Once this is done, copy sparse bundle directory into your network volume:</p>
<pre><code class="bash">
# mine network disk is called /Volume/tm
$ cp -R $SBNAME /Volumes/tm
</code></pre>
<h2>Create a separate user for TimeMachine</h2>
<p>It is a good practice to create a special user specifically for network drives that will be used for TimeMachine backup.</p>
<p>I called mine <em>tm</em>:</p>
<p><a href="http://webapp.org.ua/wp-content/uploads/2012/10/create_™_user.png"></a><a href="http://webapp.org.ua/wp-content/uploads/2012/10/2012-10-18_0039.png"><img class="aligncenter size-full wp-image-290" title="buffalo_create_user" src="http://webapp.org.ua/wp-content/uploads/2012/10/2012-10-18_0039.png" alt="" width="794" height="492" /></a></p>
<h2>Apply hack with access rights</h2>
<p>On MacOS X versions prior to 10.6.3, this step would be not necessary, but on latest versions TimeMachine automatically resizes your sparse bundle to occupy the whole space. We&#8217;ll deny it using access rights hack.</p>
<p>To be able to continue, you should access your NAS using <a href="http://buffalo.nas-central.org/wiki/Category:LS-WXL">root credentials</a>.</p>
<pre><code class="bash">
# login to your NAS via ssh
$ ssh -i ~/.ssh/my.key root@nas
Warning: Permanently added 'nas,192.168.1.227' (RSA) to the list of known hosts.
Last login: Wed Oct 17 19:35:37 2012 from amber

# go to the destination of your shared network volume
root@NAS:~$ cd /mnt/array1/tm/

# check out that sparse bundle has been successfully copied
root@NAS:/mnt/array1/tm$ ls -l
drwxrwsrwx    4 tm       hdusers      4096 Oct 17 19:08 amber_001122334455.sparsebundle/
</code></pre>
<p>The main idea behind access right hack is pretty simple: deny TimeMachine user from write access to specific files:</p>
<pre><code class="bash">
# Give read-only access for tm user
root@NAS:/mnt/array1/tm$ cd amber_001122334455.sparsebundle
root@NAS:/mnt/array1/tm/amber.sparsebundle$  chown root:root Info.*
root@NAS:/mnt/array1/tm/amber.sparsebundle$  chmod a+r-w Info.*

# Check access rights:

root@NAS:/mnt/array1/tm/amber.sparsebundle# ls -l
-r--r--r--    1 root     root          500 Oct  9 20:36 Info.bckup
-r--r--r--    1 root     root          500 Oct  9 20:36 Info.plist
drwxrwsrwx    3 tm       hdusers   1155072 Oct 17 19:08 bands/
</code></pre>
<h2>Configure TimeMachine</h2>
<p>The last step is to configure TimeMachine to backup to network disk. It&#8217;s the same process as with usual hdd.</p>
<p>Once TimeMachine is configured, let&#8217;s verify that it is backing up normally and will not occupy the whole disk space.</p>
<p>Open <code>Spotlight</code> and type <code>Console</code> — a special program to see your software logs. Matching string for TimeMachine will be <code>backupd</code></p>
<p><a href="http://webapp.org.ua/wp-content/uploads/2012/10/console_log_for_tm.png"><img class="aligncenter size-full wp-image-287" title="console log for TimeMachine" src="http://webapp.org.ua/wp-content/uploads/2012/10/console_log_for_tm.png" alt="" width="872" height="327" /></a></p>
<p>At the console logs you should see something like this:</p>
<pre><code>
10/9/12 8:39:36.012 PM com.apple.backupd: Starting standard backup
10/9/12 8:39:36.026 PM com.apple.backupd: Attempting to mount network destination URL: afp://tm@NAS._afpovertcp._tcp.local/tm
10/9/12 8:39:36.480 PM com.apple.backupd: Mounted network destination at mountpoint: /Volumes/tm-1 using URL: afp://tm@NAS._afpovertcp._tcp.local/tm
<strong>10/9/12 8:39:53.925 PM com.apple.backupd: Resizing backup disk image from 1024.0 GB to 1834.2 GB</strong>
<strong>10/9/12 8:39:53.938 PM com.apple.backupd: Could not resize backup disk image (DIHLResizeImage returned 35)</strong>
10/9/12 8:39:53.939 PM com.apple.backupd: Renaming /Volumes/tm-1/amber_c82a141a607c.sparsebundle to /Volumes/tm-1/amber.sparsebundle
10/9/12 8:39:53.971 PM com.apple.backupd: Running backup verification
10/9/12 8:39:55.349 PM com.apple.backupd: QUICKCHECK ONLY; FILESYSTEM CLEAN
10/9/12 8:40:57.454 PM com.apple.backupd: Backup verification passed!
10/9/12 8:40:58.953 PM com.apple.backupd: QUICKCHECK ONLY; FILESYSTEM CLEAN
10/9/12 8:41:01.105 PM com.apple.backupd: Disk image /Volumes/tm-1/amber.sparsebundle mounted at: /Volumes/Time Machine
10/9/12 8:41:01.113 PM com.apple.backupd: Backing up to: /Volumes/Time Machine/Backups.backupdb
10/9/12 8:41:01.117 PM com.apple.backupd: Ownership is disabled on the backup destination volume.  Enabling.
10/9/12 8:41:12.304 PM com.apple.backupd: Backup content size: 95.2 GB excluded items size: 18.1 GB for volume sys
10/9/12 8:42:20.556 PM com.apple.backupd: Backup content size: 668.6 GB excluded items size: 248.4 GB for volume storage
10/9/12 8:42:20.564 PM com.apple.backupd: 596.84 GB required (including padding), 1023.05 GB available
10/9/12 8:42:20.616 PM com.apple.backupd: Waiting for index to be ready (101)
</code></pre>
<p>The message we&#8217;re most interested in is <code>com.apple.backupd: Could not resize backup disk image (DIHLResizeImage returned 35)</code>, which means that our access rights hack worked and TimeMachine will be limited by 1024GB.</p>
<p>However, reporting will show you the whole disk size as available — don&#8217;t be confused by this:</p>
<p><a href="http://webapp.org.ua/wp-content/uploads/2012/10/main_scr_tm.png"><img class="aligncenter size-full wp-image-288" title="Time Machine reporting invalid disk quota" src="http://webapp.org.ua/wp-content/uploads/2012/10/main_scr_tm.png" alt="" width="668" height="445" /></a></p>
<h2>Related info</h2>
<ul>
<li><a href="http://forums.buffalotech.com/t5/Storage/Time-Machine-Setup-How-to-prevent-disk-image-from-resizing/td-p/73624">Time Machine Setup: How to prevent disk image from resizing</a></li>
<li><a href="http://code.stephenmorley.org/articles/time-machine-on-a-network-drive/">Time machine on a network drive</a></li>
<li><a href="http://hintsforums.macworld.com/showthread.php?t=110709">TimeMachine doesn&#8217;t play well with custom sparsebundles</a></li>
<li><a href="http://buffalo.nas-central.org/wiki/Category:LS-WXL">Root access on Buffalo LS-WXL</a></li>
<li><a href="http://www.buffalo-technology.com/en/ls-wxl-linkstation-duo.html">Buffalo LS-WXL linkstation duo</a></li>
<li><a href="http://en.wikipedia.org/wiki/Network-attached_storage"> Network attached storage </a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>https://webapp.org.ua/hardware/how-to-setup-timemachine-on-a-network-drive-with-disk-quota/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
