Posts

Restore single database from full Xtrabackup backup

Percona Xtrabackup does not have any direct way to import single database. I have found a script to restore single database written by Phil Buescher . I have made few changes in the script. There are few perquisite to run the script. You can download the script from here . You need to use mysql-utility mysqlfrm to get the structure of the table from backup. But mysqlfrm works only for innodb tables. Prerequisite:     1. Table should be innodb engine.     2. innodb_file_per_table option should be enabled on the source server        before taking the backup.     3. If you have any view inside your backup directory, script will fail. It will        print the name of the file where it failed. You need to go inside backup directory and delete all the files related to those views. For restoring DB we need to have all the following backups. I am referring to the directory structure creat...

MySQL default Password

Recently, I was setting up MySQL Galera cluster on redhat 7.4. I installed MySQL 5.7 and Galera cluster on the system according to the instructions provided in galera support page ( Galera Cluster setup ). I have made a blog post for installation and setup here . But when I started the mysql, I was not able to login as I did not setup any password for mysql root account. When I tried logging in without password, I got access denied. After looking for the answers on internet, I found out that MySQL creates a temporary password and write it in log files. It is clrearly mentioned in mysql documentation here . All I needed to do to find this password is to run the following command.      grep 'temporary password' /var/log/mysqld.log Problem solved !

MySQL 5.7 cluster with Galera on RedHat 7.4

Galera Cluster is a master-master replication, this means it keeps same data on all the nodes. For this purpose it transfers data continuously between nodes (IST or SST). There are 2 methods with which you can transfer the data. Using Percona XtraBackup or rsync. We are going to use rsync.                         yum install rsync We need to setup SELinux in permissive mode for required ports so that nodes can communicate. For this purpose we are going to use semanage . We can install this by given command.        yum install policycoreutils-python Also you firewall should not stop communication between the nodes, you can use telnet utility to check if nodes can communicate with each other on specific ports. If its not already installed, you can install it.               ...

MySQL Backup with Incremental Levels

Image
The script is written to take backup of MySQL Database using Percona Xtrabackup. The innobackupex tool is a Perl script that acts as a wrapper for the xtrabackup C program. It allows us to take backup of Innodb without any locking and also takes backup of other engines like MyISAM with minimum locking. To read more about innobackupex, read the following links. Innobackupex Script How Innobackupex Works? You can download full script  here . Innobackupex provides 2 types of backups:- Full : Which will take the full backup of the given database from start to end. Incremental : It will only take the backup of changed blocks since last base backup or LSN(Log Sequence Number). The script will take setting from the variables defined and take backups accordingly. I have currently set it up as below. Every Sunday, it will take full backup of the DB provided. Every day at 0000 hours, it will take an incremental backup since last full backup ( Figure 1 ). It is going to t...

Move Wordpress site to another server with different domain name

Most of the time, we move live site to a testing environment to do some tests. Here is how to do it.  Assumptions:          1. Source and Target servers are using linux ubuntu OS.          2. Webserver settings are already configured.  Steps:  Source Server: 1. Create a compressed copy of your website code. tar -zcvf <location_of_target_file>.tar.gz <website_code> eg.  t ar -zcvf /tmp/bacukup.tar.gz /home/avtar/www/*   2. Take database backup. Here I am assuming you are using mysql on same server as database.   mysqldump -h <hostname>  -uroot  -p ><location_of_backup_file>  eg.    mysqldump -h localhost -u root -p wp_db>/tmp/db_backup.sql 3. Compress the db backup file. tar -zcvf  <target_file_name>.tar.gz <db_backupfile_location> eg.  tar -zcvf /tmp/db_backup.tar.gz  /tmp/db_backup.sql 4. ...