Automated `init`


#1

Hi,

I’ve been using Restic for a while to backup my server, specifically the contents of bound volumes for containers. I am toying with the idea of setting up a per-service backup instead of a system-wide backup so each service can be configured to backup the files that matter to that service instead of just everything which is a bit of a waste of space (for example, I want to back up databases but not database configurations since those are all generated from environment variables regardless, so if I did a restore I’d only want the data).

Another aspect of this would be automation, so I could deploy a new service (database, website, wordpress, etc) and just paste in a backup config, tweak the directories and deploy - then the backup container would run init to create a repository at my desired location and then run backups every night.

I hit a roadblock with this idea though: the repository init command can’t be automated (x) very easily. Sure I could pipe in \n separated values using a hacky bash script but I think providing flags for this would be a much better solution.

Thoughts? Are there any other workarounds for this?


#2

I automate init just fine by setting the RESTIC_PASSWORD env variable. If you look at the function calls, you’ll see that it checks for this before prompting for a password.