Skip to content

Feature request: copy to tmp file before moving to final file name [SFTP, ...?] #1316

Closed

Description

@kubark42

What is your rclone version (eg output from rclone -V)

Which cloud storage system are you using? (eg Google Drive)

SFTP

The command you were trying to run (eg rclone copy /tmp remote:tmp)

rclone copy

When copying via SFTP, rclone copies directly to the file destination. The problem is that if the transfer is aborted, there's no way on the endpoint to know this. Appending a temporary string to the filename, and then changing the filename upon successful upload is a pretty typical way to do this.

Can rclone do this as well?

P.S. I suspect this might only be a problem on SFTP, because when uploading to the cloud, the cloud-based services handle incomplete transactions.

Activity

  1. ncw commented on Apr 10, 2017

    @ncw
    Member

    Yes this is a problem with SFTP and the local file system... rsync uses temporary names to get around this problem so rclone should probably adopt that too..

  2. added this to the Help Wanted milestone on Aug 30, 2018
  3. ncw commented on Aug 16, 2020

    @ncw
    Member

    This is also a problem with FTP as well as SFTP and local.

    Rclone should probably have a feature flag on the backend something like HasIncompleteUploads

    If this is set then operations.Copy should

    • if overwriting a file

    • transfer to new file name

    • rename over the old file when transfer is complete

    • delete the partial on errors

    • if not overwriting

    • transfer to the existing file name

    • delete the partial on errors

    If this flag is not set then the partial does not need to be deleted (like happens at the moment, which potentially can cause data loss)

    Note that the backends may need tweaking as they may delete these partials on error anyway and we should be leaving that to the next layer up.

    This will require changing the integration tests too.

  4. modified the milestones: Help Wanted, v1.54 on Aug 16, 2020
  5. modified the milestones: v1.54, v1.55 on Feb 3, 2021
  6. modified the milestones: v1.55, Soon on Mar 31, 2021
  7. Avamander commented on Oct 12, 2025

    @Avamander

    Unfortunately I've encountered data corruption with truncated files as well. Having this option would help determine if it has been caused by aborted writes or not.

  8. ncw commented on Oct 12, 2025

    @ncw
    Member

    We now have the PartialUploads feature flag

    PartialUploads bool // uploaded file can appear incomplete on the fs while it's being uploaded

    This is set for SFTP (and FTP)

    PartialUploads: true,

    This means that uploads will go to a temporary file and be renamed into place unless the --inplace flag is a set .

    Since this is already implemented I'm going to close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions