Use the tar pipe command to copy directories

In UNIX there are lots of ways to copy an entire directory
to another place or another machine.
We describe here how to accomplish this,
with a command we named: "the tar pipe command."
Which is in fact a combination of several commands.

The reason why this command is very important!
Lays in the ability to transfer directories, and files (including hidden ones)
from partitions that are completely full, on a machine
that is running very low on memory.

Further we want to keep the modification times, the access dates
and the ownerships on the particular directories and files intact.

Two examples with the tar pipe command:

tar cpf - wap |(cd /barf; tar xvpf -)

Example 1. This command copies the entire directory wap into /barf.
By packing all the data from the directory wap into a tar file.
And immediately unpacking that tar file in the /barf directory.
So that the space needed for the copy process on the hard disk and
in the systems memory is kept to a minimum.

tar cpf - . |(cd /barf; tar xvpf -)

Example 2. This command does the same as above except it copies the
directory where you are in when you issue the command.

If you omit the 'v' from the end of the command (like: "....; tar xpf -)").
You can't see the files that are copied. This is very useful in automated copy
situations like; using this command in the crontab.

Back