paperless-ngx/docs/administration.md
Michael Shamoon cd5432fec0 Squashed commit of the following:
commit b1410a854e03087023c89998b14c3296ac669f1f
Merge: f9ce4d8f 8ec9c77e
Author: shamoon <4887959+shamoon@users.noreply.github.com>
Date:   Thu Dec 29 20:09:09 2022 -0800

    Merge pull request #2263 from paperless-ngx/v1.11.0-changelog

    [Documentation] Add v1.11.0 changelog

commit 8ec9c77e51dc492f6b7f468ab533204848a554b3
Author: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Date:   Fri Dec 30 04:08:17 2022 +0000

    Changelog v1.11.0 - GHA

commit f9ce4d8f6a9086d21f7f9c5411a28dd8b0b7135e
Author: Michael Shamoon <4887959+shamoon@users.noreply.github.com>
Date:   Thu Dec 29 19:40:25 2022 -0800

    Update version strings for 1.11.0

commit 8c9a74ee0ca03d1f1afd7dee9203648d48bb33c1
Merge: 605f86f0 0b59ef2c
Author: Michael Shamoon <4887959+shamoon@users.noreply.github.com>
Date:   Thu Dec 29 19:39:38 2022 -0800

    Merge branch 'dev'

commit 605f86f0cfb908761d2f71d7e17c1e60668b7edf
Merge: 800e842a 8cbaca22
Author: shamoon <4887959+shamoon@users.noreply.github.com>
Date:   Wed Dec 28 15:55:35 2022 -0800

    Merge pull request #2256 from mendelk/patch-1

    Fixed typo in docs

commit 8cbaca22c12b5f3129b52a376dd56f00600f27be
Author: Mendel Kramer <mendelk@users.noreply.github.com>
Date:   Wed Dec 28 18:16:00 2022 -0500

    Fixed typo in docs

commit 800e842ab304ce2fcb1c126d491dac0770ad66ff
Author: ThellraAK <github.com@absurdlybored.com>
Date:   Wed Dec 21 01:36:37 2022 -0900

    Removing Mariadb default open port (#2227)

    * Removing Mariadb default open port

    Removing the listening port 3306 for the DB, Docker networks will let the containers talk to one another.  The existing setup would allow anyone to connect to the DB and use the default passwords.

    * Update docker-compose.mariadb-tika.yml

    Adding change to the other compose file to remove open port

    * Remove excess blank lines

    * Remove excess blank lines

    Co-authored-by: Felix E <felix@eckhofer.com>

commit 6f6f365e2b36410110275ca92b5ba467500bb577
Merge: 6d324dbd 43b863b8
Author: shamoon <4887959+shamoon@users.noreply.github.com>
Date:   Sat Dec 17 19:58:06 2022 -0800

    Merge pull request #2203 from tooomm/docs_updates

    Docs: More fixes and improvements

commit 43b863b816337dd19dd9b903e76ecf50b47f1583
Author: tooomm <tooomm@users.noreply.github.com>
Date:   Sun Dec 11 19:44:18 2022 +0100

    doc fixes

    This reverts commit e015babdc102a65a3cce0cc71812d3eb730da92e.

    link fix

    fix escaping, spacing, profile links, typo

    revert

    ~~add~~ at fixes

    Revert "~~add~~ at fixes"

    This reverts commit ce0192b733c19614048de81ea917660e25bb35f2.

commit 6d324dbd8e73c5acdd3b53fd9013c70c53d012e1
Author: shamoon <4887959+shamoon@users.noreply.github.com>
Date:   Fri Dec 16 09:10:11 2022 -0800

    Update config.yml

commit 8ddf05e573c4bc2a55ef6d20f5e36181ccf534b5
Author: shamoon <4887959+shamoon@users.noreply.github.com>
Date:   Fri Dec 16 09:09:48 2022 -0800

    Update bug-report.yml

commit 0472dfe25a02b3bc9b148f435bcda6e2e2987355
Author: tooomm <tooomm@users.noreply.github.com>
Date:   Sun Dec 11 19:12:58 2022 +0100

    Docs: Fix leftover issues from conversion (#2172)

commit 8b36c9ad64bb7638e33d9cb22217f3d8345d5c1e
Author: tooomm <tooomm@users.noreply.github.com>
Date:   Sun Dec 11 16:07:08 2022 +0100

    more fixes and cleanup

commit 1266f2d5b948b7d99dab267e34840ece6a3fbaa4
Author: tooomm <tooomm@users.noreply.github.com>
Date:   Sun Dec 11 12:06:15 2022 +0100

    fix links

commit 81960519592095df714fb0e0f7a0e907488fa269
Merge: 06a6eb03 d198142a
Author: shamoon <4887959+shamoon@users.noreply.github.com>
Date:   Fri Dec 9 16:12:20 2022 -0800

    Merge pull request #2157 from Weltraumschaf/patch-1

    Update setup.md

commit d198142a1ef8cdcaa0d19d126d67b4ade754fceb
Author: Sven Strittmatter <ich@weltraumschaf.de>
Date:   Fri Dec 9 22:09:06 2022 +0100

    Update setup.md

    W/o the slash it resolves to /setup/configuration/ which does 404.

commit 06a6eb0326af6eb3bbe523b0c0061fc324578834
Author: Michael Shamoon <4887959+shamoon@users.noreply.github.com>
Date:   Fri Dec 9 08:15:03 2022 -0800

    fix code block indentation

commit 28819d6d0fb77b8f6030865b0c0d2a1b74a39cad
Author: shamoon <4887959+shamoon@users.noreply.github.com>
Date:   Fri Dec 9 08:11:42 2022 -0800

    Fix code block indentation

commit 8cd5e25364768512af90c773c6a2d307cf59febe
Merge: 32d54674 7788d932
Author: shamoon <4887959+shamoon@users.noreply.github.com>
Date:   Tue Dec 6 11:23:15 2022 -0800

    Merge pull request #2137 from paperless-ngx/more-docs-cleanup

    Chore: Cleanup of new documentation

commit 7788d932275fd108f6ab9425b1daeabd2c931422
Author: Trenton Holmes <797416+stumpylog@users.noreply.github.com>
Date:   Sun Dec 4 08:34:49 2022 -0800

    Further cleanup of docs, including fixing autoconvert issues and general cleanups

commit 32d546740bd4f086369d1a81ddb6658b2f9298b0
Merge: b0ca57a7 24da3e50
Author: shamoon <4887959+shamoon@users.noreply.github.com>
Date:   Sun Dec 4 19:12:27 2022 -0800

    Merge pull request #2118 from alexander-bauer/chart-bump

commit 24da3e50342d3494ba93c83a601c8f44c635e43d
Author: Alexander Bauer <sasha@linux.com>
Date:   Mon Dec 5 02:51:35 2022 +0000

    Bump Helm Chart version to trigger release

commit b0ca57a7f0e5694f5442303e6b17cf6abe120f9a
Merge: cdd49c51 c864b3cd
Author: shamoon <4887959+shamoon@users.noreply.github.com>
Date:   Sun Dec 4 14:36:00 2022 -0800

    Merge pull request #2114 from paperless-ngx/v1.10.2-changelog

    [Documentation] Add v1.10.2 changelog

commit cdd49c51426e0de8937210a65e717fb46eea6101
Author: Michael Shamoon <4887959+shamoon@users.noreply.github.com>
Date:   Sun Dec 4 14:32:08 2022 -0800

    Update frontend compilation info

commit c864b3cd19da3dc37f2f3ba3afa34cfcb73892a8
Author: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Date:   Sun Dec 4 21:17:16 2022 +0000

    Changelog v1.10.2 - GHA
2022-12-29 20:09:58 -08:00

505 lines
16 KiB
Markdown

# Administration
## Making backups {#backup}
Multiple options exist for making backups of your paperless instance,
depending on how you installed paperless.
Before making backups, make sure that paperless is not running.
Options available to any installation of paperless:
- Use the [document exporter](#exporter). The document exporter exports all your documents,
thumbnails and metadata to a specific folder. You may import your
documents into a fresh instance of paperless again or store your
documents in another DMS with this export.
- The document exporter is also able to update an already existing
export. Therefore, incremental backups with `rsync` are entirely
possible.
!!! caution
You cannot import the export generated with one version of paperless in
a different version of paperless. The export contains an exact image of
the database, and migrations may change the database layout.
Options available to docker installations:
- Backup the docker volumes. These usually reside within
`/var/lib/docker/volumes` on the host and you need to be root in
order to access them.
Paperless uses 4 volumes:
- `paperless_media`: This is where your documents are stored.
- `paperless_data`: This is where auxillary data is stored. This
folder also contains the SQLite database, if you use it.
- `paperless_pgdata`: Exists only if you use PostgreSQL and
contains the database.
- `paperless_dbdata`: Exists only if you use MariaDB and contains
the database.
Options available to bare-metal and non-docker installations:
- Backup the entire paperless folder. This ensures that if your
paperless instance crashes at some point or your disk fails, you can
simply copy the folder back into place and it works.
When using PostgreSQL or MariaDB, you'll also have to backup the
database.
### Restoring {#migrating-restoring}
## Updating Paperless {#updating}
### Docker Route {#docker-updating}
If a new release of paperless-ngx is available, upgrading depends on how
you installed paperless-ngx in the first place. The releases are
available at the [release
page](https://github.com/paperless-ngx/paperless-ngx/releases).
First of all, ensure that paperless is stopped.
```shell-session
$ cd /path/to/paperless
$ docker-compose down
```
After that, [make a backup](#backup).
1. If you pull the image from the docker hub, all you need to do is:
```shell-session
$ docker-compose pull
$ docker-compose up
```
The docker-compose files refer to the `latest` version, which is
always the latest stable release.
2. If you built the image yourself, do the following:
```shell-session
$ git pull
$ docker-compose build
$ docker-compose up
```
Running `docker-compose up` will also apply any new database migrations.
If you see everything working, press CTRL+C once to gracefully stop
paperless. Then you can start paperless-ngx with `-d` to have it run in
the background.
!!! note
In version 0.9.14, the update process was changed. In 0.9.13 and
earlier, the docker-compose files specified exact versions and pull
won't automatically update to newer versions. In order to enable
updates as described above, either get the new `docker-compose.yml`
file from
[here](https://github.com/paperless-ngx/paperless-ngx/tree/master/docker/compose)
or edit the `docker-compose.yml` file, find the line that says
```
image: ghcr.io/paperless-ngx/paperless-ngx:0.9.x
```
and replace the version with `latest`:
```
image: ghcr.io/paperless-ngx/paperless-ngx:latest
```
!!! note
In version 1.7.1 and onwards, the Docker image can now be pinned to a
release series. This is often combined with automatic updaters such as
Watchtower to allow safer unattended upgrading to new bugfix releases
only. It is still recommended to always review release notes before
upgrading. To pin your install to a release series, edit the
`docker-compose.yml` find the line that says
```
image: ghcr.io/paperless-ngx/paperless-ngx:latest
```
and replace the version with the series you want to track, for
example:
```
image: ghcr.io/paperless-ngx/paperless-ngx:1.7
```
### Bare Metal Route {#bare-metal-updating}
After grabbing the new release and unpacking the contents, do the
following:
1. Update dependencies. New paperless version may require additional
dependencies. The dependencies required are listed in the section
about
[bare metal installations](/setup#bare_metal).
2. Update python requirements. Keep in mind to activate your virtual
environment before that, if you use one.
```shell-session
$ pip install -r requirements.txt
```
3. Migrate the database.
```shell-session
$ cd src
$ python3 manage.py migrate
```
This might not actually do anything. Not every new paperless version
comes with new database migrations.
## Downgrading Paperless {#downgrade-paperless}
Downgrades are possible. However, some updates also contain database
migrations (these change the layout of the database and may move data).
In order to move back from a version that applied database migrations,
you'll have to revert the database migration _before_ downgrading, and
then downgrade paperless.
This table lists the compatible versions for each database migration
number.
| Migration number | Version range |
| ---------------- | --------------- |
| 1011 | 1.0.0 |
| 1012 | 1.1.0 - 1.2.1 |
| 1014 | 1.3.0 - 1.3.1 |
| 1016 | 1.3.2 - current |
Execute the following management command to migrate your database:
```shell-session
$ python3 manage.py migrate documents <migration number>
```
!!! note
Some migrations cannot be undone. The command will issue errors if that
happens.
## Management utilities {#management-commands}
Paperless comes with some management commands that perform various
maintenance tasks on your paperless instance. You can invoke these
commands in the following way:
With docker-compose, while paperless is running:
```shell-session
$ cd /path/to/paperless
$ docker-compose exec webserver <command> <arguments>
```
With docker, while paperless is running:
```shell-session
$ docker exec -it <container-name> <command> <arguments>
```
Bare metal:
```shell-session
$ cd /path/to/paperless/src
$ python3 manage.py <command> <arguments>
```
All commands have built-in help, which can be accessed by executing them
with the argument `--help`.
### Document exporter {#exporter}
The document exporter exports all your data from paperless into a folder
for backup or migration to another DMS.
If you use the document exporter within a cronjob to backup your data
you might use the `-T` flag behind exec to suppress "The input device
is not a TTY" errors. For example:
`docker-compose exec -T webserver document_exporter ../export`
```
document_exporter target [-c] [-f] [-d]
optional arguments:
-c, --compare-checksums
-f, --use-filename-format
-d, --delete
-z --zip
```
`target` is a folder to which the data gets written. This includes
documents, thumbnails and a `manifest.json` file. The manifest contains
all metadata from the database (correspondents, tags, etc).
When you use the provided docker compose script, specify `../export` as
the target. This path inside the container is automatically mounted on
your host on the folder `export`.
If the target directory already exists and contains files, paperless
will assume that the contents of the export directory are a previous
export and will attempt to update the previous export. Paperless will
only export changed and added files. Paperless determines whether a file
has changed by inspecting the file attributes "date/time modified" and
"size". If that does not work out for you, specify
`--compare-checksums` and paperless will attempt to compare file
checksums instead. This is slower.
Paperless will not remove any existing files in the export directory. If
you want paperless to also remove files that do not belong to the
current export such as files from deleted documents, specify `--delete`.
Be careful when pointing paperless to a directory that already contains
other files.
If `-z` or `--zip` is provided, the export will be a zipfile
in the target directory, named according to the current date.
The filenames generated by this command follow the format
`[date created] [correspondent] [title].[extension]`. If you want
paperless to use `PAPERLESS_FILENAME_FORMAT` for exported filenames
instead, specify `--use-filename-format`.
### Document importer {#importer}
The document importer takes the export produced by the [Document
exporter](#exporter) and imports it into paperless.
The importer works just like the exporter. You point it at a directory,
and the script does the rest of the work:
```
document_importer source
```
When you use the provided docker compose script, put the export inside
the `export` folder in your paperless source directory. Specify
`../export` as the `source`.
!!! note
Importing from a previous version of Paperless may work, but for best
results it is suggested to match the versions.
### Document retagger {#retagger}
Say you've imported a few hundred documents and now want to introduce a
tag or set up a new correspondent, and apply its matching to all of the
currently-imported docs. This problem is common enough that there are
tools for it.
```
document_retagger [-h] [-c] [-T] [-t] [-i] [--use-first] [-f]
optional arguments:
-c, --correspondent
-T, --tags
-t, --document_type
-s, --storage_path
-i, --inbox-only
--use-first
-f, --overwrite
```
Run this after changing or adding matching rules. It'll loop over all
of the documents in your database and attempt to match documents
according to the new rules.
Specify any combination of `-c`, `-T`, `-t` and `-s` to have the
retagger perform matching of the specified metadata type. If you don't
specify any of these options, the document retagger won't do anything.
Specify `-i` to have the document retagger work on documents tagged with
inbox tags only. This is useful when you don't want to mess with your
already processed documents.
When multiple document types or correspondents match a single document,
the retagger won't assign these to the document. Specify `--use-first`
to override this behavior and just use the first correspondent or type
it finds. This option does not apply to tags, since any amount of tags
can be applied to a document.
Finally, `-f` specifies that you wish to overwrite already assigned
correspondents, types and/or tags. The default behavior is to not assign
correspondents and types to documents that have this data already
assigned. `-f` works differently for tags: By default, only additional
tags get added to documents, no tags will be removed. With `-f`, tags
that don't match a document anymore get removed as well.
### Managing the Automatic matching algorithm
The _Auto_ matching algorithm requires a trained neural network to work.
This network needs to be updated whenever somethings in your data
changes. The docker image takes care of that automatically with the task
scheduler. You can manually renew the classifier by invoking the
following management command:
```
document_create_classifier
```
This command takes no arguments.
### Managing the document search index {#index}
The document search index is responsible for delivering search results
for the website. The document index is automatically updated whenever
documents get added to, changed, or removed from paperless. However, if
the search yields non-existing documents or won't find anything, you
may need to recreate the index manually.
```
document_index {reindex,optimize}
```
Specify `reindex` to have the index created from scratch. This may take
some time.
Specify `optimize` to optimize the index. This updates certain aspects
of the index and usually makes queries faster and also ensures that the
autocompletion works properly. This command is regularly invoked by the
task scheduler.
### Managing filenames {#renamer}
If you use paperless' feature to
[assign custom filenames to your documents](/advanced_usage#file-name-handling), you can use this command to move all your files after
changing the naming scheme.
!!! warning
Since this command moves your documents, it is advised to do a backup
beforehand. The renaming logic is robust and will never overwrite or
delete a file, but you can't ever be careful enough.
```
document_renamer
```
The command takes no arguments and processes all your documents at once.
Learn how to use
[Management Utilities](#management-commands).
### Sanity checker {#sanity-checker}
Paperless has a built-in sanity checker that inspects your document
collection for issues.
The issues detected by the sanity checker are as follows:
- Missing original files.
- Missing archive files.
- Inaccessible original files due to improper permissions.
- Inaccessible archive files due to improper permissions.
- Corrupted original documents by comparing their checksum against
what is stored in the database.
- Corrupted archive documents by comparing their checksum against what
is stored in the database.
- Missing thumbnails.
- Inaccessible thumbnails due to improper permissions.
- Documents without any content (warning).
- Orphaned files in the media directory (warning). These are files
that are not referenced by any document im paperless.
```
document_sanity_checker
```
The command takes no arguments. Depending on the size of your document
archive, this may take some time.
### Fetching e-mail
Paperless automatically fetches your e-mail every 10 minutes by default.
If you want to invoke the email consumer manually, call the following
management command:
```
mail_fetcher
```
The command takes no arguments and processes all your mail accounts and
rules.
!!! note
As of October 2022 Microsoft no longer supports IMAP authentication
for Exchange servers, thus Exchange is no longer supported until a
solution is implemented in the Python IMAP library used by Paperless.
See [learn.microsoft.com](https://learn.microsoft.com/en-us/exchange/clients-and-mobile-in-exchange-online/deprecation-of-basic-authentication-exchange-online)
### Creating archived documents {#archiver}
Paperless stores archived PDF/A documents alongside your original
documents. These archived documents will also contain selectable text
for image-only originals. These documents are derived from the
originals, which are always stored unmodified. If coming from an earlier
version of paperless, your documents won't have archived versions.
This command creates PDF/A documents for your documents.
```
document_archiver --overwrite --document <id>
```
This command will only attempt to create archived documents when no
archived document exists yet, unless `--overwrite` is specified. If
`--document <id>` is specified, the archiver will only process that
document.
!!! note
This command essentially performs OCR on all your documents again,
according to your settings. If you run this with
`PAPERLESS_OCR_MODE=redo`, it will potentially run for a very long time.
You can cancel the command at any time, since this command will skip
already archived versions the next time it is run.
!!! note
Some documents will cause errors and cannot be converted into PDF/A
documents, such as encrypted PDF documents. The archiver will skip over
these documents each time it sees them.
### Managing encryption {#encryption}
Documents can be stored in Paperless using GnuPG encryption.
!!! warning
Encryption is deprecated since [paperless-ng 0.9](/changelog#paperless-ng-090) and doesn't really
provide any additional security, since you have to store the passphrase
in a configuration file on the same system as the encrypted documents
for paperless to work. Furthermore, the entire text content of the
documents is stored plain in the database, even if your documents are
encrypted. Filenames are not encrypted as well.
Also, the web server provides transparent access to your encrypted
documents.
Consider running paperless on an encrypted filesystem instead, which
will then at least provide security against physical hardware theft.
#### Enabling encryption
Enabling encryption is no longer supported.
#### Disabling encryption
Basic usage to disable encryption of your document store:
(Note: If `PAPERLESS_PASSPHRASE` isn't set already, you need to specify
it here)
```
decrypt_documents [--passphrase SECR3TP4SSPHRA$E]
```