使用shell和aws cli自动备份RDS并发消息到SQS

#!/bin/bash

da=`date +%y%m%d`

su - oracle <<EON

#sh /RDSBackup/scripts/asdp-backup.sh &

for child in `ps -ef|grep "$$"|grep -v grep|grep -v "$PPID"|awk '{print $2}'`

do

wait $child

echo "process $child exited"

done

wait

echo "All backup is finished!!!"

EON

echo "$da"

aws s3 cp /RDSBackup/asdp_full_$da.dmp.zip s3://rds-database-backup/backup-all-for3y/asdp_full_$da.dmp.zip

rm -f /RDSBackup/*$da.dmp.gz

echo "Uploading file to S3 is finished!!!"

##### Send finished message to SQS ########

var=`ec2-metadata -i`

echo ${var:13}

aws sqs send-message --queue-url https://sqs.cn-north-1.amazonaws.com.cn/827768676943/rds-backup-terminate --message-body ${var:13} --delay-seconds 10

相关推荐