You can compress $SPLUNK_HOME/etc/ and keep backup of compressed file. A simple shell script can do this and you can schedule it for every 24 hours using cron.
#!/bin/bash TIME=`date +%b-%d-%y` # This Command will read the date. FILENAME=splunk-configs-backup-$TIME.tar.gz # The filename including the date. SRCDIR=/opt/splunk/etc # Source backup folder. DESDIR=/backup # Destination of backup file. tar -cpzf $DESDIR/$FILENAME $SRCDIR
00 04 * * * /bin/bash /backup.sh
This will run the script every day at 04:00:00.
Hi, Thanks for the answer.
I have python script, which will do the same. could you please tell me , where should I add this script (directory) & how would I schedule to run for every 24 hours ?
Thanks in advance!
You can copy this script on /opt/splunk/bin/scripts and make it executable and add cron expression in crontab.
# chmod +x /opt/splunk/bin/scripts/test.py
# crontab -e
0 0 * * * /usr/bin/python /opt/splunk/bin/scripts/test.py
Save it. This will trigger this script everyday at midnight.