The scripts allows you to backup and restore a database from LVM2 snapshots.
-
mysql-server package installed
-
nfs-utils package installed and activated + an athore vm (for database slave)
-
db_test for testing the scripts
To unzip the database you'll need a tool that can read .zip like winzip that we'll use in this exemple :
shell> unzip test_db-master.zip
shell> cd test_db-master/
Then import the database :
shell> mysql -uroot -p -t < employees.sql
Script modification :
Change the variable ipServer in var.sh by the ip of your vm that will be the nfs server
Firewall access :
shell> firewall-cmd --permanent --zone=public --add-service=ssh
shell> firewall-cmd --permanent --zone=public --add-service=nfs
shell> firewall-cmd --reload
Server side :
- Create a directory nfs and give the own / rights :
shell> mkdir /var/nfs
shell> chown nfsnobody:nfsnobody /var/nfs
shell> chmod 755 /var/nfs
- Modify exports file
shell> nano /etc/exports
/var/nfs IPCLIENT(rw,sync,no_subtree_check)
- Save changes on exports
shell> exportfs -a
Client side
- Create a nfs directory :
shell> mkdir -p /mnt/nfs/var/nfs
-
Create a directory /backup before anything:
shell> mkdir /backup
-
Launch backup.sh with sudo or in su :
shell> sudo sh backup.sh
-
Once it's launched a password we'll be asked, enter your root password for mysql
TO DO