Skip to content

Commit d4991c9

Browse files
authored
Add compression and restore max-process (#1020)
1 parent 2a6bd13 commit d4991c9

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

src/backups.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,6 +1200,7 @@ def _render_pgbackrest_conf_file(self) -> bool:
12001200
storage_path=self.charm._storage_path,
12011201
user=BACKUP_USER,
12021202
retention_full=s3_parameters["delete-older-than-days"],
1203+
process_max=max(os.cpu_count() - 2, 1),
12031204
)
12041205
# Delete the original file and render the one with the right info.
12051206
filename = "/etc/pgbackrest.conf"

templates/pgbackrest.conf.j2

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[global]
22
backup-standby=y
3+
compress-type=zst
34
repo1-retention-full-type=time
45
repo1-retention-full={{ retention_full }}
56
repo1-retention-history=365
@@ -43,3 +44,6 @@ pg{{ ns.count }}-user={{ user }}
4344
{% set ns.count = ns.count + 1 %}
4445
{%- endfor %}
4546
{%- endif %}
47+
48+
[global:restore]
49+
process-max={{process_max}}

tests/unit/test_backups.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Copyright 2023 Canonical Ltd.
22
# See LICENSE file for licensing details.
33
import datetime
4+
from os import cpu_count
45
from unittest.mock import MagicMock, PropertyMock, call, mock_open, patch
56

67
import pytest
@@ -1812,6 +1813,7 @@ def test_render_pgbackrest_conf_file(harness, tls_ca_chain_filename):
18121813
storage_path=harness.charm._storage_path,
18131814
user="backup",
18141815
retention_full=30,
1816+
process_max=max(cpu_count() - 2, 1),
18151817
)
18161818

18171819
# Patch the `open` method with our mock.

0 commit comments

Comments
 (0)