Skip to main content

Database Migration

tip

This guide assumes that you have already established an SSH connection to the FileMaker server. If you have not done so, please refer to the Getting Started guide.

caution

This process should not be performed during working hours. The migration requires the production environment to be offline while database records are being moved.

This guide will show you how the migrate the Prime CRM from Staging to Production. This process typically takes between 5-10 minutes to complete.

Throughout this guide, we will be using the fmsadmin command line tool to perform the migration. This tool is installed on the FileMaker server and allows us to perform administrative tasks from the command line. You can find more information about this tool in the FileMaker Server CLI Reference.

Step 1 - Create a clone of the Staging database

To begin, we must create a clone of Prime_Solar_STAGING.

info

In FileMaker, making a "clone" copies database columns, valuelists, and layouts from the source file, but does not copy any records. If you were to open the cloned .fmp12 file yourself, you would find that all of the database tables were empty.

To create a clone, you can use the fmsadmin command line tool from the Ubuntu server. To do so, paste the following command into the terminal:

fmsadmin backup --cloneonly /mnt/volume_sfo3_01/fms-databases/Prime_Solar_STAGING.fmp12 --dest filelinux:/mnt/volume_sfo3_01/fms-clones

This command will create a clone of the Prime_Solar_STAGING database and place it in the fms-clones directory. This process usually takes less than 30 seconds to complete.

Once completed, you can find the clone at the following path:

/mnt/volume_sfo3_01/fms-clones/Clone - Staging_{date}/Cloned_by_FMS_{date}/fms-databases/Prime_Solar_STAGING Clone.fmp12

Lastly, rename the file to clone.fmp12 and move it into fms-databases using the following command:

mv Prime_Solar_STAGING\ Clone.fmp12 /mnt/volume_sfo3_01/fms-databases/clone.fmp12

Step 2 - Close the Production database

During the migration, all of the records will be copied over from the production database into the empty tables of the staging clone. To prevent data loss, the production database must be closed during this process.

tip

Don't worry! If you do happen to attempt a migration while the production database is open, you won't break anything. Although, you may get some funky error messages when attempting to run the migration script. If this happens, simply close the production database and try again.

To close the production database, run the following command in the terminal:

fmsadmin close /mnt/volume_sfo3_01/fms-databases/Prime_Solar.fmp12

Step 3 - Perform the migration

With the staging environment cloned and production closed, it is time to start the migration. The migration will be performed using the FileMaker Data Migration Tool. This tool allows FileMaker developers to automate the migration process that would normally need to be performed by hand.

To run the migration, paste the following command into the terminal:

This command assumes that you are currently in the fms-databases directory.

./FMDataMigration -src_path Prime_Solar.fmp12 -src_account '' -src_pwd '' -clone_path clone.fmp12 -clone_account '' -clone_pwd '' -ignore_valuelists -v

You'll notice that there are a couple fields missing from the command that contain an empty string (src_account, src_pwd, clone_account, and clone_pwd). For each of these fields, replace them with the credentials for the FileMaker CRM admin account. These credentials can be found by logging into your Keeper account and navigating to the FileMaker CRM - Admin User credentials under the Development Team folder.

After replacing the credentials, execute the command to begin the migration.

The migration process usually takes between 3-5 minutes to complete.

tip

Once the migration completes, a Summary message will appear in the terminal. This message indicates that the migration has completed.

caution

When viewing the summary window, ensure that there are no peculiarities in the summary message.

For example, if you find that the Fields not migrated contains a value greater than 0 it could mean that something didn't migrate properly.

Additionally, if the file size of the migrated .fmp12 file is significantly smaller/larger than the original database then that could mean the migration did not work properly.

After the migration is complete, you will notice a new file in the fms-databases directory named Prime_Solar migrated.fmp12. This file is the migrated database that we will be using to replace the production database.

Step 4 - Replace the production database

After the migration has completed and you have ensured, we need to replace the production database with our migrated database:

The following commands assume that you are currently in the fms-databases directory.

  1. Delete the existing production database:

    rm Prime_Solar.fmp12
  2. Delete the clone:

    rm clone.fmp12
  3. Rename the migrated database:

    mv Prime_Solar\ migrated.fmp12 Prime_Solar.fmp12

Step 5 - Go Live

At this point, the migration is complete! To bring the FileMaker database back up, run the following command:

fmsadmin open /mnt/volume_sfo3_01/fms-databases/Prime_Solar.fmp12

That's it! The migration is now complete and the database is back online. You can ensure that the database is working by connecting to it with your FileMaker client.