Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/backups.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
PGBACKREST_EXECUTABLE,
PGBACKREST_LOGROTATE_FILE,
PGBACKREST_LOGS_PATH,
POSTGRESQL_ARCHIVE_PATH,
POSTGRESQL_DATA_PATH,
UNIT_SCOPE,
)
Expand Down Expand Up @@ -1270,6 +1271,7 @@ def _render_pgbackrest_conf_file(self) -> bool:
user=BACKUP_USER,
retention_full=s3_parameters["delete-older-than-days"],
process_max=max(os.cpu_count() - 2, 1),
archive_path=POSTGRESQL_ARCHIVE_PATH,
)
# Render pgBackRest config file.
self.charm._patroni.render_file(f"{PGBACKREST_CONF_PATH}/pgbackrest.conf", rendered, 0o644)
Expand Down
2 changes: 2 additions & 0 deletions src/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
POSTGRESQL_DATA_PATH = f"{SNAP_DATA_PATH}/postgresql"
POSTGRESQL_LOGS_PATH = f"{SNAP_LOGS_PATH}/postgresql"

POSTGRESQL_ARCHIVE_PATH = f"{SNAP_COMMON_PATH}/data/archive"

UPDATE_CERTS_BIN_PATH = "/usr/sbin/update-ca-certificates"

PGBACKREST_CONFIGURATION_FILE = f"--config={PGBACKREST_CONF_PATH}/pgbackrest.conf"
Expand Down
1 change: 1 addition & 0 deletions templates/pgbackrest.conf.j2
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[global]
backup-standby=y
compress-type=zst
spool-path={{ archive_path }}
lock-path=/tmp
log-path={{ log_path }}
repo1-retention-full-type=time
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/test_backups.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from backups import ListBackupsError
from charm import PostgresqlOperatorCharm
from constants import PEER
from constants import PEER, POSTGRESQL_ARCHIVE_PATH

ANOTHER_CLUSTER_REPOSITORY_ERROR_MESSAGE = "the S3 repository has backups from another cluster"
FAILED_TO_ACCESS_CREATE_BUCKET_ERROR_MESSAGE = (
Expand Down Expand Up @@ -1732,6 +1732,7 @@ def test_render_pgbackrest_conf_file(harness, tls_ca_chain_filename):
user="backup",
retention_full=30,
process_max=max(cpu_count() - 2, 1),
archive_path=POSTGRESQL_ARCHIVE_PATH,
)

# Patch the `open` method with our mock.
Expand Down
Loading