12 Restoring on Azure or AWS

Not yet validated by a test deployment.

  1. Restore the database to a new server, at the time you want, using the links above. On AWS, set the security and parameter groups as your original had them, including rds.force_ssl.

  2. Stop web and the worker, so nothing serves or runs against the restored data until step 4 has ended what it brought back.

    • AWS: set both services' desired count to zero.

    • Azure: minimum replicas of zero is not enough for web, because while its ingress is on, the next request from anyone starts a replica. Turn ingress off first. With ingress off and no custom scale rule, an app scales to zero and has no way to start itself:

      az containerapp ingress disable -g grc-rg -n grc-web
      az containerapp update -g grc-rg -n grc-web --min-replicas 0
      az containerapp update -g grc-rg -n grc-worker --min-replicas 0
      az containerapp revision list -g grc-rg -n grc-web --query "[].{name:name,active:properties.active,replicas:properties.replicas}" -o table
      az containerapp revision list -g grc-rg -n grc-worker --query "[].{name:name,active:properties.active,replicas:properties.replicas}" -o table
      

      Wait until every active revision of both apps shows no replicas, which can take some minutes after a scale change. Don't rely on az containerapp replica list, which looks at the latest revision unless you name another, and a scale change makes a new one.

  3. Point the owner's and application's URLs at the new server, and run migrate as a one-off. On Azure, change the values only in Key Vault or with az containerapp secret set. A secret change creates no revision, and a replica reads it when it starts. Don't use az containerapp update --set-env-vars here, because a new revision starts up against the restored data.

  4. Run restore:finish as a one-off, as in "After any restore", step 1.

  5. Bring back deleted files. Run the comparison in a one-off task or job: ./node_modules/.bin/tsx --tsconfig tsconfig.worker.json src/lib/jobs/storage-reconcile.ts. Each name it lists is the object's name in the store:

    • Azure: undelete the blob within the soft delete window.

    • AWS: remove the delete marker. Removing one takes its version ID, and the application's task role doesn't have that right, so run this as an administrator:

      aws s3api list-object-versions --bucket <attachments bucket> --prefix <name>
      aws s3api delete-object --bucket <attachments bucket> --key <name> --version-id <delete marker's id>
      
  6. Follow the rest of "After any restore". Bring web back where only you can reach it, and the worker last. On Azure, that means az containerapp ingress enable -g grc-rg -n grc-web --type internal --target-port 3000 and minimum replicas of 1, reached from inside the virtual network, then --type external when people return, and minimum replicas of 1 on the worker.

Delete the old server only after the new one has been accepted. Until then it still bills you, and it is your evidence.