Commit f4428ef5 authored by Łukasz Nowak's avatar Łukasz Nowak

Fix mysql backup strategy.

Increment since most recent (incremental OR full) backup. Thanks to this
incrementals are deltas between them, but still the newest full would be used
in case if it is more recent then last incremental.
parent 1ed2aa70
......@@ -6,7 +6,7 @@ from setuptools import setup, find_packages
# "."], stdout=subprocess.PIPE).communicate()[0]))
name = "slapos.recipe.erp5"
version = '1.1-dev-183'
version = '1.1-dev-184'
def read(name):
return open(name).read()
......
import os
import glob
def controller(args):
"""Creates full backup if not yet found, otherwise uses the newes full one
to perform incremental"""
"""Creates full or incremental backup
If no full backup is done, it is created
If full backup exists incremental backup is done starting with base
base is the newest (according to date) full or incremental backup
"""
innobackupex_incremental, innobackupex_full, full_backup, incremental_backup \
= args
if len(os.listdir(full_backup)) == 0:
print 'Doing full backup in %r' % full_backup
os.execv(innobackupex_full, [innobackupex_full, full_backup])
backup_list = filter(os.path.isdir, glob.glob(full_backup + "/*"))
backup_list.sort(key=lambda x: os.path.getmtime(x), reverse=True)
base = backup_list[0]
print 'Doing incremental backup in %r using %r as a base' % (
incremental_backup, base)
os.execv(innobackupex_incremental, [innobackupex_incremental,
'--incremental-basedir=%s'%base, incremental_backup])
else:
backup_list = filter(os.path.isdir, glob.glob(full_backup + "/*") +
glob.glob(incremental_backup + "/*"))
backup_list.sort(key=lambda x: os.path.getmtime(x), reverse=True)
base = backup_list[0]
print 'Doing incremental backup in %r using %r as a base' % (
incremental_backup, base)
os.execv(innobackupex_incremental, [innobackupex_incremental,
'--incremental-basedir=%s'%base, incremental_backup])
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