<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<atom:link href="https://seanbehan.ca/posts/tag/backup/rss.xml" rel="self" type="application/rss+xml" />
		<title>Sean Behan — backup</title>
		<link>https://seanbehan.ca/posts/tag/backup</link>
		<description>Posts tagged “backup”.</description>
		<language>en-CA</language>
		<!-- RSS wants an address here and readers show the name beside it. -->
		<managingEditor>sean@seanbehan.ca (Sean Behan)</managingEditor>
		<webMaster>sean@seanbehan.ca (Sean Behan)</webMaster>
		<lastBuildDate>Sun, 30 Aug 2026 05:26:06 GMT</lastBuildDate>
		<item>
		<guid isPermaLink="true">https://seanbehan.ca/posts/ostree</guid>
		<title><![CDATA[Using Ostree for file snapshots]]></title>
		<description><![CDATA[Ostree is not just for Silverblue. Using it as a content-addressed snapshot store for your own files.]]></description>
		<link>https://seanbehan.ca/posts/ostree</link>
		<pubDate>Sat, 27 May 2023 11:47:26 GMT</pubDate>
		<category>backup</category><category>linux</category><category>ostree</category>
		<content:encoded><![CDATA[<h3>Introduction</h3><p>Ostree is the software that allows rpm-ostree in Fedora Silverblue to keep snapshots of previous deployments and do incremental updates, but did you know it can also be used to keep snapshots of your own files? It&#x27;s actually quite easy once it&#x27;s all set up.</p><p>For this I would strongly suggest you use root for your ostree. Although you can use it without, you will be able to use files that regular users can&#x27;t use such as hardlinks if you&#x27;re root, which will speed up incremental snapshots very much.</p><h3>Initializing the Ostree Repository</h3><p>First you&#x27;ll want to create your inital ostree. Do this in a new folder, on a drive with lots of free space for the files you want to snapshot. You&#x27;ll need as much free space as all the files you want to snapshot.</p><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">mkdir</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> tree</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> ostree</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> init</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> --repo=tree</span></span></code></pre><h3>Committing and Restoring Files</h3><p>Next you can start committing files to your new tree. Be sure to check the man pages for <code>ostree-commit</code> and <code>ostree-init</code>.</p><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> ostree</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> commit</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> --repo=tree</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> --branch=master</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> $PWD</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">/dir</span></span></code></pre><p>Keep in mind you cannot commit individual files, only entire directories at a time. Now when you change something inside <code>/dir</code> you can commit again with the exact same command and you will have both copies in your ostree. To restore the original copy you can then use <code>ostree-checkout</code>.</p><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">ostree</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> refs</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> --repo=tree</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> master</span></span></code></pre><p>This will show you a list of all your commits. Now choose the one you want to restore.</p><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">ostree</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> checkout</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> --repo=tree</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> --union</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> your-commit-sha</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> dir</span></span></code></pre><h3>Important Considerations</h3><p>Make sure you check <code>ostree -h</code> for a list of ostree commands and read each of their man pages if you want to use them fully.</p><p>I use this on a filesystem that is already a RAID1. Make sure you keep proper backups, ostree can create snapshots but it won&#x27;t help you if your entire drive fails.</p>]]></content:encoded>
	</item>
<item>
		<guid isPermaLink="true">https://seanbehan.ca/posts/btrfs</guid>
		<title><![CDATA[BTRFS RAID1 and how to fix it]]></title>
		<description><![CDATA[Setting up a two-disk BTRFS RAID1 for a Steam library, and repairing it when a drive starts throwing errors.]]></description>
		<link>https://seanbehan.ca/posts/btrfs</link>
		<pubDate>Tue, 23 May 2023 14:39:58 GMT</pubDate>
		<category>backup</category><category>linux</category><category>raid</category>
		<content:encoded><![CDATA[<h3>BTRFS RAID1 Setup</h3><p>I mentioned in my previous post that I use an external drive to keep my Steam</p><p>games on. In an attempt to not have to re-download hundreds of gigabytes of</p><p>games I keep them on a RAID1 with 2x5TB drives that I use BTRFS to manage. In</p><p>this post I&#x27;m going to outline how I set it all up, and how I manage it when</p><p>issues arise.</p><h3>Formatting Drives</h3><p>First of all I had to format the drives, so I made sure they were empty and</p><p>everything was backed up. Don&#x27;t do this unless you know for sure that all the</p><p>data on all your drives is backed up somewhere else, or you want to delete it</p><p>permanently.</p><p>Okay so the commands are easy, you just have to make sure you&#x27;re using the</p><p>right ones as not to lose your data. Don&#x27;t run these commands without</p><p>understanding what they do. Replace \_ with your drive letter. A lot of these</p><p>commands need to be run with root, make sure to either elevate to root (<code>sudo -s</code>)</p><p>or prepend the commands with <code>sudo</code>.</p><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">lsblk</span></span></code></pre><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">mkfs.btrfs</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> /dev/sd_1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">mkfs.btrfs</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> /dev/sd_1</span></span></code></pre><h3>Creating the RAID1 Array</h3><p>Now you can mount the newly formatted drives to a single RAID1.</p><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">mount</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> /dev/sd_1</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> /mnt</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">btrfs</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> device</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> add</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> /dev/sd_1</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> /mnt</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">btrfs</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> balance</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> start</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> -dconvert=raid1</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> -mconvert=raid1</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> /mnt</span></span></code></pre><p>The last command might take a little bit of time, but once it&#x27;s finished your</p><p>drives will be all ready to be used.</p><h3>Managing the Array</h3><p>Now if you need to swap out a drive, add another, or you unplug one when it&#x27;s</p><p>writing you can simply balance again and btrfs should be able to balance back</p><p>onto the drive.</p><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">btrfs</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> balance</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> start</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> -dconvert=raid1</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> -mconvert=raid1</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> /mnt</span></span></code></pre><p>You can view the status of the balance using:</p><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">btrfs</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> balance</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> status</span></span></code></pre><p>You can remove a drive or add another using:</p><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">btrfs</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> device</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> remove</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> /dev/sd_1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">btrfs</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> device</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> add</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> /dev/sd_1</span></span></code></pre><p>Just make sure you balance right afterwards (which will take a VERY long time</p><p>if you have lots of data, beware)</p><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">btrfs</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> balance</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> start</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> -dconvert=raid1</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> -mconvert=raid1</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> /mnt</span></span></code></pre>]]></content:encoded>
	</item>
	</channel>
</rss>