Commit 9005805e authored by Romain Courteaud's avatar Romain Courteaud

Backup mariadb with mysqldump

parent 9d064e71
...@@ -133,54 +133,54 @@ class Recipe(GenericBaseRecipe): ...@@ -133,54 +133,54 @@ class Recipe(GenericBaseRecipe):
) )
path_list.append(mysqld) path_list.append(mysqld)
# backup configuration # backup configuration
full_backup = self.options['full-backup-directory'] # full_backup = self.options['full-backup-directory']
incremental_backup = self.options['incremental-backup-directory'] # incremental_backup = self.options['incremental-backup-directory']
innobackupex_argument_list = [self.options['perl-binary'], # innobackupex_argument_list = [self.options['perl-binary'],
self.options['innobackupex-binary'], # self.options['innobackupex-binary'],
'--defaults-file=%s' % mysql_conf_file, # '--defaults-file=%s' % mysql_conf_file,
'--socket=%s' %mysql_conf['socket'].strip(), '--user=root', # '--socket=%s' %mysql_conf['socket'].strip(), '--user=root',
'--ibbackup=%s'% self.options['xtrabackup-binary']] # '--ibbackup=%s'% self.options['xtrabackup-binary']]
environment = dict(PATH='%s' % self.options['bin-directory']) # environment = dict(PATH='%s' % self.options['bin-directory'])
innobackupex_incremental = self.createPythonScript(self.options['innobackupex-incremental'], 'slapos.recipe.librecipe.execute.executee', [innobackupex_argument_list + ['--incremental'], environment]) # innobackupex_incremental = self.createPythonScript(self.options['innobackupex-incremental'], 'slapos.recipe.librecipe.execute.executee', [innobackupex_argument_list + ['--incremental'], environment])
path_list.append(innobackupex_incremental) # path_list.append(innobackupex_incremental)
innobackupex_full = self.createPythonScript(self.options['innobackupex-full'], 'slapos.recipe.librecipe.execute.executee', [innobackupex_argument_list, environment]) # innobackupex_full = self.createPythonScript(self.options['innobackupex-full'], 'slapos.recipe.librecipe.execute.executee', [innobackupex_argument_list, environment])
path_list.append(innobackupex_full) # path_list.append(innobackupex_full)
backup_controller = self.createPythonScript(self.options['backup-script'], __name__ + '.innobackupex.controller', [innobackupex_incremental, innobackupex_full, full_backup, incremental_backup]) # backup_controller = self.createPythonScript(self.options['backup-script'], __name__ + '.innobackupex.controller', [innobackupex_incremental, innobackupex_full, full_backup, incremental_backup])
path_list.append(backup_controller) # path_list.append(backup_controller)
# maatkit installation # # maatkit installation
for pt_script_name in ( # for pt_script_name in (
'pt-archiver', # 'pt-archiver',
'pt-config-diff', # 'pt-config-diff',
'pt-deadlock-logger', # 'pt-deadlock-logger',
'pt-duplicate-key-checker', # 'pt-duplicate-key-checker',
'pt-fifo-split', # 'pt-fifo-split',
'pt-find', # 'pt-find',
'pt-fk-error-logger', # 'pt-fk-error-logger',
'pt-heartbeat', # 'pt-heartbeat',
'pt-index-usage', # 'pt-index-usage',
'pt-kill', # 'pt-kill',
'pt-log-player', # 'pt-log-player',
'pt-online-schema-change', # 'pt-online-schema-change',
'pt-query-advisor', # 'pt-query-advisor',
'pt-query-digest', # 'pt-query-digest',
'pt-show-grants', # 'pt-show-grants',
'pt-slave-delay', # 'pt-slave-delay',
'pt-slave-find', # 'pt-slave-find',
'pt-slave-restart', # 'pt-slave-restart',
'pt-table-checksum', # 'pt-table-checksum',
'pt-table-sync', # 'pt-table-sync',
'pt-tcp-model', # 'pt-tcp-model',
'pt-trend', # 'pt-trend',
'pt-upgrade', # 'pt-upgrade',
'pt-variable-advisor', # 'pt-variable-advisor',
'pt-visual-explain', # 'pt-visual-explain',
): # ):
pt_argument_list = [self.options['perl-binary'], # pt_argument_list = [self.options['perl-binary'],
self.options['%s-binary' % pt_script_name], # self.options['%s-binary' % pt_script_name],
'--defaults-file=%s' % mysql_conf_file, # '--defaults-file=%s' % mysql_conf_file,
'--socket=%s' %mysql_conf['socket'].strip(), '--user=root', # '--socket=%s' %mysql_conf['socket'].strip(), '--user=root',
] # ]
pt_exe = self.createPythonScript(os.path.join(self.options['bin-directory'], pt_script_name), 'slapos.recipe.librecipe.execute.executee', [pt_argument_list, environment]) # pt_exe = self.createPythonScript(os.path.join(self.options['bin-directory'], pt_script_name), 'slapos.recipe.librecipe.execute.executee', [pt_argument_list, environment])
path_list.append(pt_exe) # path_list.append(pt_exe)
return path_list return path_list
...@@ -2,13 +2,10 @@ ...@@ -2,13 +2,10 @@
parts = parts =
publish-mariadb-url publish-mariadb-url
mariadb-instance mariadb-instance
mydumper-import
logrotate logrotate
logrotate-entry-mariadb logrotate-entry-mariadb
cron cron
cron-entry-logrotate cron-entry-logrotate
cron-entry-mariadb-backup
cron-entry-mariadb-mydumperbackup
binary-link binary-link
eggs-directory = ${buildout:eggs-directory} eggs-directory = ${buildout:eggs-directory}
...@@ -19,12 +16,12 @@ offline = true ...@@ -19,12 +16,12 @@ offline = true
recipe = slapos.cookbook:publishurl recipe = slapos.cookbook:publishurl
url = mysql://$${mariadb-instance:user}:$${mariadb-instance:password}@$${mariadb-instance:ip}:$${mariadb-instance:port}/$${mariadb-instance:database} url = mysql://$${mariadb-instance:user}:$${mariadb-instance:password}@$${mariadb-instance:ip}:$${mariadb-instance:port}/$${mariadb-instance:database}
[cron-entry-mariadb-backup] # [cron-entry-mariadb-backup]
<= cron # <= cron
recipe = slapos.cookbook:cron.d # recipe = slapos.cookbook:cron.d
name = mariadb-backup # name = mariadb-backup
frequency = 0 0 * * * # frequency = 0 0 * * *
command = $${mariadb-instance:backup-script} # command = $${mariadb-instance:backup-script}
[mariadb-instance] [mariadb-instance]
recipe = slapos.cookbook:generic.mysql recipe = slapos.cookbook:generic.mysql
...@@ -92,33 +89,33 @@ pt-visual-explain-binary = ${perl:siteprefix}/bin/pt-visual-explain ...@@ -92,33 +89,33 @@ pt-visual-explain-binary = ${perl:siteprefix}/bin/pt-visual-explain
xtrabackup-binary = ${xtrabackup:location}/bin/xtrabackup_51 xtrabackup-binary = ${xtrabackup:location}/bin/xtrabackup_51
perl-binary = ${perl:location}/bin/perl perl-binary = ${perl:location}/bin/perl
[mydumper] # [mydumper]
recipe = slapos.cookbook:mydumper # recipe = slapos.cookbook:mydumper
wrapper = $${rootdirectory:bin}/raw_mydumper # wrapper = $${rootdirectory:bin}/raw_mydumper
backup-directory = $${directory:mariadb-backup} # backup-directory = $${directory:mariadb-backup}
socket = $${mariadb-instance:socket} # socket = $${mariadb-instance:socket}
user = root # user = root
mydumper-binary = ${mydumper:location}/bin/mydumper # mydumper-binary = ${mydumper:location}/bin/mydumper
database = $${mariadb-instance:database} # database = $${mariadb-instance:database}
import = false # import = false
compression = true # compression = true
#
[cron-entry-mariadb-mydumperbackup] # [cron-entry-mariadb-mydumperbackup]
<= cron # <= cron
recipe = slapos.cookbook:cron.d # recipe = slapos.cookbook:cron.d
name = backup # name = backup
frequency = 0 * * * * # frequency = 0 * * * *
command = $${mydumper:wrapper} # command = $${mydumper:wrapper}
#
[mydumper-import] # [mydumper-import]
recipe = slapos.cookbook:mydumper # recipe = slapos.cookbook:mydumper
wrapper = $${rootdirectory:bin}/myloader # wrapper = $${rootdirectory:bin}/myloader
backup-directory = $${directory:mariadb-backup} # backup-directory = $${directory:mariadb-backup}
socket = $${mariadb-instance:socket} # socket = $${mariadb-instance:socket}
user = root # user = root
myloader-binary = ${mydumper:location}/bin/myloader # myloader-binary = ${mydumper:location}/bin/myloader
database = $${mariadb-instance:database} # database = $${mariadb-instance:database}
import = true # import = true
[logrotate] [logrotate]
recipe = slapos.cookbook:logrotate recipe = slapos.cookbook:logrotate
...@@ -161,6 +158,13 @@ name = logrotate ...@@ -161,6 +158,13 @@ name = logrotate
frequency = 0 0 * * * frequency = 0 0 * * *
command = $${logrotate:wrapper} command = $${logrotate:wrapper}
[cron-entry-mysqldump]
<= cron
recipe = slapos.cookbook:cron.d
name = mysqldump
frequency = 0 0 * * *
command = ${mysql-tritonn-5.0:location}/bin/mysqldump -u root -S $${mariadb-instance:socket} --single-transaction --no-autocommit --opt $${mariadb-instance:database} | ${gzip:location}/bin/gzip > $${directory:mariadb-dump}/$${mariadb-instance:database}.sql.gz
[binary-link] [binary-link]
recipe = slapos.cookbook:symbolic.link recipe = slapos.cookbook:symbolic.link
target-directory = $${rootdirectory:bin} target-directory = $${rootdirectory:bin}
...@@ -196,6 +200,7 @@ cron-entries = $${rootdirectory:etc}/cron.d ...@@ -196,6 +200,7 @@ cron-entries = $${rootdirectory:etc}/cron.d
crontabs = $${rootdirectory:etc}/crontabs crontabs = $${rootdirectory:etc}/crontabs
cronstamps = $${rootdirectory:etc}/cronstamps cronstamps = $${rootdirectory:etc}/cronstamps
ca-dir = $${rootdirectory:srv}/ssl ca-dir = $${rootdirectory:srv}/ssl
mariadb-dump = $${basedirectory:backup}/mariadb-dump
mariadb-backup = $${basedirectory:backup}/mariadb mariadb-backup = $${basedirectory:backup}/mariadb
mariadb-backup-full = $${basedirectory:backup}/mariadb-full mariadb-backup-full = $${basedirectory:backup}/mariadb-full
mariadb-backup-incremental = $${basedirectory:backup}/mariadb-incremental mariadb-backup-incremental = $${basedirectory:backup}/mariadb-incremental
......
...@@ -69,7 +69,7 @@ mode = 0644 ...@@ -69,7 +69,7 @@ mode = 0644
[template-mariadb-prod] [template-mariadb-prod]
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-mariadb-prod.cfg url = ${:_profile_base_location_}/instance-mariadb-prod.cfg
md5sum = 5ee6e8a9917b488c49ae0d7ce13c51ee md5sum = ca020131ac05ca71bce624a5f65e9f53
output = ${buildout:directory}/template-mariadb-prod.cfg output = ${buildout:directory}/template-mariadb-prod.cfg
mode = 0644 mode = 0644
......
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