Merge remote-tracking branch 'refs/remotes/origin/main'
This commit is contained in:
commit
e84857f46c
|
@ -44,6 +44,30 @@ ignorelist=("mysql" "performance_schema" "dbispconfig" "phpmyadmin" "roundcube")
|
|||
dumppath="/var/sqldumps"
|
||||
|
||||
|
||||
## MySQL Credentials
|
||||
|
||||
## If the username is left blank (null) then no MySQL login will be attempted.
|
||||
## If the password is left blank (null) then no Password will be used in the login attempt.
|
||||
|
||||
sqlusername="root"
|
||||
sqlpassword="djhfasdghfkjlahsdfjkh"
|
||||
|
||||
|
||||
## Determines login method.
|
||||
|
||||
if [[ -z $sqlusername ]]
|
||||
then
|
||||
sqlup=""
|
||||
else
|
||||
if [[ -z $sqlpassword ]]
|
||||
then
|
||||
sqlup="-u $sqlusername"
|
||||
else
|
||||
sqlup="-u $sqlusername -p$sqlpassword"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
## Removes previous SQL dumps and list files.
|
||||
|
||||
rm -f *.sql
|
||||
|
@ -52,7 +76,7 @@ rm -f *.list
|
|||
|
||||
## Creates a list file of all the databases.
|
||||
|
||||
mysql -e "show databases" | grep -Ev 'Database|information_schema' > db.list
|
||||
mysql $sqlup -e "show databases" | grep -Ev 'Database|information_schema' > db.list
|
||||
|
||||
|
||||
## Add a list of the unwanted databases to the list file.
|
||||
|
@ -60,6 +84,7 @@ mysql -e "show databases" | grep -Ev 'Database|information_schema' > db.list
|
|||
for ((n=0; n<${#ignorelist[@]}; n++))
|
||||
do
|
||||
echo ${ignorelist[$n]} >> db.list
|
||||
echo ${ignorelist[$n]} >> db.list
|
||||
done
|
||||
|
||||
|
||||
|
@ -68,7 +93,7 @@ done
|
|||
|
||||
sort db.list | uniq -u | while read -r dbname; do
|
||||
echo "Dumping $dbname to $dumppath/$dbname.sql"
|
||||
mysqldump $dbname > "$dumppath/$dbname.sql"
|
||||
mysqldump $sqlup $dbname > "$dumppath/$dbname.sql"
|
||||
done
|
||||
|
||||
rm db.list
|
||||
|
|
Loading…
Reference in New Issue