Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I'm trying to run a bash script to backup my database with Cronjob.

# Backup and compress each database
for database in $mysql_databases
do
  if [ "${database}" == "information_schema" ] || [ "${database}" == "performance_schema" ]; then
        additional_mysqldump_params1="--single-transaction"
  else
        additional_mysqldump_params=""
  fi
  echo "Creating backup of \"${database}\" database"
  mysqldump ${additional_mysqldump_params} --user=${mysql_user} --password=${mysql_password} ${database} | gzip > "${backup_dir}/${database}.gz"
  chmod 600 "${backup_dir}/${database}.gz" ${additional_mysqldump_params1}
done

but the --single-transaction option is not recognized

share|improve this question

1 Answer 1

up vote 1 down vote accepted

OBSERVATION #1

It is not recognized because of a typo

You have

  if [ "${database}" == "information_schema" ] || [ "${database}" == "performance_schema" ]; then
        additional_mysqldump_params1="--single-transaction"
  else
        additional_mysqldump_params=""
  fi

It should be

  if [ "${database}" == "information_schema" ] || [ "${database}" == "performance_schema" ]; then
        additional_mysqldump_params="--single-transaction"
  else
        additional_mysqldump_params=""
  fi

Please change the additional_mysqldump_params1 to additional_mysqldump_params

OBSERVATION #2

You have

chmod 600 "${backup_dir}/${database}.gz" ${additional_mysqldump_params1}

It should read

chmod 600 "${backup_dir}/${database}.gz"

Please remove additional_mysqldump_params1 from that line of code

OBSERVATION #3

There is no need to mysqldump information_schema or performance_schema databases

  • The INFORMATION_SCHEMA database is made of up in-memory temporary tables. They are dynamically generated and populated on mysqld startyo.
  • The PERFORMANCE_SCHEMA database is for the instrumentation of measuring performance. Each individual MySQL instance is responsible for populating it with instrumentation data when it is in use.
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.