Generic "cmd" data source #1344
Labels
No labels
blocked
breaking
bug
data loss
design finalized
good first issue
new feature area
question / support
security
waiting for response
No milestone
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
borgmatic-collective/borgmatic#1344
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What I'd like to do and why
I use tools that write important data to stdout, i would like to take backup of those information; Ideally, I would like to back up this information without writing to a local file first (I would like to avoid command hooks to write to temporary files) I am wondering whether it would be possible to have some kind of generic data source and whether it would be useful.
E.g.:
This will make Borgmatic run those commands and use the same mechanism as the other data source to back up the resulting stream or the content of the named pipe, as long as it is being fed. What do you think of this use case, and do you think it's a good way to start experimenting with Borgmatic?
Other notes / implementation ideas
No response
generic data sourceto Generic "cmd" data sourceInteresting idea! Thanks for filing it. A few questions:
lscommand and other commands?ls?As for the configuration design, I'd actually recommend modeling it after database data sources a bit. Something like:
I don't think it should be necessary for the user to specify the pipe path. borgmatic would presumably put that in a canonical location inside the Borg archive (via a named pipe in borgmatic's runtime directory). So for instance, the example above might create files in the archive at
borgmatic/command_outputs/listingandborgmatic/command_outputs/packages.Hi Witten!
thx for your promt reply, here are a few anwser to your question:
@witten wrote in #1344 (comment):
I have different source of data, some of them can be backup-ed with usual file access, other need
docker compose runcommand to executed before and others require to requests API.Of course, I can write them to local file first and then take a backup, but I don't like the idea of potentially leaving unencrypted data behind me; So I think IPC/Pipes could be useful here. Just to let you know, here are two example of command we actually use in our backup process:
You might be wondering why we don't run a dedicated container for Borg/Bormatic. Personally, I think it's overkill. Having such a sidecar or dedicated container would mean having a ton of containers just for backups, when we could simply orchestrate the backups from the Docker host. If you want, I can probably find and share other examples, non related to docker / container limitation.
The idea is that we should be able to restore them. We don't want to let Borgmatic/Borg handle advanced use cases for restoration. In my opinion, when using this kind of composable approach, it is the responsibility of the user to handle restoring from stdin. Therefore, we only need to print or restore the backup content to stdout.
More information on my answer to the previous question :)
Yes, a lot of different command I actually use to dump data locally which are then backup-ed with Borgmatic / Borg.
Ok thanks for the information, I will dig deeper into the code and try a first implementation!
Makes sense. Thanks for explaining. Note that for the database dump in particular, you might also be able to do that with borgmatic's built-in database hooks, including the dumping from a container part.
Nope, I think that's enough to give me an idea. And running borgmatic on the host makes sense to me.
Okay, fair enough. As a future enhancement, I could see adding a configurable
restore_command:that allows the user to write a command that takes the backed up data as input. But for an initial version, maybe aborgmatic extract --stdoutflag would be sufficient. (Note that--stdoutwould have to be added.. Should be easy to do as Borg supports it already.)Great! Let me know if you have any questions or problems along the way.
One note about tarballs in particular: I don't think you'd get any of the benefits of Borg's deduplication if storing tarballs directly in an archive. It's generally preferred to store individual files that came from the tarball to get those dedup benefits. So for that particular use case, it may be preferable to volume-mount your files onto the host and then backup source directories from there. Alternatively, there's #1273, which describes a feature to natively take tarballs as a data source. As spec'd, it doesn't currently support
docker runbeforetar, but it totally could, much in the way that the existing database hooks supportdocker run.That also makes me wonder whether a "native" curl data source hook might be interesting. So maybe instead or in addition to the command data source hook described in this ticket, there could be: a tarball data source hook (#1273), a MariaDB data source hook (already exists), and a URL data source hook.
Just brainstorming here. I'm not attached to any one approach.