Incremental backup and full backup mysql


mysql full volume and incremental backups

Full backup : You can use mysqldump directly back up an entire library or a library or a backup where a table in a library.

备份所有数据库:
[root@my ~]# mysqldump -uroot -p123456 --all-databases >/opt/all.sql
mysqldump: [Warning] Using a password on the command line interface can be insecure.

All single database table backup:
[the root @ My ~] Test # --databases the mysqldump -uroot--p123456> /opt/test.sql
the mysqldump: [Warning] A password ON the Using The Command Line interface CAN BE in the insecure.

Structure of a single table in the backup of the database:
[the root @ My ~] Test # -d -p123456 the mysqldump -uroot-UserInfo> /opt/test_userinfo_jiegou.sql
the mysqldump: [Warning] A password ON the Using The Command Line interface CAN BE in the insecure.

Contents of a single table in the backup of the database:
[the root @ My ~] Test # -p123456 the mysqldump -uroot-UserInfo> /opt/test_userinfo_neirong.sql
the mysqldump: [Warning] A password ON the Using The Command Line interface CAN BE in the insecure.


Incremental backup: incremental backup is a backup for in bin-log log database, bin-log log need to start the database. Incremental backups are operating on the basis of the full amount on. Incremental backups rely mainly on mysql bin-log log records. (It can be saved as a binary log file each day)

1. Open binary log files;
[the root @ My ~] # echo -e "log-bin = / usr / local / MySQL / logs / mysql_bin \ = nserver_id. 1 \ max_binlog_size = n-100M" >> / etc / the my.cnf 

The position values of the position recovery;
[the root @ My ~] # = the mysqlbinlog --start-position = position-795. 1 --stop /usr/local/mysql/logs/mysql_bin.000001 | MySQL -uroot--p123456

The recovery time point position; -d specified database, -h option specifies the host
[root @ my ~] #mysqlbinlog --start -date = '2019-05-30 14:49:25' --stop-date = ' 2019-05-30 14:52:39 '-d linux -h127.0.0.1 /usr/local/mysql/logs/mysql-bin.000001 | mysql -uroot -p123456

All the data records of all binary log files to recover;
[root @ My ~] # mysqlbinlog /usr/local/mysql/logs/mysql_bin.000001 | MySQL-uroot--p123123


Script:
full backup:
[root @ calldb1 ~] # CAT /shell/fs_sql_bak.sh 
# / bin / bash!
## beifen SQL

Bakdir=/data/sql-bak
Time=$(date +"%F_%T")
[ -f /usr/bin/mysqldump ] && echo "ok" || exit
/usr/bin/mysqldump -uroot -p123456 -R --all-databases > $Bakdir/$Time"_34.sql"
#echo $Bakdir/$Time"_34.sql"

增量备份:
[root@calldb2 shell]# cat zeng_sql.sh 
#!/bin/bash
## zeng liang bak sql
Logdir=/usr/local/mysql/logs
Time=$(date +%F)
mkdir $Logdir/"log-"$Time
find $Logdir -type f -mmin 1 -exec cp {} $Logdir/"log-"$Time/ \;

if [ -f $Logdir/"log-"$Time/mysql-bin.* ];then
  echo "mysql is zeng backup success on time-$(date +%F)" >>$Logdir/"log-"$Time/mysql_zeng_backup.log
else
  echo "mysql is zeng backup fail on time-$(date +%F)" >>$Logdir/"log-"$Time/mysql_zeng_backup.log
fi
mysqladmin -uroot -p123456 flush-logs >/dev/null

Production environment:
is recommended once a week or three days full backup, incremental backup once a day.
 

Original articles published 0 · won praise 27 · views 80000 +

Guess you like

Origin blog.csdn.net/yimenglin/article/details/104774398
Recommended