You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

backup-and-restore.zh-cn.md 2.2 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. Gitea 已经实现了 `dump` 命令可以用来备份所有需要的文件到一个zip压缩文件。该压缩文件可以被用来进行数据恢复。
  17. ## 备份命令 (`dump`)
  18. 先转到git用户的权限: `su git`. 再Gitea目录运行 `./gitea dump`。一般会显示类似如下的输出:
  19. ```
  20. 2016/12/27 22:32:09 Creating tmp work dir: /tmp/gitea-dump-417443001
  21. 2016/12/27 22:32:09 Dumping local repositories.../home/git/gitea-repositories
  22. 2016/12/27 22:32:22 Dumping database...
  23. 2016/12/27 22:32:22 Packing dump files...
  24. 2016/12/27 22:32:34 Removing tmp work dir: /tmp/gitea-dump-417443001
  25. 2016/12/27 22:32:34 Finish dumping in file gitea-dump-1482906742.zip
  26. ```
  27. 最后生成的 `gitea-dump-1482906742.zip` 文件将会包含如下内容:
  28. * `custom` - 所有保存在 `custom/` 目录下的配置和自定义的文件。
  29. * `data` - 数据目录下的所有内容不包含使用文件session的文件。该目录包含 `attachments`, `avatars`, `lfs`, `indexers`, 如果使用sqlite 还会包含 sqlite 数据库文件。
  30. * `gitea-db.sql` - 数据库dump出来的 SQL。
  31. * `gitea-repo.zip` - Git仓库压缩文件。
  32. * `log/` - Logs文件,如果用作迁移不是必须的。
  33. 中间备份文件将会在临时目录进行创建,如果您要重新指定临时目录,可以用 `--tempdir` 参数,或者用 `TMPDIR` 环境变量。
  34. ## Restore Command (`restore`)
  35. 当前还没有恢复命令,恢复需要人工进行。主要是把文件和数据库进行恢复。
  36. 例如:
  37. ```
  38. apt-get install gitea
  39. unzip gitea-dump-1482906742.zip
  40. cd gitea-dump-1482906742
  41. mv custom/conf/app.ini /etc/gitea/conf/app.ini
  42. unzip gitea-repo.zip
  43. mv gitea-repo/* /var/lib/gitea/repositories/
  44. chown -R gitea:gitea /etc/gitea/conf/app.ini /var/lib/gitea/repositories/
  45. mysql --default-character-set=utf8mb4 -u$USER -p$PASS $DATABASE <gitea-db.sql
  46. # or sqlite3 $DATABASE_PATH <gitea-db.sql
  47. service gitea restart
  48. ```