Hi James!
If you're looking to recreate the groups/groupings structure within the courses, you can use the course backup/restore function to do so.
I would recommend trying it out on a sandbox site to make sure it behaves the way you want before applying it on a production site.
Thanks!