diff --git a/secrets/mysql_root_password b/secrets/mysql_root_password index b1873c6..73894f6 100644 --- a/secrets/mysql_root_password +++ b/secrets/mysql_root_password @@ -1 +1 @@ -wiochohv8foR9eDo5ol5 +wiochohv8foR9eDo5ol5 \ No newline at end of file diff --git a/services/mysql-backup.hcl b/services/mysql-backup.hcl new file mode 100644 index 0000000..df605e1 --- /dev/null +++ b/services/mysql-backup.hcl @@ -0,0 +1,37 @@ +job "mysql-backup" { + datacenters = ["alo"] + type = "batch" + + periodic { + cron = "23 23 * * * *" + prohibit_overlap = true + } + + group "db" { + task "backup" { + driver = "raw_exec" + + config { + command = "/bin/sh" + args = [ "local/script.sh" ] + } + + template { + destination = "local/script.sh" + data = < /data/compute/appdata/db-backups/mysql/backup.sql + EOH + } + + template { + destination = "secrets/file.env" + env = true + data = < -# -# filename can be - for stdin. -# -# read the var back out with: -# - nomad var get -# -# From https://github.com/gerrowadat/nomad-homelab/blob/main/utilities/file_to_nomad_var.sh - -function print_usage() { - echo "Usage: ${0} " -} - -filename=$1 -nomad_var=$2 -var_key=$3 - -if [ "${filename}" != "-" ]; -then - if [ ! -f "${filename}" ] - then - echo "${filename} does not exist" - exit - fi -fi - -var_contents=$(cat ${filename}) - -if [[ "${nomad_var}" == "" || "${var_key}" == "" ]]; -then - print_usage - exit -fi - -echo "Copying ${filename} to ${nomad_var}:${var_key}..." - -nomad var put -force -in hcl - <