k8up-io / wrestic

Restic Backup Kubernetes and OpenShift Wrapper - Part of K8up
BSD 3-Clause "New" or "Revised" License
16 stars 3 forks source link

[Bug] Panic in `linkRestorePaths` during restore of stdin backup #55

Closed srueg closed 2 years ago

srueg commented 3 years ago

Describe the bug

Wrestic tries to split a path by parts which don't exist. https://github.com/vshn/wrestic/blob/master/restic/restore.go#L167

Additional context

The backup was made from stdin and therefore the path doesn't contain any parts: /0c517755-ae0b-***-***-894d0e22fa07-mariadb.sql

Logs

If applicable, add logs to help explain your problem.

panic: runtime error: slice bounds out of range [:3] with capacity 2
goroutine 1 [running]:
github.com/vshn/wrestic/restic.(*Restic).linkRestorePaths(0xc0002bb260, 0xc0006142c0, 0x40, 0x33b2b2fd, 0xed7b3c8d8, 0x0, 0xc000614280, 0x40, 0xc000616280, 0x1, ...)
    /app/restic/restore.go:167 +0x385
github.com/vshn/wrestic/restic.(*Restic).folderRestore(0xc0002bb260, 0xc00004800c, 0x8, 0xc0006142c0, 0x40, 0x33b2b2fd, 0xed7b3c8d8, 0x0, 0xc000614280, 0x40, ...)
    /app/restic/restore.go:125 +0x119
github.com/vshn/wrestic/restic.(*Restic).Restore(0xc0002bb260, 0x0, 0x0, 0x7fff96b7682f, 0x6, 0xc00004800c, 0x8, 0x0, 0x0, 0x0, ...)
    /app/restic/restore.go:83 +0x4a7
main.run(0xc0002bb260, 0x12a66a0, 0xc0002f4840, 0xc0002f4840, 0x1283000)
    /app/cmd/wrestic/main.go:120 +0xc85
main.main()
    /app/cmd/wrestic/main.go:73 +0x565

Expected behavior

If the path doesn't contain any parts, don't try to trim it.

To Reproduce

Steps to reproduce the behavior:

  1. Create a stdin backup
  2. Try to restore the backup
Kidswiss commented 3 years ago

The backup was made from stdin and therefore the path doesn't contain any parts: /0c517755-ae0b---894d0e22fa07-mariadb.sql

Oh, yeah that's a use case currently not tested or supported. The PVC restore implicitly expects that the backup is actually from a PVC.

Kidswiss commented 2 years ago

PLEASE NOTE: THIS REPOSITORY HAS BEEN ARCHIVED.

wrestic has been merged into K8up 2.0 and is available as k8up restic command.