Hi All,
Looking for some assistance. I'm fairly new to bash scripting, and here's the scenario.
Each week on our servers, we login to check all the backups have been taken correctly and are up to date. (We've had issues with NAS mounts and so on in the past, so need to manually check).
When we login we'll navigate to the directory containing the backups, do an 'll' command and check the dates on the files to see if they're recent (i.e. taken within the last 10 days).
We're trying to change this so that on a cron, once weekly, we are emailed a directory listing as a 'backup report' - this is easily done as follows:
ll /mnt/nas/server1 | mutt -s "NAS BACKUP REPORT - SERVER1"
email@address.com
Now we want to get a bit more advanced, and make the script more generic rather than hardcoding the server name for the directory and subject.
Firstly, we'd like to print the results in date order, or even better, the script will check if there are no files backed up in the last 10 days, and then email us a 'NAS BACKUP REPORT - WARNING, OUT OF DATE BACKUPS' if it fails, and a 'SUCCESS' if the files are up to date.
Also, as we'll be running the script across various servers, we'd like to be able to send a variable from the crontab with the server name in it so we dont have to have a different .sh file for each server.
If anyone can help, that would be great!