Technical article 105546

tar(C) cannot save files with a path longer than 100 characters.

OpenServer 5.0.0OpenServer 5.0.2OpenServer 5.0.4OpenServer 5.0.5

Written · Last revised

Problem

the tar(C) utility cannot back up a file with a pathname longer
than 100 characters.  Attempting to create a tar archive with
input files having pathnames exceeding 100 characters results
in an error:
tar: <long pathname> : pathname too long

Solution

One possible workaround is to create symbolic links for a portion
of the pathname so that tar actually sees less than 100 total
characters in the full path.  For example, to include this file
in the archive:

/<30 char dir name>/<40 char dir name>/<40 char filename>

you can create a symbolic link in the root directory:

ln -s /<30 char dir name>/<40 char dir name> /short_name

This effectively reduces the number of characters seen by tar in the first two pathname components from 72 to 11.

Thus, while in the root directory, you can create an archive of all files (including the 40-character long filename) in the 72-character long pathname by simply specifying the symlink instead:

tar cvLf archive short_name

Note the use of the "L" option to tar, which specifies to tar to actually follow the symlink to point to the actual files that are intended to be archived; by default, tar simply backs up the symlink without following it to the file actually pointed to. See the tar(C) man page for more details.

NOTE:     This issue is not known to apply to other backup utilities, such
          as cpio(C).  Hence, another workaround is to use cpio or some
          other utility to create the desired backup archives.

From the Xinuos technical article database, record 105546. Reproduced with permission. The original is at www.sco.com/ta/105546, which is reachable but blocked from search engines. Xinuos marks this article against a retired product line. That refers to the product’s lifecycle, not to whether the advice still works — plenty of it still applies to running systems.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.