mirror of
https://github.com/trapexit/mergerfs.git
synced 2024-12-05 07:20:30 +08:00
22 lines
535 B
Plaintext
22 lines
535 B
Plaintext
|
#!/usr/bin/env sh
|
||
|
|
||
|
if [ $# != 3 ]; then
|
||
|
echo "usage: $0 <cache-fs> <backing-pool> <percentage>"
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
CACHE="${1}"
|
||
|
BACKING="${2}"
|
||
|
PERCENTAGE=${3}
|
||
|
|
||
|
set -o errexit
|
||
|
while [ $(df --output=pcent "${CACHE}" | grep -v Use | cut -d'%' -f1) -gt ${PERCENTAGE} ]
|
||
|
do
|
||
|
FILE=$(find "${CACHE}" -type f -printf '%A@ %P\n' | \
|
||
|
sort | \
|
||
|
head -n 1 | \
|
||
|
cut -d' ' -f2-)
|
||
|
test -n "${FILE}"
|
||
|
rsync -axqHAXWESR --preallocate --remove-source-files "${CACHE}/./${FILE}" "${BACKING}/"
|
||
|
done
|