rclone/docs/content
nielash 68f0998699 bisync: add options to auto-resolve conflicts - fixes #7471
Before this change, when a file was new/changed on both paths (relative to the
prior sync), and the versions on each side were not identical, bisync would
keep both versions, renaming them with ..path1 and ..path2 suffixes,
respectively. Many users have requested more control over how bisync handles
such conflicts -- including an option to automatically select one version as
the "winner" and rename or delete the "loser". This change introduces support
for such options.

--conflict-resolve CHOICE

In bisync, a "conflict" is a file that is *new* or *changed* on *both sides*
(relative to the prior run) AND is *not currently identical* on both sides.
`--conflict-resolve` controls how bisync handles such a scenario. The currently
supported options are:

- `none` - (the default) - do not attempt to pick a winner, keep and rename
both files according to `--conflict-loser` and
`--conflict-suffix` settings. For example, with the default
settings, `file.txt` on Path1 is renamed `file.txt.conflict1` and `file.txt` on
Path2 is renamed `file.txt.conflict2`. Both are copied to the opposite path
during the run, so both sides end up with a copy of both files. (As `none` is
the default, it is not necessary to specify `--conflict-resolve none` -- you
can just omit the flag.)
- `newer` - the newer file (by `modtime`) is considered the winner and is
copied without renaming. The older file (the "loser") is handled according to
`--conflict-loser` and `--conflict-suffix` settings (either renamed or
deleted.) For example, if `file.txt` on Path1 is newer than `file.txt` on
Path2, the result on both sides (with other default settings) will be `file.txt`
(winner from Path1) and `file.txt.conflict1` (loser from Path2).
- `older` - same as `newer`, except the older file is considered the winner,
and the newer file is considered the loser.
- `larger` - the larger file (by `size`) is considered the winner (regardless
of `modtime`, if any).
- `smaller` - the smaller file (by `size`) is considered the winner (regardless
of `modtime`, if any).
- `path1` - the version from Path1 is unconditionally considered the winner
(regardless of `modtime` and `size`, if any). This can be useful if one side is
usually more trusted or up-to-date than the other.
- `path2` - same as `path1`, except the path2 version is considered the
winner.

For all of the above options, note the following:
- If either of the underlying remotes lacks support for the chosen method, it
will be ignored and fall back to `none`. (For example, if `--conflict-resolve
newer` is set, but one of the paths uses a remote that doesn't support
`modtime`.)
- If a winner can't be determined because the chosen method's attribute is
missing or equal, it will be ignored and fall back to `none`. (For example, if
`--conflict-resolve newer` is set, but the Path1 and Path2 modtimes are
identical, even if the sizes may differ.)
- If the file's content is currently identical on both sides, it is not
considered a "conflict", even if new or changed on both sides since the prior
sync. (For example, if you made a change on one side and then synced it to the
other side by other means.) Therefore, none of the conflict resolution flags
apply in this scenario.
- The conflict resolution flags do not apply during a `--resync`, as there is
no "prior run" to speak of (but see `--resync-mode` for similar
options.)

--conflict-loser CHOICE

`--conflict-loser` determines what happens to the "loser" of a sync conflict
(when `--conflict-resolve` determines a winner) or to both
files (when there is no winner.) The currently supported options are:

- `num` - (the default) - auto-number the conflicts by automatically appending
the next available number to the `--conflict-suffix`, in chronological order.
For example, with the default settings, the first conflict for `file.txt` will
be renamed `file.txt.conflict1`. If `file.txt.conflict1` already exists,
`file.txt.conflict2` will be used instead (etc., up to a maximum of
9223372036854775807 conflicts.)
- `pathname` - rename the conflicts according to which side they came from,
which was the default behavior prior to `v1.66`. For example, with
`--conflict-suffix path`, `file.txt` from Path1 will be renamed
`file.txt.path1`, and `file.txt` from Path2 will be renamed `file.txt.path2`.
If two non-identical suffixes are provided (ex. `--conflict-suffix
cloud,local`), the trailing digit is omitted. Importantly, note that with
`pathname`, there is no auto-numbering beyond `2`, so if `file.txt.path2`
somehow already exists, it will be overwritten. Using a dynamic date variable
in your `--conflict-suffix` (see below) is one possible way to avoid this. Note
also that conflicts-of-conflicts are possible, if the original conflict is not
manually resolved -- for example, if for some reason you edited
`file.txt.path1` on both sides, and those edits were different, the result
would be `file.txt.path1.path1` and `file.txt.path1.path2` (in addition to
`file.txt.path2`.)
- `delete` - keep the winner only and delete the loser, instead of renaming it.
If a winner cannot be determined (see `--conflict-resolve` for details on how
this could happen), `delete` is ignored and the default `num` is used instead
(i.e. both versions are kept and renamed, and neither is deleted.) `delete` is
inherently the most destructive option, so use it only with care.

For all of the above options, note that if a winner cannot be determined (see
`--conflict-resolve` for details on how this could happen), or if
`--conflict-resolve` is not in use, *both* files will be renamed.

--conflict-suffix STRING[,STRING]

`--conflict-suffix` controls the suffix that is appended when bisync renames a
`--conflict-loser` (default: `conflict`).
`--conflict-suffix` will accept either one string or two comma-separated
strings to assign different suffixes to Path1 vs. Path2. This may be helpful
later in identifying the source of the conflict. (For example,
`--conflict-suffix dropboxconflict,laptopconflict`)

With `--conflict-loser num`, a number is always appended to the suffix. With
`--conflict-loser pathname`, a number is appended only when one suffix is
specified (or when two identical suffixes are specified.) i.e. with
`--conflict-loser pathname`, all of the following would produce exactly the
same result:

```
--conflict-suffix path
--conflict-suffix path,path
--conflict-suffix path1,path2
```

Suffixes may be as short as 1 character. By default, the suffix is appended
after any other extensions (ex. `file.jpg.conflict1`), however, this can be
changed with the `--suffix-keep-extension` flag (i.e. to instead result in
`file.conflict1.jpg`).

`--conflict-suffix` supports several *dynamic date variables* when enclosed in
curly braces as globs. This can be helpful to track the date and/or time that
each conflict was handled by bisync. For example:

```
--conflict-suffix {DateOnly}-conflict
// result: myfile.txt.2006-01-02-conflict1
```

All of the formats described [here](https://pkg.go.dev/time#pkg-constants) and
[here](https://pkg.go.dev/time#example-Time.Format) are supported, but take
care to ensure that your chosen format does not use any characters that are
illegal on your remotes (for example, macOS does not allow colons in
filenames, and slashes are also best avoided as they are often interpreted as
directory separators.) To address this particular issue, an additional
`{MacFriendlyTime}` (or just `{mac}`) option is supported, which results in
`2006-01-02 0304PM`.

Note that `--conflict-suffix` is entirely separate from rclone's main `--sufix`
flag. This is intentional, as users may wish to use both flags simultaneously,
if also using `--backup-dir`.

Finally, note that the default in bisync prior to `v1.66` was to rename
conflicts with `..path1` and `..path2` (with two periods, and `path` instead of
`conflict`.) Bisync now defaults to a single dot instead of a double dot, but
additional dots can be added by including them in the specified suffix string.
For example, for behavior equivalent to the previous default, use:

```
[--conflict-resolve none] --conflict-loser pathname --conflict-suffix .path
```
2024-01-20 17:17:01 -05:00
..
commands sync: report list of synced paths to file -- see #7282 2024-01-20 14:50:08 -05:00
oracleobjectstorage docs: fix typos found by codespell in docs and code comments 2023-09-23 12:20:01 +01:00
_index.md docs: add bisync to index 2024-01-20 14:50:08 -05:00
alias.md docs: Add minimum versions to all the backend pages and some of the other pages 2022-11-18 14:41:24 +00:00
amazonclouddrive.md amazonclouddrive: remove Amazon Drive backend code and docs #7539 2024-01-04 17:05:54 +00:00
authors.md Add Harshit Budhraja to contributors 2024-01-17 10:23:50 +00:00
azureblob.md Version v1.65.0 2023-11-26 16:07:39 +00:00
azurefiles.md azurefiles: finish docs and implementation and add optional interfaces 2023-11-18 16:48:23 +00:00
b2.md Version v1.65.0 2023-11-26 16:07:39 +00:00
bisync.md bisync: add options to auto-resolve conflicts - fixes #7471 2024-01-20 17:17:01 -05:00
box.md Version v1.65.0 2023-11-26 16:07:39 +00:00
bugs.md docs: improve grammar and fix typos (#5361) 2021-11-04 12:50:43 +01:00
cache.md docs: add badge for experimental/beta/deprecated status next to version in backend docs 2022-12-03 18:58:55 +01:00
changelog.md Changelog updates from Version v1.65.1 2024-01-08 11:54:02 +00:00
chunker.md docs: cleanup backend hashes sections 2023-11-20 17:43:57 +00:00
combine.md docs: show only significant parts of version number in version introduced label 2022-12-21 12:41:47 +00:00
compress.md docs: show only significant parts of version number in version introduced label 2022-12-21 12:41:47 +00:00
contact.md docs: update contact page on website 2023-07-05 16:57:07 +01:00
crypt.md amazonclouddrive: remove Amazon Drive backend code and docs #7539 2024-01-04 17:05:54 +00:00
docker.md docs: show only significant parts of version number in version introduced label 2022-12-21 12:41:47 +00:00
docs.md sync: --fix-case flag to rename case insensitive dest - fixes #4854 2024-01-20 14:50:08 -05:00
downloads.md docs: add rclone OS requirements 2024-01-17 16:42:33 +00:00
drive.md Version v1.65.0 2023-11-26 16:07:39 +00:00
dropbox.md Version v1.65.0 2023-11-26 16:07:39 +00:00
faq.md docs: faq: add solution for port opening issues on Windows 2023-06-25 11:20:54 +01:00
fichier.md Version v1.65.0 2023-11-26 16:07:39 +00:00
filefabric.md Version v1.65.0 2023-11-26 16:07:39 +00:00
filtering.md add missing backtick 2024-01-19 11:17:36 +00:00
flags.md Version v1.65.0 2023-11-26 16:07:39 +00:00
ftp.md Version v1.65.0 2023-11-26 16:07:39 +00:00
googlecloudstorage.md Version v1.65.0 2023-11-26 16:07:39 +00:00
googlephotos.md Version v1.65.0 2023-11-26 16:07:39 +00:00
gui.md docs: show only significant parts of version number in version introduced label 2022-12-21 12:41:47 +00:00
hasher.md docs: fix typos found by codespell 2023-03-24 20:49:00 +00:00
hdfs.md Version v1.65.0 2023-11-26 16:07:39 +00:00
hidrive.md Version v1.65.0 2023-11-26 16:07:39 +00:00
http.md Version v1.65.0 2023-11-26 16:07:39 +00:00
imagekit.md Version v1.65.0 2023-11-26 16:07:39 +00:00
install.md docs: document how to build with version info and icon resources on windows 2023-11-01 12:44:04 +01:00
install.sh install.sh: fix harmless error message on install 2023-11-28 19:10:04 +00:00
internetarchive.md Version v1.65.0 2023-11-26 16:07:39 +00:00
jottacloud.md Version v1.65.0 2023-11-26 16:07:39 +00:00
KEYS docs: document release signing and verification 2023-09-11 12:28:23 +01:00
koofr.md Version v1.65.0 2023-11-26 16:07:39 +00:00
licence.md docs: fix typo in license webpage 2022-07-06 11:25:31 +01:00
linkbox.md backend: add Linkbox backend 2023-11-18 17:14:45 +00:00
local.md Version v1.65.0 2023-11-26 16:07:39 +00:00
mailru.md Version v1.65.0 2023-11-26 16:07:39 +00:00
mega.md Version v1.65.0 2023-11-26 16:07:39 +00:00
memory.md docs: cleanup backend hashes sections 2023-11-20 17:43:57 +00:00
netstorage.md docs: show only significant parts of version number in version introduced label 2022-12-21 12:41:47 +00:00
onedrive.md Version v1.65.0 2023-11-26 16:07:39 +00:00
opendrive.md Version v1.65.0 2023-11-26 16:07:39 +00:00
oracleobjectstorage.md oracleobjectstorage: Support "backend restore" command - fixes #7371 2024-01-09 09:43:36 +00:00
overview.md imagekit: updated overview - supported operations 2024-01-17 16:38:54 +00:00
pcloud.md Version v1.65.0 2023-11-26 16:07:39 +00:00
pikpak.md Version v1.65.0 2023-11-26 16:07:39 +00:00
premiumizeme.md Version v1.65.0 2023-11-26 16:07:39 +00:00
privacy.md docs: improve grammar and fix typos (#5361) 2021-11-04 12:50:43 +01:00
protondrive.md Version v1.65.0 2023-11-26 16:07:39 +00:00
putio.md Version v1.65.0 2023-11-26 16:07:39 +00:00
qingstor.md Version v1.65.0 2023-11-26 16:07:39 +00:00
quatrix.md Version v1.65.0 2023-11-26 16:07:39 +00:00
rc.md Version v1.65.0 2023-11-26 16:07:39 +00:00
release_signing.md docs: document release signing and verification 2023-09-11 12:28:23 +01:00
remote_setup.md amazonclouddrive: remove Amazon Drive backend code and docs #7539 2024-01-04 17:05:54 +00:00
s3.md amazonclouddrive: remove Amazon Drive backend code and docs #7539 2024-01-04 17:05:54 +00:00
seafile.md Version v1.65.0 2023-11-26 16:07:39 +00:00
sftp.md Version v1.65.0 2023-11-26 16:07:39 +00:00
sharefile.md Version v1.65.0 2023-11-26 16:07:39 +00:00
sia.md Version v1.65.0 2023-11-26 16:07:39 +00:00
smb.md Version v1.65.0 2023-11-26 16:07:39 +00:00
sponsor.md docs: rename donate page to sponsor page and rework 2023-06-30 14:32:53 +01:00
storj.md storj: update satellite urls and labels 2023-02-06 13:18:15 +00:00
sugarsync.md Version v1.65.0 2023-11-26 16:07:39 +00:00
swift.md Version v1.65.0 2023-11-26 16:07:39 +00:00
tardigrade.md docs: show only significant parts of version number in version introduced label 2022-12-21 12:41:47 +00:00
union.md union: fix documentation 2023-10-21 10:37:43 +01:00
uptobox.md Version v1.65.0 2023-11-26 16:07:39 +00:00
webdav.md Version v1.65.0 2023-11-26 16:07:39 +00:00
yandex.md Version v1.65.0 2023-11-26 16:07:39 +00:00
zoho.md Version v1.65.0 2023-11-26 16:07:39 +00:00