zoukankan      html  css  js  c++  java
  • mysql Percona-XtraBackup backup

    全量备份FULL BACKUP
    https://www.percona.com/doc/percona-xtrabackup/2.4/backup_scenarios/full_backup.html#preparing-a-backup
     
    全量备份CHEETSHEET
    下载(示例:centos7下2.4.4版本,用https://www.percona.com/downloads/XtraBackup/LATEST/选择适合版本)
    $ wget https://www.percona.com/downloads/XtraBackup/Percona-XtraBackup-2.4.4/binary/redhat/7/x86_64/percona-xtrabackup-24-2.4.4-1.el7.x86_64.rpm
     
    安装
    yum localinstall percona-xtrabackup-24-2.4.4-1.el7.x86_64.rpm
     
    卸载
    $ yum remove percona-xtrabackup
     
    备份
    $ 执行备份(innobackupex --defaults-file=/etc/my.cnf --user=root --password='p4ssword' --stream=tar --databases="database_name" /opt/backup/ | gzip > /opt/backup/data-`date +%Y%m%d`.tar.gz;
    $ sleep 5;
    $ dbfilename=data;
    $ 删除前7天的备份(find /opt/backup/ -mtime +7 -name "$dbfilename*.tar.gz" -exec rm -rf {} ;
     
    $ 解压备份(tar -zxvf data-20180904.tar.gz -C data
     

    After you made a backup with the xtrabackup --backup option, you’ll first need to prepare it in order to restore it. Data files are not point-in-time consistent until they’ve been prepared, because they were copied at different times as the program ran, and they might have been changed while this was happening. If you try to start InnoDB with these data files, it will detect corruption and crash itself to prevent you from running on damaged data. The xtrabackup --prepare step makes the files perfectly consistent at a single instant in time, so you can run InnoDB on them.

    You can run the prepare operation on any machine; it does not need to be on the originating server or the server to which you intend to restore. You can copy the backup to a utility server and prepare it there.

    $ xtrabackup --prepare --target-dir=/data/backups/
     
    $ 还原前需要先停掉mysql服务(systemctl stop mysqld [OR] service mysqld stop)
    $ 还原前需要先清空/var/lib/mysql目录(rm -rf /var/lib/mysql
    $ 执行还原操作(innobackupex --copy-back /path/to/BACKUP-DIR
    $ 文件权限还原给mysql(chown -R mysql:mysql /var/lib/mysql
    $ 启动mysql服务(systemctl start mysqld [OR] service mysqld start)
     
    增量备份INCREMENTAL BACKUP
    https://www.percona.com/doc/percona-xtrabackup/2.4/backup_scenarios/incremental_backup.html#incremental-backup
     
     
     
  • 相关阅读:
    Minimum Sum
    Prefix and Suffix
    BBuBBBlesort!
    Wanna go back home
    The Chosen One+高精度
    一元三次方程
    文本文件比对
    nginx日志文件切割
    nginx启动脚本
    nginx
  • 原文地址:https://www.cnblogs.com/xiayudashan/p/9583336.html
Copyright © 2011-2022 走看看