Question

I am very good using GNU/Linux, however on Windows I suck.

Making a dump of the local DB with mysqldump, compress the result, give it an incremental name and make it a cron task it's a very easy task for me.

But on Windows, I don't have a clue. I want to make a .bat script, or a windows script, with the task tool. Compress the result and give it a name wit the date in the PC. I using Wamp as server and I can't use GNU/Linux because my boss don't want it.

Google don't give me any good answer.

How can I do a good automated task for baking up with my desire characteristics on Windows 7 with Wamp?

Was it helpful?

Solution 2

At the end I do it myself in VBS:

Rem Plan de trabajo:
Rem 1. Dumpear la base de datos en un archivo.
Rem 2. Renombrar el archivo a uno con la fecha del dia en el nombre.
Rem 3. Comprimir el archivo con Compact
Rem 4. Borrar el archivo no comprimido.
Rem 5. Mover el archivo comprimido a la carpeta c:\Users\jvalenzuela\Documents\backups

Rem Lo que hace el script

Rem Le decimos que es un shell
Dim WshShell, oExec
Set WshShell            = WScript.CreateObject("WScript.Shell")

Rem Agarramos la fecha 
CurrentDate             = Date
Rem Le damos formato a la fecha
Fecha                   = FormatDateTime(CurrentDate, vbShortDate)
Rem le decimos cual es el directorio de backup
BackupDir               = "C:\Users\jvalenzuela\Documents\backups"
Rem Le damos la ubicación de mysqldump
MySQLDump               = "C:\wamp\bin\mysql\mysql5.6.12\bin\mysqldump.exe"
Rem  formateamos el nombre del respaldo
NombreDump              = BackupDir & "\backup." & Fecha & ".sql"

Rem y le damos argumentos
MySqlDumpArguments      = "-uroot --result-file=""" & NombreDump & """ --all-databases"

Rem Armamos el comando
comandoFinal            =  MySqlDump & " " & MySqlDumpArguments

Rem Y lo ejecutamos
set oExec = WshShell.Exec(comandoFinal)

Rem vemos si resultó el respaldo
if oExec.Status = 0 Then
        WshShell.Run "compact  /c " & NombreDump 
Rem y si no resultó, lo registramos como error en el visosr de sucesos
Else
        WshShell.LogEvent 1, "No se relizó el respaldo de base de datos del día"
End If

Rem este script no tiene poderes de super vaca

And add it to the tasks scheduler. Have fun!

OTHER TIPS

Here is what i do.

I first run mysqldump to get .sql file using current date. Next i run this script to compress it and move it into another folder. You can combine these two steps but i am posting here as a separate script to illustrate:

@echo off

set sourceDir=C:\mysql\mysqldump
set targetDir="C:\Users\Admin\Google Drive\mysql-backup"


@echo on

7z a %targetDir%\backup-%date:~-7,2%.7z %sourceDir%\backup-%date:~-7,2%.sql

@echo off

Be sure to have 7z program installed on your Windows computer.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top