Update of /cvsroot/php-blog/serendipity
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16496
Modified Files:
Tag: branch_0_6
README
Added Files:
Tag: branch_0_6
upgrade.sh
Log Message:
upgrade script (MFH)
Index: README
===================================================================
RCS file: /cvsroot/php-blog/serendipity/README,v
retrieving revision 1.6
retrieving revision 1.6.4.1
diff -u -d -r1.6 -r1.6.4.1
--- README 4 Apr 2004 15:10:24 -0000 1.6
+++ README 7 Apr 2004 06:43:11 -0000 1.6.4.1
@@ -10,7 +10,12 @@
The automatic update script should find and execute any necessary
changes to the database layout made in different s9y versions beginning
-from 0.5.
+from 0.5. The upgrader will perform its automatic actions, as soon as you
+have copied the new s9y files over your old installation and access the start
+page of your blog.
+You can speed up the process of backing up your data and copying the files by
+using the supplied "upgrade.sh" script. Be sure to edit the file and change
+the variables to your needs.
Usually all DB schema upgrades in previous versions will be used. So
when you upgrade from 0.5 to 0.7 you will get upgrades from 0.5 -> 0.6
--- NEW FILE: upgrade.sh ---
#!/bin/sh
# File: serendipity_safe_upgrade.sh
# Author: Jez Hancock
#
# Description:
# This shell script performs a backup of the serendipity MySQL database and
# files prior to upgrading from one version to another.
########################################################################
# Configuration options start
########################################################################
# Change this to the IP address from which you will be updgrading the blog from
# in a browser. This IP address will be used in a .htaccess file to restrict
# access during the upgrade process:
ip=192.168.0.1
ip=213.152.51.196
# Change this to the directory containing the current serendipity web files:
blog_dir=/usr/local/www/htdocs/serendipity
blog_dir=/web/jez.hancock-family.com
# Change this to the directory containing the new serendipity web files:
# This should be the directory containing the cvs version of s9y or the s9y
# tarball contents:
import_dir=/home/username/serendipity
import_dir=/home/munk/cvs/php-blog/serendipity
# Change this to the directory you wish your weblog files and database to be
# backed up to. A subdirectory 's9y.YYYYMMDD' will be created under here into
# which a tarball will be created containing the backed up webfiles and
# database.
# For example if your backup_dir is set to '/home/user/backup', a directory
# called '/home/user/backup/serendipity.20040406' will be created to contain
# the backup tarball 'serendipity_backup.tar.gz' and the backup database file
# 'serendipity_backup.sql'.
# Note if the backup directory already contains a backup from the current day,
# the script will exit without doing anything.
backup_dir=/home/username/backup
backup_dir=/opt/backup
# Change this to match your database user/name. Note you will be prompted for
# your password on the commandline.
db_name="serendipity"
db_user="serendipity"
########################################################################
# Configuration options end
# You should not need to modify anything below here!
########################################################################
ok() {
echo "[OK]" ; echo ""
}
nl() {
echo ""
}
# the date ... ymd=20040331 etc ... used in backup
ymd=`date "+%Y%m%d"`
# Our backup directory:
backup_dir=$backup_dir/serendipity.$ymd
# if the backup dir exists already, exit gracefully:
if [ -d $backup_dir ];then
echo "$backup_dir already exists - exiting."
exit
fi
# make backup dir:
echo "Creating backup directory:"
nl
echo "$backup_dir"
mkdir $backup_dir && ok
# backup current weblog to a tarball in the backup dir:
echo "Backing up weblog files from:"
nl
echo "$blog_dir"
nl
echo "to the tarball:"
nl
echo "$backup_dir/serendipity_backup.tar.gz"
set `echo "$blog_dir" | sed -e 's,\(.*\)/\(.*\),\1 \2,'`
tar zcf $backup_dir/serendipity_backup.tar.gz -C $1 $2 && ok
echo "Backing up database $db_name to file:"
nl
echo "$backup_dir/serendipity_backup.sql"
nl
echo -n "MySQL user $db_user - "
mysqldump -u$db_user -p $db_name > $backup_dir/serendipity_backup.sql \
&& ok
# make backup dir safe:
echo "Changing perms on $backup_dir to 700"
chmod 700 $backup_dir && ok
# move current blogdir out of way:
echo "Moving:"
nl
echo "$blog_dir"
nl
echo "to:"
nl
echo "$blog_dir.$ymd"
mv $blog_dir $blog_dir.$ymd && ok
# now copy in the new files:
echo "Copying files from:"
nl
echo "$import_dir"
nl
echo "to:"
nl
echo "$blog_dir"
cp -R $import_dir $blog_dir && ok
# check if a .htaccess file exists in old blog dir - if so copy over:
if [ -f "$blog_dir.$ymd/.htaccess" ]; then
cp $blog_dir.$ymd/.htaccess $blog_dir
fi
# allow only our ip during upgrade - remember to remove these lines
# after you've finished updating!:
echo "Adding .htaccess directives to restrict browser access to blog to $ip"
echo "during upgrade process"
exec >> $blog_dir/.htaccess
echo 'deny from all'
echo 'allow from $ip'
echo 'ErrorDocument 403 "Upgrading, please check back soon!!!'
exec > /dev/tty
ok
# copy old uploads folder over:
if [ -d $blog_dir.$ymd/uploads ];then
echo "Copying old uploads folder from:"
nl
echo "$blog_dir.$ymd/uploads"
nl
echo "to:"
nl
echo "$blog_dir/uploads"
cp -R $blog_dir.$ymd/uploads $blog_dir/uploads && ok
fi
# most importantly don't forget the local config file - this is checked
# to see whether or not your current config setup needs upgrading or
# not:
echo "Copying $blog_dir.$ymd/serendipity_config_local.inc.php to $blog_dir"
cp $blog_dir.$ymd/serendipity_config_local.inc.php $blog_dir \
&& ok
echo "########################################################################"
echo "Important!"
echo "########################################################################"
echo "Backup is now complete. Continue to upgrade your serendipity"
echo "installation by browsing to it in a web browser - you will be prompted"
echo "with instructions from there."
nl
echo "After completing the upgrade via a browser, remember to remove the lines"
echo "starting:"
nl
echo "deny from all"
echo "allow from $ip"
echo "ErrorDocument 403 ..."
nl
echo "from the .htaccess file:"
nl
echo "$blog_dir/.htaccess"
nl
nl
echo "A copy of the original serendipity web folder can be found here:"
nl
echo "$blog_dir.$ymd"
nl
echo "After confirming the upgrade was successful, you can safely remove"
echo "this directory."
# Uncomment/modify the following line if you run the server:
#chown -R www:www $blog_dir && chmod 600 $blog_dir/serendipity_config_local.inc.php
|