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 ...@@ -6,7 +6,7 @@ from setuptools import setup, find_packages
# "."], stdout=subprocess.PIPE).communicate()[0])) # "."], stdout=subprocess.PIPE).communicate()[0]))
name = "slapos.recipe.erp5" name = "slapos.recipe.erp5"
version = '1.1-dev-183' version = '1.1-dev-184'
def read(name): def read(name):
return open(name).read() return open(name).read()
......
import os import os
import glob import glob
def controller(args): def controller(args):
"""Creates full backup if not yet found, otherwise uses the newes full one """Creates full or incremental backup
to perform incremental"""
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 \ innobackupex_incremental, innobackupex_full, full_backup, incremental_backup \
= args = args
if len(os.listdir(full_backup)) == 0: if len(os.listdir(full_backup)) == 0:
print 'Doing full backup in %r' % full_backup print 'Doing full backup in %r' % full_backup
os.execv(innobackupex_full, [innobackupex_full, full_backup]) os.execv(innobackupex_full, [innobackupex_full, full_backup])
backup_list = filter(os.path.isdir, glob.glob(full_backup + "/*")) else:
backup_list.sort(key=lambda x: os.path.getmtime(x), reverse=True) backup_list = filter(os.path.isdir, glob.glob(full_backup + "/*") +
base = backup_list[0] glob.glob(incremental_backup + "/*"))
print 'Doing incremental backup in %r using %r as a base' % ( backup_list.sort(key=lambda x: os.path.getmtime(x), reverse=True)
incremental_backup, base) base = backup_list[0]
os.execv(innobackupex_incremental, [innobackupex_incremental, print 'Doing incremental backup in %r using %r as a base' % (
'--incremental-basedir=%s'%base, incremental_backup]) 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