Transferring the tracker from the server to the server with saving data

How to transfer

To simplify the understanding, we implement the following notations:
server1 – the server from which the transfer is performing;
server2 – the server to which the transfer is performing;
folder1 – folder on server1, which you need to create (example mkdir /root/mysql);
folder2 – folder on server2, which you also need to create (example mkdir /var/lib/mysql_backup).

Attention! The folders /folder1 and /folder2 must not be the real paths of your current MySQL files!

1. 1. Install xtrabackup:
apt-get install percona-xtrabackup-24
If it did not work, you can check the official installation instructions, briefly:
wget https://repo.percona.com/apt/percona-release_0.1-4.$(lsb_release -sc)_all.deb
dpkg -i percona-release_0.1-4.$(lsb_release -sc)_all.deb
apt-get update
apt-get install percona-xtrabackup-24

2. To create a backup, you need at least the same amount of space as all your MySQL databases occupy together. You will also need a place to create an archive, which you will need to transfer to another server.
In practice, there is usually no extra space, so you can immediately backup to a remote server. To do this, install sshfs on the server from which we will transfer:
apt-get install sshfs
To mount a remote folder:
sshfs username@server:/folder2 /folder1
where username@server – is the user and IP from server2.
(example, sshfs root@192.168.1.1:/var/lib/mysql_backup /root/mysql)

3. Make sure that there is no traffic going to the tracker.
You can just stop nginx:
service nginx stop

4. To start the backup process, execute:
innobackupex --no-timestamp --user=root --password=PASS /folder1
innobackupex --no-timestamp --user=root --password=PASS --apply-log /folder1

where PASS is the password from the MySQL root
(example, innobackupex --no-timestamp --user=root --password=PASS /root/mysql
innobackupex --no-timestamp --user=root --password=PASS --apply-log /root/mysql
)

Depending on the database size, backup time can vary from 5 minutes to several hours.

5. On a remote server, you need to stop MySQL and replace the database files with the backup files:
service mysql stop
mv /var/lib/mysql /var/lib/myslq.old
mv /folder2 /var/lib/mysql

(example, mv /var/lib/mysql_backup /var/lib/mysql)
chown -R mysql:mysql /var/lib/mysql

6. Now the root MySQL password you have on server2 is the same with one you have on server1, and it needs to be changed in the configuration file of the tracker:
– Open configuration/system.php file in the tracker folder, by default it is /var/www/binom/configuration/system.php;
– Find the line with $this->password=;
– Replace the old MySQL password with a new one;
– Save changes.

7. Execute:
service mysql start
mysql_upgrade -uroot -p -f

8. Restart MySQL and check the functionality of the tracker.
service mysql restart

9. Unmount the remote folder (execute on the old server):
fusermount -u /folder2
(example, fusermount -u /root/mysql)

Comments