18 lines
385 B
Bash
18 lines
385 B
Bash
|
#!/bin/bash
|
||
|
|
||
|
datetime=`date +%Y%m%d%H`
|
||
|
|
||
|
dbs=($DATABASES)
|
||
|
|
||
|
for db in "${dbs[@]}"
|
||
|
do
|
||
|
mongodump --host ${HOST} --port ${PORT} --authenticationDatabase admin -u root -p ${PASSWORD} --db $db --gzip --archive=${db}.tgz
|
||
|
if (($?==0));then
|
||
|
aws s3 cp ${db}.tgz s3://bfs-pkg-storage/mongodb/backup/${datetime}/
|
||
|
else
|
||
|
echo "Backup to failed"
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
done
|