rsync taking 100% of CPU and hours to complete

There are a few things you can do there. You don't need the -z flag to rsync for a local copy. Compression is not used for transfers that aren't remote.

You can optimize the rsync a bit better for small files and the type of changes with other options like -W (to transfer whole files without the prescan).

Also, shouldn't you be deleting files on the destination?

More details on the actual OS you're using, the disk capabilities and the backup target could help focus the solution a bit better.


Please be sure you're not on a hacked machine, a lot of users (me included) have found bitcoin miners hiding behind rsync or other processes. To check:

  • look at users cron jobs: # crontab -l -u alex
  • Delete folders listed in found malicious cron jobs
  • Delete hidden folders in /tmp
  • Delete unknown keys in /home/USER/.ssh/authorized_keys or worse /root/.ssh/authorized_keys
  • install ClamAv and setup weekly scan: Link
  • Uknown users: lslogins
  • /etc/ssh/sshd_config should allow only one, non root user for SSH: AllowUsers me mom dad
  • use more robust passwords and log in with public key

Other reports https://askubuntu.com/questions/1115770/crond64-tsm-virus-in-ubuntu