How to copy repo to another device?

I use restic to backup my pc every day and copy the repository to my usb drive every week.
I copy the repository by first deleting the repo in my usb drive and then copy the whole repo to the usb drive, but this takes a long time.
Is there a faster way to do it?
I looked at the structure of the repository and I guess I can do this by copying new files to the repo to the flash drive (copy and skip files with the same name), and then do rebuild-index and prune and check. I wonder if this is correct.

Yes, you can copy new files and delete files that no longer exist locally. rsync can do this:

rsync --delete --delete-after -a /path/to/source /path/to/flash-drive

If you perform a full sync (make the flash drive exactly match the source) then rebuild-index and prune are unnecessary; the indexes would have also been synced.

1 Like