juicedata/juicefs · error
failed to create plain backup %s: %w
Error message
failed to create plain backup %s: %w
What it means
When converting a (possibly encrypted/binary) backup to plain JSON, `convert` creates the destination plain-backup file with os.Create(nPath). If creation fails, the error is wrapped as `failed to create plain backup <nPath>: <error>`. This is a local filesystem write failure before any data is copied.
Source
Thrown at cmd/load.go:178
if key == "" && !isCompress {
return path, nil
}
nPath := path[:strings.LastIndex(path, ".")]
if utils.Exists(nPath) {
logger.Infof("plain backup %q already exists, skip conversion", nPath)
return nPath, nil
}
r, err := open(path, key, algo)
if err != nil {
return "", err
}
defer r.Close()
w, err := os.Create(nPath)
if err != nil {
return "", fmt.Errorf("failed to create plain backup %s: %w", nPath, err)
}
defer w.Close()
if _, err = io.Copy(w, r); err != nil {
return "", fmt.Errorf("failed to convert %s to %s: %w", path, nPath, err)
}
logger.Infof("converted backup %q to %q", path, nPath)
return nPath, nil
}
func load(ctx *cli.Context) error {
setup0(ctx, 1, 2)
key, algo := ctx.String("encrypt-rsa-key"), ctx.String("encrypt-algo")
src := ctx.Args().Get(1)
var err error
if ctx.Bool("binary") {
if ctx.Bool("stat") {View on GitHub (pinned to c9a67b23e8)
Solutions
- Check that the destination directory exists and is writable (`ls -ld $(dirname <nPath>)`)
- Free disk space if the filesystem is full (df -h)
- Run as a user with write permission on the destination, or pick another output path
- Check dmesg/audit logs for read-only remounts or LSM denials
Example fix
// before juicefs load meta.sqlite3 backup.json --output /root/jfs/converted.json # non-root user // after juicefs load meta.sqlite3 backup.json --output ~/converted.json
Defensive patterns
Strategy: validation
Validate before calling
dir := filepath.Dir(nPath)
if fi, err := os.Stat(dir); err != nil || !fi.IsDir() {
return fmt.Errorf("output dir missing: %s", dir)
}
if err := unix.Access(dir, unix.W_OK); err != nil {
return fmt.Errorf("output dir not writable: %s", dir)
} Try / catch
if err := convert(path, nPath); err != nil {
var pe *fs.PathError
if strings.Contains(err.Error(), "failed to create plain backup") {
log.Fatalf("fix destination dir/permissions: %v", err)
}
} Prevention
- Pre-check destination disk space and writability before conversion
- Write outputs to a dedicated writable directory owned by the running user
- Watch for read-only remounts after disk errors
When it happens
Trigger: os.Create fails because the target directory does not exist, the path is a directory, the disk is full, or the process lacks write permission on the destination (e.g. / or a read-only mount as nPath's directory).
Common situations: Redirecting converted output into a read-only volume; SELinux/AppArmor denials; running as non-root while writing to /var/lib/juicefs; typo'd directory in the target path.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
- failed to open file %s: %w
- name is required
- Could not get a FileSystem
- Cannot get file system.
- Cannot create file system.
AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06).
Data as JSON: /api/errors/de8fe2601df14a64.
Report an issue: GitHub.