Unix CPIO backupscript

I currently use a simple cpio command to backup my system manually every morning (SCO OpenServer 5.0.5).  However I would like to setup a script in the cron to run this command everyday at a specific time but also run a verification and have it email me the standard error and verification results, as well as if there was a failure.  Does anyone have a simple script that will does this.  I was told it can be done in about 4 line of shell scripting.  I just don't know how.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Cron will mail the result back to owner by default. Don't do anything.

You only put your cpio command to root cron. It so easy.
r_hortonAuthor Commented:
I need the script to launch in root's cron and email me when it starts, when it ends, and any errors it has incurred.  And I wan't the mail part to go to a specific internet email account.  I already of the internet email active on this Sco Unix Box.
The following script will do your backup & verify and can go in your crontab;  I'm not sure about the mail addressing tho'

# The contents of the final mail message enable the user
# to distinguish between write and verify errors
# Examining the files lists timestamps/contents will give
# more information on any failures

mail username < echo "Backup started"
rm /tmp/bufiles /tmp/verfiles 2> /dev/null
echo "Backup failed: Check tape drive" > buerr
find data -print |tee /tmp/bufiles |cpio -o > dumpdev 2> /tmp/buerr
mail username < echo "Backup done; Verify starting"
cpio -it < dumpdev > verfiles 2>> /tmp/buerr
diff /tmp/bufiles /tmp/verfiles >> /tmp/buerr
mail username < /tmp/buerr

r_hortonAuthor Commented:
I dont believe the script you sent me does anything to verify the tape status, however I do see the "Backup failed: Check Tape Drive" email, but nothing that would verify this before emailing it.  Please respond.
It does look a bit confusing, especially as I've missed the /tmp/ off the front of some of the temporary filenames :(

To step thru the script: It creates buerr with a "failure" message; If the cpio -o part works, it will overwite buerr with the total number of blocks cpio backed up

"cpio -it" reads the filenames on the tape & the total blocks on the tape; If it reaches the end without errors, you can be confident your tape is readable and has the the right amount of data on it on it (number of blocks read from tape is also written to "buerr")

So your mail messages each morning should consist of 2 lines, representing the number of blocks written to tape, followed by verification of the number of blocks read from tape.

If the tape was missing/write protected/failed part way thru, you would be able to work out at what stage it failed.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.