diff --git a/guides/unraid/pages/docker-app-backup.md b/guides/unraid/pages/docker-app-backup.md index aa89d05..3ffc017 100644 --- a/guides/unraid/pages/docker-app-backup.md +++ b/guides/unraid/pages/docker-app-backup.md @@ -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!" ```