Thursday, November 21, 2013

Create daily mysql backup with task scheduler

Here is one example of creating daily backup of mysql database and keep the database file on another sever for later use.
creat one batch file mysql-backup.bat. and keep this code in the batch file.

@echo off
echo Running dump...
C:\wamp\bin\mysql\mysql5.5.20\bin\mysqldump.exe -e -uexampleuser -ppass123 --result-file="\\path-to-server\dbbackup\foo-db-%DATE:~10,4%-%DATE:~7,2%-%DATE:~4,2%.sql" foodb
echo Done!

Then create a scheduled task and run this batch file. So it will take the daily backup and will keep different name depend on the server date.
You can ignore some tables if you like

@echo off
echo Running dump...

C:\wamp\bin\mysql\mysql5.5.20\bin\mysqldump.exe -e -uexampleuser -ppass123 --result-file="\\path-to-server\dbbackup\foo-db-%DATE:~10,4%-%DATE:~7,2%-%DATE:~4,2%.sql" foodb --ignore-table=foodb .mdl_log --ignore-table=foodb .mdl_sessions

echo Done!

keep in mind that you have to give your mysqldump.exe path and also the path of the file, where you want to keep your db dump.

Wednesday, November 20, 2013

Run cron jobs on Windows

You can just cron your jobs in windows environment with just one line. I have almost spent my 5 hours so i want to share with other is make a task.

     


  • In program give php.exe path, with my installation it is c:\wamp\bin\php\php5.3.5\php.exe.

  •  


  • Second you have to put the file absolute path, which you want to run. -f c:\wamp\www\foo\foo.php in the argument

  • So that's complete. There is no need for installing anything.

    Monday, November 18, 2013

    Array

    Array:
    Array is a group of items similar in properties.
    Item consist of two items, key and value.
    PHP is loosely typed, so there is no need to define the array at the begining and there is no need to tell the size before using it.
    Create an array with array() keyword.