24 lines
440 B
Plaintext
24 lines
440 B
Plaintext
|
#!/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
|