We have a MySQL server with several databases for development work and we want to back up some of the DBs to a NAS device.
These have been backed up previously but the backups have not worked for some time I have found.
There is a scheduled task in the Windows scheduler to run a batch script, this script should run the backup for the specified databases and save them to the NAS. When I run the task, I can see the folders and files being created on the NAS but the resulting backup file is always 0 KB so there is clearly something not working correctly.
I've queried the sizes of the DBs on the server and have seen that the DBs I'm trying to back up are not 0 KB.
I'm thinking it must be something in the script which is not working correctly so would appreciate some assistance.
del \\[NAS_IP]\Backups\MySQL\VMmySQLdevW7\Day1 /Y
rmdir \\[NAS_IP]\Backups\MySQL\VMmySQLdevW7\Day1 /S /Q
ren \\[NAS_IP]\Backups\MySQL\VMmySQLdevW7\Day2 Day1
ren \\[NAS_IP]\Backups\MySQL\VMmySQLdevW7\Day3 Day2
ren \\[NAS_IP]\Backups\MySQL\VMmySQLdevW7\Day4 Day3
ren \\[NAS_IP]\Backups\MySQL\VMmySQLdevW7\Day5 Day4
ren \\[NAS_IP]\Backups\MySQL\VMmySQLdevW7\Day6 Day5
ren \\[NAS_IP]\Backups\MySQL\VMmySQLdevW7\Day7 Day6
ren \\[NAS_IP]\Backups\MySQL\VMmySQLdevW7\Day8 Day7
ren \\[NAS_IP]\Backups\MySQL\VMmySQLdevW7\Day9 Day8
ren \\[NAS_IP]\Backups\MySQL\VMmySQLdevW7\Day10 Day9
ren \\[NAS_IP]\Backups\MySQL\VMmySQLdevW7\Day11 Day10
ren \\[NAS_IP]\Backups\MySQL\VMmySQLdevW7\Day12 Day11
ren \\[NAS_IP]\Backups\MySQL\VMmySQLdevW7\Day13 Day12
ren \\[NAS_IP]\Backups\MySQL\VMmySQLdevW7\Day14 Day13
ren \\[NAS_IP]\Backups\MySQL\VMmySQLdevW7\Day15 Day14
ren \\[NAS_IP]\Backups\MySQL\VMmySQLdevW7\Day16 Day15
ren \\[NAS_IP]\Backups\MySQL\VMmySQLdevW7\Day17 Day16
ren \\[NAS_IP]\Backups\MySQL\VMmySQLdevW7\Day18 Day17
ren \\[NAS_IP]\Backups\MySQL\VMmySQLdevW7\Day19 Day18
ren \\[NAS_IP]\Backups\MySQL\VMmySQLdevW7\Day20 Day19
ren \\[NAS_IP]\Backups\MySQL\VMmySQLdevW7\Day21 Day20
ren \\[NAS_IP]\Backups\MySQL\VMmySQLdevW7\Day22 Day21
ren \\[NAS_IP]\Backups\MySQL\VMmySQLdevW7\Day23 Day22
ren \\[NAS_IP]\Backups\MySQL\VMmySQLdevW7\Day24 Day23
ren \\[NAS_IP]\Backups\MySQL\VMmySQLdevW7\Day25 Day24
ren \\[NAS_IP]\Backups\MySQL\VMmySQLdevW7\Day26 Day25
ren \\[NAS_IP]\Backups\MySQL\VMmySQLdevW7\Day27 Day26
ren \\[NAS_IP]\Backups\MySQL\VMmySQLdevW7\Day28 Day27
ren \\[NAS_IP]\Backups\MySQL\VMmySQLdevW7\Day29 Day28
ren \\[NAS_IP]\Backups\MySQL\VMmySQLdevW7\Day30 Day29
md \\[NAS_IP]\Backups\MySQL\VMmySQLdevW7\Day30
mysqldump -u[user] -p[password] -databases [db1] [db2] [db3]> \\[NAS_IP]\Backups\MySQL\VMmySQLdevW7\Day30\vmmysqldevw7.sql
rem Send mail to alerts.infrastructure on completion
mailsend -sub "Backup of VMmySQLdevW7 Completed" < InputFile.txt
The email alerts appear not to work either...
The "inputFile.txt" file contains the mail server's IP address, domain name, MySQL server's name and the alerts email address.
1 Answer 1
The problem was the missing double hyphen in front of the databases switch. The line in question should have read like this:
mysqldump -u[user] -p[password] --databases [db1] [db2] [db3]> \\[NAS_IP]\Backups\MySQL\VMmySQLdevW7\Day30\vmmysqldevw7.sql
pause
command after the last batch line, disable task auto-close, and study the output of mysqldump and mailsend programs.