Database migrating exportimport scripts » History » Version 12
Anchi Cheng, 01/15/2021 06:04 PM
1 | 1 | Anchi Cheng | h1. Database migrating export/import scripts |
---|---|---|---|
2 | |||
3 | When you need to move all your data in the database to a new computer, you can |
||
4 | |||
5 | Either |
||
6 | |||
7 | 2 | Anchi Cheng | copy the all the database files over. See where in [[standard mysql database file locations]] (This only works well if your new computer is identical in setup. |
8 | 1 | Anchi Cheng | |
9 | Or |
||
10 | |||
11 | # do a full [[Mysqldump_of_your_database|mysqldump]] which includes instruction on how to recreate it through mysql command and then |
||
12 | 7 | Anchi Cheng | # [[Load_mysqldumped_databases|restore it]] on the new host |
13 | 1 | Anchi Cheng | |
14 | h2. Start fresh but keep the instruments/calibrations/settings even most recent gain/dark references and other tables that you really care. |
||
15 | |||
16 | 11 | Anchi Cheng | As years goes by, the databases get too big to backup or congested with old instrument and images you no longer own or care. A few scripts were written to |
17 | 1 | Anchi Cheng | make it possible to take a clean installation and migrate from the old system the stuff you need to care over. |
18 | 11 | Anchi Cheng | |
19 | 12 | Anchi Cheng | |what|export|import| |
20 | |tem,mag table, camera|export_leginon_instruments.py|import_leginon_instruments.py| |
||
21 | |calibrations|export_leginon_cal.py|import_leginon_cal.py| |
||
22 | |leginon settings|export_leginon_settings.py|import_leginon_settings.py| |
||
23 | |presets|export_leginon_presets.py|import_leginon_presets.py| |
||
24 | |gain/dark reference images|export_leginon_ref.py|import_leginonref.py| |
||
25 | |||
26 | 11 | Anchi Cheng | The old databases can be kept as archive that you can still view with its own myamiweb but no longer write to. |
27 | 1 | Anchi Cheng | |
28 | These are in myami/dbschema/tools. These are not installed, so you do need a git clone myami to access it. |
||
29 | You need to know your sinedon.cfg of the system you migrate from and to. |
||
30 | |||
31 | 5 | Anchi Cheng | h2. Step 1: Use mysqldump to migrate single tables (see above and mysql documentation on the internet) and restore them on the new host. |
32 | |||
33 | Here are the ones you might want: |
||
34 | 10 | Anchi Cheng | 1. all projectdb except the two tables projectexperiments and processingdb (You can dump/restore the whole database and then empty the data in these two tables). |
35 | 5 | Anchi Cheng | 2. leginondb tables GroupData and UserData |
36 | |||
37 | If you want all old applications, you can also dump/import ApplicationData. Otherwise, individual application import/export is easiest using myamiweb administration tab. |
||
38 | |||
39 | 9 | Anchi Cheng | h2. Step 2: On the old system, run these: |
40 | 1 | Anchi Cheng | |
41 | 9 | Anchi Cheng | source_database_hostname is what is in your sinedon.cfg |
42 | 1 | Anchi Cheng | All output files except reference images are json files. The name format is used for parsing in the import. |
43 | |||
44 | h3. export_leginon_instruments.py |
||
45 | |||
46 | *Usage* export_leginon_instruments.py source_database_hostname <hostname1,hostname2> |
||
47 | (optional hostname1, hostname2 etc are specific instrument hostname to export. default will export all) |
||
48 | *Example* python export_leginon_instruments.py localhost Titan123456,GatanK3host |
||
49 | |||
50 | h3. export_leginon_cal.py |
||
51 | |||
52 | *Usage* export_leginon_cal.py source_database_hostname source_camera_hosthame camera_name <source_tem_name> |
||
53 | *Example* python export_leginon_cal.py localhost GatanK3host k3host EFKrios |
||
54 | |||
55 | h3. export_leginon_settings.py |
||
56 | |||
57 | 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. |
||
58 | |||
59 | *Usage* python export_leginon_settings.py <sessionname> <optional partial application name> <optional node name prefix> |
||
60 | *Example* python 20dec31a |
||
61 | |||
62 | h3. export_leginon_presets.py |
||
63 | |||
64 | This export presets used by a specific session, typically the same session as above to be used as default in your new system. |
||
65 | |||
66 | *Usage* python export_leginon_presets.py <sessionname> <optional partial application name> <optional node name prefix> |
||
67 | *Example* python 20dec31a |
||
68 | |||
69 | |||
70 | h3. export_leginon_ref.py |
||
71 | |||
72 | *Usage* python export_leginon_ref.py source_database_hostname source_camera_hosthame camera_name |
||
73 | *Example* python export_leginon_ref.py localhost k3host GatanK3 |
||
74 | |||
75 | 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. |
||
76 | |||
77 | 6 | Anchi Cheng | h2. Step 3: copy the resulting json and mrc files to the new leginon host (called new_host in the examples) |
78 | 1 | Anchi Cheng | |
79 | 6 | Anchi Cheng | h2. Step 4: On the clean installation that has already administrator user and other default in the installation, run these imports |
80 | 1 | Anchi Cheng | |
81 | h3. import_leginon_instruments.py |
||
82 | |||
83 | *Usage* import_leginon_instruments.py database_hostname |
||
84 | *Example* python import_leginon_instruments.py new_host |
||
85 | |||
86 | h3. import_leginon_cal.py |
||
87 | |||
88 | *Usage* import_leginon_cal.py database_hostname camera_cal_json_file |
||
89 | *Example* python import_leginon_cal.py new_host cal_titan123456+EFKrios+gatank3host+GatanK3.json |
||
90 | |||
91 | h3. import_leginon_settings.py |
||
92 | |||
93 | *Usage* python import_leginon_settings.py <applicationname or json filepath> |
||
94 | *Example* python import_leginon_settings.py 20dec31a.json |
||
95 | |||
96 | h3. import_leginon_presets.py |
||
97 | |||
98 | *Usage* python import_leginon_presets.py database_hostname tem_camera_presets_json_file |
||
99 | *Example* python import_leginon_presets.py new_host preset_titan123456+EFKrios+gatank3host+GatanK3.json |
||
100 | |||
101 | h3. import_leginon_ref.py |
||
102 | |||
103 | *Usage* import_leginon_ref.py database_hostname camera_ref_json_file |
||
104 | *Example* python import_leginon_ref.py new_host ref_titan123456+EFKrios+gatank3host+GatanK3.json |