[ Index ]
 

Code source de Serendipity 1.2

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/docs/ -> upgrade.sh (source)

   1  #!/bin/sh
   2  # File: serendipity_safe_upgrade.sh
   3  # Author: Jez Hancock
   4  #
   5  # Description:
   6  # This shell script performs a backup of the serendipity MySQL database and
   7  # files prior to upgrading from one version to another.
   8  echo "This bash file is out of date and does not respect the new directory structure, templates and compiled templates. It needs to be fixed, so if you don't know how to do bash scripting, please don't use this file. Use the web-based installer instead. If you DO want to make this file work, make sure you sure know how to do it. :-)";
   9  exit;
  10  
  11  ########################################################################
  12  # Configuration options start
  13  ########################################################################
  14  # Change this to the IP address from which you will be updgrading the blog from
  15  # in a browser.  This IP address will be used in a .htaccess file to restrict
  16  # access during the upgrade process:
  17  ip=192.168.0.1
  18  
  19  # Change this to the directory containing the current serendipity web files:
  20  blog_dir=/usr/local/www/htdocs/serendipity
  21  
  22  # Change this to the directory containing the new serendipity web files:
  23  # This should be the directory containing the cvs version of s9y or the s9y
  24  # tarball contents:
  25  import_dir=/home/username/serendipity
  26  
  27  # Change this to the directory you wish your weblog files and database to be
  28  # backed up to.  A subdirectory 's9y.YYYYMMDD' will be created under here into
  29  # which a tarball will be created containing the backed up webfiles and
  30  # database.  
  31  
  32  # For example if your backup_dir is set to '/home/user/backup', a directory
  33  # called '/home/user/backup/serendipity.20040406' will be created to contain
  34  # the backup tarball 'serendipity_backup.tar.gz' and the backup database file
  35  # 'serendipity_backup.sql'.
  36  # Note if the backup directory already contains a backup from the current day,
  37  # the script will exit without doing anything.
  38  backup_dir=/home/username/backup
  39  
  40  # Change this to match your database user/name.  Note you will be prompted for
  41  # your password on the commandline.
  42  db_name="serendipity"
  43  db_user="serendipity"
  44  
  45  ########################################################################
  46  # Configuration options end
  47  # You should not need to modify anything below here!
  48  ########################################################################
  49  
  50  ok() { 
  51      echo "[OK]" ; echo ""
  52  }
  53  
  54  nl() {
  55      echo ""
  56  }
  57  
  58  # the date ... ymd=20040331 etc ... used in backup
  59  ymd=`date "+%Y%m%d"`
  60  
  61  # Our backup directory:
  62  backup_dir=$backup_dir/serendipity.$ymd
  63  
  64  # if the backup dir exists already, exit gracefully:
  65  if [ -d $backup_dir ];then
  66      echo "$backup_dir already exists - exiting."
  67      exit
  68  fi
  69  
  70  # make backup dir:
  71  echo "Creating backup directory:"
  72  nl
  73  echo "$backup_dir"
  74  mkdir $backup_dir && ok || \
  75      echo "Could not create $backup_dir - exiting."
  76  
  77  # backup current weblog to a tarball in the backup dir:
  78  echo "Backing up weblog files from:"
  79  nl
  80  echo "$blog_dir"
  81  nl
  82  echo "to the tarball:"
  83  nl
  84  echo "$backup_dir/serendipity_backup.tar.gz"
  85  set `echo "$blog_dir" | sed -e 's,\(.*\)/\(.*\),\1 \2,'`
  86  tar zcf $backup_dir/serendipity_backup.tar.gz -C $1 $2 && ok
  87  
  88  echo "Backing up database $db_name to file:"
  89  nl
  90  echo "$backup_dir/serendipity_backup.sql"
  91  nl
  92  echo -n "MySQL user $db_user - "
  93  mysqldump -u$db_user -p $db_name > $backup_dir/serendipity_backup.sql \
  94      && ok
  95  
  96  # make backup dir safe:
  97  echo "Changing perms on $backup_dir to 700"
  98  chmod 700 $backup_dir && ok
  99  
 100  # move current blogdir out of way:
 101  echo "Moving:"
 102  nl
 103  echo "$blog_dir"
 104  nl
 105  echo "to:"
 106  nl
 107  echo "$blog_dir.$ymd"
 108  mv $blog_dir $blog_dir.$ymd && ok
 109  
 110  # now copy in the new files:
 111  echo "Copying files from:"
 112  nl
 113  echo "$import_dir"
 114  nl
 115  echo "to:"
 116  nl
 117  echo "$blog_dir"
 118  cp -R $import_dir $blog_dir && ok
 119  
 120  # check if a .htaccess file exists in old blog dir - if so copy over:
 121  if [ -f "$blog_dir.$ymd/.htaccess" ]; then
 122      cp $blog_dir.$ymd/.htaccess $blog_dir
 123  fi
 124  
 125  # allow only our ip during upgrade - remember to remove these lines 
 126  # after you've finished updating!:
 127  echo "Adding .htaccess directives to restrict browser access to blog to $ip"
 128  echo "during upgrade process"
 129  exec >> $blog_dir/.htaccess
 130  echo "deny from all" 
 131  echo "allow from $ip"
 132  echo 'ErrorDocument 403 "Upgrading, please check back soon!!!'
 133  exec > /dev/tty
 134  ok
 135  
 136  # copy old uploads folder over:
 137  if [ -d $blog_dir.$ymd/uploads ];then
 138      echo "Copying old uploads folder from:"
 139      nl
 140      echo "$blog_dir.$ymd/uploads"
 141      nl
 142      echo "to:"
 143      nl
 144      echo "$blog_dir/uploads"
 145      cp -R $blog_dir.$ymd/uploads $blog_dir/uploads && ok
 146  fi
 147  
 148  
 149  # most importantly don't forget the local config file - this is checked
 150  # to see whether or not your current config setup needs upgrading or
 151  # not:
 152  echo "Copying $blog_dir.$ymd/serendipity_config_local.inc.php to $blog_dir"
 153  cp $blog_dir.$ymd/serendipity_config_local.inc.php $blog_dir \
 154      && ok
 155  
 156  echo "########################################################################"
 157  echo "Important!"
 158  echo "########################################################################"
 159  echo "Backup is now complete.  Continue to upgrade your serendipity"
 160  echo "installation by browsing to it in a web browser - you will be prompted"
 161  echo "with instructions from there."
 162  nl
 163  echo "After completing the upgrade via a browser, remember to remove the lines"
 164  echo "starting:"
 165  nl
 166  echo "deny from all"
 167  echo "allow from $ip"
 168  echo "ErrorDocument 403 ..."
 169  nl
 170  echo "from the .htaccess file:"
 171  nl
 172  echo "$blog_dir/.htaccess"
 173  nl
 174  nl
 175  echo "A copy of the original serendipity web folder can be found here:"
 176  nl
 177  echo "$blog_dir.$ymd"
 178  nl
 179  echo "After confirming the upgrade was successful, you can safely remove"
 180  echo "this directory."
 181  
 182  # This is the place to do any custom backup stuff - for example I have various
 183  # directory structures that I copy from my blog base directory, a few custom
 184  # plugins I copy, etc etc.
 185  # ...
 186  
 187  # Uncomment/modify the following line if you run the server:
 188  #chown -R www:www $blog_dir && chmod 600 $blog_dir/serendipity_config_local.inc.php


Généré le : Sat Nov 24 09:00:37 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics