Skip to main content

Synchronizing Files and Folders

The sync operation copies files between a local folder and a Files.com folder.

It uses rules very similar to Files.com's Sync feature, comparing only filename and size to determine whether a file needs to be synced. It does not currently use modified date or checksum. Given the wide variety of remote server types supported (and our plans to support hundreds more via an open integration platform coming soon), this is the only methodology that works consistently across all files on Files.com, including files that may be stored on a remote server.

Push (upload) files from a local Documents folder to a Files.com folder of the same name:

files-cli sync push --local-path="Documents" --remote-path="Documents" --send-logs-to-cloud

Pull (download) files to a local Documents folder from a Files.com folder of the same name:

files-cli sync pull --remote-path="Documents" --local-path="Documents" --send-logs-to-cloud

Delete Source File After Successful Sync

Use the --delete-source-files flag to delete each source file after it transfers successfully to its destination.

files-cli sync pull --remote-path="path/to/source/folder" --local-path="path/to/local/destination/folder" --send-logs-to-cloud --delete-source-files

If deleting the source files would leave an empty folder you want to dispose of, add the --delete-source-empty-folders flag. A common case is a sync that pulls data from a folder created every day by an external process; --delete-source-empty-folders cleans up the source filesystem and prevents performance issues from accumulated empty folders.

files-cli sync pull --remote-path="path/to/source/folder" --local-path="path/to/local/destination/folder" --delete-source-files --delete-source-empty-folders --send-logs-to-cloud 

Move Source File After Successful Sync

Use the --move-source flag to move each source file after it transfers successfully to its destination. The move occurs within the source location.

For a sync push, the source location for the move is the local system where you are running the files-cli:

files-cli sync push --local-path="path/to/local/source/folder" --remote-path="path/to/destination/folder" --move-source="path/to/local/archive/folder" --send-logs-to-cloud

For a sync pull, the source location for the move is the Files.com platform:

files-cli sync pull --remote-path="path/to/source/folder" --local-path="path/to/local/destination/folder" --move-source="path/to/archive/folder" --send-logs-to-cloud

Ignore Certain Files or Folders

Use the --ignore flag to skip certain files or folders. Pass the file and folder name patterns to ignore as a comma-separated string:

files-cli sync push --local-path="path/to/local/source/folder" --remote-path="path/to/destination/folder" --ignore='*.exe,*.msi,Archive/,secret/' --send-logs-to-cloud

Include Only Specified Files or Folders

Use the --include flag to limit the sync to specified file or folder patterns. Pass the patterns as a comma-separated string:

files-cli sync push --local-path="path/to/local/source/folder" --remote-path="path/to/destination/folder" --include='*.txt,*.pdf' --send-logs-to-cloud

Preserve File Times

Uploaded or downloaded files, including those transferred by a sync operation, normally arrive at the destination with a new timestamp reflecting the time of arrival.

Use the --times flag to preserve the original timestamp instead. Files arrive at the destination with the same timestamp they had at the source. This is useful when archiving or backing up data, so you can tell whether a file at the source has changed compared to the copy at the destination.

File times are preserved only if your site is configured to allow file modification times to be set. If file times are not preserved, check your site's data governance settings.

files-cli sync pull --local-path="Documents" --remote-path="Documents" --send-logs-to-cloud --times

Dry Run

Use the --dry-run flag to preview the actions a sync would take without transferring any data. The output shows which files would be affected by the operation.

files-cli sync pull --local-path="Documents" --remote-path="Documents" --send-logs-to-cloud --times --dry-run