Ffile2fix
Sign in Get started

Fix "tar: Unexpected EOF in archive"

tar: Unexpected EOF in archive
tar: Error is not recoverable: exiting now

tar reached the end of the file before the archive was complete, so the file is truncated. The fix is to get a complete copy; if none exists, you can still extract every file stored before the cut-off point.

Also appears as: gzip: stdin: unexpected end of file tar: Unexpected EOF in archive · tar: Unexpected EOF in archive tar: rmtlseek not stopped at a record boundary · tar: Child returned status 1 tar: Error is not recoverable: exiting now · xz: (stdin): Unexpected end of input

Common causes

  • An interrupted download, scp or rsync transfer
  • The backup job ran out of disk space or hit a quota while writing the archive
  • The archive was copied or downloaded while it was still being created
  • A web server or proxy timed out and closed a large download early
  • A size limit on the upload (PHP upload_max_filesize, panel file manager) cut the file
  • Storage errors or a full /tmp during creation

How to fix it

  1. Confirm the file is truncated. Compare ls -l backup.tar.gz with the source size and run sha256sum on both. For compressed archives gzip -t backup.tar.gz (or xz -t) reports 'unexpected end of file' when data is missing.
  2. Copy it again. Re-download with curl -fL -C - -o backup.tar.gz URL to resume, or rsync --partial --progress for server-to-server copies. Verify the checksum before extracting.
  3. Check disk space on the source. If the archive was created by a backup script, run df -h where it was written. Fix the space problem and recreate the archive, otherwise every copy will be truncated.
  4. Salvage what is readable. Extracting still writes every file before the break: tar -xzvf backup.tar.gz runs until the error. Note the last file name printed, since that one is likely incomplete.
  5. Decompress first for stubborn cases. Run gzip -dc backup.tar.gz > backup.tar (it writes what it can before failing), then tar -xvf backup.tar --ignore-zeros to extract the readable members.

Terminal

gzip -t backup.tar.gz && echo OK
sha256sum backup.tar.gz
curl -fL -C - -o backup.tar.gz https://example.com/backup.tar.gz

# salvage readable files from a truncated archive
gzip -dc backup.tar.gz > partial.tar
tar -xvf partial.tar --ignore-zeros

How to stop it happening again

  • Write a checksum file next to every backup and verify it after each transfer
  • Check free disk space before a backup job starts
  • Create archives under a temporary name and rename them only when finished
  • Run gzip -t or tar -tzf on new backups as part of the job

File2fix tools for this error

Frequently asked questions

Can I repair a truncated tar.gz?

You cannot recreate missing bytes, but you can extract everything stored before the truncation. Files after the cut-off point are gone unless you have another copy.

Why do I also see 'gzip: stdin: unexpected end of file'?

For .tar.gz files gzip decompresses the stream first and hits the end early, then tar reports its own error. Both messages point to the same truncated file.

Is it the tar version?

Almost never. Unexpected EOF means the data ends early. A different tar build will stop at the same place.