Skip to content

Instantly share code, notes, and snippets.

@mrl22
Last active March 11, 2024 10:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrl22/fc100ac4c1d86f502b4c07c66f0dabc0 to your computer and use it in GitHub Desktop.
Save mrl22/fc100ac4c1d86f502b4c07c66f0dabc0 to your computer and use it in GitHub Desktop.
Borg Backup Server + Synology Hyper Backup - Check if there has been a backup in the last 48 hours - NO ENCRYPTION PASS NEEDED
#!/bin/bash
RED="\e[31m"
GREEN="\e[32m"
ENDC="\e[0m"
# Threshold for 48 hours in seconds
threshold=$(( 48 * 3600 ))
# Loop through user directories in /home/
for user_dir in /home/*; do
# Check if the directory is not "lost+found"
if [ "$(basename "$user_dir")" = "lost+found" ]; then
continue
fi
if [ -d "$user_dir" ]; then
user=$(basename "$user_dir") # Extract the username from the path
# Check if the "transactions" or "_Syno_TaskConfig" file exists
if [ -f "$user_dir/repo/transactions" ]; then
file="$user_dir/repo/transactions"
elif [ -f "$user_dir/backup.hbk/_Syno_TaskConfig" ]; then
file="$user_dir/backup.hbk/_Syno_TaskConfig"
else
echo "---: $user is not managed by Borg or Synology"
continue
fi
# Get the modified date of the file
modified_date=$(stat -c %Y "$file")
current_time=$(date +%s)
# Compare the modified date with the threshold
if [ "$((current_time - modified_date))" -le "$threshold" ]; then
echo -e "${GREEN}YES${ENDC}: $user has been modified in the last 48 hours"
else
echo -e "${RED}NO${ENDC} : $user has not been modified in the last 48 hours"
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment