Overview
Gitea provides built-in commands for backing up and restoring your entire installation, including repositories, database, configuration, and attachments.Backup
Thedump command creates a compressed archive containing all Gitea data.
Basic Backup
gitea-dump-{timestamp}.zip in the current directory.
Specify Output File
Backup to stdout
Backup Options
The dump command supports extensive customization options (seecmd/dump.go:27-97):
Output file name. Use
- for stdout.Temporary directory for building the archive
Archive format:
zip, tar, tar.gz, tar.xz, tar.bz2, tar.lz4, tar.sz, or tar.zstDatabase SQL syntax for export:
sqlite3, mysql, postgres, mssql.
Use this to export to a different database format than currently configured.Show detailed progress during backup
Only show warnings and errors
Selective Backup
You can exclude specific components from the backup:Combine Multiple Options
What’s Included in a Backup
A complete Gitea backup includes:- Database - All database tables and data
- Repositories - Git repositories and their data
- Configuration -
app.iniconfiguration file - Custom Files - Templates, logos, and customizations
- Data Directory - User avatars, attachments, etc.
- LFS Objects - Git LFS files (if enabled)
- Attachments - Issue and comment attachments
- Packages - Package registry data (if enabled)
- Logs - Application logs (optional)
cmd/dump.go:164-324):
Restore
Restoring from a backup involves extracting the archive and placing files in the correct locations.Complete Restore
1
Stop Gitea
2
Extract Backup
3
Restore Database
4
Restore Files
5
Fix Permissions
6
Start Gitea
Repository-Level Restore
Restore a single repository using therestore-repo command (see cmd/restore_repo.go):
Selective Repository Restore
Restore specific repository components:wikiissueslabelsreleasesrelease_assetsmilestonespull_requestscomments
Validation Before Restore
Automated Backup
Create a backup script for automated backups:backup.sh
Schedule with Cron
Schedule with systemd Timer
Create/etc/systemd/system/gitea-backup.service:
/etc/systemd/system/gitea-backup.timer:
Database-Only Backup
For quick database backups without repositories:Disaster Recovery
Backup Verification
Regularly verify your backups:Off-Site Backup
Copy backups to remote storage:Recovery Time Objective (RTO)
Plan for recovery:- Database restore: 5-30 minutes depending on size
- Repository restore: Depends on repository count and size
- Configuration: 1-5 minutes
- Total downtime: Plan for 30-60 minutes for most installations
Best Practices
- Regular Backups: Daily backups for production systems
- Test Restores: Regularly test your backup restoration process
- Multiple Locations: Store backups in multiple locations (on-site and off-site)
- Encryption: Encrypt backups containing sensitive data
- Retention Policy: Define how long to keep backups (e.g., 30 days)
- Monitoring: Alert on backup failures
- Documentation: Document your backup and restore procedures
- Separate Database Backups: Consider additional database-specific backups