How to Migrate a Database!

At the very beginning of this article, I would like to clear this fact, database-migration is not data-migration, it is a subset of data-migration.

Data migration is a broad field with different approaches and techniques, that includes 

  1. Application migration
  2. Storage migration
  3. Cloud migration
  4. Database migration

But for now, let's focus on Database migration and relative approaches and ways.

Why migration:

It begins with a question, why we need to migrate our data.? There can be different reasons, but the following reasons are some examples of them.

  • To replace a legacy solution.
  • Reduce cost and footprint.
  • Stay competitive by adopting newer technology.
  • Transfer data from on-premise to cloud or vice-versa.
  • Vendor change.

Anyway, if migration needs to be done, it should be done with care and in a proper way.

Database migration steps:

Database migration is a multi-step project. Let's take a look at different steps, a database migration project can have. 

1. Understanding source Data

The first step is to understand the data you have in the current database, the nature of the data. The below fact checkpoints must be done in this step.

  •  What is the size of the source database?
  •  Does the Database contain large tables?
  • What kind of schema, data type, engine it is using?

Must backup all the data in this step, the better option is archiving.

2. Assessing Data

In this step, you should take a deep and more critical look at all the data you have. Is there any redundancy, any security-related issue, any data can be cleaned or archivable. Also, check data quality across the database.

3. Converting Schema

Heterogeneous database migrations that involve migrating data between different database engines are relatively more complex than homogenous migrations. in this step data schema, views, object store procedures and functions should be converted for use in the next step. Remember! This step is time and labor-intensive. So plan it carefully. Also, a data migration tool can be useful.

4. Test migration build

To test the migration environment, you should execute the current setup with a small set of data. Analysis of the database workload time and tuning in the right way is very important.

5. Execute the migration

finally. after all steps, you can start the migration. This can be achieved by a data migration tool. But do not delete any data in this step. After a successful connection and several E2E tests, you can think about data backup and cleanup.

Database migration patterns/ approaches

I guess now you have a clear idea about how you want to proceed with the database migration. Let's discuss some approaches and patterns of database migration. Disclosure! I am not saying these are the only ways to migrate data, there can be several more depends on application structure and project goal. But this is most used and common across the industry.

Read-Only-Push:

This method work basically migrates data from one to another instance with read-only access. The transactional instance remains on service. This is a periodic method and one-way sync.

Replication: 

You can get an idea from the name of the pattern, it is a replication 0of whole database. This approach uses cloud transfer most of the time. In this approach, the database should replicate and save in different systems/places. For example, one database in on-premise support faster read for office employees another in cloud support faster communication with users.

One Time Transfer:

This is a straight forward way of migration. Turn of current DB, transfer, turn on again. But this one is cost-effective and easy. But significant downtime will occur and should only be performed if downtime is acceptable.

 Data Remanence

Data remanence are residual representations of data that remain after deleting files or reformation data storage device. It is common for the operating system to logically delete files but physically still have footprints.

After successful migration, if you need to clear old data sources, follow data remanence options to securely clear all data.

Data remanence type:

  • Wiping
  • Degaussing
  • Physical destruction
  • Encryption