InnoDB配置说明:
innodb_data_home_dir = ./
innodb_data_file_path = ibdata1:50M:autoextend
innodb_log_group_home_dir = ./
innodb_log_files_in_group = 4
innodb_log_file_size = 104857600
可以把这个my.ini参数文件放在非mysql的安装目录下。
备份命令:
xtrabackup --defaults-file=/path/my.ini --backup --target-dir=/path
---target-dir 参数指定的是mysql的备份目的地
---xtrabackup只会备份跟innodb相关的数据文件,而不会备份.frm文件,所以对于.frm文件最好是进行了表结构变更后,就备份
---一次。
恢复命令:
xtrabackup --defaults-file=/path/my.int --prepare --target-dir=/path
---target-dir 是备份时指定的目录
xtrabackup --defaults-file=/path/my.int --prepare --target-dir=/path
这个prepare要执行两次,才会真正的恢复。
把恢复后的文件拷回mysql的数据目录就可以了。
增量备份:
xtrabackup --defaults-file=/path/my.ini --backup --target-dir=/path/incrbackup --incremental-basedir=/path/fullbackup
增量恢复:
需要对全量和增量各做一次prepare
xtrabackup --defaults-file=/path/my.int --prepare --target-dir=/path/fullbackup
xtrabackup --defaults-file=/path/my.int --prepare --target-dir=/path/incrbackup
windows下的perl备份脚本
#perl -w
sub gettime {
($sec,$min,$hour,$day,$mon,$year,$weekday,$yeardate,$savinglightday)
= (localtime(time));
$sec = ($sec < 10)? "0$sec":$sec;
$min = ($min < 10)? "0$min":$min;
$hour = ($hour < 10)? "0$hour":$hour;
$day = ($day < 10)? "0$day":$day;
$mon = ($mon < 9)? "0".($mon+1):($mon+1);
$year += 1900;
$today = "$year-$mon-$day";#:$hour:$min:$sec";
return $today;
}
$backup_exe_path="E:\mysqlbackup\tool";
$exe_name="xtrabackup.exe";
$config_file=" --defaults-file=E:\mysqlbackup\my.ini ";
$backup_dir="e:\backup";
$backup_target=gettime;
$backup_path=$backup_dir."\".$backup_target;
#system "mkdir",$backup_path;
$backup_cmd=$backup_exe_path."\".$exe_name." --backup".$config_file." --target-dir=".$backup_path;
system $backup_cmd;
声明: 此文观点不代表本站立场;转载须要保留原文链接;版权疑问请联系我们。