{"record":{"id":"2f1333fd489d905d","repo":"caddyserver/caddy","slug":"writing-archive-v","errorCode":null,"errorMessage":"writing archive: %v","messagePattern":"writing archive: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/storagefuncs.go","lineNumber":219,"sourceCode":"\t\tif info.IsTerminal {\n\t\t\tv, err := stor.Load(ctx, k)\n\t\t\tif err != nil {\n\t\t\t\tif errors.Is(err, fs.ErrNotExist) {\n\t\t\t\t\tcaddy.Log().Warn(fmt.Sprintf(\"key: %s removed while export is in-progress\", k))\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\treturn caddy.ExitCodeFailedQuit, err\n\t\t\t}\n\n\t\t\thdr := &tar.Header{\n\t\t\t\tName:    k,\n\t\t\t\tMode:    0o600,\n\t\t\t\tSize:    int64(len(v)),\n\t\t\t\tModTime: info.Modified,\n\t\t\t}\n\n\t\t\tif err = tw.WriteHeader(hdr); err != nil {\n\t\t\t\treturn caddy.ExitCodeFailedQuit, fmt.Errorf(\"writing archive: %v\", err)\n\t\t\t}\n\t\t\tif _, err = tw.Write(v); err != nil {\n\t\t\t\treturn caddy.ExitCodeFailedQuit, fmt.Errorf(\"writing archive: %v\", err)\n\t\t\t}\n\t\t}\n\t}\n\tif err = tw.Close(); err != nil {\n\t\treturn caddy.ExitCodeFailedQuit, fmt.Errorf(\"writing archive: %v\", err)\n\t}\n\n\treturn caddy.ExitCodeSuccess, nil\n}\n","sourceCodeStart":201,"sourceCodeEnd":232,"githubUrl":"https://github.com/caddyserver/caddy/blob/50e54ee279aa1e504fe218ca49ab6ae16c100410/cmd/storagefuncs.go#L201-L232","documentation":"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.","triggerScenarios":"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).","commonSituations":"Exporting to a small /tmp or tmpfs that fills; piping to a consumer (gzip, ssh) that exited before the export finished; NFS hiccup.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"OUT=/var/backups/caddy/storage.tar\nmkdir -p \"$(dirname \"$OUT\")\"\ndf -h \"$(dirname \"$OUT\")\"   # confirm free space larger than your cert storage","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["storage","export","tar","disk"],"backgroundTag":null,"analyzedSha":"50e54ee279aa1e504fe218ca49ab6ae16c100410","analyzedAt":"2026-08-15T09:20:21.641Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}