Pre/post run script in docker container?

I’m probably over-thinking this.

I have duplicati running in a container. I have plex (as an example) running in a container. I want to backup plex, including the database. I should stop plex prior to running the backup, and then spool it back up again.

I thought it would be as simple as making a bash script on my host accessible to duplicate and Bob would be my proverbial uncle, but it didn’t work. I presume that’s because even though the script is on the host, it is being run with the commands available to duplicati, which doesn’t include the necessary docker commands. Is that right? Is there a way around this? Perhaps it is easier to not run duplicati in a docker, but I like the compartmentalization.

Yes, that’s right. In addition to needing the commands in the Duplicati docker container, it would also need access to the docker engine on the host (by mapping /var/run/docker.sock to the Duplicati container).

Someone else was asking about this and may have attempted putting docker binaries in the Duplicati container. Others decided to take a simpler approach and just schedule the container shutdown on the host and schedule it to line up with the Duplicati backup schedules.

With all due respect, I’m going to suggest isn’t simpler. Or, at least, it isn’t appropriate. A primary feature of a backup should be to get back to baseline quickly and easily, and being cognizant that this may be done many years after being setup.

So for one, Duplicati really should be able to backup and restore its own settings automatically. At least I can export the configurations and store then safely, but couldn’t I just enter my password and have them (along with the server info) retrieved? That could be a nice premium feature.

For two, there shouldn’t be any reliance on a task like a cronjob which itself can’t be backed up and restored. Avoiding reliance on Cron was actually a primary motivator for finding and switching to Duplicati. I was using rdiff-backup but the issue was having to recreate so much configuration exactly after a loss.

Recovery should be a matter of downloading an app and entering a password and nothing more, in my opinion. And recovery should result in the person being back how they were, including ready to backup again, without having to re-learn all the steps.

I’m starting to think Docker just isn’t the way to go for backup. Unless… hmm… can docker-compose include arbitrary binaries? I’ll look into that.

Fair enough… it was just an idea of an alternate approach. I actually agree with you that it is better for the backup application to do everything itself. It’s just complicated when you isolate Duplicati in a docker container. It’s still possible, but you’ll need to do those extra steps.

I know how some backup applications do that, but they have a server side component. Duplicati by design has no such server side. This is a good thing in many ways, but it does have downsides. You are required to manage the backups of the Duplicati config yourself.

One idea for enhancement is to store configuration on the back end, but it only helps a little. You’d still have to provide things like back end protocol, host, path, credentials, and also encryption key before the configuration could be restored.

For now I think the best approach is what you’re doing - export the configurations and store them in a safe place. It’s what I do.

Good luck! If you manage to get the docker binaries included and are able to control other containers on the host, please post a followup. Your instructions may help others who want to do the same.

Of course I could be missing something but we’re just talking about small text files needing to be stored. I would think it would be a small thing (and a nice reward for supporters) to have an option to automatically store config files, etc, on Duplicati’s servers so the user just needs to remember their username/password.

Meanwhile, I’m making use of LastPass’s Secure Notes feature, which (I didn’t know before all this) allows files to be attached. So I export my config files, zip them up, and add them to the secure note which also contains my encryption phrase and a set of instructions to remind myself in X years what’s what! That’s fine, but I have delete and re-attach those files anytime I tweak something. Not ideal, but workable.

Thanks for your replies. I’ll see here I get with attaching binaries, but I’ll likely resort to removing duplicate from my docker setup and run it natively instead.

Duplicati has no server side piece. There is a remote storage side, which is perhaps what you mean. But that’s what I was talking about in my previous post - you’d need to track several pieces of info to get access to a config file stored in your remote storage. Maybe it should still be done though!

That’s a great idea about storing the configs in LastPass. I use Bitwarden and it has as a similar “secure notes” feature.

Of course Duplicati has servers… or at least access to those which utilizes their domain name. We’re there right now :slight_smile:

It wouldn’t take much, and my whole point was what it could be a premium feature. So no, I didn’t mean the remote storage, I meant a tiny slice of a $4/mo webserver to host some text files (and a bunch of programming to integrate it lol)