Go to file
crt 54512197f1 added humor 2024-07-14 23:23:37 +02:00
README.md added humor 2024-07-14 23:23:37 +02:00

README.md

Migrating Gitea from SQLite to MariaDB and Moving to a New Server

Documenting my entire platform shift was a bit too much, but to have something documented I've made this which shows the progress of how I migrated my Gitea to MariaDB and then to a Container

Step 1: Backup data from VM instance

Backup Gitea data

mkdir /home/crt/gitea-backup
tar -czvf /home/crt/gitea-backup/gitea-data-dir.tar.gz /opt/gitea/data-dir

Backup Gitea configuration

cp /opt/gitea/app.ini /home/crt/gitea-backup/

Backup SQLite Database

sqlite3 /opt/gitea/db/tea.db .dump > /home/crt/gitea-backup/tea.sql

Connect to container using SFTP and transfer the files (folder already created)

cd /home/crt/gitea-backup/
sftp crt@123.123.123.123
cd /home/crt/gitea-backup
put gitea-data-dir.tar.gz
put app.ini
put tea.sql
bye

Step 2: Install MariaDB and download Gitea on Container

Download and install gitea

wget -O /usr/local/bin/gitea https://dl.gitea.com/gitea/1.22.0/gitea-1.22.0-linux-amd64
chmod +x /usr/local/bin/gitea

Install MariaDB

sudo apt update
sudo apt install mariadb-server

Secure MariaDB installation by setting passwords and stuff

sudo mysql_secure_installation

Create Gitea database and user

sudo mysql -u root -p
CREATE DATABASE teadb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'gitter'@'localhost' IDENTIFIED BY 'YuoNoeGettsingThsePassworderIsVerySEEKRET';
GRANT ALL PRIVILEGES ON teadb.* TO 'gitter'@'localhost';
FLUSH PRIVILEGES;
EXIT

Step 3: Restore data on the new server

Restore Gitea data

tar -xzvf /home/crt/gitea-backup/gitea-data-dir.tar.gz -C /opt/gitea/data-dir

Restore Gitea Configuration

cp /home/crt/gitea-backup/app.ini /opt/gitea/
# Copy the Gitea configuration file

Import Data into MariaDB

mysql -u gitter -p teadb < /home/crt/gitea-backup/tea.sql

Step 5: Configure Gitea on the container

Edit Gitea configuration

[database]
DB_TYPE = mysql
HOST = 127.0.0.1:3306
NAME = teadb
USER = gitter
PASSWD = YuoNoeGettsingThsePassworderIsVerySEEKRET

Set Up Gitea as a service

Create a systemd service file for Gitea:

sudo nano /etc/systemd/system/gitea.service

Add the following content:

[Unit]
Description=Gitter
After=syslog.target
After=network.target
After=mariadb.service

[Service]
User=git
Group=git
WorkingDirectory=/opt/gitea/
ExecStart=/usr/local/bin/gitea web -c /opt/gitea/app.ini
Restart=always
Environment=USER=git HOME=/opt/gitea/

[Install]
WantedBy=multi-user.target

Start and Enable Gitea Service

sudo systemctl enable --now gitea

Enjoy my new gitea instance running more efficiently on le container wohoo

Which works because you are viewing it on it tehee