Search code examples
ubuntupermissionselasticsearchrepositorypermission-denied

RepositoryException while restoring snapshot of Elastic Search in ubuntu machine


While we upgrade from old version(1.0) of Elastic search to latest version(4.0), we need to move the indexed data from old version back up to latest version's back up. So did the following

  1. Took a snapshot of data in elasticsearch windows machine
  2. Restore(Register) snapshot data in elasticsearch ubuntu machine

Faced the same exception told in this link. I checked the same command with sudo. Yet it didn't worked out. So please tell how to reset the read/write settings / permission settings to allow the folder creation.

Query:

curl -XPUT http://xx.xx.xx.xx:9200/_snapshot/es_snap -d '{
"type": "fs",
    "settings": {
        "location": "/mount/backups/my_backup"
    }
}'

Response:

{
  "error":"RepositoryException[[es_snap] failed to create repository]; 
            nested: CreationException[Guice creation errors:\n\n1) Error injecting constructor, org.elasticsearch.common.blobstore.BlobStoreException: 
          Failed to create directory at [
            D:/data/es_snapshot_bkup/es_snapshot_repo
          ]\n  
          at org.elasticsearch.repositories.fs.FsRepository.<init>(Unknown Source)\n  
          while locating org.elasticsearch.repositories.fs.FsRepository\n  
          while locating org.elasticsearch.repositories.Repository\n\n1 error]; 
            nested: BlobStoreException[Failed to create directory at [/mount/backups/my_backup]];",
  "status":500
}

Solution

  • This is working for me. Please check it. Before Restore and Backup operation can be create a repository.

    1. mkdir ~/backup
    2. chmod 777 ~/backup

    3. Create a repository (Repository is represent you path)

      curl -XPUT http://xx.xx.xx.xx:9200/_snapshot/es_snap -d '{ "type": "fs", "settings": { "location": "/home/user/backup" } }

    4. Snapshot

      curl -XPUT "http://xx.xx.xx.xx:9200/_snapshot/es_snap/snapshot_1" -d '{ "indices": "index_1,index_2", "ignore_unavailable": "true", }'

    5. Again Create a New Repository for Elastic search to latest version(4.0) and Mention the same location.

    6. A snapshot can be restored using the following command:

      curl -XPOST "http://xx.xx.xx.xx:9200/_snapshot/es_snap/snapshot_1/_restore"