Add some fixes in retention-helper.sh #7

Merged
thomas.gebert merged 1 commits from retention-helper-fixes into main 2024-10-08 08:45:07 +00:00

View File

@ -42,7 +42,7 @@ HELP
} }
get_atime_of_file() { get_atime_of_file() {
stat --format=%X "${1}" stat --format=%X "${1}" 2> /dev/null
} }
get_xattr_of_file() { get_xattr_of_file() {
@ -50,17 +50,20 @@ get_xattr_of_file() {
} }
find_files_with_atime() { find_files_with_atime() {
for FILE in $(find "${DIRECTORY}" -type f); do while read -r FILE; do
ATIME_FILE=$(get_atime_of_file "${FILE}") ATIME_FILE=$(get_atime_of_file "${FILE}")
if [ "${ATIME_FILE}" == "" ]; then
continue
fi
if [ ${ATIME_FILE} -ge ${ATIME_SEARCH} ]; then if [ ${ATIME_FILE} -ge ${ATIME_SEARCH} ]; then
echo "${FILE}" echo "${FILE}"
fi fi
done done <<< $(find "${DIRECTORY}" -type f)
} }
find_files_with_retention() { find_files_with_retention() {
for FILE in $(find "${DIRECTORY}" -type f); do while read -r FILE; do
RETENTION_FILE=$(get_xattr_of_file "${FILE}" "trusted.worm.attr" | grep -o '[0-9]\+$') RETENTION_FILE=$(get_xattr_of_file "${FILE}" "trusted.worm.attr" | grep -o '[0-9]\+$')
if [ "${RETENTION_FILE}" == "" ]; then if [ "${RETENTION_FILE}" == "" ]; then
continue continue
@ -69,7 +72,7 @@ find_files_with_retention() {
if [ ${RETENTION_FILE} -eq ${RETENTION_SEARCH} ]; then if [ ${RETENTION_FILE} -eq ${RETENTION_SEARCH} ]; then
echo "${FILE}" echo "${FILE}"
fi fi
done done <<< $(find "${DIRECTORY}" -type f)
} }
@ -86,13 +89,16 @@ set_atime() {
show_atime_retention() { show_atime_retention() {
for FILE in $(find "${DIRECTORY}" -type f); do while read -r FILE; do
ATIME=$(get_atime_of_file "${FILE}") ATIME=$(get_atime_of_file "${FILE}")
if [ "${ATIME}" == "" ]; then
continue
fi
TRUSTED_WORM_ATTR=$(get_xattr_of_file "${FILE}" "trusted.worm.attr" | grep -o '[0-9]\+$') TRUSTED_WORM_ATTR=$(get_xattr_of_file "${FILE}" "trusted.worm.attr" | grep -o '[0-9]\+$')
echo "${FILE}" echo "${FILE}"
echo " atime: $(date --date=@${ATIME}) || ${ATIME}" echo " atime: $(date --date=@${ATIME}) || ${ATIME}"
echo " trusted.worm.attr: ${TRUSTED_WORM_ATTR}" echo " trusted.worm.attr: ${TRUSTED_WORM_ATTR}"
done done <<< $(find "${DIRECTORY}" -type f)
} }
################################################################################ ################################################################################