Skip to content

Commit ed51aa9

Browse files
lunnytechknowlogick
authored andcommitted
improve backup document and add zh-cn backup document (#4145)
1 parent d41084c commit ed51aa9

File tree

2 files changed

+62
-1
lines changed

2 files changed

+62
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ directory. There should be some output similar to the following:
3434

3535
Inside the `gitea-dump-1482906742.zip` file, will be the following:
3636

37-
* `custom/conf/app.ini` - Server config.
37+
* `custom` - All config or customerize files in `custom/`.
38+
* `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.
3839
* `gitea-db.sql` - SQL dump of database
3940
* `gitea-repo.zip` - Complete copy of the repository directory.
4041
* `log/` - Various logs. They are not needed for a recovery or migration.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
date: "2018-06-06T09:33:00+08:00"
3+
title: "使用: 备份与恢复"
4+
slug: "backup-and-restore"
5+
weight: 11
6+
toc: true
7+
draft: false
8+
menu:
9+
sidebar:
10+
parent: "usage"
11+
name: "备份与恢复"
12+
weight: 11
13+
identifier: "backup-and-restore"
14+
---
15+
16+
# 备份与恢复
17+
18+
Gitea 已经实现了 `dump` 命令可以用来备份所有需要的文件到一个zip压缩文件。该压缩文件可以被用来进行数据恢复。
19+
20+
## 备份命令 (`dump`)
21+
22+
先转到git用户的权限: `su git`. 再Gitea目录运行 `./gitea dump`。一般会显示类似如下的输出:
23+
24+
```
25+
2016/12/27 22:32:09 Creating tmp work dir: /tmp/gitea-dump-417443001
26+
2016/12/27 22:32:09 Dumping local repositories.../home/git/gitea-repositories
27+
2016/12/27 22:32:22 Dumping database...
28+
2016/12/27 22:32:22 Packing dump files...
29+
2016/12/27 22:32:34 Removing tmp work dir: /tmp/gitea-dump-417443001
30+
2016/12/27 22:32:34 Finish dumping in file gitea-dump-1482906742.zip
31+
```
32+
33+
最后生成的 `gitea-dump-1482906742.zip` 文件将会包含如下内容:
34+
35+
* `custom` - 所有保存在 `custom/` 目录下的配置和自定义的文件。
36+
* `data` - 数据目录下的所有内容不包含使用文件session的文件。该目录包含 `attachments`, `avatars`, `lfs`, `indexers`, 如果使用sqlite 还会包含 sqlite 数据库文件。
37+
* `gitea-db.sql` - 数据库dump出来的 SQL。
38+
* `gitea-repo.zip` - Git仓库压缩文件。
39+
* `log/` - Logs文件,如果用作迁移不是必须的。
40+
41+
中间备份文件将会在临时目录进行创建,如果您要重新指定临时目录,可以用 `--tempdir` 参数,或者用 `TMPDIR` 环境变量。
42+
43+
## Restore Command (`restore`)
44+
45+
当前还没有恢复命令,恢复需要人工进行。主要是把文件和数据库进行恢复。
46+
47+
例如:
48+
49+
```
50+
apt-get install gitea
51+
unzip gitea-dump-1482906742.zip
52+
cd gitea-dump-1482906742
53+
mv custom/conf/app.ini /etc/gitea/conf/app.ini
54+
unzip gitea-repo.zip
55+
mv gitea-repo/* /var/lib/gitea/repositories/
56+
chown -R gitea:gitea /etc/gitea/conf/app.ini /var/lib/gitea/repositories/
57+
mysql -u$USER -p$PASS $DATABASE <gitea-db.sql
58+
# or sqlite3 $DATABASE_PATH <gitea-db.sql
59+
service gitea restart
60+
```

0 commit comments

Comments
 (0)