server-scripts/rsnapshot_cp_zfs

24 lines
440 B
Plaintext
Raw Normal View History

2014-10-19 15:27:33 +00:00
#!/bin/bash
# name of the volume
zname=$(dirname $(dirname $(echo $2 | cut -b 2-)))
# name of the future snapshot
bsname="$zname@rsnap-$(date +%F)"
sname=$bsname
for i in 1 2 3 4 5
do
# exit if success
zfs snapshot "$sname"
if [ "x$?" == "x0" ]; then
echo "backup started at $(date)" > $2/info
exit 0
fi
# iterate over it if already exists
sname=$bsname-v$i
done
echo ERROR zfs_cp: something is really broken
exit 1