[kwlug-disc] tar question regarding leading "/"

Jason Eckert jason.eckert at gmail.com
Tue Oct 3 15:24:11 EDT 2023


You could always use the -P option to force the use of absolute pathnames
when creating the tar archive (you could always restore relative to the /
path if you like too).

On Tue, 3 Oct 2023 at 15:11, Ronald Barnes <ron at ronaldbarnes.ca> wrote:

>
> I'm having issues with `tar` that I don't understand.
>
>
> I'm trying to backup several files / folders of mailman resources, but
> am getting errors on *one* of them.
>
> (I hope the following formatting is legible.)
>
>
> The 2 sample files, which exist:
>
> # ls -l /etc/apache2/sites-available/mailman2.conf
> /lib/systemd/system/mailman.service
> -rw-r--r-- 1 root root 4793 2021-05-02 14:00
> /etc/apache2/sites-available/mailman2.conf
> -rw-r--r-- 1 root root  401 2018-06-23 09:14
> /lib/systemd/system/mailman.service
>
>
> The tar command changes directory to "/" then runs, so path names do not
> get leading "/" stripped and the associated message doesn't appear:
>
> # tar -v  --directory=/ -pjcf /tmp/mailman-test.tar
> lib/systemd/system/mailman*  etc/apache2/sites-available/mailman2.conf
>
> The error message:
>
> tar: lib/systemd/system/mailman*: Cannot stat: No such file or directory
> etc/apache2/sites-available/mailman2.conf
> tar: Exiting with failure status due to previous errors
>
>
> It worked on the apache file, not the systemd file.
>
>
> If I run it with a leading "/" on the systemd file, this is the output:
>
> # tar -v  --directory=/ -pjcf /tmp/mailman-test.tar
> /lib/systemd/system/mailman*  etc/apache2/sites-available/mailman2.conf
> tar: Removing leading `/' from member names
> /lib/systemd/system/mailman.service
> tar: Removing leading `/' from hard link targets
> etc/apache2/sites-available/mailman2.conf
>
>
> So... now it removes the leading "/" and archives the systemd unit file.
>
>
> What's going on?
>
>
>
> Thanks!
>
> rb
>
> _______________________________________________
> kwlug-disc mailing list
> To unsubscribe, send an email to kwlug-disc-leave at kwlug.org
> with the subject "unsubscribe", or email
> kwlug-disc-owner at kwlug.org to contact a human being.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://kwlug.org/pipermail/kwlug-disc_kwlug.org/attachments/20231003/386246bd/attachment.htm>


More information about the kwlug-disc mailing list