Skip to content
This repository was archived by the owner on May 25, 2022. It is now read-only.

Migrating Databases

Otavio De Moraes Neto edited this page Jun 9, 2016 · 3 revisions

Introduction

CAM2 has the cam2 database where the camera data is held. This database is shared between the development machine, and the production machine. So when the cam2 database in the development machine is altered, the cam2 database in the production machine needs to be updated, and this is done by migrating the database form the development machine to the production machine. This tutorial will demonstrate how to migrate the camera data from the development's cam2 database to the cam2 database in the production machine.

Accessing the production machine

Before you start migrating the camera data, you must first have access to the camcam account on the production machine. First thing you need is the password for the camcam account. Ask your team leader, the CAM2 leader, or Dr. Lu for the password of the camcam account, if you don't already have it. When you have the password, ssh into the machine by typing in the following command:

Congratulations! Now you have access to the production machine.

Backing up databases

This is the last step before migrating, and the most important step of them all. We all make mistakes, so to be careful we must create a backup of the cam2 database on the production machine. After you ssh into the camcam account execute this command:

mysqldump -u root -p cam2 > backup.sql

This command creates a file called backup.sql. If you need to revert the database to the backup.sql data then execute this command:

mysql -u root -p -D cam2 < backup.sql

Migrating Camera Data

To start, ssh into your account on the development machine. When you are in the development machine execute these 3 commands:

mysqldump -u root -p cam2 camera > camera.sql
mysqldump -u root -p cam2 non_ip_camera > non_ip_camera.sql
mysqldump -u root -p cam2 ip_camera > ip_camera.sql
mysqldump -u root -p cam2 ip_camera_model > ip_camera_model.sql

Now we will transfer these 4 files to the camcam account on the production machine, by executing these commands:

scp camera.sql [email protected]:~ 
scp ip_camera.sql [email protected]:~ 
scp non_ip_camera.sql [email protected]:~ 
scp ip_camera_model.sql [email protected]:~ 

Now these 4 .sql files are in the production machine and can finally be migrated into the production machine's cam2 database. Lastly execute these last 3 commands to finish the migrating of the camera data from the development machine into the production machine:

mysql -u root -p -D cam2 < camera.sql
mysql -u root -p -D cam2 < ip_camera.sql
mysql -u root -p -D cam2 < non_ip_camera.sql
mysql -u root -p -D cam2 < ip_camera_model.sql

Congrats! You have migrated the camera data.

Check if the migration worked

Check if the migration worked, and that it didn't break the cam2 cite. Log into the cam2 cite and search for new cameras that have been migrated to the production machine. After that check if the cite didn't break by searching for multiple cameras in different locations, and checking if the images are displayed correctly. If the cite doesn't work correctly after you have migrated the data, then simply backup the database by running the second command I described in the Backing up the database section.

Clone this wiki locally