Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm copying a large file using scp, and realized that the destination may not have enough space for it to finish. Is there a way I can pause it, possibly for several hours, and resume later? Also, if it fails (no space left on device), will I be able to resume it once I've cleared some space?

(Note that scp is already running; solutions like using a different program will not work.)

share|improve this question

1 Answer 1

up vote 0 down vote accepted

You can pause a process with SIGSTOP and later continue it with SIGCONT. (See kill -l for a list of signals and use ps to get the process ID).

However there is a fair chance that this will not work. E.g. if you have a router between your source and destination which notices and 'cleans' a dead connection. Most SOHO routers seem to do this because cleaning connections means less memory use. (And thus they can build cheaper routers).

If that happens you will either need to copy again with scp or you can use rsync.

Rsync has the advantage that it compares already existing files and does not needlessly copy data. In your case it should detect an already present, partially uploaded file and only upload the remainder of the file

Syntax would be rsync -v -e ssh /home/my_file username@destination.host.tld:~

-v for verbose. -e "ssh options" to specify the ssh as remote shell.

If your data is compressable then you might want to add -z to compress the data.

share|improve this answer
    
There is a router (a Time Capsule) between the two machines. Do you mean that I can use rsync to resume the copy, or that I will have to restart and use rsync instead? –  Blacklight Shining Nov 9 '12 at 22:05
    
Restart with rsync. But rsync compares files and only transfers changes. If you already have the first half of the file (before diskspace runs out) then rsync should only transfer the other half of the file. –  Hennes Nov 9 '12 at 22:15
    
…that's confusing. If the transfer is stopped (e.g. with ^C) or fails, will I be able to use rsync to copy only the remainder of the file, or will rsync copy the entire file again? (And how would I do that?) –  Blacklight Shining Nov 9 '12 at 22:17
2  
In a shell with job control you can just do Ctrl-Z to stop and fg to resume. It should work for short durations. But as the answer says, somewhere in the middle the connection state may be dropped after some time. –  Keith Nov 10 '12 at 0:31
1  
If you are trying to resume a large file, this options may be useful: --partial --inplace --no-whole-file. –  Rafael Xavier Mar 11 '13 at 19:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.