I’ve been a major fan of Plex since someone got me on the kick a few years back. Anyone that knows me my setup is no joke. One of the best aspects of the entire infrastructure is Ombi which is so well written and useful it’s amazing it’s open sourced. This tool provides a portal for users on my Plex server to make new requests as well as report issues with files. I can also use it to send announcements out to the folks my library is shared to. I’ve been uising the app since version 3 and since version 4 new support was added to use MySQL/MariaDB instead of the built in SQLlite database. I’ve used the individual docker instance for so long I wanted to migrate everything so I had a bit more scale. I have enough users I wanted to be sure the portal would not have any SQLlite lockouts. I have broken this down to the simple steps needed all taken from the full migration documentation and applied to this specific use case.
Migrating Docker Ombi to MySQL/MariaDB: Step One
The first thing you want to do is redirect your users some kind of maintenance page. This is so you can preserve the database from any changes and you will be taking things on and offline to frankly this step is not required…but it’s courteous. Also save a copy of the your three production SQLlite files somwhere
Ombi.db
OmbiSettings.db
OmbiExternal.db
Migrating Docker Ombi to MySQL/MariaDB: Step Two
The next thing you want to do is setup some folder structures as you will need them for the new multiple container stack as you move from the single container. In my case I setup the following on the docker host. The migrate folder will only be used to move the data and can be removed later.
/ombi/config
/ombi/mariadb
/ombi/migrate
cd /ombi/migrate
git clone https://github.com/vsc55/ombi_sqlite_mysql.git ombi_sqlite_mysql
cp -R /ombi/migrate/ombi_sqlite_mysql/* . #Moves files up one level
rm -rf /ombi/migrate/ombi_sqlite_mysql/
chmod +x *.py
Next you want to deploy the new stack to these folders. I used docker compose similar to this one. You can change it as you need to, but in my case I had networks I needed to attach to for the reverse proxy connections. Once this is deployed you will have a “new” SQLlite based install to work from and migrate your data. You will want to be sure you have access to the phpMyAdmin or you can use the mySQL command line next.
version: "3" services: ombi: image: ghcr.io/linuxserver/ombi:latest container_name: ombi environment: - PUID=1000 - PGID=1000 - TZ=America/New_York volumes: - /home/plex/ombi/config:/config - /home/plex/ombi/migrate:/migrate ports: - 127.0.0.1:3579:3579 networks: default: ipv4_address: 172.16.100.121 restart: unless-stopped depends_on: - "mariadb" phpmyadmin: image: phpmyadmin/phpmyadmin container_name: ombi_phpmyadmin restart: unless-stopped environment: PMA_HOST: mariadb ports: - 127.0.0.1:8800:8800 networks: default: ipv4_address: 172.16.100.122 depends_on: - "mariadb" mariadb: image: "mariadb:latest" container_name: ombi_mariadb restart: unless-stopped environment: MYSQL_ROOT_PASSWORD: 12345 #change your root password here volumes: - /home/plex/ombi/mariadb:/var/lib/mysql networks: default: external: name: myNetwork
Be sure to bring up the stack and keep it running for now.
Migrating Docker Ombi to MySQL/MariaDB: Step Three
Now that you have a new Ombi blank instance with SQLlite we can start the process of preparing the new database. First we need to create the database. I decided to go to a single database for easier backup management. I recommend using new passwords of course.
CREATE DATABASE IF NOT EXISTS `Ombi` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
CREATE USER 'ombi'@'%' IDENTIFIED BY 'ombi';
GRANT ALL PRIVILEGES ON `Ombi`.* TO 'ombi'@'%' WITH GRANT OPTION;
Next you will want to remove and copy your old database files. You can do all this with the stack running for now.
rm -rf /ombi/config #clear out the new empty SQLlite files
cp *.db /ombi/config #move your three original SQLLite files
Next we need to create a database.json file that looks like this
{ "OmbiDatabase": { "Type": "MySQL", "ConnectionString": "Server=mariadb;Port=3306;Database=Ombi;User=ombi;Password=ombi" }, "SettingsDatabase": { "Type": "MySQL", "ConnectionString": "Server=mariadb;Port=3306;Database=Ombi;User=ombi;Password=ombi" }, "ExternalDatabase": { "Type": "MySQL", "ConnectionString": "Server=mariadb;Port=3306;Database=Ombi;User=ombi;Password=ombi" } }
You will need to connect to the instance and execute the following
docker exec -it ombi bash
apt update; apt install python3 python3-mysqldb python3-packaging -y
/opt/ombi/Ombi --migrate --storage /config #Creates tables
python3 /migrate/ombi_sqlite2mysql.py -c /config --only_manager_json #Migration File
python3 /migrate/ombi_sqlite2mysql.py -c /config --host mariadb --db Ombi --user ombi --passwd ombi #Complete Migration
Migrating Docker Ombi to MySQL/MariaDB: Step Four
At this stage we have the date moved into the new MySQL database and the rest is easy. We just need to have the ombi container make use of the new database. By default if a database.json file exists on startup that is used. all you need to down the instance and..
rm -r /ombi/config/*.db #removes the old DB's
rm -r /ombi/config/migration.json #removes the migration config file
Finally power the stack back on. Since there is nothing in the config folder but the database.json file in a few minutes your application should be back and under “settings” you will see that MySQL is in use.
I recommend also setting up a mysqldump script in CRON so you can keep database backups. That’s it you have now moved all your SQLlite data to MySQL/MariaDB and you have a three container stack that should even perform a little better than the original single container.