Getting started: Making data images
In the previous exercise we made a new data image by making changes to a Spawn database and then graduating it. We can also create new data images from scratch. Data images can be created from empty databases, from backups and from scripts.
#
Create a data image from an existing backupData images can also be created directly from backup files. The backup is first uploaded to the Spawn service and restored to a new database, before being used to create our re-usable data image. For a large backup file the initial upload might take some time, but after that new copies can be created in just a few seconds.
- PostgreSQL
- MySQL
- SQL Server
We'll use a sample backup file for this example -- it's just a single table with a few rows of data, generated by pg_dump.
Save dump.sql to a local folder (you might need to rename it to dump.sql
).
Save the configuration file database-from-backup.yaml alongside the backup file, renaming it if needed.
This configuration file tells Spawn to create a data image from the backup file dump.sql
in the current folder, restoring it to PostgreSQL 12.0, and to name the data image database-from-backup
We'll use a sample backup file for this example -- it's just a single table with a few rows of data, generated by mysqldump.
Save dump.sql to a local folder (you might need to rename it to dump.sql
).
Save the configuration file database-from-backup.yaml alongside the backup file, renaming it if needed.
This configuration file tells Spawn to create a data image from the backup file dump.sql
in the current folder, restoring it to MySQL 5.7, and to name the data image database-from-backup
We'll use a sample backup file for this example -- it's just a single table with a few rows of data, generated using the T-SQL BACKUP DATABASE command.
Save sample.bak to a local folder (you might need to rename it to sample.bak
).
Save the configuration file database-from-backup.yaml alongside the backup file, renaming it if needed.
This configuration file tells Spawn to create a data image from the backup file sample.bak
in the current folder, restoring it to SQL Server 2017, and to name the data image database-from-backup
Call create data-image, passing in the path to the configuration file we created:
This data image can now be used to create multiple database copies, using spawnctl create data-container
as before:
Connect to this new data container and you'll find the database just as though it was restored from the backup file. Unlike restoring a database backup though, once the data image has been created Spawn will create new copies in seconds, regardless of the size of the backup.
- PostgreSQL
- MySQL
- SQL Server
Besides backups, data images can also be created from empty or from scripts. See source configuration for more information about creating data images from different sources.
#
Next stepsThat's the basics of Spawn covered:
- Creating disposable copies of databases for development and testing
- Resetting those database and creating revisions to undo changes
- Creating your own data images from which to make further database copies
Next learn more about the spawnctl commands