0

I need to start creating daily backup dumps for some specific tables in a database. The database contains several hundred tables, and it is really time consuming to manually select the correct tables. It is impractical to export the entire database at once because of its size.

Is it possible to create a query to run this export manually, or is there some way I could save which tables in the database I want to export, so that I could quickly run the export at the end of the day?

Any suggestions on how to go about this would be appreciated

  • 1
    you have the answer [Here](https://dba.stackexchange.com/questions/9306/how-do-you-mysqldump-specific-tables) mysqldump – Dani Aug 18 '22 at 19:45
  • I suspect you already know how to get the data out like Dani said, but I think you are actually asking how to make it something you just call? Are you meaning you would like perhaps to use a Stored Procedure so you can just be like "CALL DB.BACKUP" and be done with it ? Just type that exact thing in when you want a backup to happen? And then once you got the procedure, you could automate it in the Event Schedule so it just runs automatically every day and really work yourself out of a job. – easleyfixed Aug 18 '22 at 19:53
  • https://stackoverflow.com/questions/6560639/how-to-schedule-a-stored-procedure-in-mysql <--- info on how to make it automatic after you got the stored procedure – easleyfixed Aug 18 '22 at 19:56
  • I might be missing something really obvious, but how do I run the mysqldump command? Do I just enter that in to a sql file, like ` mysqldump -u root -p database `. It says I have an error in my SQL syntax if I try to run it like that – Ethan Graybeal Aug 18 '22 at 20:08
  • Is that something I need to run in the windows cmd? – Ethan Graybeal Aug 18 '22 at 20:10
  • IF you want to automate it you can put this line in a script (sh in linux, bat in windows) and use cron in linux or windows scheduler . – Dani Aug 19 '22 at 05:22

1 Answers1

1

You have the answer here

mysqldump -u... -p mydb t1 t2 t3 > tables.sql
Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
Dani
  • 14,639
  • 11
  • 62
  • 110
  • IF you want to automate it you can put this line in a script (sh in linux, bat in windows) and use cron in linux or windows scheduler . – Dani Aug 19 '22 at 05:22