Migration Commands
I plan on detailing the list of commands that will be used for the migration.
We need to put up the maintenance page. This will be best done by adding Rewrite rules to the apache vhost config.
Make a directory in my home dir that is world writable. This is where we will dump the dbs to.
$ mkdir bscdump $ chmod -R 777 bscdump $ cd bscdump
We need to su to the postgres user on code.oregonstate.edu so we have full permissions over everything in postgres.
$ sudo su postgres
Next, we need to dump the DB.
$ pg_dumpall > bscdump
After this, we jump to castor and pull our dump over the network.
$ mkdir bscdump $ cd bscdump $ scp gallardj@beaversource.oregonstate.edu:bscdump/bscdump .
We need to manipulate this dump a little to make it compatible with the OSL's environment. These changes are detailed below:
- The DB users are different
- tracadmin becomes bsc_projects
- pm_admin becomes bsc_projects_meta
- elgg becomes bsc_elgg
- New admin user is bsc_admin
- We need to create all of the Trac project users in the bsc_users role
- This involves adding 'IN ROLE bsc_users' to the user create statement.
- Visually select all of the trac project users in the beginning of the dump. This was lines 11-146 as of 7-5-09.
- Run the following command to add the new statement. s/_user/ IN ROLE bsc_users/c
- Doing this while you have this all visually selected will set markers automatically, and only do the substitution in that range.
- The 'c' flag at the allows us to confirm each substitute.
- This involves adding 'IN ROLE bsc_users' to the user create statement.
- After the trac project users, there will be CREATE statements for each of the DB users. We need to get rid of these.
- Visually select these CREATE and ALTER statements. Press 'd'.
- All of our databases are already created. We need to delete all of the database CREATE statements.
- Visually select the 'Database creation' section. Press 'd'.
- The dump connects to each database individually. We need to run a few substitutions to change the name of the DBs. The following VIM commands will do this.
- %s/\\connect elgg/\\connect bsc_elgg/c
- %s/\\connect projects/\\connect bsc_projects/c
- %s/\\connect project_meta/\\connect bsc_projects_meta/c
- For each table that is imported, it sets the owner of that table to a specific role. We need to update these to use the new roles. The following VIM commands will do this.
- %s/OWNER TO elgg/OWNER TO bsc_elgg/c
- %s/OWNER TO tracadmin/OWNER TO bsc_projects/c
- %s/OWNER TO pm_admin/OWNER TO bsc_project_meta/c
- For all of the GRANTS, there is an occasional instance of the tracadmin user being referenced. We need to update this. The following VIM commands will do this.
- %s/FROM tracadmin/FROM bsc_projects/
- %s/TO tracadmin/To bsc_projects/
With all of these changes, our dump will now import cleanly. We import it with the following commands. These commands assume that bsc_admin has superuser privileges.
$ psql -h dogwood.osuosl.org -U bsc_admin -W -f bscdump postgres
With the DB dump complete, we need to copy over all of the scp repos. This should take around 2 minutes. We do this with the following commands.
$ cd /data/svn $ scp -r gallardj@beaversource.oregonstate.edu:/data/svn/* .
With the changes we have made to hooks, we need to update all of the current projects with our new SVN hooks. The following script should do this perfectly.
#!/bin/bash
for repo in *
do
if [ -d $repo ]; then
sed -i -e 's/\/data/\/usr\/bin\/python \/data/' $repo/hooks/start-commit
sed -i -e 's/\/data/\/usr\/bin\/python \/data/' $repo/hooks/pre-commit
sed -i -e 's/\/data/\/usr\/bin\/python \/data/' $repo/hooks/post-commit
fi
done
Also, we need to copy all of the data(profile images, icons, files, rss feeds, etc.) for Elgg to the new server. This should take around 30 seconds.
$ cd /var/www/beaversource.oregonstate.edu/data $ sudo scp -r gallardj@beaversource.oregonstate.edu:/var/www/social/data/* .
The last thing we need to copy over from the old box is all of the Trac environments. This should take about 30 seconds as well.Do this with the following command.
$ cd /data/trac/sites $ scp -r gallardj@beaversource.oregonstate.edu:/data/trac/* .
As we are upgrading from 0.10.4 to 0.10.5 with the migration, we need to run trac-upgrade on all of the trac repos. We can do this with the following script very easily. This should be executed from /data/trac/sites
#!/bin/bash
for tracenv in *
do
trac-admin /data/trac/sites/$tracenv upgrade --no-backup
done

