20.10 Avoid Absolute Paths with tarOne problem with most versions of tar : it can't change a file's pathname when restoring. Let's say that you put your home directory in an archive (tape or otherwise) with a command like this:
%
What will these files be named when you restore them, either on your
own system or on some other system? They will have
exactly
the
same pathnames that they had originally. So if
/home/mike
already exists, it will be destroyed. There's no way to
tell
tar
that it should be careful about overwriting files;
there's no way to tell
tar
to put the files in some other
directory when it takes them off the tape, etc. If you use
absolute pathnames (
14.2
)
when you create a tape, you're stuck. If you use
relative paths (
14.2
)
(for example, This means that you should:
Rather than giving a command like
% Or, even more elegant, use -C on the tar command line:
% This command tells tar to cd to the directory /home/mike before creating the archive. If you want to archive several directories, you can use several -C options:
% This command archives mike 's docs directory and susan 's test directory. - |
|