diff --git a/upgrade_roundcube.sh b/upgrade_roundcube.sh index 3aadb44..a113aa3 100755 --- a/upgrade_roundcube.sh +++ b/upgrade_roundcube.sh @@ -230,6 +230,15 @@ fi [[ -n "$DB_NAME" ]] || DB_NAME="$DEFAULT_DB_NAME" [[ -n "$DB_USER" ]] || DB_USER="$DEFAULT_DB_USER" +[[ -n "$POSTFIX_DB_TYPE" ]] || fatal "Plugin password: Database Type for Password Database (POSTFIX_DB_TYPE) not given!" +if [[ "$POSTFIX_DB_TYPE" != "pgsql" ]] && [[ "$POSTFIX_DB_TYPE" != "mysql" ]]; then + fatal "Unknown Database Type '$POSTFIX_DB_TYPE' for Password Database (POSTFIX_DB_TYPE)" +fi +[[ -n "$POSTFIX_DB_HOST" ]] || POSTFIX_DB_HOST="localhost" +[[ -n "$POSTFIX_DB_NAME" ]] || POSTFIX_DB_NAME="postfix" +[[ -n "$POSTFIX_DB_USER" ]] || POSTFIX_DB_USER="postfix" +[[ -n "$POSTFIX_DB_PASSWD" ]] || fatal "Plugin password: Password for Password Database (POSTFIX_DB_PASSWD) not given!" + [[ -n "$MYSQL_DEBIAN_INSTALLATION" ]] || MYSQL_DEBIAN_INSTALLATION=false @@ -301,6 +310,20 @@ if [[ "$DB_TYPE" = "mysql" ]]; then echo -e "\tMySQL Credentials (root access)......: $MYSQL_CREDENTIALS" fi echo "" +if [[ "$POSTFIX_DB_TYPE" = "mysql" ]]; then + echo -e "\tDatabase type of Postfix Database....: MySQL" + echo -e "\tMySQL from Debian Package System.....: $MYSQL_DEBIAN_INSTALLATION" +else + echo -e "\tDatabase type of Postfix Database....: PostgreSQL" +fi +echo -e "\tHost of Roundcube Database...........: $POSTFIX_DB_HOST" +echo -e "\tName of Roundcube Database...........: $POSTFIX_DB_NAME" +echo -e "\tUser of Roundcube Database...........: $POSTFIX_DB_USER" +echo -e "\tPassword of Roundcube Database.......: $POSTFIX_DB_PASSWD" +if [[ "$DB_TYPE" = "mysql" ]]; then + echo -e "\tMySQL Credentials (root access)......: $MYSQL_CREDENTIALS" +fi +echo "" echo -e "\tCrontab backup file..................: $crontab_backup_file" echo "" @@ -354,6 +377,27 @@ elif [[ "$DB_TYPE" = "pgsql" ]]; then fi fi +echononl " Backup existing Database '$POSTFIX_DB_NAME'" +if [[ "$POSTFIX_DB_TYPE" = "mysql" ]]; then + echo -n " (MySQL).." + mysqldump $MYSQL_CREDENTIALS --opt $POSTFIX_DB_NAME > ${WEBSITE_BASEDIR}/${POSTFIX_DB_NAME}.$backup_date.sql 2> $log_file + if [[ $? -eq 0 ]]; then + echo_ok + else + echo_failed + error "$(cat $log_file)" + fi +elif [[ "$POSTFIX_DB_TYPE" = "pgsql" ]]; then + echo -n " (PostgreSQL).." + su - postgres -c "pg_dump -c $POSTFIX_DB_NAME" > ${WEBSITE_BASEDIR}/${POSTFIX_DB_NAME}.$backup_date.sql 2> $log_file + if [[ $? -eq 0 ]]; then + echo_ok + else + echo_failed + error "$(cat $log_file)" + fi +fi + echononl " Backup existing web-directory .." if [[ -d "$CUR_INSTALL_DIR" ]]; then