Monday, October 17, 2016

Percona server full backup

Perform Percona DB Backup


Take a backup

     mkdir -p Databases/Backups
     sudo innobackupex --user=root  --password=secret --host=127.0.0.1 ~/Databases/Backups/

Prepare the backup

     sudo innobackupex --apply-log /Databases/Backups/2015-12-31_12-00-32/
 
NOTE: Move the backup copy to the remote server where the backup will be restored. Be careful with this process to avoid eating up all your network resources especially if the remote server is far.

     sudo service mysql stop
     sudo mv /var/lib/mysql /var/lib/mysql-backup     #save the original mysql dir
     sudo mv /path/to/2015-12-31_12-00-32 /var/lib/mysql
     sudo chown mysql:mysql -R /var/lib/mysql/
     sudo service mysql restart

NOTE- at this point, the full backup is ccomplete. But if you wish to make the new server a replica following a backup you can continue with the steps below:

Configure GTID enabled replication

In the my.cnf config file, add the following params under [mysqld]
 
    server-id               = ip  # i like to use the IP here
    log_bin                 = /var/log/mysql/mysql-bin.log
    expire_logs_days        = 7
    max_binlog_size         = 100M
    binlog_format = ROW
    log-slave-updates = true
    gtid_mode = ON
    enforce-gtid-consistency = 1
 

First, get the grid_purged value from your your new data dir
      cd /var/lib/mysql
      cat xtrabackup_binlog_info
      mysql -uroot -p #log onto mysql
      mysql> SET GLOBAL gtid_purged="bad31d61-6363-ee1a-433b-941925b8ed06:1-2”;
      mysql>CHANGE MASTER TO MASTER_HOST=“ip", MASTER_USER=“superuser",
                 MASTER_PASSWORD=“superpass", MASTER_AUTO_POSITION=1;
    mysql>start slave;
    mysql>show slave status\G
 
If there are some issues while setting up GTID enabled replication with, then check out the blog below on how some of these issues can be resolved


REFERENCES

https://www.percona.com/blog/2013/02/08/how-to-createrestore-a-slave-using-gtid-replication-in-mysql-5-6/
https://www.percona.com/doc/percona-xtrabackup/2.2/howtos/recipes_ibkx_stream.html

No comments:

Post a Comment