borg/docs/usage/tar.rst
Thomas Waldmann df6f4201f8
docs: fix broken examples and stale output samples in the usage docs
All command lines were executed against scratch repositories and all
output samples regenerated from real runs (prettified, not invented):

- recreate: the example used the removed --recompress; show
  borg repo-compress instead; refresh the borg info samples.
- diff: default/text output has modified:/added:/removed: labels and
  mtime/ctime brackets now; the JSON-lines example used borg1 keys
  and lacked --json-lines on the command; add --content-only.
- mount: example passed the repository as a positional (it would have
  been taken as the mountpoint); use -r.
- tar: the archive-copy loop was a bash syntax error and used
  borg list with repo-list-only format keys; replaced with a working
  while-read loop over borg repo-list (verified end-to-end, identical
  archive contents in the destination repo).
- key: regenerate repo-create/change-passphrase samples (hex-id named
  keyfiles, Key location line, no "Synchronizing index"); the import
  example silently did nothing without --key-location=keyfile; fix
  the Windows keys path (AppData\Local, not Roaming); explain why the
  keyfile name changes on passphrase change.
- transfer: the borg1->borg2 upgrade steps were missing --from-borg1
  and used a ssh:// destination URL (rejected for current repos);
  fix the Windows keys path.
- notes: --noatime and --nobsdflags no longer exist (atime is opt-in
  via --atime); stray "|" removed.
- compact: segments wording removed.
- info/repo-info/repo-delete/list/find: output samples regenerated
  (new labels/order, UTC offsets, repo version line, prompt text;
  isomtime format and symlink size corrected in list).
- general: fix broken inline markup (stray backtick).
- serve: the authorized_keys forced command needs --rest (it is
  deliberately not client-suppliable); document the actual client
  argument allowlist including --backend.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-28 12:48:17 +02:00

63 lines
2 KiB
ReStructuredText

.. include:: export-tar.rst.inc
.. include:: import-tar.rst.inc
Examples
~~~~~~~~
::
# Export as an uncompressed tar archive
$ borg export-tar Monday Monday.tar
# Import an uncompressed tar archive
$ borg import-tar Monday Monday.tar
# Exclude some file types and compress using gzip
$ borg export-tar Monday Monday.tar.gz --exclude '*.so'
# Use a higher compression level with gzip
$ borg export-tar --tar-filter="gzip -9" Monday Monday.tar.gz
# Copy an archive from repoA to repoB
$ borg -r repoA export-tar --tar-format=BORG archive - | borg -r repoB import-tar archive -
# Export a tar, but instead of storing it on disk, upload it to a remote site using curl
$ borg export-tar Monday - | curl --data-binary @- https://somewhere/to/POST
# Remote extraction via 'tarpipe'
$ borg export-tar Monday - | ssh somewhere "cd extracted; tar x"
# Export sparse files (e.g. disk images) as sparse tar members (GNU sparse format 1.0)
$ borg export-tar --sparse disk-images disk-images.tar
Archives transfer script
~~~~~~~~~~~~~~~~~~~~~~~~
Outputs a script that copies all archives from repo1 to repo2
(``bash``, because it uses process substitution). Remove the ``echo`` to
actually run the commands instead of just printing them:
::
while read -r N I T
do
echo "borg -r repo1 export-tar --tar-format=BORG aid:$I - | borg -r repo2 import-tar --timestamp=$T $N -"
done < <(borg -r repo1 repo-list --format='{name} {id} {time:%Y-%m-%dT%H:%M:%S}{NL}')
Kept:
- archive name, archive timestamp
- archive contents (all items with metadata and data)
Lost:
- some archive metadata (like the original command line, execution time, etc.)
Please note:
- all data goes over that pipe, again and again for every archive
- the pipe is dumb, there is no data or transfer time reduction there due to deduplication
- maybe add compression
- pipe over ssh for remote transfer
- maybe add ``--sparse`` to the export-tar command, so runs of all-zero chunks
travel as a compact sparse map instead of literal zeros