<?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/ostree/rss.xml" rel="self" type="application/rss+xml" />
		<title>Sean Behan — OSTree</title>
		<link>https://seanbehan.ca/posts/tag/ostree</link>
		<description>Posts tagged “OSTree”.</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:33:55 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>
	</channel>
</rss>