Add nextcloud backup job
This commit is contained in:
parent
f1316367de
commit
af743820ec
@ -48,4 +48,4 @@ all:
|
||||
servers: {}
|
||||
vault_instances:
|
||||
children:
|
||||
# servers: {}
|
||||
servers: {}
|
||||
|
42
nomad/nextcloud/nextcloud-backup.hcl
Normal file
42
nomad/nextcloud/nextcloud-backup.hcl
Normal file
@ -0,0 +1,42 @@
|
||||
job "Nextcloud" {
|
||||
schedule = "* * * * *"
|
||||
|
||||
config {
|
||||
repo = "/local/repo"
|
||||
# Read from secret file
|
||||
# Either options.PasswordFile or using readfile()
|
||||
passphrase = "secret phrase"
|
||||
}
|
||||
|
||||
task "Create dir for repo" {
|
||||
pre_script {
|
||||
on_backup = "echo 'Backing up something'"
|
||||
}
|
||||
pre_script {
|
||||
on_backup = "mkdir -p /local/repo"
|
||||
}
|
||||
}
|
||||
|
||||
mysql "Backup database" {
|
||||
hostname = env("MYSQL_HOST")
|
||||
port = env("MYSQL_PORT")
|
||||
database = env("MYSQL_DATABASE")
|
||||
username = env("MYSQL_USER")
|
||||
password = env("MYSQL_PASSWORD")
|
||||
no_tablespaces = true
|
||||
dump_to = "/local/dump.sql"
|
||||
}
|
||||
|
||||
backup {
|
||||
paths = ["/data"]
|
||||
|
||||
restore_opts {
|
||||
Target = "/"
|
||||
}
|
||||
}
|
||||
|
||||
forget {
|
||||
KeepLast = 2
|
||||
Prune = true
|
||||
}
|
||||
}
|
@ -13,6 +13,11 @@ variable "nextcloud_pass" {
|
||||
default = "nextcloud"
|
||||
}
|
||||
|
||||
variable "backup_config" {
|
||||
type = string
|
||||
description = "HCL config for Restic Scheduler jobs"
|
||||
}
|
||||
|
||||
job "nextcloud" {
|
||||
datacenters = ["dc1"]
|
||||
type = "service"
|
||||
@ -83,9 +88,12 @@ job "nextcloud" {
|
||||
"-c",
|
||||
"/usr/bin/mysql -h${NOMAD_UPSTREAM_IP_mysql_server} -P${NOMAD_UPSTREAM_PORT_mysql_server} -uroot -psupersecretpassword < /bootstrap.sql",
|
||||
]
|
||||
volumes = [
|
||||
"local/bootstrap.sql:/bootstrap.sql"
|
||||
]
|
||||
|
||||
mount {
|
||||
type = "bind"
|
||||
source = "local/bootstrap.sql"
|
||||
target = "/bootstrap.sql"
|
||||
}
|
||||
}
|
||||
|
||||
template {
|
||||
@ -129,5 +137,44 @@ job "nextcloud" {
|
||||
memory = 250
|
||||
}
|
||||
}
|
||||
|
||||
task "backup" {
|
||||
driver = "docker"
|
||||
|
||||
volume_mount {
|
||||
volume = "nextcloud-data"
|
||||
destination = "/data"
|
||||
read_only = true
|
||||
}
|
||||
|
||||
config {
|
||||
image = "iamthefij/resticscheduler"
|
||||
args = ["/jobs/nextcloud.hcl"]
|
||||
|
||||
mount {
|
||||
type = "bind"
|
||||
target = "/jobs"
|
||||
source = "jobs"
|
||||
}
|
||||
}
|
||||
|
||||
env = {
|
||||
"MYSQL_HOST" = "${NOMAD_UPSTREAM_IP_mysql_server}"
|
||||
"MYSQL_PORT" = "${NOMAD_UPSTREAM_PORT_mysql_server}"
|
||||
"MYSQL_DATABASE" = "${var.nextcloud_db}"
|
||||
"MYSQL_USER" = "${var.nextcloud_user}"
|
||||
"MYSQL_PASSWORD" = "${var.nextcloud_pass}"
|
||||
}
|
||||
|
||||
template {
|
||||
data = var.backup_config
|
||||
destination = "jobs/nextcloud.hcl"
|
||||
}
|
||||
|
||||
resources {
|
||||
cpu = 50
|
||||
memory = 256
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,13 @@
|
||||
locals {
|
||||
backup_config = file("${path.module}/nextcloud-backup.hcl")
|
||||
}
|
||||
|
||||
resource "nomad_job" "nextcloud" {
|
||||
hcl2 {
|
||||
enabled = true
|
||||
vars = {
|
||||
"backup_config" = "${local.backup_config}",
|
||||
}
|
||||
}
|
||||
|
||||
jobspec = file("${path.module}/nextcloud.nomad")
|
||||
|
Loading…
Reference in New Issue
Block a user