Open nstanger opened 5 months ago
Actually the initial step should be fairly straightforward, just point the scripts at the correct connection details. May need separate script instances for different database containers, though.
But thinking about it further, both scripts are available as Debian packages, so they could just be installed inside each container and output to a shared volume.
Hmm…
root@8bf563428758:/# apt install autopostgresqlbackup
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
biabam ca-certificates cron cron-daemon-common exim4-base exim4-config exim4-daemon-light gsasl-common guile-3.0-libs libevent-2.1-7 libfribidi0
libgc1 libgnutls-dane0 libgpm2 libgsasl18 libgssglue1 libidn12 libltdl7 libmailutils9 libmariadb3 libncurses6 libntlm0 libunbound8 mailutils
mailutils-common mariadb-common mysql-common psmisc sharutils
Suggested packages:
bzip2 file anacron logrotate checksecurity exim4-doc-html | exim4-doc-info eximon4 spf-tools-perl swaks dns-root-data gpm mailutils-mh
mailutils-doc sharutils-doc
The following NEW packages will be installed:
autopostgresqlbackup biabam ca-certificates cron cron-daemon-common exim4-base exim4-config exim4-daemon-light gsasl-common guile-3.0-libs
libevent-2.1-7 libfribidi0 libgc1 libgnutls-dane0 libgpm2 libgsasl18 libgssglue1 libidn12 libltdl7 libmailutils9 libmariadb3 libncurses6 libntlm0
libunbound8 mailutils mailutils-common mariadb-common mysql-common psmisc sharutils
0 upgraded, 30 newly installed, 0 to remove and 8 not upgraded.
Need to get 14.2 MB of archives.
But it’s potentially more complex to extract the backups when running the script inside the container because the container runs inside a VM on macOS. That pretty much necessitates bind mounts rather than just accessing the Docker volume directly.
Aha, autopostgresqlbackup
supports PostgreSQL, MariaDB and MySQL, and you can specify the config at runtime (https://github.com/k0lter/autopostgresqlbackup/blob/master/Documentation.md). It’s also under more active development.
Problem(s) solved, or at least rendered irrelevant. Run on the host instead of the container with a separate launchd
job for each server with corresponding configs (which can probably go into the nix store). Just need to figure out the structure of the outputs so that they can be rsync
’d elsewhere.
Need version 2.1 (not yet released) for MySQL.
Original
cron
jobs:Containerised database servers will complicate the initial backup step somewhat. They will need to run within the container and expose the file(s) via a shared volume.
automysqlbackup
is innixpkgs
, butautopgsqlbackup
was my own personal hack to make it work for PostgreSQL. Someone has now createdautopostgresqlbackup
, but it’s not innixpkgs
: https://github.com/k0lter/autopostgresqlbackup.The
rsync
to the server will need some modification as there will potentially be multiple sources torsync
. It shouldn’t be too difficult, though.