«

Nov 14

How to pause and resume rsync

Just like any other Linux process, you can pause rsync by sending it a TSTP (polite) or STOP (forcible) signal. On the terminal you’ve run rsync in, pressing Ctrl+Z sends TSTP. Resume with the fg or bg command in the terminal or a CONT signal. To resume the rsync where it is interrupted, make sure to pass -P, otherwise rsync will check all files again and process the file it was interrupted on from scratch.

Ex:-

01) execute rsync command with “-P”

 

more about “-P” option from man page of rsync :

-P
The -P option is equivalent to –partial –progress. Its purpose is to make it much easier to specify these two options for a long transfer that may be interrupted.

There is also a –info=progress2 option that outputs statistics based on the whole transfer, rather than individual files. Use this flag without outputting a filename (e.g. avoid -v or specify –info=name0) if you want to see how the transfer is doing without scrolling the screen with a lot of names. (You don’t need to specify the –progress option in order to use –info=progress2.)

Finally, you can get an instant progress report by sending rsync a signal of either SIGINFO or SIGVTALRM. On BSD systems, a SIGINFO is generated by typing a Ctrl+T (Linux doesn’t currently support a SIGINFO signal). When the client-side process receives one of those signals, it sets a flag to output a single progress report which is output when the current file transfer finishes (so it may take a little time if a big file is being handled when the signal arrives). A filename is output (if needed) followed by the –info=progress2 format of progress info. If you don’t know which of the 3 rsync processes is the client process, it’s OK to signal all of them (since the non-client processes ignore the signal).

CAUTION: sending SIGVTALRM to an older rsync (pre-3.2.0) will kill it.

 

02) pause rsync

Press Ctrl+Z to stop the process.

 

 

If you kill rsync with Ctrl+C it does stop it mid transfer but it will not keep any temporary files there unless running with the –partial option.

For those also interested in just pausing rsync, if you press Ctrl+Z it pauses the program. When you resume it by running fg or bg rsync will reiterate over the file that it didn’t finish and continue downloading the rest of the files. To see all currently paused programs run jobs

03) To view the jobs

 

so job id is “1”

04) resume rsync process

to resume the job, you may need to pass jobs id as fg command.

 

The general job control commands in Linux are:

 

  • jobs – list the current jobs
    fg – resume the job that’s next in the queue
    fg %[number] – resume job [number]
    bg – Push the next job in the queue into the background
    bg %[number] – Push the job [number] into the background
    kill %[number] – Kill the job numbered [number]
    kill -[signal] %[number] – Send the signal [signal] to job number [number]
    disown %[number] – disown the process(no more terminal will be owner), so command will be alive even after closing the terminal.

Leave Your Thought Here