finish rsync backup from ceph rbd and document it
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 28 Jul 2018 09:47:54 +0000 (11:47 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 28 Jul 2018 09:47:54 +0000 (11:47 +0200)
doc/rbd-ceph.txt
gnt-lv-snap-rsync.sh
rbd-snap-backup.sh

index b96a7e0..8b34a91 100644 (file)
@@ -19,4 +19,16 @@ syslog 45b765f6-316c-46a1-a92a-071113e18fcb.rbd.disk0
 video 7cda803e-f877-4001-b9ce-9d460e3f85b8.rbd.disk0
 video f1991f16-f59c-4e9d-adae-79cbfe034878.rbd.disk1
 
+Then there is script to start snapshot backup from rbd instance to lib15:
+
+root@r1u28:/srv/gnt-info# ./rbd-snap-backup.sh odin.ffzg.hr 1
+
+gnt-lv-snap-rsync.sh will call this script if it can't find any lvm volumes
+for that disk
+
+If backup fails for some reason, it might leave mounted filesystem. You have
+to umount that manually. After that, there is cleanup script to remove left-overs
+of @backup snapshots from ceph:
+
+root@r1u28:/srv/gnt-info# ./rbd-remove-snap.sh 
 
index b3e52fc..869a7b3 100755 (executable)
@@ -20,12 +20,16 @@ echo "# $instance on $node"
 
 vg=`gnt-cluster info | grep 'lvm volume group:' | cut -d: -f2 | tr -d ' '`
 
+found_lvm=0
+
 ssh $node lvs -o name,tags | grep $instance | tee /dev/shm/$instace.$node.lvs | grep disk${disk}_data | while read lv origin ; do
+       found_lvm=1
+
        disk_nr=`echo $lv | cut -d. -f2 | tr -d a-z_`
        echo "# $lv | $origin | $disk_nr"
 
        rsync_args=""
-       if rsync lib15::$backup/$instance/rsync.args /dev/shm/$instance-rsync.args ; then
+       if rsync lib15::$backup/$instance/rsync.args /dev/shm/$instance-rsync.args 2>/dev/null; then
                rsync_args="`cat /dev/shm/$instance-rsync.args`"
        fi
 
@@ -58,4 +62,7 @@ __SHELL__
        ssh -i /root/.ssh/id_dsa-zfs lib15 lib15/$backup/$instance/$disk_nr
 done
 
-
+if [ $found_lvm = 0 ] ; then
+       export backup
+       /srv/gnt-info/rbd-snap-backup.sh $instance $disk
+fi
index ead47fd..3a897bf 100755 (executable)
@@ -1,9 +1,10 @@
 #!/bin/sh -xe
 
+test -z "$1" -o -z "$2" && echo "Usage: $0 instance disk" && exit 1
+
 instance=$1
 disk=$2
-
-test -z "$1" -o -z "$2" && echo "Usage: $0 instance disk" && exit 1
+test -z "$backup" && backup="backup"
 
 rbd_image=`gnt-instance info --static $instance | grep logical_id: | cut -d\' -f4 | grep "\.rbd\.disk$disk\$"`
 
@@ -23,8 +24,20 @@ offset=`fdisk -l $rbd_dev -u -o Device,Start,Type | grep 'Linux$' | grep $rbd_de
 test ! -z "$offset" && offset=",offset=$offset"
 mount $rbd_dev /dev/shm/$rbd_image.snap -o noatime$offset
 
-# execute something on mounted filesystem
-read -p "wait for key" key
+
+# XXX do rsync back to lib15
+
+rsync_args=""
+if rsync lib15::$backup/$instance/rsync.args /dev/shm/$instance-rsync.args 2>/dev/null ; then
+       rsync_args="`cat /dev/shm/$instance-rsync.args`"
+fi
+
+rsync -ravHzXA --inplace --numeric-ids --delete $rsync_args \
+       /dev/shm/$rbd_image.snap/ lib15::$backup/$instance/$disk/ \
+&& ssh -i /root/.ssh/id_dsa-zfs lib15 lib15/$backup/$instance/$disk
+
+# XXX backup OK
+
 
 
 umount /dev/shm/$rbd_image.snap