#
# create LVM volume and play with snapshots
#
-set -x
+
TestName="snapshot-lvm-test"
JobName=Incremental
. scripts/functions
make -C $cwd/build/src/tools install-bsnapshot
$bperl -e 'add_attribute("$conf/bacula-dir.conf", "Enable Snapshot", "yes", "FileSet")'
+$bperl -e 'add_attribute("$conf/bacula-dir.conf", "Snapshot Retention", "300", "Client")'
change_jobname CompressedTest $JobName
start_test
status client
wait
messages
+list
@output ${tmp}/list1
list files jobid=1
+@$out ${tmp}/list1.snap_list
+.jlist snapshot
+@$out ${tmp}/list1.snap_listclient
+snapshot listclient
+@$out ${tmp}/list1.snap_update
+snapshot update client snapshotid=1 comment="test1"
+snapshot update client snapshotid=1 retention=3
+@$out ${tmp}/list1.snap_list2
+.jlist snapshot snapshotid=1
+@$out ${tmp}/list1.snap_list22
+.jlist snapshot snapshotid=3
+@$out ${tmp}/list1.snap_prune
+@sleep 4
+snapshot prune client yes
+@$out ${tmp}/list1.snap_list3
+.jlist snapshot
+@$out ${tmp}/list1.snap_listclient2
+snapshot listclient
+quit
END_OF_DATA
run_bacula
+# Can be used to issue commands from an other terminal
+#echo pause
+#read a
+
+grep '{' $tmp/list1.snap_list | perl -MJSON -e '
+$l = <>;
+$j = JSON::decode_json($l) ;
+exit (scalar(@{$j->{data}}) == 2);'
+
+if [ $? != 1 ]; then
+ print_debug "ERROR: Incorrect data in $tmp/list1.snap_list"
+ estat=1
+fi
+
+nb=`grep deleted $tmp/list1.snap_prune | wc -l`
+if [ $nb != 1 ]; then
+ print_debug "ERROR: Should prune one snapshots"
+ estat=1
+fi
+
+# snapshot updated
+grep '{' $tmp/list1.snap_list2 | perl -MJSON -e '
+$l = <>;
+$j = JSON::decode_json($l) ;
+exit (scalar(@{$j->{data}}) == 1 && $j->{data}->[0]->{comment} eq "test1" && $j->{data}->[0]->{retention} == 3);'
+
+if [ $? != 1 ]; then
+ print_debug "ERROR: Incorrect data in $tmp/list1.snap_list2"
+ estat=1
+fi
+
+# One snapshot gone
+grep '{' $tmp/list1.snap_list3 | perl -MJSON -e '
+$l = <>;
+$j = JSON::decode_json($l) ;
+exit (scalar(@{$j->{data}}) == 1);'
+
+if [ $? != 1 ]; then
+ print_debug "ERROR: Incorrect data in $tmp/list1.snap_list3"
+ estat=1
+fi
+
+
check_for_zombie_jobs storage=File
cat <<END_OF_DATA >${tmp}/bconcmds