Don't want "tar: Removing leading `/' from " message

From Andreida
Revision as of 16:39, 10 June 2023 by Andreas (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

info

  1. This is neither an error nor a warning, this is an information.
  2. You do not want to change the behavior, because this is good, you do not want absolute paths in your archive.

What you normally want it to just not see this information - after you understood it - because it can, no it WILL hinder the reading of log files or trigger the sending of mails.

What you do is pretty simple.

Original example still with the "fix" and the info about it

Imagine you have the following command:

tar zchf /var/db-dump/your-name-1-images.tgz /var/www/wiki.your-wiki-1/images/

This will give you the information

tar: Removing leading `/' from member names
tar: Removing leading `/' from hard link targets

or something like that. It is good to know that this is happening but you now really don't want to see these lines.

Solution

You just use the "-C <directory> option to first switch directories and then use tar with a relative path:

 tar zchf /var/db-dump/your-name-1-images.tgz -C / var/www/wiki.your-wiki-1/images/

And nope, I am not fucking with you. Two characters and a space and you are good to go. :-)


Btw, we are NOT supressing the information or something, we change what we do so there is no need to "fix" the archive and remove leading slashes.