Here are a couple of alternatives for you that you don't need to program but may still be of use to you.
If you just want to copy a section of a course, the block_sharing_cart block is your friend. Makes re-using things like Feedback forms a snap. You can even do things like create a master course library of pre-configured activities that you can then re-use when building new courses.
Also, if you are just duplicating courses verbatim because you are offering multiple identical instances of the courses, check out mod_facetoface. For example, instead of creating 5 instances of the same course (one for each night of the week), this lets you schedule 5 instances in one shot. This is really nice because, if you make a change to one course, it changes them all. The plugin gives an example of scheduling repeated face to face sessions however, from what I can see, it will let you do this with just about any activity module.
It really depends on what is your desired outcome.
Best regards,
Michael