Windows计划任务实现MYSQL冷备份

Posted 项希盛

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Windows计划任务实现MYSQL冷备份相关的知识,希望对你有一定的参考价值。

BAT代码

@ECHO OFF
for %%i in (%0) do (set "name=%%~ni")
title %name%
set targetsql="%~dp0firadio3324"
mkdir %targetsql% 2>NUL
ECHO ======Start=======
SET config= --defaults-file=%~dp0my.ini --single-transaction
"%~dp0..mysqldump.exe" %config% firadio_ucenter>%targetsql%firadio_ucenter-all.sql
"%~dp0..mysqldump.exe" %config% firadio_yun_agent>%targetsql%firadio_yun_agent-all.sql

"%~dp0..mysqldump.exe" %config% --no-data firadio_uc>%targetsql%firadio_uc-nodata.sql
"%~dp0..mysqldump.exe" %config% --no-create-info --ignore-table=firadio_uc.uc_qq_msg_group --ignore-table=firadio_uc.uc_qq_msg_group_send --ignore-table=firadio_uc.uc_qq_msg_pri --ignore-table=firadio_uc.uc_qq_msg_pri_send --ignore-table=firadio_uc.uc_qq_base --ignore-table=firadio_uc.uc_session firadio_uc>%targetsql%firadio_uc-data.sql

"%~dp0..mysqldump.exe" %config% --no-data firadio_yun>%targetsql%firadio_yun-nodata.sql
"%~dp0..mysqldump.exe" %config% --no-create-info --ignore-table=firadio_yun.yun_ntuser_process_hour --ignore-table=firadio_yun.yun_ntuser_process_log --ignore-table=firadio_yun.yun_sensor_log --ignore-table=firadio_uc.yun_location_trace --ignore-table=firadio_uc.yun_ntuser_signin firadio_yun>%targetsql%firadio_yun-data.sql

ECHO ======End=======
set "Ymd=%date:~,4%%date:~5,2%%date:~8,2%"
set h=%time:~0,2%
set h=%h: =0%
set "His=%h%%time:~3,2%%time:~6,2%"
echo %Ymd%%His%
mkdir "%~dp0xz" 2>NUL
"%~dp0..7z.exe" a -ttar %targetsql%.tar %targetsql%
"%~dp0..7z.exe" a -txz "%~dp0xz\%Ymd%%His%.tar.xz" %targetsql%.tar
ECHO ======Finish=======

 

 

my.ini

[mysql]
host=mysql.vegan365.xyz
port=3306
user=firadio
password=*******
default-character-set=utf8

[mysqldump]
host=vps.firadio.net
port=3324
user=adm-ro
password=********
default-character-set=utf8

 

以上是关于Windows计划任务实现MYSQL冷备份的主要内容,如果未能解决你的问题,请参考以下文章

Windows下MySQL自动备份的batch脚本

windows环境设置mysql自动备份(测试成功)

windows环境设置mysql自动备份(测试成功)

Navicat设定mysql实时备份计划任务问题

windows计划任务+批处理文件实现oracle数据库的定时备份与恢复

通过windows计划任务和Dos批处理备份文件