3
Is it possible to perform automatic backup in mysql? Example: I direct a folder that Mysql will generate every day at 18:00 the backup of the database.
3
Is it possible to perform automatic backup in mysql? Example: I direct a folder that Mysql will generate every day at 18:00 the backup of the database.
2
Hello,
I did an automation of this by creating a file. bat with the commands and configuring the execution in the Windows Task Scheduler, follows below my bat file:
@echo off
cls
REM Define o usuário e senha do banco de dados
set dbUser=xxx
set dbPassword=xxx
REM Define a pasta que será feito o backup no padrão ...\<dia do mês>\<hora atual>
set backupDir=C:\Backup\MySQL\%date:~0,2%\%time:~0,2%\
REM Nome do arquivo que será gerado
set file=xxx.sql
REM Caminho dos executáveis do mysqldump.exe, para executar o dump, e do 7z.exe, para compactar o arquivo
set mysqldump="C:\wamp64\bin\mysql\mysql5.7.14\bin\mysqldump.exe"
set zip="C:\Program Files\7-Zip\7z.exe"
REM Cria a pasta de backup caso não exista
if not exist "%backupDir%" (
mkdir "%backupDir%"
)
REM Executa o dump, aqui precisa configurar o host e o nome do banco de dados (locais com xxx)
%mysqldump% --host="xxx" --user=%dbUser% --password=%dbPassword% xxx > "%backupDir%\%file%"
REM Compacta o arquivo com o dump
%zip% a -tgzip "%backupDir%\%file%.gz" "%backupDir%\%file%"
REM Exclui o arquivo .sql original
del "%backupDir%\%file%"
In case, it creates a folder for the day of the month, does the dump and compresses the file.
Browser other questions tagged mysql mysqldump
You are not signed in. Login or sign up in order to post.
Dude, before testing, you could detail the line functionality: set backupDir=C: Mysql backup%date:~0,2%time:~0,2% set mysqldump="C: wamp64 bin mysql mysql5.7.14 bin mysqldump.exe" set zip="C: Program Files 7-Zip 7z.exe"
– Pedro
I commented on the code :)
– Diego Marques