Unix & Linux: How can I pause/resume rsync? (4 Solutions!!)
Channel: Roel Van de Paar
Date: 2020-08-14

Unix & Linux: How can I pause/resume rsync?


The Question: How can I pause an rsync that's running?
First time I did Ctrl+C to kill it and used the -P flag to run again. Is this
prone to corrupt the current file transfer?
Second time I simply put MacOS to sleep (by closing the lid). Looking at the
running process I can see 2 (not sure why) with a status of 'S'.
Tried using
kill -SIGCONT
to resume the process, but it has no effect.

Solutions: Please watch the whole video to see all solutions, in order of how many people found them helpful

== This solution helped 22 people ==
Ctrl+Z to suspend, and:
$ fg
to continue, use
$ jobs
to see suspended jobs; bg [number] to background them; fg [number] to
foreground it.

== This solution helped 66 people ==
You can pause any program 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.
It is safe to kill an rsync process and run the whole thing again; it will
continue where it left off. It may be a little inefficient, particularly if you
haven't passed --partial (included in -P), because rsync will check all files
again and process the file it was interrupted on from scratch.
There may be unusual combinations of options that will lead to some files not
being synchronized properly, maybe --inplace with something else, but I think
no single option will cause this.
If you disconnect your laptop and reconnect it somewhere else, it may get a
different IP address. Then the TCP connection used by rsync would be severed,
so you'd have to kill it and start again. This can also happen if you suspend
your laptop and the TCP connection times out. The timeout will eventually
filter out to the application level, but it can take a while. It's safe to
press Ctrl+C and run rsync again.

== This solution helped 8 people ==
Run rsync with the --partial flag. It will then keep partial transfers and
resume partial files when started.

With thanks & praise to God, and with thanks to the many people who have made this project possible! | Content (except music & images) licensed under cc by-sa 3.0 | Music: https://www.bensound.com/royalty-free-music | Images: https://stocksnap.io/license & others | With thanks to user TPS (https://unix.stackexchange.com/users/31757), user qnoid (https://unix.stackexchange.com/users/1562), user Michael Mrozek (https://unix.stackexchange.com/users/73), user Mehdi Nellen (https://unix.stackexchange.com/users/147036), user Gilles 'SO- stop being evil' (https://unix.stackexchange.com/users/885), user gauteh (https://unix.stackexchange.com/users/3839), user bahamat (https://unix.stackexchange.com/users/3309), and the Stack Exchange Network (http://unix.stackexchange.com/questions/5959). Trademarks are property of their respective owners. Disclaimer: All information is provided "AS IS" without warranty of any kind. You are responsible for your own actions. Please contact me if anything is amiss at Roel D.OT VandePaar A.T gmail.com.