On my server, i need to backup my data and my databases about 2/3 times at day.
First, i compress folders with TAR, then i copy it with rsync to other servers in LAN.
Files are from 500MB to 2GB, so the transfer operation give my a heavy impact to server perfomance, with a Load from 5 to 7 (when the max should be 4 with my hardware) and sometime apache or mysql crash.
Now i found a solution that can give me the security of backup without an high load to my server.
First, i used CP instead of RSYNC, i’ve only 1 compressed file to copy, so RSYNC doesn’t give me advantage versus CP, and CP is more speedy.
Then, i found that i can limit the IO e CPU priority of CP command, so I can execute these backups during day when the server is in use.
Finally, the command is this:
ionice -c 3 nice -n 10 cp /FROM_FILE.tgz /TO_FILE.tgz --remove-destination
IONICE set the priority for I/O operations, and NICE set the priority for CPU/LOAD operation.
You can see the –help of every command for more details, or read this links: