Commit 5c3deb64 authored by Jérome Perrin's avatar Jérome Perrin

erp5: exclude mysql database from mysqldump backups

parent 09f76ebf
......@@ -34,6 +34,7 @@ import socket
import time
import contextlib
import datetime
import subprocess
import MySQLdb
......@@ -86,6 +87,37 @@ class MariaDBTestCase(ERP5InstanceTestCase):
)
class TestCrontabs(MariaDBTestCase):
def _getCrontabCommand(self, crontab_name):
"""Read a crontab and return the command that is executed.
"""
with open(
os.path.join(
self.computer_partition_root_path,
'etc',
'cron.d',
crontab_name,
)) as f:
crontab_spec = f.read()
return " ".join(crontab_spec.split()[5:])
def test_full_backup(self):
subprocess.check_call(
self._getCrontabCommand('mariadb-backup'),
shell=True,
)
self.assertTrue(
glob.glob(
os.path.join(
self.computer_partition_root_path,
'srv',
'backup',
'mariadb-full',
'*gz',
)))
class TestMariaDB(MariaDBTestCase):
def test_utf8_collation(self):
cnx = self.getDatabaseConnection()
......
......@@ -26,7 +26,7 @@ md5sum = d10b8e35b02b5391cf46bf0c7dbb1196
[template-mariadb]
filename = instance-mariadb.cfg.in
md5sum = bfed6ac56c3ba0e96be4c9474dac6f20
md5sum = 1236505acbc989c9e9a8242b0a86f6fd
[template-kumofs]
filename = instance-kumofs.cfg.in
......
......@@ -107,7 +107,7 @@ time = {{ dumps(backup_periodicity) }}
# can be fully restored.
# master-data: use value "2" as we are not in a replication case
#}
command = "${binary-wrap-mysqldump:wrapper-path}" --all-databases --flush-privileges --single-transaction --max-allowed-packet=128M {% if incremental_backup_retention_days > -1 %}--flush-logs --master-data=2 {% endif %}| {{ parameter_dict['gzip-location'] }}/bin/gzip > "${directory:mariadb-backup-full}/$({{ parameter_dict['coreutils-location'] }}/bin/date "+%Y%m%d%H%M%S").sql.gz"
command = "${binary-wrap-mysqldump:wrapper-path}" --all-databases --error-exclude-database=mysql --flush-privileges --single-transaction --max-allowed-packet=128M {% if incremental_backup_retention_days > -1 %}--flush-logs --master-data=2 {% endif %}| {{ parameter_dict['gzip-location'] }}/bin/gzip > "${directory:mariadb-backup-full}/$({{ parameter_dict['coreutils-location'] }}/bin/date "+%Y%m%d%H%M%S").sql.gz"
{# KEEP GLOB PATTERN IN SYNC with generated filenames above
# YYYYmmddHHMMSS -#}
file-glob = ??????????????.sql.gz
......
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