How to speed up `restic init`, possibly by sacrificing security?

Hello,

I am using restic as part of ButterBackup, another backup solution. I have a quite heavy test suite, which takes ages to execute. I identified that one contribution to the test suites’ long execution time is that I run restic init very often.

These are two test executions of restic init:

$ time echo "1230X~98evahluiedfng" | restic init -r restic
reading repository password from stdin
created restic repository f8178a760e at restic

Please note that knowledge of your password is required to access
the repository. Losing your password means that your data is
irrecoverably lost.
echo "1230X~98evahluiedfng"  0,00s user 0,00s system 54% cpu 0,001 total
restic init -r restic  2,69s user 0,03s system 99% cpu 2,738 total
$ rm -rf restic
 /tmp  time echo "1230X~98evahluiedfng" | restic init -r restic
reading repository password from stdin
created restic repository 2918ef27ee at restic

Please note that knowledge of your password is required to access
the repository. Losing your password means that your data is
irrecoverably lost.
echo "1230X~98evahluiedfng"  0,00s user 0,00s system 45% cpu 0,001 total
restic init -r restic  2,17s user 0,04s system 98% cpu 2,241 total

As you can see, it takes more than 2 seconds to initialise a repository.

I’d like to know whether there is a way to speed this up. Since it affects the test suite only, I am willing to sacrifice security. For instance, I was able to reduce the cryptsetup luksFormat time by lowering the PBKDF’s parameters to the lowest possible values (see here).

Is there something that can be done for Restic?

Probably not the answer you’re looking for, but since it’s tests (and assuming you don’t want to heavily test the init subcommand itself), can’t you run the init once, and then copy the config and generated keys/$keyfile around when you need a new repo? Afaik what restic calls “repository” is a folder with this config file in it, and a key under the keys directory to work with.

1 Like

Thank you for the quick reply.

Probably not the answer you’re looking for, but since it’s tests (and assuming you don’t want to heavily test the init subcommand itself), can’t you run the init once, and then copy the config and generated keys/$keyfile around when you need a new repo? Afaik what restic calls “repository” is a folder with this config file in it, and a key under the keys directory to work with.
Indeed, while writing the question it appeared to me that I could do something very similar. I could create the repository once and create a fresh copy for each test.

However, that would complicate the test suite a bit. If there is an alternative option, I’d like to learn about it.

Restic deliberately does not offer an option for users to weaken the encryption strength. That is, without patching the source code it is not possible.