Tar: Difference between revisions

From Chorke Wiki
Jump to navigation Jump to search
No edit summary
 
(22 intermediate revisions by the same user not shown)
Line 1: Line 1:
{|class='wikitable' style='width:100%;margin:-11px 0 6px 0'
|valign='top' style='width:50%'|
<syntaxhighlight style='margin:3px 0' lang='bash'>
tar --version
which tar
</syntaxhighlight>
|valign='top' style='width:50%'|
|}
==Compress==
==Compress==
<syntaxhighlight lang="bash">
{|class='wikitable mw-collapsible' style='width:100%;margin:3px 0'
!scope='col' style='text-align:left'|
Compress
|-
|valign='top'|
<syntaxhighlight style='margin:3px 0' lang='bash'>
cd /etc/nginx
cd /etc/nginx
tar -czvf chorke-nginx_academia-production-20240628-T2023-ZP0800.tar.gz sites-enabled
tar -czvf chorke-nginx_academia-production-D20240628-T2023-ZP0800.tar.gz sites-enabled
tar --exclude=default -czvf chorke-nginx_academia-production-20240628-T2023-ZP0800.tar.gz sites-enabled
tar --exclude=default -czvf chorke-nginx_academia-production-D20240628-T2023-ZP0800.tar.gz sites-enabled
</syntaxhighlight>
</syntaxhighlight>
|}


==Decompress==
==Decompress==
<syntaxhighlight lang="bash">
{|class='wikitable mw-collapsible' style='width:100%;margin:3px 0'
tar -tzvf chorke-nginx_academia-production-20240628-T2023-ZP0800.tar.gz
!scope='col' style='text-align:left'|
tar -xzvf chorke-nginx_academia-production-20240628-T2023-ZP0800.tar.gz
Decompress
tar -xzvf chorke-nginx_academia-production-20240628-T2023-ZP0800.tar.gz -C chorke-nginx-academia-production
|-
|valign='top'|
<syntaxhighlight style='margin:3px 0' lang='bash'>
tar -tzvf chorke-nginx_academia-production-D20240628-T2023-ZP0800.tar.gz
tar -xzvf chorke-nginx_academia-production-D20240628-T2023-ZP0800.tar.gz
tar -xzvf chorke-nginx_academia-production-D20240628-T2023-ZP0800.tar.gz -C chorke-nginx-academia-production
</syntaxhighlight>
</syntaxhighlight>
|}


==Explanation==
==Explanation==
-c: Create a new archive
{|class='wikitable mw-collapsible' style='width:100%;margin:3px 0'
-x: Extract the archive
!scope='col' style='text-align:left' colspan='2'|
-z: Compress the archive with gzip
Explanation
-v: Verbosely list files processed
|-
-t: List the contents of the archive
|valign='top' style='width:50%'|
-f: Specifies the name of the archive
<syntaxhighlight style='margin:3px 0' lang='text'>
-c: Create a new archive
-x: Extract the archive
-z: Compress the archive with gzip
-v: Verbosely list files processed
-t: List the contents of the archive
-f: Specifies the name of the archive
</syntaxhighlight>
 
|valign='top' style='width:50%'|
|}
 
==Cheatsheet==
{|class='wikitable mw-collapsible' style='width:100%;margin:3px 0'
!scope='col' style='text-align:left' colspan='6'|
Cheatsheet
|-
!scope="col"| Type !!scope="col"| Short !!scope="col"|                                                Compress !!scope="col"|                                  Decompress !!scope="col"| Algorithm !!scope="col"| ⚪
|-
| '''tar.gz'''    || '''-z'''          || <code>time tar -czvf nginx.2024-06-30T1519.tar.gz &nbsp;nginx</code> || <code>time tar -xzvf nginx.2024-06-30T1519.tar.gz</code> || DEFLATE=LZ77+Huffman  || 🟢
|-
| '''tar.xz'''    || '''-J'''          || <code>time tar -cJvf nginx.2024-06-30T1519.tar.xz &nbsp;nginx</code> || <code>time tar -xJvf nginx.2024-06-30T1519.tar.xz</code> || LZMA2                || 🟠
|-
| '''tar.bz2'''    || '''-j'''          || <code>time tar -cjvf nginx.2024-06-30T1519.tar.bz2 nginx</code>      || <code>time tar -xjvf nginx.2024-06-30T1519.tar.bz2</code>|| BZIP2                || 🟡
|}


==DateTime Format==
==DateTime Format==
<syntaxhighlight lang="bash">
{|class='wikitable mw-collapsible' style='width:100%;margin:3px 0'
echo "$(date +'%Y%m%d-T%H%M')-Z$(date +'%z'|tr '+-' 'PM')"
!scope='col' style='text-align:left' colspan='2'|
DateTime Format
|-
|valign='top' style='width:50%'|
<syntaxhighlight style='margin:3px 0' lang='bash'>
echo     "$(TZ=UTC-8 date +'%Y-%m-%dT%H%M')"
echo            "$(TZ=UTC-8 date +'%FT%H%M')"
BKP_DATE_N_TIME="$(TZ=UTC-8 date +'%FT%H%M')"
:'
:'
20240628-T2023-ZP0800
2025-10-10T1010
├─ 20240628
├─ 2025-10-21
│  ├─ 2024 « %Y
│  ├─ 2025 « %Y
│  ├─ 06   « m%
│  ├─  10 « %m
│  └─ 28   « %d
│  └─  10 « %d
├─ -T2023
└─ T1010
│  ├─ -   « -
  ├─    T « Time
│  ├─ T   « Time
  ├─  10 « %H
│  ├─ 20   « %H
  └─  10 « %M
│  └─ 23   « %M
└─ -ZP0800
  ├─ -    « -
  ├─ Z    « Zone
  ├─ P    « {P: Plus (+), M:Minus (-)}
  └─ 0800 « Time Offset
'
'
</syntaxhighlight>
</syntaxhighlight>
|valign='top' style='width:50%'|
|}


==References==
==References==
{|
{|class='wikitable mw-collapsible' style='width:100%;margin:3px 0'
| valign="top" |
!scope='col' style='text-align:left' colspan='3'|
References
|-
|valign='top' style='width:33%'|
* [[7Zip]]
* [[Zip]]
* [https://en.wikipedia.org/wiki/Tar Tar]
* [https://en.wikipedia.org/wiki/Tar Tar]
* [[Jar]]


| valign="top" |
|valign='top' style='width:34%'|
 
| valign="top" |


|valign='top' style='width:33%'|
|-
|-
| colspan="3" |
|valign='top'|
----
|-
| valign="top" |
* [[Minikube Systemd]]
* [[Minikube Systemd]]
* [[Alpine/Morefine]]
* [[Alpine/Morefine]]
Line 65: Line 116:
* [[Crontab]]
* [[Crontab]]
* [[PyEnv]]
* [[PyEnv]]
* [[Drone]]
* [[TMux]]
* [[TMux]]


| valign="top" |
|valign='top'|
* [[Chorke Academia Backup]]
* [https://stackoverflow.com/questions/10555483/ MediaWiki Escape </code>&#124;</code>]
* [[Disk Performance]]
* [[Google Cloud CLI]]
* [[LXC/Logrotate|LXC » Logrotate]]
* [[Free Up RAM]]
* [[AWS CLI]]


| valign="top" |
|valign='top'|


|}
|}

Latest revision as of 01:12, 16 January 2026

tar --version
which tar

Compress

Compress

cd /etc/nginx
tar -czvf chorke-nginx_academia-production-D20240628-T2023-ZP0800.tar.gz sites-enabled
tar --exclude=default -czvf chorke-nginx_academia-production-D20240628-T2023-ZP0800.tar.gz sites-enabled

Decompress

Decompress

tar -tzvf chorke-nginx_academia-production-D20240628-T2023-ZP0800.tar.gz
tar -xzvf chorke-nginx_academia-production-D20240628-T2023-ZP0800.tar.gz
tar -xzvf chorke-nginx_academia-production-D20240628-T2023-ZP0800.tar.gz -C chorke-nginx-academia-production

Explanation

Explanation

-c: Create a new archive
-x: Extract the archive
-z: Compress the archive with gzip
-v: Verbosely list files processed
-t: List the contents of the archive
-f: Specifies the name of the archive

Cheatsheet

Cheatsheet

Type Short Compress Decompress Algorithm
tar.gz -z time tar -czvf nginx.2024-06-30T1519.tar.gz  nginx time tar -xzvf nginx.2024-06-30T1519.tar.gz DEFLATE=LZ77+Huffman 🟢
tar.xz -J time tar -cJvf nginx.2024-06-30T1519.tar.xz  nginx time tar -xJvf nginx.2024-06-30T1519.tar.xz LZMA2 🟠
tar.bz2 -j time tar -cjvf nginx.2024-06-30T1519.tar.bz2 nginx time tar -xjvf nginx.2024-06-30T1519.tar.bz2 BZIP2 🟡

DateTime Format

DateTime Format

echo      "$(TZ=UTC-8 date +'%Y-%m-%dT%H%M')"
echo            "$(TZ=UTC-8 date +'%FT%H%M')"
BKP_DATE_N_TIME="$(TZ=UTC-8 date +'%FT%H%M')"
:'
2025-10-10T1010
├─ 2025-10-21
│  ├─ 2025 « %Y
│  ├─   10 « %m
│  └─   10 « %d
└─ T1010
   ├─    T « Time
   ├─   10 « %H
   └─   10 « %M
'

References

References