updating Drupal
updating Drupal
rsync is very powerful, Here's an update script that may use fewer system resources to accomplish the update with less chance for messing up:
-
To use this script from SSH logged into your shared server:
First:
A. Put your site in offline mode
B. Change to a core theme.
C. Uncheck all non-core modules. (Remember them for later so you can turn them back on.)
Second:
1. Go to drupal.org in firefox. Go to the download page for 6.x (or your preferred)
2. Right-click and copy the link location for the file download.
3. In shell, navigate to where your script is located. I've got mine at home/user/drupal-updater/.
4. TYPE: wget
5. Paste the link. In Putty, just right-click, and the link will paste. You'll see something like this:
wget http://ftp.drupal.org/files/projects/drupal-6.10.tar.gz
6. Hit return. The tar.gz file will download right next to your script.
7. TYPE: "tar -xzvf drupal-6.10.tar.gz" without quotes and hit return. You'll see the files unarchive nicely into a folder 'drupal-6.10' (or whatever version).
8. Make sure your script is chmodded to 755
chmod 755 drupal-upgrade.sh
9. Hit return.
10. Execute the script. This could take some minutes, looking like nothing is happen after you hit return, so don't panic. When the prompt comes back to it's normal blinking text entry mode you're done with this step.
./drupal-upgrade.sh
11. Go to your firefox browser and execute the mysql updater script:
http://www.mysite.com/update.php
This could take some time too, so again, don't panic.
Third:
A. Re-engage your preferred modules.
B. Re-engage your preferred theme if it's not a core theme.
C. Put the site back in online mode.
/// script ///
#!/bin/bash ## file name: drupal_upgrade.sh ## remember to set this file's permissions: chmod 755 drupal_upgrade.sh ## Drupal Automatic Upgrade Script
## Get the time and name a temporary directory for backup
TIMESTAMP=`date +%y%m%d%H%M`
BACKUPDIR=drupal_backup_$TIMESTAMP
## Drupal directory (relative to script)
## Example:
## If your drupal site is here: /home/user/www.mysite.com
## and your script is here: /home/user/drupal-upgrader/drupal-upgrade.sh
## your DRUPALDIR will be as follows:
## DRUPALDIR='../www.mysite.com'
## Your archives will show up here: /home/user/drupal-updater/drupal_backup_[timestamp]
DRUPALDIR='www'
## Database config
## DBHOST could be 'localhost' for a dev site,
## but for many shared hosting situations,
## you may end up using a named dbhost name.
## DBHOST = 'localhost'
DBHOST='mysql.mysite.com'
DBUSER='my_database_user'
DBPASS='my_password'
DBNAME='drupal_database'
## Backup Drupal files
mkdir $BACKUPDIR/
cp -pr $DRUPALDIR/includes/ $BACKUPDIR/
cp -pr $DRUPALDIR/misc/ $BACKUPDIR/
cp -pr $DRUPALDIR/modules/ $BACKUPDIR/
cp -pr $DRUPALDIR/profiles/ $BACKUPDIR/
cp -pr $DRUPALDIR/scripts/ $BACKUPDIR/
cp -pr $DRUPALDIR/sites/ $BACKUPDIR/
cp -pr $DRUPALDIR/themes/ $BACKUPDIR/
cp -p $DRUPALDIR/cron.php $BACKUPDIR/
cp -p $DRUPALDIR/index.php $BACKUPDIR/
cp -p $DRUPALDIR/robots.txt $BACKUPDIR/
cp -p $DRUPALDIR/update.php $BACKUPDIR/
cp -p $DRUPALDIR/xmlrpc.php $BACKUPDIR/
cp -p $DRUPALDIR/.htaccess $BACKUPDIR/
## Backup Drupal database
mysqldump -h$DBHOST -u$DBUSER -p$DBPASS $DBNAME > $BACKUPDIR/$DBNAME.sql
## Remove old and copy new files
rm -r $DRUPALDIR/includes
cp -pr drupal-6.*/includes/ $DRUPALDIR/
rm -r $DRUPALDIR/misc
cp -pr drupal-6.*/misc/ $DRUPALDIR/
rm -r $DRUPALDIR/modules
cp -pr drupal-6.*/modules/ $DRUPALDIR/
rm -r $DRUPALDIR/profiles
cp -pr drupal-6.*/profiles/ $DRUPALDIR/
rm -r $DRUPALDIR/scripts
cp -pr drupal-6.*/scripts/ $DRUPALDIR/
rm -r $DRUPALDIR/themes
cp -pr drupal-6.*/themes/ $DRUPALDIR/
rm $DRUPALDIR/cron.php
cp -p drupal-6.*/cron.php $DRUPALDIR/
rm $DRUPALDIR/index.php
cp -p drupal-6.*/index.php $DRUPALDIR/
rm $DRUPALDIR/robots.txt
cp -p drupal-6.*/robots.txt $DRUPALDIR/
rm $DRUPALDIR/update.php
cp -p drupal-6.*/update.php $DRUPALDIR/
rm $DRUPALDIR/xmlrpc.php
cp -p drupal-6.*/xmlrpc.php $DRUPALDIR/
rm $DRUPALDIR/.htaccess
cp -p drupal-6.*/.htaccess $DRUPALDIR/
## Copy additional config or include files here...
## Example for transferring your old imagemagick include file...
## This example only executes if the include file was already in
## your core include folder archive - (in the $BACKUPDIR).
MYFILE=$BACKUPDIR/includes/image.imagemagick.inc
if [ -e $MYFILE ];
then
cp -p $BACKUPDIR/includes/image.imagemagick.inc $DRUPALDIR/includes
fi
I've removed these snippets of code:
chmod -R +w $DRUPALDIR/sites/default
rm -r $DRUPALDIR/sites
cp -pr drupal-6.*/sites/ $DRUPALDIR/
and
## Replace config cp -pr $BACKUPDIR/sites/default/* $DRUPALDIR/sites/default/ chmod -w $DRUPALDIR/sites/default chmod -w $DRUPALDIR/sites/default/settings.php