Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Use credentials in /etc/mysql/debian.cnf to export MySQL database
- database="$1"
- shift
- options="$@"
- if [[ -z "$database" ]]; then
- echo "Usage: $0 database [options]" >&2
- exit 2
- fi
- user=$(sudo grep user /etc/mysql/debian.cnf | head -n1 | sed -r 's/^.+=\s*//')
- pass=$(sudo grep password /etc/mysql/debian.cnf | head -n1 | sed -r 's/^.+=\s*//')
- socket=$(sudo grep socket /etc/mysql/debian.cnf | head -n1 | sed -r 's/^.+=\s*//')
- mysqldump \
- --user="$user" \
- --password="$pass" \
- --socket="$socket" \
- --add-drop-table \
- --add-locks \
- --comments \
- --create-options \
- --disable-keys \
- --dump-date \
- --extended-insert \
- --no-create-db \
- --lock-tables \
- --set-charset \
- --quick \
- --routines \
- --events \
- --triggers \
- $options \
- $database
Add Comment
Please, Sign In to add comment