Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Backup shell scripting program

Posted on 2004-10-21
3
Medium Priority
?
224 Views
Last Modified: 2010-05-18
Good afternoon gentlemen...I'm writing a backup shell script on Fedora Linux server. The purpose of the script is back-up weekly files to an internal tape drive. I have everything execpt when the tape is finished at the recording, I need to develop an if statement so that when it reaches the end of the tape it will eject the tape and send a message to the administrator that the tape has been ejected. I have a sample script below, but the if statement is the one I need help with, what do I use to specify the tape is at the end, is it 0. Script below


!#/bin/sh

File_st="/var/log"
tape_drive="/dev/sto"
cd $File_st
find . print | cpio -ovH crc -O /dev/nst0

if ( $tape_drive = ????)
then

eject $tape_drive
mail "tape is finished" > admin@localhost

else

mail "date% this weeks backup is complete" > admin@localhost


any modifications will be welcomed.
0
Comment
Question by:ritru
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 38

Accepted Solution

by:
wesly_chen earned 1000 total points
ID: 12375939
Hi ritru,

  The line should change to
find . print | cpio -ovH crc -O /dev/nst0
===>  find . -name <filename> -print -exec cpio -ovH crc -O {} /dev/st0 \;

   If you just copy whatever under /var/log, then just use "cpio". No need for find command.

   Besides, you can check the status of cpio, if it fail, then you need to check the tape or the backup log.
Not just check whether tape full (if tape were full, then the cpio would error out, and the status will be 1:fail).

Regards,

Wesly
0
 

Author Comment

by:ritru
ID: 12382590
So what you saying is I can do an

if [$tape_drive == -1] then

eject $tape_drive
mail "tape has finished" > admin@localhost

else

cd $File_st
find . print | cpio -ovH crc -O /dev/nst0
mail "date% this weeks backup is complete" > admin@localhost

fi

This would resolve if the tape is full or not...One more question is that the correct command to prompt for the date or am I missing something.... My mail command is correct right?  Anyway thank you for time and patience.

0
 
LVL 38

Expert Comment

by:wesly_chen
ID: 12406183
Well,
the return status code is stored in $status.

So if you do
cpio -ovH crc -O /var/log /dev/st0
and cpio fails for any reason including "tape full".
Then the $status is set to "1" automically.
So it should be:
--------------------------
cpio -ovH crc -O $File_st /dev/st0

if [ $status == 1 ] then
mail "backup failed" > admin@localhost
else
mail "date% this weeks backup is complete" > admin@localhost
fi
----------------------------

Regards,

Wesly
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question