During installation of the URbackup client on Linux, it asks if the user wants to setup a snapshot feature using LVM or BTRFS (if the corresponding FS is detected).
Seeing as how on the client side, this is only used to create a temporary snapshot to ensure a consistent file state during backups, would it be possible to also implement this for clients that use ZFS?
uroni
May 13, 2017, 2:18pm
2
Yeah, one can probably adapt the script btrfs_create_filesystem_snapshot
pretty easily.
For anyone who wants it, here is my amateurish script for zfs client snapshots adapted from the btrfs scripts, feel free to improve it!
zfs_create_filesystem_snapshot
#!/bin/bash
set -e
SNAP_ID=$1
SNAP_MOUNTPOINT="$2"
SNAP_NAME="$3"
SNAP_ORIG_PATH="$4"
TYPE=$(df -T -P | egrep " ${SNAP_MOUNTPOINT}\$" | head -n 1 | tr -s " " | cut -d" " -f2)
if [[ $TYPE == "zfs" ]]
then
ZPOOL=`zpool list -H -o name`
ZVOL=`df -P | egrep " ${SNAP_MOUNTPOINT}\$" | cut -d" " -f1`
zfs snapshot ${ZVOL}@${SNAP_ID}
else
echo "Cannot create snapshot of file system with type $TYPE"
exit 1
fi
echo "SNAPSHOT=${SNAP_MOUNTPOINT}/.zfs/snapshot/${SNAP_ID}"
exit 0
zfs_remove_file_system_snapshot
#!/bin/bash
set -e
SNAP_ID=$1
SNAP_MOUNTPOINT="$2"
SNAP_NAME="$3"
SNAP_DEST="$4"
SNAP_ORIG_PATH="$5"
TYPE=$(df -T -P | egrep " ${SNAP_MOUNTPOINT}\$" | tr -s " " | cut -d" " -f2)
ZVOL=`cd $SNAP_MOUNTPOINT/ ; df -T -P | egrep " ${SNAP_MOUNTPOINT}\$" | cut -d" " -f1`
ZVOL=`zfs list -t snapshot | egrep "${SNAP_ID}" | cut -d" " -f1`
zfs destroy $ZVOL
exit 0
2 Likes
Fixed a bug in the removal script and changed a few things.
Works ok on my end.
Good day!
How can these scripts be adapted to the freebsd client? Tried including using bash, but fails…
rlopez
June 15, 2022, 5:04pm
7
Hello,
I made these scripts and put them in /usr/local/share/urbackup
Also I edited snapshot.cfg with the paths to these scripts
When I run a file backup, I receive this error:
Errores
15/06/22 18:51
Creating snapshot of "/RAID1/urbackup" failed
Errores
15/06/22 18:51
sh: 1: /usr/local/share/urbackup/zfs_create_filesystem_snapshot: not found
Errores
15/06/22 18:51
Creating snapshot of "urbackupdb" failed.
What could be the problem?
Thanks
It would be nice to include these scripts in default urbackup client install.
rlopez
June 15, 2022, 5:18pm
8
Sorry, It is solved.
It seems that works fine!
1 Like
I did also some work on ZFS snapshots on client.
Team may consider merging the code in client.
urbackup_client_zfs_snaps.tar.gz (9.6 KB)