Opened 11 years ago

Closed 11 years ago

#642 closed Question/How do I...? (fixed)

Move from Dev Server to Live Site

Reported by: https://id.mayfirst.org/mcdev Owned by: Jamie McClelland
Priority: Urgent Component: Tech
Keywords: Drupal Development Server Live Cc: eric@…
Sensitive: no

Description

Need to move the development server to the live site. Can I do this (easily).

Thanks, Eric

Change History (4)

comment:1 Changed 11 years ago by Jamie McClelland

Hi Eric,

From looking at your site, I see that you are not using a revision control system to track your code. That's the best way to manage code changes between a live and development server, but it is more complicated to setup.

Below are suggestions on how to push changes from your development site to your live site when not using revision control (let us know if you'd like help setting up revision control):

Assumptions

  • These directions are for Drupal development
  • I'm assuming that you have the same version of Drupal in both the development site and the live site. In your case, both sites seem to be running Drupal 5 (but as issue #395 points out - your live site is not using our central installation - so there is probably a minor version difference between the live and development sites. That probably won't make a difference here but is something we should fix).
  • I'm assuming that the data i the database on the live site is the most recent data and you want to preserve it.

Steps

Below are the steps. I would recommend making them into scripts so you can easily run them again in the future.

  • Backup your live site sites/default directory:
cp -rp sites/default sites/default.bak
  • Synchronize your development web/files directory with your live web/files directory.

If you manually added any files to the web/files directory on the development server, you will need to add those files to the web/files directory on the live server. You can do this step, while logged in as the user with write permissions to the live site, with:

rsync -a /path/to/dev/web/files/ /path/to/live/web/files/

If you added files via the web interface (meaning that they were entered into the database), then you should manually enter them into the live site via the web interface as well.

  • Make pre-update database changes.

If you made any database changes on the development site, you should first make those changes on the live site. This includes the creation of or changes to any CCK types, views, or other configuration changes that are stored in the database. This does not include database changes that you made that rely on new modules installed on the development site that are not on the live site yet.

  • Synchronize your sites/default directory:
rsync -a --delete --exclude '*/settings.php' /path/to/dev/web/sites/default/ /path/to/live/web/sites/default/

The exclude statement prevents your development settings.php file from overwriting your live settings.php file. The --delete part means that any files or directories on your live site that are not on your development site will be deleted. Use with caution!

  • Make post-update database changes

If you have added any new modules then you will need to login to the live site and enable them.

If something goes wrong you can always move your backup default directory into place with:

mv default default.new; mv default.bak default

There are a few steps I take while developing to make this process easier:

  • I have a script that dumps from the live database to the development database. Whenever I have to make a change to the database, I make it to the live database first, then I dump it to the development database. That way I keep to a minimum the number of pre-update database changes that I have to make.
  • I push my development site live as frequently as possible so I don't have a lot of changes to make at once and so I am more comfortable with the process.

Hope this helps. Let us know how it goes or if any of my assumptions are wrong.

comment:2 Changed 11 years ago by https://id.mayfirst.org/mcdev

The content on the development server is all current. Would it be possible to have you replace the live site with the development site. This way is brings those two completely in synch and I'll set up the revision control system this weekend.

Thanks! Eric

comment:3 Changed 11 years ago by Jamie McClelland

Hi Eric,

If that database on the development site is current (and you expect that to be the way your dev and live site will operate), then I would recommend writing a simple script like the following to make the development site live:

#!/bin/bash

DEV=/path/to/dev/web
LIVE=/path/to/live/web
DEV-USER=dev-db-username
DEV-PASS=dev-db-password
DEV-DB=dev-db-name
LIVE-USER=live-db-username
LIVE-PASS=live-db-password
LIVE-DB=live-db-name

# synchronize the files
rsync -a --delete $DEV/files/ $LIVE/files/

# synchronize the code
rsync -a --delete --exclude '*/settings.php' $DEV/sites/default/ $LIVE/sites/default/

# dump the live database
mysqldump -u $LIVE-USER -p$LIVE-PASS $LIVE-DB > ~/live-db-backup.sql

# dump the dev database into the live database
mysqldump -u $DEV-USER -p$DEV-PASS $DEV-DB | mysql -u $LIVE-USER -p$LIVE-PASS $LIVE-DB

You could manipulate your apache configuration to have the live domain point to what is now the development site and it would probably be easier for a one time switch.

However, by using a script like this - you will make it much easier to continue developing in your development site and always be able to easily push your development changes live.

comment:4 Changed 11 years ago by Jamie McClelland

Resolution: fixed
Status: newclosed

We haven't heard back on this ticket so I'm going to close it out. Please feel free to re-open if you have more questions. Thanks!

Please login to add comments to this ticket.

Note: See TracTickets for help on using tickets.