Commit 8aa7af94 authored by Romain Courteaud's avatar Romain Courteaud

Add rdiff backup statistics in the RSS feeds.

parent 396a54e2
......@@ -23,6 +23,7 @@ crontabs = $${:etc}/crontabs
cronstamps = $${:etc}/cronstamps
backup = $${:srv}/backup
status = $${:srv}/status
statistic = $${:srv}/statistic
backupscript = $${:etc}/backup
www = $${:srv}/www
home = $${:etc}/home
......@@ -111,7 +112,9 @@ include = {{ include_string }}
exclude_string = {{ exclude_string }}
remote_schema = {{ remote_schema }}
status_name = {{ slave_reference }}_status.txt
statistic_name = {{ slave_reference }}_statistic.txt
status_log = $${directory:status}/$${:status_name}
statistic_log = $${directory:statistic}/$${:statistic_name}
[{{ slave_reference }}-backup-crontab-line]
recipe = slapos.recipe.template
......
......@@ -12,6 +12,7 @@ extends =
../../component/rsync/buildout.cfg
../../component/dropbear/buildout.cfg
../../component/grep/buildout.cfg
../../component/findutils/buildout.cfg
# ../../stack/flask.cfg
../../stack/slapos.cfg
......@@ -196,7 +197,7 @@ mode = 0644
[template-backup-script]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/template-backup-script.sh.in
md5sum = 8a076962fc4df7f154572543899328e3
md5sum = 3c4ad4b9a1ecef88f35a84ceb84a3ec6
output = ${buildout:directory}/template-backup-script.sh.in
mode = 0644
......@@ -217,7 +218,7 @@ mode = 0644
[status2rss]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/status2rss.py
md5sum = 138c96e0836f2b06414b98ba2643f21c
md5sum = 0cd1cf97b199dd18fc0168c7281890ea
output = ${buildout:directory}/status2rss.py
mode = 0644
......@@ -234,7 +235,7 @@ mode = 0644
[template-pullrdiffbackup]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-pullrdiffbackup.cfg.in
md5sum = 9bf3a34fa41ae6fe57b183293b3ff377
md5sum = 061b98d001b501c9e1beb424e8802d3d
output = ${buildout:directory}/template-pullrdiffbackup.cfg
mode = 0644
......@@ -327,3 +328,12 @@ cliff = 1.4
cmd2 = 0.6.5.1
prettytable = 0.7.2
requests = 1.2.3
cffi = 0.8.1
cryptography = 0.2.1
pyOpenSSL = 0.14
six = 1.5.2
# Required by:
# cffi==0.8.1
pycparser = 2.10
......@@ -23,11 +23,12 @@ while 1:
if not line:
break
time, desc = line.split(',', 1)
time, statistic, desc = line.split(',', 2)
rss_item = PyRSS2Gen.RSSItem(
title = desc,
description = "%s, %s" % (time, desc),
description = "<p>%s</p>" % "<br/>".join(("%s, %s\n<a href='http://www.nongnu.org/rdiff-backup/FAQ.html#statistics'>Lastest statistic</a>\n%s" % (time, desc,
open(statistic).read())).split("\n")),
link = LINK,
pubDate = datetime.datetime.fromtimestamp(mktime_tz(parsedate_tz(time))),
guid = PyRSS2Gen.Guid(base64.b64encode("%s, %s" % (time, desc)))
......
......@@ -6,9 +6,11 @@ export HOME=$${directory:home}
# Clean status file (no history needed)
${coreutils-output:rm} -f $${:status_log}
${coreutils-output:rm} -f $${:statistic_log}
# Inform about beginning of backup
${coreutils-output:echo} "`${coreutils-output:date} -u`, $${:hostname} backup running" >> $${:status_log}
${coreutils-output:echo} "Available only if backup succeed." >> $${:statistic_log}
# set -e
cd $${:datadirectory}
......@@ -25,9 +27,11 @@ RESULT=$?
${coreutils-output:rm} -f $${:status_log}
if [ $RESULT -eq 0 ]
then
${coreutils-output:echo} "`${coreutils-output:date} -u`, $${:hostname} backup success" >> $${:status_log}
${coreutils-output:echo} "`${coreutils-output:date} -u`,$${:statistic_log},$${:hostname} backup success" >> $${:status_log}
${coreutils-output:rm} -f $${:statistic_log}
${findutils-output:find} rdiff-backup-data/ -name "session_statistic*" | ${coreutils-output:sort} | ${coreutils-output:tail} -n 1 | ${findutils-output:xargs} ${rdiff-backup-output:rdiff-backup} --calculate-average >> $${:statistic_log}
else
${coreutils-output:echo} "`${coreutils-output:date} -u`, $${:hostname} backup failed" >> $${:status_log}
${coreutils-output:echo} "`${coreutils-output:date} -u`,$${:statistic_log},$${:hostname} backup failed" >> $${:status_log}
fi
# python scripts/verify_with_sudo.py ./ $${:connection}:/
......
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