- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- need backup script help
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2002 10:03 AM
04-10-2002 10:03 AM
mediawrite -f
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2002 10:04 AM
04-10-2002 10:04 AM
Re: need backup script help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2002 04:06 AM
04-11-2002 04:06 AM
Re: need backup script help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2002 04:52 AM
04-11-2002 04:52 AM
SolutionIt looks as though you are already there with what you want from the script but just need help putting it together?
Are you going to give users the choice of files to back up ? output devices etc
If so, to keep things simple I would you examples such as
#!/usr/bin/sh
echo "What would you like to do ?"
echo " Enter 1 if you wish to back up a file"
echo "Enter 2 if you wish to back up a directory"
echo --------------------------
echo " Please enter your choice \c"
read choice
echo "which files/directory do you wish to back up ? \c"
read files
echo "Here are you list of available output devices"
echo " /dev/rmt/0m "
echo " /dev/rmt/1m "
echo " /dev/rmt/2m "
echo "Please type the full device name \c "
read device
# from the users choice
case $choice in
1) < command > > /tmp/log 2> /tmp/errors
2) < command > > /tmp/log 2> /tmp/errors
;;
*) echo " you have not pressed a valid key
esac
You have 2 variables , files and device, when you enter your commands the choices entered from the user will be entered into the command as $files and $device
Is this the kind of thing you are after ?
Or something more complex
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2002 05:16 AM
04-11-2002 05:16 AM
Re: need backup script help
if you wish to pass arguments to your script you will could read up on getopts.
while getopts ":ab:c" opt; do
case $opt in
a) process options -a ;;
b) process options -b ;;
c) process options -c ;;
esac
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2002 05:17 AM
04-11-2002 05:17 AM
Re: need backup script help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2002 05:58 AM
04-11-2002 05:58 AM
Re: need backup script help
You either give the user a choice of medium names, then
read medium
or at the beginning of the script specify the medium
medium1=
your variable is then $medium_name which you simply pass into your full command
same goes with your output destination
I'm at home at the moment, but back in over the weekend. It's fairly quite then so if you haven't got a full solution I'll put more ideas down for you. I'm fairly new to scripting so it will be good practice for me also
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2002 06:08 AM
04-11-2002 06:08 AM
Re: need backup script help
Just one more before I log off. After each command there will always be an exit code of either 0 = successful or 1 = failure
You can perform commands depending on the outcome of the exit code of your previous commands
ie
mediawrite
if [$? = 0 ]
then
else
if [ $? = 1 ]
then
fi
Regards
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2002 06:22 AM
04-11-2002 06:22 AM
Re: need backup script help
what do you mean by "media" with the "-m" option?
And you are going to have issues using the same option flag "-d" in your second example. Why not just have "-f" handle single files and directories?
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2002 07:01 AM
04-11-2002 07:01 AM
Re: need backup script help
-m media is differnet tape drive, -o output format is tar/cpio.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2002 07:02 AM
04-11-2002 07:02 AM
Re: need backup script help
live free or die
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2002 07:18 AM
04-11-2002 07:18 AM
Re: need backup script help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2002 10:23 AM
04-14-2002 10:23 AM
Re: need backup script help
Have attached script ( not finished ) as I had a few problems come in over the weekend
You think initially it's quite simple but it does get complicated when user intervention comes into the equation
Have a look anyway. The more I got it into the more I thought of how functions and getopts would make things easier when putting it together.
As previously mentioned, i'm only 2 months into scripting so have got a long way to go before I become proficent
I haven't checked the 1st case
What comes into the equation is the location of the files requested to be backed up and whether they are actually there etc etc
I am going to finish it when I get chance
Have a look anyway and see what you think
you should be able to complete or adjust it to suit your needs
Regards
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2002 04:55 AM
04-16-2002 04:55 AM
Re: need backup script help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2002 05:37 AM
04-16-2002 05:37 AM
Re: need backup script help
Your script is really good. I did want to look further into getops, but didn't get chance to.
Now you have given me a good example i can hopefully incorporate it more
Ok
I've printed the script , and as far as I can see you have got the user to specify the log file
l) LOG_FILE=$OPTARG;;
when checking whether correct arguments have been passed you just use
exit 1
This will just exit the script but not send anything to the log file
you could use
echo "exit 1 because $FILE_PATH not supplied by $LOGNAME" >> $LOG_FILE
Also pass the output of your backup commands to the log file again with the use of >> $LOG_FILE after the command
You can pass to both stdout and log file with the use of the tee command if you require
ie
tar -cvf $DEVICE $FILE_PATH | tee $LOG_FILE
What do you think ?
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2002 07:28 AM
04-16-2002 07:28 AM
Re: need backup script help
Thanks