mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-23 08:47:42 -05:00
e8433b7fe6
- **Installation**: includes how to install Gitea and related other tools, also includes upgrade Gitea - **Administration**: includes how to configure Gitea, customize Gitea and manage Gitea instance out of Gitea admin UI - **Usage**: includes how to use Gitea's functionalities. A sub documentation is about packages, in future we could also include CI/CD and others. - **Development**: includes how to integrate with Gitea's API, how to develop new features within Gitea - **Contributing**: includes how to contribute code to Gitea repositories. After this is merged, I think we can have a sub-documentation of `Usage` part named `Actions` to describe how to use Gitea actions --------- Co-authored-by: John Olheiser <john.olheiser@gmail.com>
66 lines
2.1 KiB
Markdown
66 lines
2.1 KiB
Markdown
---
|
|
date: "2017-01-01T16:00:00+02:00"
|
|
title: "用法: 備份與還原"
|
|
slug: "backup-and-restore"
|
|
weight: 11
|
|
toc: false
|
|
draft: false
|
|
menu:
|
|
sidebar:
|
|
parent: "administration"
|
|
name: "備份與還原"
|
|
weight: 11
|
|
identifier: "backup-and-restore"
|
|
---
|
|
|
|
# 備份與還原
|
|
|
|
Gitea 目前支援 `dump` 指令,用來將資料備份成 zip 檔案,後續會提供還原指令,讓你可以輕易的將備份資料及還原到另外一台機器。
|
|
|
|
## 備份指令 (`dump`)
|
|
|
|
首先,切換到執行 Gitea 的使用者: `su git` (請修改成您指定的使用者),並在安裝目錄內執行 `./gitea dump` 指令,你可以看到 console 畫面如下:
|
|
|
|
```
|
|
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
|
|
```
|
|
|
|
備份出來的 `gitea-dump-1482906742.zip` 檔案,檔案內會包含底下內容:
|
|
|
|
* `custom/conf/app.ini` - 伺服器設定檔。
|
|
* `gitea-db.sql` - SQL 備份檔案。
|
|
* `gitea-repo.zip` - 此 zip 檔案為全部的 repo 目錄。
|
|
請參考 Config -> repository -> `ROOT` 所設定的路徑。
|
|
* `log/` - 全部 logs 檔案,如果你要 migrate 到其他伺服器,此目錄不用保留。
|
|
|
|
你可以透過設定 `--tempdir` 指令參數來指定備份檔案目錄,或者是設定 `TMPDIR` 環境變數來達到此功能。
|
|
|
|
## 還原指令 (`restore`)
|
|
|
|
持續更新中: 此文件尚未完成.
|
|
|
|
例:
|
|
|
|
```sh
|
|
unzip gitea-dump-1610949662.zip
|
|
cd gitea-dump-1610949662
|
|
mv data/conf/app.ini /etc/gitea/conf/app.ini
|
|
mv data/* /var/lib/gitea/data/
|
|
mv log/* /var/lib/gitea/log/
|
|
mv repos/* /var/lib/gitea/repositories/
|
|
chown -R gitea:gitea /etc/gitea/conf/app.ini /var/lib/gitea
|
|
|
|
# mysql
|
|
mysql --default-character-set=utf8mb4 -u$USER -p$PASS $DATABASE <gitea-db.sql
|
|
# sqlite3
|
|
sqlite3 $DATABASE_PATH <gitea-db.sql
|
|
# postgres
|
|
psql -U $USER -d $DATABASE < gitea-db.sql
|
|
|
|
service gitea restart
|
|
```
|