The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,087 other followers

Backing up ZFS snapshots

Posted by jpluimers on 2018/12/06

An interesting idea at [WayBack] I was getting concerned about a backup, which had exceeded 1GB, when the data was only about 400MB. Once the job finished, I realized: Ahh, ZFS compres… – Dan Langille – Google+:

Here’s that script I use for creating/destroy the snaphots for a particular long dataset name. Then I backup from /mnt

[WayBackgist.github.com/dlangille/480dbca509562eb03e76c2e1b576c6d2 is in sh, not even bash.

–jeroen

#!/bin/sh
ACTION=$1
BASENAME="/usr/bin/basename"
MOUNT="/sbin/mount"
UMOUNT="/sbin/umount"
ZFS="/sbin/zfs"
DATASETROOT="main_tank/data/freshports/backend/queues"
DATASETS="${ZFS} list -r -H -o name ${DATASETROOT}"
SNAPSHOTDIRECTORY='/.zfs/snapshot/'
SNAPNAME="bu"
TMP_MNT_POINT="/mnt/freshports-queues"
case ${ACTION} in
"create")
${ZFS} snapshot -r "${DATASETROOT}@${SNAPNAME}"
for dataset in `${DATASETS}`
do
echo mkdir -p ${TMP_MNT_POINT}/${dataset}
mkdir -p ${TMP_MNT_POINT}/${dataset}
done
for dataset in `${DATASETS}`
do
if [ ${dataset} != ${DATASETROOT} ]
then
echo ${MOUNT} -t zfs -o ro ${dataset}@${SNAPNAME} ${TMP_MNT_POINT}/${dataset}
${MOUNT} -t zfs -o ro ${dataset}@${SNAPNAME} ${TMP_MNT_POINT}/${dataset}
fi
done
;;
"destroy")
for dataset in `${DATASETS}`
do
# Ignore the jail root. Nothing in there to backup.
if [ "${dataset}" = "${DATASETROOT}" ]
then
continue
fi
echo ${UMOUNT} ${TMP_MNT_POINT}/${dataset}
done
${ZFS} destroy -r "${DATASETROOT}@${SNAPNAME}"
;;
esac

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

 
%d bloggers like this: