Script de backup de todos os banco de dados do mysql para arquivo no formato .sql via .bat
:: Check to see if files older than 7 day exist
FORFILES /P "C:\MySQLBackup" /M * /D -7 /C "CMD /C DEL @path"
:: MySQl DB user
SET dbuser=root
SET dbuser=root
:: MySQl DB users password
SET dbpass=************
SET dbpass=************
:: Switch to the MySQL data directory and collect the folder names
PUSHD "C:\ProgramData\MySQL\MySQL Server 5.6\data"
PUSHD "C:\ProgramData\MySQL\MySQL Server 5.6\data"
:: Loop through the folders and use the fnames for the sql filenames, collects all databases automatically this way
ECHO "Pass each name to mysqldump.exe and output an individual .sql file for each"
FOR /D %%F IN (*) DO (
"C:\Program Files\MySQL\MySQL Server 5.6\bin\mysqldump.exe" -u %dbuser% -p%dbpass% -P 3306 %%F > "C:\MySQLBackup\%%F_%date:~-4,4%%date:~-7,2%%date:~-10,2%.sql"
)-
0 comentários :
Postar um comentário