borg extract

borg [common options] extract [options] ARCHIVE [PATH...]

positional arguments

ARCHIVE

archive to extract

PATH

paths to extract; patterns are supported

optional arguments

--list

output verbose list of items (files, dirs, …)

-n, --dry-run

do not actually change any files

--numeric-owner

deprecated, use --numeric-ids instead

--numeric-ids

only obey numeric user and group identifiers

--nobsdflags

deprecated, use --noflags instead

--noflags

do not extract/set flags (e.g. NODUMP, IMMUTABLE)

--noacls

do not extract/set ACLs

--noxattrs

do not extract/set xattrs

--stdout

write all extracted data to stdout

--sparse

create holes in output sparse file from all-zero chunks

Common options

Include/Exclude options

-e PATTERN, --exclude PATTERN

exclude paths matching PATTERN

--exclude-from EXCLUDEFILE

read exclude patterns from EXCLUDEFILE, one per line

--pattern PATTERN

include/exclude paths matching PATTERN

--patterns-from PATTERNFILE

read include/exclude patterns from PATTERNFILE, one per line

--strip-components NUMBER

Remove the specified number of leading path elements. Paths with fewer elements will be silently skipped.

Description

This command extracts the contents of an archive. By default the entire archive is extracted but a subset of files and directories can be selected by passing a list of PATHs as arguments. The file selection can further be restricted by using the --exclude option.

For more help on include/exclude patterns, see the borg help patterns command output.

By using --dry-run, you can do all extraction steps except actually writing the output data: reading metadata and data chunks from the repo, checking the hash/hmac, decrypting, decompressing.

--progress can be slower than no progress display, since it makes one additional pass over the archive metadata.

Note

Currently, extract always writes into the current working directory (“.”), so make sure you cd to the right place before calling borg extract.

When parent directories are not extracted (because of using file/directory selection or any other reason), borg can not restore parent directories’ metadata, e.g. owner, group, permission, etc.

Examples

# Extract entire archive
$ borg extract /path/to/repo::my-files

# Extract entire archive and list files while processing
$ borg extract --list /path/to/repo::my-files

# Verify whether an archive could be successfully extracted, but do not write files to disk
$ borg extract --dry-run /path/to/repo::my-files

# Extract the "src" directory
$ borg extract /path/to/repo::my-files home/USERNAME/src

# Extract the "src" directory but exclude object files
$ borg extract /path/to/repo::my-files home/USERNAME/src --exclude '*.o'

# Restore a raw device (must not be active/in use/mounted at that time)
$ borg extract --stdout /path/to/repo::my-sdx | dd of=/dev/sdx bs=10M