Admin Reports

22 Jan, 2008

Batch File to Backup Your Windows Server Database

Posted by: BSchwarz In: Tips and Tricks|Tutorials

This is a quick batch file that will create a date based backup. The file created will be backup_dbname_year_month_day.sql This is to backup one database. You cold change one line to backup all databases if you choose.

Here it is. As with the other file it is attached to this post.

@ECHO OFF
for /f “tokens=1-4 delims=/ ” %%a in (‘date/t’) do (
set dw=%%a
set mm=%%b
set dd=%%c
set yy=%%d
)

SET bkupdir=C:\path\to\backups
SET mysqldir=C:\path\to\mysql\bin
SET dbname=databasename
SET dbuser=databaseusername

@ECHO Beginning backup of %dbname%…

%mysqldir%\mysqldump -B %dbname% -u %dbuser% > %bkupdir%\BackUp_%dbname%_%yy%%mm%%dd%.sql
@ECHO Done. New File: dbBkup_%dbname%_%yy%%mm%%dd%.sql

That’s it. Just change the path variables and run the batch file from the command line. You can place it anywhere you like. I place it in the backup dir and run it from there.

If you have any questions you can post a comment to this article. If you want one o one help start a thread on the forum.

 

Files:
Backup to FTP Batch File
Date Based Database Backup Batch File

 


 

Pages: 1 2

No Responses to "Batch File to Backup Your Windows Server Database"

Comment Form

About

Admin Reports is a resource for forum and server admins geared towards admins that run communities on Windows Servers and IIS.

You will find tutorials, tips and tricks to tweak your Windows server, howto and reviews of forum software packages.

Advertisement

 

July 2010
M T W T F S S
« Sep    
 1234
567891011
12131415161718
19202122232425
262728293031  

Who is Online

Users: 4 Guests