Search K
Appearance
Appearance
This script is called before/after a database is created.
This script is called before/after a MySQL database is deleted.
The hook script called when deleting a Database User.
Note that database_destroy_user_post.sh will not be called when a database and its users are being deleted.
It's only called when a single DB user is removed from a database.
This means that any code used in database_user_create_post.sh will have to be doubled in database_delete_post.sh.
The hook script called after a database user is created. This script would not be called when a database and its user is being created.
These are custom pre/post scripts that are called if a DB User's password is set.
One could use the database_delete_pre.sh to create an sql backup prior to database deletion to prevent loss of data due to accidental deletion. Note, though, that you would likely want to implement a way to purge these stored sql files every so often via cron to prevent them from accumulating and filling your disk space.
!#/bin/bash
DIR="/home/$username/deleted_dbs"
if [ ! -d $DIR ] ; then
mkdir -p $DIR
fi
mysqldump --defaults-extra-file=/usr/local/directadmin/conf/my.cnf $database > $DIR/$database.sql
retval=$?
if [ $retval -eq 0 ]; then
exit 0;
else
exit 1;
fi