Register
It is currently Thu Apr 24, 2014 12:11 am

backups location


All times are UTC - 6 hours


Post new topic Reply to topic  [ 4 posts ] 
Author Message
 PostPosted: Mon Jan 31, 2011 2:04 pm   

Joined: Fri May 16, 2008 4:58 am
Posts: 94
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


Top
 Profile  
 PostPosted: Thu Feb 03, 2011 8:44 pm   
Site Admin
User avatar

Joined: Sun May 15, 2005 9:36 pm
Posts: 657
Location: Des Moines, Iowa
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


Top
 Profile WWW  
 PostPosted: Sun Feb 06, 2011 2:56 pm   

Joined: Fri May 16, 2008 4:58 am
Posts: 94
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


Top
 Profile  
 PostPosted: Tue Feb 15, 2011 10:39 pm   
Site Admin
User avatar

Joined: Sun May 15, 2005 9:36 pm
Posts: 657
Location: Des Moines, Iowa
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)
}


Top
 Profile WWW  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP