0

Hello to professionals ! There was a good and simplest script idea to make mysqldump of every database - taken from
dump all mysql tables into separate files automagically? author - https://stackoverflow.com/users/1274838/elias-torres-arroyo with script as follows

#!/bin/bash
# Optional variables for a backup script
MYSQL_USER="root"
MYSQL_PASS="PASSWORD"
BACKUP_DIR="/backup/01sql/";
# Get the database list, exclude information_schema
for db in $(mysql -B -s -u $MYSQL_USER --password=$MYSQL_PASS -e 'show databases' | grep -v information_schema)
do
# dump each database in a separate file
mysqldump -u $MYSQL_USER --password=$MYSQL_PASS "$db" | gzip > "$BACKUP_DIR/$db.sql.gz"
done
sh

but the problem is that this script does not "understand" arguments like

--add-drop-database

to perform

      mysqldump -u $MYSQL_USER --password=$MYSQL_PASS "$db" --add-drop-database | gzip > "$BACKUP_DIR/$db.sql.gz"

Is there any idea how to force this script to understand the additional arguments listed under

    mysqldump --help

because while all my tests shows it doesn't. Thank you in advance for any hint to try !

Community
  • 1
  • 1
Serge
  • 679
  • 1
  • 9
  • 23
  • `but the problem is that this script does not "understand" arguments like`, WHat error do you get ? What do you mean by "does not understand"? – slayedbylucifer Jan 08 '14 at 08:30
  • no errors at all. Just no reaction. If I add --add-drop-database - it does not perform it. So I try to guess while. – Serge Jan 08 '14 at 09:07
  • ...can't understand local comments system...I mean - no errors at all. Just no reaction. If I add --add-drop-database - it does not perform it. The basic code looks very direct and simple - but does not react to any arguments listed under mysqldump --help. So I try to guess why. May be a specific syntax should be used ? – Serge Jan 08 '14 at 09:22
  • What if you give some garbage option? does it give you syntax error or something? if it does, then I guess `--add-drop-database` is doing what it is supposed to do, just that it does not throw any output on hte screen. – slayedbylucifer Jan 08 '14 at 10:09
  • Of course I check the dump file output after performing of the script above. Even with --add-drop-database - as I said above - nothing in dump file. So this argument (under this code) does nothing. – Serge Jan 08 '14 at 10:15
  • tagged the question with `mysqldunp` hoping some one good at mysqldump will help you. – slayedbylucifer Jan 08 '14 at 10:47

1 Answers1

0

--add-drop-database works only with --all-databases or --databases. See please the reference in docs

So in your case mysqldump utility ignore mentioned parameter because you are going to dump one database.

ravnur
  • 2,772
  • 19
  • 28