Skip to content

Automatically migrate Zoom recordings

Why migrate

We primarily use Zoom for meetings which records and stores it for 120 days. But the recordings can be required to be stored for much longer period, for example, in case of Business development meetings with new leads. These leads take much longer than 120 days to mature into sales.

Solution

A simple solution is to store these recordings in cloud, i.e. Google drive in our case. To automate the process of downloading and uploading to drive, we have implemented a python script.

The solution goes through a list of zoom accounts set up in configuration, downloads and then uploads all videos (based on filters provided) to google drive in the designated folder. It also sends email notification with details about migrated videos.

This script can be run locally as well as on Gitlab via schedules feature.

Running via Gitlab

Currently, the script is executed once every week.

Following environment variables are required to be configured before execution. Ideally, we just need to configure the below variables once in Gitlab CI/CD varibles settings.

  • GOOGLE_API_CREDENTIALS: Copy contents of token_json from this store and set it as value of creds_or_token environment variable as shown below. If you want to use a different google account, you can create new credentials for a desktop application by following this document. If the script fails with invalid credentials error, copy contents of credentials_json and set it as value of creds_or_token env and run python -m automation.libs.google locally to get updated token.

    1
    2
    3
    4
    5
    6
    7
    {
        # set value of token in CI/prod.
        "creds_or_token": {"token": "...", "refresh_token": "...", "token_uri": "...", "client_id": "...", "client_secret": "...", "scopes": ["..."], "expiry": "..."},
        # set value of credentials_json locally to get updated token and replace it.
        "creds_or_token": {"installed":{"client_id":"...","project_id":"...","auth_uri":"...","token_uri":"...","auth_provider_x509_cert_url":"...","client_secret":"...","redirect_uris":["http://localhost"]}},
        "scopes": ["https://www.googleapis.com/auth/drive.file", "https://www.googleapis.com/auth/drive.metadata"],
    }
    
  • ZOOM_ACCOUNTS: Create a variable with list of zoom accounts in below format. You can optionally set start, end date and pattern to filter recordings. Credentials (client_id, client_secret and account_id) can be generated by creating a OAuth app in Zoom marketplace. The steps can be found here.

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    [
        # zoom account 1
        {
            "client_id": "xxxxxxxxxxxxxxxxxxxxxx",
            "client_secret": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
            "account_id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
            "user_id": "me", # optional: zoom user id
            # recipients will recieve a notification email about successful and failed videos
            "recipients": ["xxxxx@xxxxxxxxx.xxx"],
            "drive_folder_name": "xxxxxxxxxxxxxx",
            "start": "2022-07-01 00:00:00", # optional
            "end": "2022-07-08 00:00:00", # optional
            "pattern": "^.* - sprint retrospective$" # optional
        },
        # zoom account 2
        {
            "client_id": "xxxxxxxxxxxxxxxxxxxxxx",
            "client_secret": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
            "account_id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
            "recipients": ["xxxxx@xxxxxxxxx.com"],
            "drive_folder_name": "xxxxxxxxxxxxxx",
            "last_n_days": 7 # Download videos from last 7 days
        }
    ]
    

  • DRIVE_FOLDER_IDS: Map of IDs of the folders in drive to be used as base directory. All folders will be created inside this directory. Please share these directories with the service account.

    1
    2
    3
    4
    {
        "general_base_dir_id": "xxxx", # directory used for general zoom meetings
        "retro_base_dir_id": "Xsaddx" # directory used for retrospective zoom meetings
    }
    

  • EMAIL_SETTINGS: Configuration for sending emails.
    1
    2
    3
    4
    5
    6
    7
    8
    {
        "use_tls": true,
        "port": 1025,
        "host": "xxxxxxxxx",
        "host_user": "xxx",
        "host_password": "xxx",
        "from_email": "xxxxxxxx@xxxxxxx.xxx"
    }
    
  • DEBUG: [Optional] Setting this to true would allow you to download and upload videos without deleting them from zoom

Setup a schedule in gitlab. You can also trigger the schedule manually as described here.

Running locally

You can also run the script locally by setting up the same environment variables as mentioned above.

  • Install pre-requisites
1
make install_prereqs
  • Execute the script by running below command.
1
make migrate_zoom_meetings

Migrating sprint retrospective recordings

A separate script/job has been defined to migrate sprint retrospective meetings. Only difference is that it creates the file with sprint and cell name and instead of sending email notification, it creates a forum post in specific cell forum topics.

Below environment variables are required to be defined.

  • GOOGLE_API_CREDENTIALS: Same as above
  • DRIVE_FOLDER_IDS: Same as above
  • DISCOURSE_CONFIG: Discourse api url, key, username and topic_ids.
    1
    2
    3
    4
    5
    6
    {
        "api_url": "https://forum.opencraft.com/",
        "api_key": "Xxx",
        "username": "Xxx",
        "topic_ids": {"cell_name": "1", "cell_name2": "2"}
    }
    
  • RETROSPECTIVE_CONFIG: Configuration specifically for migrating sprint retrospective meetings.
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    {
        # Text to be used for generating forum post message
        "message_body":"**{sprint_name} Sprint Retrospective Meeting**\n\n <iframe src=\"https://drive.google.com/file/d/{file_id}/preview\" width=\"640\" height=\"360\" frameborder=\"0\" allowfullscreen></iframe>",
        "zoom_account":
            {
                "client_id": "xxxxxxxxxxxxxxxxxxxxxx",
                "client_secret": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
                "account_id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
                "user_id": "example@example.com",
                "recipients": [],
                "last_n_days": 7,
                "pattern": "(?P<cell_name>.*) - synchronous sprint retrospective$"
            },
        # api url to fetch sprint names from
        "sprint_name_url":"https://some-host/sprint_names/?active_sprint=true",
        # auth header for sprint_name_url
        "headers": {
            "Content-Type": "application/json",
            "Authorization": "Token xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
        },
        "dummy_sprint_names": {"bebop": "BB.278", "serenity": "SE.278"}  # Optional: to be used for testing purpose only
    }
    

Last update: 2023-09-25