Physical backup:
Mysql
Show variables like 'datadir ';
Use hellodb;
Show table status;
Mysql
Flush logs with read lock;
\ Q
Lvcreate-L 50 M-n mysnap-s/dev/myvg/mydata
Mysql
Unlock tables;
\ Q
Mount/dev/myvg/mysnap/mnt
Cd/mnt
Cd data/
Ls
Tar-jcf/root/mysql.tar.bz2 hellodb ibdata1 ib_logfile * mysql-bin *
Ls
Cd
Umount/mnt
Lvremove -- force/dev/myvg/mysnap
Service mysqld start
Ls/mydata/data
Rm-rf/mydata/data /*
Cd/usr/local/mysql
Chown-R mysql: mysql data/
Scripts/-- datadir =/mydata/data -- user = mysql
Killall mysqld
Service mysqld start
Service mysqld stop
Cd/mydata
Cd data
Ls
Tar xf/root/mysql.tar.bz2-C ./
Ls
Service mysqld start
Mysql
Show databases;
Incremental Backup:
SHOW MASTER STATUS
Lvcreate-L 50 M-n mysnap-s/dev/myvg/mydata
Mysql
Unlock tables;
Tar-jcf/root/mysql.tar.bz2 hellodb ibdata1 ib_logfile * mysql-bin *
Mysql
Use hellodb;
Insert into t2 values ('huhu ')
Show master status;
Mysqlbinlog -- start-position 201 mysql-bin.000004>/root/mysql2.incr. SQL
Cd
Serviece mysqld stop
Rm-rf/mydata/data /*
Cd/usr/local/mysql
Chown-R mysql: mysql data/
Scripts/-- datadir =/mydata/data -- user = mysql
Service mysqld start
Serviece mysqld stop
Cd/mydata/data/
Tar xf/root/mysql.tar.bz2-C ./
Service mysqld start
Mysql
Use hellodb;
SELECT * FROM t2;
# Mysql <root/mysql2.incr. SQL
Mysql
Use hellodb;
SELECT * FROM t2;
Author: "linux"