2017-11-26 15:44:32 -06:00
---
date: "2017-01-01T16:00:00+02:00"
title: "Usage: Backup and Restore"
slug: "backup-and-restore"
weight: 11
toc: true
draft: false
menu:
sidebar:
parent: "usage"
name: "Backup and Restore"
weight: 11
identifier: "backup-and-restore"
---
# Backup and Restore
2018-01-08 16:48:42 -06:00
Gitea currently has a `dump` command that will save the installation to a zip file. This
file can be unpacked and used to restore an instance.
2017-11-26 15:44:32 -06:00
## Backup Command (`dump`)
2018-06-09 14:16:16 -05:00
Switch to the user running gitea: `su git` . Run `./gitea dump -c /path/to/app.ini` in the gitea installation
2018-01-08 16:48:42 -06:00
directory. There should be some output similar to the following:
2017-11-26 15:44:32 -06:00
```
2016/12/27 22:32:09 Creating tmp work dir: /tmp/gitea-dump-417443001
2016/12/27 22:32:09 Dumping local repositories.../home/git/gitea-repositories
2016/12/27 22:32:22 Dumping database...
2016/12/27 22:32:22 Packing dump files...
2016/12/27 22:32:34 Removing tmp work dir: /tmp/gitea-dump-417443001
2016/12/27 22:32:34 Finish dumping in file gitea-dump-1482906742.zip
```
2018-01-08 16:48:42 -06:00
Inside the `gitea-dump-1482906742.zip` file, will be the following:
2017-11-26 15:44:32 -06:00
2019-04-05 08:24:28 -05:00
* `app.ini` - Optional copy of configuration file if originally stored outside of the default `custom/` directory
2018-06-08 18:47:51 -05:00
* `custom` - All config or customerize files in `custom/` .
* `data` - Data directory in < GITEA_WORK_DIR > , except sessions if you are using file session. This directory includes `attachments` , `avatars` , `lfs` , `indexers` , sqlite file if you are using sqlite.
2018-01-08 16:48:42 -06:00
* `gitea-db.sql` - SQL dump of database
* `gitea-repo.zip` - Complete copy of the repository directory.
* `log/` - Various logs. They are not needed for a recovery or migration.
2017-11-26 15:44:32 -06:00
2018-01-08 16:48:42 -06:00
Intermediate backup files are created in a temporary directory specified either with the
`--tempdir` command-line parameter or the `TMPDIR` environment variable.
2017-11-26 15:44:32 -06:00
## Restore Command (`restore`)
2018-01-08 16:48:42 -06:00
There is currently no support for a recovery command. It is a manual process that mostly
involves moving files to their correct locations and restoring a database dump.
Example:
```
apt-get install gitea
unzip gitea-dump-1482906742.zip
cd gitea-dump-1482906742
2019-04-05 08:24:28 -05:00
mv custom/conf/app.ini /etc/gitea/conf/app.ini # or mv app.ini /etc/gitea/conf/app.ini
2018-01-08 16:48:42 -06:00
unzip gitea-repo.zip
mv gitea-repo/* /var/lib/gitea/repositories/
chown -R gitea:gitea /etc/gitea/conf/app.ini /var/lib/gitea/repositories/
mysql -u$USER -p$PASS $DATABASE < gitea-db.sql
# or sqlite3 $DATABASE_PATH <gitea-db.sql
service gitea restart
```