From b7c1d19f080ed11c711d65d26109eb90581ddcea Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Tue, 8 Sep 2020 12:14:47 +0200 Subject: [PATCH] new: [mariadb] added ``backup`` relation. Signed-off-by: Valentin Lab --- mariadb/hooks/backup-relation-joined | 21 +++++++++++++++++++++ mariadb/metadata.yml | 16 ++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100755 mariadb/hooks/backup-relation-joined diff --git a/mariadb/hooks/backup-relation-joined b/mariadb/hooks/backup-relation-joined new file mode 100755 index 00000000..e5ec3bd8 --- /dev/null +++ b/mariadb/hooks/backup-relation-joined @@ -0,0 +1,21 @@ +#!/bin/bash + +## When writing relation script, remember: +## - they should be idempotents +## - they can be launched while the dockers is already up +## - they are launched from the host +## - the target of the link is launched first, and get a chance to ``relation-set`` +## - both side of the scripts get to use ``relation-get``. + +. lib/common + +set -e + +## if I'm not linked to a schedule-command, then complain +if read-0 ts _ _ < <(get_service_relation "$SERVICE_NAME" "schedule-command"); then + debug "schedule-command relation fullfilled" +else + ## XXXvlab: relation dependence as this one could actually be implemented in compose-core + err "backup relation requires schedule-command relation to be set" + exit 1 +fi diff --git a/mariadb/metadata.yml b/mariadb/metadata.yml index 414a21de..3c742ee1 100644 --- a/mariadb/metadata.yml +++ b/mariadb/metadata.yml @@ -16,3 +16,19 @@ uses: backup: "Automatic regular dumps for backuping purpose" default-options: schedule: "31 * * * *" ## schedule backup every hour + ## This one is useful only if previous relation is used + backup: + constraint: optional + auto: pair + solves: + backup: "Automatic regular backups of dumps" + default-options: + ## First pattern matching wins, no pattern matching includes. + ## include-patterns are checked first, then exclude-patterns + ## Patterns rules: + ## - ending / for directory + ## - '*' authorized + ## - must start with a '/', will start from $SERVICE_DATASTORE + exclude-patterns: + - "/var/lib/" ## mariadb working data files + - "/var/backups/mysql/*.inprogress" ## database dump in progress