Getting started: Using data containers
The state of a Spawn data container can easily be saved so that you can
- undo mistakes
- return to previous states
- store the state to make further copies from
note
Ensure you've completed the Spawn installation guide before going further.
#
Accidentally delete data from the databaseWe're going to pretend to make a mistake with the database, deleting some data that we didn't intend to. Using the connection details, connect to the database using your preferred client and delete all the records from a table:
- PostgreSQL
- MySQL
- SQL Server
#
Reset the database to its original stateNormally we'd now need to restore the data from a backup, but Spawn allows you return the database to its original state in just a few seconds using the reset data-container command:
Reconnect to the database and check -- the data we just deleted is restored, undoing the mistake.
#
Make some changes you'd like to keepWhat if you want to keep changes that you've made, so that a reset will only return to that point? You can save the state of your database at any time using the save data-container command.
Let's add a new table and some data to our database. Use your database client to execute the following:
- PostgreSQL
- MySQL
- SQL Server
#
Save the new state as a "revision"We can save the current state of the database as a new revision. This is the default state that reset will return to. Each time you use the save data-container command it will create a new revision.
note
You can use the load data-container command to return to states other than the current revision.
#
Store the state to make further copiesThe revisions that we've created only exist for as long as the data container lives -- if we delete the data container the revisions will be lost. To store a revision for later use we need to use the graduate data-container command, creating a persistent data image that can be used to create new data containers.
The new image appears in the list of available data images:
This data image includes the new table that we added to our database, and can be used to create new data containers whenever we need them: