# How to use repository create from-config

**URL:** https://kopia.discourse.group/t/how-to-use-repository-create-from-config/2365
**Category:** General Topics
**Created:** [October 19, 2023, 5:47pm UTC](https://kopia.discourse.group/t/how-to-use-repository-create-from-config/2365 "2023-10-19T17:47:55Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![RhysGoodwin](https://yyz2.discourse-cdn.com/free1/user_avatar/kopia.discourse.group/rhysgoodwin/32/495_2.png) [@RhysGoodwin](https://kopia.discourse.group/u/RhysGoodwin)
#### Post date: [October 19, 2023, 5:47pm UTC](https://kopia.discourse.group/t/how-to-use-repository-create-from-config/2365/1 "2023-10-19T17:47:55Z")

</div>

Hi there,

I have a config file like this:

```auto
{
  "storage": {
    "type": "s3",
    "config": {
      "bucket": "mybucket",
      "endpoint": "s3.amazonaws.com",
      "accessKeyID": "AKIxyxyxyx",
      "secretAccessKey": "keykeykey",
      "sessionToken": "",
      "region": "ap-southeast-2"
    }
  },
  "caching": {
    "cacheDirectory": "E:\\kopia\\jobs\\mgmt\\cache",
    "maxCacheSize": 5242880000,
    "maxMetadataCacheSize": 5242880000,
    "maxListCacheDuration": 30
  },
  "hostname": "mgmt01",
  "username": "iac",
  "description": "Repository in S3: xyxyxyx",
  "enableActions": false,
  "formatBlobCacheDuration": 900000000000
}

```

I thought I should be able to do something like:

kopia repository create from-config --config-file=“.\config\repository\_mgmt.config” -p repopwd’

But it complains about token:  
`ERROR can't connect to storage: one of --token-file, --token-stdin or --token must be provided`  
I’m not sure what the --token or --token-file option is for. Does this relate to the repo password?

I did try pointing the --token-file to `config\repository_mgmt.config.kopia-password` which contains the bas64 encoded repo password. but no go.

It seems to me that between the config file and provided repo password I have everything required to create a repo but I’m clearly doing something wrong.

The use case here is that I’m generating kopia packages using Ansible. I.e. the config file is being built from a template.

Any guidance would be much apricated.

Cheers.  
Rhys

---

<div class="post-metadata">

### Author: ![wayland](https://yyz2.discourse-cdn.com/free1/user_avatar/kopia.discourse.group/wayland/32/268_2.png) [@wayland](https://kopia.discourse.group/u/wayland)
#### Post date: [December 2, 2023, 1:33am UTC](https://kopia.discourse.group/t/how-to-use-repository-create-from-config/2365/2 "2023-12-02T01:33:22Z")

</div>

Did you find a solution? I am trying to do same thing but with connecting a repository. This page does not tell how it is done and no help is found arond the web

> **[repository connect from-config](https://kopia.io/docs/reference/command-line/common/repository-connect-from-config/)**
>
> $ kopia repository connect from-config Connect to repository in the provided configuration file
> Flag Short Default Help --cache-directory Cache directory --\[no-\]check-for-updates true Periodically check for Kopia updates on GitHub...

---

<div class="post-metadata">

### Author: ![RhysGoodwin](https://yyz2.discourse-cdn.com/free1/user_avatar/kopia.discourse.group/rhysgoodwin/32/495_2.png) [@RhysGoodwin](https://kopia.discourse.group/u/RhysGoodwin)
#### Post date: [December 2, 2023, 3:20am UTC](https://kopia.discourse.group/t/how-to-use-repository-create-from-config/2365/3 "2023-12-02T03:20:39Z")

</div>

No, I haven’t unfortunately. I’ve worked around it by writing out the repository.config to its target location then my python deployment script reads the file with json load and builds a “create repo” command which then writes back to the same config file.

The doco could use some improvement. I’ve really no idea what --token or --token-file mean.

Ngā mihi  
Rhys

---

<div class="post-metadata">

### Author: ![wayland](https://yyz2.discourse-cdn.com/free1/user_avatar/kopia.discourse.group/wayland/32/268_2.png) [@wayland](https://kopia.discourse.group/u/wayland)
#### Post date: [December 2, 2023, 4:11am UTC](https://kopia.discourse.group/t/how-to-use-repository-create-from-config/2365/4 "2023-12-02T04:11:06Z")

</div>

I actually found a solution finally, brought to you by bing chat ☹

Basically " --config-file" is wrong in this context.

`kopia.exe repository connect from-config --file=CONFIG-FILE`

---

<div class="post-metadata">

### Author: ![RhysGoodwin](https://yyz2.discourse-cdn.com/free1/user_avatar/kopia.discourse.group/rhysgoodwin/32/495_2.png) [@RhysGoodwin](https://kopia.discourse.group/u/RhysGoodwin)
#### Post date: [December 2, 2023, 4:16am UTC](https://kopia.discourse.group/t/how-to-use-repository-create-from-config/2365/5 "2023-12-02T04:16:25Z")

</div>

In my case the repo doesn’t exist. Will the above create it?

---

<div class="post-metadata">

### Author: ![wayland](https://yyz2.discourse-cdn.com/free1/user_avatar/kopia.discourse.group/wayland/32/268_2.png) [@wayland](https://kopia.discourse.group/u/wayland)
#### Post date: [December 2, 2023, 4:19am UTC](https://kopia.discourse.group/t/how-to-use-repository-create-from-config/2365/6 "2023-12-02T04:19:26Z")

</div>

Take a look at this, [Getting Started Guide | Kopia](https://kopia.io/docs/getting-started/)

Maybe you need to pass the kopia password in the terminal, then create the repo and use the lines I used to connect and create additional snapshots on the command line using a config.

---

<div class="post-metadata">

### Author: ![RhysGoodwin](https://yyz2.discourse-cdn.com/free1/user_avatar/kopia.discourse.group/rhysgoodwin/32/495_2.png) [@RhysGoodwin](https://kopia.discourse.group/u/RhysGoodwin)
#### Post date: [December 2, 2023, 4:55am UTC](https://kopia.discourse.group/t/how-to-use-repository-create-from-config/2365/7 "2023-12-02T04:55:42Z")

</div>

Yes, that’s what I’m doing, but in the documentation, there is a **repository create from-config** command as per this link:  
[repository create from-config | Kopia](https://kopia.io/docs/reference/command-line/common/repository-create-from-config/)

And I would have thought this would allow creating the repo from a config file. Afterall, the config file contains all the required info to do so but I can’t get it to work. Or am I misunderstanding what the command is for?

---

<div class="post-metadata">

### Author: ![wayland](https://yyz2.discourse-cdn.com/free1/user_avatar/kopia.discourse.group/wayland/32/268_2.png) [@wayland](https://kopia.discourse.group/u/wayland)
#### Post date: [December 2, 2023, 6:58am UTC](https://kopia.discourse.group/t/how-to-use-repository-create-from-config/2365/8 "2023-12-02T06:58:43Z")

</div>

> [@RhysGoodwin](#):
>
> –config-file=“.\config\repository\_mgmt.config” -p repopwd’

That was the intention of my post try `--file` instead of `--config-file`

---

<div class="post-metadata">

### Author: ![RhysGoodwin](https://yyz2.discourse-cdn.com/free1/user_avatar/kopia.discourse.group/rhysgoodwin/32/495_2.png) [@RhysGoodwin](https://kopia.discourse.group/u/RhysGoodwin)
#### Post date: [December 2, 2023, 8:11am UTC](https://kopia.discourse.group/t/how-to-use-repository-create-from-config/2365/9 "2023-12-02T08:11:23Z")

</div>

Thanks Wayland. I’m 99% sure I have dried --file and a whole range of variations but I think the main hang up was the token options which are required. I thought token-file might be the base64 encoded version of the repo password, but suspect I’m way off.

---

<div class="post-metadata">

### Author: ![wayland](https://yyz2.discourse-cdn.com/free1/user_avatar/kopia.discourse.group/wayland/32/268_2.png) [@wayland](https://kopia.discourse.group/u/wayland)
#### Post date: [December 2, 2023, 7:21pm UTC](https://kopia.discourse.group/t/how-to-use-repository-create-from-config/2365/10 "2023-12-02T19:21:42Z")

</div>

That was what I was trying to get at, the `connect` option (which was what I needed) seemed to require a token with --config-file until I discarded that and used the --file option, then it stopped complaining about token related stuff and relied only on the actual config file.

---

<div class="post-metadata">

### Author: ![martinpk](https://avatars.discourse-cdn.com/v4/letter/m/c5a1d2/32.png) [@martinpk](https://kopia.discourse.group/u/martinpk)
#### Post date: [January 20, 2024, 11:10pm UTC](https://kopia.discourse.group/t/how-to-use-repository-create-from-config/2365/11 "2024-01-20T23:10:05Z")

</div>

Searching the documentation for “token”, the second hit is this: [Command Line | Kopia](https://kopia.io/docs/reference/command-line/#quick-reconnection-to-repository) (Quick Reconnection To Repository), which shows where to find the token in the output of the `kopia repo status -t` command.

If you want to extract the token programmatically, you can use: `kopia repository status -t -s | grep token | head -1 | awk '{print $7}'`

Hope this helps!
