Skip to content

Syncs all Canvas files from specified courses to a local folder, then uploads them to cloud storage using rclone.

License

Notifications You must be signed in to change notification settings

jensenhwa/canvastocloud

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Canvas2Cloud Sync Tool

Easy-to-use, versatile, platform-independent program that downloads course files from Canvas and syncs them to your cloud storage of choice. Gracefully handles incompatible filenames and preserves deleted/outdated files in a separate folder. Handles content stored in Modules as well. Works best when run from an always-on, internet-connected machine such as a Raspberry Pi.

Prerequisites

This tool requires rclone along with Python 3.7 or later. Install Python dependencies with pip:

$ pip3 install -r requirements.txt

Quick start

  1. Download or clone the repo.
  2. Set up a new remote in rclone:
    $ rclone config
    ...
    n/r/c/s/q> n
    
    Remember the remote name you set, as this will be used later.
  3. In a web browser, login to Canvas and head to Account > Settings. Under Approved Integrations, click New Access Token. Type a purpose and click Generate Token.
  4. Copy the access token that appears.
  5. Open the settings.yaml.starter repo file in a text editor.
  6. In the tokens object, paste your access token in place of <access_token>.
  7. Next to timezone, set your local timezone that you would like to appear in file version names. (See here for a list of acceptable options.)
  8. Next to base_url, change the domain from umich.instructure.com to whatever domain your school's Canvas uses.
  9. (optional) If you prefer a different time format to be displayed in file version names, set it at time_fmt. See this page for more details.
  10. Set up the courses for which you would like your files synced. Go back to your web browser and visit the homepage for the course in Canvas. In the url bar, you should see something like this:
    https://<canvas-domain>/courses/123456
    
  11. Copy the number at the end. This is the course id.
  12. In the settings file, edit the id of one of the courses to this value. Make sure the access_token key refers to the name in front of the actual token you pasted in step 6.
  13. If you want to sync content from the Modules page instead of the Files page, add modules: true to the corresponding course in the settings file.
  14. For the rclone key, change the drive to the remote name you set in step 2, and change the path to wherever you want your course files to appear relative to your cloud storage.
  15. Repeat steps 10-13 for each course. You can have as many courses, tokens, or rclone entries you want.
  16. Delete any default entries you aren't using.
  17. Finally, rename the settings.yaml.starter file to settings.yaml:
    $ mv settings.yaml.starter settings.yaml
    
  18. Run the canvassync.py file to test it. (Use ./canvassync.py -h to see available options.)
  19. Make a cronjob using crontab -e to have your files synced automatically on a specified interval and receive email notifications on error. For example, to sync your files every 10 minutes, add the following to the file:
    MAILTO:<your_email>
    */10 * * * * /usr/bin/flock -n /tmp/canvassync.lockfile <path_to_canvassync.py>
    

About

Syncs all Canvas files from specified courses to a local folder, then uploads them to cloud storage using rclone.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages