Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Support for restic copy command #145

Closed
cqjjjzr opened this issue Dec 21, 2021 · 15 comments · Fixed by #180
Closed

[Feature Request] Support for restic copy command #145

cqjjjzr opened this issue Dec 21, 2021 · 15 comments · Fixed by #180
Labels
enhancement New feature or request ready Implemented and waiting for release
Milestone

Comments

@cqjjjzr
Copy link

cqjjjzr commented Dec 21, 2021

Hi, just discovered this awesome project and I wonder if we could support the restic copy command: https://restic.readthedocs.io/en/stable/045_working_with_repos.html#copying-snapshots-between-repositories

When backing up to multiple backends, the current solution is to run restic backup command multiple times. However, if all the backends have similar options, then: 1) backing up to one repository first; 2) then copying the whole repository to all other backends; would save a lot of time and disk I/Os. However, since all data is needed to be downloaded and then uploaded, the first repository (the one as the destination of restic copy) must be fast and responsive.

The ideal solution is: For configuration, add a copy section in the location nodes in locations. This section consists of two elements:

  • from - must be one name from backends in to list of the current location;
  • to - a list of backends

When the backup is completed for the current location + from backend specified in the copy section, (should the time and whether to run the copy command be customizable?) autorestic should run restic copy for all to backends specified in the copy section to synchronize the snapshots.

@cupcakearmy cupcakearmy added the enhancement New feature or request label Dec 22, 2021
@cupcakearmy
Copy link
Owner

Thats a very interesting suggestion. What about something like this?

location:
  from: ...
  to: backend1
  copy:
    - backend2
    - backend3

@cqjjjzr
Copy link
Author

cqjjjzr commented Dec 22, 2021

Factually I believe it could be:

location:
    from: ...
    to:
        - backend1 # fast
        - backend2 # slow
    copy:
        from: backend1 # disambiguity
        to:
            - backend3
            - backend4

But this syntax seems to be a little verbose..

@cupcakearmy
Copy link
Owner

Mhh, it is a bit verbose. Though more flexible for sure.

location:
    from: ...
    to:
        - backend1 # fast
        - backend2 # slow
    copy:
        - backend1: backend3
        - backend1: backend4

or

location:
    from: ...
    to:
        - backend1 # fast
        - backend2 # slow
    copy:
      backend1:
        - backend3
        - backend4

Don't know which I would prefer, all threee seem reasonable. Maybe I'll ask discord 😅

@cqjjjzr
Copy link
Author

cqjjjzr commented Dec 22, 2021

The second one is even more flexible since it supports many-to-many copying.

Additionally, I noticed that we don't need to place the copy section in a location! It could be a global section because copy command doesn't depend on any location.

@cupcakearmy
Copy link
Owner

2 and 3 shold be equivalent mostly, you can do many to many with both. But maybe the 2nd is more clear? I'll ask discord about 2 vs 3.

I thought too about a global config option. But if it's a global setting every location will be mirrored. I think it's better to scope it to a location?

@cqjjjzr
Copy link
Author

cqjjjzr commented Dec 22, 2021

The copy command is not based on source locations, but are about backends (aka restic repositories) only, so it makes sense to make it global.

@cupcakearmy
Copy link
Owner

Yes, but I think its better to only copy the current snapshot made for a location than every snapshot ever made on that backend.

@cqjjjzr
Copy link
Author

cqjjjzr commented Dec 22, 2021

Hmm.. The filter criteria can be tags, hosts, paths, snapshot ID, maybe we could allow both one global section and one in the location (which uses paths for filtering)?

@cupcakearmy
Copy link
Owner

Paths are a bit of a pain to work with as they are an array tbh. thats why I introduced tags for each location. But then the usecase is replicate an entire repo?

@cqjjjzr
Copy link
Author

cqjjjzr commented Dec 22, 2021

According to the restic document, you could replicate the entire one, but can also pick out some snapshots (based on those criteria) to copy.

But anyway, it's a operation between two repos.

@cupcakearmy
Copy link
Owner

Yes, the operation is between two repos, but semantically it's still relevant to a location right? because I though you wanted to copy the backup that was just made to another repo right? and a backup in the "world" of autorestic is location bound.

@cqjjjzr
Copy link
Author

cqjjjzr commented Dec 22, 2021

Hmm. That's correct.

@cupcakearmy
Copy link
Owner

Discord has spoken https://discord.com/channels/252403122348097536/834380500315537478/923163095801688106

location:
  from: ...
  to:
    - backend1 # fast
    - backend2 # slow
  copy:
    backend1:
      - backend3
      - backend4

seems to be the more popular version

@FarisZR
Copy link
Contributor

FarisZR commented Mar 21, 2022

Until this is implemented, can I use the normal Restic copy command to copy autorestic repositories ?

@cupcakearmy
Copy link
Owner

You should be able to simply use autorestic exec to run any native restic commands :)

@cupcakearmy cupcakearmy mentioned this issue Apr 13, 2022
@cupcakearmy cupcakearmy added the ready Implemented and waiting for release label Apr 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request ready Implemented and waiting for release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants