Update notes on postgres.

This commit is contained in:
Brian Lee 2023-08-10 14:28:39 -07:00
parent ed0cb57827
commit 070a215234
2 changed files with 37 additions and 2 deletions

View File

@ -16,3 +16,5 @@ Example using [alvistack/ansible-role-podman](https://github.com/alvistack/ansib
cmd: "loginctl enable-linger {{ sysadmin_username }}" cmd: "loginctl enable-linger {{ sysadmin_username }}"
creates: "/var/lib/systemd/linger/{{ sysadmin_username }}" creates: "/var/lib/systemd/linger/{{ sysadmin_username }}"
``` ```
Depending on the OS version you're using, you may have to account for the usage of deprecated apt-key functionality.

View File

@ -1,6 +1,6 @@
# PostgreSQL # PostgreSQL
This variation of the [original role](https://github.com/Tronde/ansible_role_deploy_wikijs_with_mariadb_pod) is intended to be composed with another role that sets up the database. Here is an example using [anxs.postgresql](https://github.com/ANXS/postgresql) Here is an example using [anxs.postgresql](https://github.com/ANXS/postgresql)
## Example Playbook ## Example Playbook
@ -23,3 +23,36 @@ postgresql_databases:
owner: wikijs owner: wikijs
state: present state: present
``` ```
Depending on the OS version you're using, you may have to account for the usage of deprecated apt-key functionality.
## PG 15
I'm temporarily using this branch to get PG15:
```yaml
- src: https://github.com/ANXS/postgresql
name: anxs.postgresql
version: development
```
## Backups
```bash
BACKUP_PG_DB() {
BACKUP_DIR=$HOME/archive/${TARGET}/postgresql
DUMP_FILE=/var/lib/postgresql/${1}_${TIMESTAMP}.dump.bz2
ssh root@${TARGET} "cd /var/lib/postgresql && doas -u postgres /usr/bin/pg_dump -Fc ${1} | /usr/bin/bzip2 > ${DUMP_FILE}"
mkdir -p ${BACKUP_DIR}
rsync -tav root@${TARGET}:${DUMP_FILE} ${BACKUP_DIR}/
ssh root@${TARGET} rm -v ${DUMP_FILE}
# Only remove older backups if newer backups exist
NEWER_BACKUPS=$(find $BACKUP_DIR -mtime -60 -type f -name "${1}_*.dump.bz2")
if [[ -n $NEWER_BACKUPS ]]; then
find $BACKUP_DIR -mtime +60 -type f -name "${1}_*.dump.bz2" -delete
else
echo "No newer backups found. Old backups not pruned."
fi
}
BACKUP_PG_DB wikijs
```