#!/bin/bash

LV_LIST=`mktemp 2>/dev/null`

if [ "x${LV_LIST}" = "x" -o ! -f $LV_LIST ]; then
  exit 0
fi

cd /etc/lvm/backup/

if (shopt -s nullglob dotglob; fs=(onapp-*); (( ${#fs[@]}))); then
  for VG in onapp-*; do
    grep -m1 creation_time $VG|awk '{ print "'$VG' " $3 }' >> $LV_LIST;
    sed '0,/logical_volumes/d' $VG | grep '[A-Za-z0-9_] {' | egrep -v 'segment|snapshot' | awk '{ print "/dev/'$VG'/"$1 }' >> $LV_LIST;
  done
fi

cat $LV_LIST | gzip | base64 -w0
rm -f $LV_LIST

exit 0
