Importing a data snapshot: Difference between revisions

From OpenHatch wiki
Content added Content deleted
imported>Onceuponatimeforever
imported>Onceuponatimeforever
Line 26: Line 26:
Then, run the following command to update the database file mysite.db with the new data snapshot:
Then, run the following command to update the database file mysite.db with the new data snapshot:


python manage.py syncdb.
python manage.py syncdb


You can test that it worked by loading up your local people page and the live one. Do you have about the same number of people? Click on these things:
You can test that it worked by loading up your local people page and the live one. Do you have about the same number of people? Click on these things:

Revision as of 02:58, 25 August 2013

This is a page about improving or modifying OpenHatch.

We call that "Hacking OpenHatch," and there is a whole category of pages about that.

When you get your own instance of the OpenHatch code running, you'll discover you're missing the data that are on the main OpenHatch site. So we take periodic snapshots of the data on the main openhatch.org site.

Where you can find the snapshots

Privacy implications

We discuss some privacy implications in the privacy policy document. We do suggest people read the privacy policies when they make their accounts.

How to use a snapshot

To load a snapshot into your database, you can run this command from your local install.

Note: You must run python manage.py syncdb --noinput and python manage.py migrate before this will work. Read README.mkd to learn more about those commands. It should take less than one minute.

Once the snapshot file has been retrieved on your computer, load it (no need to uncompress the file):

python manage.py loaddata 2012-08-12.json.gz

You'll see output that looks something like this:

Installed 94858 object(s) from 1 fixture(s)

Then, run the following command to update the database file mysite.db with the new data snapshot:

 python manage.py syncdb

You can test that it worked by loading up your local people page and the live one. Do you have about the same number of people? Click on these things:

More about this

  • We go through some effort to remove private information before we publish user data in these snapshots. The code for that is in [https://github.com/openhatch/oh-

mainline/blob/master/mysite/customs/management/commands/snapshot_public_data.py].

  • We are now creating these snapshots once a day.
  • We don't snapshot every single table. If you find there's something that we don't publish that we should, do file a bug!
  • Known issue: If your MySQL database isn't set up for Unicode, you could get a warning/error like this: "Incorrect string value: '\xC8\x9B' for column 'first_name' at row 1". That issue can be fixed; just re-create your database as described in the README.mkd file. (If you need help, come find us on #openhatch.)
  • How it works, on the servers: On linode2.openhatch.org, a cron job wakes up daily and runs mysite/scripts/snapshot_then_push.sh