Table of Contents

GNU tar

compress

tar caf /path/to/archive.tgz /path/to/folder/

files in /etc

tar cvaT include.txt -f files_$(date +%Y-%m-%d).tlz

extract

tar xavf files_$(date +%Y-%m-%d).tlz -C /

transfer tar over ssh

For many small files, transferring them over ssh or even with rsync can take ages. You can use the following command to pack them into a stream and transfer them to your PC:

ssh user@source.example.com tar cf - /path/to/remote/source | tar xvf - -C /path/to/local/target

This will not create one connection for each file, but instead use a pipe through SSH to maximise I/O.

If you want to transfer files from your local PC to the remote server, you can do this the other way round:

tar cvf - /path/to/local/source | ssh user@target.example.com tar xvf - -C /path/to/remote/target

Show files in archive

tar taf files.tlz