#!/bin/bash
find . -type d
dateTime=$(/bin/date +"%Y_%h_%d_%H_%M_%S")
read -p "Please press y to continue with backup or press x to exit this menu:" option1
if [ "$option1" == "y" ];then
echo "You have selected 'y', starting backup now"
read -p "Please enter a directory name to backup:" dir1
if [ -d $dir1 ];then
echo Directory found, backing up now
tar cfz $dir1.$dateTime.tar.gz $dir1
echo "Backup for directory $dir1 was successful"
read -p "would you like to continue or exit now? press y to continue or x to exit:" option2
if [ "$option2" == "y" ];then
echo "You have selected 'y', starting backup now"
read -p "Please enter a directory name to backup:" dir2
if [ -d $dir2 ];then
echo Directory found, backing up now
tar cfz $dir2.$dateTime.tar.gz $dir2
echo "Backup for directory $dir2 was successful, exiting now"
exit
else
echo Directory not found, exiting now
exit
fi
fi
if [ "$option2" == "x" ];then
echo you have selected x to exit, exiting now
exit
fi
else
echo Directory not found
read -p "Would you like to try again or exit? Press Y to continue or X to exit:" option3
if [ "$option3" == "y" ];then
echo "You have selected 'Y', starting backup now
read -p "Please enter a directory name to backup:" dir3
if [ -d $dir3 ];then
echo Directory found, backing up now
tar cfz $dir3.$dateTime.tar.gz $dir3
echo "Backup for directory $dir3 was successful, exiting now"
exit
else
echo Directory not found, exiting now
exit
fi
fi
if [ "$option3" == "x" ];then
echo you selected x, exiting now
exit
fi
fi
fi
if [ "$option1" == "x" ];then
echo you selected x, exiting now
fi
if [ "$option1" != "y" ] || [ "$option1" != "x" ];then
echo I was expecting y or x , I didn't get what you entered, bye
exit
fi
|