Project

General

Profile

1 14028 aaronmk
to test the import:
2
# -> "to set up the VM"
3
# restore the "booted" snapshot under "+pg_restore"
4
# start the VM
5
ssh -t 128.111.220.240
6 14062 aaronmk
# update system time so wait times can be calculated correctly:
7
sudo service ntp stop; sudo ntpdate -s time.nist.gov; sudo service ntp start
8 14032 aaronmk
* to test a different revision:
9
# {
10 14039 aaronmk
# pick [rev] from r12025 (2014-2-2, last success)..r13002 (2014-3-30, 1st failure)
11 14049 aaronmk
svn revert --depth infinity .
12 14037 aaronmk
svn up --force -r [rev] # runtime: 1 min ("0m50.945s")
13 14063 aaronmk
# fix concurrent regressions (which occurred during the revision range):
14 14057 aaronmk
for patch in r12689 r12760 r12865 r12872 r12994; do
15 14056 aaronmk
	svn di -c "$patch"|patch --force --fuzz=3 -p 0
16
done
17 14061 aaronmk
	# use `patch` instead of `svn merge` because `svn merge` sometimes inexplicably
18
	# doens't apply patches
19
	# --fuzz: allow patching even when surrounding lines have changed
20 14041 aaronmk
# if any of the commands below are broken, try a different revision
21 14042 aaronmk
yes|make mk_db rm_initial_public schemas/reinstall # mk_db: install new extensions
22 14043 aaronmk
yes|make inputs/.TNRS/reinstall
23
yes|make schemas/public/reinstall # sanity check before running the import
24 14032 aaronmk
# }
25 14028 aaronmk
$0 # nested shell
26
export version=test_import
27
declare -ax inputs; inputs=(inputs/ARIZ/)
28
. bin/import_all # runtime: 50 min ("0:45:07.105389"+"4:05.03")
29 14059 aaronmk
# at "This will delete the test_import schema", type y and press ENTER
30 14058 aaronmk
# determine if the revision works:
31
# {
32 14064 aaronmk
# wait 8-10 min
33
# wait until pg_stat_activity shows an in# query
34 14058 aaronmk
# see if pg_stat_activity shows the buggy query
35 14064 aaronmk
#  (https://projects.nceas.ucsb.edu/nceas/issues/902) -> the revision is broken,
36
#  or an in# query after in#6 -> the revision is OK
37 14058 aaronmk
# }
38
# stop the import:
39
# {
40 14028 aaronmk
kill % # cancel after_import()
41 14058 aaronmk
. bin/stop_imports
42
sudo pkill -f 'postgres: bien vegbien'
43
# }
44 14028 aaronmk
45
to set up the VM:
46
ln -s /Volumes/vegbiendev/vegbiendev.vdi ~/VirtualBox\ VMs/vegbiendev/vegbiendev.vdi
47
screen
48
# press ENTER
49
l=1 overwrite=1 inplace=1 src=/Volumes/vegbiendev/vegbiendev.vdi dest=~/VirtualBox\ VMs/vegbiendev/vegbiendev.file.vdi put # runtime: 5 h ("4:43:16")
50
	# move vegbiendev.vdi to the internal hard drive
51
# press Ctrl-D
52
(cd ~/VirtualBox\ VMs/vegbiendev/; mv vegbiendev.file.vdi vegbiendev.vdi)
53
# open VirtualBox
54
# select the vegbiendev VM
55
# restore the "+bootloader+VirtualBox Guest Additions+eth1" snapshot
56
# open Settings > System tab
57
# in the Motherboard subtab, set Base Memory to 2048 MB
58
# in the Processor subtab, set Processor(s) to 1
59
# boot the VM
60
# when asked whether to skip mounting, press S
61
ssh -t 128.111.220.240
62
rm inputs/GBIF/_MySQL/GBIFPortalDB-2013-02-20.data.sql
63
sed --in-place -r 's/^(shared_buffers = )\S+/\11000MB/' schemas/postgresql.conf
64
	# = <1 GB; decrease to match VM's allocated memory (2 GB)
65
sudo mkdir -p /var/lib/postgresql/9.3/main/
66
sudo chown postgres:postgres /var/lib/postgresql/9.3/main/
67
sudo -E -u postgres /usr/lib/postgresql/9.3/bin/initdb -D /var/lib/postgresql/9.3/main/
68
sudo ln -sf /etc/postgresql/9.3/main/*.conf /var/lib/postgresql/9.3/main/
69
make postgres_reload
70
# at "Modifying postgresql.conf and pg_hba.conf", type y and press ENTER
71
# at "kernel.shmmax ... Press ENTER to continue", press ENTER
72
# at "restart PostgreSQL manually ... Press ENTER to continue":
73
# open a new window
74
ssh -t 128.111.220.240
75
# run what it says
76
# press Ctrl-D
77
# return to the previous window
78
# press ENTER
79
* to use a database backup:
80
# {
81 14033 aaronmk
make mk_db rm_initial_public # do things that are not part of the backup
82 14028 aaronmk
screen
83
# press ENTER
84 14408 aaronmk
l=1 src='frenzy.nceas.ucsb.edu:~/bien/' dest=. put backups/vegbien.r12025.backup # runtime: 25 min ("0:25:24")
85 14028 aaronmk
# press Ctrl-D
86
sudo chgrp postgres backups/vegbien.r12025.backup
87
sudo halt
88
# at "System halted", close the VM and *uncheck* Restore current snapshot
89 14029 aaronmk
# create a VM snapshot named "+initdb+database backup file"
90 14028 aaronmk
# boot the VM
91
# when asked whether to skip mounting, press S
92
ssh -t 128.111.220.240
93
screen
94
# press ENTER
95
time for schema in temp util py_util geoscrub herbaria IRMNG IUCN NCBI newWorld TNRS ARIZ; do
96
	bin/psql_verbose_vegbien <<<"CREATE SCHEMA \"$schema\";"
97
	"time" sudo -E -u postgres pg_restore --exit-on-error --verbose --dbname=vegbien --schema="$schema" backups/vegbien.r12025.backup
98
		# need to run as DB superuser to restore py_util
99
done # runtime: 15 min ("11:44:05" - ~11:30)
100
	# must use for loop because pg_restore doesn't support multiple --schema
101
	# options (it just uses the last one)
102
	# (http://postgresql.1045698.n5.nabble.com/pg-restore-should-accept-multiple-t-switches-td2399138.html)
103
# press Ctrl-D
104
sudo halt
105
# at "System halted", close the VM and *uncheck* Restore current snapshot
106
# create a VM snapshot named "+pg_restore"
107
# boot the VM
108
# when asked whether to skip mounting, press S
109
# create a VM snapshot named "booted"
110
# close the VM and *check* Restore current snapshot
111
# }
112
* to use a clean database:
113
# {
114
(cd inputs/; for dir in IRMNG IUCN newWorld; do mv "$dir" ."$dir"; done)
115
(cd inputs/; for dir in */; do dir="${dir%/}"; case "$dir" in analytical_db|ARIZ) : ;; *) mv "$dir" .archive/"$dir";; esac; done)
116
make misc-Linux db inputs/install schemas/public/reinstall # runtime: 15 min ("15:11:16".."15:26:28") @starscream.vegbiendev
117
# at "This will delete the current public schema of your VegBIEN DB", type y and press ENTER
118
# }
119
120
to install system updates:
121
# boot the VM
122
# when asked whether to skip mounting, press S
123
sudo apt-get update
124 14030 aaronmk
sudo apt-get dist-upgrade # runtime: 12 min ("14:20:15".."14:31:50") @starscream.vegbiendev
125 14028 aaronmk
sudo reboot # some system updates require system restart
126
# when asked whether to skip mounting, press S
127
sudo halt
128
# at "System halted", close the VM and *uncheck* Restore current snapshot
129
# create a VM snapshot named "+system updates"
130
# boot the VM
131
# when asked whether to skip mounting, press S
132
# create a VM snapshot named "booted"
133
134
to enable VM to access VirtualBox shared folders:
135
(currently doesn't work, likely because of a bug in VirtualBox Guest Additions when installed on something other than a clean Linux install)
136
sudo sed --in-place -r 's/^vboxsf:.*:$/&aaronmk/' /etc/group
137
# press Ctrl-D
138
ssh -t 128.111.220.240
139 14602 aaronmk
140
to retrieve the original contents of the backup from the VM:
141 14604 aaronmk
# open VirtualBox
142
# select the vegbiendev VM
143
# restore the "+LiveCD+ssh+root pw+mount" snapshot
144 14914 aaronmk
# **IMPORTANT**: can't use inplace=1 optimization because this messes up the
145
#  shared hardlinks used by ~/Documents/BIEN/vegbiendev/
146 14602 aaronmk
# --link-dest: relative to dest, not currdir, so need abs path
147 14914 aaronmk
l=1 overwrite=1 src=root@128.111.220.198:/mnt/ dest=~/Documents/BIEN/vegbiendev.2014-2-2_1-07-32PT/ sudo -E put --link-dest="$HOME"/Documents/BIEN/vegbiendev/ --exclude=/home/bien/svn/ --exclude=/home/aaronmk/Dropbox/
148 14602 aaronmk
	# --exclude=/home/aaronmk/Dropbox/: this is not used by the BIEN scripts
149
sudo mkdir ~/Documents/BIEN/vegbiendev.2014-2-2_1-07-32PT/home/bien/svn/
150
# --exclude of specific files: these have compressed versions
151 14914 aaronmk
l=1 overwrite=1 src=root@128.111.220.198:/mnt/ dest=~/Documents/BIEN/vegbiendev.2014-2-2_1-07-32PT/ sudo -E put --link-dest="$HOME"/Documents/BIEN/vegbiendev/home/aaronmk/bien/ --no-owner --no-group --exclude=/backups/.vegbien.r10848.backup.aYCFxI --exclude='/backups/vegbien.*.backup' --exclude=/inputs/GBIF/_archive/Specimen/GBIF.txt --exclude=/inputs/GBIF/_MySQL/GBIFPortalDB-2013-02-20.data.sql --exclude=/inputs/GBIF/raw_occurrence_record_plants/_archive/table.2013-5-13.tsv --exclude=/inputs/GBIF/raw_occurrence_record_plants/table.tsv --exclude=/inputs/VegBank/_archive/2012-8-30/vegbank.sql --exclude='/inputs/FIA/_archive/2011-10-17/Organism/*_Extract.csv' --exclude='*.CSV' --exclude='*.gz' --exclude='*.log.sql' --exclude='*.zip'                                          home/bien/svn/
152
l=1 overwrite=1 src=root@128.111.220.198:/mnt/ dest=~/Documents/BIEN/vegbiendev.2014-2-2_1-07-32PT/ sudo -E put --link-dest="$HOME"/Documents/BIEN/vegbiendev/home/aaronmk/bien/ --no-owner --no-group --exclude=/backups/.vegbien.r10848.backup.aYCFxI --exclude='/backups/vegbien.*.backup' --exclude=/inputs/GBIF/_archive/Specimen/GBIF.txt --exclude=/inputs/GBIF/_MySQL/GBIFPortalDB-2013-02-20.data.sql --exclude=/inputs/GBIF/raw_occurrence_record_plants/_archive/table.2013-5-13.tsv --exclude=/inputs/GBIF/raw_occurrence_record_plants/table.tsv --exclude=/inputs/VegBank/_archive/2012-8-30/vegbank.sql --include='/inputs/FIA/_archive/2011-10-17/Organism/*_Extract.csv' --include='*.CSV' --include='*.gz' --include='*.log.sql' --include='*.zip' --include='*/' --exclude='**' --no-perms home/bien/svn/
153 14602 aaronmk
	# --no-perms: enable --link-dest to work in spite of perms changes (the
154
	#  perms on these files are not important to the BIEN scripts)
155 14603 aaronmk
# generate list of all the files whose permissions were changed since the
156
#  backup, but which are extracted with their changed permissions instead of
157
#  their original ones in the backup:
158 14914 aaronmk
l=  overwrite=1 src=root@128.111.220.198:/mnt/ dest=~/Documents/BIEN/vegbiendev.2014-2-2_1-07-32PT/ sudo -E put --link-dest="$HOME"/Documents/BIEN/vegbiendev/home/aaronmk/bien/ --no-owner --no-group --exclude=/backups/.vegbien.r10848.backup.aYCFxI --exclude='/backups/vegbien.*.backup' --exclude=/inputs/GBIF/_archive/Specimen/GBIF.txt --exclude=/inputs/GBIF/_MySQL/GBIFPortalDB-2013-02-20.data.sql --exclude=/inputs/GBIF/raw_occurrence_record_plants/_archive/table.2013-5-13.tsv --exclude=/inputs/GBIF/raw_occurrence_record_plants/table.tsv --exclude=/inputs/VegBank/_archive/2012-8-30/vegbank.sql home/bien/svn/ >~/Documents/BIEN/vegbiendev.2014-2-2_1-07-32PT.perms_changed.txt
159 14605 aaronmk
160
to retrieve the contents of the VM, with the VirtualBox changes added:
161
# open VirtualBox
162
# select the vegbiendev VM
163
# restore the "(+VirtualBox changes)+root pw" snapshot
164 14914 aaronmk
# boot the VM
165
# **IMPORTANT**: can't use inplace=1 optimization because this messes up the
166
#  shared hardlinks used by ~/Documents/BIEN/vegbiendev/
167 14605 aaronmk
# --link-dest: relative to dest, not currdir, so need abs path
168 14914 aaronmk
l=1 overwrite=1 src=root@128.111.220.240:/ dest=~/Documents/BIEN/vegbiendev.2014-2-2_1-07-32PT.VirtualBox/ sudo -E put --link-dest="$HOME"/Documents/BIEN/vegbiendev.2014-2-2_1-07-32PT/ --exclude=/home/bien/svn/ --exclude=/home/aaronmk/Dropbox/
169 14605 aaronmk
	# --exclude=/home/aaronmk/Dropbox/: this is not used by the BIEN scripts
170 14619 aaronmk
sudo mkdir ~/Documents/BIEN/vegbiendev.2014-2-2_1-07-32PT.VirtualBox/home/bien/svn/
171 14605 aaronmk
# --exclude of specific files: these have compressed versions
172 14914 aaronmk
l=1 overwrite=1 src=root@128.111.220.240:/ dest=~/Documents/BIEN/vegbiendev.2014-2-2_1-07-32PT.VirtualBox/ sudo -E put --link-dest="$HOME"/Documents/BIEN/vegbiendev.2014-2-2_1-07-32PT/home/bien/svn/ --no-owner --no-group --exclude=/backups/.vegbien.r10848.backup.aYCFxI --exclude='/backups/vegbien.*.backup' --exclude=/inputs/GBIF/_archive/Specimen/GBIF.txt --exclude=/inputs/GBIF/_MySQL/GBIFPortalDB-2013-02-20.data.sql --exclude=/inputs/GBIF/raw_occurrence_record_plants/_archive/table.2013-5-13.tsv --exclude=/inputs/GBIF/raw_occurrence_record_plants/table.tsv --exclude=/inputs/VegBank/_archive/2012-8-30/vegbank.sql --exclude='/inputs/FIA/_archive/2011-10-17/Organism/*_Extract.csv' --exclude='*.CSV' --exclude='*.gz' --exclude='*.log.sql' --exclude='*.zip'                                          home/bien/svn/
173
l=1 overwrite=1 src=root@128.111.220.240:/ dest=~/Documents/BIEN/vegbiendev.2014-2-2_1-07-32PT.VirtualBox/ sudo -E put --link-dest="$HOME"/Documents/BIEN/vegbiendev.2014-2-2_1-07-32PT/home/bien/svn/ --no-owner --no-group --exclude=/backups/.vegbien.r10848.backup.aYCFxI --exclude='/backups/vegbien.*.backup' --exclude=/inputs/GBIF/_archive/Specimen/GBIF.txt --exclude=/inputs/GBIF/_MySQL/GBIFPortalDB-2013-02-20.data.sql --exclude=/inputs/GBIF/raw_occurrence_record_plants/_archive/table.2013-5-13.tsv --exclude=/inputs/GBIF/raw_occurrence_record_plants/table.tsv --exclude=/inputs/VegBank/_archive/2012-8-30/vegbank.sql --include='/inputs/FIA/_archive/2011-10-17/Organism/*_Extract.csv' --include='*.CSV' --include='*.gz' --include='*.log.sql' --include='*.zip' --include='*/' --exclude='**' --no-perms home/bien/svn/
174 14605 aaronmk
	# --no-perms: enable --link-dest to work in spite of perms changes (the
175
	#  perms on these files are not important to the BIEN scripts)
176 14914 aaronmk
l=  overwrite=1 src=root@128.111.220.240:/ dest=~/Documents/BIEN/vegbiendev.2014-2-2_1-07-32PT.VirtualBox/ sudo -E put --link-dest="$HOME"/Documents/BIEN/vegbiendev.2014-2-2_1-07-32PT/home/bien/svn/ --no-owner --no-group --exclude=/backups/.vegbien.r10848.backup.aYCFxI --exclude='/backups/vegbien.*.backup' --exclude=/inputs/GBIF/_archive/Specimen/GBIF.txt --exclude=/inputs/GBIF/_MySQL/GBIFPortalDB-2013-02-20.data.sql --exclude=/inputs/GBIF/raw_occurrence_record_plants/_archive/table.2013-5-13.tsv --exclude=/inputs/GBIF/raw_occurrence_record_plants/table.tsv --exclude=/inputs/VegBank/_archive/2012-8-30/vegbank.sql home/bien/svn/|diff /dev/stdin ~/Documents/BIEN/vegbiendev.2014-2-2_1-07-32PT.perms_changed.txt
177 14605 aaronmk
# ensure there are no file changes
178 14606 aaronmk
179
to configure the VM to support VirtualBox:
180
# open VirtualBox
181
# select the vegbiendev VM
182
# restore the "restore of 2014-02-02 01:07:32 backup (DO NOT DELETE)" snapshot
183
# boot the VM from ~/software/ubuntu-12.04.4-desktop-amd64.iso
184
# install a bootloader
185
# shut down the VM
186
# eject the CD image
187
# boot the VM
188
# when asked whether to skip mounting, press S
189
# install VirtualBox Guest Additions
190
# set up the network connection:
191
# {
192
ssh -t aaronmk@128.111.220.240
193
sudo nano /etc/network/interfaces
194
# remove the entry for eth0 (which doesn't work under VirtualBox)
195
# add the following entry:
196
---
197
auto eth1
198
iface eth1 inet dhcp
199
---
200
# }