innobackupex备份目录

2023-12-13 20:07:41

innobackupeex全备脚本思路

四个需求如下:

(1)每天晚上23点执行,这需要linux系统做一个定时任务

00 23 * * * /bin/sh /shell/tencent_xtrabackup_all.sh /dev/null 2>&1

(2)每天。。看到这个词,也就是说,每天备份的数据要求分开

 month=`date +%m`
 day=`date +%d`
 year=`date +%Y`
 hour=`date +%H`
 min=`date +%M`
 dirname=$year-$month-$day

(3)备份mysql数据,需要开一个可以备份mysql数据库的用户

use mysql;
grant all privileges on *.* to 'root'@'%' identified by 'QQ61066319' with grant option;
flush privileges;

(4)备份的命令是什么,备份之后是否可以用tar -zcvf 新软件包.tar.gz 资料或数据目录 打包后是不是可以把原来的数据目录给删除了呢

/usr/local/xtrabackup/bin/innobackupex --defaults-file=/etc/my.cnf --user=root --password=QQ61066319 --host=localhost  /shell/xtrabackupDB/

全备脚本思路如下:

MysqlUser=root
MyseqlPwd=Fan.88888
hosts=127.0.0.1
month=`date +%m`
day=`date +%d`
year=`date +%Y`
hour=`date +%H`
min=`date +%M`
bakdir=/back/xtrabackup
dirname=$year-$month-$day
bakdir_mysql=$bakdir/$dirname/all/
bakdir_mysql_packaging=$bakdir/$dirname/packaging/
back_tar=${dirname}-${hour}-${min}
bakdir_mysql_rm=$bakdir/$dirname/
echo "$bakdir_mysql"
if [ ! -d "$bakdir_mysql" ]; then
  mkdir -p $bakdir_mysql
fi
if [ ! -d "$bakdir_mysql_packaging" ]; then
  mkdir -p $bakdir_mysql_packaging
fi
innobackupex  --defaults-file=/etc/my.cnf  --user=${MysqlUser} --password=${MyseqlPwd} --host=${hosts}  ${bakdir_mysql}

cd ${bakdir_mysql}
pwds=`pwd`

if [ "${bakdir_mysql}" == "${pwds}/" ]; then
      back_tar_name=${back_tar}.all.tar.gz
      tar -czf ${back_tar_name} ${bakdir_mysql}* -R
      [ $? != 0 ] && echo "tar -czf ${back_tar_name} ${bakdir_mysql}* -R" && exit

      mv ${back_tar_name} ${bakdir_mysql_packaging}
      echo "$bakdir_mysql Packaging success "

    cd ${bakdir_mysql_rm}
    pwds_bakdir_mysql_rm=`pwd`
    if [ "${bakdir_mysql_rm}" == "${pwds_bakdir_mysql_rm}/" ]; then
    fi

else
      echo "$bakdir_mysql Packaging not success "
fi

文章来源:https://blog.csdn.net/fan13938409755/article/details/134909205
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。