fix db backups
This commit is contained in:
parent
1d59a74002
commit
fbe31a508d
12
db/backup.ts
12
db/backup.ts
@ -5,6 +5,9 @@ import { PassThrough } from "stream";
|
|||||||
|
|
||||||
import { sendEmail } from "integrations/aws-ses";
|
import { sendEmail } from "integrations/aws-ses";
|
||||||
import { s3 } from "integrations/aws-s3";
|
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") {
|
export default async function backup(schedule: "daily" | "weekly" | "monthly") {
|
||||||
const s3Bucket = `shellphone-${schedule}-backup`;
|
const s3Bucket = `shellphone-${schedule}-backup`;
|
||||||
@ -61,13 +64,14 @@ export default async function backup(schedule: "daily" | "weekly" | "monthly") {
|
|||||||
|
|
||||||
uploadPromise
|
uploadPromise
|
||||||
.then(() => console.log(`Successfully uploaded "${fileName}"`))
|
.then(() => console.log(`Successfully uploaded "${fileName}"`))
|
||||||
.catch((error) =>
|
.catch((error) => {
|
||||||
sendEmail({
|
logger.error(error);
|
||||||
|
return sendEmail({
|
||||||
body: `${schedule} backup failed: ${error}`,
|
body: `${schedule} backup failed: ${error}`,
|
||||||
subject: `${schedule} backup failed: ${error}`,
|
subject: `${schedule} backup failed: ${error}`,
|
||||||
recipients: ["error@shellphone.app"],
|
recipients: ["error@shellphone.app"],
|
||||||
}),
|
});
|
||||||
);
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ processes = []
|
|||||||
|
|
||||||
[env]
|
[env]
|
||||||
NODE_ENV = "production"
|
NODE_ENV = "production"
|
||||||
AWS_S3_REGION = "eu-west-3"
|
AWS_S3_REGION = "eu-central-1"
|
||||||
AWS_SES_REGION = "eu-central-1"
|
AWS_SES_REGION = "eu-central-1"
|
||||||
AWS_SES_FROM_EMAIL = """"Mokhtar from Shellphone" <mokhtar@shellphone.app>"""
|
AWS_SES_FROM_EMAIL = """"Mokhtar from Shellphone" <mokhtar@shellphone.app>"""
|
||||||
QUIRREL_API_URL = "https://queue.mokhtar.dev"
|
QUIRREL_API_URL = "https://queue.mokhtar.dev"
|
||||||
|
@ -13,7 +13,7 @@ processes = []
|
|||||||
|
|
||||||
[env]
|
[env]
|
||||||
NODE_ENV = "production"
|
NODE_ENV = "production"
|
||||||
AWS_S3_REGION = "eu-west-3"
|
AWS_S3_REGION = "eu-central-1"
|
||||||
AWS_SES_REGION = "eu-central-1"
|
AWS_SES_REGION = "eu-central-1"
|
||||||
AWS_SES_FROM_EMAIL = """"Mokhtar from Shellphone" <mokhtar@shellphone.app>"""
|
AWS_SES_FROM_EMAIL = """"Mokhtar from Shellphone" <mokhtar@shellphone.app>"""
|
||||||
QUIRREL_API_URL = "https://queue.mokhtar.dev"
|
QUIRREL_API_URL = "https://queue.mokhtar.dev"
|
||||||
|
@ -4,8 +4,8 @@ import { getConfig } from "blitz";
|
|||||||
const { serverRuntimeConfig } = getConfig();
|
const { serverRuntimeConfig } = getConfig();
|
||||||
|
|
||||||
const credentials = new Credentials({
|
const credentials = new Credentials({
|
||||||
accessKeyId: serverRuntimeConfig.awsSes.accessKeyId,
|
accessKeyId: serverRuntimeConfig.awsS3.accessKeyId,
|
||||||
secretAccessKey: serverRuntimeConfig.awsSes.secretAccessKey,
|
secretAccessKey: serverRuntimeConfig.awsS3.secretAccessKey,
|
||||||
});
|
});
|
||||||
|
|
||||||
export const s3 = new S3({ region: serverRuntimeConfig.awsS3.region, credentials });
|
export const s3 = new S3({ region: serverRuntimeConfig.awsS3.region, credentials });
|
||||||
|
Loading…
Reference in New Issue
Block a user