Linux/Compression tools: Difference between revisions

From Wiki
mNo edit summary
 
(13 intermediate revisions by the same user not shown)
Line 1: Line 1:
== tar ==
* create .tar.gz
<pre>
tar -czvf file.tar.gz directory        # pack directory
                                      # (c):create (z):gzip (v):verbose (f):file
tar -czf file.tar.gz -C /var/www .    # remove parent directory path
</pre>
* list contents
<pre>
tar -ztvf my-data.tar.gz              # (z):gzip (t):list (v):verbose (f):file
</pre>
* extract (untar)
<pre>
tar -xvf archive.tar.gz                # (x):extract (v):verbose (f):file
</pre>
== benchmark ==
== benchmark ==
* Compressing 6144MB kvm image
* Compressing 6144MB kvm image (RAW, 2,7GB used)


{| class="wikitable sortable" border="1"
{| class="wikitable sortable" border="1"
Line 8: Line 27:
! compressed size [MB]
! compressed size [MB]
! time [s]
! time [s]
! additional size [MB]
|-
|-
| pigz
| pigz
Line 13: Line 33:
| 1526
| 1526
| 259.65
| 259.65
| 533
|-
|-
| pigz
| pigz
Line 18: Line 39:
| 1667
| 1667
| 28.06
| 28.06
| 674
|-
|-
| cat  
| cat  
Line 34: Line 56:
| 1333
| 1333
| 359.66
| 359.66
| 340


|-
|-
Line 40: Line 63:
| 993
| 993
| 1360.15
| 1360.15
| 0


|-
|-
Line 46: Line 70:
| 1137
| 1137
| 551.40
| 551.40
| 144


|-
|-
| 7z  
| 7z  
| -mx9 -m0=lzma2 -mmt4 -si
| a -m0=lzma2 -mx9 -si
| 1006
| 1006
| 788
| 788.00
| 13


|}
|}
Line 70: Line 96:
</pre>  
</pre>  
</blockquote>
</blockquote>
[[Category:Linux/CL-Tools]]
[[Category:Linux]]

Latest revision as of 20:11, 21 August 2024

tar

  • create .tar.gz
tar -czvf file.tar.gz directory        # pack directory 
                                       # (c):create (z):gzip (v):verbose (f):file

tar -czf file.tar.gz -C /var/www .     # remove parent directory path
  • list contents
tar -ztvf my-data.tar.gz               # (z):gzip (t):list (v):verbose (f):file
  • extract (untar)
tar -xvf archive.tar.gz                # (x):extract (v):verbose (f):file

benchmark

  • Compressing 6144MB kvm image (RAW, 2,7GB used)
Command Arguments compressed size [MB] time [s] additional size [MB]
pigz --best 1526 259.65 533
pigz --fast 1667 28.06 674
cat > target 6144 60.80
copy 6144 59.36
7z a -t7z -mx1 -si 1333 359.66 340
7z a -t7z -mx9 -si 993 1360.15 0
7z a -m0=lzma2 -si 1137 551.40 144
7z a -m0=lzma2 -mx9 -si 1006 788.00 13


  • benchmark script
#!/bin/bash
COMPRESSCMD="pigz -9"
DESC="pigz-best"

START=$(date +%s.%N)
cat image.img | $COMPRESSCMD > /backup/$DESC.img.gz
END=$(date +%s.%N)
DIFF=$(echo "$END - $START" | bc)
echo "$DIFF" > /backup/$DESC.log