Daniel
Daniel

Reputation: 2726

How to use tar with lz4?

How to use tar and filter the archive through LZ4? Or any available tools? It looks cumbersome to use tar cvf folderABC.tar folderABC && lz4c -c0 folderABC.tar.

PS: *nix environment

Upvotes: 27

Views: 51881

Answers (4)

mrskyenet
mrskyenet

Reputation: 51

Install lz4

sudo apt install lz4

Compress

tar --use-compress-program=lz4 -cvf target.lz4 /source/files

Decompress

tar --use-compress-program=lz4 -xvf target.lz4 -C /destination

Upvotes: 4

Cyan
Cyan

Reputation: 13988

lz4 has a command line structure similar to gzip. Therefore, something like this will work :

tar cvf - folderABC | lz4 > folderABC.tar.lz4

or

tar cvf - folderABC | lz4 - folderABC.tar.lz4

First one compresses silently, like gzip. Second one is a bit more lz4-specific, and will also display summarized compression stats.

Decompression would go like this :

lz4 -d folderABC.tar.lz4 -c | tar xvf -

Upvotes: 44

JTerry
JTerry

Reputation: 29

To use -I in GNU tar, you must specify it AFTER destination file as this:

tar cvf /path/to/destinationfile.tar.lz4 -I lz4 /path/to/archive

Upvotes: 2

Gert van den Berg
Gert van den Berg

Reputation: 2785

On GNU tar, you can use -I lz4

Both FreeBSD and GNU tar seems to support --use-compress-program=lz4 as well.

tar -I lz4 -cf archive.tar.lz4 stuff to add to archive
tar -I lz4 -xf archive.tar.lz4

or

tar --use-compress-program=lz4 -cf archive.tar.lz4 stuff to add to archive
tar --use-compress-program=lz4 -xf archive.tar.lz4

Upvotes: 30

Related Questions