8
Gitea
alvis edited this page 2026-06-14 10:22:24 +00:00

Gitea

Git hosting running on Agap via Docker.

Configuration

Configuration is in the AgapHost repository:

  • Compose file: gitea/docker-compose.yml
  • Environment: gitea/.env

Access

  • Public: https://git.alogins.net/
  • Internal: http://agap:3000
  • SSH: ssh -p 222 git@git.alogins.net

Data

Path Contents
/mnt/misc/gitea Repositories, config, attachments
/mnt/ssd/dbs/gitea/postgres PostgreSQL data
/mnt/backups/gitea Backup dumps and logs
/home/git/.ssh SSH keys

Backup

Daily backup via root's cron at 3 AM:

0 3 * * * /home/alvis/agap_git/gitea/backup.sh >> /mnt/backups/gitea/cron.log 2>&1

Note: Must run as root — /mnt/backups/gitea/ is root-owned and not writable by other users.

Script: gitea/backup.sh — stops services, runs gitea dump, saves zip to /mnt/backups/gitea/.

Output: gitea-dump-*.zip containing repos/, gitea-db.sql, app.ini, data/.

Restore

Script: gitea/restore.sh <path-to-dump.zip>

Stops services, restores DB and data files from the dump zip, starts everything back up, regenerates git hooks.

Zabbix Monitoring

Config: /etc/zabbix/zabbix_agent2.d/gitea_backup.conf

Key Returns
gitea.backup.status 1 if last backup succeeded, 0 otherwise
gitea.backup.age Age of latest dump zip in seconds (-1 if none)

Creating Zabbix Trigger Alerts

  1. Create items — go to Data collection → Hosts → AgapHost → Items → Create item:

    • Name: Gitea backup status, Key: gitea.backup.status, Type: Zabbix agent (active), Type of information: Numeric (unsigned), Update interval: 1h
    • Name: Gitea backup age, Key: gitea.backup.age, Type: Zabbix agent (active), Type of information: Numeric (unsigned), Update interval: 1h
  2. Create triggers — go to Data collection → Hosts → AgapHost → Triggers → Create trigger:

    • Backup failed:
      • Name: Gitea backup failed
      • Severity: High
      • Expression: last(/AgapHost/gitea.backup.status)=0
    • Backup stale (>25h):
      • Name: Gitea backup is stale
      • Severity: Warning
      • Expression: last(/AgapHost/gitea.backup.age)>90000 or last(/AgapHost/gitea.backup.age)=-1
  3. Verify — go to Monitoring → Latest data, filter by host AgapHost and key gitea.backup, confirm both items return values.

Note: Items and triggers are already configured via the Zabbix API.

Troubleshooting

SSH push fails with Permission denied (publickey)

After a container rebuild/recreate, Gitea's authorized_keys can lose the user keys (only the internal Gitea Host Key remains in /data/git/.ssh/authorized_keys), even though the keys are still registered in the database. Symptom: git push over SSH is rejected although the key shows up under Settings → SSH Keys.

Rebuild authorized_keys from the database:

docker exec -u git gitea gitea admin regenerate keys

Verify the user key is back:

docker exec gitea grep ssh-ed25519 /data/git/.ssh/authorized_keys

Run this after any gitea container rebuild if SSH access stops working.

SSH port / remote URL

  • Gitea SSH listens on host port 222 (mapped to container 22).
  • git.alogins.net:222 is not reachable externally (not forwarded). Pushing from the Agap host itself must use ssh://git@localhost:222/<user>/<repo>.git.

Stack

  • Gitea 1.25.3
  • PostgreSQL 14