title: Manually duplicate a file in Moodle
body: <p>I'm coding a local plugin in Moodle and I'm trying to copy resources from one course to another one manually (not doing a backup and restoring).</p>
  
  <p>I've tried to manually get the resource, the course_module, the context and finally the file from DB, then copying rows and updating the fields that concern to the new course, and also chaning SHA1 from pathnamehash file's table field.</p>
  
  <p>Any ideas or alternatives to do that?</p>
  
  <p>Thanks!</p>