Server Migration - richjoslin/rivety GitHub Wiki

Overview

There are two components to a Rivety implementation that need to be migrated individually: the database, and the code. It is sometimes necessary to migrate the code and not the database, or vice versa, so this system was designed with that in mind.

Migrating the MySQL Database

  • Use the mysqldump command to make a backup of the existing database.
    NOTE: some views get exported with SECURITY DEFINER code which will break when trying to restore the database.
    See below for an example bash script that automatically removes the offending code.
  • Create a new empty database on the destination server.
  • Copy the backup file over and then use the mysql command to restore the database. See below for an example reusable bash script that takes the backup filename as an argument.
  • Open up phpMyAdmin (recommended) or other db management tool to make the following changes:
    - In the default_config table, in the row where ckey='missing_image', make sure the value column contains the correct path.
    - In the default_config table, in the row where ckey='upload_path', make sure the value column contains the correct path.
    - In the default_config table, in the row where ckey='site_url', make sure the value column contains the correct URL.
  • Update the etc/config.ini file in each Rivety implementation that should connect to this database, or proceed with the code migration shown below.
  • Done.
Example reusable bash script for backing up the database:
 mysqldump -u my_db_user -p my_db_name | grep -v DEFINER= > \
 my_db_name.rivety.$(date +%Y).$(date +%m).$(date +%d).$(date +%H).$(date +%M).sql.bak

Example reusable bash script for restoring the database:

 E_BADARGS=65
 if [ ! -n "$1" ]
 then
     echo "Usage: $0 DATABASE_FILENAME"
     exit $E_BADARGS
 fi
 echo $1
 mysql -u my_db_user -p my_db_name < $1

Migrating the PHP Code

  • Delete caches and temporary files so you don't copy them unnecessarily.
    ./logs/* (you might want to keep the logs or make a backup)
    ./tmp/cache/*
    ./tmp/image_cache/*
    ./tmp/view_compiles/*
  • Copy all files and directories from one webroot to another however you can (FTP, etc). A zip archive or tarball would be a good idea. Also make sure you don't miss hidden files like .htaccess, .git, .gitignore, etc.

    If your file transfer options are limited (e.g. FTP is not an option), and since you're copying from one web server to another, you might post a tarball in a hidden location and download it via http to the new server using the wget command.
  • Open [webroot]/etc/config.ini in a text editor and update the paths and database information.
Settings that might need to change include:
 db.rivety.config.host
 db.rivety.config.dbname
 db.rivety.config.username
 db.rivety.config.password
 zf_path
 smarty_path
 asido_path
 image_cache_dir
 log_filename
 log_filename_cli
  • Double-check that any templated files made it to the server. These include:
    - .htaccess
    - errordocuments/404.html
    - errordocuments/500.html
    - errordocuments/error.css
    - crossdomain.xml
    - maintenance.html
    - robots.txt
  • After saving changes to the config file, you should be done. Finally, test your website.
⚠️ **GitHub.com Fallback** ⚠️