Re: Cron Jobs
Posted: Sun Jun 27, 2010 6:15 pm
If you would create a tutorial on PHP security that would be awesome. I'm sure it would save myself and probably many others alot of time researching how to do basic security properly.
Create a document and save it as mysql-backup.bat (I opened notepad and done it, but your choice on how.) It is important that it is not saved as a .txt file.
Then in the batch file put the following:Note: c:\[location of mysql] line must ALL be on ONE line, or the batch file will not work.Code: Select all
@echo off echo Running backup... c:\[location of mysql]\bin\mysqldump -u [username] -p [password] --result-file="c:\backup.%DATE:~0,3%.sql" [database name] //remove the brackets and this comment echo Done!
c:\wamp\bin\mysql\mysql5.1.36\bin\mysqldump -u admin -p ******** --result-file="c:\backup.%DATE:~0,3%.sql" *****
The above location is where my database goes too. If its the same location, then just simply copy it. I have *** out certain information, but if you are not using a password, and simply using root as your username, then it would be -u root --result-file=".
Then after you put all that into your batch file, save it somewhere, and open up the command prompt. And type the following:What this is doing is backing up the chosen database at 2am daily to your chosen location in the mysql-backup.bat file. That should be all you need to do. If you need to remove the backup, simply do at [id] /delete and it will remove it. Simply do at to see what ID your job is.Code: Select all
at 02:00 /every:M,T,W,Th,F,S,Su c:\<path>\mysql-backup.bat where <path> is the location of where you put the mysql-backup.bat file.
SpiritWebb wrote:I ran the job and it completed successfully. So, if you are running WAMP, here is how you would write a cron in windows.
Create a document and save it as mysql-backup.bat (I opened notepad and done it, but your choice on how.) It is important that it is not saved as a .txt file.
Then in the batch file put the following:Note: c:\[location of mysql] line must ALL be on ONE line, or the batch file will not work.Code: Select all
@echo off echo Running backup... c:\[location of mysql]\bin\mysqldump -u [username] -p [password] --result-file="c:\backup.%DATE:~0,3%.sql" [database name] //remove the brackets and this comment echo Done!
c:\wamp\bin\mysql\mysql5.1.36\bin\mysqldump -u admin -p ******** --result-file="c:\backup.%DATE:~0,3%.sql" *****
The above location is where my database goes too. If its the same location, then just simply copy it. I have *** out certain information, but if you are not using a password, and simply using root as your username, then it would be -u root --result-file=".
Then after you put all that into your batch file, save it somewhere, and open up the command prompt. And type the following:What this is doing is backing up the chosen database at 2am daily to your chosen location in the mysql-backup.bat file. That should be all you need to do. If you need to remove the backup, simply do at [id] /delete and it will remove it. Simply do at to see what ID your job is.Code: Select all
at 02:00 /every:M,T,W,Th,F,S,Su c:\<path>\mysql-backup.bat where <path> is the location of where you put the mysql-backup.bat file.
?KunoNoOni wrote:ROFL!
-KunoNoOni