Synchronizing Files and Folders


To facilitate file-syncing workflows, the sync operation can be used.

This sync uses rules very similar to Files.com's Remote Server Sync feature, using only filename and size to determine whether a file needs to be synced. It does not currently use information such as modified date or checksum for this purpose. Due to 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 we've been able to design that works 100% consistently across all files on Files.com, including files that may potentially be stored on a remote server.

Here is a push (upload) example for syncing 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

Here is a pull (download) example for syncing 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

The sync operation also provides some useful options.

Delete Source File After Successful Sync

To configure the sync so that the source file will be deleted after it has been successfully transferred to its destination, use the --delete-source flag.

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

Move Source File After Successful Sync

You can configure the sync so that the source file will be moved after it has been successfully transferred to its destination, using the --move-source flag. The move will occur in the source location.

For a sync push, the source location for the move will be 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 will be 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

You can configure the sync to ignore certain files or folders using the --ignore flag. Place the file and folder name patterns to be ignored into 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

You can configure the sync to include only specified files or folders patterns using the --include flag. Place the file and folder name patterns to be included into 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

Files that are uploaded or downloaded, including those that were transferred using a sync operation, typically gain an updated timestamp when they arrive at their destination, reflecting the date and time of when the file arrived on the destination system.

You can preserve the original timestamp by using the --times flag. When using the --times flag, the files will arrive at their destination with the same timestamp as they possessed at their source location. This is useful when archiving, or backing up, data so that you can determine if a file at the source location has been modified or updated when compared to the copy at the destination location.

Preservation of file times will only occur 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

Before attempting a sync operation, you might want to observe the actions that will be taken without any actual data being transferred. The --dry-run flag can be used to show you which files would have been affected by the operation.

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

Get Instant Access to Files.com

The button below will take you to our Free Trial signup page. Click on the white "Start My Free Trial" button, then fill out the short form on the next page. Your account will be activated instantly. You can dive in and start yourself or let us help. The choice is yours.

Start My Free Trial

©2024 Files.com. All right reserved

FILES.COM

  • Start My Free Trial
  • Pricing
  • Docs
  • API and SDKs
  • Contact

CONTACT & SUPPORT

support@files.com

(800) 286-8372

Monday–Friday

9am–8pm Eastern