Script for dumping your drupal database by reusing settings.php
| Attachment | Size |
|---|---|
| 506 bytes |
Not able to find the page where I found that script so posting is here.
#!/bin/bash
# A simple script to avoid remembering database information for command line
# SQL connections.
# TODO: postgres
if [ -z "$1" ]; then
echo "usage: $0 sites/default/settings.php" >&2
exit 1
fi
if [ ! -r "$1" ]; then
echo "$1 is not readable" >&2
exit 1
fi
settings=$1
shift
args=$@
$(php -r "
include '$settings';
\$conn = parse_url(\$db_url);
print 'mysqldump -u '. \$conn['user'] .' -p'. \$conn['pass'] .' -h '. \$conn['host'] .' '. substr(\$conn['path'], 1) .' $args';
")
Add new comment