Skip to content

Commit 40e87d0

Browse files
singulieredelvh
andauthored
docs: recommendations to ensure backup consistency and reliability (#19845)
* docs: recommendations to ensure backup consistency and reliability * s/stooping/stopping/ * Update docs/content/doc/usage/backup-and-restore.en-us.md Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: delvh <dev.lh@web.de>
1 parent 4a295d4 commit 40e87d0

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Diff for: docs/content/doc/usage/backup-and-restore.en-us.md

+17
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ file can be unpacked and used to restore an instance.
2222

2323
{{< toc >}}
2424

25+
## Backup Consistency
26+
27+
To ensure the consistency of the Gitea instance, it must be shutdown during backup.
28+
29+
Gitea consists of a database, files and git repositories, all of which change when it is used. For instance, when a migration is in progress, a transaction is created in the database while the git repository is being copied over. If the backup happens in the middle of the migration, the git repository may be incomplete although the database claims otherwise because it was dumped afterwards. The only way to avoid such race conditions is by stopping the Gitea instance during the backups.
30+
2531
## Backup Command (`dump`)
2632

2733
Switch to the user running Gitea: `su git`. Run `./gitea dump -c /path/to/app.ini` in the Gitea installation
@@ -48,6 +54,17 @@ Inside the `gitea-dump-1482906742.zip` file, will be the following:
4854
Intermediate backup files are created in a temporary directory specified either with the
4955
`--tempdir` command-line parameter or the `TMPDIR` environment variable.
5056

57+
## Backup the database
58+
59+
The SQL dump created by `gitea dump` uses XORM and Gitea admins may prefer to use the native the MySQL and PostgreSQL dump tools instead. There are still open issues when using XORM for dumping the database that may cause problems when attempting to restore it.
60+
61+
```sh
62+
# mysql
63+
mysqldump -u$USER -p$PASS --database $DATABASE > gitea-db.sql
64+
# postgres
65+
pgdump -U $USER $DATABASE > gitea-db.sql
66+
```
67+
5168
### Using Docker (`dump`)
5269

5370
There are a few caveats for using the `dump` command with Docker.

0 commit comments

Comments
 (0)