admin:linux:cli:tar

GNU tar

tar caf /path/to/archive.tgz /path/to/folder/
tar cvaT include.txt -f files_$(date +%Y-%m-%d).tlz
tar xavf files_$(date +%Y-%m-%d).tlz -C /

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
tar taf files.tlz
  • Last modified: 2020-12-21 05:45