Commit 222c43bd by John Jarvis

use s3 backups instead of mongodump

parent 6b0ecb32
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
- name: update the mongo config to use the new mongo dir - name: update the mongo config to use the new mongo dir
shell: > shell: >
sed -i 's#^dbpath=.*#dbpath=/mnt/mongodb#' /etc/mongodb.conf sed -i 's#^dbpath=.*#dbpath=/mnt/mongodb#' /etc/mongodb.conf
tags: update_mongo_data1 tags: update_mongo_data
- name: restart mongodb - name: restart mongodb
service: > service: >
...@@ -23,45 +23,67 @@ ...@@ -23,45 +23,67 @@
state=restarted state=restarted
tags: update_mongo_data tags: update_mongo_data
- name: Dump mongo data using the cloned dbs for forums - name: grab the most recent backup from s3 for forums
shell : >
/edx/bin/s3cmd ls s3://edx-mongohq/mongohq_backups/ | grep comment | sort | tail -1 | awk '{ print $4 }'
register: s3cmd_out_forum
tags: update_mongo_data
- name: grab the most recent backup from s3 for forums
shell : >
/edx/bin/s3cmd get {{ s3cmd_out_forum.stdout }}
chdir=/mnt
tags: update_mongo_data
- name: untar the s3 backup
shell: > shell: >
mongodump -d comments-prod-clone -u {{ CLONE_FORUM_USER }} -p {{ CLONE_FORUM_PASS }} -h {{ CLONE_FORUM_HOST }} --port {{ CLONE_FORUM_PORT }} -o /mnt/forum-dump -c {{ item }} tar zxf {{ s3cmd_out_forum.stdout }}
with_items: chdir=/mnt
- activities
- blocked_hash
- contents
- contents_tag_aggregation
- delayed_backend_mongoid_jobs
- results
- subscriptions
- users
tags: update_mongo_data tags: update_mongo_data
- name: Restore the mongo data for the forums
- name: grab the most recent backup from s3 for prod-edx
shell : >
/edx/bin/s3cmd ls s3://edx-mongohq/mongohq_backups/ | grep prod-edx | sort | tail -1 | awk '{ print $4 }'
register: s3cmd_out_modulestore
tags: update_mongo_data
- name: grab the most recent backup from s3 for prod-edx
shell : >
/edx/bin/s3cmd get {{ s3cmd_out_modulestore.stdout }}
chdir=/mnt
tags: update_mongo_data
- name: untar the s3 backup
shell: > shell: >
mongorestore --drop -d cs_comments_service /mnt/forum-dump/comments-prod-clone tar zxf {{ s3cmd_out_modulestore.stdout }}
chdir=/mnt
tags: update_mongo_data tags: update_mongo_data
- name: Dump mongo data using the cloned dbs for the modulestore - name: Restore the mongo data for the forums
shell: > shell: >
mongodump -d prod-edx-clone -u {{ CLONE_MODULESTORE_USER }} -p {{ CLONE_MODULESTORE_PASS }} -h {{ CLONE_MODULESTORE_HOST }} --port {{ CLONE_MODULESTORE_PORT }} -o /mnt/modulestore-dump -c {{ item }} mongorestore --drop -d cs_comments_service /mnt/comments-prod
with_items:
- modulestore
- fs.chunks
- fs.files
tags: update_mongo_data tags: update_mongo_data
- name: Restore the mongo data for the modulestore - name: Restore the mongo data for the modulestore
shell: > shell: >
mongorestore --drop -d edxapp /mnt/modulestore-dump/prod-edx-clone mongorestore --drop -d edxapp /mnt/prod-edx
tags: update_mongo_data tags: update_mongo_data
- name: Remove dump files # recreate users after the restore
shell: > - name: create a mongodb users
rm -rf {{ item }} mongodb_user: >
database={{ item.database }}
name={{ item.user }}
password={{ item.password }}
state=present
with_items: with_items:
- /mnt/forum-dump - user: cs_comments_service
- /mnt/modulestore-dump password: password
database: cs_comments_service
- user: exdapp
password: password
database: edxapp
# WARNING - calling lineinfile on a symlink # WARNING - calling lineinfile on a symlink
# will convert the symlink to a file! # will convert the symlink to a file!
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment