bruh idk leave me alone i want to enjoy my holiday

This commit is contained in:
crt 2024-07-14 23:22:19 +02:00
parent 8c489b1ed1
commit 46950922d1
1 changed files with 125 additions and 0 deletions

125
README.md
View File

@ -0,0 +1,125 @@
# 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
```bash
mkdir /home/crt/gitea-backup
tar -czvf /home/crt/gitea-backup/gitea-data-dir.tar.gz /opt/gitea/data-dir
```
### Backup Gitea configuration
```bash
cp /opt/gitea/app.ini /home/crt/gitea-backup/
```
### Backup SQLite Database
```bash
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)
```bash
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
```bash
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
```bash
sudo apt update
sudo apt install mariadb-server
```
### Secure MariaDB installation by setting passwords and stuff
```bash
sudo mysql_secure_installation
```
### Create Gitea database and user
```bash
sudo mysql -u root -p
```
```sql
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
```bash
tar -xzvf /home/crt/gitea-backup/gitea-data-dir.tar.gz -C /opt/gitea/data-dir
```
### Restore Gitea Configuration
```bash
cp /home/crt/gitea-backup/app.ini /opt/gitea/
# Copy the Gitea configuration file
```
### Import Data into MariaDB
```sh
mysql -u gitter -p teadb < /home/crt/gitea-backup/tea.sql
```
## Step 5: Configure Gitea on the container
### Edit Gitea configuration
```ini
[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:
```sh
sudo nano /etc/systemd/system/gitea.service
```
Add the following content:
```ini
[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
```sh
sudo systemctl enable --now gitea
```
### Enjoy my new gitea instance running more efficiently on le container wohoo