create tomporary files with sftp

Bug #782294 reported by Markus
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Duplicity
Fix Released
Medium
Unassigned

Bug Description

Using ubuntu lucid ppa: 0.6.13-0ubuntu1~lucid1 with sftp.

when a transfer with put_sftp fails in the middle of it, there's an unfinished file left on the backend (which duplicity treats as a complete one on next run). This can be avoided simply:

- upload file with a temporary filename ignored by list()
- rename the file after a successful upload

i simply accomplished this changing backends/sshbackend.py put_sftp():

    def put_sftp(self, source_path, remote_filename = None):
        """Use sftp to copy source_dir/filename to remote computer"""
        if not remote_filename:
            remote_filename = source_path.get_filename()

        // changed to upload to a temp name and then finally rename
        commands = ["put \"%s\" \"%s.%s.part\"" %
                    (source_path.name, self.remote_prefix, remote_filename),
                    "rename \"%s.%s.part\" \"%s%s\"" %
                    (self.remote_prefix, remote_filename,self.remote_prefix, remote_filename)]
        commandline = ("%s %s %s" % (globals.sftp_command,
                                     globals.ssh_options,
                                     self.host_string))
        self.run_sftp_command(commandline, commands)

Now the file first gets created with a '.' as a prefix and a '.part' suffix. it is ignored by the "ls -1" in list(), so duplicity does not get confused. when uploaded - at least when the connection does not drop and the PUT returns to 'sftp>' - the file gets renamed to the desired name.

same should be done for put_scp, i think.

this helps from silently corrupted incremental backup sets when connection to the backend drops in the middle of the transfer and next backup starts.

Markus (doits)
description: updated
Revision history for this message
Markus (doits) wrote :
Changed in duplicity:
importance: Undecided → Medium
milestone: none → 0.6.14
status: New → Fix Committed
Changed in duplicity:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.