#!/bin/sh set -e export ROUNDCUBE_ROOT=/usr/local/cpanel/base/3rdparty/roundcube export ROUNDCUBE_DATA=/var/cpanel/roundcube ## # shared script with debian/preinst and rpm %pre # please keep these two in sync runPreInst() { # check to see if we're NOT in an initial install situation (there will be no database to backup) # if [ "x$CPANEL_BASE_INSTALL" != "x" ]; then /bin/echo "No MySQL server (or tools) are available, skipping roundcube database backup." /bin/echo "NOTE: Fresh installs will not have a database to backup." return fi # do a backup of the existing database if the database exists # HAS_DB=$(perl -e 'qx{mysqlshow roundcube >/dev/null 2>&1}; print qq[ok] if $? == 0') if [ "x${HAS_DB}" = "x" ]; then /bin/echo 'No existing Roundcube database detected; skipping database backup.' return fi DATE="$(date '+%s')" BACKUP_FILE=${ROUNDCUBE_DATA}/roundcube.backup.sql.${DATE} /bin/echo "Archiving current Roundcube data to ${BACKUP_FILE}" mysqldump --no-create-db --skip-comments --complete-insert \ --ignore-table=roundcube.cache --ignore-table=roundcube.session \ --ignore-table=roundcube.messages --databases roundcube \ > ${BACKUP_FILE} /bin/echo "Roundcube DB successfully archived" # ensure the latest backup symlink is correct # /bin/ln -sf ${BACKUP_FILE} ${ROUNDCUBE_DATA}/latest } ## case "$1" in install) runPreInst; ;; esac exit 0