#!/bin/bash
# Bash Menu Script Example
echo "=================================================================="
echo -e "\e[1m\e[104mMake consistent backups with LVM with multithreading compression !\e[0m\e[39m"
echo "=================================================================="
echo -e "\e[93mOption 1 sudo vgextend mydell /dev/sdb2"
echo "option 2,3 and 4 for backup mydell-boot"
echo "option 5,6 and 7for backup mydell-root"
echo "option 8,9 and 10 for backup mydell-home"
echo "option 11,12 and 13 for backup mydell-data"
echo "option 14 sudo vgreduce mydell /dev/sdb2"
echo -e "option 15 to stop this script\e[0m\e[39m"
echo -e "------------------------------------------------------------------\a"
PS3='Please enter your choice: '
options=("Option 1" "Option 2" "Option 3" \
         "Option 4" "Option 5" "Option 6" \
         "Option 7" "Option 8" "Option 9" \
         "Option 10" "Option 11" "Option 12" \
         "Option 13" "Option 14" \
         "Option 15 Quit")
select opt in "${options[@]}"
do
    case $opt in
        "Option 1")
	    date
            echo "sudo vgextend mydell /dev/sdb2"
            sudo vgextend mydell /dev/sdb2
            ;;
        "Option 2")
	    date
            echo "sudo lvcreate -L 6G -s -n mysnap /dev/mapper/mydell-boot"
            sudo lvcreate -L 6G -s -n mysnap /dev/mapper/mydell-boot
            ;;
        "Option 3")
	    date
	    echo "python myarchive.py /dev/mapper/mydell-mysnap backup-boot"
            ./myarchive2.pyc /dev/mapper/mydell-mysnap backup-boot 4 4 1000
	    date
            ;;
        "Option 4")
	    date
            echo "sudo lvremove -vf /dev/mapper/mydell-boot"
            sudo lvremove -vf /dev/mapper/mydell-boot
            ;;
        "Option 5")
	    date
            sudo lvcreate -L 6G -s -n mysnap /dev/mapper/mydell-root
            ;;
        "Option 6")
	    date
	    echo "python myarchive.py /dev/mapper/mydell-mysnap backup-root"
            ./myarchive2.pyc /dev/mapper/mydell-mysnap backup-root 4 4 1000
            date
	    ;;
        "Option 7")
	    date
            sudo lvremove -vf /dev/mapper/mydell-root
            ;;
        "Option 8")
	    date
            sudo lvcreate -L 6G -s -n mysnap /dev/mapper/mydell-home
            ;;
        "Option 9")
	    date
	    echo "python myarchive.py /dev/mapper/mydell-mysnap backup-home"
            ./myarchive2.pyc /dev/mapper/mydell-mysnap backup-home 4 4 1000
            date
            ;;
        "Option 10")
	    date
            sudo lvremove -vf /dev/mapper/mydell-home
            ;;
        "Option 11")
	    date
            sudo lvcreate -L 6G -s -n mysnap /dev/mapper/mydell-data
            ;;
        "Option 12")
	    date
	    echo "python myarchive.py /dev/mapper/mydell-mysnap backup-data"
            ./myarchive2.pyc /dev/mapper/mydell-mysnap backup-data 4 4 1000
            date
            ;;
        "Option 13")
	    date
            sudo lvremove -vf /dev/mapper/mydell-data
            ;;
        "Option 14")
	    date
            sudo vgreduce mydell /dev/sdb2
            ;;
        "Option 15 Quit")
	    date
	    echo "=================================================================="
            break
            ;;
        *) echo invalid option;;
    esac
done
