Mysql physical backup and Incremental Backup

Source: Internet
Author: User

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"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.