borg-import-tar
Create a backup archive from a tarball
- Provided by: borgbackup2 (Version: 2.0.0b25-4)
- Report a bug
Create a backup archive from a tarball
borg [common options] import-tar [options] NAME TARFILE
This command creates a backup archive from a tarball.
When giving '-' as path, Borg will read a tar stream from standard input.
By default (--tar-filter=auto) Borg will detect whether the file is compressed based on its file extension and pipe the file through an appropriate filter:
For zstd, Borg decompresses in-process using libzstd instead of piping through an external program. The other formats are piped through the respective external filter program.
Alternatively, a --tar-filter program may be explicitly specified. It should read compressed data from stdin and output an uncompressed tar stream on stdout.
Most documentation of borg create applies. Note that this command does not support excluding files.
--strip-components removes the specified number of leading path elements from the tar member names when creating the archive items. Members whose path has fewer or equally many elements are silently skipped. Hard link targets are stripped accordingly, symbolic link targets are left unchanged.
The path elements are counted after normalizing the member name the same way it is stored in the archive, so a leading ./ is not a path element. This differs from tar, which counts it: to import ./top/dir/file as dir/file, use --strip-components=1 here, while tar needs --strip-components=2.
A --sparse option (as found in borg create) is not needed: sparse members in input tarballs (old GNU and PAX sparse formats) are read correctly and their holes are stored as deduplicated all-zero chunks.
About tar formats and metadata conservation or loss, please see borg export-tar.
import-tar reads these tar formats:
To import multiple tarballs into a single archive, they can be simply concatenated (e.g. using "cat") into a single file, and imported with an --ignore-zeros option to skip through the stop markers between them.
See borg-common(1) for common options of Borg commands.
# 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
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:
Lost:
Please note:
The Borg Collective