Difference between revisions of "IPBrick Disk migration"

From wiki.IPBRICK.COM
Jump to: navigation, search
m
(Scenario 2 - two server machine)
Line 81: Line 81:
 
Procedure
 
Procedure
 
* Install the IPBrick on the new machine (refer to IPBRICK.IC installation manual)
 
* Install the IPBrick on the new machine (refer to IPBRICK.IC installation manual)
*
+
 
 
EX: IPBrick1 New (192.168.69.199) and IPBrick2 OLD (192.168.69.200)
 
EX: IPBrick1 New (192.168.69.199) and IPBrick2 OLD (192.168.69.200)
  
On machine IPBrick2 open ssh to root
+
On machine IPBrick1 generate ssh key:
 +
<pre>
 +
ipbrick1:~# cd /root
 +
ipbrick1:~# ssh-keygen -t rsa
 +
#assume default location /root/.ssh/id_rsa
 +
#enter empty passphrase
 +
Generating public/private rsa key pair.
 +
Enter file in which to save the key (/root/.ssh/id_rsa):
 +
Enter passphrase (empty for no passphrase):
 +
Enter same passphrase again:
 +
Your identification has been saved in /root/.ssh/id_rsa.
 +
Your public key has been saved in /root/.ssh/id_rsa.pub.
 +
The key fingerprint is:
 +
3d:90:bf:f3:95:b3:96:6f:9d:90:95:98:69:fd:fb:0b root@ipbrick1
 +
The key's randomart image is:
 +
+--[ RSA 2048]----+
 +
|                |
 +
|        .      |
 +
|        o    = .|
 +
|        +  = + |
 +
|        S + . o .|
 +
|          o o ..|
 +
|          o  E=.+|
 +
|          o .+=o|
 +
|            ...+=|
 +
+-----------------+
 +
ipbrick1:~#
 +
</pre>
  
 +
Copy contents of public key from IPBrick1 to IPBrick2.
 
<pre>
 
<pre>
cat /etc/ssh/sshusers-allowed
+
ipbrick1:~# cat /root/ssh/id_rsa.pub
operator
+
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCRRerZEo0cyzCP3JxTabRAG8uPe4DVnAuduIUUayn+r64mrpy1RFcu1qQLGiKFyOgxCg3m+pCtg79yxvWfrx/XR/SIXh1uuLSmG/SOnFmn5WQJLXSCNBYGp/2BOQ1e4p6J2GFzmJF5/QnUXWCbLyIG/j7+klidLhktv/8+gHJClehMm6H31KynReaiuSyNiPFoG9+q5EmF+7Ibjqk5ZG6XeGodgINpfnNNFNLTmG+RyCK0vttGwVyKbnz2s3ypAbHpjQcNm7vG9iq73KjPaH1Y2r/09XoV3Bw15/0ZPVkkvlNHSwBpnsHrCAL8KT3m7qgDy2WT3cuArXRpm/PGTMXH root@ipbrick1
root
+
ipbrick1:~#
 +
</pre>
 +
Select and copy the output/contents of file id_rsa.pub from IPBrick1 as example above, install it on IPBrick2. Example:
 +
<pre>
 +
ipbrick2:~# mkdir -p /home1/_ssh/root/.ssh
 +
ipbrick2:~# echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCRRerZEo0cyzCP3JxTabRAG8uPe4DVnAuduIUUayn+r64mrpy1RFcu1qQLGiKFyOgxCg3m+pCtg79yxvWfrx/XR/SIXh1uuLSmG/SOnFmn5WQJLXSCNBYGp/2BOQ1e4p6J2GFzmJF5/QnUXWCbLyIG/j7+klidLhktv/8+gHJClehMm6H31KynReaiuSyNiPFoG9+q5EmF+7Ibjqk5ZG6XeGodgINpfnNNFNLTmG+RyCK0vttGwVyKbnz2s3ypAbHpjQcNm7vG9iq73KjPaH1Y2r/09XoV3Bw15/0ZPVkkvlNHSwBpnsHrCAL8KT3m7qgDy2WT3cuArXRpm/PGTMXH root@ipbrick1" >> /home1/_ssh/root/.ssh/authorized_keys
 +
ipbrick2:~#
 +
</pre>
 +
 
 +
Now for the first root ssh access from ipbrick1 to ipbrick2 using the ssh key.
 +
<pre>
 +
ipbrick1:~# ssh -i /root/.ssh/id_rsa root@192.168.69.200
 +
The authenticity of host '192' can't be established.
 +
RSA key fingerprint is 2d:b9:97:b6:c0:e9:1e:b7:c4:51:01:ab:e9:21:12:51.
 +
Are you sure you want to continue connecting (yes/no)? ^C
 +
atlas:~# ssh -i /root/.ssh/id_rsa root@localhost
 +
The authenticity of host '192.168.69.200 (192.168.69.200)' can't be established.
 +
RSA key fingerprint is 2d:b9:97:b6:c0:e9:1e:b7:c4:51:01:ab:e9:21:12:51.
 +
Are you sure you want to continue connecting (yes/no)? yes
 +
Warning: Permanently added '192.168.69.200' (RSA) to the list of known hosts.
 +
 +
 
 +
++++++++++++++++++++++++++++++: System Info :+++++++++++++++++++++++++++++++++
 +
+        FQDN =  ipbrick2.domain.com
 +
+  IP address =  192.168.69.200
 +
+      Kernel =  3.2.0-4-amd64
 +
+      Uptime =  10:05:02 up 458 days, 32 min, 10 users,  load average: 3.04, 2.51, 2.20
 +
+  Total CPUs =  4 x Architecture x86_64 @ 2399.734 Hz
 +
+ Total Memory =  16470664 kB
 +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 +
 
 +
 
 +
 
 +
ipbrick2:~# logout
 +
Connection to 192.168.69.200 closed.
 +
ipbrick1:~#
 
</pre>
 
</pre>
  
insert the line root on the file.
+
Now you can access as root from ipbrick1 (NEW, 192.168.69.199)  to ipbrick2 (OLD, 192.168.69.200).
  
Now lets start the rsync on IPBrick1
+
Now lets start the rsync on IPBrick1.
  
 
<pre>
 
<pre>
rsync -avz --rsh="ssh -l root" 192.168.69.200:/home1 /home1 > rsync_home1.log 2> rsync_home1.err
+
ipbrick1:~# rsync -avu --delete --rsh="ssh -l root -i /root/.ssh/id_rsa " 192.168.69.200:/home1/ /home1/ > rsync_home1.log 2> rsync_home1.err
rsync -avz --rsh="ssh -l root" 192.168.69.200:/home2 /home2 > rsync_home2.log 2> rsync_home2.err
+
ipbrick1:~# rsync -avu --delete --rsh="ssh -l root -i /root/.ssh/id_rsa " 192.168.69.200:/home2/ /home2/ > rsync_home2.log 2> rsync_home2.err
 
</pre>
 
</pre>
* the route password will be prompt to insert. 
 
  
 
You can see the logs in this file -> rsync_home1.log
 
You can see the logs in this file -> rsync_home1.log

Revision as of 09:35, 6 May 2016

This guide is to assist the IT IPBRICK administrator in the process of migrating a running IPBRICK installation from:

  • scenario 1 : one server machine - one disk to another disk on the same server machine
  • scenario 2 : two server machine - one disk to another disk on a different server machine


ATTENTION: This is an advanced procedure. The tasks described bellow are to be performed by an IT technician familiar with IPBRICK.IC operating system architecture and linux command line interface. This guide refers to the IPBRICK installation manual and the disaster recovery procedure. Before starting please make sure that you have an up to date backup of all data files, databases and configurations. Proceed at your own risk.

On the original server machine

On the original installation, apply configurations and download/save a backup copy configurations file to your Desktop. (Advanced Configurations -> Disaster Recovery -> Download : select the last one with the current timestamp).

Just stop the the services you use.

/etc/init.d/asterisk stop
/etc/init.d/apache2 stop
/etc/init.d/ejabberd stop
/etc/init.d/qmail stop
...


Execute this command to backup all the data bases.

  • IPBRICK.IC version v6.0 or above
php5 /opt/system/backupSYS/backup_DBs.php 
  • IPBRICK.IC versions: 5.3, 5.4 or 5.5
php5 /opt/ipbox/backupSYS/backup_DBs.php 

Scenario 1 - only one server machine

Procedure:

  • shutdown the server machine
  • remove/detach the original (old) disk from the server
  • install/attach the replacement (new) disk
  • install the IPBRICK.IC operating system (please refer to IPBRICK.IC installation manual)
    • perform the first boot, proceed with initial setup (FQDN, IP)
    • after finishing installation and initial configuration proceed to the next step
  • with the server power on, connect the old (original) disk using a USB connector
    • now at the command line you can check for the disks
fdisk -l
  • confirm that you have 2 (two) disks: sda (new internal disk) and sdb (old disk connected via usb)
    • you shoudl be able to identify the partition tables
  • create two temporary folders to map/mount the work areas from the old disk
mkdir /old_home1
mkdir /old_home2
ls /old_home* -al
  • Then we need to mount the partitions we need to copy.
mount /dev/sdb7 /old_home1
mount /dev/sdb8 /old_home2
  • Now lets start the rsync
rsync -aAuv /old_home1/ /home1/ > /tmp/rsync_home1.log 2> /tmp/rsync_home1.err &
rsync -aAuv /old_home2/ /home2/ > /tmp/rsync_home2.log 2> /tmp/rsync_home2.err &
  • You can see the logs in these files (log is normal output, err is for status warning)
tail /tmp/rsync_home1.log
tail /tmp/rsync_home1.err
tail /tmp/rsync_home2.log
tail /tmp/rsync_home2.err
  • When the rsync process finishes, you can unmap/unmount the old disk
umount /old_home1
umount /old_home2
  • after successfull unmount you can disconnect the old disk (usb)
    • NOTE: we recommend you to keep the old disk safe until this procedure is completly finished (backup procedure)
  • Now please access to web interface, insert and replace the configurations file that you have previously saved on your desktop
    • Please refer to the installation manual and/or disaster recover procedure in order to perform settings replacement
    • The server machine performs a reboot
  • After the server boot up, go to IPBRICK web interface, Advanced configurations -> Disaster Recovery -> Aplications -> Databases : for each database, click on the database name, then you get a listing of all the available backups, click on the last timestamp (click on the timestamp, not on the download link), and click on Restore to proceed to restore.
  • When this Finnish test the services you have on IPBrick
  • For the last step you need to re-activate your license - Advanced configurations -> IPBrick -> Web Access : License activation (please refer to the installation manual, license activation)


Scenario 2 - two server machine

Procedure

  • Install the IPBrick on the new machine (refer to IPBRICK.IC installation manual)

EX: IPBrick1 New (192.168.69.199) and IPBrick2 OLD (192.168.69.200)

On machine IPBrick1 generate ssh key:

ipbrick1:~# cd /root
ipbrick1:~# ssh-keygen -t rsa
#assume default location /root/.ssh/id_rsa
#enter empty passphrase
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
3d:90:bf:f3:95:b3:96:6f:9d:90:95:98:69:fd:fb:0b root@ipbrick1
The key's randomart image is:
+--[ RSA 2048]----+
|                 |
|         .       |
|        o     = .|
|         +   = + |
|        S + . o .|
|           o o ..|
|          o  E=.+|
|           o .+=o|
|            ...+=|
+-----------------+
ipbrick1:~# 

Copy contents of public key from IPBrick1 to IPBrick2.

ipbrick1:~# cat /root/ssh/id_rsa.pub 
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCRRerZEo0cyzCP3JxTabRAG8uPe4DVnAuduIUUayn+r64mrpy1RFcu1qQLGiKFyOgxCg3m+pCtg79yxvWfrx/XR/SIXh1uuLSmG/SOnFmn5WQJLXSCNBYGp/2BOQ1e4p6J2GFzmJF5/QnUXWCbLyIG/j7+klidLhktv/8+gHJClehMm6H31KynReaiuSyNiPFoG9+q5EmF+7Ibjqk5ZG6XeGodgINpfnNNFNLTmG+RyCK0vttGwVyKbnz2s3ypAbHpjQcNm7vG9iq73KjPaH1Y2r/09XoV3Bw15/0ZPVkkvlNHSwBpnsHrCAL8KT3m7qgDy2WT3cuArXRpm/PGTMXH root@ipbrick1
ipbrick1:~# 

Select and copy the output/contents of file id_rsa.pub from IPBrick1 as example above, install it on IPBrick2. Example:

ipbrick2:~# mkdir -p /home1/_ssh/root/.ssh
ipbrick2:~# echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCRRerZEo0cyzCP3JxTabRAG8uPe4DVnAuduIUUayn+r64mrpy1RFcu1qQLGiKFyOgxCg3m+pCtg79yxvWfrx/XR/SIXh1uuLSmG/SOnFmn5WQJLXSCNBYGp/2BOQ1e4p6J2GFzmJF5/QnUXWCbLyIG/j7+klidLhktv/8+gHJClehMm6H31KynReaiuSyNiPFoG9+q5EmF+7Ibjqk5ZG6XeGodgINpfnNNFNLTmG+RyCK0vttGwVyKbnz2s3ypAbHpjQcNm7vG9iq73KjPaH1Y2r/09XoV3Bw15/0ZPVkkvlNHSwBpnsHrCAL8KT3m7qgDy2WT3cuArXRpm/PGTMXH root@ipbrick1" >> /home1/_ssh/root/.ssh/authorized_keys
ipbrick2:~# 

Now for the first root ssh access from ipbrick1 to ipbrick2 using the ssh key.

ipbrick1:~# ssh -i /root/.ssh/id_rsa root@192.168.69.200
The authenticity of host '192' can't be established.
RSA key fingerprint is 2d:b9:97:b6:c0:e9:1e:b7:c4:51:01:ab:e9:21:12:51.
Are you sure you want to continue connecting (yes/no)? ^C
atlas:~# ssh -i /root/.ssh/id_rsa root@localhost
The authenticity of host '192.168.69.200 (192.168.69.200)' can't be established.
RSA key fingerprint is 2d:b9:97:b6:c0:e9:1e:b7:c4:51:01:ab:e9:21:12:51.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.69.200' (RSA) to the list of known hosts.
 

++++++++++++++++++++++++++++++: System Info :+++++++++++++++++++++++++++++++++
+         FQDN =  ipbrick2.domain.com
+   IP address =  192.168.69.200
+       Kernel =  3.2.0-4-amd64
+       Uptime =  10:05:02 up 458 days, 32 min, 10 users,  load average: 3.04, 2.51, 2.20
+   Total CPUs =  4 x Architecture x86_64 @ 2399.734 Hz 
+ Total Memory =  16470664 kB
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++



ipbrick2:~# logout
Connection to 192.168.69.200 closed.
ipbrick1:~#

Now you can access as root from ipbrick1 (NEW, 192.168.69.199) to ipbrick2 (OLD, 192.168.69.200).

Now lets start the rsync on IPBrick1.

ipbrick1:~# rsync -avu --delete --rsh="ssh -l root -i /root/.ssh/id_rsa " 192.168.69.200:/home1/ /home1/ > rsync_home1.log 2> rsync_home1.err
ipbrick1:~# rsync -avu --delete --rsh="ssh -l root -i /root/.ssh/id_rsa " 192.168.69.200:/home2/ /home2/ > rsync_home2.log 2> rsync_home2.err

You can see the logs in this file -> rsync_home1.log Or the errors in this file -> rsync_home1.err

Wen the rsync is finish access to web interface and then insert and replace the configuration that you save on your desktop.

After replacing, go to Advanced configuration -> disaster recovery -> aplication -> data bases -> and replace the last one.


Wen this Finnish test the services you have on IPBrick.