Skip to content

Pulling data with Sync: copy tables from another site

Describes Sync 0.4.0.

Once another site has given you a connection, you can copy its tables into this site’s database. You choose the tables, how to treat rows you already have, and, for a single table, which rows.

Where to find it

Open Sync > Connections in the admin sidebar (/admin/sync/connections). In the Incoming card, click Sync data on a connection. You need the Admin or Owner role, or a role with the Sync permission, and the Sync module enabled.

Sync data appears only when the connection is active on this site and the sending site reports it active too. A pending incoming connection must be approved first; see the guide on Sync connections. Opening a connection that isn’t active here shows “This connection is not active, so it cannot sync”.

The page, Sync Data, says “Pull data from” and the connection’s name. Close returns to the list. It has two tabs: Bulk Transfer and Precise Transfer.

Before the tables appear

The page first asks the sending site for its tables (“Fetching available tables…”). Some messages you may see:

  • Sender site is offline or unreachable, or another “Failed to fetch tables” message, with a Retry button.
  • A Download password field, when the sending site’s connection has one. Type it and click Continue. As the page says, it is used for this page only and is not stored, so you type it again next time.
  • Rate limited by the sender, retrying in N s: the sending site allows only so many requests a minute. The page waits and tries again by itself.

Bulk Transfer

A legend explains the counts: Sender is the other site’s data, Local is your database, and a warning badge means the two differ.

The table list has a row per table the sending site lets you read:

  • Table, Sender (row count there), Local (row count here, or a dash when the table doesn’t exist here), Size and Checksum (the sender’s and yours, green when they match).
  • Status: New when the table isn’t here yet, Match when the data is the same, otherwise a badge with how many rows differ, or Modified when the counts are equal but the content isn’t.

Under the list, New tables, Different and Match count the tables in each state.

Choosing tables:

  • Click the box at the start of a row to select it. Tables it depends on through foreign keys are selected with it.
  • Tables that point at your selection are marked Suggested (a warning sign and the tip “Used by selected tables — consider including”). They aren’t selected for you.
  • Select All, Deselect All and Select Different (every table that isn’t a match) change the whole selection. The box in the header selects or clears all.

The Conflict: menu decides what happens to a row that already exists here:

  • Skip: leave the local row alone.
  • Overwrite: write the sender’s values onto it.
  • Merge: the same, but keep the local value wherever the sender’s is empty.
  • Append: insert the sender’s rows that don’t match a local row under a new key, and leave matched rows alone.

It starts on the connection’s Default Conflict Strategy, or Skip.

Click Pull N Tables. Tables are pulled in dependency order, one after another, with “Syncing 3/12” and the table being processed. Stay on the page: the pull is driven from it, and if you leave, the table in progress finishes but the rest aren’t started.

If some tables end with errors, the page tries those tables again, up to three more passes, as long as the previous pass imported something. The results note “Auto-retried N times to resolve dependencies”, and a retried table is marked with ↻.

The results

The screen says Sync Complete! or Sync Completed with Errors. A table lists each table with Imported, Skipped and Errors, and a Total row. A table that failed as a whole shows the reason under its name, and the other tables are still pulled. Hover an error count to see its message. Done returns to the connection list.

Common reasons a table fails:

  • It doesn’t exist on this site. Create it first on the Precise Transfer tab.
  • It has no primary key. Such a table is never pulled, because every repeat pull would add the same rows again.
  • The sending site cut it short. Tables are sent in pages; a key type that can’t be paged is sent only up to the sender’s Records per request.

Precise Transfer

Use this tab for one table, or for some of its rows.

  1. Pick a table in Select Table. It shows the sender’s and the local row counts (or New table), and the Table Schema: each Column with its Type, Nullable, Default, and PK on the key.
  2. If the table isn’t here, a warning says Table doesn’t exist locally. Click Create Table to create it from the sender’s schema.
  3. Under Filter Records, choose All records, Specific IDs (a list such as 1,2,3) or ID Range (From and To, for a whole-number key).
  4. Preview rows shows the first 10 matching rows, up to six columns each. As the page says, a preview counts as one download on the sending site, so it is asked for only when you click.
  5. Choose the Conflict Strategy and click Transfer followed by the table name.

The result screen says Transfer Complete! or Transfer Completed with Errors, with the same columns as a bulk pull.

What it doesn’t do

  • It only pulls. Nothing here sends your data to the other site; the other site pulls from you with its own connection.
  • It doesn’t run on a schedule. Every pull is started by hand.
  • Some tables are never offered, whatever the connection allows, such as Sync’s own tables, the settings table and tables holding tokens or provider keys.
  • Some column types aren’t carried: ranges, the geometric types and tsvector. A row holding one counts as an error, and the rest of the table is imported.
  • It can’t tell when a table is kept up to date by a database trigger from another table. Pull only the source table and let the trigger fill the other one here.
  • The sending site’s limits apply. When it refuses, for example after its download or record limit is reached, the pull fails with its reason.