You can use the
sync-cmd command and Google Cloud Directory Sync (GCDS) to run synchronizations from the command line.
When to sync from the command line
When you set up or modify your configuration, you should run a manual synchronization from Configuration Manager. Doing so allows you to check the synchronized data and make sure it's in order. For details, go to Perform a manual synchronization.
After you’re done making configuration changes, you can automate your sync process using the command line. You can incorporate synchronizations into any scheduling or batch script you wish to use. Alternatively, you can use a third-party tool to automate syncs. For details, go to Schedule automatic synchronizations.
Use the command line
You run the
sync-cmd command from the GCDS installation directory and enter the command on a single line. You can use the command arguments listed below to perform a range of actions, such as:
- Apply any detected changes.
- Read a specified file.
- Set the logging detail level.
Tip: You can get information about the available command arguments by entering
Command arguments & examplesCommand arguments
|Argument (use either option)||Description|
||Applies any detected changes.
Note: If you don't use this argument, a sync is run as a test only and no changes are made to your Google Account. For the best results, run a test sync without this argument before running a full sync with it.
||Specifies the XML configuration file to load.
Important: You must include a valid XML file with this argument. For details, go to Work with configuration files.
||Excludes custom schemas.
Use this option if you don't want to sync custom schema data for users.
||Ignores configured delete limits.|
||Clears the cached copy of your Google Account data before running the sync.
Important: Improper use can cause performance degradation. Do not use this option unless directed to do so by support.
Use this option if you want to sync users, but not groups.
||Displays help information and exits.|
||Overrides the default or configured log level with a specified value. Valid values (in increasing order of detail) are FATAL, ERROR, WARN, INFO, DEBUG, and TRACE.
In most cases, we recommend you set the log level to INFO.
Use this option if you don't want to sync license data for users.
Restricts any running synchronizations to a single instance per XML configuration file. Doing so prevents multiple instances from running inadvertently (for example, through a scheduler or cron job). The argument is only valid with the
To troubleshoot, go to Why isn’t GCDS running a sync from the command line?
||Excludes organizational units.|
||Writes reports to a specified output file, in addition to the log.|
||Excludes shared contacts.|
Use this option if you want to sync groups, but not users.
||Displays short application-version information.|
||Displays detailed application-version information, but does not sync it.|
Example 1: Run a simulated sync using the XML configuration file C:\Users\user\gdcs-config.xml:
sync-cmd -c C:\Users\user\gdcs-config.xml
Example 2: Run a full sync, including applying any detected changes, using the XML configuration file C:\Users\user\gdcs-config.xml:
sync-cmd -a -c C:\Users\user\gdcs-config.xml
Example 1: Run a simulated sync using the XML configuration file /path/gcds-config.xml:
sync-cmd -c /path/gcds-config.xml
Example 2: Run a full sync, including applying any detected changes, using the XML configuration file /path/gcds-config.xml:
sync-cmd -a -c /path/gcds-config.xml
Review exit code
After you run your sync or simulation from the command line, you get one of the following exit codes:
- 0—Sync completed without any sync issues and all modifications do not exceed the configured limits.
- 255—Simulation completed. Or, sync completed and there are sync issues, such as modifications that exceeded the configured limits or a user failed to sync.
Google, Google Workspace, and related marks and logos are trademarks of Google LLC. All other company and product names are trademarks of the companies with which they are associated.