update script on unraid backup

This commit is contained in:
Lee 2023-06-27 14:45:38 +01:00
parent d2751933db
commit 228e583dc7

@ -40,8 +40,8 @@ applicationData="/mnt/user/appdata/application_name/"
# Example: /mnt/user/Storage/Backups/$applicationName/
backupDirectory=""
# Set Number of Days to Keep Backups
days=30
# Set Number backups to keep
backupsToKeep=30
# The user of your account
# Example: lee
@ -50,6 +50,7 @@ user=""
# --- Backup Application ---
# Start notification
echo "Backup of $applicationName starting."
/usr/local/emhttp/plugins/dynamix/scripts/notify -s "$applicationName Backup" -d "Backup of $applicationName starting."
# Create backup directory
@ -61,12 +62,19 @@ cd "$backupDirectory"
tar -cf "$applicationName-$now".tar "$applicationData"
# Set Permissions
chown "$user:$user" $applicationName-"$now".tar
chown "$user:$user" "$applicationName-$now".tar
# Cleanup old backups
find "$backupDirectory"* -type d -mtime +"$days" | xargs rm -rf
for file in $(ls -t); do
if [[ $count -ge $backupsToKeep ]]; then
rm -- "$file"
echo "Deleted old backup: $file"
fi
((count++))
done
# Stop notification
echo "Backup of $applicationName completed!"
/usr/local/emhttp/plugins/dynamix/scripts/notify -s "$applicationName Backup" -d "Backup of $applicationName completed!"
```