improve backup detection

This commit is contained in:
Jérémy Lecour 2019-03-23 10:32:29 +01:00
parent 3979b71831
commit 9cd5e1c325

View file

@ -847,14 +847,21 @@ if is_debian; then
# Check if files in /home/backup/ are up-to-date # Check if files in /home/backup/ are up-to-date
if [ "$IS_BACKUPUPTODATE" = 1 ]; then if [ "$IS_BACKUPUPTODATE" = 1 ]; then
if [ -d /home/backup/ ]; then if [ -d /home/backup/ ]; then
for file in /home/backup/*; do if [ -n "$(ls -A /home/backup/)" ]; then
limit=$(date +"%s" -d "now - 2 day") for file in /home/backup/*; do
updated_at=$(stat -c "%Y" "$file") limit=$(date +"%s" -d "now - 2 day")
if [ -f "$file" ] && [ "$limit" -gt "$updated_at" ]; then updated_at=$(stat -c "%Y" "$file")
failed "IS_BACKUPUPTODATE" "$file has not been backed up"
test "${VERBOSE}" = 1 || break; if [ -f "$file" ] && [ "$limit" -gt "$updated_at" ]; then
fi failed "IS_BACKUPUPTODATE" "$file has not been backed up"
done test "${VERBOSE}" = 1 || break;
fi
done
else
failed "IS_BACKUPUPTODATE" "/home/backup/ is empty"
fi
else
failed "IS_BACKUPUPTODATE" "/home/backup/ is missing"
fi fi
fi fi