[kwlug-disc] tar question regarding leading "/"
Ronald Barnes
ron at ronaldbarnes.ca
Tue Oct 3 15:08:56 EDT 2023
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
More information about the kwlug-disc
mailing list