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.
r_hortonAsked:
Who is Participating?
 
tfewsterConnect With a Mentor Commented:
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.

0
 
kawinCommented:
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.
0
 
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.
0
 
tfewsterCommented:
The following script will do your backup & verify and can go in your crontab;  I'm not sure about the mail addressing tho'

#!/sbin/sh
# 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


0
 
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.
0
All Courses

From novice to tech pro — start learning today.