nils-werner / crestic

Configurable Restic Wrapper
https://nils-werner.github.io/crestic/
MIT License
106 stars 10 forks source link

[idea] Allow "stdin mode" #18

Closed fancsali closed 3 years ago

fancsali commented 3 years ago

One of the very nice, and convenient features of restic is, that one can do a backup for the output of a command, like:

mysql-dump --all-databases | restic backup --stdin --stdin-filename mysql-all.sql

(See https://restic.readthedocs.io/en/latest/040_backup.html#reading-data-from-stdin)

It would be brilliant, if crestic would be able to build such commands as well.

nils-werner commented 3 years ago

What have you tried so far? Given the correct config file (no arguments that conflict with --stdin) I believe it should just work...

fancsali commented 3 years ago

Indeed, it doesn't. What I meant, is that it might be a bit error-prone, to configure things in two places:

Once in /etc/crestic.cfg:

[mysql]
repo: ...
keep-daily: ...
...

And then a custom systemd unit for this.

So, I had the idea, to provide a method of inserting something at the very beginning of the assembled command line.

nils-werner commented 3 years ago

Hm, can you please give a reproducible example and the error message you are seeing?

nils-werner commented 3 years ago

So, I had the idea, to provide a method of inserting something at the very beginning of the assembled command line.

Or did you mean you want the mysql-dump --all-databases | part created by crestic?

fancsali commented 3 years ago

So, I had the idea, to provide a method of inserting something at the very beginning of the assembled command line.

Or did you mean you want the mysql-dump --all-databases | part created by crestic?

Well, "want" is a very strong word here, but yes, I am proposing that might be a nice feature... 😉

nils-werner commented 3 years ago

Ah, I see. That is a shell feature and therefore probably out of scope for crestic, when all you need to do is

mysql-dump --all-databases | crestic mysql backup

with a config file

[mysql.backup]
stdin:
stdin-filename: mysql-all.sql
fancsali commented 3 years ago

Well, it might be out of scope; it just occured to me.

A solution around it is to make 2 systemd templates, one for when there's a command to pipe, and one for "standard" invocation.