Automatically Upgrading a Sendy Instance

Sendy is a self-hosted Newsletter manager. We've got a couple instance of Sendy running, and instead of manually upgrading each when a new version comes out, we simply run the following script for each. It's based off of the instructions from Sendy's Get Updated Page.

#!/bin/bash
# This script upgrades a sendy installation, retaining the configuration,
# languages & uploads.

if [ $# -ne 2 ]; then
    echo "Usage: sendy_upgrade.sh <upgrade zip file> <install folder>"
    echo ""
    echo "    sendy_upgrade.sh ~/sendy-2.0.1.zip ~/public_html/sendy"
    exit
fi

SENDY_PACKAGE="$1"
SENDY_INSTALL_DIR="$2"

# Unzip the package
UNZIP_DIR="$HOME/sendy"
TEMP_SENDY_DIR="$UNZIP_DIR/sendy"
mkdir -p $UNZIP_DIR
unzip $SENDY_PACKAGE -d $UNZIP_DIR

# Remove files we will replace
rm -rf $TEMP_SENDY_DIR/includes/config.php $TEMP_SENDY_DIR/.htaccess \
       $TEMP_SENDY_DIR/uploads $TEMP_SENDY_DIR/locale/en_US

# Copy over files from old installation
cp $SENDY_INSTALL_DIR/includes/config.php $TEMP_SENDY_DIR/includes/
cp $SENDY_INSTALL_DIR/.htaccess $TEMP_SENDY_DIR/
cp -r $SENDY_INSTALL_DIR/uploads $SENDY_INSTALL_DIR/locale $TEMP_SENDY_DIR

# Backup & Replace the old installation
CURRENT_TIME="`date +%s`"
BACKUP_DIR="$HOME/sendy_backup_$CURRENT_TIME/"
mkdir -p $BACKUP_DIR
mv $SENDY_INSTALL_DIR $BACKUP_DIR
mv $TEMP_SENDY_DIR $SENDY_INSTALL_DIR

rm -rf $UNZIP_DIR

echo "Sendy upgrade Complete!"

A paste is available here, along with a raw version.

To use the script, you should download the latest version of Sendy to your server's home folder. You can grab the script using wget:

wget http://sleepanarchy.com/p/k80BK1/raw -O upgrade_sendy.sh

Then just point it to the correct zip file & installation directory:

bash upgrade_sendy.sh ~/sendy-2.0.1.zip ~/public_html/sendy

Your configuration file, .htaccess, languages & uploads will be retained and a backup will be created in your home folder.

Comments

There are currently no comments

New Comment

required

required (not published)

optional