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:
- Ensure your YAML file uses a version key of 1.2.0 or later.
- Add a SSH key as described in Creating and managing your build definition file.
- 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 thecde-databases
key. - Select the source database.
- Add deployment steps to your YAML file.
For more information about the Cloud Platform CD user interface and example build definition files, see Managing your Pipelines in the Cloud Platform interface and Example Pipelines build definition files respectively.
Selecting the source database
To select a source database for database syncing:
- Sign in to the Cloud Platform user interface with an account that has the Execute pipelines permission.
- Select the application you want to use.
- In the left menu, click Pipelines.
Select More Links > View Application Info.
In the DB Sync source environment, section, select the environment to copy the database from, and your selection will be saved.
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.