Backup MongoDB before CockroachDB because we can backfill user registrations in MongoDB but not in CockroachDB.
This commit is contained in:
parent
9dad4ee4bc
commit
96c634b6e7
|
@ -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