generate backup file using date and time as filename
On Linux, simply put $(date +%Y-%m-%d-%H.%M.%S)
to show date and time in the file name, so it looks like:
mysqldump -u <user> -p <database> | bzip2 -c > <backup>$(date +%Y-%m-%d-%H.%M.%S).sql.bz2
(This command also compresses the file using bzip2)
I think the syntax of your mysqldump command is wrong;
mysqldump -u root -p --add-drop-table --create-options --password= onstor
You use both -p
and --pasword=
, you should only use one option. And there is a space before the password.
Just try to run the mysqldump command on the commandline to see error messages. Alternatively add 2>&1
at the end of the command in the batchfile. Then you would also see error messages in the output file.
mysqldump -u root --add-drop-table --create-options --password=onstor >c:\%mydate%_%mytime%.sql 2>&1