Data Snapshots & Backups
Pagoda Box offers many different types of databases as well as network storage. With any data-storage comes the need for regular snapshots & backups. Your data is incredibly important and keeping up-to-date snapshots & backups can be a lifesaver in tight situations. Pagoda Box gives you the tools you need to easily take snapshots of your data and offers other tools for backing data up. After reading this doc, you will be familiar with:
- The differences between snapshots & backups
- How to create snapshots of your data
- How to restore data using snapshots
- Different backup strategies you can employ for you data
The Difference Between Snapshots & Backups
Although these terms are often used synonymously, in this doc and on Pagoda Box, there are key differences between the two.
A snapshot is a copy of your service’s data taken at a specific date & time and is stored in the Pagoda Box storage cluster. Snapshots can be taken and used to restore data in your dashboard. However, snapshots cannot be downloaded. They can only be managed in your dashboard.
A backup is a copy of your service’s data taken a specific date & time, however these are not handled by Pagoda Box. How backups are taken and where they are stored is completely up to you. Pagoda Box does not provide or manage automated data and storage backups. It is up to you to employ backup strategies beyond what snapshots offer. Below are examples and suggestions of potential backup strategies.
Managing Snapshots in Your Dashboard
All data snapshots are managed in the dashboard under the “Snapshots” tab of each data service. Here snapshots can be created, restored from, or deleted.
Creating a Snapshot
To create a snapshot, simply click the “New Snapshot” button.
Restoring from a Snapshot
To restore from a snapshot, simply click the “Restore” button below the snapshot you’d like to restore. When restoring, any new data added since the selected snapshot was created will be overwritten. You will need to confirm that you understand this risk before the snapshot is restored.
Deleting a Snapshot
To delete a snapshot, simply click the “X” in the upper right of the snapshot you’d like to delete.
Snapshot Storage Pricing
Snapshots are stored in the Pagoda Box storage cluster. Storage is $0.50 per GB per 30 days.
Suggested Backup Strategies
While keeping snapshots on-hand is nice, snapshots can only be accessed from your dashboard. We highly recommend putting other backup strategies in place.
Use Cron Jobs to Run Regular, Downloadable Backups
Cron jobs allow you to schedule and automate tasks making them a great tool for automating backups. Where your backups get stored is completely up to. You can store them in one of your network directories, email the backup files to yourself, or push them to offsite storage. It’s totally up to you.
Below are some simple examples of backup cron jobs configured in the Boxfile. In these examples, backups are saved to a network directory, but that is by no means your only option.
Example Cron Job Backups in the Boxfile YAML
web1: cron: #MySQL - "0 0 * * *": "mysqldump -h $DATABASE1_HOST -P $DATABASE1_PORT -u $DATABASE1_USER -p$DATABASE1_PASS gopagoda > path/to/network_dir/bk_`date +\%m-\%d-\%Y_\%H-\%M\%Z`.sql" #MariaDB - "0 0 * * *": "mysqldump -h $DATABASE1_HOST -P $DATABASE1_PORT -u $DATABASE1_USER -p$DATABASE1_PASS gopagoda > path/to/network_dir/bk_`date +\%m-\%d-\%Y_\%H-\%M\%Z`.sql" #Percona - "0 0 * * *": "mysqldump -h $DATABASE1_HOST -P $DATABASE1_PORT -u $DATABASE1_USER -p$DATABASE1_PASS gopagoda > path/to/network_dir/bk_`date +\%m-\%d-\%Y_\%H-\%M\%Z`.sql" #MongoDB - "0 0 * * *": "mongodump -h $DATABASE1_HOST:$DATABASE1_PORT -u $DATABASE1_USER -p $DATABASE1_PASS --db gopagoda > path/to/network_dir/mongodump_`date +\%m-\%d-\%Y_\%H-\%M\%Z`"
You can also create cron jobs on your local machine or another remote server that connect to your data services, run a backup, and store the backup file. Where and how you do that depends on your operating system.
Below is an example command that opens a secure SSH connection to a network storage service, compresses all the contents, then downloads the compressed file to the local filesystem. (Obviously, replace the IP and Port with the IP and Port assigned to your network storage service).
Backing Up Network Storage to Your Local Machine Terminal
$ ssh email@example.com:1234 "tar -cz /data" > path/to/local-dir/nfs_backup`date +\%m-\%d-\%Y`.tar.gz
You can also use this same technique to run db backups and save them to your local machine, however, you’d have to SSH into one of your code services, then run the backup command. When connecting directly to data services, your are not given a native prompt. More information in the SSH Access to Services doc.
Keep Offsite Backups
Keeping offsite backups is always a good idea. Here’s why: Say for example, all of your backups are stored in network storage. One day, one of your collaborators makes a mistake and deletes your network storage service. Once deleted, it’s gone, along with everything stored in it. If you don’t have offsite backups, there’s not much that can be done. You’re out of luck.
The above example of storing backups to your local machine is a simple way of keeping offsite backups. You can also push backups to another cloud storage-provider or one of your own remote servers. No matter where you store them, we highly recommend adopting the practice of keeping offsite backups.
Table of Contents
- Creating a Snapshot
- Restoring from a Snapshot
- Deleting a Snapshot
- Automating Snapshots
- Snapshot Storage Pricing
If you have any questions, suggestions, or corrections, let us know.