Automatically create Icinga Basket Snapsnot

I’m curious if there is a way to automatically create a Configuration Basket snapshot, either using a scheduled task on Icinga2 or preferably using the REST API. I’m hoping to create an automated backup that will take a snapshot, download the JSON file, and store it into revision control so there is always a back up of the current configuration.

I’ve looked at the documentation for both Baskets and the REST API but don’t see any mention of a way to do so; however, I have found that if I send an HTTP get request to the Config Basket snapshot page it generates multiple snapshots in succession. I don’t know if this is a bug, or if there is a hidden API feature that I’m not quiet using correctly.

Any input is appreciated!

I would enable the developer tools in the browser and record the communication between the front and back end, while creating the configuration basket snapshot manually and try to replicate the same with a bash/python script. Maybe you hit on a official API that’s just undocumented or you’ll ending up using a internal one. If it’s not a proper API, you maybe need to first authenticate and reuse the cookie in the later requests.

Also, why don’t you just backup the database?

Just use the CLI tool:

$ icingacli director basket
Export Director Config Objects

Available actions:

  dump            JSON-dump for objects related to the given Basket
  list            List configured Baskets
  restore         Restore a Basket from JSON dump provided on STDIN
  snapshot        Take a snapshot for the given Basket

@Dominik I frequently use baskets to migrate configs from a development server to a production one. A database backup is not sufficient for that.