Latitude.sh Databases offers scheduled backups to S3-compatible storage, allowing you to protect your data and restore it when needed. Backups are a critical component of any production database strategy, ensuring business continuity and data protection. Restoring a database from a backup is a vital operation that allows you to recover your data in case of accidental deletion, corruption, or when you need to create a copy of an existing database.

How backups work

When you enable backups for your database:
  1. Latitude.sh automatically creates full database backups according to your specified schedule.
  2. Backups are stored in your specified S3-compatible storage location.
  3. Backups are retained for the duration you configure.
  4. You can restore from any available backup when creating a new database.

Configuring scheduled backups

When creating a new database or modifying an existing one, you can enable and configure scheduled backups:
  1. Check the box next to “Scheduled Backups” when creating a database or navigate to the database overview page for an existing database.
  2. Enter the name of your S3 bucket and specify the backup path where the backups will be stored (E.g. /backups).
  3. Provide your S3 Endpoint.
  4. Enter your Access Key ID and Secret Access Key.
  5. Use the Schedule (Cron) dropdown to set how often backups should run. For a custom schedule, enter a six-field cron expression (E.g. 0 0 3 * * * for daily backups at 3 AM UTC).
  6. In the Retention field, enter how many days backups should be kept (E.g. 30 days).
  7. Click Apply to save the backup configuration.
Once enabled, you’ll see a shield icon next to your database in the database list, indicating that backups are active.

Restoring a Database from a Backup

Latitude.sh provides multiple intuitive ways to restore databases from backups, ensuring this functionality is easily accessible when you need it most, especially in critical situations.

Prerequisites for Restoration

Before you can restore a database from a backup:
  • You must have at least one database with backups configured.
  • At least one successful backup must have been created.
  • You need appropriate permissions to create databases in your project.

Restoration Methods

Latitude.sh offers multiple straightforward ways to restore a database from a backup:

Method 1: From the Database List View

The most direct way to restore a database from a backup is directly from the database list view:
  1. Navigate to Databases in the sidebar menu to view your list of databases.
  2. Find the database with the backup you want to restore from and click the actions menu (three dots) on the right side of its row.
  3. Select Restore from backup from the dropdown menu.
  4. Choose the specific backup point you want to restore from.
  5. Provide a name for your new database.
  6. Select a plan and specifications. Note that the plan must be equal to or higher than the source database’s plan.
  7. Click Deploy to start the restoration process.

Method 2: From a Database’s Overview Page

You can also initiate a backup restoration from a specific database’s overview page:
  1. Navigate to Databases in the sidebar menu.
  2. Click on the name of the database that has the backup you want to restore from.
  3. On the database overview page, click the actions menu in the top right corner.
  4. Select Restore from backup from the dropdown menu.
  5. Follow the prompts to select a specific backup, name your new database, and choose appropriate specifications.
  6. Click Deploy to create the new database from the backup.

Method 3: From the Database Creation Flow

You can also restore from a backup when creating a new database:
  1. Navigate to Databases in the sidebar menu and click Restore from backup.
  2. Select a source database and choose the backup you want to use. If no databases appear, ensure backups have been created.
  3. Provide a name for your new database.
  4. Choose a plan and specifications based on your requirements. Note that the selected plan must be equal to or higher than the source database plan.
  5. Click Deploy.

Important Considerations for Restoration

When restoring a database from a backup, keep these points in mind:
  • The restoration process creates a new database; it does not overwrite the existing one.
  • The new database will have a different connection string than the original.
  • You must update your application configuration to use the new connection string.
  • The restoration time depends on the size of the backup.
  • The new database must use a plan equal to or higher than the source database’s plan.
  • All data in the backup will be restored, including tables, indexes, and stored procedures.

Backup and Restoration Best Practices

For an optimal database backup and restoration strategy:
  1. Set appropriate frequency: Configure backup frequency based on how much data you can afford to lose. Critical applications might require hourly backups, while less critical ones might be fine with daily backups.
  2. Test your backups and restoration: Periodically create a test database from a backup to verify that your backups are working correctly and can be restored. Regularly testing your backup restoration process is recommended to ensure you can recover your data when needed.
  3. Secure your S3 credentials: Ensure that the S3 credentials used for backups have appropriate permissions and are securely stored.
  4. Consider retention periods: Set retention periods based on your compliance requirements and storage constraints.

Troubleshooting

If you encounter issues with your database backups or the restoration process:

Backup Issues:

  1. Verify S3 credentials: Ensure your S3 access key and secret key are correct and have appropriate permissions.
  2. Check S3 bucket existence: Confirm that the specified S3 bucket exists and is accessible.
  3. Validate cron expression: If using a custom schedule, verify that your cron expression is correctly formatted using a 6-field format.

Restoration Issues:

  1. Ensure sufficient permissions: Verify you have permissions to create databases in your project.
  2. Check for successful backups: Confirm that the source database has successful backups available.
  3. Review database logs: If the restoration fails, check the database logs for specific error messages.
If you continue to experience issues with backups or restoration, contact Latitude.sh support for assistance.