BSDTAR vs TAR

This site pretty much sums it up really well: http://unix.stackexchange.com/questions/101561/what-are-the-differences-between-bsdtar-and-gnu-tar

Note that tar has the ability to use -a or autocompress. In some versions of bsdtar you also get -a. -a will guess the archive type of that file by the extension. As long as you use well known one such as: filename.tbz2, filename.tar.bz2, filename.tlz, filename.tar.lz, filename.tgz, filename.tar.gz,  etc…

When thinking of how to use bsdtar syntax vs tar syntax, just know bsdtar is more versatile, therefore it will work just like tar worked for you.

Creating TARS

# to tar with gzip:
tar zcvf newfile.tgz /location/archiving/up/
# to bsdtar with gzip:
bsdtar zcvf newfile.tgz /location/archiving/up/

# variations (can throw in - minus sign or not, can change directory with -C)
tar -zcvf newfile.tgz /location/archiving/up/
bsdtar zcf newfile.tgz /location/archiving/up/
tar -zcvf newfile.tgz /location/archiving/up/somefile.txt
bsdtar zcf newfile.tgz -C /location/archiving/up/ somefile.txt

# use autocompress to guess the type (when using autocompress dont state the zip type, so dont use z,j or any of those letters)
bsdtar caf newfile.tgz /location/archiving/up/
tar cavf newfile.tar.gz /location/archiving/up/
# above variations can apply

# for more variations look at man page of GnuTAR, BSDtar and etc...

Extracting TARS

# to extract tar here:
tar xf somefile.tar
bsdtar xf somefile.tar

# to extract tar.gz / tgz here:
tar zxvf somefile.tgz
bsdtar zxvf somefile.tar.gz

# autocompress (use -a, or not, its smart enough to know when to use autocompress)
tar xf somefile.tlz
bsdtar xf somefile.tgz
tar xaf somefile.tar.lz
bsdtar xaf somefile.tlz

# to decompress elsewhere use -C (make sure the directory is already made)
tar xf somefile.tar -C /dump/files/here
bsdtar xaf somefile.tgz -C /dump/files/here

 

COPYING SPARSE FILES

Why would anyone use sparse files? They are kind of like “thin” images. “thin” luns of a file based iscsi target system could be made of sparse files.

The question is how do you copy a sparse file and keep all of its properties.

To find out everything on sparse files, just read this wiki really quick:

http://en.wikipedia.org/wiki/Sparse_file

Sparse files can be handled well with BSDTAR, CP but dont use RSYNC or regular TAR (gnutar)

To CP a Sparse file:

cp --sparse=always new_file.img recovered_file.img

To Archive a file use BSDTAR: http://stackoverflow.com/questions/13252682/copying-a-1tb-sparse-file

To zip it up:

bsdtar cvfz outfilemade.tgz /location/to/big/sparse/file/onetb.dd

To extract it:

tar -xvSf outfilemade.tgz

NOTE: I know I said not use “tar” and “rsync” – however – you can use “tar” and “rsync” using thier –sparse or -S options to use the sparse feature.

Leave a Reply

Your email address will not be published. Required fields are marked *