I've got a backup process which reads quite a lot of data from disk, and therefore uses up all memory for disk cache, swapping off apps and other cached data in the process. There is no benefit to keep backuped data in disk cache after the backup is finished, so I'd like to limit the amount of data which could be cached by kernel for that process. Is it possible?



Fix the backup process so that it opens files with O_DIRECT, or so that it regularly calls posix_fadvise(..., POSIX_FADV_DONTNEED) when it's done with a block of data.

Or complain to whoever is responsible for the backup program to fix it per the above.

Alternatively, you can make a filter library which does the above and LD_PRELOAD that library when running the backup process.

  • 1
    Thank you for starting points. To extend your answer a bit: I use duplicity and rdiff-backup, both of them use rsync internally. There's a ticket and some patches to implement it, and some non-official builds with a patch are provided. There's also a LD_PRELOAD way done by Andrew Morton. – liori Jan 2 '12 at 18:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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