summaryrefslogtreecommitdiff
path: root/docs/locales/zh/advanced/replicating-sqlite.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/locales/zh/advanced/replicating-sqlite.md')
-rw-r--r--docs/locales/zh/advanced/replicating-sqlite.md102
1 files changed, 102 insertions, 0 deletions
diff --git a/docs/locales/zh/advanced/replicating-sqlite.md b/docs/locales/zh/advanced/replicating-sqlite.md
new file mode 100644
index 000000000..13361fc35
--- /dev/null
+++ b/docs/locales/zh/advanced/replicating-sqlite.md
@@ -0,0 +1,102 @@
+# 配置 SQLite 副本
+
+除了常规的[备份方法](../admin/backup_and_restore.md)之外,你可能还想设置副本功能,以便在发生灾难时恢复到另一个路径或外部主机。
+
+为了使其正常工作,SQLite 需要将日志模式配置为 `WAL` 模式,且同步模式设置为 `NORMAL`。这是 GoToSocial 的默认配置。
+
+你可以在配置文件中检查你的设置。日志模式在 `db-sqlite-journal-mode` 中设置,同步模式在 `db-sqlite-synchronous` 中设置。
+
+## Linux 下的 Litestream
+
+使用 [Litestream](https://litestream.io) 是设置 SQLite 副本的一种相对轻量且快速的方法。它可以很容易地配置,并支持不同的后端,比如基于文件的副本、兼容 S3 的存储和许多其他设置。
+
+你可以通过在 Linux 上使用 deb 文件安装预构建的软件包,或在其他发行版上从源代码构建。
+
+在 Linux 上使用 .deb 包:
+
+转到 [releases page](https://github.com/benbjohnson/litestream/releases/latest),下载最新版本(确保为下面的 wget 命令选择合适的平台)。
+
+```bash
+wget https://github.com/benbjohnson/litestream/releases/download/v0.3.13/litestream-v0.3.13-linux-amd64.deb
+sudo dpkg -i litestream-*.deb
+```
+
+## 配置 Litestream
+
+通过编辑配置文件进行配置。文件位于 /etc/litestream.yml。
+
+### 配置基于文件的副本
+
+```yaml
+dbs:
+ - path: /gotosocial/sqlite.db
+ - path: /backup/sqlite.db
+```
+
+### 配置基于 S3 的副本
+
+设置一个用于副本的桶,并确保将其设置为私有。
+确保用你仪表板中的正确值替换示例中的 `access-key-id` 和 `secret-access-key`。
+
+```yaml
+access-key-id: AKIAJSIE27KKMHXI3BJQ
+secret-access-key: 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
+
+dbs:
+ - path: /gotosocial/sqlite.db
+ - url: s3://my.bucket.com/db
+```
+
+使用兼容 S3 的存储提供商时,你需要设置一个端点。
+例如,对 minio 可以使用以下配置。
+
+```yaml
+access-key-id: miniouser
+secret-access-key: miniopassword
+
+dbs:
+ - path: /gotosocial/sqlite.db
+ - type: s3
+ bucket: mybucket
+ path: sqlite.db
+ endpoint: minio:9000
+```
+
+## 启用副本
+
+你可以通过启用 Litestream 服务在 Linux 上启用副本。
+
+```bash
+sudo systemctl enable litestream
+sudo systemctl start litestream
+```
+
+使用 `sudo journalctl -u litestream -f` 检查其是否正常运行。
+
+如果你需要更改配置文件,请重启 Litestream:
+
+```bash
+sudo systemctl restart litestream
+```
+
+### 从配置的后端恢复
+
+你可以使用以下简单命令从存储的后端拉取恢复文件。
+
+```bash
+sudo litestream restore
+```
+
+如果你配置了多个文件备份或有多个副本,请指定你要执行的操作。
+
+对于基于文件的副本:
+
+```bash
+sudo litestream restore -o /gotosocial/sqlite.db /backup/sqlite.db
+```
+
+对于基于 S3 的副本:
+
+```bash
+sudo litestream restore -o /gotosocial/sqlite.db s3://bucketname/db
+```