[英]how to get incremental backup for mysql using shellscript
here the given below code it's correctly worked for backup but i need to change incremental backup. 在这里给定的以下代码,它已正确地用于备份,但我需要更改增量备份。 i want to take backup every 4 hour.
我想每4小时备份一次。 how to set time schedular in shell script ?
如何在shell脚本中设置时间表?
#!/bin/bash
TIMESTAMP=$(date +"%F")
BACKUP_DIR="/home/admin/$TIMESTAMP"
MYSQL_USER="test"
MYSQL=/usr/bin/mysql
MYSQL_PASSWORD="******"
MYSQLDUMP=/usr/bin/mysqldump
mkdir -p "$BACKUP_DIR/mysql"
databases=`$MYSQL --user=$MYSQL_USER -p$MYSQL_PASSWORD -e "SHOW DATABASES;" | grep -Ev "(Database|information_schema|performance_schema)"`
for db in $databases; do
$MYSQLDUMP --force --opt --user=$MYSQL_USER -p$MYSQL_PASSWORD --databases $db | gzip > "$BACKUP_DIR/mysql/$db.gz"
done
Take a look into mysql binary logs. 看看mysql二进制日志。 Basically two steps have to be done
基本上必须完成两个步骤
mysqldump provides you a full backup. mysqldump为您提供完整的备份。 The binary log all the changes that happened.
二进制日志记录了发生的所有更改。 That is the closest that comes to "incremental" backups in mysql.
这与mysql中的“增量”备份最接近。
See http://dev.mysql.com/doc/refman/5.5/en/binary-log.html for more details. 有关更多详细信息,请参见http://dev.mysql.com/doc/refman/5.5/en/binary-log.html 。 Be aware that you want
--master-data
flag for the mysqldump, else you don't know where to start in the binary log. 请注意,您需要mysqldump的
--master-data
标志,否则您将不知道从二进制日志中的何处开始。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.