BashScripts.org
http://bashscripts.org/forum/

backups location
http://bashscripts.org/forum/viewtopic.php?f=15&t=1296
Page 1 of 1

Author:  BrianUK [ Mon Jan 31, 2011 2:04 pm ]
Post subject:  backups location

I have a small bash menu for carrying out various tasks, i'd like to add in a backup option with different locations i'm using the following code

Code:
backups() {
clear               
echo "Backup Control"
echo
select CHOICE in 'Backup System' 'Backup Home'
do
   case "$CHOICE" in
      "Backup System")


After i've selected 'Backup System' or 'Backup Home' i'd like it to give me the option of a location ie
1) Local
2) External Disk

ie local would be /backups external disk would be /dev/sda1 what i'd like to know is how to create this extra bit of the menu. I'm guessing it would be using read and if?

thanks

Author:  crouse [ Thu Feb 03, 2011 8:44 pm ]
Post subject:  Re: backups location

Code:
backups ()
{
clear
echo "Backup Control"
echo " "
echo "1.) Backup to Local Drive"
echo "2.) Backup to External Drive"
echo " "
read -p "Enter number of your choice: " choice
   case $choice in
      "1")   DOSOMETHINGHERE;
         ;;
      "2")   DOSOMETHINGHERE;
         ;;
      "0")   exit 0; #Done
         ;;
      *)   echo "     That choice was invalid!! Exiting!"; exit 1
         ;;
   esac
}


HTH's

Author:  BrianUK [ Sun Feb 06, 2011 2:56 pm ]
Post subject:  Re: backups location

thanks Crouse, how do I make it

1, Backup to Local Drive
2, Backup to External Drive

1, Backup home
2, Backup System

user selects 1+1 it executes command blah
user selects 2+1 it executes command blah blah
etc

Author:  crouse [ Tue Feb 15, 2011 10:39 pm ]
Post subject:  Re: backups location

You could do something like this ... obviously there is more than one way to do this..

Code:
backups ()
{
clear
echo "Backup Control"
echo " "
echo "1.) Backup to Local Drive"
echo "2.) Backup to External Drive"
echo " "
read -p "Enter number of your choice: " choice
   case $choice in
      "1")   bu2local;
         ;;
      "2")   bu2external;
         ;;
      "0")   exit 0; #Done
         ;;
      *)   echo "     That choice was invalid!! Exiting!"; exit 1
         ;;
   esac
}

bu2external ()
{
echo "1 - Backup Home"
echo "2 - Backup System"
read -p "Enter Choice: " response
########## IF/THEN LOOP GOES HERE WITH COMMANDS (if response = 1 then do something ...etc)
}

bu2local ()
{
echo "1 - Backup Home"
echo "2 - Backup System"
read -p "Enter Choice: " response
########## IF/THEN LOOP GOES HERE WITH COMMANDS (if response = 1 then do something ...etc)
}

Page 1 of 1 All times are UTC - 6 hours
© 2000, 2002, 2005, 2007 phpBB Group • http://www.phpbb.com