Repository: borgbackup/borg
Pull request: add warnings on repository copies to avoid future problem like #4272
fixes #3933.

Problem statement:
docs/faq: copying a repo?
check docs and faq whether we have some words about copying a repo (which should NOT be done usually, at least not if the goal is to update the original as well as the copy using borg).

problems:
- aes ctr reuse (crypto not secure any more)
- cache confusion due to duplicate repo id

we need to point out that for encrypted repos always `borg init` must be used.

Hints from issue discussion:
for unencrypted repos, copies can be made, but you need to change the repo id in the repo config after copying to a new unique value.
To clarify for me:
- if I am just making a copy / backup of a repo (move to a new USB drive / server) so long as I only ever write to one of them in the future then all is good. Can read from either.
- If I am making a copy so that I have a seed repo for future backups, and plan to write to both of them then this is bad.

Could we add a `borg reinit` command that can be run on one of the copies which would take the old password, and a new password, then create a new repo id, and re-encrypt all the repo data with a new aes key, encrypted with the new password.

or `borg export-tar  /path/to/repo::Monday - | borg import-tar /path/to/new-repo::Monday -`

borg import/export-tar: is half there, needs someone doing the other half.

reinit: if you first copy it 1:1, then decrypt and reencrypt everthing, you have read all your data twice and written all your data twice, plus all the encryption/decryption.

Commit message: add warnings on repository copies to avoid future problem like #4272

Patch to review:
diff --git a/docs/faq.rst b/docs/faq.rst
index bd2662dbb2..aa6f94d56f 100644
--- a/docs/faq.rst
+++ b/docs/faq.rst
@@ -26,12 +26,15 @@ or deleting archives, which may make *simultaneous* backups fail.
 Can I copy or synchronize my repo to another location?
 ------------------------------------------------------
 
-Yes, you could just copy all the files. Make sure you do that while no
-backup is running. If you copy a repository while a backup is running, 
-the lock held will be present in the copy. Thus, before using borg on the copy 
-from a different host, you need to use :ref:`break-lock` on the copied 
-repository, because Borg is cautious and does not automatically remove 
-stale locks made by a different host.
+Yes, you could just copy all the files. But you generally do not want
+to do that.
+
+First, make sure you do that while no backup is running. If you copy a
+repository while a backup is running, the lock held will be present in
+the copy. Thus, before using borg on the copy from a different host,
+you need to use :ref:`break-lock` on the copied repository, because
+Borg is cautious and does not automatically remove stale locks made by
+a different host.
 
 So what you get here is this: 
 
@@ -42,7 +45,14 @@ There is no special borg command to do the copying, just use cp or rsync if
 you want to do that.
 
 But think about whether that is really what you want. If something goes
-wrong in repo1, you will have the same issue in repo2 after the copy.
+wrong in repo1, you will have the same issue in repo2 after the
+copy. Specifically, operating on the two repositories at the same time
+will definitely create some issues, both in terms of security (because
+of counter reuse) and reliability (because of the shared cache).
+
+.. important:: One must never access multiple copies of the same
+               repository with borg, as it might lead to data
+               loss. See :issue:`4272` for an example.
 
 If you want to have 2 independent backups, it is better to do it like this:
 


Code review comments:
diff_hunk: @@ -26,12 +26,15 @@ or deleting archives, which may make *simultaneous* backups fail.
 Can I copy or synchronize my repo to another location?
 ------------------------------------------------------
 
-Yes, you could just copy all the files. Make sure you do that while no
-backup is running. If you copy a repository while a backup is running, 
-the lock held will be present in the copy. Thus, before using borg on the copy 
-from a different host, you need to use :ref:`break-lock` on the copied 
-repository, because Borg is cautious and does not automatically remove 
-stale locks made by a different host.
+Yes, you could just copy all the files. But you generally do not want
+to do that.
path: docs/faq.rst
text: @user1:
well, that is maybe a bit too restrictive.

quite some people e.g. use rclone to have a copy of their local repo in the cloud, just in case their house burns down or so.

@author:
how should i phrase this instead? 

@user1:
we should mention `borg with-lock ...` here. it will also produce a lock, but it will use the lock so not other borg updates the repo while it is copied / synchronized.

the problem is not making the copy, but using borg to access more than 1 of the set of original and cloned repos (includes: just reading, updating independently, etc.).