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
- Check space: df -h <output-path> and free space or pick a larger target
- If piping to another command, ensure it reads until EOF (e.g. gzip without -q early exit, ssh without timeout)
- Retry the export after fixing storage; partial output file can be deleted
- 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
- Ensure output free space exceeds total storage size (check with du on the storage dir)
- Keep pipe consumers alive for the whole export when using --output -
- Check quota limits on NFS/home filesystems used for exports
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
- reading archive: %v
- opening output file: %v
- WebSocket connections aren't allowed.
- Disabling same-origin restrictions is not allowed.
- Buggy browser is sending null Origin header.
AI-assisted analysis of caddyserver/caddy@50e54ee279 (2026-08-15).
Data as JSON: /api/errors/2f1333fd489d905d.
Report an issue: GitHub.