Toots du Jour (Feb 29)
<1 min read
- Async Rust in a Nutshell #async #rustlang www.shuttle.rs/blog/2024/02/29… #
- 8 Linux Apps That Surprised Me! #apps #linux news.itsfoss.com/interesting-l… #
I spent most of last night trying to figure out how to migrate my Forgejo (Gitea) database from MariaDB (MySQL) to PostgreSQL. There's a lot of misleading information out there, so I figured I'd post about it and hopefully prevent someone for falling into a rabbit hole like I did.
First, a bit about my setup. I'm using MariaDB and Forgejo, but these steps will work with MySQL and Gitea too. My database name is forgejodb (which will most likely be giteadb when using Gitea).
To migrate, the steps are:
forgejo dump --database postgres --config /etc/forgejo/app.ini
mkdir tmp
cd tmp
unzip ../forgejo-dump-XXXXXXXXXX.zip
sudo -u postgres psql
postgres=# CREATE USER forgejo WITH PASSWORD 'changeme';
postgres=# CREATE DATABASE forgejo WITH OWNER forgejo TEMPLATE template0 ENCODING UTF8 LC_COLLATE 'en_US.UTF-8' LC_CTYPE 'en_US.UTF-8';
psql --username forgejo -h localhost --set ON_ERROR_STOP=on forgejodb < forgejo-db.sql
Don't forget to edit your app.ini with:
DB_TYPE = postgres
HOST = 127.0.0.1:5432
It's pretty straightforward if you have the right steps.