MySQL Forums
Forum List  »  Newbie

Re: Backup all existing databases except
Posted by: Barry Galbraith
Date: March 23, 2023 04:28PM

I found this on stackoverflow.
Does it help?
#!/bin/sh
DATABASES="$(/lighttpd/local/bin/mysql --user=user --password=pass -Bse 'show databases')"

for db in ${DATABASES[@]}
do
if [ $db == "information_schema" ]
then
continue
fi
echo ${db}-$(date +%m-%d-%y).sql.bz2 is being saved in /backup/mysql
mysqldump --user=user --password=pass $db --single-transaction -R | bzip2 -c > ${db}-$(date +%m-%d-%y).sql.bz2
done

You might need to edit the path to your mysql commandline, and edit the mysqldup options to suit what you want.

https://stackoverflow.com/questions/2773199/is-there-a-way-to-dump-all-mysql-databases-except-for-system-databases

Good luck,
Barry.

Options: ReplyQuote


Subject
Written By
Posted
Re: Backup all existing databases except
March 23, 2023 04:28PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.