<?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>ZFS &#8211; bablick.de</title>
	<atom:link href="https://bablick.de/tag/zfs/feed/" rel="self" type="application/rss+xml" />
	<link>https://bablick.de</link>
	<description>Writing About Clusters, Curiosity, and Everything in Between.</description>
	<lastBuildDate>Sat, 20 Sep 2025 22:47:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.3</generator>

<image>
	<url>https://bablick.de/wp-content/uploads/2025/08/cropped-BablickLogo-1-32x32.png</url>
	<title>ZFS &#8211; bablick.de</title>
	<link>https://bablick.de</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Automatically Create, Rotate and Destroy Periodic ZFS Snapshots</title>
		<link>https://bablick.de/automatically-create-rotate-and-destroy-periodic-zfs-snapshots/</link>
		
		<dc:creator><![CDATA[ernst.bablick]]></dc:creator>
		<pubDate>Fri, 29 Aug 2025 21:48:12 +0000</pubDate>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[ZFS]]></category>
		<category><![CDATA[ZFS-Snapshots]]></category>
		<guid isPermaLink="false">https://bablick.de/?p=91</guid>

					<description><![CDATA[The main reason for moving my home directories to a ZFS file system is ZFS&#8217;s support for snapshots. I have found them quite handy on server systems when something has been accidentally deleted, a software upgrade has failed, or software has not done what it promised. A simple rollback to a previous state can help...]]></description>
										<content:encoded><![CDATA[
<p>The main reason for moving my home directories to a ZFS file system is ZFS&#8217;s support for snapshots. I have found them quite handy on server systems when something has been accidentally deleted, a software upgrade has failed, or software has not done what it promised. A simple rollback to a previous state can help undo changes and allow you to continue safely. ZFS-Auto-Snapshot is a tool that uses cron to automatically create, rotate and destroy snapshots in the background.</p>



<h2 class="wp-block-heading">How To Do</h2>



<p>Install the zfs-auto-snapshot package</p>



<pre class="wp-block-code"><code>sudo apt install zfs-auto-snapshot</code></pre>



<p>On Ubuntu and Debian, cron scripts are already in place to trigger the script.</p>



<p>Enabling or disabling automatic snapshots for a specific ZFS is done via ZFS properties. This property is inherited by all descendant datasets, so there is no need to set it manually for each one.</p>



<pre class="wp-block-code"><code>sudo zfs set com.sun:auto-snapshot=true zhome/home</code></pre>



<p>You should also specify where you don&#8217;t want to see snapshots.</p>



<pre class="wp-block-code"><code>sudo zfs set com.sun:auto-snapshot=false zhome/home/tstusr1
sudo zfs set com.sun:auto-snapshot=false zhome/home/tstusr2</code></pre>



<p>You can enable or disable frequent (every 15 minutes), hourly, daily, weekly or monthly snapshots. They are all enabled by default, so the first snapshot should appear soon.</p>



<pre class="wp-block-code"><code>zfs set com.sun:auto-snapshot:frequent=false zhome/home/tstusr
zfs set com.sun:auto-snapshot:daily=true ...
zfs set com.sun:auto-snapshot:monthly=true ...
...</code></pre>



<p>The following commands are helpful for listing, creating and destroying snapshots:</p>



<pre class="wp-block-code"><code>zfs list -t snapshot

zfs snapshot -r zpool/foo/bar@name

zfs destroy zpool/foo/bar@name</code></pre>



<p>To restore to a certain snapshot, ZFS will roll back <strong>all</strong> the files and delete all the newer snapshots, so be careful!</p>



<pre class="wp-block-code"><code>zfs rollback zpool/foo/bar@name -r</code></pre>



<p>ZFS itself does not support deleting large numbers of snapshots, but this command comes in handy for that purpose.</p>



<pre class="wp-block-code"><code>sudo zfs list -H -o name -t snapshot zhome/somedir | xargs -n1 zfs destroy</code></pre>



<p>ZFS rollbacks are permanent. They recover everything from the snapshot. If you only want to recover some files or directories, ZFS does not support this directly. However, there is a workaround: Clone the snapshot to a different location and mount the clone. Restore the required files and then delete the clone.</p>



<pre class="wp-block-code"><code>sudo zfs clone zhome/home/ebablick@zfs-auto-snap_frequent-2025-08-25-1845 \
         -o mountpoint=/mnt zhome/ebablick_clone_of_snapshot_2025-08-25-1845

copy /mnt/... /to/...

sudo zfs destroy zhome/ebablick_clone_of_snapshot_2025-08-25-1845 -r</code></pre>



<p>Take a look at the zfs-auto-snapshot(8) manual page. The tool itself offers a few interesting options for executing pre- and post-snapshot commands. The number of snapshots to keep can also be configured via command line arguments, which then need to be adapted for the cron jobs.</p>



<p></p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
