Difference between revisions of "Linux command: tar"
Jump to navigation
Jump to search
Rafahsolis (talk | contribs) m (→Extraction) Tag: visualeditor |
Rafahsolis (talk | contribs) m (→With password) Tag: visualeditor |
||
| (2 intermediate revisions by the same user not shown) | |||
| Line 17: | Line 17: | ||
tar --exclude='./folder' --exclude='./upload/folder2' -zcvf /backup/filename.tgz . | tar --exclude='./folder' --exclude='./upload/folder2' -zcvf /backup/filename.tgz . | ||
tar --exclude='./backup' -zcvf - . | split --bytes=1024MB - backup/content.sdf.backup.tar.gz. | tar --exclude='./backup' -zcvf - . | split --bytes=1024MB - backup/content.sdf.backup.tar.gz. | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | ===With password=== | ||
| + | <syntaxhighlight lang="bash"> | ||
| + | tar -czf - * | openssl enc -e -aes256 -pbkdf2 -out secured.tar.gz | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 29: | Line 34: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
tar -zxvf archive.tar.gz | tar -zxvf archive.tar.gz | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | ====With password==== | ||
| + | <syntaxhighlight lang="bash"> | ||
| + | openssl enc -d -aes256 -pbkdf2 -in secured.tar.gz | tar xz -C target_dir | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 46: | Line 56: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| − | === Extract all files in subdirectories === | + | ===Extract all files in subdirectories=== |
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
DEST=<Destination Folder> | DEST=<Destination Folder> | ||
Latest revision as of 07:57, 26 April 2019
Compression
.tar.gz
tar -zcvf /var/my-backup.tar.gz /home/rafa/
.tar.gz split with max size
tar cvzf - dir/ | split --bytes=200MB - sda1.backup.tar.gz.
tar cvzf - dir/ | split -b 200m - sda1.backup.tar.gz.
tar cvzf - /Applications/Install\ macOS\ Sierra.app/ | split -b 4294967295 - /Volumes/UNTITLED/install_macos_sierra.tgz.
.tar.gz exclude files
tar --exclude='./folder' --exclude='./upload/folder2' -zcvf /backup/filename.tgz .
tar --exclude='./backup' -zcvf - . | split --bytes=1024MB - backup/content.sdf.backup.tar.gz.
With password
tar -czf - * | openssl enc -e -aes256 -pbkdf2 -out secured.tar.gz
Extraction
View .tar.gz contents
tar -ztvf file.tar.gz
Extract .tar.gz
tar -zxvf archive.tar.gz
With password
openssl enc -d -aes256 -pbkdf2 -in secured.tar.gz | tar xz -C target_dir
Extract .txz
tar Jxvf file.txz
Extract .tar.xz
tar -xvf file.tar.xz
Extract .tar.bz2
tar -jtvf file.tar.bz2
Extract all files in subdirectories
DEST=<Destination Folder>
SRC=<Src Folder>
find $SRC -name "*.tar.gz" -or -name "*.tgz" -exec tar xzvvf -C $DEST {} \;
Note: .gz files are decompressed with gunzip file.gz