Clone a Database

Open inAnthropic

Prerequisites

  • TerminusDB running locally (install guide)
  • Access to the remote database you want to clone

What you'll achieve By the end of this guide, you will have cloned a remote database to your local TerminusDB instance — like git clone for databases.

Cloning creates a full local copy of a remote database, including all documents, schema, and commit history. You can then modify your clone independently and synchronise changes with pull or push.

Clone a public database

Clone the Star Wars database from the public data server:

Example: TypeScript
const clonePublicDb = async () => {
  client.remoteAuth({ type: "basic", user: "public", key: "public" })
  const cloneDetails = {
    remote_url: "https://data.terminusdb.org/public/star-wars",
    label: "Star Wars",
    comment: "Cloned from public data server",
  }
  await client.clonedb(cloneDetails, "star-wars")
  console.log("Database cloned successfully")
}

You now have a local copy of the Star Wars database with its full commit history.

Clone a private database

If the database is not public, provide an API token. For example, to clone from a DFRNT Hub team:

Example: TypeScript
const clonePrivateDb = async () => {
  client.remoteAuth({ type: "token", key: "YOUR_API_TOKEN_HERE" })
  const cloneDetails = {
    remote_url: "https://cloud.dfrnt.com/MyTeam/MyTeam/mydb",
    label: "My Database",
    comment: "Cloned from DFRNT Hub",
  }
  await client.clonedb(cloneDetails, "my_local_copy")
  console.log("Private database cloned successfully")
}

Next steps

  • Pull updates — fetch new commits from the remote
  • Push changes — send your local changes to the remote
  • Branch — create a feature branch on your clone

Was this helpful?