Perform a full dump before upgrading MariaDB
This commit is contained in:
@@ -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