From 61bd4653da0eedc66a9e1b630b0e7f5fa2971b90 Mon Sep 17 00:00:00 2001 From: ttionya Date: Sun, 11 Dec 2022 23:23:33 +0800 Subject: [PATCH] docs: update README --- README.md | 6 ++- README_zh.md | 6 ++- docs/using-the-postgresql-backend.md | 71 ++++++++++++++++++++++++++++ scripts/restore.sh | 2 +- 4 files changed, 80 insertions(+), 5 deletions(-) create mode 100644 docs/using-the-postgresql-backend.md diff --git a/README.md b/README.md index c4dd177..767b416 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,8 @@ The old image can still be used, just **DEPRECATED**. It is recommended to migra This tool supports backing up the following files or directories. -- `db.sqlite3` +- `db.sqlite3` (for SQLite database) +- `db.dump` (for PostgreSQL database) - `config.json` - `rsa_key*` (multiple files) - `attachments` (directory) @@ -213,7 +214,7 @@ If not, the password will be asked for interactively. ##### --db-file \ -You need to use this option to specify the `db.sqlite3` file. +You need to use this option to specify the `db.*` file. ##### --config-file \ @@ -491,6 +492,7 @@ We recommend re-downloading the `docker-compose.yml` file, replacing your enviro - [Run as non-root user](docs/run-as-non-root-user.md) - [Multiple remote destinations](docs/multiple-remote-destinations.md) +- [Using the PostgreSQL backend](docs/using-the-postgresql-backend.md)
diff --git a/README_zh.md b/README_zh.md index f0da5de..3a2d38a 100644 --- a/README_zh.md +++ b/README_zh.md @@ -31,7 +31,8 @@ 本工具会备份以下文件或目录。 -- `db.sqlite3` +- `db.sqlite3` (SQLite 数据库) +- `db.dump` (PostgreSQL 数据库) - `config.json` - `rsa_key*` (多个文件) - `attachments` (目录) @@ -211,7 +212,7 @@ docker run --rm -it \ ##### --db-file \ -你需要用这个选项来指定 `db.sqlite3` 文件。 +你需要用这个选项来指定 `db.*` 文件。 ##### --config-file \ @@ -488,6 +489,7 @@ docker run --rm -it -e MAIL_SMTP_VARIABLES='' -e MAIL_TO='< - [以非 root 用户运行](docs/run-as-non-root-user.md) - [备份到多个远程目标](docs/multiple-remote-destinations.md) +- [使用 PostgreSQL 数据库](docs/using-the-postgresql-backend.md)
diff --git a/docs/using-the-postgresql-backend.md b/docs/using-the-postgresql-backend.md new file mode 100644 index 0000000..88a1356 --- /dev/null +++ b/docs/using-the-postgresql-backend.md @@ -0,0 +1,71 @@ +# Using the PostgreSQL backend + +Now supports PostgreSQL backend. + +Because upstream Rclone image is based on `alpine 3.16`(and `linux/arm/v6` platform is based on `alpine 3.15`), it **only supports PostgreSQL 14 and previous versions**, see [Alpine 3.16 Packages](https://pkgs.alpinelinux.org/packages?name=postgresql*-client&branch=v3.16) and [Alpine 3.15 Packages](https://pkgs.alpinelinux.org/packages?name=postgresql*-client&branch=v3.15). + +
+ + + +## Environment Variables + +#### DB_TYPE + +Set to `postgresql` switch to PostgreSQL database. + +Default: `sqlite` + +#### PG_HOST + +PostgreSQL host, **required**. + +#### PG_PORT + +PostgreSQL port. + +Default: `5432` + +#### PG_DBNAME + +PostgreSQL database name. + +Default: `vaultwarden` + +#### PG_USERNAME + +PostgreSQL username. + +Default: `vaultwarden` + +#### PG_PASSWORD + +PostgreSQL password, **required**. + +The login information will be saved in the `~/.pgpass` file. + +
+ + + +## Backup + +Specify the above environment variables to switch to the PostgreSQL database. + +
+ + + +## Restore + +When restoring, also specify the above environment variables to switch to the PostgreSQL database. + +1. Ensure that the database is accessible. + +Perhaps you will use the `docker-compose up -d [services name]` command to start the database separately. + +2. Verify that the `PG_HOST` you are using is accessible to. + +If your database is running in docker-compose, you need to find the corresponding network name via `docker network ls` and add `--network=[name]` to the restore command to specify the network name. + +3. Restore and restart the container. diff --git a/scripts/restore.sh b/scripts/restore.sh index 327e86b..1b0f08f 100644 --- a/scripts/restore.sh +++ b/scripts/restore.sh @@ -76,7 +76,7 @@ function restore_db_sqlite() { } function restore_db_postgresql() { - color blue "restore vaultwarden sqlite database" + color blue "restore vaultwarden postgresql database" pg_restore -h "${PG_HOST}" -p "${PG_PORT}" -d "${PG_DBNAME}" -U "${PG_USERNAME}" -c "${RESTORE_FILE_DB}"