Adds manual backup and restore documentation for PostgreSQL as the recommended database.

This commit is contained in:
John Baumlin 2024-02-21 20:24:34 +09:00
parent d4c7766f5a
commit 3a69bc5ee0

@ -102,16 +102,71 @@ your package manager or download and unpack the new zip files. You
might want to have a look at the changelog, since it is sometimes
necessary to modify the config file.
## More
## Backup & Restore
There are several supported [databases](https://docspell.org/docs/configure/database/) but PostgreSQL is recommended for Docspell.
First to prevent any currently queued data from being lost, it's good practice to
shutdown `docspell-joex` and `docspell-restserver` system services
before taking a database backup of Docspell. In order to stop Docspell,
you need to perform these on the system that docspell is running on.
```bash
sudo systemctl stop docspell-joex
sudo systemctl stop docspell-restserver
```
Next, you can become the `postgres` user or database admin user on
your PostgreSQL server/microservice and backup the database.
Note that this will take some time to complete depending on the size of your database.
We'll assume in our guide example that `docspelldb` is the name of your database:
```bash
pg_dump docspelldb > docspelldb_backup.sql
```
Optionally, once the docspell backup is complete you can
use `rsync` or `scp` to send `docspelldb_backup.sql` to a backup server.
Now that you have known backup(s) of Docspell, you may one day have to restore a backup.
Let's test restoring a backup. You can start a PostgreSQL shell by using
the `psql` command as the `postgres` user or a PostgreSQL admin account.
If the database is corrupted or still exists, you will first need to remove it.
Warning: By performing this next step you are *deleting* your database.
```sql
DROP DATABASE docspelldb;
```
And now we'll create a new database for your backup to restore to.
Optionally, you can add UTF-8 encoding for better multilingual support.
This example will assume the owner of the database is named `docspell`.
```sql
CREATE DATABASE docspelldb WITH OWNER = 'docspell' ENCODING = 'UTF8' template = 'template0';
```
Now that we have a new database, we can restore the backup.
Exit your database with `\q` and in bash execute the following
commands as the `postgres` or admin user.
This command will also take some time to complete.
```bash
psql docspelldb < docspelldb_backup.sql
```
Now your database should be fully restored from your backup!
Let's go to the Docspell server and restart the Docspell services.
```bash
sudo systemctl stop docspell-joex
sudo systemctl stop docspell-restserver
```
If your database and owner are the same as your initial configuration,
and you see your docspell data restored, you have sucessfully restored
your PostgreSQL backup of Docspell manually.
### Fulltext Search
Fulltext search is powered by [SOLR](https://solr.apache.org). You
need to install solr and create a core for docspell. Then cange the
Fulltext search can also be powered by [SOLR](https://solr.apache.org).
You need to install solr and create a core for docspell. Then cange the
solr url for both components (restserver and joex) accordingly. See
the relevant section in the [config
page](@/docs/configure/fulltext-search.md).
the relevant section in the [config page](@/docs/configure/fulltext-search.md).
### Watching a directory