You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
535 B

  1. #!/usr/bin/env sh
  2. if [ $# != 3 ]; then
  3. echo "usage: $0 <cache-fs> <backing-pool> <percentage>"
  4. exit 1
  5. fi
  6. CACHE="${1}"
  7. BACKING="${2}"
  8. PERCENTAGE=${3}
  9. set -o errexit
  10. while [ $(df --output=pcent "${CACHE}" | grep -v Use | cut -d'%' -f1) -gt ${PERCENTAGE} ]
  11. do
  12. FILE=$(find "${CACHE}" -type f -printf '%A@ %P\n' | \
  13. sort | \
  14. head -n 1 | \
  15. cut -d' ' -f2-)
  16. test -n "${FILE}"
  17. rsync -axqHAXWESR --preallocate --remove-source-files "${CACHE}/./${FILE}" "${BACKING}/"
  18. done