This guide will show you how to set up
znapzend on OpenIndiana to backup a ZFS fileystem to a different ZFS filesystem.
- The backup destination ZFS zpool, e.g.
destinationzpool, has already been created
- The backup destination ZFS dataset, e.g.
destinationzpool/destinationzfsdatasethas already been created
- Both of the above are on the same machine as the source dataset
See the Oracle Solaris docs for instructions on Steps 1 to 3. At that link, pick the latest Solaris release and search the ensuing page for “ZFS.”
As of this writing,
znapzend does not exist in the OpenIndiana repos, so you’ll have to set up the 3rd party pkgsrc repo that has it.
# pkgin install znapzend
The official documentation is overly complicated for this purpose. A simple example config is:
znapzendzetup create --recursive SRC '1h=>15min,1d=>1h,1w=>1d,1m=>1w,1y=>1m' sourcezpool DST '1h=>15min,1d=>1h,1w=>1d,1m=>1w,1y=>1m' destinationzpool/destinationzfsdataset
Explaining the above command:
znapzendzetup: Set up
create: Generate a new backup config
--recursive: Backup all child datasets on
SRC: Source zpool settings begin here
'1h=>15min,1d=>1h,1w=>1d,1m=>1w,1y=>1m': For each comma-separated parameter, take a snapshot at interval equal to the value to the right of the arrow, and then destroy that snapshot after the value to the left of the arrow, e.g.
1h=>15minmeans take a snapshot every 15 minutes and destroy all such snapshots after they’ve existed for an hour. See official documentation for more options
sourcezpool: The zpool you want to backup
DST: Destination zpool & ZFS dataset settings begin here
'1h=>15min,1d=>1h,1w=>1d,1m=>1w,1y=>1m': Same as before
destinationzpool/destinationzfsdataset: The destination zpool and ZFS dataset
# znapzend --noaction --debug
The output of the above command may appear to freeze and not return you to a prompt. If that happens just hit
CTRL + C until the prompt shows up again. As long as the output has no errors, your config should be good.
# znapzend --daemonize
# zfs list -t snapshot
You should see snapshots with
znapzend‘s default) timestamps in their names.
There are many ways to do this, but I prefer using
htop (install it from the OI repos if you haven’t already):
- # htop
- Use the arrow keys to highlight any matching entries
F9while each matching entry is highlighted to kill it
CoW filesystems like ZFS sometimes have difficulty with a large number of snapshots combined with low space. Also, destroying snapshots is computationally expensive, and taking them too frequently can slow down the machine.
Therefore, it’s a good idea to disable other snapshot utilities if they are likely to cause such issues. For example, if you use Time Slider:
- Open Time Slider
Enable Time Slider
- In the window that follows, click
The deletion process may take a very long time (I suggest running it overnight.) If any Time Slider snapshots remain after the bulk deletion, just run it again and that should take care of the rest.
Wouldn’t it be nice if you could start
znapzend at boot? Unlike Linux and FreeBSD, OI’s crontab syntax lacks an
@reboot option, so anything that starts with OS has to be a service. While
@reboot makes things simple, service creation has some advantages, such as alerting the user when a service isn’t running as expected.
sudo svccfg export znapzend
Copy the output of that command to a text editor. You could also possibly use
echo to combine this and the following manifest file creation steps.
BONUS: You can use
svccfg export combined with the following steps to turn just about any background executable into a service!
Create the following file
/var/svc/manifest/site/znapzend.xml using your preferred method, then copy the output of Step 10 to it and save the file.
# nano /var/svc/manifest/site/znapzend.xml
- Copy the output from Step 10 into
CTRL + Oto save the file
CTRL + Xto exit
# svccfg validate /var/svc/manifest/site/znapzend.xml
# svccfg import /var/svc/manifest/site/znapzend.xml
# svcadm enable znapzend
And that’s it. Now you have automatic, incremental, rotating, easily restored backups of your OS filesystem.