Database migrating exportimport scripts » History » Version 1
Anchi Cheng, 01/15/2021 05:37 PM
| 1 | 1 | Anchi Cheng | h1. Database migrating export/import scripts |
|---|---|---|---|
| 2 | |||
| 3 | h2. Move everything |
||
| 4 | When you need to move all your data in the database to a new computer, you can |
||
| 5 | |||
| 6 | Either |
||
| 7 | |||
| 8 | copy the all the database files over. See where in [[database file locations]] (This only works well if your new computer is identical in setup. |
||
| 9 | |||
| 10 | Or |
||
| 11 | |||
| 12 | # do a full [[Mysqldump_of_your_database|mysqldump]] which includes instruction on how to recreate it through mysql command and then |
||
| 13 | # [[Load_mysqldumped_databases|restore it]] |
||
| 14 | |||
| 15 | h2. Start fresh but keep the instruments/calibrations/settings even most recent gain/dark references and other tables that you really care. |
||
| 16 | |||
| 17 | As years goes by, the database gets too big to backup or congested with old instrument you no longer own or care. A few scripts were written to |
||
| 18 | make it possible to take a clean installation and migrate from the old system the stuff you need to care over. |
||
| 19 | |||
| 20 | These are in myami/dbschema/tools. These are not installed, so you do need a git clone myami to access it. |
||
| 21 | You need to know your sinedon.cfg of the system you migrate from and to. |
||
| 22 | |||
| 23 | h2. Step 1: On the old system, run these. source_database_hostname is what is in your sinedon.cfg |
||
| 24 | |||
| 25 | All output files except reference images are json files. The name format is used for parsing in the import. |
||
| 26 | |||
| 27 | h3. export_leginon_instruments.py |
||
| 28 | |||
| 29 | *Usage* export_leginon_instruments.py source_database_hostname <hostname1,hostname2> |
||
| 30 | (optional hostname1, hostname2 etc are specific instrument hostname to export. default will export all) |
||
| 31 | *Example* python export_leginon_instruments.py localhost Titan123456,GatanK3host |
||
| 32 | |||
| 33 | h3. export_leginon_cal.py |
||
| 34 | |||
| 35 | *Usage* export_leginon_cal.py source_database_hostname source_camera_hosthame camera_name <source_tem_name> |
||
| 36 | *Example* python export_leginon_cal.py localhost GatanK3host k3host EFKrios |
||
| 37 | |||
| 38 | h3. export_leginon_settings.py |
||
| 39 | |||
| 40 | This export settings used by a specific session, typically a session you know containing good settings to be used as default in your new system. |
||
| 41 | |||
| 42 | *Usage* python export_leginon_settings.py <sessionname> <optional partial application name> <optional node name prefix> |
||
| 43 | *Example* python 20dec31a |
||
| 44 | |||
| 45 | h3. export_leginon_presets.py |
||
| 46 | |||
| 47 | This export presets used by a specific session, typically the same session as above to be used as default in your new system. |
||
| 48 | |||
| 49 | *Usage* python export_leginon_presets.py <sessionname> <optional partial application name> <optional node name prefix> |
||
| 50 | *Example* python 20dec31a |
||
| 51 | |||
| 52 | |||
| 53 | h3. export_leginon_ref.py |
||
| 54 | |||
| 55 | *Usage* python export_leginon_ref.py source_database_hostname source_camera_hosthame camera_name |
||
| 56 | *Example* python export_leginon_ref.py localhost k3host GatanK3 |
||
| 57 | |||
| 58 | This script and its import counter part are also used as a regular backup to quickly recover from file server issue that require us to use a different file disk and avoid accessing the problem disk. |
||
| 59 | |||
| 60 | h2. Step two: copy the resulting json and mrc files to the new leginon host called new_host |
||
| 61 | |||
| 62 | h2. On the clean installation that has already administrator user and other default in the installation, run these imports |
||
| 63 | |||
| 64 | h3. import_leginon_instruments.py |
||
| 65 | |||
| 66 | *Usage* import_leginon_instruments.py database_hostname |
||
| 67 | *Example* python import_leginon_instruments.py new_host |
||
| 68 | |||
| 69 | h3. import_leginon_cal.py |
||
| 70 | |||
| 71 | *Usage* import_leginon_cal.py database_hostname camera_cal_json_file |
||
| 72 | *Example* python import_leginon_cal.py new_host cal_titan123456+EFKrios+gatank3host+GatanK3.json |
||
| 73 | |||
| 74 | h3. import_leginon_settings.py |
||
| 75 | |||
| 76 | *Usage* python import_leginon_settings.py <applicationname or json filepath> |
||
| 77 | *Example* python import_leginon_settings.py 20dec31a.json |
||
| 78 | |||
| 79 | h3. import_leginon_presets.py |
||
| 80 | |||
| 81 | *Usage* python import_leginon_presets.py database_hostname tem_camera_presets_json_file |
||
| 82 | *Example* python import_leginon_presets.py new_host preset_titan123456+EFKrios+gatank3host+GatanK3.json |
||
| 83 | |||
| 84 | h3. import_leginon_ref.py |
||
| 85 | |||
| 86 | *Usage* import_leginon_ref.py database_hostname camera_ref_json_file |
||
| 87 | *Example* python import_leginon_ref.py new_host ref_titan123456+EFKrios+gatank3host+GatanK3.json |