Running multple instances of Kopia

I can’t seem to wrap my head around on how to run multiple kopia (cli) instances.
I am trying to create an ansible playbook that would execute a kopia snapshot.

For a single repo this is trivial - but my use case require that I have several different repos. My current understanding is that kopia needs to connect to a repo before you can execute any commands against it. Essentially this means only a single instance of kopia can be active at any given time?

I’ve tried to run a snapshop list command while using the --config-file flag - but I get this as an output

kopia --config-file <> snapshot list --password <>

ERROR open repository: repository is not connected. See Repositories | Kopia

Is this a limitation of kopia that it needs to be connected to a repo and therefor its not possible to run multiple instances at the same time or am I not using the cli api properly?

I don’t use the CLI – I use the GUI – but I fairly certain running multiple instances of Kopia is as easy as running multiple instances of the kopia binary.

You can simultaneously run multiple kopia repository connect commands to connect to multiple repos (as long as you have created the repos first). In other words, open multiple terminals and in each terminal run a kopia repository connect command. Once connected to a repo, you can use the various different Kopia commands. I strongly recommend read the Getting Started Guide:

Try configuring it in your browser, it makes it a little easier to deal with. Pass your alternative --config flag into there, and use it in the web browser,

/usr/bin/kopia server start --insecure --without-password --config-file /path/to/other/config.file

I find this to be easier to manage. If you’re already using port 51515, you may need to increment it for the next free port.

The config is already done (I used the WebUI on my laptop to get the config files for the various repos ) :slight_smile:

This will be running on a headless LXC container as part of an automated ansible playbook. I’m trying kopia as an alternative to restic but if kopia requires multiple terminal instances (as an example from above) to function - then I’m starting to think that kopia won’t be a good fit for my current infrastructure

How are you accessing the headless machines? Couldn’t you use some SSH forwarding?

Perhaps you could use a central kopia repo instead.

Maybe you could run them detached, or using Cron jobs, seems like there’s any number of ways to pull off what you’re doing. It’s not that much different from restic

I misunderstood what you were trying to do and what step you were at.

To clarify, you should be able to run Kopia commands for different repos in a script. I do it regularly for some commands that arent supported in the GUI. For example, I have a script that runs path\to\kopia.exe --config-file="path\to\repository.config" snapshot verify regularly for all my repos.

Can you share the exact commands you are running? I dont think you need the --password option if you already have a config file, perhaps that could be part of the problem.

The issue I was seeing was that everytime kopia connect was ran - it overrode the current ~/.config/kopia/repository.config file - even if the provided path for --config-file was different. This led me to believe that even if you specify the --config-file argument - it would still use the default config file (~/.config/kopia/repository.config file ). But I think after some more debugging that I understand what is actually going on.

The kopia connect command is somewhat misleading (atleast to me). At a glance this command seemingly ties the kopia instance to a specific repository - but that isn’t the case (not in the purest / most literal sense).

The connect command simply creates some meta data files / folders in your storage so that the next time you run any command on that repo - it would succeed (I verified this by overriding the content of ~/.config/kopia/repository.config and pointing the snapshot command to a different file).

Previously for my testing I executed the disconnect command , then trying to execute a snapshot command by providing a different config file - and this failed with the error in the OP (after running disconnect the folders / files created by connect are removed).

If I run into any other issues I will post an edit / reply here. Thanks for the help. Hopefully this info helps someone else who are also struggling to understand the relationship between the kopia binary and the target repo with relation to the “connect” command

Edit: I guess this creates another question - if you are using the from-config flag for connect - should kopia then create / override the default config file (for me this is ~/.config/kopia/repository.config ) ?

1 Like

Ok I have finally tracked down the source of all confusion. For experienced linux users - this would have been obvious from the start - so you learn…

My issue was that I was testing the snapshot commands from within the directory where my config file was stored. Coming from a windows background - I just use the relative file path
kopia --config-file test.config snapshot ls

and this always results in
ERROR open repository: repository is not connected. See https://kopia.io/docs/repositories/

My mistake was not using ./test.config ( ./ was missing). I think a better error message would be helpful here. Something like “File not found”

1 Like