exit 1 on existing, verbose receive
[ganeti-extstorage-zfs] / bin / adopt
index 01107b4..f9c2a93 100755 (executable)
--- a/bin/adopt
+++ b/bin/adopt
@@ -1,6 +1,9 @@
-
 #!/bin/sh
 
 . /usr/share/ganeti/extstorage/zfs/defaults.sh
 
-./bin/snap | iselect -p 2 -a -n 'adopt snapshot' | awk '{ print $1 }' | xargs -i zfs clone {} $EXTP_ZFS/adopt
+test -e /dev/zvol/$EXTP_ZFS/adopt && exit 1
+
+zfs list -t snapshot -r -r $EXTP_ZFS -o name -H \
+| iselect -p 1 -a -n 'adopt snapshot' \
+| xargs -i sh -cx 'zfs send -R {} | zfs receive -v '$EXTP_ZFS'/adopt && zfs set ganeti:originstname="`zfs get ganeti:originstname -o value -p -H {}`+adopt" '$EXTP_ZFS'/adopt && zfs set lv:a="-" '$EXTP_ZFS'/adopt'