简体   繁体   中英

How can I automate mysqldump database backups in Windows Server 2012?

I'm trying to get mysqldump to do backups to a .sql file automatically, I have being reading that I need to use cron jobs or Windows Task Scheduler ; the problem is that I can't find anything online that shows me how to do it.

To do the backups I'm using cmd with the following commands:

mysqldump --user username --password=123  databtable > backup.sql

This command works perfectly, it does create the .sql file but how do I automate it in such a way that it does the backup every certain time.

Hopefully you can help me and thank you so much!

You should use the schtasks command in Windows. Command syntax details are available here: https://technet.microsoft.com/en-us/library/cc772785(v=ws.10).aspx

You could also use the Task Scheduler application in Windows if you like GUIs:

  1. Create a new basic task
  2. Set the Trigger (run daily, weekly, etc)
  3. Set the Action. (what program to run) Be sure to include only the executable in the Program field, and put the command arguments in the Add Arguments field.

You probably want to set your task to 'Run whether the user is logged on or not' . This is achieved by modifying the task, and adjusting the Security Options on the General Tab of the task.

When troubleshooting your task, use the History tab for info regarding job failures.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM