Jump to content

Automatically Backup Database


dzhax
 Share

Recommended Posts

I am worried about forgetting to backup my website so I made a batch file to backup the folder. Now I want to add into the same batch that it backs up my mysql database also. Is this possible in a batch file? And if so does anyone know how to do it? The DBMS the database is in is phpmyadmin so i would have to remotely connect to it to download a specific database in it.Any help is appreciated.

Edited by dzhax
Link to comment
Share on other sites

I can not seem to get it to work...I found some information about how to use it on google and it seems clear.here is what i have

@echo offsetlocalFOR /F "TOKENS=1* DELIMS=  " %%A IN ('DATE/T')	   DO SET CDATE=%%AFOR /F "TOKENS=3  DELIMS=/ " %%A IN ('echo %CDATE%') DO SET mm=%%AFOR /F "TOKENS=2  DELIMS=/ " %%A IN ('echo %CDATE%') DO SET dd=%%AFOR /F "TOKENS=4* DELIMS=/ " %%A IN ('echo %CDATE%') DO SET yyyy=%%ASET _Today=%YYYY%-%MM%-%dd%SET _Drive=C:set backupcmd=xcopy /s /c /d /e /h /i /r /k /y:checkdir1IF NOT EXIST %_Drive%\backup (GOTO :createdir1) else GOTO :checkdir2:checkdir2IF NOT EXIST %_Drive%\backup\%_Today% (GOTO :createdir2) else GOTO :backupdb:runbackupecho ### Backing up Arcane-Arena Website%backupcmd% "Z:\localhost" "%_Drive%\backup\%_Today%\arcane-arena_website\localhost"echo %YYYY%-%MM%-%dd%: Arcane-Arena_Website Backup Completed! >> %_Drive%\backup\backups.logGOTO backupdb:createdir1mkdir %_Drive%\backupGOTO checkdir2:createdir2mkdir %_Drive%\backup\%_Today%GOTO runbackup:backupdbcd "C:\www\mysql5\bin"mysqldump --compact -q -h localhost -u root -p[rootwdp] website > %_Drive%\backup\%_Today%\arcane-arena_website\database\website.sql pauseexit

I know it skips :runbackup for now because it just takes to long to wait for just to see if database backs up right.This is what prints out

The system cannot find the path specified.Press any key to continue . . .

Link to comment
Share on other sites

OK, so it can't find something you're trying to do. Remove or comment out lines until you can narrow down which thing it can't find.
its the part about the mysql i have it skipping all the rest and going straight to it... I have it installed and it is pointing to the correct place. Is the mysqldump statement mistyped?I even tried putting mysqldump in the same directory and pointing to it... still does same thing Edited by dzhax
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...