您好,登录后才能下订单哦!
备份:
mysqldump -uroot -p** -A -B -F --master-data=2 --single-transaction --events > /root/all.sql
恢复:
mysql -uroot -pVaren2100* < /root/all.sql
利用binlog日志进行增量恢复
利用位置恢复:
mysqlbinlog --start-position="154" --stop-position="789694" /var/lib/mysql/mysql-bin.000002 | mysql -uroot -p***
bin-log指定恢复数据库
分库备份:
#!/bin/sh
BACKPATH=/root/gool/backup
MYUSER=root
MYPASS=gool
MYCMD="mysql -u$MYUSER -p$MYPASS"
MYDUMP="mysqldump -u$MYUSER -p$MYPASS -x -B -F -R"
[ ! -d $BACKPATH ] && mkdir -p $BACKPATH
DBLIST=`$MYCMD -e "show databases;"|sed 1d|egrep -v "_schema|mysql|sys"`
for dbname in $DBLIST
do
$MYDUMP $dbname|gzip > /root/gool/backup/${dbname}_$(date +%F).sql.gz
done
分库分表备份:
#!/bin/sh
BACKPATH=/root/gool/backup
MYUSER=root
MYPASS=gool
MYCMD="mysql -u$MYUSER -p$MYPASS"
MYDUMP="mysqldump -u$MYUSER -p$MYPASS -x -F -R"
[ ! -d $BACKPATH ] && mkdir -p $BACKPATH
DBLIST=`$MYCMD -e "show databases;"|sed 1d|egrep -v "_schema|mysql|sys"`
for dbname in $DBLIST
do
TBLIST=`$MYCMD -e "show tables from $dbname;"|sed 1d`
for tablename in $TBLIST
do
mkdir -p $BACKPATH/$dbname
$MYDUMP $dbname $tablename |gzip > $BACKPATH/${dbname}/${tablename}_$(date +%F).sql.gz
done
done
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。