Add support for multiple restic parameters
ofayans opened this issue · 4 comments
Apart from the path to backup source, restic supports a number of additional parameters, for example file/folder excluding based on a pattern. In our case the restic command looks like
restic backup --exclude="audit*" /backup-source/vault -r /backup-target/vault
We are trying to migrate to restic-robot (mainly for the prometheus' alerts sake) and have bumped into a problem that restic-robot does not support spaces in RESTIC_ARGS variable.
The code looks like this:
backup:
command: -c "RESTIC_PASSWORD=`cat /run/secrets/RESTIC_PASSWORD` restic-robot"
deploy:
mode: replicated
replicas: 1
entrypoint:
- sh
environment:
RESTIC_ARGS: --exclude='audit*' /backup-source/vault
RESTIC_REPOSITORY: /backup-target/vault
SCHEDULE: 0 15 13 * * *
And the backup fails with the following message:
{"level":"error","ts":"2020-07-20T13:15:00.011Z","caller":"restic-robot/main.go:106","msg":"failed to run backup","error":"exit status 1","output":"Fatal: nothing to backup, please specify target files/dirs\n","stacktrace":"main.(*backup).Run\n\t/restic-robot/main.go:106\ngithub.com/robfig/cron.(*Cron).runWithRecovery\n\t/go/pkg/mod/github.com/robfig/cron@v0.0.0-20180505203441-b41be1df6967/cron.go:165"}
With the argument looking like this:
RESTIC_ARGS: "/backup-source/vault --exclude=\"audit*\""
the error message changes a bit:
{"level":"error","ts":"2020-07-20T13:39:00.011Z","caller":"restic-robot/main.go:106","msg":"failed to run backup","error":"exit status 1","output":"/backup-source/vault --exclude=\"audit*\" does not exist, skipping\nFatal: all target directories/files do not exist\n","stacktrace":"main.(*backup).Run\n\t/restic-robot/main.go:106\ngithub.com/robfig/cron.(*Cron).runWithRecovery\n\t/go/pkg/mod/github.com/robfig/cron@v0.0.0-20180505203441-b41be1df6967/cron.go:165"}
Would it be possible to add support for multiple optional restic arguments?
Yes, this was an oversight. Should be simple to fix!
cmd := exec.Command("restic", "backup", "-q", "-v", b.Args)
should split by space then spread.
One possible issue with my naive approach is that you can't escape spaces in RESTIC_ARGS
.
We are trying to back up some windows servers and are very happy with restic-robot. Unfortunately we now have folders containing spaces and I can not figure out a way to correctly escape them.
Is there meanwhile a way to do so or should I open a new issue for this?
Spaces should be fine with Restic, but there may be an issue passing those from this app into the process. Worth checking in a new issue.