Restore json via curl

Hello expert,
I want to backup and restore kibana saved objects via curl command. For backup purpose, I created kibana_backup.sh which and below is the backup curl command:-
[root@labelk ~]# cd /usr/local/scripts/
[root@labelk scripts]# ls -ltr
total 8
-rwxr-xr-x 1 root root 1034 Jan 8 11:08 kibana_backup.sh
-rwxr-xr-x 1 root root 363 Jan 8 11:10 kibana_restore.sh
[root@labelk scripts]# cat kibana_backup.sh
#!/bin/bash
#########################

Backup of Kibana saved objects

#########################

KIBANA_VERSION=5.6.3
KIBANA_INDEX=.kibana
timestamp=$(date +%F)

backupdir=/var/backup

Backup kibana saved objects

#curl -u ericadmin:q.3#edsM! -XGET 'http://localhost:9200/$KIBANA_INDEX/dashboard,visualization,search,index-pattern/search' > $backupdir/kibana_saved_objects$timestamp.json 2> /dev/null
curl --user ericadmin:q.3#edsM! -XPOST "http://localhost:9200/$KIBANA_INDEX/search?size=1000&pretty" -d'{"query":{"match_all":{}}}' > $backupdir/kibana_saved_objects$timestamp.json 2> /dev/null

This generates a kibana_saved_objects_2019_x_x.json file. ES and Kibana version=5.6.3 . Could you please assist in how can I recover the json file via restore command?

Try this api: https://www.elastic.co/guide/en/kibana/master/saved-objects-api-create.html
It will have to be called for each object.

Note that this is current documentation and your 5.6.3 version may behave differently. There is also a bulk create api documented, but that is not available in 5.x.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.