Linux forum

Question

Script

Hi I am trying to write a script to perform backups on ubuntu. There should be 3 options exit, backup all and backup selected files the first 2 work but stuck on the select backup so far I have anyone able to help me out?
#method to show a welcome message
showWelcome () {
echo "*****************"
echo $1
echo "*****************"
}
showWelcome "Welcome to my script"
AllBackup= "AllBackup"
menuitems= 'Backup_All_Files Backup_Selected_Files exit'
select menuitem in $menuitems
do
echo "Select Option:"
if [ $menuitem == 'exit' ]
then
break
elif [ $menuitem == 'Backup_All_Files' ]
then
read Outcome3
mkdir $AllBackUp
cp -a Home/Outcome3 $AllBackUp
elif [ $menuitem == 'Backup_Selected_Files' ]
then
mkdir $SelectBackUp
echo "input folder"
read Outcome3
echo "input wildcard"
read WILDCARD
fi
done

Answer This Ask For Clarification
Discussion is locked
You are posting a reply to: Script
The posting of advertisements, profanity, or personal attacks is prohibited. Please refer to our CNET Forums policies for details. All submitted content is subject to our Terms of Use.
Track this discussion and email me when there are updates

If you're asking for technical help, please be sure to include all your system info, including operating system, model number, and any other specifics related to the problem. Also please exercise your best judgment when posting in the forums--revealing personal information such as your e-mail address, telephone number, and address is not recommended.

You are reporting the following post: Script
This post has been flagged and will be reviewed by our staff. Thank you for helping us maintain CNET's great community.
Sorry, there was a problem flagging this post. Please try again now or at a later time.
If you believe this post is offensive or violates the CNET Forums' Usage policies, you can report it below (this will not automatically remove the post). Once reported, our moderators will be notified and the post will be reviewed.
Collapse -
Clarification Request
Next time?

In reply to: Script

You wrote what looks to be fine enough script but next time drop a clue where you need new lines.
Example:
"read WILDCARD
--->> What do you suggest here?
fi
"

I had to read your request and figure out if the other lines were valid before I could guess where you needed new script lines. You may know this but the rest of us have to guess.

I'm thinking something like

cp -a Home/Outcome3/$WILDCARD $AllBackUp

If you need to make the target folder then add code to that. I assume all the lines you supplied worked so far. And you can deal with necessary $ and escapes for your shell script.

All Answers

Collapse -
Answer
Re: script

In reply to: Script

Scripts are the hard way. Use TimeShift for backups.

Popular Forums

icon
Computer Newbies 10,686 discussions
icon
Computer Help 54,365 discussions
icon
Laptops 21,181 discussions
icon
Networking & Wireless 16,313 discussions
icon
Phones 17,137 discussions
icon
Security 31,287 discussions
icon
TVs & Home Theaters 22,101 discussions
icon
Windows 7 8,164 discussions
icon
Windows 10 2,657 discussions

DEALS, DEALS, DEALS!

Best Black Friday Deals

CNET editors are busy culling the list and highlighting what we think are the best deals out there this holiday season.