restore wazuh-archive

48 views
Skip to first unread message

Bitemir Myrzash

unread,
Jul 29, 2025, 3:33:33 AM7/29/25
to Wazuh | Mailing List
Hello everyone! 
How can I restore the wazuh-archive index if I accidentally deleted it? There are no snapshots.
I deleted it through the policy, although I set it up to delete it for 60 days.



Md. Nazmur Sakib

unread,
Jul 29, 2025, 3:45:37 AM7/29/25
to Wazuh | Mailing List

Hi Bitemir Myrzash,

To recover these files, you will need JSON gz(ossec-archive-DD.json.gz) files inside
/var/ossec/logs/archives/YEAR/Mon/

If you have those compressed JSON files for archives, you can restore the archive indices following this.

Download the script (recovery.py) from the blog page here.

  1. Let's create a duplicate of the original script: 

  • cp recovery.py recover-arch.py

  1. We need to make one little adjustment to the recover-arch.py script:

  • sed -i 's|logs/alerts/{1}/{2}/ossec-alerts-|logs/archives/{1}/{2}/ossec-archive-|1' recover-arch.py

  1. Let's create a new empty file in the /tmp folder: 

  • touch /tmp/recover-arch.json

  1. Now, let's change the manifest for the archives module to monitor the new file (or edit the file manifest.yml in /usr/share/filebeat/module/wazuh/archives and add the path to the new file):
     

  • sed -i 's|      - /var/ossec/logs/archives/archives.json|      - /var/ossec/logs/archives/archives.json\n      - /tmp/recover-arch.json\n|1' /usr/share/filebeat/module/wazuh/archives/manifest.yml

  1. Restart the service:

  • systemctl restart filebeat

  1. We are ready to execute the script to recover archives, here's an example, replace the parameters accordingly to your needs:

  • nohup /var/ossec/framework/python/bin/python3 recover-arch.py -eps 1000 -min 2025-01-01T00:00:00 -max 2025-07-29T23:59:59 -o /tmp/recover-arch.json -log /tmp/recover-arch.log -sz 4 &


Check this for more information.
Blog - Recover your data using Wazuh alerts backups

Let me know if this works for you.

Bitemir Myrzash

unread,
Jul 31, 2025, 3:43:23 AM7/31/25
to Wazuh | Mailing List
Hello,  Md. Nazmur Sakib!
Thanks a lot. it helped me!
If you have another benefit scprits, can you send it?

вторник, 29 июля 2025 г. в 12:45:37 UTC+5, Md. Nazmur Sakib:

Md. Nazmur Sakib

unread,
Aug 4, 2025, 8:19:46 AM8/4/25
to Wazuh | Mailing List
Hi. I am glad that it helped you. Can you explain a bit more about what you meant by "another benefit scripts"? If you are looking for anything specific, let me know.
Reply all
Reply to author
Forward
0 new messages