While attempting to backup WordPress, I noticed that a warning was being shown.
This warning stated that “WARNING: File name wp-content/uploads/… is too long to be save correctly in TarGz archive”.
The warning seems clear enough, but how long exactly is “too long”, and can this be improved upon?
Searching online gave a few examples of people with similar issues:
- Let us remove the warning for long file names when using tar format.
- too long to be saved correctly in TarGz archive!
The consensus on fixing this seems to be to use “zip” instead.
This is also the officially provided solution for this: WARNING: FILE NAME TOO LONG TO BE SAVED
OK, if you don’t care about any further details, this is the solution. Use “zip”.
I was interested as to the limitations of tar and zip, and if they could be improved upon, so I asked through Bard AI with an appropriate prompt shown below:
When creating a backup with tar.gz, I sometimes get a file name too long warning. It seems that only 100 character file names are supported. Is this 100-character limit something that applies to all available tar executables? Is there a way to allow longer file names? Does this limitation differ by Linux, Windows, or Linux distribution/version?
The 100-character limit on file names in tar archives is a limitation of the original tar format, which was defined in 1979. This format is still used by many tar implementations today, including the default format used by the GNU tar command.
However, there are also a number of tar implementations that support longer file names. One example is GNU tar with the
--format=gnu option. This format allows for file names of up to 255 characters.
Another option is to use a different archive format altogether. For example, the zip format supports file names of up to 65535 characters.
Whether or not you can use longer file names in a tar archive will depend on the tar implementation that you are using and the format of the archive.
To answer your specific questions:
- The 100-character limit on file names does not apply to all available tar executables. There are a number of tar implementations that support longer file names.
- There are a few ways to allow longer file names in a tar archive. One option is to use the GNU tar command with the
--format=gnuoption. Another option is to use a different archive format altogether, such as zip.
- The limitation on file name length in tar archives does not differ by Linux, Windows, or Linux distribution/version. It is a limitation of the original tar format, which is used by many tar implementations on all platforms.
If you are creating a tar archive, and you get a file name too long warning, you can try one of the following:
- Use a tar implementation that supports longer file names, such as GNU tar with the
- Use a different archive format altogether, such as zip.
- Rename the files with longer names to shorter names.
- Split the files with longer names into multiple files with shorter names.
- tar file name character limit is 100 by default
- –format=gnu option makes the file name character limit 255
- zip file name character limit is 65535
100 characters is definitely very small, so is an issue.