githaven-fork/docs/content/doc/administration/backup-and-restore.zh-tw.md
John Olheiser bb25f85ce8
Refactor docs (#23752)
This was intended to be a small followup for
https://github.com/go-gitea/gitea/pull/23712, but...here we are.

1. Our docs currently use `slug` as the entire URL, which makes
refactoring tricky (see https://github.com/go-gitea/gitea/pull/23712).
Instead, this PR attempts to make future refactoring easier by using
slugs as an extension of the section. (Hugo terminology)
- What the above boils down to is this PR attempts to use directory
organization as URL management. e.g. `usage/comparison.en-us.md` ->
`en-us/usage/comparison/`, `usage/packages/overview.en-us.md` ->
`en-us/usage/packages/overview/`
- Technically we could even remove `slug`, as Hugo defaults to using
filename, however at least with this PR it means `slug` only needs to be
the name for the **current file** rather than an entire URL
2. This PR adds appropriate aliases (redirects) for pages, so anything
on the internet that links to our docs should hopefully not break.
3. A minor nit I've had for a while, renaming `seek-help` to `support`.
It's a minor thing, but `seek-help` has a strange connotation to it.
4. The commits are split such that you can review the first which is the
"actual" change, and the second is added redirects so that the first
doesn't break links elsewhere.

---------

Signed-off-by: jolheiser <john.olheiser@gmail.com>
2023-04-28 11:33:41 +08:00

2.1 KiB

date title slug weight toc draft aliases menu
2017-01-01T16:00:00+02:00 用法: 備份與還原 backup-and-restore 11 false false
/zh-tw/backup-and-restore
sidebar
parent name weight identifier
administration 備份與還原 11 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)

持續更新中: 此文件尚未完成.

例:

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