restic 0.18.0 compiled with go1.24.1 on darwin/arm64
I must discard the creds for my existing Restic/b2 backup setup.
I want to change the password/key and re-encrypt existing b2 Restic snapshots, but that seems infeasible. The closest alt I found is restic copy to a new repo to transfer re-encrypted (+compressed) backup history—is that correct?
So, my plan is (two terminal sessions; respective old/new env values already set):
--copy-chunker-params must be used with init, NOT with copy. You want your new repo to be initialised with the same chunker parameter. This is only done once and can NOT be changed later.
see:
--compression max should be used with copy. NOT with init. Restic does not store this setting anywhere. Your repo can contain mix of compressed and plain data. So if you want your data to be max compressed you have to use it in the future with any other restic commands.
see:
And what your goal is? Because better is relative depending on your requirements. If you are not sure then use default settings. They are fine for most people.
You can also read:
Maybe you will find something what applies to you.
Thank you. I had misplaced this param. I had looked at old repo config and found chunker_polynomial there and I wrongly assumed that I can set “that” when copying.
So I believe
the init should now change to (new repo password set in env):
Looks OKish now at quick glance. Not 100% sure though about --from-password-file in init. Will restic use it for old/new/both repos? You have to test. Actually the same with copy. It is not something you do everyday so not something I remember well. But I managed in the past.
Always good to use --dry-run first always - especially when live data is used.
True. I intend to do that. Though I wonder what will be involved in running a dry-run of copy command. Will it anyway download all the data locally and then?
The source repository is specified with --from-repo or can be read from a file specified via --from-repository-file. Both of these options can also be set as environment variables $RESTIC_FROM_REPOSITORY or $RESTIC_FROM_REPOSITORY_FILE, respectively. For the source repository the password can be read from a file --from-password-file or from a command
When running the init command I am getting an error on the --from-repo:
Fatal: unable to open repository at b2:old_bucket:backup: Bucket: b2_list_buckets: 401:
The terminal has all the env vars exported for the new repo, but not for the old repo. Besides I do not really know how to export other env vars like Account ID etc when those are already exported for one repo i.e the new repo.
So while I was able to pass the old repo password correctly via --from-password-file I would assume restic init needs other info like a/c id etc as well to access the old repo, right?
So in that case how do I even run restic init in such a way that in one terminal session two repos are being accessed with their exported env vars like account id, account key, along with the password at the same time?
Always good to use --dry-run first always
Coming back to this - it seems restic init doesn’t support --dry-run.
Is there something very obvious (or not) I am missing?
You can read docs and forum trying to solve this or just init from b2 to some local temp repo and then from this local to your b2 new. This way you always need only one b2 repo parameters active.
Hey, yes I have been trying to find a comment or post with this situation (and possible solution) on forum and github issues. No luck so far. I will keep looking.
This way you always need only one b2 repo parameters active.
But then doing it local won’t help, right? Because the very problem is trying to get two sets of env info in session. I mean that’s how I am seeing it. Please do tell if there’s something I am missing in this regard.
I just tried it from the terminal where I have sourced/loaded old repo env info
This sounds great. Thanks. I didn’t know this could be done.
While reading this comment of yours I created a new application key on b2 and gave it permission on both old/new buckets and ran the command again with loaded/soruces env vars and it seems to have worked:
repository xxx1111xxxx opened (version 1)
created restic repository xx11111yyy222 at b2:new_bucket:repo with chunker parameters copied from secondary repository
I checked with restic cat config on both repos and they have the same chunker_polynomial.
I believe your suggestion is cleaner though. No need to mess up with application keys et cetera.
repository xxxxxx opened (version 2, compression level auto)
….
Total Uncompressed Size: 7.751 GiB
Total Size: 7.454 GiB
Compression Progress: 100.00%
Compression Ratio: 1.04x
Compression Space Saving: 3.83%
On B2 web interface: old repo 8.8GB vs new repo: 8GB (don’t know if it’s good enough for compression max). Strange that compression level auto sneaked in (maybe this). restic copy was done with --compression max
Some notes (just in case it helps someone else):
--dry-run didn’t work either with init or copy (not sure I missed something or that’s how it is)
During first copy attempt the command was interrupted; succeeded in next try. But the new repo had ballooned to 17GB (vs 8GB of old repo). restic check said ……additional files were found in the repo, which likely contain duplicate data… → restic prune fixed it.
restic check, restic check --read-data-subset=1/20, and restic restore (checked on couple of smaller file/folders) passed.
I will check with --read-data later, set up backrest, and then delete old repo.
Thank you @kapitainsky and restic community.