mbecker20 / komodo

🦎 a tool to build and deploy software on many servers 🦎
https://komo.do
GNU General Public License v3.0
1.87k stars 36 forks source link

Backing up Komodo settings (possibly also DB change) #199

Open gitcatpeter opened 7 hours ago

gitcatpeter commented 7 hours ago

Is there any way to backup and export Komodo core settings? Like all server configs, stacks and so on... How much is kept in TOML and how much can be dumped from a DB. And then restore to a vanilla install?

Second part of that question is changing DB type e.g. postgres -> mongo. Is there a way to somehow convert DB dump or something?

I had unexplained postgres failure and even though it eventually recovered I lost some confidence in it (latest Komodo, latest postgres and ferret). Which is strange. because for years postgres has been rock-solid for me.

mbecker20 commented 3 hours ago

Yes, there is the Resource Sync to help with this. Lets say you want to set up Komodo again with a new database backend:

The high level steps will be:

  1. Export your configs to Resource Toml
  2. Take down Komodo
  3. Start fresh Komodo pointing to new db
  4. Create a Resource Sync, paste in the exported Resources Toml, and execute the sync.

Specifics:

To start, note that you cannot export either Users or Git / Docker Providers, lets deal with that first.

For Users, they will have to recreate their account and onboard again. You will lose any specific Permissions attached to Users if you delete the database data. The solution is to migrate all user specific permissions to User Groups which can be included in Resource Toml: https://komo.do/docs/sync-resources#user-group. Non-admin users just need to create their users again with the same username. Admin users can use any username / have no restrictions.

For the Git / Docker Providers, move them all to the core.config.toml: https://github.com/mbecker20/komodo/blob/main/config/core.config.toml#L397. Either this, or you must re-add them via the UI.

The settings for Komodo itself are in the config files (compose.yaml, compose.env, core.config.toml). Just copy these somewhere safe to backup if the server is being formatted.

For the Resources, everything is in the TOML files. Export them before taking down Komodo.

Assuming all your user permissions are moved to User Groups, and your Git / Docker Providers are in your core.config.toml, you can follow the below steps.

  1. From the Dashboard, click the Toml export button. Copy the contents.
  2. Paste the contents into a local file for safekeeping.
  3. Take down Komodo. Copy the compose files as they are as a backup.
  4. Start from the default compose files for your desired database: https://komo.do/docs/setup. Change the necessary things to align with your old config, but leave the database config alone (still fill in DB_USERNAME / DB_PASSWORD).
  5. Bring up Komodo using the provided command from https://komo.do/docs/setup.
  6. Navigate to komodo login in the browser, and sign up your admin user.
  7. Create a new Sync, choose UI Defined, and paste in your Resource Toml you copied before.
  8. Execute the Sync. Confirm all your Resources are back.

Let me know how it works out 🦎

gitcatpeter commented 1 hour ago

Thank you for that detailed instruction! I'm going to try it asap.

What is your experience or recommendation for a backend DB for Komodo. We're talking about a homelab with ~200 docker stacks.

Have you seen any issues with ferret+postgres? That additional translation layer could potentially cause issues. Is my decision to go back to MongoDB warranted?