Google Workspace
The Google Workspace source migrates the users of a Workspace domain. Vandelay reads the directory (users, aliases, domains, groups and calendar resources) through the Admin SDK, and copies each user’s mail with its Gmail labels, through the Gmail API by default or over IMAP. It also copies each user’s own calendars and contacts, and the Gmail filters, forwarding, vacation reply and send-as addresses. It signs in with a service account that has domain-wide delegation, so no user password is needed. Drive files are not copied.
A hosted service cannot be placed behind the Stalwart proxy, because the operator controls neither its network nor its ports, so Google Workspace is migrated with a one-shot migration: every account is copied while users keep working in Gmail, and each domain moves at once with its MX records and client settings.
Migrated data
Section titled “Migrated data”Mail is copied with its labels: each label becomes the folder of the same name, and a message with several labels is filed in each of them, without being copied twice. The Gmail API route puts the system folders (sent, drafts, spam, trash) at the top level, while the IMAP route keeps them under a [Gmail] folder, as Gmail’s IMAP service shows them.
Each user’s primary calendar and the secondary calendars the user owns are copied with their events, recurring series, changed and cancelled occurrences, reminders and colours. Calendars shared with or subscribed by the user, such as a colleague’s calendar or a holiday calendar, are not copied from that user, and the run names them in a warning; a shared calendar comes from its owner’s account when the owner is migrated. Birthday events are not copied, because the birthday stays on the contact. Event attachments are Drive links, and are copied as links, which open only for people that Drive lets in. Contacts are copied into an address book named Contacts, with their labels as keywords and their photos.
The Gmail settings are converted for Stalwart:
- Filters become mail rules. A label becomes the folder of the same name, and skipping the inbox moves the message to the folder that holds unlabelled mail. A filter whose label is not migrated loses that action, and the loss names the label.
- Forwarding becomes a forwarding rule placed before the filters. Stalwart forwards a message through at most one rule, so when the forwarding setting and a forwarding filter match the same message only the first forwards it, which is reported once per account. Forwarding is migrated as each user set it, without Gmail’s spam exception and regardless of the domain’s forwarding policy; when the domain blocks automatic forwarding, turn off “Forwarding” (
data.forwarding) on the “Data to migrate” step. - A vacation reply limited to the user’s contacts or to the organisation is migrated turned off, with its text and dates, because Stalwart replies to every sender.
- Verified send-as addresses become identities.
In the directory, suspended and archived users become disabled accounts. A group with a collaborative inbox becomes a group with a mailbox, and any other group becomes a list of its members. Calendar resources have addresses under resource.calendar.google.com, so each is proposed an address in the primary domain, made from its name, such as [email protected]; change it with an account override before provisioning when the name gives an unwanted address.
Google exposes no password hashes, so every account gets a temporary password, or signs in through an external identity provider, as chosen in Passwords. No DKIM keys are read either; provisioning generates new ones, as described in DKIM keys.
Source preparation
Section titled “Source preparation”Prepare Google Workspace in three steps, in the Google Cloud console and in the Google Admin console. The same steps are printed by vandelay migrate guide google and shown beside the Source: access step in the web and terminal interfaces.
- Enable the APIs. In the Google Cloud console, create a project or pick one, and enable the Admin SDK API, the Gmail API, the Google Calendar API and the People API, plus the Groups Settings API when the optional scope below is granted. Without the Gmail API, no user’s mail is read on the default route, and no filters, forwarding, vacation reply or send-as addresses are migrated; without the Calendar API or the People API, no calendars or contacts are.
- Create the service account. Create a service account in that project and add a JSON key to it. Keep the downloaded file safe: through domain-wide delegation, it signs in as any user of the domain. In a Google Cloud organisation created on or after 3 May 2024, key creation is blocked by default by the organisation policy constraint
iam.disableServiceAccountKeyCreation, or its managed formiam.managed.disableServiceAccountKeyCreation. An Organization Policy Administrator (roles/orgpolicy.policyAdmin) on the organisation then exempts the migration’s project from the constraint, leaving it enforced everywhere else, as Create and delete service account keys describes; the secure-by-default organisations page lists the constraints enforced by default. - Delegate the scopes. In the Google Admin console, open Security, Access and data control, API controls, Manage Domain Wide Delegation, choose Add new, enter the service account’s client ID, and grant the scopes listed below. Adding domain-wide delegation needs a super administrator, as Google’s domain-wide delegation article states. Delegation usually applies within minutes, but Google allows up to 24 hours; until then the connection test fails, with a hint that domain-wide delegation is not granted for the requested scopes or has not propagated yet.
Scopes
Section titled “Scopes”Every project needs these scopes:
https://www.googleapis.com/auth/admin.directory.user.readonlyhttps://www.googleapis.com/auth/admin.directory.group.readonlyhttps://www.googleapis.com/auth/admin.directory.domain.readonlyhttps://www.googleapis.com/auth/admin.directory.resource.calendar.readonlyhttps://www.googleapis.com/auth/gmail.readonlyhttps://www.googleapis.com/auth/calendar.readonlyhttps://www.googleapis.com/auth/contacts.readonlyThe IMAP route also needs https://www.googleapis.com/auth/gmail.imap_admin. The Gmail API route does not: that scope opens every mailbox over IMAP with full access, while the Gmail API route reads with gmail.readonly.
Two scopes are optional:
https://www.googleapis.com/auth/apps.groups.settingsreads each group’s settings: who may post to it, whether it is a collaborative inbox, and whether it keeps a message archive. No read-only form of the scope exists, but Vandelay only reads. Without it, every group becomes a list of its members that accepts mail from any sender, a collaborative inbox included, and each group is reported.https://www.googleapis.com/auth/contacts.other.readonlyreads each user’s Other contacts, the addresses Gmail saved from mail the user exchanged, into a second address book named Other contacts. Without it, they are not migrated, and each user is reported.
Plan settings
Section titled “Plan settings”“Service account key” (source.service_account, --service-account) is a secret reference to the JSON key, file:PATH or env:NAME, never the key itself; ask is refused with Service account key cannot be ask: the key spans several lines and cannot be typed at a prompt; give file:PATH (the key file on the vandelay host) or env:NAME. A file: path names a file on the host where Vandelay runs. “Administrator” (source.admin, --admin) is the address of a super administrator, on whose behalf the directory is read. An administrator whose role covers only some organisational units would see part of the directory, so the connection test refuses any other administrator with <admin> is not a super administrator; a delegated admin sees only part of the directory.
“Mail route” (source.route, --route) decides how mail is read: api, the default, through the Gmail API, or imap over IMAP. The two routes build different folder trees, so the route is bound once work starts. Changing it means a new project, which does not remove the folders the first route already copied, so the same mail would appear under both layouts; point a new project at accounts that are still empty, or empty them first.
The following command sets a Google Workspace source on the Gmail API route, with the key in the project directory:
vandelay migrate source --system=google \ --service-account=file:secrets/workspace-key.json \ --route=apiThe same settings in plan.toml:
[source]system = "google"service_account = "file:secrets/workspace-key.json"route = "api"Quotas
Section titled “Quotas”Gmail limits the mail a user can download over IMAP to about 2,500 MB a day, and Vandelay keeps each account within the same budget over a rolling 24-hour window on both routes. A large mailbox is therefore copied over several days: the run pauses the account shortly before its budget is spent and resumes it on its own once enough of the window has passed. Starting the first copy well before the planned change leaves room for this.
Gmail also throttles requests per user and per project. Vandelay reads each mailbox with two parallel requests on the Gmail API route, and retries the requests that Gmail throttles. When Gmail reports that a daily quota is exhausted, the account’s copy stops with gmail quota exhausted: <detail>, and a later run continues it.
Items not migrated
Section titled “Items not migrated”The directory reports what it cannot carry, among others:
- Users without a Gmail mailbox:
user <address> has no Gmail mailbox and is not migrated. - Posting restrictions and message archives of groups, for example
group <group> accepts mail only from <who> in Google; the migrated group accepts mail from any sender. - The conversations of a collaborative inbox, which live in Google Groups: its mailbox on Stalwart starts empty.
- Groups whose members include every user of the organisation, whose members are added by hand.
- Unverified domains, and the test domain alias that Google adds to every Workspace account.
For each user, the run reports:
- Send-as addresses that are not verified in Gmail, and mail delegates:
mail delegate <address> (Gmail delegation) is not migrated; grant the access on Stalwart. - Google Chat messages, which the Gmail API route counts as skipped and reports once per account.
- Working location entries, reported once per account.
- Calendars of a user who cannot use Google Calendar:
No Google calendars of <account> are copied: Google reports that <account> cannot use Google Calendar (the user never opened it, or Calendar is turned off for the user); if it is turned off, turn it on and run a delta. - Calendars, contacts or the events of one calendar whose listing Google refused, for example
Events of Google calendar <name> of <account> are not migrated: Google refused the listing (<text>); anything archived on an earlier run is kept. Nothing archived is removed for them. - Calendars and contacts of a user for whom Google refused a token:
Google calendars and contacts of <user> are not migrated: Google refused a token for <scopes> (<text>). A refused token for the optional Other contacts scope leaves out only the Other contacts, withGoogle Other contacts of <user> are not migrated: Google refused a token for https://www.googleapis.com/auth/contacts.other.readonly (<text>). - Settings that could not be read, with a hint such as
check that the Gmail API is enabled in the service account's project and that gmail.readonly is delegated.
Drive files are not migrated.
Cutover notes
Section titled “Cutover notes”The change of a domain follows One-shot migration, with three points specific to Google Workspace.
Before the change, publish the records Stalwart needs: the DKIM keys that provisioning generated, SPF and DMARC records that authorise Stalwart, MTA-STS, and the autoconfig and Autodiscover names, as Records to change lists. Lower the TTL of the MX records a day in advance, so that sending servers follow the change quickly.
Users’ clients need to be set up again. Phones, tablets and mail programs configured with a Google account type keep connecting to Google after the MX change, whatever the DNS says, so each user removes that account and adds the Stalwart account, with the temporary password or the external sign-in. vandelay migrate export-users and vandelay migrate guide mail-merge prepare the message to send them, as User communication describes.
Keep the Workspace subscription active until the catch-up passes have run for every account. Until then the domain can still be returned to Google by restoring its MX records and client settings, but Vandelay cannot undo the switch (see No rollback): mail that Stalwart received after the change exists only on Stalwart, and has to be carried back separately, for example by users moving it with a client connected to both services.