l-migrate2cloud-1-pd..
l-migrate2cloud-1-pd..
l-migrate2cloud-1-pd..
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
developerWorks®<br />
ibm.com/developerWorks<br />
application stores data both in the database and the file system. The database will<br />
be dumped using the pg_dump command that comes with PostgreSQL; the file<br />
system data will use rsync. The database will have to be wiped and re-transferred<br />
for the migration because of the nature of database dumps, but the file system data<br />
only needs to transfer new and changed files, because rsync can detect when a file<br />
hasn't changed. Thus, the testing part of the plan helps speed up the migration,<br />
because most of the data will already be there.<br />
The fastest way to copy the database is to run:<br />
pg_dump payroll_prod | gzip -c > /tmp/dbbackup.gz<br />
on your production machine, copy dbbackup.gz to the cloud server, and then run:<br />
zcat dbbackup.gz | psql payroll_prod<br />
This command simply creates a compressed dump of the database from one server,<br />
and then replays all the transactions on the other server.<br />
rsync is just as simple. From your production server, run:<br />
rsync -avz -e "ssh -i .ssh/main.pem" /var/uploads/ root@174.129.138.83:/var/uploads/<br />
This command copies everything from /var/uploads from the current production<br />
server to the new server. If you run it again, only the changed files are copied over,<br />
saving you time later on synchronizations.<br />
Because you are copying the database over, you do not have to apply your Rails<br />
migrations first. Rails will believe the database is up to date, because you already<br />
copied over the schema_migrations table.<br />
Deploying the Rails application<br />
At this point, you have the base server set up but not your application. You must<br />
install some basic gems, along with any gems your application requires, before your<br />
application will run. Listing 9 shows the commands to u<strong>pd</strong>ate your gems. Note that<br />
you must be in the root of your Rails application, so copy it over to your server first.<br />
Listing 9. U<strong>pd</strong>ating RubyGems and installing your gems<br />
# gem u<strong>pd</strong>ate --system<br />
U<strong>pd</strong>ating RubyGems<br />
Nothing to u<strong>pd</strong>ate<br />
# gem install rails mongrel mongrel-cluster postgres<br />
Successfully installed rails-2.3.8<br />
Initial migration<br />
Trademarks<br />
© Copyright IBM Corporation 2010. All rights reserved. Page 12 of 21