Automate data comparison and synchronization from the command line

You can automate data comparison and synchronization using the command line.

To run a comparison from the command line:

1. Click Start.

2. Type cmd in the Search programs and files text box and click ENTER.

Note

To run the Command Line in Windows 10:

From the Desktop Mode

  • Move the mouse cursor to the exact lower left corner until the desktop shortcuts menu appears.
  • Right-click to see the shortcut menu and than click Run.

From the Charms Bar

  • Move your mouse to the upper right corner until the Charms Bar appears.
  • Select Apps from the list and type run in the search box.
  • Click Run from the search results.

Use Windows + R Shortcut Keys

  • In desktop mode, press the Windows + R keys, to show the Run command line.
  • In the window that opens, type cmd and press Enter.

3. Type a path to the dbforgepostgresql.com file located in the dbForge Data Compare for PostgreSQL installation folder on your PC, and press the SPACE bar.

C:\Program Files\Devart\dbForge Data Compare for PostgreSQL\dbforgepostgresql.com

4. Specify the type of the operation you want to perform.

/datacompare 

5. Specify the source and target connection settings.

/datacompare /source connection:"Connection Lifetime=120;Host=host1_name;Port=5435;Database=database1_name;User ID=yourusername;Password=yourpassword;Pooling=False" /target connection:"Connection Lifetime=120;Host=host2_name;Port=5436;Database=database2_name;User ID=yourusername;Password=yourpassword;Pooling=False" 

6. Specify the objects that will be compared and synchronized.

/includeobjects:All

7. Synchronize data directly into the database and generate a synchronization script file.

/sync:"D:\mysync.sql" 

8. Compose a comparison report.

/report:"D:\myreport.html" 

9. Specify the report format. HTML and EXCEL formats are available.

/reportformat:HTML

10. Press ENTER to run the process.

Tip

To see a quick help on the arguments available in the command line, type the following:

C:\Program Files\Devart\dbForge Data Compare for PostgreSQL>dbforgepostgresql.com /?

Generate a file with command-line arguments

You can configure command-line file settings to manage *.bat file text in the Command line execution file settings window. You can open the window by clicking the Save Command Line button in:

  • New Data Comparison Wizard

Save Command Line button

  • Data Synchronization Wizard

Save Command Line button

Next, in the Command line execution file settings window that will open check and edit the settings if necessary.

Command line settings

Once done, click Save and provide a path to the directory to save the generated .bat file.

Note that the generated file does not contain password information for security purposes. You should edit the file and enter the passwords manually.

To run data comparison and/or synchronization from the command line using the created batch file, specify its name and path to it using the /argfile argument.

The command line string with the /argfile parameter looks as follows:

C:\Program Files\Devart\dbForge Data Compare for PostgreSQL>dbforgepostgresql.com /argfile:file_name.txt

Note

Options specified from the command line have higher priority than the options specified in the file.