There are example code snippets on https://docs.moodle.org/dev/Backup_2.0_for_developers#Setting_up_the_environment and https://docs.moodle.org/dev/Restore_2.0_for_developers#Automatically_triggering_restore_in_code
Backup and restore
Manually triggering activity backup/restore
This discussion has been locked so you can no longer reply to it.