How to Copy using Rsync with Resume Option

Posted on

There is a certain tool which is provided and it exist in Linux operating system intended to copy either locally or remotely files from another location to another place. The command itself although in some reference, it stands for remote sycn, basically based on the manual page, rsync is defined asĀ  a fast, versatile, remote (and local) file-copying tool. It can be used to copy with resume option. By the definition of resume option means it can be resumed or continued if the process either stop or disturbed by any cause or means available accidentally or intentionally.

Accidentally means, either because of broken internet connection suddenly happened, or the command executed terminated without any intention to actually do it. Intentionally means in general the command itself is terminated. It has been tested on only one file since the situation really need a copy file with a resume option. It is because the file size is quite huge so that it has to be resumed if later on in the middle of the process of copying, it suddenly stop.

So, without further ado, below is the command pattern of copying file using rsync with a resume option :

rsync -avzP --append source_location destination_location 

The explanation on the above additional parameter will be shown as follows :

-a : archive, it is a multipurpose parameter for recursive copy with symlinks and preserving attributes of files and folders copied. 
-v : verbose, it is a parameter to show verbose output of the command execution in the screen.
-z : compress, it is a parameter for compressing the file data during the copy process.
-P : progress, it is a parameter for showing the progress of the copy process.
--append : it is an additional parameter for appending any files or folders if there are already files or folders exist
in the target or destination location.
destination_location : Remote location, it generally considered as a remote location. It refers to the location where it is actually describing the target synchronization
source_location : local location, it refers to the location where it is actually describing the source synchronization

 

Below is the example of the copy process using a file named netbeans-8.2-linux.sh with several times terminated the process to simulate whether or not the process of copying can be resumed or can be continued :

user@hostname:~/Downloads$ rsync -avzP --append netbeans-8.2-linux.sh /tmp/
sending incremental file list
netbeans-8.2-linux.sh
     87,228,416  38%   19.83MB/s    0:00:06  ^C
rsync error: received SIGINT, SIGTERM, or SIGHUP (code 20) at rsync.c(638) [sender=3.1.1]
rsync error: received SIGINT, SIGTERM, or SIGHUP (code 20) at io.c(504) [generator=3.1.1]
user@hostname:~/Downloads$ rsync -avzP --append netbeans-8.2-linux.sh /tmp/
sending incremental file list
netbeans-8.2-linux.sh
    150,436,105  67%   23.92MB/s    0:00:02  ^C
rsync error: received SIGINT, SIGTERM, or SIGHUP (code 20) at rsync.c(638) [sender=3.1.1]
rsync error: received SIGINT, SIGTERM, or SIGHUP (code 20) at io.c(504) [generator=3.1.1]
user@hostname:~/Downloads$
user@hostname:~/Downloads$ rsync -avzP --append netbeans-8.2-linux.sh /tmp/
sending incremental file list
netbeans-8.2-linux.sh
    205,007,002  91%   24.04MB/s    0:00:00  
    223,882,240 100%   24.17MB/s    0:00:02 (xfr#1, to-chk=0/1)

sent 69,267,345 bytes  received 35 bytes  27,706,952.00 bytes/sec
total size is 223,882,240  speedup is 3.23
user@hostname:~/Downloads$ cd /tmp/
user@hostname:/tmp$ ls -al | grep netbeans-8.2-linux.sh 
-rw-rw-r-- 1 user user 223882240 May 16 09:34 netbeans-8.2-linux.sh
user@hostname:/tmp$

As shown in the above process which is described to simulate the rsync process, the process itself is actually success.

Leave a Reply