# Change the location of an existing snapshot repository

**URL:** <https://discuss.elastic.co/t/change-the-location-of-an-existing-snapshot-repository/344200>\
**Category:** Elasticsearch\
**Created:** [October 2, 2023, 12:29am UTC](https://discuss.elastic.co/t/change-the-location-of-an-existing-snapshot-repository/344200 "2023-10-02T00:29:58Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Russell\_Fulton](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/russell_fulton/32/62888_2.png) [@Russell\_Fulton](https://discuss.elastic.co/u/Russell_Fulton)\
**Post date:** [October 2, 2023, 12:29am UTC](https://discuss.elastic.co/t/change-the-location-of-an-existing-snapshot-repository/344200/1 "2023-10-02T00:29:58Z")

</div>

I need to change the location of the repository:

 ![Screenshot 2023-10-02 at 1.21.51 PM](https://us1.discourse-cdn.com/elastic/original/3X/c/0/c0a054ce614d49d6d2eb8e23a8555249282fb1f1.png)

but when I do I get this error:

 ![Screenshot 2023-10-02 at 1.27.51 PM](https://us1.discourse-cdn.com/elastic/original/3X/a/6/a6baff9e384da35e634b585503e6bb868d86ee15.png)

we had to move the mountpoint for the shared disk...

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [October 2, 2023, 11:57am UTC](https://discuss.elastic.co/t/change-the-location-of-an-existing-snapshot-repository/344200/2 "2023-10-02T11:57:33Z")

</div>

Hm that looks like a bug, but without a stack trace it's going to be hard to understand/fix it. Can you try and do the same thing directly with the [create snapshot repo API](https://www.elastic.co/guide/en/elasticsearch/reference/current/put-snapshot-repo-api.html?) rather than through the UI (i.e. using the dev console) and add the `?error_trace` parameter to the URL to get a full stack trace?

---

<div class="post-metadata">

**Author:** ![Russell\_Fulton](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/russell_fulton/32/62888_2.png) [@Russell\_Fulton](https://discuss.elastic.co/u/Russell_Fulton)\
**Post date:** [October 2, 2023, 6:34pm UTC](https://discuss.elastic.co/t/change-the-location-of-an-existing-snapshot-repository/344200/3 "2023-10-02T18:34:42Z")

</div>

```auto
PUT /_snapshot/daily?error_trace
{
  "type": "fs",
  "settings": {
    "location": "/home/elasticsearch/esbackups/"
  }
}

```

```auto
{
  "error" : {
    "root_cause" : [
      {
        "type" : "null_pointer_exception",
        "reason" : "Cannot invoke \"org.elasticsearch.repositories.Repository.getMetadata()\" because \"repository\" is null",
        "stack_trace" : "[Cannot invoke \"org.elasticsearch.repositories.Repository.getMetadata()\" because \"repository\" is null]; nested: NullPointerException[Cannot invoke \"org.elasticsearch.repositories.Repository.getMetadata()\" because \"repository\" is null];\n\tat org.elasticsearch.ElasticsearchException.guessRootCauses(ElasticsearchException.java:667)\n\tat org.elasticsearch.ElasticsearchException.generateFailureXContent(ElasticsearchException.java:595)\n\tat org.elasticsearch.rest.BytesRestResponse.build(BytesRestResponse.java:140)\n\tat org.elasticsearch.rest.BytesRestResponse.<init>(BytesRestResponse.java:101)\n\tat org.elasticsearch.rest.BytesRestResponse.<init>(BytesRestResponse.java:81)\n\tat org.elasticsearch.rest.action.RestActionListener.onFailure(RestActionListener.java:55)\n\tat org.elasticsearch.action.support.TransportAction$1.onFailure(TransportAction.java:97)\n\tat org.elasticsearch.action.support.ContextPreservingActionListener.onFailure(ContextPreservingActionListener.java:38)\n\tat org.elasticsearch.action.ActionListener$Delegating.onFailure(ActionListener.java:66)\n\tat org.elasticsearch.action.support.master.TransportMasterNodeAction$AsyncSingleAction$1.handleException(TransportMasterNodeAction.java:248)\n\tat org.elasticsearch.transport.TransportService$4.handleException(TransportService.java:853)\n\tat org.elasticsearch.transport.TransportService$ContextRestoreResponseHandler.handleException(TransportService.java:1481)\n\tat org.elasticsearch.transport.InboundHandler.lambda$handleException$3(InboundHandler.java:380)\n\tat org.elasticsearch.common.util.concurrent.EsExecutors$DirectExecutorService.execute(EsExecutors.java:291)\n\tat org.elasticsearch.transport.InboundHandler.handleException(InboundHandler.java:378)\n\tat org.elasticsearch.transport.InboundHandler.handlerResponseError(InboundHandler.java:370)\n\tat org.elasticsearch.transport.InboundHandler.messageReceived(InboundHandler.java:134)\n\tat org.elasticsearch.transport.InboundHandler.inboundMessage(InboundHandler.java:88)\n\tat org.elasticsearch.transport.TcpTransport.inboundMessage(TcpTransport.java:743)\n\tat org.elasticsearch.transport.InboundPipeline.forwardFragments(InboundPipeline.java:147)\n\tat org.elasticsearch.transport.InboundPipeline.doHandleBytes(InboundPipeline.java:119)\n\tat org.elasticsearch.transport.InboundPipeline.handleBytes(InboundPipeline.java:84)\n\tat org.elasticsearch.transport.netty4.Netty4MessageChannelHandler.channelRead(Netty4MessageChannelHandler.java:71)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)\n\tat io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)\n\tat io.netty.handler.logging.LoggingHandler.channelRead(LoggingHandler.java:280)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)\n\tat io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)\n\tat io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)\n\tat io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)\n\tat io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1383)\n\tat io.netty.handler.ssl.SslHandler.decodeJdkCompatible(SslHandler.java:1246)\n\tat io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1295)\n\tat io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:529)\n\tat io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:468)\n\tat io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:290)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)\n\tat io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)\n\tat io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)\n\tat io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)\n\tat io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)\n\tat io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788)\n\tat io.netty.channel.nio.NioEventLoop.processSelectedKeysPlain(NioEventLoop.java:689)\n\tat io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:652)\n\tat io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562)\n\tat io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)\n\tat io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)\n\tat java.base/java.lang.Thread.run(Thread.java:1623)\nCaused by: java.lang.NullPointerException: Cannot invoke \"org.elasticsearch.repositories.Repository.getMetadata()\" because \"repository\" is null\n\tat org.elasticsearch.repositories.RepositoriesService.canUpdateInPlace(RepositoriesService.java:524)\n\tat org.elasticsearch.repositories.RepositoriesService.access$200(RepositoriesService.java:69)\n\tat org.elasticsearch.repositories.RepositoriesService$1.execute(RepositoriesService.java:211)\n\tat org.elasticsearch.cluster.ClusterStateUpdateTask.execute(ClusterStateUpdateTask.java:51)\n\tat org.elasticsearch.cluster.service.MasterService.executeTasks(MasterService.java:840)\n\tat org.elasticsearch.cluster.service.MasterService.calculateTaskOutputs(MasterService.java:407)\n\tat org.elasticsearch.cluster.service.MasterService.runTasks(MasterService.java:243)\n\tat org.elasticsearch.cluster.service.MasterService.access$100(MasterService.java:63)\n\tat org.elasticsearch.cluster.service.MasterService$Batcher.run(MasterService.java:170)\n\tat org.elasticsearch.cluster.service.TaskBatcher.runIfNotProcessed(TaskBatcher.java:146)\n\tat org.elasticsearch.cluster.service.TaskBatcher$BatchedTask.run(TaskBatcher.java:202)\n\tat org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:718)\n\tat org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.runAndClean(PrioritizedEsThreadPoolExecutor.java:262)\n\tat org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.run(PrioritizedEsThreadPoolExecutor.java:225)\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)\n\tat java.lang.Thread.run(Thread.java:1623)\n"
      }
    ],
    "type" : "null_pointer_exception",
    "reason" : "Cannot invoke \"org.elasticsearch.repositories.Repository.getMetadata()\" because \"repository\" is null",
    "stack_trace" : "java.lang.NullPointerException: Cannot invoke \"org.elasticsearch.repositories.Repository.getMetadata()\" because \"repository\" is null\n\tat org.elasticsearch.repositories.RepositoriesService.canUpdateInPlace(RepositoriesService.java:524)\n\tat org.elasticsearch.repositories.RepositoriesService.access$200(RepositoriesService.java:69)\n\tat org.elasticsearch.repositories.RepositoriesService$1.execute(RepositoriesService.java:211)\n\tat org.elasticsearch.cluster.ClusterStateUpdateTask.execute(ClusterStateUpdateTask.java:51)\n\tat org.elasticsearch.cluster.service.MasterService.executeTasks(MasterService.java:840)\n\tat org.elasticsearch.cluster.service.MasterService.calculateTaskOutputs(MasterService.java:407)\n\tat org.elasticsearch.cluster.service.MasterService.runTasks(MasterService.java:243)\n\tat org.elasticsearch.cluster.service.MasterService.access$100(MasterService.java:63)\n\tat org.elasticsearch.cluster.service.MasterService$Batcher.run(MasterService.java:170)\n\tat org.elasticsearch.cluster.service.TaskBatcher.runIfNotProcessed(TaskBatcher.java:146)\n\tat org.elasticsearch.cluster.service.TaskBatcher$BatchedTask.run(TaskBatcher.java:202)\n\tat org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:718)\n\tat org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.runAndClean(PrioritizedEsThreadPoolExecutor.java:262)\n\tat org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.run(PrioritizedEsThreadPoolExecutor.java:225)\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)\n\tat java.lang.Thread.run(Thread.java:1623)\n"
  },
  "status" : 500
}

```

---

<div class="post-metadata">

**Author:** ![Russell\_Fulton](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/russell_fulton/32/62888_2.png) [@Russell\_Fulton](https://discuss.elastic.co/u/Russell_Fulton)\
**Post date:** [October 2, 2023, 6:40pm UTC](https://discuss.elastic.co/t/change-the-location-of-an-existing-snapshot-repository/344200/4 "2023-10-02T18:40:35Z")

</div>

now to work around the "bug" ...

If I delete the repository in kibana I assume it will remove the snapshots, which we definitely don't want. If I rename the directory on disk and create a empty one in its place, then do a create repository with the new location should that work?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [October 2, 2023, 7:28pm UTC](https://discuss.elastic.co/t/change-the-location-of-an-existing-snapshot-repository/344200/5 "2023-10-02T19:28:10Z")

</div>

Removing a repository does not remove the snapshots.  
But you don't need to remove the repository. You can just create a new one with a new name.

---

<div class="post-metadata">

**Author:** ![Russell\_Fulton](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/russell_fulton/32/62888_2.png) [@Russell\_Fulton](https://discuss.elastic.co/u/Russell_Fulton)\
**Post date:** [October 2, 2023, 10:52pm UTC](https://discuss.elastic.co/t/change-the-location-of-an-existing-snapshot-repository/344200/6 "2023-10-02T22:52:06Z")

</div>

I deleted the repository and recreated it with the correct path. That worked. I then repeated that for all the other repositories.

I realised when I tried to change the path the new path I gave was to the directory where the repository was to be created. I had assumed the the directory would be created with the same name as the repository. Not so.

Before deleting are recreating the repositories I tried "edit" and changing the path, this time using the full path and that still failed???

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [October 3, 2023, 9:37am UTC](https://discuss.elastic.co/t/change-the-location-of-an-existing-snapshot-repository/344200/7 "2023-10-03T09:37:01Z")

</div>

What version are you using exactly @Russell_Fulton?

I opened [NPE when updating repository settings · Issue #100183 · elastic/elasticsearch · GitHub](https://github.com/elastic/elasticsearch/issues/100183) to investigate this further.

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [October 3, 2023, 9:40am UTC](https://discuss.elastic.co/t/change-the-location-of-an-existing-snapshot-repository/344200/8 "2023-10-03T09:40:45Z")

</div>

Ah I found a matching issue, [NPE in RepositoriesService · Issue #85550 · elastic/elasticsearch · GitHub](https://github.com/elastic/elasticsearch/issues/85550), fixed in 8.3.0 but not backported to 7.17 it seems.

---

<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:** [October 31, 2023, 9:41am UTC](https://discuss.elastic.co/t/change-the-location-of-an-existing-snapshot-repository/344200/9 "2023-10-31T09:41:25Z")

</div>

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