Win32 MySQL Backup Solution to CD-RW

Small, short code snippets that other people may find useful. Do you have a good regex that you would like to share? Share it! Even better, the code can be commented on, and improved.

Moderator: General Moderators

Post Reply
User avatar
Pyrite
Forum Regular
Posts: 769
Joined: Tue Sep 23, 2003 11:07 pm
Location: The Republic of Texas
Contact:

Win32 MySQL Backup Solution to CD-RW

Post by Pyrite »

First, get the XP/2003 Power Toy CDCreate CLi Tool and put it in your path (ie. c:\windows).

Then put this batch file in your path too. Call it what you want.

Then you can setup the Schedule Tasks to run this batch file every day or whatever.

Begin cms_backup.bat

Code: Select all

@echo off
REM Create IBS MySQL Dump Backup
echo Creating MySQL Backup ...
c:\mysql\bin\mysqldump -uroot -pyourpass --all-databases > d:\Backups\IBS-MySQL.sql

set MONTH=
set DAY=
set YEAR=
set HOUR=
set MIN=
set SECOND=
set MONTH=%DATE:~4,2%
set DAY=%DATE:~7,2%
set YEAR=%DATE:~12,2%
set HOUR=%TIME:~0,2%
set MINUTE=%TIME:~3,2%
set SECOND=%TIME:~6,2%

set NEWFILE="IBS-MySQL-%YEAR%-%MONTH%-%DAY%-%HOUR%.sql"
REM Rename Backup to IBS-MySQL-YY-MM-DD-Hour.sql Format
echo Renaming Backup to %NEWFILE%
ren "d:\Backups\IBS-MySQL.sql" %NEWFILE%

REM Backup File To CD-RW at E:\
echo Erasing CDRW and Burning %NEWFILE% to CDRW
d:
cd d:\Backups
createcd -e -r:e %NEWFILE%

echo All Done.
You get the idea, hopefully. This really helps me. I can setup my Windows 2003 Server to backup my files and MySQL dump to a CD-RW every night. It erases the same CD-RW every night before writting to it. This is just a secondary backup solution for me, easier than restoring tape.

You can also probably use the same type of scenario on Linux with cdrecord.
Post Reply