Changes

Jump to navigation Jump to search
2,303 bytes added ,  17:52, 8 December 2013
Mariadb backup & restore
Line 1: Line 1: −
===Draft notes on installing mariadb 'alongside' mysql===
+
===Install mariadb 'alongside' mysql===
 +
====Draft notes on mariadb installation====
 
  <nowiki>
 
  <nowiki>
 
#####################################################################################
 
#####################################################################################
Line 59: Line 60:  
</nowiki>
 
</nowiki>
   −
* Nice notes. Would it be worth it to look at the pre-backup and pre-restore events (And config db settings) so MariaDB databases are being backup up ?
+
====Backup & Restore====
 +
* (RequestedDeletion) Nice notes. Would it be worth it to look at the pre-backup and pre-restore events (And config db settings) so MariaDB databases are being backup up ?
 +
=====/etc/e-smith/events/actions/mariadb-dump-tables=====
 +
* Based on /etc/e-smith/events/actions/mysql-dump-tables
 +
* "CONNECT" options separated out for easy modification and potential movement into db variables
 +
* "-x" option added to the mysqldump command line to avoid an error about locking log files
 +
<nowiki>#!/bin/sh
 +
#CONNECT=--socket=/opt/mariadb-data/mariadb.sock
 +
CONNECT="--protocol=TCP --port=3307"
    +
if ! $(mysqladmin $CONNECT ping >/dev/null 2>&1)
 +
then
 +
    echo "mariadb is not running - no tables dumped" >&2
 +
    exit 0
 +
fi
 +
 +
mkdir -p /home/e-smith/db/mariadb
 +
for db in $(mysql $CONNECT -BNre "show databases;")
 +
do
 +
    mysqldump $CONNECT  -x --add-drop-table  -QB "$db" -r /home/e-smith/db/mariadb/"$db".dump  || exit 1
 +
done</nowiki>
 +
=====/etc/e-smith/events/actions/mariadb-load-tables=====
 +
* based on /etc/e-smith/events/actions/mysql-load-tables
 +
* doesn't actually load the dbs
 +
* NEEDS EXAMINATION!
 +
<nowiki>#!/bin/sh
 +
#CONNECT=--socket=/opt/mariadb-data/mariadb.sock
 +
CONNECT="--protocol=TCP --port=3307"
 +
MARIADATA=/opt/mariadb-data
 +
 +
if ! $(mysqladmin $CONNECT ping >/dev/null 2>&1)
 +
then   
 +
    echo "mariadb is not running - no tables restored" >&2
 +
    exit 0
 +
fi
 +
 +
if [ ! -f $MARIADATA/mysql/user.frm ]
 +
then
 +
    mkdir -p /etc/e-smith/mariadb/init
 +
    for db in $(ls /home/e-smith/db/mariadb/*.dump 2> /dev/null | grep -v '/mysql.dump')
 +
    do
 +
        mv $db /etc/e-smith/mariadb/init/01_$(basename $db .dump).sql
 +
    done
 +
fi</nowiki>
 +
=====Automation=====
 +
======Backup======
 +
* Link mariadb-dump-tables into the pre-backup event
 +
* Dumped tables should be included in backups as they are stored under /home/e-smith
 +
<nowiki>cd /etc/e-smith/events/pre-backup
 +
ln -s ../actions/mariadb-dump-tables S20mariadb-dump-tables</nowiki>
 +
======Restore - NEEDS WORK======
 +
The SME Server mysql restore is complicated by various factors that may not apply to a mariadb "alongside" installation.
 +
Here's what would need to be done to restore all mariadb databases:
 +
* Reinstall mariadb, including setting the password to match the mysql root password
 +
* Restore the 'dump' files created during pre-backup individually using:
 +
<nowiki>cd /home/e-smith/db/mariadb
 +
CONNECT=--socket=/opt/mariadb-data/mariadb.sock
 +
mysql $CONNECT < <dbname>.dump</nowiki>
 +
 
===Install Moodle using git===
 
===Install Moodle using git===
 
====Installation====
 
====Installation====

Navigation menu