exportDatabase.sh 561 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/bash
# schachi 2017-01-19
# export database for transport

  if test $# -ge 1; then
    if test $1 = "-h" || test $1 = "--help"; then
      echo "Execute $0 <db-name>"
      exit 0
    else
      db=$1
      path="/tmp"
    fi
  else
    path=`dirname $PWD`
    db=mpidb_`basename $path`
  fi

  echo -n "Export database $db to $PWD/$db.sql ? (y/[n]) : "
  read ok
  if test -z $ok; then ok="n"; fi
  if test "$ok" != "y"; then exit 0; fi

23
  /usr/bin/mysqldump -p --events --routines --skip-extended-insert --skip-comments --databases $db > $PWD/$db.sql