Skip to content

Commit 7a80c06

Browse files
committed
Adds barman for postgres 15
1 parent 8bcd18d commit 7a80c06

File tree

4 files changed

+134
-0
lines changed

4 files changed

+134
-0
lines changed

postgres/15.5/barman/Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM postgres:15
2+
3+
RUN apt-get update \
4+
&& apt-get install -y \
5+
barman \
6+
cron \
7+
rsyslog \
8+
&& apt-get clean \
9+
&& apt-get autoremove -y \
10+
&& rm -rf /var/lib/apt/lists/*
11+
12+
COPY barman.conf /etc/barman.conf
13+
COPY crontab /var/spool/cron/crontabs/barman
14+
RUN sed -i '/imklog/s/^/#/' /etc/rsyslog.conf
15+
16+
COPY entrypoint.sh /entrypoint.sh
17+
RUN chmod +x /entrypoint.sh
18+
ENTRYPOINT ["/entrypoint.sh"]
19+
20+
VOLUME /var/lib/barman
21+
22+
CMD ["/bin/bash", "-c", "rsyslogd && chown barman:crontab /var/spool/cron/crontabs/barman && chmod 0600 /var/spool/cron/crontabs/barman && cron && tail -n 0 -f /var/log/syslog /var/log/barman/barman.log"]

postgres/15.5/barman/barman.conf

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
; Barman, Backup and Recovery Manager for PostgreSQL
2+
; http://www.pgbarman.org/ - http://www.2ndQuadrant.com/
3+
;
4+
; Main configuration file
5+
6+
[barman]
7+
; System user
8+
barman_user = barman
9+
10+
; Directory of configuration files. Place your sections in separate files with .conf extension
11+
; For example place the 'main' server section in /etc/barman.d/main.conf
12+
configuration_files_directory = /etc/barman.d
13+
14+
; Main directory
15+
barman_home = /var/lib/barman
16+
17+
; Locks directory - default: %(barman_home)s
18+
;barman_lock_directory = /var/run/barman
19+
20+
; Log location
21+
log_file = /var/log/barman/barman.log
22+
23+
; Log level (see https://docs.python.org/3/library/logging.html#levels)
24+
log_level = INFO
25+
26+
; Default compression level: possible values are None (default), bzip2, gzip, pigz, pygzip or pybzip2
27+
;compression = gzip
28+
29+
; Pre/post backup hook scripts
30+
;pre_backup_script = env | grep ^BARMAN
31+
;pre_backup_retry_script = env | grep ^BARMAN
32+
;post_backup_retry_script = env | grep ^BARMAN
33+
;post_backup_script = env | grep ^BARMAN
34+
35+
; Pre/post archive hook scripts
36+
;pre_archive_script = env | grep ^BARMAN
37+
;pre_archive_retry_script = env | grep ^BARMAN
38+
;post_archive_retry_script = env | grep ^BARMAN
39+
;post_archive_script = env | grep ^BARMAN
40+
41+
; Global retention policy (REDUNDANCY or RECOVERY WINDOW) - default empty
42+
;retention_policy =
43+
44+
; Global bandwidth limit in KBPS - default 0 (meaning no limit)
45+
;bandwidth_limit = 4000
46+
47+
; Immediate checkpoint for backup command - default false
48+
;immediate_checkpoint = false
49+
50+
; Enable network compression for data transfers - default false
51+
;network_compression = false
52+
53+
; Number of retries of data copy during base backup after an error - default 0
54+
;basebackup_retry_times = 0
55+
56+
; Number of seconds of wait after a failed copy, before retrying - default 30
57+
;basebackup_retry_sleep = 30
58+
59+
; Maximum execution time, in seconds, per server
60+
; for a barman check command - default 30
61+
;check_timeout = 30
62+
63+
; Time frame that must contain the latest backup date.
64+
; If the latest backup is older than the time frame, barman check
65+
; command will report an error to the user.
66+
; If empty, the latest backup is always considered valid.
67+
; Syntax for this option is: "i (DAYS | WEEKS | MONTHS)" where i is an
68+
; integer > 0 which identifies the number of days | weeks | months of
69+
; validity of the latest backup for this check. Also known as 'smelly backup'.
70+
;last_backup_maximum_age =
71+
72+
; Minimum number of required backups (redundancy)
73+
;minimum_redundancy = 1
74+
75+
; Examples of retention policies
76+
; Retention policy (disabled)
77+
;retention_policy =
78+
; Retention policy (based on redundancy)
79+
;retention_policy = REDUNDANCY 2
80+
; Retention policy (based on recovery window)
81+
;retention_policy = RECOVERY WINDOW OF 4 WEEKS

postgres/15.5/barman/crontab

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Edit this file to introduce tasks to be run by cron.
2+
#
3+
# Each task to run has to be defined through a single line
4+
# indicating with different fields when the task will be run
5+
# and what command to run for the task
6+
#
7+
# To define the time you can provide concrete values for
8+
# minute (m), hour (h), day of month (dom), month (mon),
9+
# and day of week (dow) or use '*' in these fields (for 'any').#
10+
# Notice that tasks will be started based on the cron's system
11+
# daemon's notion of time and timezones.
12+
#
13+
# Output of the crontab jobs (including errors) is sent through
14+
# email to the user the crontab file belongs to (unless redirected).
15+
#
16+
# For example, you can run a backup of all your user accounts
17+
# at 5 a.m every week with:
18+
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
19+
#
20+
# For more information see the manual pages of crontab(5) and cron(8)
21+
#
22+
# m h dom mon dow command
23+
24+
# * * * * * /usr/bin/barman cron <- included in debian package
25+
# 30 23 * * * /usr/bin/barman backup main-db-server <- example full backup

postgres/15.5/barman/entrypoint.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
set -e
3+
4+
chown -R barman:barman /var/lib/barman || true
5+
6+
exec "$@"

0 commit comments

Comments
 (0)