This article came about due to an administrator noticing bucket timestamp inconsistencies when comparing search results with apparent most recent timestamps as they appear in an indexer's Web UI under Settings > Indexes (while mousing over the latest event column for a specific index). The goal of this article is to identify events that had been removed from search using the |delete command. For the scenario encountered, the events being sought were dated far into the future, as the indexer's Web UI showed the most recent events for some indexes being future-dated, but searches on the UI did not pull up such events. However, the process outlined here could be followed to identify or restore "deleted" events for any reason.
In Splunk, the |delete command appended to the end of a search will "soft delete" all events that appear in said search. What this means is that the events are not removed from the buckets in which they are indexed. They are simply flagged as "deleted" so they will no longer show up in searches. For guidance on using the |delete command in search, please refer to the following links:
When |delete is run on a search, Splunk places a deletes folder inside the rawdata folder for all affected buckets in the impacted index(es). That folder contains the details of all events that should not appear in search. Only one such folder is generated, regardless of how many times that particular bucket is impacted by use of the command.
The steps in this article will restore ALL events removed from search using the |delete command. It will not offer solutions on how to restore selected events. Best practice in that scenario is to re-delete any events that should remain deleted.
IMPORTANT NOTE: This process is not simple and involves re-indexing data (which may have a negative impact on license usage). ANY attempts to modify already-indexed data carries inherent risk of data loss and should be carried out with extreme caution and only by a Splunk Administrator well-versed in such processes. As a best practice, Splunk suggests following best practices for data management, which typically does not include a process such as this. It is provided for specific purposes and admins are very strongly advised to carry out such activities in a non-production environment.
The process below worked in a test environment, based on this non-Splunk link (which is NOT Splunk provided or endorsed documentation). It will NOT work if SmartStore is enabled.
Buckets are stored in folders. In this article, references to a "bucket name" mean how the bucket folder is named in the file system. For example:
db_<lastest_event_epoch_time>_<earliest_event_epoch_time>_<bucket_number>db_1763762872_1763762872_1db_<lastest_event_epoch_time>_<earliest_event_epoch_time>_<bucket_number>_<GUID_of_this_indexer>rb_<lastest_event_epoch_time>_<earliest_event_epoch_time>_<bucket_number>_<GUID_original_indexer>db_1763762391_1763528400_0_0C4590DC-1477-4AA7-ACC6-8CA33F76D913
rb_2140488000_1793595600_2_0C4590DC-1477-4AA7-ACC6-8CA33F76D913
|dbinspect search to identify all buckets in an index|dbinspect on the index over all time. This may take some time to complete. It will list all buckets in the index. In a clustered environment, it will also identify exactly which indexers have each copy. Use these results to verify you have identified all copies of each impacted bucket.|dbinspect index=<yourindex>
Example:|dbinspect index=gamelog
Example results:
deletes folder. Replace <path_to_index> with the absolute path to the affected index
find <path_to_index> -type d -name "deletes"
Example result (results can include buckets in both the db and colddb directories, assuming these are on the same mount point. If they are on separate mount points, the search should be to run on each):[splunker@idx1 ~]$ find /opt/splunk/var/lib/splunk/gamelog -type d -name "deletes"
/opt/splunk/var/lib/splunk/gamelog/db/db_2140488000_1793595600_2_0C4590DC-1477-4AA7-ACC6-8CA33F76D913/rawdata/deletes
<index> with the impacted index, and replace <latest> and <earliest> with the actual epoch timestamps in the bucket itself.index=<index> latest=<latest> earliest=<earliest>
Example:
index=gamelog latest=2140488000 earliest=1793595600
|dbinspect in test search head to identify where it placed a replicated copy.
<yourindex> with the name of the impacted index, <filename> with your chosen name for the tar'd file and <bucketname> with the full folder name of the bucket to be tar'd:
cd /opt/splunk/var/lib/splunk/<yourindex>
tar -czvf <filename>.tar.gz <bucketname>
cd ~
ls -l
Example:
[splunker@idx1 ~]$ cd /opt/splunk/var/lib/splunk/gamelog/db
[splunker@idx1 db]$ tar -czvf ~/gamelogbucket.tar.gz db_2140488000_1793595600_2_0C4590DC-1477-4AA7-ACC6-8CA33F76D913
db_2140488000_1793595600_2_0C4590DC-1477-4AA7-ACC6-8CA33F76D913/
db_2140488000_1793595600_2_0C4590DC-1477-4AA7-ACC6-8CA33F76D913/rawdata/
db_2140488000_1793595600_2_0C4590DC-1477-4AA7-ACC6-8CA33F76D913/rawdata/journal.zst
db_2140488000_1793595600_2_0C4590DC-1477-4AA7-ACC6-8CA33F76D913/rawdata/slicesv2.dat
db_2140488000_1793595600_2_0C4590DC-1477-4AA7-ACC6-8CA33F76D913/rawdata/slicemin.dat
db_2140488000_1793595600_2_0C4590DC-1477-4AA7-ACC6-8CA33F76D913/rawdata/deletes/
db_2140488000_1793595600_2_0C4590DC-1477-4AA7-ACC6-8CA33F76D913/rawdata/deletes/e42a246b1d6cd6ac199a1480307e67e3.csv.gz
db_2140488000_1793595600_2_0C4590DC-1477-4AA7-ACC6-8CA33F76D913/rawdata/deletes/b490bdc3a156f5f8058d4bc6bb05d318.csv.gz
db_2140488000_1793595600_2_0C4590DC-1477-4AA7-ACC6-8CA33F76D913/bucket_info.csv
db_2140488000_1793595600_2_0C4590DC-1477-4AA7-ACC6-8CA33F76D913/Hosts.data
db_2140488000_1793595600_2_0C4590DC-1477-4AA7-ACC6-8CA33F76D913/Sources.data
db_2140488000_1793595600_2_0C4590DC-1477-4AA7-ACC6-8CA33F76D913/SourceTypes.data
db_2140488000_1793595600_2_0C4590DC-1477-4AA7-ACC6-8CA33F76D913/Strings.data
db_2140488000_1793595600_2_0C4590DC-1477-4AA7-ACC6-8CA33F76D913/.rawSize
db_2140488000_1793595600_2_0C4590DC-1477-4AA7-ACC6-8CA33F76D913/optimize.result
db_2140488000_1793595600_2_0C4590DC-1477-4AA7-ACC6-8CA33F76D913/bloomfilter
db_2140488000_1793595600_2_0C4590DC-1477-4AA7-ACC6-8CA33F76D913/.sizeManifest4.1
db_2140488000_1793595600_2_0C4590DC-1477-4AA7-ACC6-8CA33F76D913/2140488000-1793595600-15882901470497181416.tsidx
[splunker@idx1 db]$ cd ~
[splunker@idx1 db]$ ls -l
total 2936304
-rw-r--r--. 1 splunker splunker 4256 Nov 26 19:12 gamelogbucket.tar.gz
[splunker@idx1 db]$
<filename> with your chosen name for the tar'd file, <user> with the user you will log in to the indexer as (preferably the user that runs Splunk), and <test-indexer> with the IP or hostname of your test indexer:scp <filename> <user>@<test-indexer>:~/
In a clustered environment, rinse an repeat for each replicated copy of the impacted bucket. Transfer each replicated copy to a different indexer than where you sent the primary bucket copy)
You are now ready to take real action!
The following steps assume commands are being run from Splunk user account (the OS user that runs Splunk and owns all its files).
$SPLUNK_HOME/bin/splunk enable maintenance-mode
$SPLUNK_HOME/bin/splunk stop
Or, if systemd-managed (may also need to disable the service so it does not restart Splunk):
sudo systemctl stop Splunkd.service
sudo systemctl disable Splunkd.service
Extract the impacted bucket (assumes command is run from the Splunk user's home directory to which the file was sent). Replace <filename> with your chosen name for the tar'd file:
tar -xvf <filename>.tar.gz
$SPLUNK_HOME/bin/splunk status
Or, if systemd-managed:
sudo systemctl status Splunkd.service
<bucketname> with the full folder name of your bucket, and <index> with the name of your index):cp -r <bucketname> /opt/splunk/var/lib/splunk/<indexname>/db/
Example:[splunker@test-idx1 ~]$ cp -r db_2140488000_1793595600_2_0C4590DC-1477-4AA7-ACC6-8CA33F76D913/ /opt/splunk/var/lib/splunk/gamelog/db/
$SPLUNK_HOME/bin/splunk enable maintenance-mode
index=<index> latest=<latest> earliest=<earliest>
deletes folder from the impacted bucket
$SPLUNK_HOME/bin/splunk enable maintenance-mode
Whether environment is clustered or not, stop Splunk the indexer(s) to which you uploaded this bucket:
$SPLUNK_HOME/bin/splunk stop
Or, if systemd-managed:
sudo systemctl stop Splunkd.service
Either MOVE or DELETE the deletes folder in this index:
deletes folder will be saved. For this KB, created /opt/splunk/temp. (ex: mkdir /opt/splunk/temp); alternatively, choose a folder on a mount point that has space available on this indexer. deletes folders will be moved here, hence deletes_<bucket-name> below): mv /opt/splunk/var/lib/splunk/main/<bucket-name>/rawdata/deletes /opt/splunk/temp/deletes_<bucket-name>
Delete:
rm -r /opt/splunk/var/lib/splunk/main/<bucket-name>/rawdata/deletes
<index> with the index and <bucket-name> with the full folder name of the impacted bucket.
/opt/splunk/bin/splunk fsck repair --one-bucket --bucket-path=/opt/splunk/var/lib/splunk/<index>/db/<bucket-name>
$SPLUNK_HOME/bin/splunk start
Or, if systemd-managed:
sudo systemctl start Splunkd.service
$SPLUNK_HOME/bin/splunk disable maintenance-modeindex=<index> latest=<latest> earliest=<earliest>
mv /opt/splunk/temp/deletes_db_2140488000_1793595600_2_0C4590DC-1477-4AA7-ACC6-8CA33F76D913 /opt/splunk/var/lib/splunk/main/db/db_2140488000_1793595600_2_0C4590DC-1477-4AA7-ACC6-8CA33F76D913/rawdata/deletes
OR:
cp -r ~/_db_2140488000_1793595600_2_0C4590DC-1477-4AA7-ACC6-8CA33F76D913/rawdata/deletes /opt/splunk/var/lib/splunk/main/db/db_2140488000_1793595600_2_0C4590DC-1477-4AA7-ACC6-8CA33F76D913/rawdata/
It is possible to restore ALL deleted events in production, but it is not feasible to restore only select deleted events. If do not want all events undeleted, consider undeleting ALL, then very carefully re-deleting only the events that should remain deleted.
To restore the undeleted events to production (sorry this KB is SO LONG -- steps are similar as previous, so providing in condensed (TL;DR) form:
| Revision | Publish Date | Comments |
|---|---|---|
1.0 |
01-Oct-2026
|
Initial Release |