MySQL Forums
Forum List  »  InnoDB

Re: Backup Of all databases
Posted by: Peter Brawley
Date: July 20, 2017 01:08PM

Here's a generic version of a batch script I've used for years. It assumes the windows/dos environment var MYSQL_HOME contains the path to the MySQL bin folder. Replace BACKUP_FOLDER, NAMED_LANSTATION, NAMED_NETWORK_DRIVE and MySQL username USR & password PWD with your values. Beware that Windows date oarsing changed a bit between win7 and win10.

REM BACKUP ALL MYSQL DBs TO BACKUP_FOLDER, COPY TO NAMED_NETWORK_DRIVE/BACKUP on NAMED_LANSTATION
@echo off
for /f "tokens=2-4 delims=/- " %%a in ('date /t') do set XDate=%%c%%a%%b
if exist BACKUP_FOLDER\mysql_%XDate%.sql del BACKUP_FOLDER\mysql_%XDate%.sql
%mysql_home%\bin\mysqldump -uUSR-pPWD -A --add-drop-database -K -E -R >c:\backup\BACKUP_FOLDER\mysql_%XDate%.sql
dir c:\backup\BACKUP_FOLDER\mysql_%XDate%.sql

:NETCOPY
if not exist n: net use n: \\NAMED_LANSTATION\NAMED_NETWORK_DRIVE "" /user:administrator
if not exist n:\ goto NETERR
xcopy c:\backup\BACKUP_FOLDER\mysql_%XDate%.sql n:\backup\mysql\ /d/y
dir n:\backup\BACKUP_FOLDER\mysql\mysql_%XDate%.sql
goto STOP

:NETERR
echo Error: Cannot reach drive n:.

:STOP
if not "%1"=="nopause" pause

Options: ReplyQuote


Subject
Views
Written By
Posted
931
July 20, 2017 12:08PM
Re: Backup Of all databases
640
July 20, 2017 01:08PM
494
July 20, 2017 01:58PM
443
July 20, 2017 04:06PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.