{"record":{"id":"2e6bccc6cb504021","repo":"siyuan-note/siyuan","slug":"export-failed-s","errorCode":null,"errorMessage":"Export failed: %s","messagePattern":"Export failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/export.go","lineNumber":752,"sourceCode":"\tzipPath = \"/export/\" + url.PathEscape(filepath.Base(zipPath))\n\treturn\n}\n\nfunc exportData(exportFolder string) (zipPath string, err error) {\n\tFlushTxQueue()\n\n\tlogging.LogInfof(\"exporting data...\")\n\n\tbaseFolderName := \"data-\" + util.CurrentTimeSecondsStr()\n\tif err = os.MkdirAll(exportFolder, 0755); err != nil {\n\t\tlogging.LogErrorf(\"create export temp folder failed: %s\", err)\n\t\treturn\n\t}\n\n\tdata := filepath.Join(util.WorkspaceDir, \"data\")\n\tif err = filelock.Copy(data, exportFolder); err != nil {\n\t\tlogging.LogErrorf(\"copy data dir from [%s] to [%s] failed: %s\", data, baseFolderName, err)\n\t\terr = fmt.Errorf(Conf.Language(14), err.Error())\n\t\treturn\n\t}\n\n\tzipPath = exportFolder + \".zip\"\n\tzip, err := gulu.Zip.Create(zipPath)\n\tif err != nil {\n\t\tlogging.LogErrorf(\"create export data zip [%s] failed: %s\", exportFolder, err)\n\t\treturn\n\t}\n\n\tzipCallback := func(filename string) {\n\t\tutil.PushEndlessProgress(Conf.language(65) + \" \" + fmt.Sprintf(Conf.language(253), filename))\n\t}\n\n\tif err = zip.AddDirectory(baseFolderName, exportFolder, zipCallback); err != nil {\n\t\tlogging.LogErrorf(\"create export data zip [%s] failed: %s\", exportFolder, err)\n\t\treturn\n\t}","sourceCodeStart":734,"sourceCodeEnd":770,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/afa823b6b4e4f183511e0bc0a3be93caa94c7c97/kernel/model/export.go#L734-L770","documentation":"Thrown by the exportData helper behind model.ExportData (POST /api/export/exportData, i.e. Settings - Export - Export Data). The kernel first duplicates the entire <workspace>/data directory into <TempDir>/export/<workspace>-<timestamp> via filelock.Copy; if that copy fails, the raw OS error is wrapped into the localized template \"Export failed: %s\" (Conf.Language(14)) and the export aborts before any zip is created. The real cause (disk full, permission denied, locked file) is the wrapped text, also logged as \"copy data dir from [...] to [...] failed\".","triggerScenarios":"POST /api/export/exportData when filelock.Copy cannot duplicate <WorkspaceDir>/data into the temp export folder: destination volume full (data is copied uncompressed before zipping), permission denied on files/subdirs, a data file held open by another process, or the workspace on an unavailable network drive.","commonSituations":"Large workspaces on a nearly full temp volume; antivirus or backup software locking .sy/asset files on Windows; a second SiYuan instance or sync job holding file locks; data dir made read-only or owned by another user.","solutions":["Read the kernel log line \"copy data dir from [...] to [...] failed: ...\" — the suffix names the offending file and errno","Free space on the volume hosting the kernel temp dir; the full data tree is duplicated uncompressed before zipping","Close other SiYuan instances, sync and backup tools; exclude workspace and temp dirs from real-time antivirus scanning","Verify the kernel process can read <workspace>/data and write <TempDir>/export (ownership, read-only flags)","Retry the export once transient locks and space issues are cleared"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"dataDir := filepath.Join(util.WorkspaceDir, \"data\")\nif info, err := os.Stat(dataDir); err != nil || !info.IsDir() {\n\treturn fmt.Errorf(\"data dir not readable: %w\", err)\n}\nprobe := filepath.Join(util.TempDir, \"export\", \".probe\")\nif err := os.WriteFile(probe, nil, 0600); err != nil {\n\treturn fmt.Errorf(\"export temp dir not writable: %w\", err)\n}\nos.Remove(probe)","typeGuard":null,"tryCatchPattern":"zipPath, err := model.ExportData()\nif err != nil {\n\t// err.Error() == \"Export failed: <cause>\" — surface the inner cause, do not retry blindly\n\tlogging.LogErrorf(\"export data failed: %s\", err)\n\treturn\n}","preventionTips":["Keep free space on the temp volume larger than the data dir","Do not run exports concurrently with sync or another export","Exclude workspace and temp dirs from antivirus real-time scanning"],"tags":["export","filesystem","disk-space","filelock","workspace"],"backgroundTag":"file-copy-failed","analyzedSha":"afa823b6b4e4f183511e0bc0a3be93caa94c7c97","analyzedAt":"2026-08-18T17:04:10.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}