snapshot
Core Concepts
Deploy ☁️

Deploy data

The typical Snaplet workflow involves restoring snapshots to your local development PostgreSQL database to code against. While working locally with snapshots allows for more flexibility, configurability, and the ability to work offline without network latency or connectivity interruptions, there are situations where being able to preview your snapshot on an instant serverless database, called preview databases, is useful.

For example, if you're currently in the process of evaluating Snaplet, being able to restore a snapshot to a preview database allows you to view that database without needing to download and install the Snaplet CLI. Preview databases are also easy to share with team members, and allow you to have isolated preview databases for preview deployments.

As such, Snaplet supports the creation of instant preview databases from snapshots, which allows users to view, code against, or run pull-request previews against a preview serverless PostgreSQL database.

These preview databases can be created from within the Snaplet Cloud dashboard, or the Snaplet CLI. Note, Snaplet can only create a preview database from an unencrypted snapshot.

Each Snaplet Project receives a PostgreSQL server instance where multiple preview databases can be created.

Preview databases on Snaplet Cloud

To create a preview database from within Snaplet Cloud, you'll need to have captured a snapshot from your source database - refer to the Getting Started guide if you need help. From the Snaplet dashboard, click on your snapshot, and then select the 'Previews' tab. From here, simply click the 'Create new preview database' button.

Create a new preview database

The first preview database may take a moment to create, depending on the size of your snapshot. Once done, you'll be able to copy the connection string for the database to import into your preferred database client.

Copy connection string

Preview databases using Snaplet CLI

>_ terminal

$ snaplet preview-database --help
snaplet preview-database [action]
manage preview databases
Commands:
snaplet preview-database create [snapshot] create a preview database from a snapshot [aliases: c]
snaplet preview-database url [name] get a connection URL for a specified preview database [aliases: u]
snaplet preview-database list [snapshot] shows all preview databases created from a specific snapshot [aliases: ls]
snaplet preview-database reset [name] reset a specified preview database state [aliases: r]
snaplet preview-database drop [name] drops a specified preview database [aliases: d]

create [snapshot]

The create subcommand generates a new preview database using a specified snapshot:

>_ terminal

snaplet preview-database create preview_db_tutorial --name my_awesome_pdb

url [name]

This command retrieves the connection URL for a specified preview database. The name parameter is optional and if not provided, the most recent preview database will be used.

>_ terminal

snaplet preview-database url my_awesome_pdb

list [snapshot]

The list subcommand shows all preview databases created from a specific snapshot:

>_ terminal

snaplet preview-database list preview_db_tutorial

reset [name]

This command reset the state of a specified preview database. The name parameter is required and specifies the name of the preview database to reset.

>_ terminal

snaplet preview-database reset my_awesome_pdb

drop [name]

This command drops a specified preview database. The name parameter is required and specifies the name of the preview database to drop.

>_ terminal

snaplet preview-database drop my_awesome_pdb