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.
This tool requires rclone along with Python 3.7 or later. Install Python dependencies with pip:
$ pip3 install -r requirements.txt
- Download or clone the repo.
- Set up a new remote in rclone:
Remember the remote name you set, as this will be used later.
$ rclone config ... n/r/c/s/q> n
- 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.
- Copy the access token that appears.
- Open the
settings.yaml.starter
repo file in a text editor. - In the
tokens
object, paste your access token in place of<access_token>
. - 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.) - Next to
base_url
, change the domain fromumich.instructure.com
to whatever domain your school's Canvas uses. - (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. - 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
- Copy the number at the end. This is the course id.
- In the settings file, edit the
id
of one of the courses to this value. Make sure theaccess_token
key refers to the name in front of the actual token you pasted in step 6. - 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. - 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. - Repeat steps 10-13 for each course. You can have as many
courses
,tokens
, orrclone
entries you want. - Delete any default entries you aren't using.
- Finally, rename the
settings.yaml.starter
file tosettings.yaml
:$ mv settings.yaml.starter settings.yaml
- Run the canvassync.py file to test it. (Use
./canvassync.py -h
to see available options.) - 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>