{"record":{"id":"f34ab905fc1ee471","repo":"VictoriaMetrics/VictoriaMetrics","slug":"cannot-read-metadata-from-s-w","errorCode":null,"errorMessage":"cannot read metadata from %s: %w","messagePattern":"cannot read metadata from (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/backup/actions/copy.go","lineNumber":54,"sourceCode":"\t\treturn fmt.Errorf(\"cannot delete `backup complete` file at %s: %w\", dst, err)\n\t}\n\tif err := runCopy(src, dst, concurrency); err != nil {\n\t\treturn err\n\t}\n\tif err := copyMetadata(src, dst); err != nil {\n\t\treturn fmt.Errorf(\"cannot store backup metadata: %w\", err)\n\t}\n\tif err := dst.CreateFile(backupnames.BackupCompleteFilename, nil); err != nil {\n\t\treturn fmt.Errorf(\"cannot create `backup complete` file at %s: %w\", dst, err)\n\t}\n\n\treturn nil\n}\n\nfunc copyMetadata(src common.RemoteFS, dst common.RemoteFS) error {\n\tmetadata, err := src.ReadFile(backupnames.BackupMetadataFilename)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cannot read metadata from %s: %w\", src, err)\n\t}\n\tif err := dst.CreateFile(backupnames.BackupMetadataFilename, metadata); err != nil {\n\t\treturn fmt.Errorf(\"cannot create metadata at %s: %w\", dst, err)\n\t}\n\treturn nil\n}\n\nfunc runCopy(src common.OriginFS, dst common.RemoteFS, concurrency int) error {\n\tstartTime := time.Now()\n\n\tlogger.Infof(\"starting remote backup copy from %s to %s\", src, dst)\n\n\tsrcParts, err := src.ListParts()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cannot list src parts: %w\", err)\n\t}\n\tlogger.Infof(\"obtained %d parts from src %s\", len(srcParts), src)\n","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/VictoriaMetrics/VictoriaMetrics/blob/5079fb58f1e8e62113f90c945ad71586c797d770/lib/backup/actions/copy.go#L36-L72","documentation":"copyMetadata reads BackupMetadataFilename from the source remote FS before writing it to the destination. If that read fails, the copy is aborted with this error naming the source location. Without metadata, restoring the copied backup would lack required backup description, so the operation refuses to continue.","triggerScenarios":"RemoteBackupCopy.Run -> copyMetadata when src.ReadFile(backupnames.BackupMetadataFilename) returns an error: file missing in source, read access denied, or storage API failure.","commonSituations":"Backing up from a legacy/old backup that predates metadata files; source bucket credentials lacking read access; source backup truncated or manually deleted metadata object.","solutions":["Confirm the source backup actually contains the metadata file (check bucket listing for the metadata object name)","Check read permissions on the source bucket/prefix for the configured credentials","If the source is a legacy backup without metadata, re-create the backup from the database instead of copying it","Inspect the wrapped (%w) error to distinguish NotFound vs access-denied vs transient API failure"],"exampleFix":"// before: copy blindly\nerr := copyAction.Run()\n// after: verify metadata exists first\nok, _ := src.HasFile(backupnames.BackupMetadataFilename)\nif !ok {\n    log.Fatal(\"source backup has no metadata file; cannot copy\")\n}\nerr = copyAction.Run()","handlingStrategy":"validation","validationCode":"ok, err := src.HasFile(backupnames.BackupMetadataFilename)\nif err != nil {\n    return fmt.Errorf(\"cannot probe source metadata: %w\", err)\n}\nif !ok {\n    return errors.New(\"source backup has no metadata file; re-create the backup\")\n}","typeGuard":null,"tryCatchPattern":"if err := copyAction.Run(); err != nil {\n    if strings.Contains(err.Error(), \"cannot read metadata\") {\n        log.Printf(\"source metadata unreadable: %v\", err) // check perms / legacy backup\n    }\n}","preventionTips":["Confirm source backups are created by a version that writes metadata","Grant read/list permission on the source bucket/prefix","Never manually delete metadata objects from source backups"],"tags":["backup","metadata","remote-fs","read-failure"],"backgroundTag":"backup-metadata-missing","analyzedSha":"5079fb58f1e8e62113f90c945ad71586c797d770","analyzedAt":"2026-09-03T18:10:26.153Z","contentChangedAt":"2026-09-03T18:10:26.153Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}