Bash script to 'complain' when a directory is 1% lower than the last days directory

Prof.Merlin

Expert Member
Joined
Aug 2, 2006
Messages
1,695
Reaction score
201
Location
Netherlands
Basically we have backups running to a tape.

Want to kinda "verifiy" if the backup was sucessful. So was thinking of running a backup today and getting the filesize. Then tomorrow it does the backup again and gets the filesize. If the filesize is 1% less than what it was yesterday, it must notify me.

Anybody know how to write a script to do something like that?

Or if there is an easier way of checking that the backup was complete?

Thanks
 
If you happen to be using AMANDA, see here for a few options.

You could also use the cksum utility to calculate the CRC checksum and byte size of each file that you want to backup, which should then be the same as those on your backup media, but IMHO using amrecover would be a better option because "verified" backups are useless if you are unable to restore them when the time comes (and it always does).
 
Okay here is something basic

df -h | grep /directory | awk '{ print $5 }'

This will give the current % used in that directory

From there you could do an if script that will check this percentage against the saved one from yesterday. Given a little more time I could do one, the basics would be setup a crontab to run the script at a certain time, the script will create/update a file with the previous %, run an if check against the previous value to see if if it's < or > then previous one, then send alert via mailx or something similar.
 
Top
Sign up to the MyBroadband newsletter
X