From 9fcaf6a67433d99cdd6c046ba77e64ce759a876b Mon Sep 17 00:00:00 2001 From: Antonio SJ Musumeci Date: Sun, 19 Mar 2023 01:12:22 -0400 Subject: [PATCH] Move tiered cache mover scripts to files in tools dir --- README.md | 42 ++----------------------------- tools/mergerfs.percent-full-mover | 21 ++++++++++++++++ tools/mergerfs.time-based-mover | 13 ++++++++++ 3 files changed, 36 insertions(+), 40 deletions(-) create mode 100755 tools/mergerfs.percent-full-mover create mode 100755 tools/mergerfs.time-based-mover diff --git a/README.md b/README.md index 0f70d410..5039c615 100644 --- a/README.md +++ b/README.md @@ -1427,22 +1427,7 @@ version of rsync or run rsync with the tool "nocache". **filesystem** itself. Not the pool with the cache filesystem. You could have data loss if the source is the cache pool. - -``` -#!/bin/bash - -if [ $# != 3 ]; then - echo "usage: $0 " - exit 1 -fi - -CACHE="${1}" -BACKING="${2}" -N=${3} - -find "${CACHE}" -type f -atime +${N} -printf '%P\n' | \ - rsync --files-from=- -axqHAXWES --preallocate --remove-source-files "${CACHE}/" "${BACKING}/" -``` +[mergerfs.time-based-mover](tools/mergerfs.time-based-mover?raw=1 "download") ##### percentage full expiring @@ -1454,30 +1439,7 @@ below percentage threshold. **filesystem** itself. Not the pool with the cache filesystem. You could have data loss if the source is the cache pool. - -``` -#!/bin/bash - -if [ $# != 3 ]; then - echo "usage: $0 " - 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 -``` +[mergerfs.percent-full-mover](tools/percent-full-mover?raw=1) # PERFORMANCE diff --git a/tools/mergerfs.percent-full-mover b/tools/mergerfs.percent-full-mover new file mode 100755 index 00000000..bf52b6cc --- /dev/null +++ b/tools/mergerfs.percent-full-mover @@ -0,0 +1,21 @@ +#!/usr/bin/env sh + +if [ $# != 3 ]; then + echo "usage: $0 " + 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 diff --git a/tools/mergerfs.time-based-mover b/tools/mergerfs.time-based-mover new file mode 100755 index 00000000..b2af7966 --- /dev/null +++ b/tools/mergerfs.time-based-mover @@ -0,0 +1,13 @@ +#!/usr/bin/env sh + +if [ $# != 3 ]; then + echo "usage: $0 " + exit 1 +fi + +CACHE="${1}" +BACKING="${2}" +N=${3} + +find "${CACHE}" -type f -atime +${N} -printf '%P\n' | \ + rsync --files-from=- -axqHAXWES --preallocate --remove-source-files "${CACHE}/" "${BACKING}/"