Merge pull request #1301 from SkynetLabs/ivo/fix_backups_order
Backup MongoDB before CockroachDB
This commit is contained in:
commit
2f88d081e5
|
@ -27,26 +27,6 @@ fi
|
||||||
# Take the current datetime:
|
# Take the current datetime:
|
||||||
DT=$(date +%Y-%m-%d)
|
DT=$(date +%Y-%m-%d)
|
||||||
|
|
||||||
### COCKROACH DB ###
|
|
||||||
echo "Creating a backup of CockroachDB:"
|
|
||||||
# Check if a backup already exists:
|
|
||||||
totalFoundObjects=$(aws s3 ls $S3_BACKUP_PATH/$DT --recursive --summarize | grep "cockroach" | wc -l)
|
|
||||||
if [ "$totalFoundObjects" -ge "1" ]; then
|
|
||||||
echo "Backup already exists for today. Skipping."
|
|
||||||
else
|
|
||||||
# Create a cockroachdb backup:
|
|
||||||
docker exec cockroach \
|
|
||||||
cockroach sql \
|
|
||||||
--host cockroach:26257 \
|
|
||||||
--certs-dir=/certs \
|
|
||||||
--execute="BACKUP TO '$S3_BACKUP_PATH/$DT/cockroach/?AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID&AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY';"
|
|
||||||
if [[ $? > 0 ]]; then
|
|
||||||
echo "Creating a CockroachDB backup failed. Skipping."
|
|
||||||
else
|
|
||||||
echo "Successfully backed up CockroachDB."
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
### MONGO DB ###
|
### MONGO DB ###
|
||||||
echo "Creating a backup of MongoDB:"
|
echo "Creating a backup of MongoDB:"
|
||||||
# Check if a backup already exists:
|
# Check if a backup already exists:
|
||||||
|
@ -73,3 +53,23 @@ else
|
||||||
fi
|
fi
|
||||||
docker exec mongo rm -rf /data/db/backups/$DT
|
docker exec mongo rm -rf /data/db/backups/$DT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
### COCKROACH DB ###
|
||||||
|
echo "Creating a backup of CockroachDB:"
|
||||||
|
# Check if a backup already exists:
|
||||||
|
totalFoundObjects=$(aws s3 ls $S3_BACKUP_PATH/$DT --recursive --summarize | grep "cockroach" | wc -l)
|
||||||
|
if [ "$totalFoundObjects" -ge "1" ]; then
|
||||||
|
echo "Backup already exists for today. Skipping."
|
||||||
|
else
|
||||||
|
# Create a cockroachdb backup:
|
||||||
|
docker exec cockroach \
|
||||||
|
cockroach sql \
|
||||||
|
--host cockroach:26257 \
|
||||||
|
--certs-dir=/certs \
|
||||||
|
--execute="BACKUP TO '$S3_BACKUP_PATH/$DT/cockroach/?AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID&AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY';"
|
||||||
|
if [[ $? > 0 ]]; then
|
||||||
|
echo "Creating a CockroachDB backup failed. Skipping."
|
||||||
|
else
|
||||||
|
echo "Successfully backed up CockroachDB."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
Reference in New Issue