# Post bulk on elastic xpack role

**URL:** <https://discuss.elastic.co/t/post-bulk-on-elastic-xpack-role/158036>\
**Category:** Kibana\
**Tags:** elastic-stack-security\
**Created:** [November 23, 2018, 3:28pm UTC](https://discuss.elastic.co/t/post-bulk-on-elastic-xpack-role/158036 "2018-11-23T15:28:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![totsugeki](https://avatars.discourse-cdn.com/v4/letter/t/b782af/32.png) [@totsugeki](https://discuss.elastic.co/u/totsugeki)\
**Post date:** [November 23, 2018, 3:28pm UTC](https://discuss.elastic.co/t/post-bulk-on-elastic-xpack-role/158036/1 "2018-11-23T15:28:01Z")

</div>

Hello everyone,

I have an Elastic cluster + kibana, with xpack enable.

I'd like to make a backup of all roles created :

```auto
GET _xpack/security/role

```

=\> I get a big json, ex :

```auto
{
  "kibana_dashboard_only_user": {
    "cluster": [],
    "indices": [
      {
        "names": [
          ".kibana*"
        ],
        "privileges": [
          "read",
          "view_index_metadata"
        ]
      }
    ],
    "run_as": [],
    "metadata": {
      "_reserved": true
    },
    "transient_metadata": {
      "enabled": true
    }
  },
  "watcher_admin": {
    "cluster": [
      "manage_watcher"
    ],
    "indices": [
      {
        "names": [
          ".watches",
          ".triggered_watches",
          ".watcher-history-*"
        ],
        "privileges": [
          "read"
        ]
      }
    ],
    "run_as": [],
    "metadata": {
      "_reserved": true
    },
    "transient_metadata": {
      "enabled": true
    }
  },
  ....
}

```

And now I'd like to put it back in the cluster (or another). I cannot just PUT it to \_xpack/security/role.  
If i understand correctly I have to use bulk :

```auto
curl --user elastic:password https://elastic:9200/_xpack/security/_bulk?pretty -XPOST -H 'Content-Type: application/json' -d '
{"index":{"_index": "_xpack/security/role"}}
{"ROOOOLE" : {"cluster" : [],"indices" : [{"names" : [".kibana*"],"privileges" : ["read","view_index_metadata"]}],"run_as" : [],"metadata" : {"_reserved" : true},"transient_metadata" : {"enabled" : true}}}
'

```

But i get an error :

```auto
{
  "took" : 3,
  "errors" : true,
  "items" : [
    {
      "index" : {
        "_index" : "_xpack/security/role",
        "_type" : "security",
        "_id" : null,
        "status" : 400,
        "error" : {
          "type" : "invalid_index_name_exception",
          "reason" : "Invalid index name [_xpack/security/role], must not contain the following characters [, \", *, \\, <, |, ,, >, /, ?]",
          "index_uuid" : "_na_",
          "index" : "_xpack/security/role"
        }
      }
    }
  ]
}

```

Is there a way to do this easily ? Or do I have to parse the json, and put each role one by one to :

- \_xpack/security/role/rolexxx
- \_xpack/security/role/roleyyy
- ...

More globally, is there a way to get all data of an index (config index), then upload it back or put it into another cluster ?

Thank you.

---

<div class="post-metadata">

**Author:** ![Yogesh\_Gaikwad](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yogesh_gaikwad/32/27025_2.png) [@Yogesh\_Gaikwad](https://discuss.elastic.co/u/Yogesh_Gaikwad)\
**Post date:** [November 27, 2018, 6:07am UTC](https://discuss.elastic.co/t/post-bulk-on-elastic-xpack-role/158036/2 "2018-11-27T06:07:48Z")

</div>

Hi @totsugeki,

There is no bulk API for creating/updating roles.  
The `.security` index is an internal index and so no other actions are allowed.

You could make use of Elasticsearch clients to help you with the parsing of JSON and do custom logic to do backup/restore or use Curator to take snapshots and restore them.

If your purpose is to do a backup/restore in the same or different cluster then you could use curator to achieve that.  
[https://www.elastic.co/guide/en/elasticsearch/client/curator/current/index.html](https://www.elastic.co/guide/en/elasticsearch/client/curator/current/index.html)  
(For using curator for backing up internal indices you will need a user with `superuser` role only they have access to internal indices)

Hope this is helpful.

Thanks and Regards,  
Yogesh Gaikwad

---

<div class="post-metadata">

**Author:** ![totsugeki](https://avatars.discourse-cdn.com/v4/letter/t/b782af/32.png) [@totsugeki](https://discuss.elastic.co/u/totsugeki)\
**Post date:** [November 27, 2018, 3:39pm UTC](https://discuss.elastic.co/t/post-bulk-on-elastic-xpack-role/158036/3 "2018-11-27T15:39:43Z")

</div>

Thank you !

I'll look at it 😉

Best regards.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 25, 2018, 3:39pm UTC](https://discuss.elastic.co/t/post-bulk-on-elastic-xpack-role/158036/4 "2018-12-25T15:39:49Z")

</div>

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