+4 votes
in Operating Systems by (40.5k points)

I am running "rsync" on a VPS to create a backup of data present on another VPS. It works perfectly fine, but there is a memory consumption issue. The VPS where I run "rsync" has 2GB RAM and 0.5 GB swap, and the size of data on the VPS I copy the data from is 20+ GB. When I run  "rsync", it just consumes all RAM and SWAP memory, and as a result,  "rsync" also becomes very slow.

Is there any way to stop  "rsync" from consuming all memory on the VPS?

1 Answer

+3 votes
by (348k points)
selected by
 
Best answer

"Incremental recursion" may be the culprit, and if you disable it, the memory usage will come down.

"Incremental recursion" can be disabled using the "--no-inc-recursive" option or its shorter "--no-i-r" alias. Your "rsync" command should look like the following.

rsync --no-inc-recursive --progress ...

If you are using "--delete" option, it will not disable incremental recursion. --delete-before, --delete-after, --prune-empty-dirs, and --delay-updates disable incremental recursion.

According to the manual of rsync (man rsync),

Some options require rsync to know the full file list, so these options disable the incremental recursion mode.  These  include:  --delete-before, --delete-after, --prune-empty-dirs, and --delay-updates.  Because of this, the default delete mode when you specify --delete is now --delete-during when both ends of the connection are at least 3.0.0 (use --del or --delete-during to request this improved deletion mode explicitly).  Incremental recursion can be disabled using the --no-inc-recursive option or its shorter --no-i-r alias.

 If you use "--no-inc-recursive" option, using "--delete" will not increase RAM usage.

Related questions

+4 votes
1 answer
asked Nov 16, 2021 in Operating Systems by kush (40.5k points)
+3 votes
1 answer
+2 votes
1 answer
+2 votes
1 answer
+2 votes
1 answer

...