Deployment Architecture
Highlighted

Script to backup of Splunk

Engager

Does anyone have an example of a backup script for Splunk

Tags (1)
Highlighted

Re: Script to backup of Splunk

Explorer

Hi

This will need some tweeking, but here we go:

#!/bin/bash
SPLUNK="/opt/splunk"
CONFIG="/opt/splunk/etc"
BUCKETS="/opt/splunk/var/lib/splunk/"
ADMU={admin-user-name}
ADMP={admin-password}
INDEX={index you need to roll}
SPLUNKHOME="/opt/splunk"
SPLUNK
DB="/opt/splunk/var/lib/splunk"

mount /mnt/backup
set $(date)

for i in ls /opt/splunk/var/lib/splunk ; do $SPLUNKHOME/bin/splunk _internal call $SPLUNKDB/roll-hot-buckets –auth $ADMU:$ADMP ; done

if test "$1" = "Sun" ; then
# weekly a full backup of all data and config. settings:
#
tar cfz "/backup/data/datafull$6-$2-$3.tgz" $BUCKETS –-exclude='hot_' ; done
rm -f /backup/data/datadiff*
#
tar cfz "/backup/config/config
full$6-$2-$3.tgz" $CONFIG
rm -f /backup/config/config
diff*
else
# incremental backup:
#
find $BUCKETS -depth -type f ( -ctime -1 -o -mtime -1 ) -print > $LIST
tar cfzT "/backup/data/datadiff$6-$2-$3.tgz" "$LIST" –-exclude='hot_' ; done
rm -f "$LIST"
#
find $CONFIG -depth -type f ( -ctime -1 -o -mtime -1 ) -print > $LIST
tar cfzT "/backup/config/configdiff$6-$2-$3.tgz" "$LIST"
rm -f "$LIST"
fi

View solution in original post