Create and restore database backups

Edit on GitHub

This doc describes how to create and restore database backups in Spryker Cloud Commerce OS (SCCOS).

As all the data is stored in relational databases, you only need database(DB) backups. DB backups are managed via Amazon Relational Database Service (Amazon RDS).

The following DB backups are created automatically:

  • Transaction log backups via AWS Point-in-time recovery.

  • Monthly snapshots with a default retention of 90 days.

  • Hourly snapshots by SCCOS tools with a default retention of 35 days.

Also, you can create DB snapshots manually.

Create a DB snapshot

  1. In the AWS Management Console, go to Services > RDS.

  2. In the navigation pane, select Databases.

  3. In the Databases pane, select the DB you want to take a snapshot of.

  4. Select Actions > Take snapshot.

    This opens the Take DB snapshot page.

  5. Enter a Snapshot name.

Meaningful Snapshot name

Ensure that you enter a meaningful Snapshot name. It is used as an identifier when restoring a DB.

  1. Select Take snapshot.

This opens the Snapshots page. The created snapshot is displayed in the Manual snapshots pane.

Restore a database

To restore a DB from a snapshot, follow the steps below.

Expected downtime

During database restoration, your application is not accessible. For production environments, we recommend setting up a maintenance page. To do that, provide your custom HTML page or request to set up a generic one via support.

Rename a DB

  1. In the AWS Management Console, go to Services > RDS.

  2. In the navigation pane, select Databases.

  3. In the Databases pane, select the DB you want to rename.

  4. Select Modify.
    This takes you to the Modify DB instance: {DB name} page.

  5. In the Settings pane, update the DB instance identifier.

  6. Scroll down the page and select Continue.

  7. In the Scheduling of modifications pane:

  • To apply the changes immediately, select Immediately. This can cause an outage in some cases. For more information, see  Modifying an Amazon RDS DB Instance.

  • To apply the changes during the next scheduled maintenance window of the DB, select During the next scheduled maintenance window. In this case, you have to wait for the database to be renamed before you can restore it from a snapshot.

  1. Review your changes and select Modify DB Instance.
    This takes you to the Databases page with the success message displayed.

Even if you selected to apply the change immediately, it may take a few minutes to update the DB name.

Restore a DB from a snapshot

  1. In the AWS Management Console, go to Services > RDS.

  2. In the navigation pane, select Snapshots.

  3. Select the snapshot you want to restore.

  4. Select Actions > Restore snapshot.
    This takes you to the Restore snapshot page.

  5. Enter the settings of the original DB.

DB settings

Ensure that:

  • DB instance identifier corresponds to the name of the original DB before you renamed it.

  • The settings exactly replicate those of the original DB. Otherwise, the DB may fail to restore correctly or work with the application.

  1. Select Restore DB Instance.
    This takes you to the Databases page with the success message displayed. The entry of the restored DB is displayed in the list.

It may take a few minutes for the DB to restore.

Re-sync data from the restored database to ElasticSearch and Redis

  1. Connect to OpenVPN.

  2. Open Jenkins web interface at http://jenkins.{environment_hostname}.

  3. Select New Item.

  4. For Enter an item name, enter a job name.

  5. Select Freestyle project.

  6. Select OK.

  7. In the Build section, select Add build step > Execute shell.

  8. In the Execute shell pane, for Command, enter the script with the vendor/bin/console sync:data command. You can add the command to the script from another Jenkins job in your environment.

  9. Select Save.

Set up a jenkins job

  1. On the page that opens, select Build Now.
    Give it a few minutes to execute the job. You can track the execution in the Build History pane.

You’ve re-synced data from a restored database to ElasticSearch and Redis.

Restore an application

Application restoration is part of a regular deployment workflow. See Rolling back an application to learn about restoring a previous version of an application.

Delete recovery points

To delete recovery steps via Terraform Cloud, follow the steps in the sections below.

Install AWS CLI and configure the session

  1. Install AWS CLI.

  2. Open a terminal.

  3. Export AWS credentials:

export AWS_ACCESS_KEY_ID=""
export AWS_SECRET_ACCESS_KEY=""
export AWS_SESSION_TOKEN=""
  1. Set the region you want to remove delete recovery points in:
aws configure set region {REGION_NAME}

Clone Terraform Cloud and delete recovery points

  1. Clone Terraform Cloud:
git clone git@github.com:spryker/tfcloud.git
  1. Delete recovery points:
/tfcloud/tools/scripts./backup_vault_clear.sh {ENVIRONMENT_NAME}_rds_backup

Next step