Skip to content

Feature: Take command output as stdin for restic#98

Merged
creativeprojects merged 2 commits intocreativeprojects:masterfrom
jkellerer:ft-stream-source
Apr 25, 2022
Merged

Feature: Take command output as stdin for restic#98
creativeprojects merged 2 commits intocreativeprojects:masterfrom
jkellerer:ft-stream-source

Conversation

@jkellerer
Copy link
Collaborator

@jkellerer jkellerer commented Mar 12, 2022

PR introducing "stdin-command" to allow scheduling backups of streams (e.g. mysql-dump) without requiring temporary storage.

Usage:

my-profile:
  backup:
    schedule: 'hourly'
    stdin-filename: mysql-dump.sql
    stdin-command:
      - mysqldump --order-by-primary --host=db-host --user=db-user --password=db-pw db-name

@jkellerer jkellerer marked this pull request as draft March 12, 2022 21:26
@jkellerer jkellerer force-pushed the ft-stream-source branch 2 times, most recently from 70041d8 to ec7f574 Compare March 12, 2022 22:08
@codecov
Copy link

codecov bot commented Mar 12, 2022

Codecov Report

Merging #98 (f36cbd2) into master (d46265d) will increase coverage by 0.54%.
The diff coverage is 86.79%.

@@            Coverage Diff             @@
##           master      #98      +/-   ##
==========================================
+ Coverage   65.18%   65.73%   +0.54%     
==========================================
  Files          65       66       +1     
  Lines        6495     6636     +141     
==========================================
+ Hits         4234     4362     +128     
- Misses       2062     2070       +8     
- Partials      199      204       +5     
Impacted Files Coverage Δ
shell/command.go 64.42% <45.45%> (-2.00%) ⬇️
config/profile.go 93.40% <57.14%> (-1.01%) ⬇️
shell/command_windows.go 66.66% <66.66%> (-33.34%) ⬇️
wrapper.go 79.86% <77.77%> (+0.58%) ⬆️
wrapper_streamsource.go 94.69% <94.69%> (ø)
config/config.go 72.93% <100.00%> (ø)
shell_command.go 86.95% <100.00%> (+6.52%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d46265d...f36cbd2. Read the comment docs.

@jkellerer jkellerer force-pushed the ft-stream-source branch 3 times, most recently from dd254e2 to 29b9e2a Compare March 12, 2022 22:46
@jkellerer jkellerer changed the title Feature: Take command output as stdin for resitc Feature: Take command output as stdin for restic Mar 12, 2022
@jkellerer jkellerer force-pushed the ft-stream-source branch 2 times, most recently from 858203b to 6cb5de7 Compare March 15, 2022 22:45
@jkellerer jkellerer marked this pull request as ready for review April 9, 2022 19:27
@jkellerer jkellerer added the enhancement New feature or request label Apr 9, 2022
@creativeprojects
Copy link
Owner

I like it.

I was using a temp file, but that will make my config simpler 😄

    [azure.backup]
    limit-upload = 500
    exclude = [ "azure-backup.log" ]
    exclude-file = [ "root-excludes", "excludes" ]
    exclude-caches = true
    tag = [ "mysql", "git" ]
    run-before = [
        "rm -f /tmp/mysqldump.gz",
        "mysqldump -u{{ mysql_backup_user }} -p{{ mysql_backup_password }} --opt zabbix | gzip > /tmp/mysqldump.gz"
    ]
    source = [ "/tmp/mysqldump.gz", "/git/creativeprojects" ]
    run-after = [
        "rm -f /tmp/mysqldump.gz"
    ]
    schedule = "04:18"
    schedule-permission = "system"
    schedule-log = "azure-backup.log"

Copy link
Owner

@creativeprojects creativeprojects left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is a bit annoying, but I think we have to synchronise the stdin goroutine with the command runner during a --dry-run

@creativeprojects creativeprojects added this to the v0.17.0 milestone Apr 20, 2022
Copy link
Owner

@creativeprojects creativeprojects left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That'd be nice to find a better way to stop on Windows but I'm not even sure we can do it.
Apart from that, it's all good for me, nice job 😊

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 5 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@creativeprojects creativeprojects merged commit 8cef157 into creativeprojects:master Apr 25, 2022
@coderabbitai coderabbitai bot mentioned this pull request Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants