Perform a full dump before upgrading MariaDB
This commit is contained in:
2
install
2
install
@@ -9,7 +9,7 @@
|
||||
# -------------------------------------------------------------------------
|
||||
# wget -qO wo wops.cc && sudo -E bash wo
|
||||
# -------------------------------------------------------------------------
|
||||
# Version 3.12.4 - 2020-10-14
|
||||
# Version 3.13.0 - 2020-10-22
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
# CONTENTS
|
||||
|
||||
2
setup.py
2
setup.py
@@ -27,7 +27,7 @@ if os.geteuid() == 0:
|
||||
os.makedirs('/var/lib/wo/tmp/')
|
||||
|
||||
setup(name='wordops',
|
||||
version='3.12.4',
|
||||
version='3.13.0',
|
||||
description='An essential toolset that eases server administration',
|
||||
long_description=LONG,
|
||||
long_description_content_type='text/markdown',
|
||||
|
||||
@@ -26,7 +26,7 @@ class WOStackMigrateController(CementBaseController):
|
||||
@expose(hide=True)
|
||||
def migrate_mariadb(self):
|
||||
# Backup all database
|
||||
WOMysql.backupAll(self)
|
||||
WOMysql.backupAll(self, fulldump=True)
|
||||
|
||||
if not WOVar.wo_distro == 'raspbian':
|
||||
if (not WOVar.wo_platform_codename == 'jessie'):
|
||||
|
||||
@@ -964,7 +964,9 @@ def post_pref(self, apt_packages, packages, upgrade=False):
|
||||
'/etc/mysql/conf.d/my.cnf')
|
||||
except CommandExecutionError:
|
||||
Log.error(self, "Unable to set MySQL password")
|
||||
Log.info(self, "Tuning MariaDB configuration")
|
||||
WOGit.add(self, ["/etc/mysql"],
|
||||
msg="Adding MySQL into Git")
|
||||
Log.wait(self, "Tuning MariaDB configuration")
|
||||
if not os.path.isfile("/etc/mysql/my.cnf.default-pkg"):
|
||||
WOFileUtils.copyfile(self, "/etc/mysql/my.cnf",
|
||||
"/etc/mysql/my.cnf.default-pkg")
|
||||
@@ -1013,15 +1015,16 @@ def post_pref(self, apt_packages, packages, upgrade=False):
|
||||
'mariadb.service.d/limits.conf',
|
||||
'[Service]\nLimitNOFILE=500000')
|
||||
WOShellExec.cmd_exec(self, 'systemctl daemon-reload')
|
||||
Log.valide(self, "Tuning MySQL configuration")
|
||||
# set innodb_buffer_pool_instances depending
|
||||
# on the amount of RAM
|
||||
|
||||
WOService.stop_service(self, 'mysql')
|
||||
WOService.restart_service(self, 'mysql')
|
||||
|
||||
# WOFileUtils.mvfile(self, '/var/lib/mysql/ib_logfile0',
|
||||
# '/var/lib/mysql/ib_logfile0.bak')
|
||||
# WOFileUtils.mvfile(self, '/var/lib/mysql/ib_logfile1',
|
||||
# '/var/lib/mysql/ib_logfile1.bak')
|
||||
WOService.start_service(self, 'mysql')
|
||||
|
||||
WOCron.setcron_weekly(self, 'mysqlcheck -Aos --auto-repair '
|
||||
'> /dev/null 2>&1',
|
||||
|
||||
@@ -315,7 +315,7 @@ class WOStackUpgradeController(CementBaseController):
|
||||
# mariadb upgrade
|
||||
if ("mariadb-server" in apt_packages and
|
||||
mariadbmajorupgrade is True):
|
||||
WOMysql.backupAll(self)
|
||||
WOMysql.backupAll(self, fulldump=True)
|
||||
WOAptGet.remove(self, ["mariadb-server"])
|
||||
# upgrade packages
|
||||
WOAptGet.install(self, apt_packages)
|
||||
|
||||
@@ -88,7 +88,7 @@ class WOMysql():
|
||||
finally:
|
||||
connection.close()
|
||||
|
||||
def backupAll(self):
|
||||
def backupAll(self, fulldump=False):
|
||||
import subprocess
|
||||
try:
|
||||
Log.info(self, "Backing up database at location: "
|
||||
@@ -98,24 +98,47 @@ class WOMysql():
|
||||
Log.debug(self, 'Creating directory'
|
||||
'/var/lib/wo-backup/mysql')
|
||||
os.makedirs('/var/lib/wo-backup/mysql')
|
||||
|
||||
db = subprocess.check_output(["/usr/bin/mysql "
|
||||
"-Bse \'show databases\'"],
|
||||
universal_newlines=True,
|
||||
shell=True).split('\n')
|
||||
for dbs in db:
|
||||
if dbs == "":
|
||||
continue
|
||||
Log.info(self, "Backing up {0} database".format(dbs))
|
||||
if not fulldump:
|
||||
db = subprocess.check_output(
|
||||
["/usr/bin/mysql "
|
||||
"-Bse \'show databases\'"],
|
||||
universal_newlines=True,
|
||||
shell=True).split('\n')
|
||||
for dbs in db:
|
||||
if dbs == "":
|
||||
continue
|
||||
Log.info(self, "Backing up {0} database".format(dbs))
|
||||
p1 = subprocess.Popen(
|
||||
"/usr/bin/mysqldump {0} --max_allowed_packet=1024M "
|
||||
"--single-transaction ".format(dbs),
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE, shell=True)
|
||||
p2 = subprocess.Popen(
|
||||
"/usr/bin/zstd -T0 -c > "
|
||||
"/var/lib/wo-backup/mysql/{0}{1}.sql.zst"
|
||||
.format(dbs, WOVar.wo_date),
|
||||
stdin=p1.stdout, shell=True)
|
||||
# Allow p1 to receive a SIGPIPE if p2 exits
|
||||
p1.stdout.close()
|
||||
output = p1.stderr.read()
|
||||
p1.wait()
|
||||
if p1.returncode == 0:
|
||||
Log.debug(self, "done")
|
||||
else:
|
||||
Log.error(self, output.decode("utf-8"))
|
||||
else:
|
||||
Log.info(self, "Backing up all databases")
|
||||
p1 = subprocess.Popen(
|
||||
"/usr/bin/mysqldump {0} --max_allowed_packet=1024M "
|
||||
"--single-transaction ".format(dbs),
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
|
||||
"/usr/bin/mysqldump --all-databases "
|
||||
"--max_allowed_packet=1024M "
|
||||
"--single-transaction --events",
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE, shell=True)
|
||||
p2 = subprocess.Popen(
|
||||
"/usr/bin/zstd -T0 -c > "
|
||||
"/var/lib/wo-backup/mysql/{0}{1}.sql.zst"
|
||||
.format(dbs, WOVar.wo_date), stdin=p1.stdout, shell=True)
|
||||
# Allow p1 to receive a SIGPIPE if p2 exits
|
||||
"/var/lib/wo-backup/mysql/fulldump-{0}.sql.zst"
|
||||
.format(WOVar.wo_date),
|
||||
stdin=p1.stdout, shell=True)
|
||||
p1.stdout.close()
|
||||
output = p1.stderr.read()
|
||||
p1.wait()
|
||||
@@ -123,6 +146,7 @@ class WOMysql():
|
||||
Log.debug(self, "done")
|
||||
else:
|
||||
Log.error(self, output.decode("utf-8"))
|
||||
|
||||
except Exception as e:
|
||||
Log.error(self, "Error: process exited with status %s"
|
||||
% e)
|
||||
|
||||
@@ -14,7 +14,7 @@ class WOVar():
|
||||
"""Intialization of core variables"""
|
||||
|
||||
# WordOps version
|
||||
wo_version = "3.12.4"
|
||||
wo_version = "3.13.0"
|
||||
# WordOps packages versions
|
||||
wo_wp_cli = "2.4.0"
|
||||
wo_adminer = "4.7.5"
|
||||
@@ -83,7 +83,7 @@ class WOVar():
|
||||
while not match(r"^[A-Za-z0-9\.\+_-]+@[A-Za-z0-9\._-]+\.[a-zA-Z]*$",
|
||||
wo_email):
|
||||
print("Whoops, seems like you made a typo - "
|
||||
"the e-mailaddress is invalid...")
|
||||
"the e-mail address is invalid...")
|
||||
wo_email = input("Enter your email: ")
|
||||
|
||||
git.config("--global", "user.name", "{0}".format(wo_user))
|
||||
|
||||
Reference in New Issue
Block a user