Reputation: 11
Anyone to give pointers or ideas.
I have a server, that is running rsync and backs up other servers to itself on different folders creating new folders by date everyday e.g(2017-03-20). i want to create a bash script that will check if these backups have run, by checking the created folders and then if all backups were successfully the script will confirm by writing a text file in another folder /Z, the text file with format 20-17-03-20. If any of the backups fail the script should just exit and not create the file.
The whole point is, i will then do a nagios plugin script to be checking this text file daily and sending results to Nagios daily.
Any ideas will be most welcome.
Upvotes: 1
Views: 634
Reputation: 935
First add the epel repo -
sudo rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
Then install the inotify-tools -
sudo yum install inotify-tools
Write a script running and indefinite loop monitoring the specific directory (where you expect the backup script to generate directory).
#!/bin/sh
while true
do
inotifywait -r -e modify,create,delete /<directory> && /bin/sh <script_confirming _backup>
done
The -e
flag check for mentioned events. You can add up events as per your monitoring requirement.
The -r
flag will look for all the directories and sub-directories under the mentioned directory recursively.
Upvotes: 2