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/ # Example: /mnt/user/Storage/Backups/$applicationName/
backupDirectory="" backupDirectory=""
# Set Number of Days to Keep Backups # Set Number backups to keep
days=30 backupsToKeep=30
# The user of your account # The user of your account
# Example: lee # Example: lee
@ -50,6 +50,7 @@ user=""
# --- Backup Application --- # --- Backup Application ---
# Start notification # Start notification
echo "Backup of $applicationName starting."
/usr/local/emhttp/plugins/dynamix/scripts/notify -s "$applicationName Backup" -d "Backup of $applicationName starting." /usr/local/emhttp/plugins/dynamix/scripts/notify -s "$applicationName Backup" -d "Backup of $applicationName starting."
# Create backup directory # Create backup directory
@ -61,12 +62,19 @@ cd "$backupDirectory"
tar -cf "$applicationName-$now".tar "$applicationData" tar -cf "$applicationName-$now".tar "$applicationData"
# Set Permissions # Set Permissions
chown "$user:$user" $applicationName-"$now".tar chown "$user:$user" "$applicationName-$now".tar
# Cleanup old backups # 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 # Stop notification
echo "Backup of $applicationName completed!"
/usr/local/emhttp/plugins/dynamix/scripts/notify -s "$applicationName Backup" -d "Backup of $applicationName completed!" /usr/local/emhttp/plugins/dynamix/scripts/notify -s "$applicationName Backup" -d "Backup of $applicationName completed!"
``` ```