Compare commits
6
Commits
9650c36b69
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
58dfcd2ebb | ||
|
|
242fa8a927 | ||
|
|
ffdd8bb4b2 | ||
|
|
e17ee68fbd | ||
|
|
1f06472140 | ||
|
|
26af7784e7 |
@@ -0,0 +1,2 @@
|
||||
# Copy to .env and fill in. Used by docker-compose.yml.
|
||||
POSTGRES_PASSWORD=change-me
|
||||
@@ -0,0 +1,4 @@
|
||||
*.zip
|
||||
*.log
|
||||
.env
|
||||
*.bak-*
|
||||
@@ -1,2 +1,30 @@
|
||||
# gitea
|
||||
# Gitea
|
||||
|
||||
Self-hosted Gitea instance running on Docker Compose with a remote PostgreSQL database and automated daily backups.
|
||||
|
||||
## Services
|
||||
|
||||
- **gitea** — Web UI on port `3008`, SSH on port `2222`
|
||||
- **gitea-backup** — Alpine sidecar running a daily cron job at 2 AM
|
||||
|
||||
## Setup
|
||||
|
||||
```bash
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
## Backups
|
||||
|
||||
Backups run automatically at 2 AM daily, writing `gitea-dump-*.zip` files to `/mnt/nasen/backup/gitea` with 7-day retention.
|
||||
|
||||
Run a manual backup:
|
||||
|
||||
```bash
|
||||
docker exec gitea-backup /usr/local/bin/backup.sh
|
||||
```
|
||||
|
||||
Check backup logs:
|
||||
|
||||
```bash
|
||||
docker exec gitea-backup cat /var/log/backup.log
|
||||
```
|
||||
|
||||
@@ -16,18 +16,21 @@ if ! docker inspect gitea >/dev/null 2>&1; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure backup directory exists inside gitea container
|
||||
docker exec -u git gitea sh -c "mkdir -p /tmp/backup"
|
||||
|
||||
# Run gitea dump
|
||||
# Run gitea dump to /tmp (writable by git user)
|
||||
echo "Running gitea dump..."
|
||||
docker exec -u git -w /tmp gitea \
|
||||
/app/gitea/gitea dump \
|
||||
-c /data/gitea/conf/app.ini \
|
||||
--file "/tmp/backup/${BACKUP_FILE}" \
|
||||
--file "/tmp/${BACKUP_FILE}" \
|
||||
--skip-log \
|
||||
--type zip
|
||||
|
||||
# Copy dump out of gitea container into sidecar's backup dir
|
||||
docker cp "gitea:/tmp/${BACKUP_FILE}" "${BACKUP_DIR}/${BACKUP_FILE}"
|
||||
|
||||
# Clean up temp file inside gitea container
|
||||
docker exec gitea rm -f "/tmp/${BACKUP_FILE}"
|
||||
|
||||
# Verify backup was created
|
||||
if [ ! -f "${BACKUP_DIR}/${BACKUP_FILE}" ]; then
|
||||
echo "ERROR: Backup file not found at ${BACKUP_DIR}/${BACKUP_FILE}"
|
||||
|
||||
+20
-6
@@ -1,24 +1,37 @@
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:16-alpine
|
||||
container_name: gitea-postgres
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- POSTGRES_USER=gitea
|
||||
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
|
||||
- POSTGRES_DB=gitea
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
|
||||
gitea:
|
||||
image: gitea/gitea:latest
|
||||
container_name: gitea
|
||||
depends_on:
|
||||
- postgres
|
||||
environment:
|
||||
- USER_UID=1000
|
||||
- USER_GID=1000
|
||||
- GITEA__database__DB_TYPE=postgres
|
||||
- GITEA__database__HOST=192.168.50.42:5432
|
||||
- GITEA__database__HOST=postgres:5432
|
||||
- GITEA__database__NAME=gitea
|
||||
- GITEA__database__USER=postgres
|
||||
- GITEA__database__PASSWD=ratata,123
|
||||
- GITEA__database__USER=gitea
|
||||
- GITEA__database__PASSWD=${POSTGRES_PASSWORD}
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- gitea_data:/data
|
||||
- /etc/timezone:/etc/timezone:ro
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
- /mnt/nasen/backup/gitea:/tmp/backup
|
||||
- ./backup:/tmp/backup
|
||||
ports:
|
||||
- "3008:3000"
|
||||
- "2222:22"
|
||||
- "100.75.252.111:2222:22"
|
||||
|
||||
gitea-backup:
|
||||
image: alpine:3.21
|
||||
@@ -30,7 +43,7 @@ services:
|
||||
- BACKUP_RETAIN_DAYS=7
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
- /mnt/nasen/backup/gitea:/backup
|
||||
- ./backup:/backup
|
||||
- ./backup.sh:/usr/local/bin/backup.sh:ro
|
||||
- /etc/timezone:/etc/timezone:ro
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
@@ -45,3 +58,4 @@ services:
|
||||
|
||||
volumes:
|
||||
gitea_data:
|
||||
postgres_data:
|
||||
|
||||
Reference in New Issue
Block a user