Connect SPSync to DuckDB or MotherDuck
DuckDB is a single local file with no server, which makes it a good place to analyse a
SharePoint replica on one machine. MotherDuck is DuckDB hosted in the cloud, and SPSync
connects to it with the same destination kind, duckdb.
Before you start
Section titled “Before you start”- For a file: a folder on the machine that runs SPSync. Nothing else to install, because SPSync includes DuckDB.
- For MotherDuck: a MotherDuck account, a database and a token from the MotherDuck settings page.
Create the database and a least-privilege user
Section titled “Create the database and a least-privilege user”- File: there is nothing to create. SPSync makes the file on its first run. The account that runs SPSync must be able to write to the folder. DuckDB allows one writing process at a time, so close any other tool that has the file open for writing before a sync.
- MotherDuck: create the database in MotherDuck first, for example
CREATE DATABASE spsync;. MotherDuck access is by token, and SPSync does not limit a token to one database, so use a token from an account that holds only what SPSync should touch.
Allow SPSync to reach it
Section titled “Allow SPSync to reach it”- File: not applicable, because nothing crosses the network. A file on your computer is not reachable from the Azure managed application.
- MotherDuck: SPSync connects outbound over HTTPS to MotherDuck. There is no firewall on your side to open, but the machine running SPSync needs outbound internet access to MotherDuck.
Encrypt the connection
Section titled “Encrypt the connection”A DuckDB file is not encrypted by SPSync, so rely on full-disk encryption. A MotherDuck connection is encrypted in transit by MotherDuck.
Authentication SPSync supports today
Section titled “Authentication SPSync supports today”A file has no authentication: the operating system’s file permissions decide. MotherDuck uses a token carried in the connection string. Microsoft Entra ID and cloud IAM tokens are not supported. Treat the token as a secret, because it is part of the string.
Connect from SPSync
Section titled “Connect from SPSync”A file path, or a MotherDuck string:
/Users/you/spsync/replica.duckdbmd:spsync?motherduck_token=PASTE-TOKEN-HERE-
Desktop app: open the Destination screen, choose DuckDB / MotherDuck, enter the path or the
md:string into File path and choose Test connection. -
CLI:
Terminal window export SPSYNC_DUCKDB_PATH=/Users/you/spsync/replica.duckdbspsync export-config --output replication.yaml \--site-url https://contoso.sharepoint.com/sites/x --list Projects \--pipeline-name spsync_dev --prefix dev \--destination-kind duckdb --connection-string-env SPSYNC_DUCKDB_PATH --dataset-name main \--client-id <entra-app-client-id>mainis DuckDB’s default schema. -
AI assistant: with the admin MCP server connected, a file path can be passed directly. A MotherDuck string holds a token, so you enter it on the secure entry page.
Parquet export
Section titled “Parquet export”You can also write every table to a Parquet file after each round, for tools such as Power
BI that read Parquet. Set parquet_export_dir in the config’s destination: block:
destination: kind: duckdb connection_string_env: SPSYNC_DUCKDB_PATH dataset_name: main parquet_export_dir: ./exportEach table becomes <table_name>.parquet, a full snapshot of its current state, soft-deleted
rows included, rewritten every round. You can also upload to an abfss:// or s3:// location
with parquet_export_bucket_url; gs:// is not supported. For an s3:// bucket give an
access key pair (and a session token for temporary keys), or leave them out to use the
machine’s AWS credential, plus an optional region and endpoint for S3-compatible storage.
To avoid storing keys, set parquet_export_s3_role_arn to an IAM role (arn:aws:iam::<account>:role/<name>)
and SPSync assumes it through STS for each upload; if the role’s trust policy needs an external id, put it
in an environment variable and name it with parquet_export_s3_external_id_env. The role cannot be
combined with access keys or with a custom endpoint (an S3-compatible store such as MinIO has no IAM
roles), and a role in the China or GovCloud partition (arn:aws-cn, arn:aws-us-gov) needs
parquet_export_s3_region. spsync doctor shows the AWS identity it connected as and warns when
long-lived access keys are in use. spsync auth s3-policy --bucket <bucket> --prefix <folder> prints
a least-privilege IAM policy (list one bucket, read, write, delete and abort multipart uploads under one
prefix) for you to review and attach yourself; SPSync never attaches it. The role has not been
verified against a live AWS account.
For abfss:// give a SAS token (parquet_export_sas_token_env), or leave it out to use
the Azure default credential chain. spsync doctor warns when the SAS token is within 14 days
of its expiry. To name the identity explicitly instead, set destination.auth.mode to one of
entra_managed_identity, entra_default, entra_service_principal_certificate or
entra_service_principal_secret (the secret is weaker and doctor flags it), with the same fields
as in Delta Lake. This is a preview: it is unit-tested with the
identity library replaced and has not been verified against a live storage account.
destination: kind: duckdb connection_string_env: SPSYNC_DUCKDB_PATH dataset_name: main parquet_export_bucket_url: abfss://<container>@<account>.dfs.core.windows.net/<prefix> auth: mode: entra_managed_identity client_id: <user-assigned-identity-client-id>An Entra mode needs the abfss://...dfs.core.windows.net form (the US Government and China
storage domains are also recognised), because the token is only ever sent to an Azure storage
host. It cannot be combined with parquet_export_sas_token_env or an s3:// bucket, and needs
parquet_export_bucket_url. spsync doctor and Test connection show the identity they connected
as. Print the role assignment (Storage Blob Data Contributor on one container) with spsync auth storage-roles --principal <object-id> --storage-account-id <resource-id> --container <name>;
review it and run it yourself, SPSync never does. The Destination screen does not offer the Entra
modes for the Azure export yet.
The same settings are on the Destination screen in the desktop app and the server (the Parquet export fields under the file path). Its Parquet export S3 authentication choice picks the default AWS credential chain, an access key pair or an IAM role (role ARN and optional external id; the external id is stored as a secret). An AI assistant can set the non-secret ones and send you to the secure entry page for the keys, token and external id.
What Test connection and doctor check
Section titled “What Test connection and doctor check”Both open the file or the MotherDuck database and run SELECT 1. A pass means the path is
writable or the token was accepted. When a Parquet export bucket is set, they also list the
bucket, which proves its credentials work. They do not write a file. spsync doctor reports
it as destination-connectivity.
Common errors
Section titled “Common errors”| What you see | What it means and the fix |
|---|---|
Could not set lock on file |
Another process has the DuckDB file open. Close it, then run again. |
IO Error: Cannot open file |
The folder does not exist or is not writable by the account running SPSync. |
Invalid Input Error: ... motherduck_token or an authentication failure |
The token is missing, expired or revoked. Create a new one in MotherDuck and update the string. |
Catalog Error: Database ... does not exist |
The MotherDuck database in the md: string has not been created. |