MySql database backup shell script
#!/bin/sh
# Setting date to name the backupfile with todays date
date=`/bin/date "+%Y%m%d"`
# creating backup folder
/bin/mkdir -p /mysqlbkp/dbbackup_$date
DBS="$(mysql -Bse 'show databases')"
for db in $DBS
do
/usr/bin/mysqldump --routines $db > /mysqlbkp/dbbackup_$date/$db.sql
done
The backups will be generated in the location /mysqlbkp under the folder dbbackup_todays date.
Comments
Post a Comment