Skip to content

Instantly share code, notes, and snippets.

@Ashoat
Created July 26, 2022 11:39
Show Gist options
  • Save Ashoat/f3f4027b64707cac3e8a52fc1435b6dc to your computer and use it in GitHub Desktop.
Save Ashoat/f3f4027b64707cac3e8a52fc1435b6dc to your computer and use it in GitHub Desktop.
Migrating Comm developer database from MySQL to MariaDB

Migrating to MariaDB

Don't care about the database contents?

If you don't care about the database contents, it should be easy:

  1. Shut down the keyserver if it's running
  2. Uninstall MySQL: brew services stop mysql@5.7 && brew uninstall mysql@5.7
  3. Delete MySQL data: rm -rf /opt/homebrew/var/mysql/ (this directory might be different on Intel Macs)
  4. Install and configure MariaDB by following all THREE sections in the dev environment instructions titled "MariaDB"

Want to keep database contents?

If you want to keep your database contents, you'll need to first back them up.

  1. Create a keyserver/facts/backups.json file
    • Contents: {"enabled":true,"directory":"/home/comm/backups","maxDirSizeMiB":96}
    • Change the directory to a location where you want to save the backup
  2. Update keyserver/src/cron/cron.js to run backupDB more frequently
    • If the current time is 15:45, you could try something like 48 * * * *
  3. Run the keyserver (eg. with yarn dev) and wait for a backup to be generated in the directory you selected
    • Once the backup is finished generating, you should shut down the keyserver
    • You can tell it's done once the backup file stops getting larger
  4. Next, follow the instructions above under "Don't care about the database contents?"
  5. Finally, you'll restore the database. First use gunzip to unarchive the backup, and then pipe it into mysql:
    • mysql -ucomm -Dcomm -p < ~/Downloads/backup.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment