{"record":{"id":"ab38d0965d965e1f","repo":"VictoriaMetrics/VictoriaMetrics","slug":"cannot-decode-snapshot-name-q-w","errorCode":null,"errorMessage":"cannot decode snapshot name %q: %w","messagePattern":"cannot decode snapshot name %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/backup/actions/backup.go","lineNumber":91,"sourceCode":"\t}\n\tif err := runBackup(src, dst, origin, concurrency); err != nil {\n\t\treturn err\n\t}\n\tif err := storeMetadata(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 storeMetadata(src *fslocal.FS, dst common.RemoteFS) error {\n\tsnapshotName := filepath.Base(src.Dir)\n\tsnapshotTime, err := snapshotutil.Time(snapshotName)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cannot decode snapshot name %q: %w\", snapshotName, err)\n\t}\n\n\td := BackupMetadata{\n\t\tCreatedAt:   snapshotTime.Format(time.RFC3339),\n\t\tCompletedAt: time.Now().Format(time.RFC3339),\n\t}\n\n\tmetadata, err := json.Marshal(d)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cannot marshal metadata: %w\", err)\n\t}\n\n\tif err := dst.CreateFile(backupnames.BackupMetadataFilename, metadata); err != nil {\n\t\treturn fmt.Errorf(\"cannot create `backup complete` file at %s: %w\", dst, err)\n\t}\n\n\treturn nil\n}","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/VictoriaMetrics/VictoriaMetrics/blob/5079fb58f1e8e62113f90c945ad71586c797d770/lib/backup/actions/backup.go#L73-L109","documentation":"storeMetadata derives the backup creation time by parsing the snapshot directory name (filepath.Base(src.Dir)) with snapshotutil.Time. VictoriaMetrics snapshot names look like `<dataDir>/<YYYY-MM-DDTHH-MM-SSZ>-<random>`. If the base directory name does not match that timestamp format, this error is returned.","triggerScenarios":"Backup.Run() with Src pointed at a directory whose basename is not a valid VM snapshot name — e.g. -snapshot.createURL not used and src is a plain directory like /var/lib/victoria-metrics-data or a manually renamed/copied snapshot dir.","commonSituations":"Pointing vmbackup at the raw storage dir instead of a snapshot; copying a snapshot to a directory with a changed name; running vmbackup for backup of non-snapshot data (explicitly unsupported: the backup works only on /snapshot/create output).","solutions":["Point Src at a real snapshot created via /snapshot/create, e.g. <storageDataPath>/snapshots/2024-01-02T15-04-05Z-<id>.","Do not rename the snapshot directory; restore the original `<timestamp>-<random>` name.","If you must back up a copy, keep the timestamp prefix format intact so snapshotutil.Time can parse it.","Check the wrapped error to see exactly which part of the name failed to decode."],"exampleFix":"// before\nsrc: /var/lib/victoria-metrics-data  // not a snapshot\n// after\nsnapshot=$(curl -XGET 'http://localhost:8428/snapshot/create' | jq -r .status.snapshot)\nvmbackup -storageDataPath=/var/lib/victoria-metrics-data -snapshotName=$snapshot -dst=s3://bucket/backup","handlingStrategy":"validation","validationCode":"name := filepath.Base(srcDir)\nif _, err := snapshotutil.Time(name); err != nil {\n    return fmt.Errorf(\"src %q is not a VM snapshot dir: %w\", srcDir, err)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always create snapshots via POST/GET /snapshot/create and pass the returned name to the backup.","Never rename snapshot directories; keep the <timestamp>-<random> format.","Validate the snapshot path exists before starting the backup job.","Remember vmbackup only works correctly on immutable snapshots, not live data dirs."],"tags":["snapshot","backup","naming","victoriametrics"],"backgroundTag":"invalid-snapshot-name","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"}