I want backup my mysql database with lvm. I will do the backup with cronjob. Here the pseudocode
- Open mysql session
- Run SQL
FLUSH TABLES WITH READ LOCK
- Do backup
lvcreate -l100%FREE -s -n mysql-backup /dev/vg00/lv_var
- Run SQL
UNLOCK TABLES
- done
Between step 2 until 4, mysql session must keep opened.
So now I have solved this in my script:
mysql -u root -prootpwd -e "FLUSH TABLES WITH READ LOCK";
lvcreate -l100%FREE -s -n mysql-backup /dev/vg00/lv_var
mysql -u root -prootpwd -e "UNLOCK TABLES";
but how to keep the mysql session open in my script?
Normally, I should open mysql session to run FLUSH TABLES WITH READ LOCK
but not terminating the this mysql session. In another shell I should do the lvcreate
command, after that I must unlock the tables in the first shell.
The other part with second mysql instance and mysqldump working without problems.
How I can do that?