From fbe31a508d644740d841183cad8b5dd676648a8e Mon Sep 17 00:00:00 2001 From: m5r Date: Sun, 24 Oct 2021 18:37:41 +0200 Subject: [PATCH] fix db backups --- db/backup.ts | 12 ++++++++---- fly.dev.toml | 2 +- fly.prod.toml | 2 +- integrations/aws-s3.ts | 4 ++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/db/backup.ts b/db/backup.ts index 4820d48..35d3bd1 100644 --- a/db/backup.ts +++ b/db/backup.ts @@ -5,6 +5,9 @@ import { PassThrough } from "stream"; import { sendEmail } from "integrations/aws-ses"; import { s3 } from "integrations/aws-s3"; +import appLogger from "../integrations/logger"; + +const logger = appLogger.child({ module: "backup" }); export default async function backup(schedule: "daily" | "weekly" | "monthly") { const s3Bucket = `shellphone-${schedule}-backup`; @@ -61,13 +64,14 @@ export default async function backup(schedule: "daily" | "weekly" | "monthly") { uploadPromise .then(() => console.log(`Successfully uploaded "${fileName}"`)) - .catch((error) => - sendEmail({ + .catch((error) => { + logger.error(error); + return sendEmail({ body: `${schedule} backup failed: ${error}`, subject: `${schedule} backup failed: ${error}`, recipients: ["error@shellphone.app"], - }), - ); + }); + }); }); } diff --git a/fly.dev.toml b/fly.dev.toml index 29527b8..dbb67da 100644 --- a/fly.dev.toml +++ b/fly.dev.toml @@ -13,7 +13,7 @@ processes = [] [env] NODE_ENV = "production" - AWS_S3_REGION = "eu-west-3" + AWS_S3_REGION = "eu-central-1" AWS_SES_REGION = "eu-central-1" AWS_SES_FROM_EMAIL = """"Mokhtar from Shellphone" """ QUIRREL_API_URL = "https://queue.mokhtar.dev" diff --git a/fly.prod.toml b/fly.prod.toml index 0d05224..5050617 100644 --- a/fly.prod.toml +++ b/fly.prod.toml @@ -13,7 +13,7 @@ processes = [] [env] NODE_ENV = "production" - AWS_S3_REGION = "eu-west-3" + AWS_S3_REGION = "eu-central-1" AWS_SES_REGION = "eu-central-1" AWS_SES_FROM_EMAIL = """"Mokhtar from Shellphone" """ QUIRREL_API_URL = "https://queue.mokhtar.dev" diff --git a/integrations/aws-s3.ts b/integrations/aws-s3.ts index 15f8568..cae91e1 100644 --- a/integrations/aws-s3.ts +++ b/integrations/aws-s3.ts @@ -4,8 +4,8 @@ import { getConfig } from "blitz"; const { serverRuntimeConfig } = getConfig(); const credentials = new Credentials({ - accessKeyId: serverRuntimeConfig.awsSes.accessKeyId, - secretAccessKey: serverRuntimeConfig.awsSes.secretAccessKey, + accessKeyId: serverRuntimeConfig.awsS3.accessKeyId, + secretAccessKey: serverRuntimeConfig.awsS3.secretAccessKey, }); export const s3 = new S3({ region: serverRuntimeConfig.awsS3.region, credentials });