Jump to content
  • 0

Automatic database backup


Relentless

Question

Hey there,

after a whole day of trying, I want to ask for help now cause this is very annoying for me.
So the plan is to make an automated backup of my database and save it in a .sql file somewhere what is not necessary for now.

My plan was to make it a batch file and then add it to the scheduler. My current file looks like that:

@echo off

set backuppath="D:\whatever\Backup\Database"
set mysqlpath="C:\xampp\mysql\bin"
set dbuser=db_username
set dbpassword=db_password
set dbname=db_name

FOR /F "tokens=1-4 DELIMS=/ " %%F IN ('date /T') DO (set v_date=%%F%%G%%H) 
FOR /F "tokens=1-4 DELIMS=: " %%F IN ('time /T') DO (set v_time=%%F%%G%%H) 
set fname=database_%v_date%_%v_time%.sql

start /d %mysqlpath% mysqldump.exe -e -u%dbuser% -p%dbpassword% %dbname% > %backuppath%\%fname%
stop

I consored the db related stuff but you can be sure that I looked into that several times and the credentials for the database are right. The current problem is that this batch file creates the wanted database.sql file but it has 0kb and is as it is expected to be completly empty. The weird thing is that when I run the script there's another command prompt that's popping up, scrolling down all the data that is provided in the database so as it is supposed to be. But it's not saving those information.


Is anyone able to help me? I tried that batch file on my local computer and there it works like love but not on my virtual server.
Would like to get some help. Greetz, Martin

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

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
  • Discord

×
×
  • Create New...