Commit 673572ef authored by Julien Muchembled's avatar Julien Muchembled

re6stnet: add cron task to backup registry.db

parent 63015188
No related merge requests found
......@@ -14,11 +14,11 @@
# not need these here).
[template]
filename = instance.cfg.in
md5sum = 99e8d2b0a0a937ca21d449b542fd8f45
md5sum = 01938aa1683b7994f814fff6d964b9ba
[template-re6stnet]
filename = instance-re6stnet.cfg.in
md5sum = f6dbd62f8db7de1c431eb82b82568085
md5sum = bc3a7aebbd15b90309e6bdaffaf9643e
[template-apache-conf]
filename = apache.conf.in
......
......@@ -78,6 +78,11 @@
"description": "Prevent tunnelling accross borders of listed countries",
"type": "string",
"default": ""
},
"backup-repository": {
"title": "Git backup repository",
"description": "URL of Git repository where backups are pushed. Nothing is pushed if empty.",
"type": "string"
}
}
}
......@@ -112,6 +112,13 @@ wrapper-path = ${directory:services}/re6st-registry
pidfile = ${directory:run}/registry.pid
command-line = {{ bin_directory }}/re6st-registry @${re6st-registry-conf:rendered}
[cron-entry-re6st-backup]
recipe = slapos.cookbook:cron.d
cron-entries = ${cron:cron-entries}
name = re6stnet-backup
time = hourly
command = {{ parameter_dict['re6stnet-backup'] }} ${logrotate-directory:backup}/re6stnet ${re6st-registry-conf-dict:db} {{ slapparameter_dict.get('backup-repository', '') }}
[re6st-registry]
recipe = slapos.cookbook:re6stnet.registry
manager-wrapper = ${directory:bin}/re6stManageToken
......@@ -199,6 +206,7 @@ parts =
re6stnet-manage
cron-entry-logrotate
cron-entry-re6st-manage
cron-entry-re6st-backup
apache-httpd
apache-httpd-graceful
publish
......
......@@ -29,6 +29,7 @@ bin-directory = {{ bin_directory }}
python-executable = {{ python_with_eggs }}
template-apache-conf = {{ template_apache_conf }}
apache-location = {{ apache_location }}
re6stnet-backup = {{ re6stnet_backup }}
template-re6st-registry-conf = {{ template_re6st_registry_conf }}
[dynamic-template-re6stnet]
......
......@@ -43,6 +43,28 @@ initialization =
os.environ['PATH'] = '${git:location}/bin' + (path and ':' + path)
depends = ${re6stnet-develop:recipe}
[re6stnet-backup]
recipe = slapos.recipe.template:jinja2
rendered = ${buildout:bin-directory}/re6st-backup
template =
inline:#!/bin/sh -e
PATH={{git_location}}/bin:{{sqlite3_location}}/bin:$PATH
cd "$1" || {
rm -rf "$1.new"
git init --bare "$1.new"
rm "$1.new"/description "$1.new"/hooks/*
mv "$1.new" "$1"
cd "$1"
}
h=`sqlite3 "$2" .dump |git hash-object --stdin -w`
git update-index --add --cacheinfo 0644 "$h" registry.sql
git diff --cached --quiet || GIT_WORK_TREE=$PWD GIT_DIR=$PWD git \
-c gc.auto=100 -c gc.autoDetach=false commit --allow-empty-message -qm ''
[ ! "$3" ] || git push --mirror "$3"
context =
key git_location git:location
key sqlite3_location sqlite3:location
[download-base]
recipe = slapos.recipe.build:download
url = ${:_profile_base_location_}/${:filename}
......@@ -59,6 +81,7 @@ context =
key apache_location apache:location
key logrotate_location logrotate:location
key openssl_location openssl:location
key re6stnet_backup re6stnet-backup:rendered
key template_apache_conf template-apache-conf:target
key template_re6stnet template-re6stnet:target
key template_re6st_registry_conf template-re6st-registry-conf:target
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment