2024-07-26 18:50:39 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
datetime=`date +%Y%m%d%H`
|
|
|
|
|
2024-07-29 19:08:15 +08:00
|
|
|
mkdir -p ~/.aws
|
|
|
|
|
|
|
|
echo -ne "[default]\naws_access_key_id = ${AWS_ACCESS_KEY}\naws_secret_access_key = ${AWS_SECRET_KEY}\n" > ~/.aws/credentials
|
|
|
|
|
2024-07-26 18:50:39 +08:00
|
|
|
dbs=($DATABASES)
|
|
|
|
|
|
|
|
for db in "${dbs[@]}"
|
|
|
|
do
|
2024-07-27 11:40:36 +08:00
|
|
|
mongodump --host ${HOST} --port ${PORT} --authenticationDatabase admin -u backup -p ${PASSWORD} --db $db --gzip --archive=${db}.tgz
|
2024-07-26 18:50:39 +08:00
|
|
|
if (($?==0));then
|
|
|
|
aws s3 cp ${db}.tgz s3://bfs-pkg-storage/mongodb/backup/${datetime}/
|
|
|
|
else
|
|
|
|
echo "Backup to failed"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
done
|