Files
gitea-docker/BACKUP-README.md

2.2 KiB

Gitea Backup Strategy

This document outlines the backup strategy for your Gitea installation, focusing on ensuring your database is always backed up in at least one place.

Backup Methods

This setup provides two complementary backup methods:

1. PostgreSQL Database Dumps

Database dumps are SQL files containing all your database data. These are the most reliable way to back up a PostgreSQL database.

  • Script: backup-gitea-db.ps1
  • Output: SQL dumps in the backups directory, compressed as ZIP files
  • Retention: Keeps the last 10 backups by default

2. Docker Volume Backups

This method backs up the entire PostgreSQL data volume, which includes all database files.

  • Script: backup-volume.ps1
  • Output: TAR archives in the backups directory, compressed as ZIP files
  • Retention: Keeps the last 5 volume backups by default

Automated Backups

You can set up automated daily backups using the included script:

.\schedule-backup.ps1

This creates a Windows Scheduled Task that runs the database backup script daily at 3 AM.

Restoring from Backups

Restoring from a Database Dump

.\restore-gitea-db.ps1 -BackupFile "backups\gitea-db-backup-2025-03-01_10-30-00.sql.zip"

Restoring from a Volume Backup

.\restore-volume.ps1 -BackupFile "backups\postgres-volume-backup-2025-03-01_10-30-00.tar.zip"

Best Practices

  1. Regular Backups: Run backups at least daily
  2. Multiple Backup Methods: Use both database dumps and volume backups
  3. Off-site Storage: Copy your backups to an external drive or cloud storage
  4. Test Restores: Periodically test restoring from your backups
  5. Version Control: Keep your Gitea configuration files in version control

Important Notes

  • Never run docker-compose down -v unless you have a recent backup
  • When upgrading Gitea, always create a backup first
  • The database volume (postgres-data) persists even when containers are stopped or removed, but can be lost if explicitly deleted

Manual Backup Commands

If you need to create a backup manually:

# Database dump
.\backup-gitea-db.ps1

# Volume backup
.\backup-volume.ps1