Back up and restore a cluster
BigAnimal automatically and continuously saves backups of your clusters. You can restore your cluster to any point in the past after the initial backup on cluster creation. That functionality is included in the free trial as well. While that means you don't have to do anything to generate backups, it's always sensible to test your backups.
If you haven't already, create a cluster on BigAnimal. For the free trial, you can have only one active cluster. Since this example is a demonstration of recovering a cluster from backup, it doesn't matter whether you start a new cluster or just restore your current cluster to its current state.
We're going to add a database called "baseball," which we'll populate with some Major League Baseball statistics.
Now you can switch to your new (and empty) baseball database.
Normally we'd use log files to determine the moment in time that we want to restore. The free trial doesn't provide access to the logs, however. So that we have accurate timing of our activities, let's change the prompt to include a timestamp. For convenience, we'll use the (almost) ISO-8601 format that the restore command accepts.
For this demonstration, we're just going to import batter data from the Baseball Databank, which is in CSV form. While it's easy to import the data using PostgreSQL's COPY command, we'll need to first define a table to put that data into. Most of the columns are integers, but there are a few strings to consider as well. You can copy and paste this command into your terminal.
Now we can populate the table from the internet using the most recent data.
Just to prove there's data loaded, let's look at the home run leaders for the 1998 season.
Suppose someone wanted to revise history a bit.
Note the time so we can restore that data later. Verify the data has been changed by rerunning the 1998 home run leader query. Now go ahead and drop the whole table.
You can verify the table is gone by looking at the list of tables.
For the free trial, you're limited to one active cluster. Restoring a cluster creates a brand new cluster that's initialized with the cluster backup. Quit psql (\q
), and delete the cluster from the command line.
Note
For more on using the BigAnimal CLI, see Creating a cluster on the command line and the BigAnimal CLI reference.
Restore the cluster using the timestamp before the time you dropped the table.
Optional arguments for the CLI
We're only providing the information we have handy to the restore command: the ID of the cluster, the fact that the cluster is deleted, and the timestamp for the restore point. The CLI will prompt for additional information, such as the password or the region to restore to, and allow you to enter or select from a list as appropriate.
If you know ahead of time the options you'll need, you can provide all of them using parameters, and the command will run non-interactively.
Check the status of the new cluster from the command line.
Once provisioning is complete, you'll want to grab the new connection information. The hostname changed!
Log into the new cluster. Be sure to use the new hostname, and use the edb_admin password you provided when restoring the cluster.
Verify that the batters table was restored:
Further reading
BigAnimal CLI reference and Backing up and restoring in the full version documentation.
- On this page
- Further reading