server-scripts/rsnapshot_cp_zfs
2014-10-19 17:27:33 +02:00

24 lines
440 B
Bash
Executable File

#!/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