kbond / ZenstruckBackupBundle

Symfony2 Bundle that wraps backup commands
http://zenstruck.com/projects/ZenstruckBackupBundle
MIT License
17 stars 3 forks source link

How to extend with custom sources and destinations? #19

Open nclavaud opened 7 months ago

nclavaud commented 7 months ago

Hi, I would like to add my own sources and destinations but it does not look so straightforward.

I have tried registering a custom Source and SourceFactory and tagging them appropriately, but the new source is not detected, so I guess I am missing something.

What would be the simplest way to add a custom source? Any help or example would be much appreciated :pray:

kbond commented 7 months ago

Hey Nicolas,

Oi, it's been a long while since I've done anything with this bundle other than keeping it up to date with the latest Symfony versions. It definitely needs some modernization to make it easier to achieve what you want.

Basically, those source/destination tags you are trying to use are for a pre-compiled container that's used to build configuration and unfortunately, are hard-coded.

Right now, I think what you can do, and this isn't pretty, is the following:

  1. Register your custom sources/destination services (and note their service ids)
  2. In a compiler pass, get the zenstruck_backup.profile_builder definition and add method calls for addSource/addDestination referencing the custom services from above
  3. In your services.yaml, add your profile service using zenstruck_backup.profile_builder::create() as the factory and tag this service with zenstruck_backup.profile

Running bin/console zenstruck:backup:run (without arguments), you should see your profile listed.

It's a bit complex so if this isn't enough to get you up and running, please let me know, and I'll create a reproducer so you can see an example of what I describe above.

I'll keep this issue open as I need to improve this.