Faspex in Disaster Recovery (DR) and Migration

Primary to DR Sync Proceedures

Here is one method for backing up a Faspex system to a DR site on a periodic basis. This method was documented with Enterprise Server 2.5 and Faspex 1.5. Mileage will vary with ES 2.6+ and Faspex 2.0+.

On Primary

  1. Create an ssh keypair. For example's sake, creating/some/key/id_file and/some/key/id_file.pub, but these can be any place safe:
    # ssh-keygen -f /some/key/id_file
  2. Create a script for use in the root crontab. The basic script should look like this -- please note that example variable values are used and they should be tailored for your need:
    #!/bin/bash 
    ASPERA_BASE=/opt/aspera
    ASPERA_BIN=${ASPERA_BASE}/bin
    FASPEX_BASE=${ASPERA_BASE}/faspex
    ASCTL_BIN=${FASPEX_BASE}/bin
    DR_SITE=10.1.2.3
    DR_USER=backup
    DR_ASCP_ARGS="-Ql 100m -k2 -i /some/key/id_file -o RemoveAfterTransfer=yes"
    BACKUP_DIR=${FASPEX_BASE}/db/backup
    BACKUP_DATE=`date +%y%m%d`
    BACKUP_FILES[0]=${BACKUP_DIR}/faspex_backup_${BACKUP_DATE}.sql
    BACKUP_FILES[1]=${BACKUP_DIR}/central_backup_${BACKUP_DATE}.sql
    BACKUP_FILES[2]=${BACKUP_DIR}/user_service_backup_${BACKUP_DATE}.sql

    ${ASCTL_BIN}/asctl \
    faspex:backup_databases

    for FILE in ${BACKUP_FILES[@]}; do
    if [ ! -f ${FILE} ]; then
    echo "Cannot access backup file"
    exit 1
    fi
    done

    ${ASPERA_BIN}/ascp \
    ${DR_ASCP_ARGS} \
    ${BACKUP_FILES[@]} \
    ${DR_USER}@${DR_SITE}:

On Backup/DR

  1. Create a user for these transfers. Above the user is called 'backup'. These steps will create the user on the system and setup a docroot in /tmp/backup. Replace the docroot with the destination that temporary backups of the DB should be placed. Also, the public key created above should be placed in theauthorized_keys file.
    # useradd -m -d /home/backup -s /bin/aspshell backup 
    # cd ~backup # mkdir .ssh && chmod 700 .ssh && chown backup .ssh && cd .ssh
    # ascp root@IP_OF_PRIMARY:/some/key/file.pub authorized_keys
    # chmod 600 authorized_keys && chown backup authorized_keys
    # /opt/aspera/bin/asconfigurator -F "set_user_data;user_name,backup"
    # /opt/aspera/bin/asconfigurator -F "set_user_data;user_name,backup;user,backup,docroot,1,absolute,/tmp/backup"
  2. (Optional on Primary) Verify backup works with keyfile from Primary to DR
  3. Edit existing /opt/aspera/var/aspera-prepost. If none exists, use the code here:
    #!/bin/sh 
    ASPERA_BASE=/opt/aspera
    FASPEX_BASE=${ASPERA_BASE}/faspex
    ASCTL_BIN=${FASPEX_BASE}/bin
    DR_USER=backup
    DR_SITE=10.1.2.3
    BACKUP_LOG=/tmp/faspex_backup.log
    if [ "${TYPE}" == File ]; then
    if [ "${STARTSTOP}" == Stop ]; then
    if [ "${STATE}" == success ]; then
    if [ "${DIRECTION}" == recv ]; then
    if [ "${USER}" == "${DR_USER}" ]; then
    /bin/date >> ${BACKUP_LOG}
    DB_IN=`/usr/bin/basename ${FILE} | sed -e 's/_backup.*$//'`
    ${ASCTL_BIN}/asctl faspex:reload_database ${DB_IN} ${FILE} >> ${BACKUP_LOG} 2>&1
    if [ "${DB_IN" == faspex ]; then
    echo n |${ASCTL_BIN}/asctl faspex:shared:apache:hostname ${DR_SITE} >> ${BACKUP_LOG} 2>&1
    fi
    fi
    fi
    fi
    fi
    fi

Old Faspex to New Faspex Migration

In essence, the proceedure used above is similar to what is done for the migration. Since the asctl commands to backup the database don't exist in the version of Faspex that is being moved from, direct SQL commands are needed, and additional schema upgrade. In addition, the faspex_packages directory will need to be copied over:

On the Old Faspex Server

  1. Create backups of the 3 faspex tables. The $DATABASE_PASSWORD variable referenced is the mysql password for the faspex MySQL root. If you don't know the password, it is located in/opt/aspera/faspex/config/database.yml:

    # cd /tmp 
    # /opt/aspera/common/mysql/bin/mysql -uroot -p$DATABASE_PASSWORD -h127.0.0.1 -P4406 faspex > faspex_backup_`date +%Y%m%d`.sql
    # /opt/aspera/common/mysql/bin/mysql -uroot -p$DATABASE_PASSWORD -h127.0.0.1 -P4406 central > central_backup_`date +%Y%m%d`.sql
    # /opt/aspera/common/mysql/bin/mysql -uroot -p$DATABASE_PASSWORD -h127.0.0.1 -P4406 user_service > user_service_backup_`date +%Y%m%d`.sql
  2. Transfer the SQL files and the Faspex packages directory to the new Server. For this example, the root user is docrooted to /, and the faspex user's docroot (which is where packages are kept) is /home/faspex/faspex_packages:

    # ascp -Ql 100m /tmp/*_backup_*.sql root@IP_OF_NEW_SERVER:/tmp/ 
    # ascp -Ql 100m /home/faspex/faspex_packages/packages root@IP_OF_NEW_SERVER:/home/faspex/faspex_packages

On New Faspex Server

  1. Make sure Faspex is not running.

    # /opt/aspera/faspex/bin/asctl faspex:shared:apache stop 
    # /opt/aspera/faspex/bin/asctl faspex stop
  2. Make sure the packages copied over have the same permissions:

    # chown -R faspex:faspex /home/faspex/faspex_packages/packages
    
  3. Import the tables into database (replace YYYYMMDD with date used on SQL creation):

    # /opt/aspera/faspex/bin/asctl faspex:reload_database faspex /tmp/faspex_backup_YYYYMMDD.sql 
    # /opt/aspera/faspex/bin/asctl faspex:reload_database central /tmp/central_backup_YYYYMMDD.sql
    # /opt/aspera/faspex/bin/asctl faspex:reload_database user_service /tmp/user_service_backup_YYYYMMDD.sql
  4. Update the MySQL schema:

    # /opt/aspera/faspex/bin/asctl faspex:migrate_database
    
  5. Make sure the hostname is set properly (replace 10.1.2.3 with real IP of DR site instance)

    # echo n | /opt/aspera/faspex/bin/asctl faspex:shared:apache:hostname 10.1.2.3
    
  6. To finish, restart the apache and faspex services:

    # /opt/aspera/faspex/bin/asctl faspex:shared:apache start 
    # /opt/aspera/faspex/bin/asctl faspex start

A Note on Alternate Addresses

You will need to execute some SQL to change a few settings for which we have no asctl command, but only if the primary server uses the "enable alternate address" option in the "Config->Faspex Server" or Config-Central Server" screens (or if the primary server does not use it but the standby server needs to).

If neither the primary or standby server needs the 'enable alternate address feature' then the following is unneeded.

If a field needs to be set to blank, use the word NULL without quotes, e.g. c_server_alternate_address_client_filter=NULL

Here are the SQL commands:

UPDATE faspex.e_configurations SET 
e_server_enable_alternate_address=ZERO_FOR_FALSE_ONE_FOR_TRUE,
e_server_alternate_address='ALTERNATE.IP.ADDRESS.OR.NAME.FROM.FASPEX.SERVER.CONFIGURATION';
UPDATE central.c_configurations SET
c_server_enable_alternate_address=ZERO_FOR_FALSE_ONE_FOR_TRUE,
c_server_alternate_address='ALTERNATE.IP.ADDRESS.OR.NAME.FROM.CENTRAL.SERVER.CONFIGURATION',
c_server_alternate_address_client_filter='CLIENT_MATCH_STRING',
c_server_alternate_address_server_filter='SERVER_MATCH_STRING';
Have more questions? Submit a request

0 Comments

Article is closed for comments.
Powered by Zendesk