Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Łukasz Nowak
slapos
Commits
9005805e
Commit
9005805e
authored
Mar 05, 2012
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Backup mariadb with mysqldump
parent
9d064e71
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
91 additions
and
86 deletions
+91
-86
slapos/recipe/generic_mysql/__init__.py
slapos/recipe/generic_mysql/__init__.py
+49
-49
software/erp5/instance-mariadb-prod.cfg
software/erp5/instance-mariadb-prod.cfg
+41
-36
software/erp5/software.cfg
software/erp5/software.cfg
+1
-1
No files found.
slapos/recipe/generic_mysql/__init__.py
View file @
9005805e
...
...
@@ -133,54 +133,54 @@ class Recipe(GenericBaseRecipe):
)
path_list
.
append
(
mysqld
)
# backup configuration
full_backup
=
self
.
options
[
'full-backup-directory'
]
incremental_backup
=
self
.
options
[
'incremental-backup-directory'
]
innobackupex_argument_list
=
[
self
.
options
[
'perl-binary'
],
self
.
options
[
'innobackupex-binary'
],
'--defaults-file=%s'
%
mysql_conf_file
,
'--socket=%s'
%
mysql_conf
[
'socket'
].
strip
(),
'--user=root'
,
'--ibbackup=%s'
%
self
.
options
[
'xtrabackup-binary'
]]
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
])
path_list
.
append
(
innobackupex_incremental
)
innobackupex_full
=
self
.
createPythonScript
(
self
.
options
[
'innobackupex-full'
],
'slapos.recipe.librecipe.execute.executee'
,
[
innobackupex_argument_list
,
environment
])
path_list
.
append
(
innobackupex_full
)
backup_controller
=
self
.
createPythonScript
(
self
.
options
[
'backup-script'
],
__name__
+
'.innobackupex.controller'
,
[
innobackupex_incremental
,
innobackupex_full
,
full_backup
,
incremental_backup
])
path_list
.
append
(
backup_controller
)
# maatkit installation
for
pt_script_name
in
(
'pt-archiver'
,
'pt-config-diff'
,
'pt-deadlock-logger'
,
'pt-duplicate-key-checker'
,
'pt-fifo-split'
,
'pt-find'
,
'pt-fk-error-logger'
,
'pt-heartbeat'
,
'pt-index-usage'
,
'pt-kill'
,
'pt-log-player'
,
'pt-online-schema-change'
,
'pt-query-advisor'
,
'pt-query-digest'
,
'pt-show-grants'
,
'pt-slave-delay'
,
'pt-slave-find'
,
'pt-slave-restart'
,
'pt-table-checksum'
,
'pt-table-sync'
,
'pt-tcp-model'
,
'pt-trend'
,
'pt-upgrade'
,
'pt-variable-advisor'
,
'pt-visual-explain'
,
):
pt_argument_list
=
[
self
.
options
[
'perl-binary'
],
self
.
options
[
'%s-binary'
%
pt_script_name
],
'--defaults-file=%s'
%
mysql_conf_file
,
'--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
])
path_list
.
append
(
pt_exe
)
#
full_backup = self.options['full-backup-directory']
#
incremental_backup = self.options['incremental-backup-directory']
#
innobackupex_argument_list = [self.options['perl-binary'],
#
self.options['innobackupex-binary'],
#
'--defaults-file=%s' % mysql_conf_file,
#
'--socket=%s' %mysql_conf['socket'].strip(), '--user=root',
#
'--ibbackup=%s'% self.options['xtrabackup-binary']]
#
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])
#
path_list.append(innobackupex_incremental)
#
innobackupex_full = self.createPythonScript(self.options['innobackupex-full'], 'slapos.recipe.librecipe.execute.executee', [innobackupex_argument_list, environment])
#
path_list.append(innobackupex_full)
#
backup_controller = self.createPythonScript(self.options['backup-script'], __name__ + '.innobackupex.controller', [innobackupex_incremental, innobackupex_full, full_backup, incremental_backup])
#
path_list.append(backup_controller)
#
# maatkit installation
#
for pt_script_name in (
#
'pt-archiver',
#
'pt-config-diff',
#
'pt-deadlock-logger',
#
'pt-duplicate-key-checker',
#
'pt-fifo-split',
#
'pt-find',
#
'pt-fk-error-logger',
#
'pt-heartbeat',
#
'pt-index-usage',
#
'pt-kill',
#
'pt-log-player',
#
'pt-online-schema-change',
#
'pt-query-advisor',
#
'pt-query-digest',
#
'pt-show-grants',
#
'pt-slave-delay',
#
'pt-slave-find',
#
'pt-slave-restart',
#
'pt-table-checksum',
#
'pt-table-sync',
#
'pt-tcp-model',
#
'pt-trend',
#
'pt-upgrade',
#
'pt-variable-advisor',
#
'pt-visual-explain',
#
):
#
pt_argument_list = [self.options['perl-binary'],
#
self.options['%s-binary' % pt_script_name],
#
'--defaults-file=%s' % mysql_conf_file,
#
'--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])
#
path_list.append(pt_exe)
return
path_list
software/erp5/instance-mariadb-prod.cfg
View file @
9005805e
...
...
@@ -2,13 +2,10 @@
parts =
publish-mariadb-url
mariadb-instance
mydumper-import
logrotate
logrotate-entry-mariadb
cron
cron-entry-logrotate
cron-entry-mariadb-backup
cron-entry-mariadb-mydumperbackup
binary-link
eggs-directory = ${buildout:eggs-directory}
...
...
@@ -19,12 +16,12 @@ offline = true
recipe = slapos.cookbook:publishurl
url = mysql://$${mariadb-instance:user}:$${mariadb-instance:password}@$${mariadb-instance:ip}:$${mariadb-instance:port}/$${mariadb-instance:database}
[cron-entry-mariadb-backup]
<= cron
recipe = slapos.cookbook:cron.d
name = mariadb-backup
frequency = 0 0 * * *
command = $${mariadb-instance:backup-script}
#
[cron-entry-mariadb-backup]
#
<= cron
#
recipe = slapos.cookbook:cron.d
#
name = mariadb-backup
#
frequency = 0 0 * * *
#
command = $${mariadb-instance:backup-script}
[mariadb-instance]
recipe = slapos.cookbook:generic.mysql
...
...
@@ -92,33 +89,33 @@ pt-visual-explain-binary = ${perl:siteprefix}/bin/pt-visual-explain
xtrabackup-binary = ${xtrabackup:location}/bin/xtrabackup_51
perl-binary = ${perl:location}/bin/perl
[mydumper]
recipe = slapos.cookbook:mydumper
wrapper = $${rootdirectory:bin}/raw_mydumper
backup-directory = $${directory:mariadb-backup}
socket = $${mariadb-instance:socket}
user = root
mydumper-binary = ${mydumper:location}/bin/mydumper
database = $${mariadb-instance:database}
import = false
compression = true
[cron-entry-mariadb-mydumperbackup]
<= cron
recipe = slapos.cookbook:cron.d
name = backup
frequency = 0 * * * *
command = $${mydumper:wrapper}
[mydumper-import]
recipe = slapos.cookbook:mydumper
wrapper = $${rootdirectory:bin}/myloader
backup-directory = $${directory:mariadb-backup}
socket = $${mariadb-instance:socket}
user = root
myloader-binary = ${mydumper:location}/bin/myloader
database = $${mariadb-instance:database}
import = true
#
[mydumper]
#
recipe = slapos.cookbook:mydumper
#
wrapper = $${rootdirectory:bin}/raw_mydumper
#
backup-directory = $${directory:mariadb-backup}
#
socket = $${mariadb-instance:socket}
#
user = root
#
mydumper-binary = ${mydumper:location}/bin/mydumper
#
database = $${mariadb-instance:database}
#
import = false
#
compression = true
#
#
[cron-entry-mariadb-mydumperbackup]
#
<= cron
#
recipe = slapos.cookbook:cron.d
#
name = backup
#
frequency = 0 * * * *
#
command = $${mydumper:wrapper}
#
#
[mydumper-import]
#
recipe = slapos.cookbook:mydumper
#
wrapper = $${rootdirectory:bin}/myloader
#
backup-directory = $${directory:mariadb-backup}
#
socket = $${mariadb-instance:socket}
#
user = root
#
myloader-binary = ${mydumper:location}/bin/myloader
#
database = $${mariadb-instance:database}
#
import = true
[logrotate]
recipe = slapos.cookbook:logrotate
...
...
@@ -161,6 +158,13 @@ name = logrotate
frequency = 0 0 * * *
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]
recipe = slapos.cookbook:symbolic.link
target-directory = $${rootdirectory:bin}
...
...
@@ -196,6 +200,7 @@ cron-entries = $${rootdirectory:etc}/cron.d
crontabs = $${rootdirectory:etc}/crontabs
cronstamps = $${rootdirectory:etc}/cronstamps
ca-dir = $${rootdirectory:srv}/ssl
mariadb-dump = $${basedirectory:backup}/mariadb-dump
mariadb-backup = $${basedirectory:backup}/mariadb
mariadb-backup-full = $${basedirectory:backup}/mariadb-full
mariadb-backup-incremental = $${basedirectory:backup}/mariadb-incremental
...
...
software/erp5/software.cfg
View file @
9005805e
...
...
@@ -69,7 +69,7 @@ mode = 0644
[template-mariadb-prod]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-mariadb-prod.cfg
md5sum =
5ee6e8a9917b488c49ae0d7ce13c51ee
md5sum =
ca020131ac05ca71bce624a5f65e9f53
output = ${buildout:directory}/template-mariadb-prod.cfg
mode = 0644
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment