I’m trying to generate .bat batch files (for Windows) and .sh shell scripts (for Linux) to perform automated backups.
Is there a kopia snapshot create command where I can actually specify the destination repo? i.e. Without it being reliant on whatever commands may or may not have been run before it? (and whether those previous commands succeeded or failed)
I’m concerned about race conditions and other issues in the case where the source servers have multiple repos they connect to, and it also just makes scripting a lot more complicated needing to to deal with this “modal” nature of running separate commands to “connect” to one repo at a time, and then actually do backups to which ever is the “current” repo is. Or maybe I’ve misunderstood how Kopia works?
Ideally I’m also looking for a command that can first check if the repo exists first, and auto-create it if it doesn’t. Is this possible?
I’d love a simple one-liner that gives consistent results like:
Kopia parameters are all derived from a configuration file which is created when you do repo connect. If you want to avoid connecting (or have multiple connected repositories) you can specify config file yourself.
Basically you can create the config once (by repo create/repo connect) and bundle it together with your script using --config-file ~/my.config to point at it. The last thing you need to to do is passing the password which by default is not stored in the config but in OS-specific keychain. You can either always pass it using KOPIA_PASSWORD environment variable, alternatively you can persist it in a file:
Really loving Kopia! Especially the fact that mounting even works on Windows!
A couple of follow up questions:
Any thoughts on the --auto-create-repo thing? Is it something you’d consider adding in the future? It would be amazing to just be able to deploy a single idempotent command out to my servers so that they can auto-create repos in a simple way. (password for the new repo can just be taken from the same KOPIA_PASSWORD environment variable)
Does Kopia have any environment variables other than KOPIA_PASSWORD ? Any doco anywhere on them?