Synchronize two environments using diff-changelog

Last updated: June 9, 2026

Use diff-changelog to synchronize two databases by generating a delta changelog that contains only the changes missing from the target.

Common scenarios include keeping staging and production in sync, or updating a local development instance to match a shared environment.

This differs from generate-changelog, which captures a full baseline from a single existing database and is typically a one-time step during onboarding.

Use diff-changelog on an ongoing basis as your reference environment continues to evolve.

Procedure

1

Take a snapshot of the target database.

Before generating a diff, capture the current state of your target database. This snapshot serves as the baseline for comparison.

Be sure to:

  • Replace your_database_type with your database type (for example, postgresql, mysql, or oracle)

  • Replace your_target_host with your target database hostname or IP address

  • Replace your_port with your target database port

  • Replace your_database_name with your target database name

  • Replace your_username with your target database username

  • Replace your_password with your target database password

loading
2

Run diff-changelog to generate the delta changelog.

Compare the reference database (source of truth) against the snapshot of your target database. Liquibase will produce a changelog containing only the changes present in the reference that are missing from the target.

Be sure to:

  • Replace your_working_directory with the path to the directory where your snapshot file is saved

  • Replace your_database_type with your database type (for example, postgresql, mysql, or oracle)

  • Replace your_reference_host with your reference database hostname or IP address

  • Replace your_port with your reference database port

  • Replace your_reference_database with your reference database name

  • Replace your_reference_username with your reference database username

  • Replace your_reference_password with your reference database password

Note: You can find the correct JDBC URL format to use by referring to the article What databases are supported by Liquibase?

After the command runs, Liquibase automatically opens a Drift Report (HTML) in your browser showing the differences detected between the two databases.

loading
3

Review the generated changelog.

Open sync-changelog.xml and verify that the changesets reflect only the expected differences. Confirm there are no unintended changes before deploying.

4

Deploy the changelog to the target database.

Once you’ve reviewed the changelog and it matches your expectations, apply the changes to the target database.

Be sure to:

  • Replace your_working_directory with the path to the directory where your changelog file is saved

  • Replace your_database_type with your database type (for example, postgresql, mysql, or oracle)

  • Replace your_target_host with your target database hostname or IP address

  • Replace your_port with your target database port

  • Replace your_database_name with your target database name

  • Replace your_username with your target database username

  • Replace your_password with your target database password

After the command runs, Liquibase automatically opens an Update Report (HTML) in your browser summarizing which changesets were applied.

loading
5

Commit the changelog to source control.

Add sync-changelog.xml to your version control system so the synchronization is tracked and reproducible.