caddyserver/caddy · error

writing archive: %v

Error message

writing archive: %v

What it means

During 'caddy storage export', tar.Writer.WriteHeader failed for a storage key — the writer could not emit the header for the next archive entry. With a file-backed writer this almost always means the underlying file write failed: disk full, quota exceeded, or the file closed prematurely.

Source

Thrown at cmd/storagefuncs.go:219

		if info.IsTerminal {
			v, err := stor.Load(ctx, k)
			if err != nil {
				if errors.Is(err, fs.ErrNotExist) {
					caddy.Log().Warn(fmt.Sprintf("key: %s removed while export is in-progress", k))
					continue
				}
				return caddy.ExitCodeFailedQuit, err
			}

			hdr := &tar.Header{
				Name:    k,
				Mode:    0o600,
				Size:    int64(len(v)),
				ModTime: info.Modified,
			}

			if err = tw.WriteHeader(hdr); err != nil {
				return caddy.ExitCodeFailedQuit, fmt.Errorf("writing archive: %v", err)
			}
			if _, err = tw.Write(v); err != nil {
				return caddy.ExitCodeFailedQuit, fmt.Errorf("writing archive: %v", err)
			}
		}
	}
	if err = tw.Close(); err != nil {
		return caddy.ExitCodeFailedQuit, fmt.Errorf("writing archive: %v", err)
	}

	return caddy.ExitCodeSuccess, nil
}

View on GitHub (pinned to 50e54ee279)

Solutions

  1. Check space: df -h <output-path> and free space or pick a larger target
  2. If piping to another command, ensure it reads until EOF (e.g. gzip without -q early exit, ssh without timeout)
  3. Retry the export after fixing storage; partial output file can be deleted
  4. For quota-managed filesystems, raise the quota or export elsewhere
Defensive patterns

Strategy: validation

Validate before calling

OUT=/var/backups/caddy/storage.tar
mkdir -p "$(dirname "$OUT")"
df -h "$(dirname "$OUT")"   # confirm free space larger than your cert storage

Prevention

When it happens

Trigger: Output filesystem filling up mid-export (cert storage can be large); quota hit; the output file on a network mount that dropped; writing to '-' when the reading side of the pipe closed early (EPIPE/ErrClosed).

Common situations: Exporting to a small /tmp or tmpfs that fills; piping to a consumer (gzip, ssh) that exited before the export finished; NFS hiccup.

Related errors


AI-assisted analysis of caddyserver/caddy@50e54ee279 (2026-08-15). Data as JSON: /api/errors/2f1333fd489d905d. Report an issue: GitHub.