Merge remote-tracking branch 'refs/remotes/origin/main'

This commit is contained in:
Ze'ev Schurmann 2023-10-27 10:55:15 +02:00
commit e84857f46c
1 changed files with 27 additions and 2 deletions

29
sqldumps/sqldumps.sh Normal file → Executable file
View File

@ -44,6 +44,30 @@ ignorelist=("mysql" "performance_schema" "dbispconfig" "phpmyadmin" "roundcube")
dumppath="/var/sqldumps" 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. ## Removes previous SQL dumps and list files.
rm -f *.sql rm -f *.sql
@ -52,7 +76,7 @@ rm -f *.list
## Creates a list file of all the databases. ## 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. ## 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++)) for ((n=0; n<${#ignorelist[@]}; n++))
do do
echo ${ignorelist[$n]} >> db.list echo ${ignorelist[$n]} >> db.list
echo ${ignorelist[$n]} >> db.list
done done
@ -68,7 +93,7 @@ done
sort db.list | uniq -u | while read -r dbname; do sort db.list | uniq -u | while read -r dbname; do
echo "Dumping $dbname to $dumppath/$dbname.sql" echo "Dumping $dbname to $dumppath/$dbname.sql"
mysqldump $dbname > "$dumppath/$dbname.sql" mysqldump $sqlup $dbname > "$dumppath/$dbname.sql"
done done
rm db.list rm db.list