Documentation incongruity regarding 'copy' command?

Studying the restic docs Working with repositories — restic 0.12.0 documentation, it appears to me that I initialize that second repository before I can do a copy to it.

But then I read about the deduplication problem Working with repositories — restic 0.12.0 documentation. The docs appear to clearly state and show that the target repository must be initialized so that the chunker parameters of the source repo are used.

I try to do that:

tomc@tomc-Spin-SP513-54N:~/bkup$ restic -r /media/tomc/seagate-21/spin5/ _restic-bkup/dropbox init --repo2 /media/tomc/seagate-4/ __spin5-current-restic-copy/dropbox --copy-chunker-params
 enter password for secondary repository: 
 Fatal: unable to open config file: Stat: stat /media/tomc/seagate-4/ __spin5-current-restic-copy/dropbox/config: no such file or directory
 Is there a repository at the following location?
 /media/tomc/seagate-4/__spin5-current-restic-copy/dropbox
 tomc@tomc-Spin-SP513-54N:~/bkup$

restic appears to be seeking and not finding a config file at the target location - but that cannot exist unless there is a repo already set up there. That seems to contradict the docs.

But I try to play along and so set up a repo so it can find a config file…

tomc@tomc-Spin-SP513-54N:~/bkup$ restic init --repo /media/tomc/seagate-4/ __spin5-current-restic-copy/dropbox
 enter password for new repository: 
 enter password again: 
 created restic repository 229949af84 at /media/tomc/seagate-4/ __spin5-current-restic-copy/dropbox
 .
 .
 .
 tomc@tomc-Spin-SP513-54N:~/bkup$

Rerunning the command that was looking for that config file, I get this -

tomc@tomc-Spin-SP513-54N:~/bkup$ restic -r /media/tomc/seagate-21/spin5/ _restic-bkup/dropbox init --repo2 /media/tomc/seagate-4/ __spin5-current-restic-copy/dropbox --copy-chunker-params
 enter password for secondary repository: 
 repository 229949af opened successfully, password is correct
 created new cache in /home/tomc/.cache/restic
 Fatal: create repository at /media/tomc/seagate-21/spin5/_restic-bkup/ dropbox failed: config file already exists
 tomc@tomc-Spin-SP513-54N:~/bkup$ 

Neither approach works for me.

Clearly, I am misunderstanding something here, but I can’t see it.

What OUGHT I to be doing?

The problem is that (IMO) restic confusingly uses --repo and --repo2 for different things in init and copy. This is in my mind a defect that should be fixed, but I’m not sure how it could be in a backwards-compatible way (paging @fd0).

For init, --repo is the repository being written to (initialized) and --repo2 is the repository being read from (source for chunker params).

For copy, --repo is the repository being read from and --repo2 is the repository being written to.

I think it would make sense for --repo to always be the repository written to, and --repo2 used to supply a repository being read from in cases where that’s needed/desired. Unfortunately these two commands are inconsistent regarding which is which.

Most likely you have the repositories swapped in your init command; what restic views as the source repository is what you think is the destination repository, which has no config file yet.

2 Likes

Wow. Your reply certainly looks helpful. What you describe would surely account for the problem I’m having. I’ll rerun the commands with changes reflecting what you suggest.

Thanks! - both for the info. and for the speed of your response.

1 Like

I have successfully copied the first of my 4 repositories! Thank you for your most helpful suggestion.

1 Like

I don’t see how we could swap the repository parameters of the copy command in a backwards compatible way. It would be sort of possible to do that for the init command, as it refuses to overwrite an already existing repository. But neither option is pretty.