borg transfer

borg [common options] transfer [options]
optional arguments
  -n, --dry-run do not change repository, just check
  --other-repo SRC_REPOSITORY transfer archives from the other repository
  --upgrader UPGRADER use the upgrader to convert transferred data (default: no conversion)

Common options

Archive filters — Archive filters can be applied to repository targets.
  -a GLOB, --glob-archives GLOB only consider archive names matching the glob. sh: rules apply, see “borg help patterns”.
  --sort-by KEYS Comma-separated list of sorting keys; valid keys are: timestamp, name, id; default is: timestamp
  --first N consider first N archives after other filters were applied
  --last N consider last N archives after other filters were applied

Description

This command transfers archives from one repository to another repository. Optionally, it can also upgrade the transferred data.

Suggested use for general purpose archive transfer (not repo upgrades):

# initialize DST_REPO reusing key material from SRC_REPO, so that
# chunking and chunk id generation will work in the same way as before.
borg --repo=DST_REPO init --other-repo=SRC_REPO --encryption=DST_ENC

# transfer archives from SRC_REPO to DST_REPO
borg --repo=DST_REPO transfer --other-repo=SRC_REPO --dry-run  # check what it would do
borg --repo=DST_REPO transfer --other-repo=SRC_REPO            # do it!
borg --repo=DST_REPO transfer --other-repo=SRC_REPO --dry-run  # check! anything left?

The default is to transfer all archives, including checkpoint archives.

You could use the misc. archive filter options to limit which archives it will transfer, e.g. using the -a option. This is recommended for big repositories with multiple data sets to keep the runtime per invocation lower.

For repository upgrades (e.g. from a borg 1.2 repo to a related borg 2.0 repo), usage is quite similar to the above:

borg --repo=DST_REPO transfer --other-repo=SRC_REPO --upgrader=From12To20

Examples

# 0. Have borg 2.0 installed on client AND server, have a b12 repo copy for testing.

# 1. Create a new "related" repository:
# here, the existing borg 1.2 repo used repokey-blake2 (and aes-ctr mode),
# thus we use repokey-blake2-aes-ocb for the new borg 2.0 repo.
# staying with the same chunk id algorithm (blake2) and with the same
# key material (via --other-repo <oldrepo>) will make deduplication work
# between old archives (copied with borg transfer) and future ones.
# the AEAD cipher does not matter (everything must be re-encrypted and
# re-authenticated anyway), you could also choose repokey-blake2-chacha20-poly1305.
# in case your old borg repo did not use blake2, just remove the "-blake2".
$ borg --repo       ssh://borg2@borgbackup/./tests/b20 rcreate \
       --other-repo ssh://borg2@borgbackup/./tests/b12 -e repokey-blake2-aes-ocb

# 2. Check what and how much it would transfer:
$ borg --repo       ssh://borg2@borgbackup/./tests/b20 transfer \
       --other-repo ssh://borg2@borgbackup/./tests/b12 --dry-run

# 3. Transfer (copy) archives from old repo into new repo (takes time and space!):
$ borg --repo       ssh://borg2@borgbackup/./tests/b20 transfer \
       --other-repo ssh://borg2@borgbackup/./tests/b12

# 4. Check if we have everything (same as 2.):
$ borg --repo       ssh://borg2@borgbackup/./tests/b20 transfer \
       --other-repo ssh://borg2@borgbackup/./tests/b12 --dry-run