creativeprojects / resticprofile

Configuration profiles manager and scheduler for restic backup
https://creativeprojects.github.io/resticprofile/
GNU General Public License v3.0
701 stars 33 forks source link

resticprofile writes log information to stdout when using restic dump #352

Closed damoclark closed 6 months ago

damoclark commented 6 months ago

I have been dumping postgresql databases into restic using stdin.

When I attempt to restore these backups, I am using the restic dump command to send the dump file contents to standard output and piping it to pg_restore as follows:

resticprofile profile.dump --path /sql.pgdump latest /sql.pgdump | pg_restore -d dbname

But the beginning of the stanard output stream includes the following 2 lines generated by resticprofile ahead of the actual dump file contents:

2024/03/28 20:11:37 using configuration file: /etc/resticprofile/profiles.toml  
2024/03/28 20:11:37 profile 'db': starting 'dump'                               
PGDM |dbname#14.6 (Ubuntu 14.6-0ubuntu0.22.04.1)#14.6 (Ubuntu 14.6-0ubuntu0.22.0
0ENCODINENCODINGSET client_encoding = 'UTF8';
...

pg_restore is complaining about the extraneous output generated by resticprofile. I initially reported this issue, but probably not as clearly as shown above.

I propose, when using the restic dump command with resticprofile, either logging is suppressed on standard output entirely, or is instead written to standard error.

The new run hooks don't really help here when you want to send the dump output to a variety of different commands. Or in my case, I don't want to accidentally pipe the output directly to a db restore and wipe anything out.

What do you think?

jkellerer commented 6 months ago

Since handling stdout properly still needs more time, I agree that we should handle the dump command special in that we don't send anything to stdout other than the command output.