Information for: DEVELOPERS   PARTNERS

Copying a database into a Cloud Platform CD environment

When running tests in your Cloud Platform CD environment, you may want to copy a database from another Cloud Platform environment into your Cloud Platform CD environment. To sync a database as part of a deployment, perform the following steps:

  1. Ensure your YAML file uses a version key of 1.2.0 or greater.
  2. Add a SSH key as described in Creating and managing your build definition file.
  3. Add a cde-databases key to your YAML file as described in Creating and managing your build definition file. Any databases you want to copy must be explicitly specified in the cde-databases key.
  4. Select the source database.
  5. Add deployment steps to your YAML file.

For more information about the Cloud Platform CD user interface, see Managing your pipelines in the Cloud Platform interface. For example build definition files, see Example pipelines build definition files.

Selecting the source database

To select a source database for database syncing, perform the following steps:

  1. Sign in to Cloud Platform with an account that has the Execute pipelines permission.

  2. Select the application you want to use.

  3. In the left menu, click Pipelines.

  4. Click More Links.

    More Links icon

  5. In the DB Sync source environment, section, select the environment to copy the database from, and your selection will be saved.

    Select a source environment to use when copying databases

Adding deployment steps to your YAML file

After selecting a source database for syncing and adding a cde-databases key to your YAML file, add a post-deploy step to your events key as displayed in the following example, replacing db1 and db2 with databases listed as parameters in the cde-databases key:

version: 1.2.0

cde-databases:
  - db1
  - db2

events:

  post-deploy:
    steps:
      # Deploy the build artifact to an on-demand environment,
      # and sync the specified databases.
      - deploy:
          script:
            - pipelines-deploy
            - pipelines-sync-dbs db1 db2

In the previous example, the pipelines-deploy command creates the environment and deploys the build result. The pipelines-sync-dbs command syncs the databases provided as parameters, provided they are also listed as parameters in the cde-databases key.

Important

Before performing testing, you should scrub the copy of the database in your Cloud Platform CD environment of any sensitive or personal identifying user information to prevent unintended user notifications or data leaks.