Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

At a certain time we run a few backup scripts to backup:

  • code/files
  • databases
  • other important files on the server

During this time the websites on the server grind to a hault giving timeouts and database connection issues.

So, i imagine im doing this wrong. What is the bets way to perform nightly backups without affecting the performance of sites on the server?

OS: Centos applications: MySQL, Rsync

Backups are to a remote server.

share|improve this question
How do you backup your database? If using mysqldump, it certainly can make everything slow for a while, especially with large MyISAM tables as with MyISAM full table locks are needed. – Janne Pikkarainen Jan 11 '12 at 11:47
How else would you backup mysql? – David Jan 11 '12 at 14:56
LVM snapshot and copying the MySQL data directory is one approach. Another one which does not bully the master MySQL server is to have a slave MySQL server and take backups from there. – Janne Pikkarainen Jan 12 '12 at 7:08
up vote 2 down vote accepted

Because of the backup operation there is contention for disk and cpu also maybe network resources, hence your site is not responsive. To avoid this you will have to reduce the io and cpu priorities of the backup operations so that your site can function normally.

You can use this before you invoke your backup script.

root@x:~# bash
root@x:~# echo $BASHPID

BASHID variable is PID of current bash session

root@x:~# ionice -c 2 -n 7 -p $BASHPID

This will reduce your current shell's disk io priority

-c = class ( 0 none, 1 real time, 2 best-effort, 3 idle)

-n = priority (0-7 , 0 is highest priority)

root@x:~# renice  +10 -p  $BASHPID

This will reduce your current shell's cpu scheduling priority (-19 is max priority and 20 is least priority)

root@x:~# ./backup-script

Now from here you can invoke your backup script. Since the child processes inherit cpu and io priorities from parent, your backup script process(es) will run with lower io,cpu priorities and therefore your server processes have precedence over backup.

In case you are using a cron job you can put all above commands in a file , chmod for x permissions and add that file to cron.

In case network is bottleneck , you may have to use "tc" to classify backup traffic and rate limit it. You can read about rate-limiting here.

share|improve this answer

Difficult to answer without knowing what OS, applications, filesystems, and backup media are involved.

Without any of that available, my answer is: rsync

share|improve this answer
use rsync as this answer suggests, and if possible, use ionice to give the backup a low priority on the disks. It usually helps alot. – Sirex Jan 11 '12 at 11:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.