• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

MySQL Backup Question

D

DoobyWho

Guest
I have two MySQL backup questions:


(1) Is there a way to do an incremental MySQL backup, specifically where each database is it's own .SQL file?

I know you can do an incremental backup and I know you can backup each to it's own .sql, but both together?



(2) How can this be modified to work for RHE3? I found this script and it looks like a decent mysql backup script if the above question isn't possible.

#!/bin/sh
# mysqlback.sh -- do mysql database dumps -- t|<evans
# Sun Jun 22 11:00:35 EDT 2003
##############################
PATH=/usr/local/bin:$PATH
BACKDIR=/data/backups/mysql
DAYSBACK=7
export PATH BACKDIR DAYSBACK
#
########################
# clean up backups older
# than $DAYSBACK
########################
cd $BACKDIR
find . -mtime +$DAYSBACK -exec rm -f {} \;
#########################
# get a list of databases
#########################
cat <<EOF > tmpsql$$
show databases;
EOF
mysql -u root --password=XXXXX < tmpsql$$ | sed '/Database/d' >
dblist$$
############################
# back each one up in turn;
# --opt locks tables during
# backup, so no need to shut
# down mysql; but access will
# be denied during backup
#
# we also pipe through gzip
############################
for DB in `cat dblist$$`
do mysqldump -u root --password=XXXXX --opt --flush-logs $DB | gzip
\
> $DB.`date '+%m.%d.%y'`.gz
done
###################
# empty the logfile
###################
rm /var/mysql/mysql.log.*
cat /dev/null > /var/mysql/mysql.log

#######
# email
#######
ls -l $BACKDIR | /usr/bin/mailx -s "MySQL Backup Completed" admin
##########
# clean up
##########
rm dblist$$ tmpsql$$
 
Back
Top