Compare commits

..

3 Commits

46 changed files with 1334 additions and 809 deletions

View File

@@ -1,32 +1,82 @@
# Gitea Database Backup Script
$timestamp = Get-Date -Format "yyyy-MM-dd_HH-mm-ss"
$backupDir = ".\backups"
$backupFile = "$backupDir\gitea-db-backup-$timestamp.sql"
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$backupDir = Join-Path $scriptDir "backups"
$backupFile = Join-Path $backupDir "gitea-db-backup-$timestamp.sql"
$redundantBackupDir = "D:\Pr00jects\gitea-docker"
# Ensure backup directory exists
if (-not (Test-Path $backupDir)) {
New-Item -ItemType Directory -Path $backupDir
}
# Ensure redundant backup directory exists
if (-not (Test-Path $redundantBackupDir)) {
try {
New-Item -ItemType Directory -Path $redundantBackupDir -Force
} catch {
"[$timestamp] Warning: Could not create redundant backup directory at $redundantBackupDir. Error: $_" | Out-File -Append -FilePath $logFile
}
}
# Log execution of the script
$logFile = Join-Path $backupDir "backup-log.txt"
"[$timestamp] Starting database backup..." | Out-File -Append -FilePath $logFile
# Check if Docker is running
$dockerRunning = $false
try {
$dockerStatus = docker info 2>&1
$dockerRunning = $LASTEXITCODE -eq 0
} catch {
$dockerRunning = $false
}
if (-not $dockerRunning) {
"[$timestamp] Error: Docker is not running. Backup failed." | Out-File -Append -FilePath $logFile
exit 1
}
# Check if Gitea container is running
$containerRunning = docker ps --format "{{.Names}}" | Select-String -Pattern "gitea-db" -Quiet
if (-not $containerRunning) {
"[$timestamp] Error: Gitea database container is not running. Backup failed." | Out-File -Append -FilePath $logFile
exit 1
}
# Create database dump
Write-Host "Creating database backup to $backupFile..."
"[$timestamp] Creating database backup to $backupFile..." | Out-File -Append -FilePath $logFile
docker exec gitea-db pg_dump -U gitea -d gitea > $backupFile
# Check if backup was successful
if ($LASTEXITCODE -eq 0 -and (Test-Path $backupFile) -and (Get-Item $backupFile).Length -gt 0) {
Write-Host "Backup completed successfully!"
"[$timestamp] Backup completed successfully!" | Out-File -Append -FilePath $logFile
# Optional: Compress the backup file
Compress-Archive -Path $backupFile -DestinationPath "$backupFile.zip" -Force
$zipFileName = "$backupFile.zip"
Compress-Archive -Path $backupFile -DestinationPath $zipFileName -Force
Remove-Item $backupFile
Write-Host "Backup compressed to $backupFile.zip"
"[$timestamp] Backup compressed to $zipFileName" | Out-File -Append -FilePath $logFile
# Copy backup to redundant location
if (Test-Path $redundantBackupDir) {
try {
$redundantBackupFile = Join-Path $redundantBackupDir (Split-Path -Leaf $zipFileName)
Copy-Item -Path $zipFileName -Destination $redundantBackupFile -Force
"[$timestamp] Backup copied to redundant location: $redundantBackupFile" | Out-File -Append -FilePath $logFile
} catch {
"[$timestamp] Error copying backup to redundant location: $_" | Out-File -Append -FilePath $logFile
}
} else {
Write-Host "Backup failed!" -ForegroundColor Red
"[$timestamp] Warning: Redundant backup directory not found: $redundantBackupDir" | Out-File -Append -FilePath $logFile
}
} else {
"[$timestamp] Backup failed!" | Out-File -Append -FilePath $logFile
}
# Optional: Clean up old backups (keep last 10)
$oldBackups = Get-ChildItem -Path $backupDir -Filter "gitea-db-backup-*.zip" | Sort-Object LastWriteTime -Descending | Select-Object -Skip 10
foreach ($backup in $oldBackups) {
Remove-Item $backup.FullName
Write-Host "Removed old backup: $($backup.Name)"
"[$timestamp] Removed old backup: $($backup.Name)" | Out-File -Append -FilePath $logFile
}

View File

@@ -1,36 +1,82 @@
# Script to backup the entire Postgres Docker volume
$timestamp = Get-Date -Format "yyyy-MM-dd_HH-mm-ss"
$backupDir = ".\backups"
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$backupDir = Join-Path $scriptDir "backups"
$volumeName = "gitea-docker_postgres-data"
$backupFile = "$backupDir\postgres-volume-backup-$timestamp.tar"
$backupFile = "postgres-volume-backup-$timestamp.tar"
$backupFilePath = Join-Path $backupDir $backupFile
$redundantBackupDir = "D:\Pr00jects\gitea-docker"
$logFile = Join-Path $backupDir "volume-backup-log.txt"
$currentDir = Get-Location
# Ensure backup directory exists
if (-not (Test-Path $backupDir)) {
New-Item -ItemType Directory -Path $backupDir
}
# Ensure redundant backup directory exists
if (-not (Test-Path $redundantBackupDir)) {
try {
New-Item -ItemType Directory -Path $redundantBackupDir -Force
} catch {
Add-Content -Path $logFile -Value "[$timestamp] Warning: Could not create redundant backup directory at $redundantBackupDir. Error: $_"
}
}
# Log start of backup
Add-Content -Path $logFile -Value "[$timestamp] Starting volume backup for $volumeName..."
# Check if volume exists
$volumeExists = docker volume ls --format "{{.Name}}" | Select-String -Pattern "^$volumeName$"
if (-not $volumeExists) {
Write-Host "Volume $volumeName not found!" -ForegroundColor Red
Add-Content -Path $logFile -Value "[$timestamp] Error: Volume $volumeName not found!"
exit 1
}
# Create a temporary container to access the volume
Write-Host "Creating backup of Docker volume $volumeName..."
docker run --rm -v ${volumeName}:/volume -v ${PWD}/${backupDir}:/backup alpine tar -cf /backup/$(Split-Path $backupFile -Leaf) -C /volume ./
Add-Content -Path $logFile -Value "[$timestamp] Creating backup to $backupFilePath..."
# Change to backup directory and use simple relative paths for Docker
Set-Location -Path $backupDir
docker run --rm -v ${volumeName}:/volume -v ${PWD}:/backup alpine tar -cf /backup/$backupFile -C /volume ./
# Restore original directory
Set-Location -Path $currentDir
# Check if backup was successful
if ($LASTEXITCODE -eq 0 -and (Test-Path $backupFile) -and (Get-Item $backupFile).Length -gt 0) {
Write-Host "Volume backup completed successfully to $backupFile!" -ForegroundColor Green
if ($LASTEXITCODE -eq 0 -and (Test-Path $backupFilePath) -and (Get-Item $backupFilePath).Length -gt 0) {
Write-Host "Volume backup completed successfully to $backupFilePath!" -ForegroundColor Green
Add-Content -Path $logFile -Value "[$timestamp] Volume backup completed successfully!"
# Optional: Compress the backup file
Write-Host "Compressing backup file..."
Compress-Archive -Path $backupFile -DestinationPath "$backupFile.zip" -Force
Remove-Item $backupFile
Write-Host "Backup compressed to $backupFile.zip" -ForegroundColor Green
Add-Content -Path $logFile -Value "[$timestamp] Compressing backup file..."
$zipFileName = "$backupFilePath.zip"
Compress-Archive -Path $backupFilePath -DestinationPath $zipFileName -Force
Remove-Item $backupFilePath
Write-Host "Backup compressed to $zipFileName" -ForegroundColor Green
Add-Content -Path $logFile -Value "[$timestamp] Backup compressed to $zipFileName"
# Copy backup to redundant location
if (Test-Path $redundantBackupDir) {
try {
$redundantBackupFile = Join-Path $redundantBackupDir (Split-Path -Leaf $zipFileName)
Copy-Item -Path $zipFileName -Destination $redundantBackupFile -Force
Write-Host "Backup copied to redundant location: $redundantBackupFile" -ForegroundColor Green
Add-Content -Path $logFile -Value "[$timestamp] Backup copied to redundant location: $redundantBackupFile"
} catch {
Write-Host "Error copying backup to redundant location: $_" -ForegroundColor Red
Add-Content -Path $logFile -Value "[$timestamp] Error copying backup to redundant location: $_"
}
} else {
Write-Host "Warning: Redundant backup directory not found: $redundantBackupDir" -ForegroundColor Yellow
Add-Content -Path $logFile -Value "[$timestamp] Warning: Redundant backup directory not found: $redundantBackupDir"
}
} else {
Write-Host "Volume backup failed!" -ForegroundColor Red
Add-Content -Path $logFile -Value "[$timestamp] Volume backup failed!"
}
# Optional: Clean up old volume backups (keep last 5)
@@ -38,4 +84,5 @@ $oldBackups = Get-ChildItem -Path $backupDir -Filter "postgres-volume-backup-*.z
foreach ($backup in $oldBackups) {
Remove-Item $backup.FullName
Write-Host "Removed old volume backup: $($backup.Name)"
Add-Content -Path $logFile -Value "[$timestamp] Removed old volume backup: $($backup.Name)"
}

BIN
backups/backup-log.txt Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,104 @@
[2025-04-19_19-40-51] Starting volume backup for gitea-docker_postgres-data...
[2025-04-19_19-40-51] Creating backup to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-04-19_19-40-51.tar...
[2025-04-19_19-40-51] Volume backup failed!
[2025-04-19_19-41-05] Starting volume backup for gitea-docker_postgres-data...
[2025-04-19_19-41-05] Creating backup to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-04-19_19-41-05.tar...
[2025-04-19_19-41-05] Volume backup failed!
[2025-04-19_19-42-55] Starting volume backup for gitea-docker_postgres-data...
[2025-04-19_19-42-55] Creating backup to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-04-19_19-42-55.tar...
[2025-04-19_19-42-55] Volume backup completed successfully!
[2025-04-19_19-42-55] Compressing backup file...
[2025-04-19_19-42-55] Backup compressed to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-04-19_19-42-55.tar.zip
[2025-04-19_19-42-55] Backup copied to redundant location: D:\Pr00jects\gitea-docker\postgres-volume-backup-2025-04-19_19-42-55.tar.zip
[2025-04-19_19-43-53] Starting volume backup for gitea-docker_postgres-data...
[2025-04-19_19-43-53] Creating backup to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-04-19_19-43-53.tar...
[2025-04-19_19-43-53] Volume backup completed successfully!
[2025-04-19_19-43-53] Compressing backup file...
[2025-04-19_19-43-53] Backup compressed to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-04-19_19-43-53.tar.zip
[2025-04-19_19-43-53] Backup copied to redundant location: D:\Pr00jects\gitea-docker\postgres-volume-backup-2025-04-19_19-43-53.tar.zip
[2025-04-19_19-44-40] Starting volume backup for gitea-docker_postgres-data...
[2025-04-19_19-44-40] Creating backup to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-04-19_19-44-40.tar...
[2025-04-19_19-44-40] Volume backup completed successfully!
[2025-04-19_19-44-40] Compressing backup file...
[2025-04-19_19-44-40] Backup compressed to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-04-19_19-44-40.tar.zip
[2025-04-19_19-44-40] Backup copied to redundant location: D:\Pr00jects\gitea-docker\postgres-volume-backup-2025-04-19_19-44-40.tar.zip
[2025-04-20_03-06-24] Starting volume backup for gitea-docker_postgres-data...
[2025-04-20_03-06-24] Creating backup to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-04-20_03-06-24.tar...
[2025-04-20_03-06-24] Volume backup completed successfully!
[2025-04-20_03-06-24] Compressing backup file...
[2025-04-20_03-06-24] Backup compressed to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-04-20_03-06-24.tar.zip
[2025-04-20_03-06-24] Backup copied to redundant location: D:\Pr00jects\gitea-docker\postgres-volume-backup-2025-04-20_03-06-24.tar.zip
[2025-04-21_03-05-47] Starting volume backup for gitea-docker_postgres-data...
[2025-04-21_03-05-47] Creating backup to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-04-21_03-05-47.tar...
[2025-04-21_03-05-47] Volume backup completed successfully!
[2025-04-21_03-05-47] Compressing backup file...
[2025-04-21_03-05-47] Backup compressed to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-04-21_03-05-47.tar.zip
[2025-04-21_03-05-47] Backup copied to redundant location: D:\Pr00jects\gitea-docker\postgres-volume-backup-2025-04-21_03-05-47.tar.zip
[2025-04-21_03-05-47] Removed old volume backup: postgres-volume-backup-2025-03-01_23-23-13.tar.zip
[2025-04-22_03-27-19] Starting volume backup for gitea-docker_postgres-data...
[2025-04-22_03-27-19] Creating backup to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-04-22_03-27-19.tar...
[2025-04-22_03-27-19] Volume backup completed successfully!
[2025-04-22_03-27-19] Compressing backup file...
[2025-04-22_03-27-19] Backup compressed to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-04-22_03-27-19.tar.zip
[2025-04-22_03-27-19] Backup copied to redundant location: D:\Pr00jects\gitea-docker\postgres-volume-backup-2025-04-22_03-27-19.tar.zip
[2025-04-22_03-27-19] Removed old volume backup: postgres-volume-backup-2025-04-19_19-42-55.tar.zip
[2025-04-23_08-10-53] Starting volume backup for gitea-docker_postgres-data...
[2025-04-23_08-10-53] Creating backup to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-04-23_08-10-53.tar...
[2025-04-23_08-10-53] Volume backup completed successfully!
[2025-04-23_08-10-53] Compressing backup file...
[2025-04-23_08-10-53] Backup compressed to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-04-23_08-10-53.tar.zip
[2025-04-23_08-10-53] Backup copied to redundant location: D:\Pr00jects\gitea-docker\postgres-volume-backup-2025-04-23_08-10-53.tar.zip
[2025-04-23_08-10-53] Removed old volume backup: postgres-volume-backup-2025-04-19_19-43-53.tar.zip
[2025-05-18_01-22-29] Starting volume backup for gitea-docker_postgres-data...
[2025-05-18_01-22-29] Creating backup to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-05-18_01-22-29.tar...
[2025-05-18_01-22-29] Volume backup completed successfully!
[2025-05-18_01-22-29] Compressing backup file...
[2025-05-18_01-22-29] Backup compressed to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-05-18_01-22-29.tar.zip
[2025-05-18_01-22-29] Backup copied to redundant location: D:\Pr00jects\gitea-docker\postgres-volume-backup-2025-05-18_01-22-29.tar.zip
[2025-05-18_01-22-29] Removed old volume backup: postgres-volume-backup-2025-04-19_19-44-40.tar.zip
[2025-05-18_03-00-14] Starting volume backup for gitea-docker_postgres-data...
[2025-05-18_03-00-14] Creating backup to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-05-18_03-00-14.tar...
[2025-05-18_03-00-14] Volume backup completed successfully!
[2025-05-18_03-00-14] Compressing backup file...
[2025-05-18_03-00-14] Backup compressed to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-05-18_03-00-14.tar.zip
[2025-05-18_03-00-14] Backup copied to redundant location: D:\Pr00jects\gitea-docker\postgres-volume-backup-2025-05-18_03-00-14.tar.zip
[2025-05-18_03-00-14] Removed old volume backup: postgres-volume-backup-2025-04-20_03-06-24.tar.zip
[2025-05-19_03-00-14] Starting volume backup for gitea-docker_postgres-data...
[2025-05-19_03-00-14] Creating backup to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-05-19_03-00-14.tar...
[2025-05-19_03-00-14] Volume backup completed successfully!
[2025-05-19_03-00-14] Compressing backup file...
[2025-05-19_03-00-14] Backup compressed to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-05-19_03-00-14.tar.zip
[2025-05-19_03-00-14] Backup copied to redundant location: D:\Pr00jects\gitea-docker\postgres-volume-backup-2025-05-19_03-00-14.tar.zip
[2025-05-19_03-00-14] Removed old volume backup: postgres-volume-backup-2025-04-21_03-05-47.tar.zip
[2025-05-20_03-14-23] Starting volume backup for gitea-docker_postgres-data...
[2025-05-20_03-14-23] Creating backup to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-05-20_03-14-23.tar...
[2025-05-20_03-14-23] Volume backup completed successfully!
[2025-05-20_03-14-23] Compressing backup file...
[2025-05-20_03-14-23] Backup compressed to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-05-20_03-14-23.tar.zip
[2025-05-20_03-14-23] Backup copied to redundant location: D:\Pr00jects\gitea-docker\postgres-volume-backup-2025-05-20_03-14-23.tar.zip
[2025-05-20_03-14-23] Removed old volume backup: postgres-volume-backup-2025-04-22_03-27-19.tar.zip
[2025-05-21_03-08-24] Starting volume backup for gitea-docker_postgres-data...
[2025-05-21_03-08-24] Creating backup to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-05-21_03-08-24.tar...
[2025-05-21_03-08-24] Volume backup completed successfully!
[2025-05-21_03-08-24] Compressing backup file...
[2025-05-21_03-08-24] Backup compressed to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-05-21_03-08-24.tar.zip
[2025-05-21_03-08-24] Backup copied to redundant location: D:\Pr00jects\gitea-docker\postgres-volume-backup-2025-05-21_03-08-24.tar.zip
[2025-05-21_03-08-24] Removed old volume backup: postgres-volume-backup-2025-04-23_08-10-53.tar.zip
[2025-05-22_03-03-49] Starting volume backup for gitea-docker_postgres-data...
[2025-05-22_03-03-49] Creating backup to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-05-22_03-03-49.tar...
[2025-05-22_03-03-49] Volume backup completed successfully!
[2025-05-22_03-03-49] Compressing backup file...
[2025-05-22_03-03-49] Backup compressed to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-05-22_03-03-49.tar.zip
[2025-05-22_03-03-49] Backup copied to redundant location: D:\Pr00jects\gitea-docker\postgres-volume-backup-2025-05-22_03-03-49.tar.zip
[2025-05-22_03-03-49] Removed old volume backup: postgres-volume-backup-2025-05-18_01-22-29.tar.zip
[2025-05-23_08-01-05] Starting volume backup for gitea-docker_postgres-data...
[2025-05-23_08-01-05] Creating backup to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-05-23_08-01-05.tar...
[2025-05-23_08-01-05] Volume backup completed successfully!
[2025-05-23_08-01-05] Compressing backup file...
[2025-06-09_21-30-15] Starting volume backup for gitea-docker_postgres-data...
[2025-06-09_21-30-15] Creating backup to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-06-09_21-30-15.tar...
[2025-06-09_21-30-15] Volume backup completed successfully!
[2025-06-09_21-30-15] Compressing backup file...
[2025-06-09_21-30-15] Backup compressed to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-06-09_21-30-15.tar.zip
[2025-06-09_21-30-15] Backup copied to redundant location: D:\Pr00jects\gitea-docker\postgres-volume-backup-2025-06-09_21-30-15.tar.zip
[2025-06-09_21-30-15] Removed old volume backup: postgres-volume-backup-2025-05-18_03-00-14.tar.zip

View File

@@ -0,0 +1,20 @@
version: '3.8'
services:
headscale:
image: headscale/headscale:latest
container_name: headscale
restart: unless-stopped
ports:
- "8081:8080" # Web UI and API (avoiding conflict with Traefik)
- "50443:50443" # gRPC
volumes:
- ./headscale/config:/etc/headscale
- ./headscale/data:/var/lib/headscale
command: serve
networks:
- headscale-net
networks:
headscale-net:
driver: bridge

View File

@@ -3,6 +3,10 @@ version: "3"
networks:
gitea:
external: false
traefik:
external: true
immich_default:
external: true
volumes:
gitea-data:
@@ -15,18 +19,20 @@ services:
container_name: traefik
restart: always
ports:
- "80:80" # HTTP
- "443:443" # HTTPS
- "8080:8080" # Dashboard
- "8080:80" # HTTP (changed from 80 to 8080 for ISP testing)
- "8443:443" # HTTPS (changed from 443 to 8443 for ISP testing)
- "8081:8080" # Dashboard (changed to avoid conflict)
networks:
- gitea
- traefik
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- traefik-certs:/letsencrypt
command:
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--providers.docker.network=gitea-docker_gitea"
- "--providers.docker.network=traefik"
- "--entrypoints.web.address=:80"
- "--entrypoints.websecure.address=:443"
- "--entrypoints.web.http.redirections.entryPoint.to=websecure"
@@ -53,7 +59,7 @@ services:
- GITEA__database__PASSWD=gitea
# Server Configuration
- GITEA__server__DOMAIN=bee8333.ddns.net
- GITEA__server__ROOT_URL=https://bee8333.ddns.net/
- GITEA__server__ROOT_URL=https://bee8333.ddns.net/gitea/
- GITEA__server__PROTOCOL=http
- GITEA__server__HTTP_PORT=3000
- GITEA__server__SSH_DOMAIN=bee8333.ddns.net
@@ -68,30 +74,63 @@ services:
restart: always
networks:
- gitea
- traefik
volumes:
- gitea-data:/data
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
# - /etc/timezone:/etc/timezone:ro
# - /etc/localtime:/etc/localtime:ro
ports:
- "2224:22" # SSH: Host port 2224 -> Container port 22
depends_on:
- db
labels:
- "traefik.enable=true"
# HTTP Configuration for HTTPS access
- "traefik.http.routers.gitea.rule=Host(`bee8333.ddns.net`)"
- "traefik.docker.network=traefik"
# HTTPS Configuration for /gitea subpath
- "traefik.http.routers.gitea.rule=Host(`bee8333.ddns.net`) && PathPrefix(`/gitea`)"
- "traefik.http.routers.gitea.entrypoints=websecure"
- "traefik.http.routers.gitea.tls.certresolver=letsencrypt"
- "traefik.http.routers.gitea.priority=10"
- "traefik.http.services.gitea.loadbalancer.server.port=3000"
- "traefik.http.middlewares.gitea-stripprefix.stripprefix.prefixes=/gitea"
- "traefik.http.middlewares.gitea-headers.headers.customrequestheaders.X-Forwarded-Proto=https"
- "traefik.http.routers.gitea.middlewares=gitea-headers@docker"
- "traefik.http.routers.gitea.middlewares=gitea-stripprefix@docker,gitea-headers@docker"
# HTTP Configuration for HTTP -> HTTPS redirection
- "traefik.http.routers.gitea-http.rule=Host(`bee8333.ddns.net`)"
- "traefik.http.routers.gitea-http.rule=Host(`bee8333.ddns.net`) && PathPrefix(`/gitea`)"
- "traefik.http.routers.gitea-http.entrypoints=web"
- "traefik.http.middlewares.https-redirect.redirectscheme.scheme=https"
- "traefik.http.middlewares.https-redirect.redirectscheme.permanent=true"
- "traefik.http.routers.gitea-http.middlewares=https-redirect@docker"
headscale:
image: headscale/headscale:latest
container_name: headscale
restart: unless-stopped
ports:
- "3478:3478/udp" # STUN for DERP relay
volumes:
- ./headscale/config:/etc/headscale
- ./headscale/data:/var/lib/headscale
command: serve
networks:
- gitea
- traefik
labels:
- "traefik.enable=true"
- "traefik.docker.network=traefik"
# HTTPS Configuration for /headscale subpath
- "traefik.http.routers.headscale.rule=Host(`bee8333.ddns.net`) && PathPrefix(`/headscale`)"
- "traefik.http.routers.headscale.entrypoints=websecure"
- "traefik.http.routers.headscale.tls.certresolver=letsencrypt"
- "traefik.http.services.headscale.loadbalancer.server.port=8080"
- "traefik.http.middlewares.headscale-stripprefix.stripprefix.prefixes=/headscale"
- "traefik.http.middlewares.headscale-headers.headers.customrequestheaders.X-Forwarded-Proto=https"
- "traefik.http.routers.headscale.middlewares=headscale-stripprefix@docker,headscale-headers@docker"
# HTTP Configuration for HTTP -> HTTPS redirection
- "traefik.http.routers.headscale-http.rule=Host(`bee8333.ddns.net`) && PathPrefix(`/headscale`)"
- "traefik.http.routers.headscale-http.entrypoints=web"
- "traefik.http.routers.headscale-http.middlewares=https-redirect@docker"
db:
image: postgres:14
container_name: gitea-db

83
ensure-docker-running.ps1 Normal file
View File

@@ -0,0 +1,83 @@
# Script to ensure Docker is running before scheduled backup
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$logFile = Join-Path $scriptDir "backups\docker-status.log"
$timestamp = Get-Date -Format "yyyy-MM-dd_HH-mm-ss"
# Ensure log directory exists
$backupDir = Join-Path $scriptDir "backups"
if (-not (Test-Path $backupDir)) {
New-Item -ItemType Directory -Path $backupDir
}
"[$timestamp] Checking Docker status..." | Out-File -Append -FilePath $logFile
# Check if Docker Desktop is running
$dockerProcess = Get-Process "Docker Desktop" -ErrorAction SilentlyContinue
if ($null -eq $dockerProcess) {
"[$timestamp] Docker Desktop is not running. Attempting to start..." | Out-File -Append -FilePath $logFile
# Path to Docker Desktop
$dockerPath = "C:\Program Files\Docker\Docker\Docker Desktop.exe"
if (Test-Path $dockerPath) {
Start-Process $dockerPath
"[$timestamp] Started Docker Desktop." | Out-File -Append -FilePath $logFile
# Wait for Docker to start up (give it 60 seconds)
$maxWaitTime = 60
$waitTime = 0
$dockerRunning = $false
while (-not $dockerRunning -and $waitTime -lt $maxWaitTime) {
Start-Sleep -Seconds 5
$waitTime += 5
try {
$dockerStatus = docker info 2>&1
if ($LASTEXITCODE -eq 0) {
$dockerRunning = $true
"[$timestamp] Docker is now running after waiting $waitTime seconds." | Out-File -Append -FilePath $logFile
}
} catch {
# Keep waiting
}
}
if (-not $dockerRunning) {
"[$timestamp] Docker did not start successfully after waiting $maxWaitTime seconds." | Out-File -Append -FilePath $logFile
}
} else {
"[$timestamp] Docker Desktop executable not found at expected location: $dockerPath" | Out-File -Append -FilePath $logFile
}
} else {
"[$timestamp] Docker Desktop is already running." | Out-File -Append -FilePath $logFile
}
# Check if containers are running
try {
$containersRunning = docker ps 2>&1
if ($LASTEXITCODE -eq 0) {
"[$timestamp] Docker containers status: " | Out-File -Append -FilePath $logFile
$runningContainers = docker ps --format "{{.Names}}" 2>&1
$runningContainers | Out-File -Append -FilePath $logFile
# Check specifically for gitea containers
$giteaRunning = $runningContainers | Select-String -Pattern "gitea" -Quiet
if (-not $giteaRunning) {
"[$timestamp] Gitea containers are not running. Starting containers..." | Out-File -Append -FilePath $logFile
# Navigate to gitea-docker directory and start containers
Set-Location $scriptDir
docker-compose up -d 2>&1 | Out-File -Append -FilePath $logFile
if ($LASTEXITCODE -eq 0) {
"[$timestamp] Successfully started Gitea containers." | Out-File -Append -FilePath $logFile
} else {
"[$timestamp] Failed to start Gitea containers." | Out-File -Append -FilePath $logFile
}
}
} else {
"[$timestamp] Failed to check running containers. Docker might not be ready yet." | Out-File -Append -FilePath $logFile
}
} catch {
"[$timestamp] Error checking Docker containers: $_" | Out-File -Append -FilePath $logFile
}

BIN
gitea-dump.zip Normal file

Binary file not shown.

View File

@@ -0,0 +1,54 @@
server_url: https://bee8333.ddns.net/headscale/
listen_addr: 0.0.0.0:8080
metrics_listen_addr: 127.0.0.1:9090
grpc_listen_addr: 0.0.0.0:50443
grpc_allow_insecure: false
tls_cert_path: ""
tls_key_path: ""
private_key_path: /var/lib/headscale/private.key
noise:
private_key_path: /var/lib/headscale/noise_private.key
prefixes:
v4: 100.64.0.0/10
v6: fd7a:115c:a1e0::/48
derp:
server:
enabled: true
region_id: 900
region_code: "homelab"
region_name: "Home Lab"
stun_listen_addr: "0.0.0.0:3478"
private_key_path: /var/lib/headscale/derp_server_private.key
urls:
- https://controlplane.tailscale.com/derpmap/default
disable_check_updates: false
ephemeral_node_inactivity_timeout: 30m
database:
type: sqlite3
sqlite:
path: /var/lib/headscale/db.sqlite
log:
format: text
level: info
policy:
path: ""
dns:
override_local_dns: true
nameservers:
global:
- 1.1.1.1
- 8.8.8.8
search_domains: []
magic_dns: true
base_domain: headscale.bee8333.local
unix_socket: /var/run/headscale/headscale.sock
unix_socket_permission: "0770"

36
immich-https.conf Normal file
View File

@@ -0,0 +1,36 @@
events {
worker_connections 1024;
}
http {
upstream immich {
server immich_server:2283;
}
server {
listen 443 ssl;
server_name bee8333.ddns.net;
# Self-signed SSL certificate (will be generated at startup)
ssl_certificate /etc/ssl/certs/immich.crt;
ssl_certificate_key /etc/ssl/private/immich.key;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
client_max_body_size 50000M;
# Direct proxy to Immich - NO subpath manipulation
location / {
proxy_pass http://immich;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
# WebSocket support for real-time features
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
}

49
immich-nginx.conf Normal file
View File

@@ -0,0 +1,49 @@
events {
worker_connections 1024;
}
http {
upstream immich {
server immich_server:2283;
}
server {
listen 80;
server_name bee8333.ddns.net;
client_max_body_size 50000M;
# Main application - all requests go to Immich
location / {
proxy_pass http://immich;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# Critical headers for subpath handling
proxy_set_header X-Forwarded-Prefix /immich;
proxy_set_header X-Script-Name /immich;
# WebSocket support for real-time features
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
# SPA support - handle client-side routing
proxy_intercept_errors on;
error_page 404 = @fallback;
}
# Fallback for SPA routing
location @fallback {
proxy_pass http://immich;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Prefix /immich;
proxy_set_header X-Script-Name /immich;
}
}
}

17
run-backup.ps1 Normal file
View File

@@ -0,0 +1,17 @@
# This script is automatically generated - do not edit manually
# It runs the Docker check script followed by database and volume backup scripts
# Get the script directory
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
# Run the Docker check script first
$dockerCheckScript = Join-Path $scriptDir "ensure-docker-running.ps1"
& $dockerCheckScript
# Then run the database backup script
$dbBackupScript = Join-Path $scriptDir "backup-gitea-db.ps1"
& $dbBackupScript
# Finally run the volume backup script
$volumeBackupScript = Join-Path $scriptDir "backup-volume.ps1"
& $volumeBackupScript

View File

@@ -1,5 +1,7 @@
# Script to create a scheduled task for Gitea database backups
$scriptPath = Join-Path (Get-Location) "backup-gitea-db.ps1"
$workingDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$scriptPath = Join-Path $workingDir "backup-gitea-db.ps1"
$dockerCheckScript = Join-Path $workingDir "ensure-docker-running.ps1"
$taskName = "GiteaDatabaseBackup"
$taskDescription = "Regular backup of Gitea PostgreSQL database"
@@ -9,8 +11,32 @@ if (-not (Test-Path $scriptPath)) {
exit 1
}
# Check if the Docker check script exists
if (-not (Test-Path $dockerCheckScript)) {
Write-Host "Docker check script not found at: $dockerCheckScript" -ForegroundColor Red
exit 1
}
# Create a batch script that runs both scripts
$batchScriptPath = Join-Path $workingDir "run-backup.ps1"
@"
# This script is automatically generated - do not edit manually
# It runs the Docker check script followed by the backup script
# Get the script directory
`$scriptDir = Split-Path -Parent `$MyInvocation.MyCommand.Path
# Run the Docker check script first
`$dockerCheckScript = Join-Path `$scriptDir "ensure-docker-running.ps1"
& `$dockerCheckScript
# Then run the backup script
`$backupScript = Join-Path `$scriptDir "backup-gitea-db.ps1"
& `$backupScript
"@ | Out-File -FilePath $batchScriptPath -Encoding utf8
# Create a scheduled task to run daily at 3 AM
$action = New-ScheduledTaskAction -Execute "PowerShell.exe" -Argument "-NoProfile -ExecutionPolicy Bypass -File `"$scriptPath`""
$action = New-ScheduledTaskAction -Execute "PowerShell.exe" -Argument "-NoProfile -ExecutionPolicy Bypass -File `"$batchScriptPath`"" -WorkingDirectory "$workingDir"
$trigger = New-ScheduledTaskTrigger -Daily -At 3AM
$settings = New-ScheduledTaskSettingsSet -StartWhenAvailable -DontStopOnIdleEnd -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries