Backup AWS RDS mysql database peroidically with automatically.
Deploy Lambda and WatchLog Schedule by Serverless framework.
-
for local testing create ".env" based on "template.env" filling with real database information.
-
for AWS open serverless.yaml, update the environment section with your real database information.
- please make sure the "~/.aws/credentials" configured
npm install
# .env should configured with correct database connection information before executing local testing
npm run test:local
- the backup files expiration in days in serverless.yaml, change the ExpirationInDays under resources\Resources\Bucket\Properties\LifecycleConfiguration\Rules
- the schedule of cloud watch event in serverless.yaml, change the schedule under functions\main\events, such as rate(1 day) or rate (2 days)
- deploy to AWS China
npm run deploy2cn
- deploy to AWS Global
npm run deploy
-
error: database connect timeout
resolution: In the security attached to the RDS instance, modify an inbound rule for mysql/aurora (port 3306) and rather than adding it for an IP address add it for your lambda functions security group.
-
error: S3 read-only file system
resolution: save temporary file to /tmp folder in lambda.