!/bin/bash
script to check all of the backups at anders and send the results in an email
2009-07 johnpfeiffer
check the linux bacukps sorted by time, show all hidden and attributes (head only shows the top items)
awk then only shows columns 5,6,7 and 8 and then it overwrites the last email-backup.txt file
ls -tahl /mnt/anders-crm-external/linux-backups/ | head | awk '{print $5,$6,$7,$8,$9}' > email-backup.txt
the -e allows interpretation of backslashes, \n means newline, >> appends to the end of the file
echo -e "\n------------------------------------------------------------------------------\n" >> email-backup.txt
check the acronis images and system state jobs on the external hard drive, append the top 20 lines to the email-backup.txt file
ls -tahl /mnt/external/ | head -n 20 | awk '{print $5,$6,$7,$8,$9}' >> email-backup.txt
echo -e "\n------------------------------------------------------------------------------\n" >> email-backup.txt
check the sql server native backup to the external\sqlback folder
ls -tahl /mnt/external/sqlback/Anders_MSCRM | awk '{print $5,$6,$7,$8,$9}' >> email-backup.txt ls -tahl /mnt/external/sqlback/WSS_Cont_80 | awk '{print $5,$6,$7,$8,$9}' >> email-backup.txt
echo -e "\n------------------------------------------------------------------------------\n" >> email-backup.txt
replace the single spaces with tabs and write to a new file
sed -e 's/ /\t /g' email-backup.txt > email-backup-formatted.txt
add the information about the brightstor backup - temporarily mount the shared folder
mount -t smbfs -o username=backup,password=pass- //anders-crm/ARCserve$ /mnt/brightstor tail -n 30 /mnt/brightstor/LOG/BrightStor.log >> email-backup-formatted.txt umount /mnt/brightstor
format the text to be windows compatible (carriage returns at the end)
sed -e 's/$/\r/' email-backup-formatted.txt > email-backup.txt
mail -s daily-backup backups@domain.com < email-backup.txt