Tarballs, extraction, & you!

bash

#1

I know that I’m not the only one who fights with tar -xvjf versus tar -xvzf (or even what the four options are!). The reason that I know I’m not the only one is because I found this on the web this morning:

https://packages.debian.org/jessie/utils/dtrx

Do The Right eXtraction!

## Instead of 
tar -xvjf foo.tar.bz2

##  Use
dtrx foo.tar.bz2

I hope this helps everyone as much as it helped me!


#2

Modern tar works without j,x, and other options:

tar xf file.tar.bz2
tar xf foo.tar.gz

#3

I didn’t know that, and it isn’t obvious from the Man Page. :frowning:


#4

First version of using tar for system backup and restore based on instructions at cryptsetup and ArchLinux (did cf followed by gzip rather than zcf since I wanted to pass -9 option to gzip):

#!/bin/bash

parent_dir=/tmp
some_dir=n1p3
split_at=2145386496

stamp(){
echo
date
echo
}

stamp

pushd ${parent_dir}

stamp

tar cf - ${some_dir} | gzip -9c | split -a4  --bytes=${split_at} - /media/ubuntu/bak/tar_gzip_std_in_out_split_n1p3_source.tgz

stamp

echo 3 > /proc/sys/vm/drop_caches

stamp

cat /media/ubuntu/bak/tar_gzip_std_in_out_split_n1p3_source.tgz* | gunzip -c | tar df - ${some_dir}

stamp

popd

exit