LogoLogo
DoltHubBlogDiscordGitHubDolt
  • Introduction
    • What Is Dolt?
    • Installation
      • Linux
      • Windows
      • Mac
      • Build from Source
      • Application Server
      • Docker
      • Upgrading
    • Getting Started
      • Version Controlled Database
      • Git For Data
      • Versioned MySQL Replica
    • Use Cases
      • Data Sharing
      • Data and Model Quality Control
      • Manual Data Curation
      • Version Control for your Application
      • Versioned MySQL Replica
      • Audit
      • Configuration Management
      • Offline First
  • Concepts
    • Dolt
      • Git
        • Commits
        • Log
        • Diff
        • Branch
        • Merge
        • Conflicts
        • Remotes
        • Working Set
      • SQL
        • Databases
        • Schema
        • Tables
        • Primary Keys
        • Types
        • Indexes
        • Views
        • Constraints
        • Triggers
        • Procedures
        • Users/Grants
        • Transactions
        • System Variables
      • RDBMS
        • Server
        • Backups
        • Replication
    • DoltHub/DoltLab
      • Permissions
      • Pull Requests
      • Issues
      • Forks
  • SQL Reference
    • Running the Server
      • Configuration
      • Access Management
      • Branch Permissions
      • Backups
      • Garbage Collection
      • Metrics
      • Replication
      • Troubleshooting
    • Version Control Features
      • Using Branches
      • Merges
      • Querying History
      • Using Remotes
      • Procedures
      • Functions
      • System Tables
      • System Variables
      • Saved Queries
    • SQL Language Support
      • Data Description
      • Expressions, Functions, Operators
      • Supported Statements
      • MySQL Information Schema
      • Collations and Character Sets
      • System Variables
      • Miscellaneous
    • Supported Clients
      • Programmatic
      • SQL Editors
    • Benchmarks and Metrics
      • Correctness
      • Latency
      • Import
  • CLI Reference
    • Commands
    • Git Comparison
  • Architecture
    • Overview
    • Storage Engine
      • Commit Graph
      • Prolly Trees
      • Block Store
    • SQL
      • Go MySQL Server
      • Vitess
  • Guides
    • Cheat Sheet
    • Contributing
      • dolt
      • go-mysql-server
    • MySQL to Dolt Replication
    • Importing Data
    • Integrations
  • Other
    • FAQ
    • Roadmap
    • Versioning
  • Products
    • Hosted Dolt
      • Getting Started
      • Notable Features
      • SQL Workbench
      • Cloning a Hosted Database
      • Using DoltHub as a Remote
      • Infrastructure
    • DoltHub
      • Data Sharing
      • API
        • Authentication
        • SQL
        • CSV
        • Database
        • Hooks
      • Continuous Integration
        • Getting Started
        • Workflow Reference
      • Transform File Uploads
      • Workspaces
    • DoltLab
    • Dolt Workbench
    • DoltgreSQL
Powered by GitBook
On this page
  • How it works
  • Example
  • 1. Expose remotesapi endpoint
  • 2. Set remote password and run clone command with user flag
  • 3. Sync your local copy with upstream changes
  • 4. Sync your upstream with changes from local copy

Was this helpful?

Edit on GitHub
Export as PDF
  1. Products
  2. Hosted Dolt

Cloning a Hosted Database

PreviousSQL WorkbenchNextUsing DoltHub as a Remote

Last updated 1 year ago

Was this helpful?

How it works

In some cases you might want to clone your database from Hosted so that you can access Dolt's . While much of the command line is there are some CLI-specific features that can be helpful for debugging your database offline.

In order to clone from Hosted, we needed to add support for exposing the databases on a Hosted sql-server as a read-only remotesapi endpoint. When you run sql-server with this configuration, it will:

  1. Listen on an indicated port and serve read-only remotesapi traffic on that port

  2. Use any server-side TLS associated with the sql-server itself as part of that listener

  3. Use the deployment's user and password in the sql-server config as password authentication credentials for accessing the exposed data

Once you allow the remotesapi to be exposed for your Hosted deployment (available only for deployments with Web PKI certificates), you can simply set a DOLT_REMOTE_PASSWORD environment variable and provide a username to the dolt clone command. You'll see these instructions in the Connectivity tab of your deployment page.

Example

When you're using Hosted as your production database, there might be some performance-heavy operations or tests you want to run in isolation so you don't impact production, such as beta testing a considerable schema migration or running a big analytics query. makes it easy to get a local copy of your Hosted database with one command. Do whatever potentially destructive or performance-degrading operations on your laptop while respecting your production database.

1. Expose remotesapi endpoint

In order to enable cloning from your Hosted database, first expose the . This will set the port for a server which can expose the databases in the sql-server over remotesapi.

Note that this will only work for deployments that use a Web PKI certificate.

Check both the "Use Web PKI Certificate" and "Expose remotesapi endpoint" when creating a deployment will also work.

2. Set remote password and run clone command with user flag

To authenticate against it, you have to set a DOLT_REMOTE_PASSWORD environment variable and pass along a --user flag to the dolt clone command. You can find these instructions in the Connectivity tab on your deployment page.

If you'd like to allow other SQL users to clone without giving them access to your Hosted admin username and password, you can grant them CLONE_ADMIN privileges. They will then be able to execute the above commands using their own SQL user and password.

GRANT CLONE_ADMIN ON *.* TO "[username]"@"[host]";

After running the dolt clone command, you should have a local copy of your Hosted database.

% dolt clone https://dolthub-us-housing.dbs.hosted.doltdb.com/us-housing-prices --user "username"
cloning https://dolthub-us-housing.dbs.hosted.doltdb.com/us-housing-prices
% cd us-housing-prices
% dolt sql -q "select count(*) from sales"
+----------+
| count(*) |
+----------+
| 13844603 |
+----------+

3. Sync your local copy with upstream changes

Assuming your password environment variable is still set, you can authenticate these commands to your remotesapi endpoint in the same way by passing the --user flag:

% dolt pull --user "[username]"
% dolt fetch --user "[username]"

4. Sync your upstream with changes from local copy

% dolt push origin --user "[username]" HEAD:main

Now we can run whatever queries or schema migrations we want without affecting production. If there are updates to the database, easily sync your local copy using or .

If you make any changes on your local copy, you can push them to your upstream using .

dolt fetch
dolt pull
dolt push
command line interface
available in SQL
Clone
remotesapi endpoint