2

I am looking for mysql database backup script to backup each database into separate files windows and exclude system database like mysql, information schema.

ex: db1, db2 db1_date_time.sql , db2_date_time.sql

Saran
  • 71
  • 7

2 Answers2

2

I have some sample posts from the past on running mysqldumps in Windows and creating .BAT files for them to execute

Here are other old posts on dumping mysqldumps into specific databases

I hope these help. Have a good day !!!

RolandoMySQLDBA
  • 182,700
  • 33
  • 317
  • 520
0

I have a Bash script backup-mysql-databases.sh for Linux that does exactly what is required here. The same workflow should be easy to convert for Windows.

databases=$(
  mysql -N -B -e "SHOW DATABASES;" \
    | grep -E -v "$ExcludeDatabases"
)

for db in $databases; do mysqldump --databases "$db" done

  1. List all databases with mysql -N -B -e "SHOW DATABASES;"
  2. Remove the databases you would like to exclude from the list.
  3. Iterate over the resulting list, e.g., with FOR /F, running mysqldump --databases "$db".
Esa Jokinen
  • 421
  • 5
  • 8