Skip to content

backup AWS RDS mysql database peroidically with automatically

Notifications You must be signed in to change notification settings

neoxie/backup-mysql

Repository files navigation

mysql backup utility

Backup AWS RDS mysql database peroidically with automatically.

Deploy Lambda and WatchLog Schedule by Serverless framework.

backup-mysql-arch

prerequisite

  • 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. serverless-environments

local test

  • 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

configure

  • 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)

deployment

  • deploy to AWS China
npm run deploy2cn
  • deploy to AWS Global
npm run deploy

issues and resolutions

  • 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.

reference links

About

backup AWS RDS mysql database peroidically with automatically

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published