Skip to main content

Overview

Gitea provides built-in commands for backing up and restoring your entire installation, including repositories, database, configuration, and attachments.

Backup

The dump command creates a compressed archive containing all Gitea data.

Basic Backup

This creates a file named gitea-dump-{timestamp}.zip in the current directory.

Specify Output File

Backup to stdout

Backup Options

The dump command supports extensive customization options (see cmd/dump.go:27-97):
--file
string
default:"gitea-dump-{time}.zip"
Output file name. Use - for stdout.
--tempdir
string
default:"system temp dir"
Temporary directory for building the archive
--type
string
default:"zip"
Archive format: zip, tar, tar.gz, tar.xz, tar.bz2, tar.lz4, tar.sz, or tar.zst
--database
string
Database SQL syntax for export: sqlite3, mysql, postgres, mssql. Use this to export to a different database format than currently configured.
--verbose
boolean
default:"false"
Show detailed progress during backup
--quiet
boolean
default:"false"
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:
  1. Database - All database tables and data
  2. Repositories - Git repositories and their data
  3. Configuration - app.ini configuration file
  4. Custom Files - Templates, logos, and customizations
  5. Data Directory - User avatars, attachments, etc.
  6. LFS Objects - Git LFS files (if enabled)
  7. Attachments - Issue and comment attachments
  8. Packages - Package registry data (if enabled)
  9. Logs - Application logs (optional)
The backup structure (from 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 the restore-repo command (see cmd/restore_repo.go):

Selective Repository Restore

Restore specific repository components:
Available units:
  • wiki
  • issues
  • labels
  • releases
  • release_assets
  • milestones
  • pull_requests
  • comments

Validation Before Restore

This performs a sanity check on the backup data before attempting restoration.

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:
Create /etc/systemd/system/gitea-backup.timer:
Enable the 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:
  1. Database restore: 5-30 minutes depending on size
  2. Repository restore: Depends on repository count and size
  3. Configuration: 1-5 minutes
  4. 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

Troubleshooting

Backup Fails with “Permission Denied”

Backup File Too Large

Database Restore Fails