I had to figure this out myself and thought I’d share what I’m doing.
Make an archive:
tar -cf TargetFile.tar Foldername/
The c flag tells it to create an archive.
The f flag tells it that you’re making an archive from files.
Compress it:
gzip TargetFile.tar
And the resulting file is:
TargetFile.tar.gz
If you want real good compression and so on, you’ll need to play around with the flags, but this will do when you simply need to transfer quickly. I tested on a big folder of about 250MB, the .tar file was 285MB and the resulting .tar.gz file was 211MB.
Compressed files can be restored to their original form using gzip -d or gunzip or zcat.
LikeLike
Untar:
tar xvf something.tar
LikeLike
I like the following using the -C parameter. This creates relative directories, so if you untar on a different box, you are not forced to untar to the exact same full directory from root.
(Especially if you do not have permissions to access that dir on the new box! A bit of a neccessity then 🙂 )
tar cvf $BASE_DIR/mynewtar.tar -C $BASE_DIR online backup 2>dev/null
LikeLike