Skip to content

Add a sync_folder method #14

Open
Open

Description

@pjbull

We currently think it is a non-goal to manage folder syncing behind the scenes, but we might want to explicitly support it as a method.

For example, something like:

# I have a local folder that has many changes in it, including file deletions
local_changes = "/work_in_progress"

# copies cloud versions down to disk, but skips dl'ing where possible; deletes extra files locally
S3Path("s3://bucket/project_storage").sync_down(local_changes)

# copies local versions up to cloud, but skips ul'ing where possible; deletes extra files on the cloud
S3Path("s3://bucket/project_storage").sync_up(local_changes)

Activity

  1. added
    enhancement
    on Oct 2, 2020
  2. ypicard commented on Jan 30, 2022

    @ypicard

    This is the last missing piece that will make me migrate to this library. I would really appreciate this being a thing indeed.

  3. pjbull commented on Dec 19, 2022

    @pjbull
    MemberAuthor

    Additional discussion in #134.

  4. added
    design decision
    on Sep 28, 2025
  5. noamgot commented on Nov 30, 2025

    @noamgot

    @pjbull any news about this one...? would love to see this feature; specifically, I think it would be nice to allow syncing to/from the path _local attribute...

  6. pjbull commented on Dec 2, 2025

    @pjbull
    MemberAuthor

    Thanks @noamgot. I think we're unlikely to add this in the near term since it is out of scope for the project given the number of scenarios to support.

    We should provide the building blocks for cloudpathlib users to write a sync function that works for their scenario:

    • CloudPath.download_to will always overwrite local with what is on the cloud
    • CloudPath.upload_from will always overwrite cloud the cloud with what is local
    • Otherwise, globbing both dirs with .realtive_to will let you (1) skip things that exist already, (2) delete any extra files from one side or the other of the sync.
    • For two-way sync scenarios, you need to decide for yourself what determines which file is canonical (modified time? be careful of timestamp resolution and time zones; etags? you need to track those locally for yourself; file hashes? you need to calculate for local (and cloud if not provided by the backend)).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    design decisionenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions