Adding a db removal tool.

This commit is contained in:
Ubergeek 2019-06-28 13:27:25 +00:00
parent 9bf8982535
commit 3e3838aef2
1 changed files with 14 additions and 0 deletions

14
dbremove Executable file
View File

@ -0,0 +1,14 @@
#!/bin/bash
ADMIN_EMAIL="root@thunix.net"
USER=$1
sudo mysqldump -u root $USER > /tmp/$USER.sql
sudo mv /tmp/$USER.sql /root/$USER.sql
sudo mysql -u root << _EOF
DROP DATABASE $USER;
FLUSH PRIVILEGES;
_EOF
echo "The databases for $USER has been archived, and removed." | sudo mail -s "Database for $USER has been removed" $ADMIN_EMAIL