Backing Up and Restoring Log Database


You can manually backup log database and backup can be restored.

Step 1: Repository Creation

Log database can be manually backed by command prompt and backup can be restored.

curl -XPUT 'http://localhost:9200/_snapshot/repositoryName?pretty' -H 'Content-Type:application/json' 
-d "{"type":"fs", "settings":{"location":"/storeLocation", "compress":true}}"

When creating a log server on the Server Management screen, the directory information is entered in the ES Data Path field where the log server’s repositories will be located. The repository is generated at that location based on the index information in this field.

When executing command lines on Windows, punctuation marks such as double quotes (“), less than (<) and greater than (>) in the body of the request sent to the log server may give an error.

curl -XPUT "http://localhost:9200/_snapshot/repositoryName?pretty" -H "Content-Type:application/json"
-d "{\"type\":\"fs\",\"settings\":{\"location\":\"storeLocation\", \"compress\":true}}"
                                        

Step 2: Taking Snapshot

Snapshots are taken to copy or restore indexes. Snapshots are kept in the repository. When this is done, backups can be moved to another location, deleted indexes can be deleted or restored.

curl –XPUT  "http://localhost:9200/_snapshot/repositoryName/snapshotName?wait_for_completion=true" 
-H "Content-Type: application/json" 
–d "{"indices":"apilogs20180924, apilogs20180923, apilogs20180922", "ignore_unavailable":true, "include_global_state": false}"
"indices":"<apilogs{now{YYYYMMdd}}>,<apilogs{now-d{YYYYMMdd}}>,<apilogs{now-2d{YYYYMMdd}}>"

Step 3: Restore a Backup

All or some of the indexes in snapshot can be restored.

curl -XPOST "http://localhost:9200/_snapshot/repositoryName/snapshotName/_restore?pretty" 
-H "Content-Type: application/json" 
-d "{"indices":"apilogs20180924, apilogs20180923","ignore_unavailable":true,"include_global_state": false}"

The following commands can help during backup and restore operations.

  • For information on all the repositories in the cluster;
curl -XGET “http://localhost:9200/_snapshot/_all?pretty”
  • To learn about snapshots in a repository;
curl -XGET “http://localhost:9200/_snapshot/snapshotName/_all?pretty”
  • To delete the snapshot or stop the process during snapshot;
curl -XDELETE "http://localhost:9200/_snapshot/snapshotName"