mysql 逻辑备份_mysql逻辑备份

一、逻辑备份

1.mysqldump

备份策略

1.逻辑热备

2.备份周期

保留一周,日志保留一周,本地备份

3.crontab

目录规划

mkdir -p /mysqldump/{log,data,bash}

备份用户

grant select on *.* to 'bkusr'@'192.168.110.%' identified by 'bkpwd';

flush privileges;

备份脚本

mkdir -p /mysqldump/{log,data,bash}

cd /mysqldump/bash

vim mysqldump.sh

#!/bin/sh

bkusr=bkusr

bkpwd=bkpwd

bkhst=`ip a|grep 'inet '|awk -F"/" '/[1][9][2][.][1][6][8]*/{print $1}'|awk '{print $2}'`

bkpt=3306

bkdir="/mysqldump/data"

mysqldump -u${bkusr} -p${bkpwd} -h${bkhst} -P${bkpt} --single-transaction --all-databases > $bkdir/all_databases_${bkhst}_${bkpt}_`date +%F`.sql

故障:

# time ./mysqldump.sh

Warning: Using a password on the command line interface can be insecure.

mysqldump: Couldn't execute 'show create table `vw_gm_stat`': SHOW VIEW command denied to user 'bkusr'@'xxx.xxx.xxx.xxx' for table 'vw_gm_stat' (1142)

权限问题,加上即可

你可能感兴趣的:(mysql,逻辑备份)