1 |
702
|
aaronmk
|
Installation:
|
2 |
14747
|
aaronmk
|
open a terminal window
|
3 |
13764
|
aaronmk
|
Check out svn:
|
4 |
14742
|
aaronmk
|
sudo apt-get --yes install subversion # not preinstalled on Ubuntu
|
5 |
13764
|
aaronmk
|
svn co https://code.nceas.ucsb.edu/code/projects/bien/trunk bien
|
6 |
8458
|
aaronmk
|
cd bien/
|
7 |
14699
|
aaronmk
|
Install:
|
8 |
12226
|
aaronmk
|
**WARNING**: This will delete the public schema of your VegBIEN DB!
|
9 |
14902
|
aaronmk
|
# to install a complete DB with all the datasources:
|
10 |
|
|
$ make install all=1
|
11 |
|
|
# or, to install a blank DB:
|
12 |
|
|
$ make install
|
13 |
14743
|
aaronmk
|
# at "reload PATH" (if displayed), do what it says
|
14 |
14746
|
aaronmk
|
# at "Are you sure you want to continue connecting", type "yes" and
|
15 |
|
|
press Enter
|
16 |
14756
|
aaronmk
|
# at "aaronmk@jupiter's password", enter the applicable password
|
17 |
14699
|
aaronmk
|
# at "[sudo] password for user", enter your password and press Enter
|
18 |
|
|
# at "Modifying postgresql.conf and pg_hba.conf", type y and press Enter
|
19 |
|
|
# at "kernel.shmmax [...] Press ENTER to continue":
|
20 |
|
|
# open a new window
|
21 |
|
|
# run what it says
|
22 |
|
|
# press Ctrl-D
|
23 |
|
|
# return to the previous window
|
24 |
|
|
# press Enter
|
25 |
|
|
# at "restart PostgreSQL manually ... Press ENTER to continue":
|
26 |
|
|
# open a new window
|
27 |
|
|
# run what it says
|
28 |
|
|
# press Ctrl-D
|
29 |
|
|
# return to the previous window
|
30 |
|
|
# press Enter
|
31 |
|
|
# at "This will delete the current public schema of your VegBIEN DB",
|
32 |
|
|
type y and press Enter
|
33 |
14757
|
aaronmk
|
# at "If asked for MySQL root password", copy the password to the
|
34 |
|
|
clipboard and press Enter
|
35 |
|
|
# at "Web server to reconfigure automatically", select apache2 and click
|
36 |
|
|
Ok
|
37 |
|
|
# at "Configure database for phpmyadmin with dbconfig-common?", click
|
38 |
|
|
Yes
|
39 |
|
|
# at "Password of the database's administrative user", paste the
|
40 |
|
|
password and click Ok
|
41 |
|
|
# at "MySQL application password for phpmyadmin", just click Ok
|
42 |
|
|
# at "An error occurred while installing the database", click Ok
|
43 |
|
|
# at "Next step for database installation", select ignore and click Ok
|
44 |
14758
|
aaronmk
|
# at "aaronmk@jupiter's password", enter the applicable password
|
45 |
8458
|
aaronmk
|
Uninstall: make uninstall
|
46 |
12226
|
aaronmk
|
**WARNING**: This will delete your entire VegBIEN DB!
|
47 |
8458
|
aaronmk
|
This includes all archived imports and staging tables.
|
48 |
554
|
aaronmk
|
|
49 |
11515
|
aaronmk
|
Connecting to vegbiendev:
|
50 |
13284
|
aaronmk
|
ssh -t vegbiendev.nceas.ucsb.edu exec sudo -u aaronmk -i
|
51 |
13763
|
aaronmk
|
cd /home/bien # should happen automatically at login
|
52 |
11515
|
aaronmk
|
|
53 |
14651
|
aaronmk
|
Single datasource refresh:
|
54 |
14653
|
aaronmk
|
ssh -t vegbiendev.nceas.ucsb.edu exec sudo -u aaronmk -i
|
55 |
14651
|
aaronmk
|
# -> Maintenance > to back up the vegbiendev databases
|
56 |
14787
|
aaronmk
|
# place updated extract in inputs/$datasrc/_src/
|
57 |
14654
|
aaronmk
|
# place extracted flat file(s) in the appropriate table subdirs
|
58 |
14651
|
aaronmk
|
rm=1 inputs/<datasrc>/run # reload staging tables
|
59 |
|
|
make inputs/<datasrc>/reimport_scrub by_col=1 &
|
60 |
|
|
# this works whether or not datasource is already imported
|
61 |
14652
|
aaronmk
|
tail -150 inputs/<datasrc>/*/logs/public.log.sql # view progress
|
62 |
14651
|
aaronmk
|
# -> Full database import > To re-run geoscrubbing
|
63 |
|
|
# -> Full database import > To remake analytical DB
|
64 |
14791
|
aaronmk
|
# -> Full database import > To back up DB
|
65 |
14651
|
aaronmk
|
# -> Maintenance > to back up the vegbiendev databases
|
66 |
|
|
|
67 |
14788
|
aaronmk
|
datasource removal:
|
68 |
|
|
ssh -t vegbiendev.nceas.ucsb.edu exec sudo -u aaronmk -i
|
69 |
14868
|
aaronmk
|
$ make inputs/$datasrc/rm # runtime: see
|
70 |
|
|
# http://vegpath.org/wiki/Individual_datasource_refresh#datasource-removal-runtimes
|
71 |
14788
|
aaronmk
|
|
72 |
13024
|
aaronmk
|
Notes on system stability:
|
73 |
14091
|
aaronmk
|
**WARNING**: when shutting down the VM, always first stop Postgres:
|
74 |
|
|
sudo service postgresql stop
|
75 |
|
|
this prevents the OS from SIGKILLing Postgres, which sometimes causes
|
76 |
|
|
database corruption
|
77 |
13024
|
aaronmk
|
|
78 |
12011
|
aaronmk
|
Notes on running programs:
|
79 |
|
|
**WARNING**: always start with a clean shell, to avoid spurious bugs. the
|
80 |
|
|
shell should not have changes to the env vars. (there have been bugs
|
81 |
|
|
that went away after closing and reopening the terminal window.) note
|
82 |
|
|
that running `exec bash` is not sufficient to *reset* the env vars.
|
83 |
|
|
|
84 |
11967
|
aaronmk
|
Notes on editing files:
|
85 |
|
|
**WARNING**: shell scripts should always be read-only, so that editing them
|
86 |
|
|
while an import is in progress will not crash the import (see
|
87 |
|
|
http://vegpath.org/links/#**%20modifying%20a%20running%20shell%20script)
|
88 |
|
|
|
89 |
7287
|
aaronmk
|
Full database import:
|
90 |
12226
|
aaronmk
|
**WARNING**: You must perform *every single* step listed below, to avoid
|
91 |
9499
|
aaronmk
|
breaking column-based import
|
92 |
12011
|
aaronmk
|
**WARNING**: always start with a clean shell, as described above under
|
93 |
|
|
"Notes on running programs"
|
94 |
13021
|
aaronmk
|
**IMPORTANT**: the beginning of the import should be scheduled at a time
|
95 |
|
|
when the DB will not be needed for other uses. this is necessary because
|
96 |
|
|
vegbiendev will be slow for the first few hours of the import, due to
|
97 |
|
|
the import using all the available cores.
|
98 |
13000
|
aaronmk
|
do steps under Maintenance > "to synchronize vegbiendev, jupiter, and
|
99 |
|
|
your local machine"
|
100 |
8458
|
aaronmk
|
On local machine:
|
101 |
|
|
make inputs/upload
|
102 |
10025
|
aaronmk
|
make inputs/upload live=1
|
103 |
14077
|
aaronmk
|
make test by_col=1 # runtime: 1 h ("53m7.383s") @starscream
|
104 |
10549
|
aaronmk
|
if you encounter errors, they are most likely related to the
|
105 |
|
|
PostgreSQL error parsing in /lib/sql.py parse_exception()
|
106 |
8458
|
aaronmk
|
See note under Testing below
|
107 |
14887
|
aaronmk
|
-> Maintenance > to back up the vegbiendev databases > back up Postgres
|
108 |
13284
|
aaronmk
|
ssh -t vegbiendev.nceas.ucsb.edu exec sudo -u aaronmk -i
|
109 |
8458
|
aaronmk
|
Ensure there are no local modifications: svn st
|
110 |
12998
|
aaronmk
|
up
|
111 |
8458
|
aaronmk
|
make inputs/download
|
112 |
10025
|
aaronmk
|
make inputs/download live=1
|
113 |
8458
|
aaronmk
|
For each newly-uploaded datasource above: make inputs/<datasrc>/reinstall
|
114 |
|
|
Update the auxiliary schemas: make schemas/reinstall
|
115 |
12226
|
aaronmk
|
**WARNING**: requires sudo access!
|
116 |
8458
|
aaronmk
|
The public schema will be installed separately by the import process
|
117 |
|
|
Delete imports before the last so they won't bloat the full DB backup:
|
118 |
|
|
make backups/vegbien.<version>.backup/remove
|
119 |
|
|
To keep a previous import other than the public schema:
|
120 |
|
|
export dump_opts='--exclude-schema=public --exclude-schema=<version>'
|
121 |
13009
|
aaronmk
|
# env var will be inherited by `screen` shell
|
122 |
13016
|
aaronmk
|
restart Postgres to free up any disk space used by temp tables from the last
|
123 |
|
|
import (this is apparently not automatically reclaimed):
|
124 |
|
|
make postgres_restart
|
125 |
13022
|
aaronmk
|
Make sure there is at least 1 TB of disk space on /: df -h
|
126 |
|
|
although the import schema itself is only 315 GB, Postgres uses
|
127 |
13023
|
aaronmk
|
significant temporary space at the beginning of the import.
|
128 |
13028
|
aaronmk
|
the total disk usage oscillates between 1.2 TB and the entire disk
|
129 |
|
|
for the first day (for import started @12:55:09, high-water marks of
|
130 |
13031
|
aaronmk
|
1.7 TB @14:00:25, 1.8 TB @15:38:32; then next day w/ 2 datasources
|
131 |
|
|
running: entire disk for 4 min @05:35:44, 1.8 TB @11:15:05).
|
132 |
8458
|
aaronmk
|
To free up space, remove backups that have been archived on jupiter:
|
133 |
|
|
List backups/ to view older backups
|
134 |
|
|
Check their MD5 sums using the steps under On jupiter below
|
135 |
|
|
Remove these backups
|
136 |
14895
|
aaronmk
|
unlock hardlinked files:
|
137 |
|
|
$ chmod ug+w inputs/{.[^as.],}*/*/{map.csv,new_terms.csv,unmapped_terms.csv}
|
138 |
13423
|
aaronmk
|
for full import:
|
139 |
|
|
screen
|
140 |
|
|
Press ENTER
|
141 |
14893
|
aaronmk
|
unset TMOUT # TMOUT causes shell to exit even with background processes
|
142 |
14087
|
aaronmk
|
$0 # nested shell to prevent errexit from closing the window
|
143 |
13422
|
aaronmk
|
the following must happen within screen to avoid affecting the outer shell:
|
144 |
13428
|
aaronmk
|
unset TMOUT # TMOUT causes shell to exit even with background processes
|
145 |
|
|
set -o ignoreeof # prevent Ctrl+D from exiting shell to keep attached jobs
|
146 |
13426
|
aaronmk
|
on local machine:
|
147 |
|
|
unset n # clear any limit set in .profile (unless desired)
|
148 |
|
|
unset log # allow logging output to go to log files
|
149 |
13424
|
aaronmk
|
unset version # clear any version from last import, etc.
|
150 |
|
|
if no commits have been made since the last import (eg. if retrying an
|
151 |
|
|
import), set a custom version that differs from the auto-assigned one
|
152 |
|
|
(would otherwise cause a collision with the last import):
|
153 |
|
|
svn info
|
154 |
|
|
extract the svn revision after "Revision:"
|
155 |
|
|
export version=r[revision]_2 # +suffix to distinguish from last import
|
156 |
|
|
# env var will be inherited by `screen` shell
|
157 |
13119
|
aaronmk
|
to import just a subset of the datasources:
|
158 |
13427
|
aaronmk
|
declare -ax inputs; inputs=(inputs/{src,...}/) # no () in declare on Mac
|
159 |
13119
|
aaronmk
|
# array vars *not* inherited by `screen` shell
|
160 |
|
|
export version=custom_import_name
|
161 |
10579
|
aaronmk
|
Start column-based import: . bin/import_all
|
162 |
|
|
To use row-based import: . bin/import_all by_col=
|
163 |
8458
|
aaronmk
|
To stop all running imports: . bin/stop_imports
|
164 |
12226
|
aaronmk
|
**WARNING**: Do NOT run import_all in the background, or the jobs it
|
165 |
|
|
creates won't be owned by your shell.
|
166 |
8458
|
aaronmk
|
Note that import_all will take up to an hour to import the NCBI backbone
|
167 |
|
|
and other metadata before returning control to the shell.
|
168 |
12026
|
aaronmk
|
To view progress:
|
169 |
14882
|
aaronmk
|
tail inputs/{.[^as.],}*/*/logs/$version.log.sql
|
170 |
13020
|
aaronmk
|
note: at the beginning of the import, the system may send out CPU load
|
171 |
|
|
warning e-mails. these can safely be ignored. (they happen because the
|
172 |
|
|
parallel imports use all the available cores.)
|
173 |
13425
|
aaronmk
|
for test import, turn off DB backup (also turns off analytical DB creation):
|
174 |
13429
|
aaronmk
|
kill % # cancel after_import()
|
175 |
10850
|
aaronmk
|
Wait (4 days) for the import to finish
|
176 |
14197
|
aaronmk
|
**WARNING**: do *not* run backups/pg_snapshot while the import is running,
|
177 |
|
|
due to continuously-changing files
|
178 |
|
|
**WARNING**: do *not* run backups/pg_snapshot until the previous import has
|
179 |
|
|
been replaced, to avoid running into disk space limits
|
180 |
8458
|
aaronmk
|
To recover from a closed terminal window: screen -r
|
181 |
10583
|
aaronmk
|
To restart an aborted import for a specific table:
|
182 |
|
|
export version=<version>
|
183 |
11800
|
aaronmk
|
(set -o errexit; make inputs/<datasrc>/<table>/import_scrub by_col=1 continue=1; make inputs/<datasrc>/publish) &
|
184 |
10588
|
aaronmk
|
bin/after_import $! & # $! can also be obtained from `jobs -l`
|
185 |
8458
|
aaronmk
|
Get $version: echo $version
|
186 |
|
|
Set $version in all vegbiendev terminals: export version=<version>
|
187 |
13017
|
aaronmk
|
When there are no more running jobs, exit `screen`: exit # not Ctrl+D
|
188 |
13025
|
aaronmk
|
upload logs: make inputs/upload live=1
|
189 |
10025
|
aaronmk
|
On local machine: make inputs/download-logs live=1
|
190 |
13030
|
aaronmk
|
check for disk space errors:
|
191 |
14882
|
aaronmk
|
grep --files-with-matches -F 'No space left on device' inputs/{.[^as.],}*/*/logs/$version.log.sql
|
192 |
13030
|
aaronmk
|
if there are any matches:
|
193 |
|
|
manually reimport these datasources using the steps under
|
194 |
|
|
Single datasource import
|
195 |
|
|
bin/after_import &
|
196 |
|
|
wait for the import to finish
|
197 |
14882
|
aaronmk
|
tail inputs/{.[^as.],}*/*/logs/$version.log.sql
|
198 |
13029
|
aaronmk
|
In the output, search for "Command exited with non-zero status"
|
199 |
|
|
For inputs that have this, fix the associated bug(s)
|
200 |
|
|
If many inputs have errors, discard the current (partial) import:
|
201 |
|
|
make schemas/$version/uninstall
|
202 |
|
|
Otherwise, continue
|
203 |
8458
|
aaronmk
|
In PostgreSQL:
|
204 |
11568
|
aaronmk
|
Go to wiki.vegpath.org/VegBIEN_contents
|
205 |
11728
|
aaronmk
|
Get the # observations
|
206 |
|
|
Get the # datasources
|
207 |
|
|
Get the # datasources with observations
|
208 |
11892
|
aaronmk
|
in the r# schema:
|
209 |
14940
|
aaronmk
|
Check that view_full_occurrence_individual contains [# observations] rows
|
210 |
14939
|
aaronmk
|
Check that source contains the following datasources (note that
|
211 |
|
|
refreshed datasources will be at the end):
|
212 |
|
|
geoscrub herbaria IRMNG IUCN NCBI newWorld TNRS ACAD ARIZ bien_web
|
213 |
|
|
BRIT CTFS GBIF HIBG JBM Madidi MO MT NCU NVS NY QFA REMIB
|
214 |
|
|
SpeciesLink TEAM test_taxonomic_names TRT TRTE U UBC UNCC VASCAN WIN
|
215 |
|
|
XAL
|
216 |
11568
|
aaronmk
|
Check that provider_count contains [# datasources with observations]
|
217 |
|
|
rows with dataset="(total)" (at the top when the table is unsorted)
|
218 |
9492
|
aaronmk
|
Check that TNRS ran successfully:
|
219 |
|
|
tail -100 inputs/.TNRS/tnrs/logs/tnrs.make.log.sql
|
220 |
|
|
If the log ends in an AssertionError
|
221 |
|
|
"assert sql.table_col_names(db, table) == header":
|
222 |
|
|
Figure out which TNRS CSV columns have changed
|
223 |
|
|
On local machine:
|
224 |
10784
|
aaronmk
|
Make the changes in the DB's TNRS and public schemas
|
225 |
|
|
rm=1 inputs/.TNRS/schema.sql.run export_
|
226 |
9492
|
aaronmk
|
make schemas/remake
|
227 |
10785
|
aaronmk
|
inputs/test_taxonomic_names/test_scrub # re-run TNRS
|
228 |
10784
|
aaronmk
|
rm=1 inputs/.TNRS/data.sql.run export_
|
229 |
9492
|
aaronmk
|
Commit
|
230 |
13284
|
aaronmk
|
ssh -t vegbiendev.nceas.ucsb.edu exec sudo -u aaronmk -i
|
231 |
9492
|
aaronmk
|
If dropping a column, save the dependent views
|
232 |
|
|
Make the same changes in the live TNRS.tnrs table on vegbiendev
|
233 |
|
|
If dropping a column, recreate the dependent views
|
234 |
|
|
Restart the TNRS client: make scrub by_col=1 &
|
235 |
9498
|
aaronmk
|
Publish the new import:
|
236 |
12226
|
aaronmk
|
**WARNING**: Before proceeding, be sure you have done *every single*
|
237 |
9498
|
aaronmk
|
verification step listed above. Otherwise, a previous valid import
|
238 |
|
|
could incorrectly be overwritten with a broken one.
|
239 |
10864
|
aaronmk
|
make schemas/$version/publish # runtime: 1 min ("real 1m10.451s")
|
240 |
8458
|
aaronmk
|
unset version
|
241 |
10027
|
aaronmk
|
make backups/upload live=1
|
242 |
11897
|
aaronmk
|
on local machine:
|
243 |
|
|
make backups/vegbien.$version.backup/download live=1
|
244 |
|
|
# download backup to local machine
|
245 |
12396
|
aaronmk
|
ssh aaronmk@jupiter.nceas.ucsb.edu
|
246 |
8458
|
aaronmk
|
cd /data/dev/aaronmk/bien/backups
|
247 |
|
|
For each newly-archived backup:
|
248 |
|
|
make -s <backup>.md5/test
|
249 |
|
|
Check that "OK" is printed next to the filename
|
250 |
|
|
If desired, record the import times in inputs/import.stats.xls:
|
251 |
11573
|
aaronmk
|
On local machine:
|
252 |
8458
|
aaronmk
|
Open inputs/import.stats.xls
|
253 |
14878
|
aaronmk
|
click the "current" tab
|
254 |
8458
|
aaronmk
|
If the rightmost import is within 5 columns of column IV:
|
255 |
|
|
Copy the current tab to <leftmost-date>~<rightmost-date>
|
256 |
|
|
Remove the previous imports from the current tab because they are
|
257 |
|
|
now in the copied tab instead
|
258 |
|
|
Insert a copy of the leftmost "By column" column group before it
|
259 |
|
|
export version=<version>
|
260 |
14882
|
aaronmk
|
bin/import_date inputs/{.[^as.],}*/*/logs/$version.log.sql
|
261 |
8458
|
aaronmk
|
Update the import date in the upper-right corner
|
262 |
14882
|
aaronmk
|
bin/import_times inputs/{.[^as.],}*/*/logs/$version.log.sql
|
263 |
8458
|
aaronmk
|
Paste the output over the # Rows/Time columns, making sure that the
|
264 |
|
|
row counts match up with the previous import's row counts
|
265 |
|
|
If the row counts do not match up, insert or reorder rows as needed
|
266 |
|
|
until they do. Get the datasource names from the log file footers:
|
267 |
14882
|
aaronmk
|
tail inputs/{.[^as.],}*/*/logs/$version.log.sql
|
268 |
14883
|
aaronmk
|
update the Postprocessing times:
|
269 |
|
|
analytical DB remake time:
|
270 |
|
|
from the end of inputs/analytical_db/logs/make_analytical_db.log.sql,
|
271 |
|
|
search upwards for "_individual_view_modify" followed by a
|
272 |
|
|
line of -'s
|
273 |
|
|
enter as: =[ms]/1000/3600/24
|
274 |
11573
|
aaronmk
|
Commit: svn ci -m 'inputs/import.stats.xls: updated import times'
|
275 |
10885
|
aaronmk
|
Running individual steps separately:
|
276 |
9497
|
aaronmk
|
To run TNRS:
|
277 |
9996
|
aaronmk
|
To use an import other than public: export version=<version>
|
278 |
13594
|
aaronmk
|
to rescrub all names:
|
279 |
|
|
make inputs/.TNRS/reinstall
|
280 |
|
|
re-create public-schema views that were cascadingly deleted
|
281 |
9995
|
aaronmk
|
make scrub &
|
282 |
8458
|
aaronmk
|
To view progress:
|
283 |
|
|
tail -100 inputs/.TNRS/tnrs/logs/tnrs.make.log.sql
|
284 |
14447
|
aaronmk
|
To re-run geoscrubbing:
|
285 |
|
|
$ screen
|
286 |
14871
|
aaronmk
|
# press Enter
|
287 |
14802
|
aaronmk
|
$ unset TMOUT # TMOUT causes shell to exit even with background processes
|
288 |
14530
|
aaronmk
|
# to use an import other than public: $ export version=<version>
|
289 |
|
|
$ bin/psql_verbose_vegbien <<<'SELECT geoscrub_input_view_modify();' &
|
290 |
14877
|
aaronmk
|
# runtime: 6 min ("6:02.30") @r14827 @vegbiendev
|
291 |
14531
|
aaronmk
|
# wait until done
|
292 |
14536
|
aaronmk
|
$ rm=1 exports/geoscrub_input.csv.run
|
293 |
14877
|
aaronmk
|
# runtime: 1 min ("1m2.962s") @r14827 @vegbiendev
|
294 |
14792
|
aaronmk
|
$ $0 # subshell to avoid closing screen on errexit
|
295 |
14447
|
aaronmk
|
$ rm=1 inputs/.geoscrub/geoscrub_output/geoscrub.csv.run &
|
296 |
14877
|
aaronmk
|
# runtime: 1.5 h ("84m55.408s") @r14827 @vegbiendev
|
297 |
14447
|
aaronmk
|
# wait until done
|
298 |
14798
|
aaronmk
|
$ rm=1 inputs/.geoscrub/geoscrub_output/run &
|
299 |
14877
|
aaronmk
|
# runtime: 12 min ("11m35.693s") @r14827 @vegbiendev
|
300 |
14447
|
aaronmk
|
# wait until done
|
301 |
14824
|
aaronmk
|
# re-create public-schema views that were cascadingly deleted (currently
|
302 |
|
|
plot.**, view_full_occurrence_individual_view, geoscrub_input_new)
|
303 |
14447
|
aaronmk
|
# press Ctrl+D
|
304 |
|
|
# remake the analytical DB (below)
|
305 |
9497
|
aaronmk
|
To remake analytical DB:
|
306 |
9996
|
aaronmk
|
To use an import other than public: export version=<version>
|
307 |
11089
|
aaronmk
|
bin/make_analytical_db & # runtime: 13 h ("12:43:57elapsed")
|
308 |
8458
|
aaronmk
|
To view progress:
|
309 |
10600
|
aaronmk
|
tail -150 inputs/analytical_db/logs/make_analytical_db.log.sql
|
310 |
8458
|
aaronmk
|
To back up DB (staging tables and last import):
|
311 |
10578
|
aaronmk
|
To use an import *other than public*: export version=<version>
|
312 |
10743
|
aaronmk
|
make backups/TNRS.backup-remake &
|
313 |
10577
|
aaronmk
|
dump_opts=--exclude-schema=public make backups/vegbien.$version.backup/test &
|
314 |
10578
|
aaronmk
|
If after renaming to public, instead set dump_opts='' and replace
|
315 |
|
|
$version with the appropriate revision
|
316 |
10744
|
aaronmk
|
make backups/upload live=1
|
317 |
3381
|
aaronmk
|
|
318 |
1773
|
aaronmk
|
Datasource setup:
|
319 |
11516
|
aaronmk
|
On local machine:
|
320 |
11090
|
aaronmk
|
Example steps for a datasource: wiki.vegpath.org/Import_process_for_Madidi
|
321 |
8469
|
aaronmk
|
umask ug=rwx,o= # prevent files from becoming web-accessible
|
322 |
8458
|
aaronmk
|
Add a new datasource: make inputs/<datasrc>/add
|
323 |
|
|
<datasrc> may not contain spaces, and should be abbreviated.
|
324 |
|
|
If the datasource is a herbarium, <datasrc> should be the herbarium code
|
325 |
|
|
as defined by the Index Herbariorum <http://sweetgum.nybg.org/ih/>
|
326 |
11018
|
aaronmk
|
For a new-style datasource (one containing a ./run runscript):
|
327 |
11019
|
aaronmk
|
"cp" -f inputs/.NCBI/{Makefile,run,table.run} inputs/<datasrc>/
|
328 |
8458
|
aaronmk
|
For MySQL inputs (exports and live DB connections):
|
329 |
|
|
For .sql exports:
|
330 |
|
|
Place the original .sql file in _src/ (*not* in _MySQL/)
|
331 |
|
|
Follow the steps starting with Install the staging tables below.
|
332 |
|
|
This is for an initial sync to get the file onto vegbiendev.
|
333 |
13284
|
aaronmk
|
ssh -t vegbiendev.nceas.ucsb.edu exec sudo -u aaronmk -i
|
334 |
8458
|
aaronmk
|
Create a database for the MySQL export in phpMyAdmin
|
335 |
9494
|
aaronmk
|
Give the bien user all database-specific privileges *except*
|
336 |
|
|
UPDATE, DELETE, ALTER, DROP. This prevents bugs in the
|
337 |
|
|
import scripts from accidentally deleting data.
|
338 |
8458
|
aaronmk
|
bin/mysql_bien database <inputs/<datasrc>/_src/export.sql &
|
339 |
|
|
mkdir inputs/<datasrc>/_MySQL/
|
340 |
|
|
cp -p lib/MySQL.{data,schema}.sql.make inputs/<datasrc>/_MySQL/
|
341 |
|
|
Edit _MySQL/*.make for the DB connection
|
342 |
|
|
For a .sql export, use server=vegbiendev and --user=bien
|
343 |
|
|
Skip the Add input data for each table section
|
344 |
|
|
For MS Access databases:
|
345 |
|
|
Place the .mdb or .accdb file in _src/
|
346 |
14661
|
aaronmk
|
Download and install Bullzip's MS Access to PostgreSQL from
|
347 |
|
|
http://bullzip.com/download.php > Access To PostgreSQL > Download
|
348 |
8458
|
aaronmk
|
Use Access To PostgreSQL to export the database:
|
349 |
|
|
Export just the tables/indexes to inputs/<datasrc>/<file>.schema.sql
|
350 |
14662
|
aaronmk
|
using the settings in the associated .ini file where available
|
351 |
|
|
Export just the data to inputs/<datasrc>/<file>.data.sql using the
|
352 |
|
|
settings in the associated .ini file where available
|
353 |
8458
|
aaronmk
|
In <file>.schema.sql, make the following changes:
|
354 |
14813
|
aaronmk
|
Replace text "^CREATE DATABASE .*?;$" with "/*$0*/"
|
355 |
8458
|
aaronmk
|
Replace text "BOOLEAN" with "/*BOOLEAN*/INTEGER"
|
356 |
|
|
Replace text "DOUBLE PRECISION NULL" with "DOUBLE PRECISION"
|
357 |
|
|
Skip the Add input data for each table section
|
358 |
|
|
Add input data for each table present in the datasource:
|
359 |
|
|
For .sql exports, you must use the name of the table in the DB export
|
360 |
|
|
For CSV files, you can use any name. It's recommended to use a table
|
361 |
|
|
name from <https://projects.nceas.ucsb.edu/nceas/projects/bien/wiki/VegCSV#Suggested-table-names>
|
362 |
|
|
Note that if this table will be joined together with another table, its
|
363 |
|
|
name must end in ".src"
|
364 |
|
|
make inputs/<datasrc>/<table>/add
|
365 |
|
|
Important: DO NOT just create an empty directory named <table>!
|
366 |
|
|
This command also creates necessary subdirs, such as logs/.
|
367 |
|
|
If the table is in a .sql export: make inputs/<datasrc>/<table>/install
|
368 |
|
|
Otherwise, place the CSV(s) for the table in
|
369 |
|
|
inputs/<datasrc>/<table>/ OR place a query joining other tables
|
370 |
|
|
together in inputs/<datasrc>/<table>/create.sql
|
371 |
|
|
Important: When exporting relational databases to CSVs, you MUST ensure
|
372 |
|
|
that embedded quotes are escaped by doubling them, *not* by
|
373 |
|
|
preceding them with a "\" as is the default in phpMyAdmin
|
374 |
|
|
If there are multiple part files for a table, and the header is repeated
|
375 |
|
|
in each part, make sure each header is EXACTLY the same.
|
376 |
8466
|
aaronmk
|
(If the headers are not the same, the CSV concatenation script
|
377 |
|
|
assumes the part files don't have individual headers and treats the
|
378 |
|
|
subsequent headers as data rows.)
|
379 |
8458
|
aaronmk
|
Add <table> to inputs/<datasrc>/import_order.txt before other tables
|
380 |
|
|
that depend on it
|
381 |
11018
|
aaronmk
|
For a new-style datasource:
|
382 |
|
|
"cp" -f inputs/.NCBI/nodes/run inputs/<datasrc>/<table>/
|
383 |
|
|
inputs/<datasrc>/<table>/run
|
384 |
8458
|
aaronmk
|
Install the staging tables:
|
385 |
|
|
make inputs/<datasrc>/reinstall quiet=1 &
|
386 |
|
|
For a MySQL .sql export:
|
387 |
|
|
At prompt "[you]@vegbiendev's password:", enter your password
|
388 |
|
|
At prompt "Enter password:", enter the value in config/bien_password
|
389 |
|
|
To view progress: tail -f inputs/<datasrc>/<table>/logs/install.log.sql
|
390 |
|
|
View the logs: tail -n +1 inputs/<datasrc>/*/logs/install.log.sql
|
391 |
|
|
tail provides a header line with the filename
|
392 |
|
|
+1 starts at the first line, to show the whole file
|
393 |
|
|
For every file with an error 'column "..." specified more than once':
|
394 |
|
|
Add a header override file "+header.<ext>" in <table>/:
|
395 |
|
|
Note: The leading "+" should sort it before the flat files.
|
396 |
|
|
"_" unfortunately sorts *after* capital letters in ASCII.
|
397 |
|
|
Create a text file containing the header line of the flat files
|
398 |
|
|
Add an ! at the beginning of the line
|
399 |
|
|
This signals cat_csv that this is a header override.
|
400 |
|
|
For empty names, use their 0-based column # (by convention)
|
401 |
|
|
For duplicate names, add a distinguishing suffix
|
402 |
|
|
For long names that collided, rename them to <= 63 chars long
|
403 |
|
|
Do NOT make readability changes in this step; that is what the
|
404 |
|
|
map spreadsheets (below) are for.
|
405 |
|
|
Save
|
406 |
|
|
If you made any changes, re-run the install command above
|
407 |
|
|
Auto-create the map spreadsheets: make inputs/<datasrc>/
|
408 |
|
|
Map each table's columns:
|
409 |
|
|
In each <table>/ subdir, for each "via map" map.csv:
|
410 |
|
|
Open the map in a spreadsheet editor
|
411 |
|
|
Open the "core map" /mappings/Veg+-VegBIEN.csv
|
412 |
|
|
In each row of the via map, set the right column to a value from the
|
413 |
|
|
left column of the core map
|
414 |
|
|
Save
|
415 |
|
|
Regenerate the derived maps: make inputs/<datasrc>/
|
416 |
|
|
Accept the test cases:
|
417 |
11018
|
aaronmk
|
For a new-style datasource:
|
418 |
|
|
inputs/<datasrc>/run
|
419 |
|
|
svn di inputs/<datasrc>/*/test.xml.ref
|
420 |
|
|
If you get errors, follow the steps for old-style datasources below
|
421 |
|
|
For an old-style datasource:
|
422 |
|
|
make inputs/<datasrc>/test
|
423 |
8458
|
aaronmk
|
When prompted to "Accept new test output", enter y and press ENTER
|
424 |
|
|
If you instead get errors, do one of the following for each one:
|
425 |
|
|
- If the error was due to a bug, fix it
|
426 |
|
|
- Add a SQL function that filters or transforms the invalid data
|
427 |
|
|
- Make an empty mapping for the columns that produced the error.
|
428 |
|
|
Put something in the Comments column of the map spreadsheet to
|
429 |
|
|
prevent the automatic mapper from auto-removing the mapping.
|
430 |
|
|
When accepting tests, it's helpful to use WinMerge
|
431 |
|
|
(see WinMerge setup below for configuration)
|
432 |
|
|
make inputs/<datasrc>/test by_col=1
|
433 |
|
|
If you get errors this time, this always indicates a bug, usually in
|
434 |
|
|
the VegBIEN unique constraints or column-based import itself
|
435 |
|
|
Add newly-created files: make inputs/<datasrc>/add
|
436 |
|
|
Commit: svn ci -m "Added inputs/<datasrc>/" inputs/<datasrc>/
|
437 |
|
|
Update vegbiendev:
|
438 |
12396
|
aaronmk
|
ssh aaronmk@jupiter.nceas.ucsb.edu
|
439 |
12998
|
aaronmk
|
up
|
440 |
8458
|
aaronmk
|
On local machine:
|
441 |
|
|
./fix_perms
|
442 |
|
|
make inputs/upload
|
443 |
10025
|
aaronmk
|
make inputs/upload live=1
|
444 |
13284
|
aaronmk
|
ssh -t vegbiendev.nceas.ucsb.edu exec sudo -u aaronmk -i
|
445 |
12998
|
aaronmk
|
up
|
446 |
8458
|
aaronmk
|
make inputs/download
|
447 |
10025
|
aaronmk
|
make inputs/download live=1
|
448 |
8458
|
aaronmk
|
Follow the steps under Install the staging tables above
|
449 |
1773
|
aaronmk
|
|
450 |
10884
|
aaronmk
|
Maintenance:
|
451 |
|
|
on a live machine, you should put the following in your .profile:
|
452 |
|
|
--
|
453 |
|
|
# make svn files web-accessible. this does not affect unversioned files, because
|
454 |
|
|
# these get the right permissions on the local machine instead.
|
455 |
|
|
umask ug=rwx,o=rx
|
456 |
|
|
|
457 |
|
|
unset TMOUT # TMOUT causes screen to exit even with background processes
|
458 |
|
|
--
|
459 |
|
|
if http://vegbiendev.nceas.ucsb.edu/phppgadmin/ goes down:
|
460 |
13284
|
aaronmk
|
ssh -t vegbiendev.nceas.ucsb.edu exec sudo -u aaronmk -i
|
461 |
12548
|
aaronmk
|
make phppgadmin-Linux
|
462 |
13027
|
aaronmk
|
regularly, re-run full-database import so that bugs in it don't pile up.
|
463 |
|
|
it needs to be kept in working order so that it works when it's needed.
|
464 |
13466
|
aaronmk
|
to back up the vegbiendev databases:
|
465 |
|
|
ssh -t vegbiendev.nceas.ucsb.edu exec sudo -u aaronmk -i
|
466 |
|
|
back up MySQL: # usually few changes, so do this first
|
467 |
14554
|
aaronmk
|
backups/mysql_snapshot
|
468 |
13466
|
aaronmk
|
l=1 overwrite=1 inplace=1 local_dir=/ remote_url="$USER@jupiter:/data/dev/aaronmk/Documents/BIEN/" subpath=/var/lib/mysql.bak/ sudo -E env PATH="$PATH" bin/sync_upload
|
469 |
|
|
on local machine:
|
470 |
|
|
l=1 swap=1 overwrite=1 inplace=1 local_dir=~ sync_remote_subdir= subpath=~/Documents/BIEN/var/lib/mysql.bak/ bin/sync_upload
|
471 |
|
|
back up Postgres:
|
472 |
14892
|
aaronmk
|
$ screen
|
473 |
|
|
# press Enter
|
474 |
|
|
$ unset TMOUT # TMOUT causes shell to exit even with background processes
|
475 |
14894
|
aaronmk
|
$ backups/pg_snapshot # runtime when queries have been run: 1 h ("64m11.586s")
|
476 |
10884
|
aaronmk
|
to synchronize vegbiendev, jupiter, and your local machine:
|
477 |
12226
|
aaronmk
|
**WARNING**: pay careful attention to all files that will be deleted or
|
478 |
10884
|
aaronmk
|
overwritten!
|
479 |
|
|
install put if needed:
|
480 |
|
|
download https://uutils.googlecode.com/svn/trunk/bin/put to ~/bin/ and `chmod +x` it
|
481 |
|
|
when changes are made on vegbiendev:
|
482 |
12951
|
aaronmk
|
avoid extraneous diffs when rsyncing:
|
483 |
14670
|
aaronmk
|
on local machine:
|
484 |
|
|
up; ./fix_perms
|
485 |
|
|
ssh -t vegbiendev.nceas.ucsb.edu exec sudo -u aaronmk -i
|
486 |
|
|
up; ./fix_perms
|
487 |
|
|
ssh aaronmk@jupiter.nceas.ucsb.edu
|
488 |
|
|
up; ./fix_perms
|
489 |
13284
|
aaronmk
|
ssh -t vegbiendev.nceas.ucsb.edu exec sudo -u aaronmk -i
|
490 |
12396
|
aaronmk
|
upload:
|
491 |
14888
|
aaronmk
|
del=1 bin/sync_upload --size-only
|
492 |
13337
|
aaronmk
|
then review diff, and rerun with `l=1` prepended
|
493 |
12396
|
aaronmk
|
on your machine:
|
494 |
|
|
download:
|
495 |
14889
|
aaronmk
|
overwrite=1 swap=1 src=. dest='aaronmk@jupiter.nceas.ucsb.edu:~/bien' put --exclude=.svn web/BIEN3/TWiki; ./fix_perms
|
496 |
13337
|
aaronmk
|
then review diff, and rerun with `l=1` prepended
|
497 |
12957
|
aaronmk
|
swap=1 bin/sync_upload backups/TNRS.backup
|
498 |
13337
|
aaronmk
|
then review diff, and rerun with `l=1` prepended
|
499 |
14888
|
aaronmk
|
del=1 swap=1 bin/sync_upload --size-only
|
500 |
13337
|
aaronmk
|
then review diff, and rerun with `l=1` prepended
|
501 |
14891
|
aaronmk
|
sync_remote_url=~/Dropbox/svn/ bin/sync_upload --existing --size-only --no-perms
|
502 |
14890
|
aaronmk
|
# --size-only: just update mtimes
|
503 |
|
|
# --no-perms: don't transfer the hardlink lock status
|
504 |
14891
|
aaronmk
|
# no overwrite=1: preserve uncommitted changes
|
505 |
13337
|
aaronmk
|
then review diff, and rerun with `l=1` prepended
|
506 |
12959
|
aaronmk
|
to back up e-mails:
|
507 |
|
|
on local machine:
|
508 |
|
|
/Applications/gmvault-v1.8.1-beta/bin/gmvault sync --multiple-db-owner --type quick aaronmk.nceas@gmail.com
|
509 |
|
|
open Thunderbird
|
510 |
|
|
click the All Mail folder for each account and wait for it to download the e-mails in it
|
511 |
|
|
to back up the version history:
|
512 |
13333
|
aaronmk
|
# back up first on the local machine, because often only the svnsync
|
513 |
|
|
command gets run, and that way it will get backed up immediately to
|
514 |
|
|
Dropbox (and hourly to Time Machine), while vegbiendev only gets
|
515 |
|
|
backed up daily to tape
|
516 |
|
|
on local machine:
|
517 |
13331
|
aaronmk
|
svnsync sync file://"$HOME"/Dropbox/docs/BIEN/svn_repo/ # initial runtime: 1.5 h ("08:21:38" - "06:45:26") @vegbiendev
|
518 |
12959
|
aaronmk
|
(cd ~/Dropbox/docs/BIEN/git/; git svn fetch)
|
519 |
14565
|
aaronmk
|
# use absolute path for vegbiendev commands because the Ubuntu 14.04
|
520 |
|
|
version of rsync doesn't expand ~ properly
|
521 |
13332
|
aaronmk
|
overwrite=1 src=~ dest='aaronmk@jupiter.nceas.ucsb.edu:/data/dev/aaronmk/' put Dropbox/docs/BIEN/svn_repo/ # runtime: 1 min ("1:05.08")
|
522 |
13337
|
aaronmk
|
then review diff, and rerun with `l=1` prepended
|
523 |
13332
|
aaronmk
|
overwrite=1 src=~ dest='aaronmk@jupiter.nceas.ucsb.edu:/data/dev/aaronmk/' put Dropbox/docs/BIEN/git/
|
524 |
13337
|
aaronmk
|
then review diff, and rerun with `l=1` prepended
|
525 |
14553
|
aaronmk
|
to back up vegbiendev:
|
526 |
14568
|
aaronmk
|
do steps under Maintenance > "to synchronize vegbiendev, jupiter, and
|
527 |
|
|
your local machine"
|
528 |
14553
|
aaronmk
|
on local machine:
|
529 |
14912
|
aaronmk
|
# **IMPORTANT**: can't use inplace=1 optimization because this
|
530 |
|
|
# messes up the shared hardlinks used by
|
531 |
|
|
# ~/Documents/BIEN/vegbiendev.2014-2-2_1-07-32PT*/
|
532 |
|
|
l=1 overwrite=1 src=root@vegbiendev.nceas.ucsb.edu:/ dest=~/Documents/BIEN/vegbiendev/ sudo -E put --exclude=/var/lib/mysql.bak --exclude=/var/lib/postgresql.bak --exclude='/var/lib/postgresql/9.3/main/*/' --exclude=/home/aaronmk/bien
|
533 |
14601
|
aaronmk
|
# enable --link-dest to work:
|
534 |
|
|
chmod -R o+r ~/bien/.svn/; find ~/bien/.svn -type d -exec chmod o+rx {} \; # match perms
|
535 |
|
|
l=1 overwrite=1 del= src='aaronmk@vegbiendev.nceas.ucsb.edu:~/bien/' dest=~/bien/ put --existing --size-only .svn/pristine/ # match times and perms
|
536 |
14912
|
aaronmk
|
l=1 overwrite=1 src=aaronmk@vegbiendev.nceas.ucsb.edu:/ dest=~/Documents/BIEN/vegbiendev/ sudo -E put --link-dest="$HOME"/Documents/BIEN/svn/ --no-owner --no-group home/aaronmk/bien/
|
537 |
14601
|
aaronmk
|
# --no-owner --no-group: needed to allow --link-dest to work
|
538 |
|
|
# --link-dest: relative to dest, not currdir, so need abs path
|
539 |
14911
|
aaronmk
|
./fix_perms # lock hardlinked files
|
540 |
14399
|
aaronmk
|
to back up the local machine's settings:
|
541 |
|
|
do step when changes are made on vegbiendev > on your machine, download
|
542 |
|
|
ssh aaronmk@jupiter.nceas.ucsb.edu
|
543 |
|
|
(cd ~/Dropbox/svn/; up)
|
544 |
|
|
on your machine:
|
545 |
14922
|
aaronmk
|
sudo find / -name .DS_Store -print -delete # runtime: 23 min ("04:01:28" - "03:39:10")
|
546 |
14399
|
aaronmk
|
rm ~/'Library/Thunderbird/Profiles/9oo8rcyn.default/ImapMail/imap.googlemail.com/[Gmail].sbd/Spam'
|
547 |
|
|
# remove the downloaded Spam folder, because spam e-mails often contain viruses that would trigger clamscan
|
548 |
14548
|
aaronmk
|
overwrite=1 sync_local_dir=~/Dropbox/svn/ sync_remote_subdir=Dropbox/svn/ bin/sync_upload --size-only # just update mtimes
|
549 |
14399
|
aaronmk
|
then review diff, and rerun with `l=1` prepended
|
550 |
14738
|
aaronmk
|
overwrite=1 inplace=1 sync_local_dir=~/ sync_remote_subdir= bin/sync_upload ~/"VirtualBox VMs/**" # need inplace=1 because they are very large files
|
551 |
14399
|
aaronmk
|
then review diff, and rerun with `l=1` prepended
|
552 |
14738
|
aaronmk
|
overwrite=1 sync_local_dir=~/ sync_remote_subdir= sudo -E bin/sync_upload --exclude="/Library/Saved Application State/" --exclude="/.Trash/" --exclude="/bin/" --exclude="/bin/pg_ctl" --exclude="/bin/unzip" --exclude="/Dropbox/home/" --exclude="/.profile" --exclude="/.shrc" --exclude="/.bashrc" --exclude="/software/**/.svn/"
|
553 |
14693
|
aaronmk
|
# sudo -E: needed for Documents/BIEN/vegbiendev*/
|
554 |
14399
|
aaronmk
|
then review diff, and rerun with `l=1` prepended
|
555 |
14692
|
aaronmk
|
pause Dropbox: system tray > Dropbox icon > gear icon > Pause Syncing
|
556 |
14399
|
aaronmk
|
this prevents Dropbox from trying to capture filesystem
|
557 |
|
|
events while syncing
|
558 |
14738
|
aaronmk
|
overwrite=1 sync_local_dir=~/ sync_remote_url=~/Dropbox/home/ bin/sync_upload --exclude="/Library/Saved Application State/" --exclude="/.Trash/" --exclude="/.dropbox/" --exclude="/Documents/BIEN/" --exclude="/Dropbox/" --exclude=/gmvault-db/ --exclude="/software/" --exclude="/VirtualBox VMs/**.sav" --exclude="/VirtualBox VMs/**.vdi" --exclude="/VirtualBox VMs/**.vmdk"
|
559 |
14399
|
aaronmk
|
then review diff, and rerun with `l=1` prepended
|
560 |
14692
|
aaronmk
|
resume Dropbox: system tray > Dropbox icon > gear icon > Resume Syncing
|
561 |
14924
|
aaronmk
|
l=1 overwrite=1 src=/ dest=root@vegbiendev.nceas.ucsb.edu:/home/aaronmk/Documents/BIEN/frenzy/ sudo -E put --exclude=/.fseventsd/ --exclude=/private/var/vm/ --exclude="$HOME"/ --exclude=/usr/local/var/postgres/
|
562 |
14923
|
aaronmk
|
# --exclude="$HOME"/: saves 466 GB
|
563 |
|
|
# --exclude=/usr/local/var/postgres/: saves 60 GB
|
564 |
|
|
# total size: 58 GB (584 GB - (466 GB + 60 GB))
|
565 |
10884
|
aaronmk
|
to backup files not in Time Machine:
|
566 |
14667
|
aaronmk
|
**IMPORTANT**: need to use 2 TB external hard drive instead of Time
|
567 |
|
|
Machine drive because Time Machine drive does not have
|
568 |
|
|
~/Documents/BIEN/ in a location where it can be hardlinked against
|
569 |
11516
|
aaronmk
|
On local machine:
|
570 |
14656
|
aaronmk
|
on first run, create parent dirs:
|
571 |
14667
|
aaronmk
|
sudo mkdir -p '/Volumes/BIEN3.**SAVE**/Users/aaronmk/Documents/BIEN/'
|
572 |
|
|
sudo mkdir -p '/Volumes/BIEN3.**SAVE**/usr/local/var/postgres/'
|
573 |
|
|
l=1 src=/ dest='/Volumes/BIEN3.**SAVE**/' sudo -E put --existing
|
574 |
|
|
l=1 overwrite=1 src=/ dest='/Volumes/BIEN3.**SAVE**/' sudo -E put --include='/vegbiendev**' --exclude='**' Users/aaronmk/Documents/BIEN/
|
575 |
14660
|
aaronmk
|
# this cannot be backed up by Time Machine because it dereferences hard links:
|
576 |
|
|
# `sudo find /Volumes/Time\ Machine\ Backups/Backups.backupdb/ ! -type d -links +1`
|
577 |
|
|
# returns no files when there is a single timestamped backup, but
|
578 |
|
|
# `sudo find / ! -type d -links +1` does
|
579 |
14667
|
aaronmk
|
l=1 overwrite=1 src=/ dest='/Volumes/BIEN3.**SAVE**/' sudo -E put usr/local/var/postgres/
|
580 |
14655
|
aaronmk
|
# this cannot be backed up by Time Machine because it prevents the backup process from ending
|
581 |
14916
|
aaronmk
|
brew services stop postgresql # if doesn't work, run `rm /usr/local/var/postgres/postmaster.pid` and retry
|
582 |
14667
|
aaronmk
|
l=1 overwrite=1 src=/ dest='/Volumes/BIEN3.**SAVE**/' sudo -E put usr/local/var/postgres/
|
583 |
14916
|
aaronmk
|
brew services start postgresql # if doesn't work, run `rm /usr/local/var/postgres/postmaster.pid` and retry
|
584 |
14400
|
aaronmk
|
to back up the local machine's hard drive:
|
585 |
|
|
turn on and connect the 2 TB external hard drive
|
586 |
14917
|
aaronmk
|
# open "/Applications/Utilities/Disk Utility.app"
|
587 |
|
|
# resize the BIEN3.**SAVE** partition so there is enough space
|
588 |
14608
|
aaronmk
|
screen
|
589 |
14623
|
aaronmk
|
# --exclude='/\**': exclude *-files indicating the (differing) retention
|
590 |
|
|
# statuses of the partitions involved
|
591 |
14919
|
aaronmk
|
# don't need to pause Dropbox, since it will be reinitialized for the
|
592 |
|
|
# new partition UUID anyway
|
593 |
14920
|
aaronmk
|
# **IMPORTANT**: turn off Time Machine. this prevents Time Machine from
|
594 |
|
|
# running when the backup is booted, which messes up the Time Machine
|
595 |
|
|
# backup because the partition UUID is different.
|
596 |
14915
|
aaronmk
|
brew services stop postgresql # if doesn't work, run `rm /usr/local/var/postgres/postmaster.pid` and retry
|
597 |
14627
|
aaronmk
|
l=1 overwrite=1 src=/ dest='/Volumes/BIEN3.**SAVE**/' sudo -E put --exclude='/\**' --exclude=/.fseventsd/ --exclude=/private/var/vm/
|
598 |
14696
|
aaronmk
|
# no --extended-attributes: rsync has to visit every file for this
|
599 |
|
|
# runtime: 10 min (~600); initial runtime: 4-13 h ("2422.84"+"12379.91" .. "45813.19"+"747.96")
|
600 |
14915
|
aaronmk
|
brew services start postgresql # if doesn't work, run `rm /usr/local/var/postgres/postmaster.pid` and retry
|
601 |
14920
|
aaronmk
|
# turn on Time Machine
|
602 |
14401
|
aaronmk
|
to restore from Time Machine:
|
603 |
|
|
# restart holding Alt
|
604 |
|
|
# select Time Machine Backups
|
605 |
|
|
# restore the last Time Machine backup to Macintosh HD
|
606 |
|
|
# restart holding Alt
|
607 |
|
|
# select Macintosh HD
|
608 |
|
|
$ screen
|
609 |
14607
|
aaronmk
|
$ l=1 swap=1 src=/ dest=/Volumes/Time\ Machine\ Backups/ sudo -E put usr/local/var/postgres/ # runtime: 1 h ("4020.61")
|
610 |
14401
|
aaronmk
|
$ make postgres_restart
|
611 |
10884
|
aaronmk
|
VegCore data dictionary:
|
612 |
|
|
Regularly, or whenever the VegCore data dictionary page
|
613 |
|
|
(https://projects.nceas.ucsb.edu/nceas/projects/bien/wiki/VegCore)
|
614 |
|
|
is changed, regenerate mappings/VegCore.csv:
|
615 |
11516
|
aaronmk
|
On local machine:
|
616 |
10884
|
aaronmk
|
make mappings/VegCore.htm-remake; make mappings/
|
617 |
12716
|
aaronmk
|
apply new data dict mappings to datasource mappings/staging tables:
|
618 |
12883
|
aaronmk
|
inputs/run postprocess # runtime: see inputs/run
|
619 |
12887
|
aaronmk
|
time yes|make inputs/{NVS,SALVIAS,TEAM}/test # old-style import; runtime: 1 min ("0m59.692s") @starscream
|
620 |
10884
|
aaronmk
|
svn di mappings/VegCore.tables.redmine
|
621 |
|
|
If there are changes, update the data dictionary's Tables section
|
622 |
|
|
When moving terms, check that no terms were lost: svn di
|
623 |
|
|
svn ci -m 'mappings/VegCore.htm: regenerated from wiki'
|
624 |
13284
|
aaronmk
|
ssh -t vegbiendev.nceas.ucsb.edu exec sudo -u aaronmk -i
|
625 |
12717
|
aaronmk
|
perform the steps under "apply new data dict mappings to
|
626 |
|
|
datasource mappings/staging tables" above
|
627 |
10884
|
aaronmk
|
Important: Whenever you install a system update that affects PostgreSQL or
|
628 |
|
|
any of its dependencies, such as libc, you should restart the PostgreSQL
|
629 |
|
|
server. Otherwise, you may get strange errors like "the database system
|
630 |
|
|
is in recovery mode" which go away upon reimport, or you may not be able
|
631 |
|
|
to access the database as the postgres superuser. This applies to both
|
632 |
|
|
Linux and Mac OS X.
|
633 |
|
|
|
634 |
|
|
Backups:
|
635 |
|
|
Archived imports:
|
636 |
13284
|
aaronmk
|
ssh -t vegbiendev.nceas.ucsb.edu exec sudo -u aaronmk -i
|
637 |
10884
|
aaronmk
|
Back up: make backups/<version>.backup &
|
638 |
|
|
Note: To back up the last import, you must archive it first:
|
639 |
|
|
make schemas/rotate
|
640 |
|
|
Test: make -s backups/<version>.backup/test &
|
641 |
|
|
Restore: make backups/<version>.backup/restore &
|
642 |
|
|
Remove: make backups/<version>.backup/remove
|
643 |
|
|
Download: make backups/<version>.backup/download
|
644 |
|
|
TNRS cache:
|
645 |
13284
|
aaronmk
|
ssh -t vegbiendev.nceas.ucsb.edu exec sudo -u aaronmk -i
|
646 |
10884
|
aaronmk
|
Back up: make backups/TNRS.backup-remake &
|
647 |
|
|
runtime: 3 min ("real 2m48.859s")
|
648 |
|
|
Restore:
|
649 |
|
|
yes|make inputs/.TNRS/uninstall
|
650 |
|
|
make backups/TNRS.backup/restore &
|
651 |
|
|
runtime: 5.5 min ("real 5m35.829s")
|
652 |
|
|
yes|make schemas/public/reinstall
|
653 |
|
|
Must come after TNRS restore to recreate tnrs_input_name view
|
654 |
|
|
Full DB:
|
655 |
13284
|
aaronmk
|
ssh -t vegbiendev.nceas.ucsb.edu exec sudo -u aaronmk -i
|
656 |
10884
|
aaronmk
|
Back up: make backups/vegbien.<version>.backup &
|
657 |
|
|
Test: make -s backups/vegbien.<version>.backup/test &
|
658 |
|
|
Restore: make backups/vegbien.<version>.backup/restore &
|
659 |
|
|
Download: make backups/vegbien.<version>.backup/download
|
660 |
|
|
Import logs:
|
661 |
11516
|
aaronmk
|
On local machine:
|
662 |
10884
|
aaronmk
|
Download: make inputs/download-logs live=1
|
663 |
|
|
|
664 |
6484
|
aaronmk
|
Datasource refreshing:
|
665 |
8458
|
aaronmk
|
VegBank:
|
666 |
13284
|
aaronmk
|
ssh -t vegbiendev.nceas.ucsb.edu exec sudo -u aaronmk -i
|
667 |
8458
|
aaronmk
|
make inputs/VegBank/vegbank.sql-remake
|
668 |
|
|
make inputs/VegBank/reinstall quiet=1 &
|
669 |
6484
|
aaronmk
|
|
670 |
702
|
aaronmk
|
Schema changes:
|
671 |
11516
|
aaronmk
|
On local machine:
|
672 |
8458
|
aaronmk
|
When changing the analytical views, run sync_analytical_..._to_view()
|
673 |
|
|
to update the corresponding table
|
674 |
|
|
Remember to update the following files with any renamings:
|
675 |
|
|
schemas/filter_ERD.csv
|
676 |
|
|
mappings/VegCore-VegBIEN.csv
|
677 |
|
|
mappings/verify.*.sql
|
678 |
|
|
Regenerate schema from installed DB: make schemas/remake
|
679 |
|
|
Reinstall DB from schema: make schemas/public/reinstall schemas/reinstall
|
680 |
12226
|
aaronmk
|
**WARNING**: This will delete the public schema of your VegBIEN DB!
|
681 |
12227
|
aaronmk
|
If needed, reinstall staging tables:
|
682 |
8837
|
aaronmk
|
On local machine:
|
683 |
8840
|
aaronmk
|
sudo -E -u postgres psql <<<'ALTER DATABASE vegbien RENAME TO vegbien_prev'
|
684 |
8845
|
aaronmk
|
make db
|
685 |
8837
|
aaronmk
|
. bin/reinstall_all
|
686 |
|
|
Fix any bugs and retry until no errors
|
687 |
8846
|
aaronmk
|
make schemas/public/install
|
688 |
|
|
This must be run *after* the datasources are installed, because
|
689 |
|
|
views in public depend on some of the datasources
|
690 |
8842
|
aaronmk
|
sudo -E -u postgres psql <<<'DROP DATABASE vegbien_prev'
|
691 |
13284
|
aaronmk
|
ssh -t vegbiendev.nceas.ucsb.edu exec sudo -u aaronmk -i
|
692 |
12396
|
aaronmk
|
repeat the above steps
|
693 |
12226
|
aaronmk
|
**WARNING**: Do not run this until reinstall_all runs successfully
|
694 |
|
|
on the local machine, or the live DB may be unrestorable!
|
695 |
12927
|
aaronmk
|
update mappings and staging table column names:
|
696 |
12881
|
aaronmk
|
on local machine:
|
697 |
12883
|
aaronmk
|
inputs/run postprocess # runtime: see inputs/run
|
698 |
12887
|
aaronmk
|
time yes|make inputs/{NVS,SALVIAS,TEAM}/test # old-style import; runtime: 1 min ("0m59.692s") @starscream
|
699 |
13284
|
aaronmk
|
ssh -t vegbiendev.nceas.ucsb.edu exec sudo -u aaronmk -i
|
700 |
12928
|
aaronmk
|
manually apply schema changes to the live public schema
|
701 |
12929
|
aaronmk
|
do steps under "on local machine" above
|
702 |
8458
|
aaronmk
|
Sync ERD with vegbien.sql schema:
|
703 |
|
|
Run make schemas/vegbien.my.sql
|
704 |
|
|
Open schemas/vegbien.ERD.mwb in MySQLWorkbench
|
705 |
|
|
Go to File > Export > Synchronize With SQL CREATE Script...
|
706 |
|
|
For Input File, select schemas/vegbien.my.sql
|
707 |
|
|
Click Continue
|
708 |
|
|
In the changes list, select each table with an arrow next to it
|
709 |
|
|
Click Update Model
|
710 |
|
|
Click Continue
|
711 |
|
|
Note: The generated SQL script will be empty because we are syncing in
|
712 |
|
|
the opposite direction
|
713 |
|
|
Click Execute
|
714 |
|
|
Reposition any lines that have been reset
|
715 |
|
|
Add any new tables by dragging them from the Catalog in the left sidebar
|
716 |
|
|
to the diagram
|
717 |
|
|
Remove any deleted tables by right-clicking the table's diagram element,
|
718 |
|
|
selecting Delete '<table name>', and clicking Delete
|
719 |
|
|
Save
|
720 |
|
|
If desired, update the graphical ERD exports (see below)
|
721 |
|
|
Update graphical ERD exports:
|
722 |
|
|
Go to File > Export > Export as PNG...
|
723 |
|
|
Select schemas/vegbien.ERD.png and click Save
|
724 |
|
|
Go to File > Export > Export as SVG...
|
725 |
|
|
Select schemas/vegbien.ERD.svg and click Save
|
726 |
|
|
Go to File > Export > Export as Single Page PDF...
|
727 |
|
|
Select schemas/vegbien.ERD.1_pg.pdf and click Save
|
728 |
|
|
Go to File > Print...
|
729 |
|
|
In the lower left corner, click PDF > Save as PDF...
|
730 |
|
|
Set the Title and Author to ""
|
731 |
|
|
Select schemas/vegbien.ERD.pdf and click Save
|
732 |
|
|
Commit: svn ci -m "schemas/vegbien.ERD.mwb: Regenerated exports"
|
733 |
|
|
Refactoring tips:
|
734 |
|
|
To rename a table:
|
735 |
|
|
In vegbien.sql, do the following:
|
736 |
|
|
Replace regexp (?<=_|\b)<old>(?=_|\b) with <new>
|
737 |
|
|
This is necessary because the table name is *everywhere*
|
738 |
|
|
Search for <new>
|
739 |
|
|
Manually change back any replacements inside comments
|
740 |
|
|
To rename a column:
|
741 |
|
|
Rename the column: ALTER TABLE <table> RENAME <old> TO <new>;
|
742 |
|
|
Recreate any foreign key for the column, removing CONSTRAINT <name>
|
743 |
|
|
This resets the foreign key name using the new column name
|
744 |
|
|
Creating a poster of the ERD:
|
745 |
|
|
Determine the poster size:
|
746 |
|
|
Measure the line height (from the bottom of one line to the bottom
|
747 |
|
|
of another): 16.3cm/24 lines = 0.679cm
|
748 |
|
|
Measure the height of the ERD: 35.4cm*2 = 70.8cm
|
749 |
|
|
Zoom in as far as possible
|
750 |
|
|
Measure the height of a capital letter: 3.5mm
|
751 |
|
|
Measure the line height: 8.5mm
|
752 |
|
|
Calculate the text's fraction of the line height: 3.5mm/8.5mm = 0.41
|
753 |
|
|
Calculate the text height: 0.679cm*0.41 = 0.28cm
|
754 |
|
|
Calculate the text height's fraction of the ERD height:
|
755 |
|
|
0.28cm/70.8cm = 0.0040
|
756 |
|
|
Measure the text height on the *VegBank* ERD poster: 5.5mm = 0.55cm
|
757 |
|
|
Calculate the VegBIEN poster height to make the text the same size:
|
758 |
|
|
0.55cm/0.0040 = 137.5cm H; *1in/2.54cm = 54.1in H
|
759 |
|
|
The ERD aspect ratio is 11 in W x (2*8.5in H) = 11x17 portrait
|
760 |
|
|
Calculate the VegBIEN poster width: 54.1in H*11W/17H = 35.0in W
|
761 |
|
|
The minimum VegBIEN poster size is 35x54in portrait
|
762 |
|
|
Determine the cost:
|
763 |
|
|
The FedEx Kinkos near NCEAS (1030 State St, Santa Barbara, CA 93101)
|
764 |
|
|
charges the following for posters:
|
765 |
|
|
base: $7.25/sq ft
|
766 |
|
|
lamination: $3/sq ft
|
767 |
|
|
mounting on a board: $8/sq ft
|
768 |
203
|
aaronmk
|
|
769 |
1459
|
aaronmk
|
Testing:
|
770 |
8458
|
aaronmk
|
On a development machine, you should put the following in your .profile:
|
771 |
8469
|
aaronmk
|
umask ug=rwx,o= # prevent files from becoming web-accessible
|
772 |
8458
|
aaronmk
|
export log= n=2
|
773 |
11985
|
aaronmk
|
For development machine specs, see /planning/resources/dev_machine.specs/
|
774 |
11516
|
aaronmk
|
On local machine:
|
775 |
8458
|
aaronmk
|
Mapping process: make test
|
776 |
|
|
Including column-based import: make test by_col=1
|
777 |
|
|
If the row-based and column-based imports produce different inserted
|
778 |
|
|
row counts, this usually means that a table is underconstrained
|
779 |
|
|
(the unique indexes don't cover all possible rows).
|
780 |
|
|
This can occur if you didn't use COALESCE(field, null_value) around
|
781 |
|
|
a nullable field in a unique index. See sql_gen.null_sentinels for
|
782 |
|
|
the appropriate null value to use.
|
783 |
|
|
Map spreadsheet generation: make remake
|
784 |
|
|
Missing mappings: make missing_mappings
|
785 |
|
|
Everything (for most complete coverage): make test-all
|
786 |
702
|
aaronmk
|
|
787 |
7183
|
aaronmk
|
Debugging:
|
788 |
8458
|
aaronmk
|
"Binary chop" debugging:
|
789 |
|
|
(This is primarily useful for regressions that occurred in a previous
|
790 |
|
|
revision, which was committed without running all the tests)
|
791 |
12998
|
aaronmk
|
up -r <rev>; make inputs/.TNRS/reinstall; make schemas/public/reinstall; make <failed-test>.xml
|
792 |
8470
|
aaronmk
|
.htaccess:
|
793 |
|
|
mod_rewrite:
|
794 |
12226
|
aaronmk
|
**IMPORTANT**: whenever you change the DirectorySlash setting for a
|
795 |
8471
|
aaronmk
|
directory, you *must* clear your browser's cache to ensure that
|
796 |
|
|
a cached redirect is not used. this is because RewriteRule
|
797 |
|
|
redirects are (by default) temporary, but DirectorySlash
|
798 |
|
|
redirects are permanent.
|
799 |
8470
|
aaronmk
|
for Firefox:
|
800 |
|
|
press Cmd+Shift+Delete
|
801 |
|
|
check only Cache
|
802 |
|
|
press Enter or click Clear Now
|
803 |
7183
|
aaronmk
|
|
804 |
3783
|
aaronmk
|
WinMerge setup:
|
805 |
11516
|
aaronmk
|
In a Windows VM:
|
806 |
8458
|
aaronmk
|
Install WinMerge from <http://winmerge.org/>
|
807 |
|
|
Open WinMerge
|
808 |
|
|
Go to Edit > Options and click Compare in the left sidebar
|
809 |
|
|
Enable "Moved block detection", as described at
|
810 |
|
|
<http://manual.winmerge.org/Configuration.html#d0e5892>.
|
811 |
|
|
Set Whitespace to Ignore change, as described at
|
812 |
|
|
<http://manual.winmerge.org/Configuration.html#d0e5758>.
|
813 |
3783
|
aaronmk
|
|
814 |
3133
|
aaronmk
|
Documentation:
|
815 |
8458
|
aaronmk
|
To generate a Redmine-formatted list of steps for column-based import:
|
816 |
11516
|
aaronmk
|
On local machine:
|
817 |
8458
|
aaronmk
|
make schemas/public/reinstall
|
818 |
|
|
make inputs/ACAD/Specimen/logs/steps.by_col.log.sql
|
819 |
|
|
To import and scrub just the test taxonomic names:
|
820 |
13284
|
aaronmk
|
ssh -t vegbiendev.nceas.ucsb.edu exec sudo -u aaronmk -i
|
821 |
8458
|
aaronmk
|
inputs/test_taxonomic_names/test_scrub
|
822 |
3133
|
aaronmk
|
|
823 |
702
|
aaronmk
|
General:
|
824 |
8458
|
aaronmk
|
To see a program's description, read its top-of-file comment
|
825 |
|
|
To see a program's usage, run it without arguments
|
826 |
|
|
To remake a directory: make <dir>/remake
|
827 |
|
|
To remake a file: make <file>-remake
|