@Nva2023
When courses are deleted, you get a 404 not found status code when trying to access them through the API. At a minimum, you would have to undelete the course.
Some information is available for students who are not active, but it depends on whether you deleted the enrollment or concluded it. If you deleted the enrollment, then you would need to re-add them.
You could potentially write a script to automate the process. Restoring the course could likely be done by SIS ID, which could speed up the process a little.
I would recommend doing this in your beta instance so the student doesn't know the course has been reopened.
Some schools delete their courses once the course is over. Some delete courses after a set number of years. Others never delete course. We're a small school and haven't deleted a course that actually ran with students in the 11+ years we've been using Canvas.
It sounds like you might be in that first group, but if you're finding this situation arises frequently, then you might benefit from delaying the deletion for a couple of years. I think I've seen admins discussing their retention periods in other places in the Community.
Another approach might be to get the information using Canvas Data 2 (CD2). I cannot test this for you as we don't delete courses that have grades in them, but CD2 does have submissions for deleted enrollments and deleted courses. CD2 is not a trivial undertaking, though. But if your institution already has it set up, it may be able to give you the information without requiring your lengthy process in Canvas.