This script backups up a postgres db to S3. It sends any errors that occur to slack. Successful backups are logged in cloudwatch. DB credentials are retrieved from AWS secrets manager.
Use this cron to schedule the script to run every hour.
* * * * /usr/bin/python3 /path/to/script/script.py <app_name> <db_name> <slack webhook url> <secrets manager ARN> <s3 bucket name> <cloudwatch loggroup> <cloudwatch logstream>
These libraries need to be installed.
amazon-linux-extras install postgresql14
pip3 install urllib3
pip3 install boto3
AWS Permissions Needed
s3:PutObject
secretsmanager:GetSecretValue
logs:PutLogEvents
Top comments (0)