7

I'm using tar do make backups of a machine. But, it is using a lot of I/O and slows down the whole machine.

So, is there a way to limit the read speed of tar?

I know about pv, but it limit only the write speed. Because I do incremental backups with tar --listed-incremental, this will work only with the first full backup (subsequent incremental backups will then consume a lot of read I/O if there is only small changes).

I've tried to lower the overall priority of the backup with a combination of nice and ionice, but this not really change anything.

Informations: it's Debian 9 machine, and the files are residing on an ext4 file-system on top of a LVM volume.

5
  • 2
    As a side note, sorry if I'm not posting the question on the right website. I'm a bit confused about the difference between unix.stackexchange, Super User and Server Fault since this question seems to be on-topic for these 3 websites. Commented Dec 16, 2018 at 12:01
  • 1
    check out cpulimit as in this answer: unix.stackexchange.com/a/39730/3375 Commented Dec 16, 2018 at 12:27
  • 1
    Have you tried limiting the output of tar using something like pv, as you mentioned? Commented Dec 16, 2018 at 21:53
  • Be careful, gtar in general is unable to restore it's incremental backups. This only works in case that the differences between two incrementals are trivial and do not include renamed directories. Commented Dec 17, 2018 at 16:23
  • For completeness -and for tips for us noobs- can you include how you can use pv to limit the output rate? (edit: ah, rtfm... its in linux.die.net/man/1/pv) Commented Jan 19, 2021 at 12:35

2 Answers 2

2

You can run your tar command using ionice. Like this:

ionice -c3 tar --listed-incremental [...]

This will let the tar process only do I/O when there is no other process waiting for I/O.

In Debian the ionice utility is in the package util-linux, so you you may need to install that first.

Like with the normal (cpu) nice utility, the I/O scheduler class of a process is inherited by its child processes. When I'm planning to do resource-heavy stuff, I do not want users have their I/O slowed down because of it. I often start my shell this way:

nice ionice -c3 bash

Then everything I do from that shell will be very, very nice :)

0

Use cgroups

mkdir -p /sys/fs/cgroup/blkio/g1
echo "8:0 1048576" > /sys/fs/cgroup/blkio/g1/blkio.throttle.read_bps_device
pgrep -f tar > /sys/fs/cgroup/blkio/g1/cgroup.procs

https://andrestc.com/post/cgroups-io/

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.