Context :
I needed to have all my nagios files on my computer to be able to run some python scripts trying to figure out what refactoring needed to be done, and identifying gaps in the configuration I inherited.
I took that opportunity to version all our nagios configuration files, with a git repository configured at the /usr/local/nagios/etc level.
That proved itself useful to gain some confidence that we're not going to loose anything.
Initial idea was taken from :
Script to automatically commit changes done in Nagios and push them to the central repo.
NB : still a few things to investigate, but ...
auto-git-commit-push.sh
cd /usr/local/nagios/etc \
&& /bin/git pull \
&& /bin/git add -A \
&& /bin/git commit -m "updated nagios dynamic files $(date) -- automatic commit" \
&& /bin/git push origin master \
&& /bin/git pull \
&& if ! $(grep -lr '<<<<<<<' . ) ; then grep -lr '<<<<<<<' . | xargs git checkout --ours; ./$0; fi