How to move a MODX Revolution installation from one location to another

Published on: - 5 months, 3 weeks ago

An article tagged as: linux, modx

Twitter Google+ Facebook Reddit

Overview

Whilst using MODX Revolution, it is very likely that at some point you will have to copy your setup from one folder to another, or even from one server to another. Here is a straight forward way to make such a move.

Clean-up source installation

Clear the cache and sessions via Manager

On your source installation, log into Manager then do the following:-

  • Manage → Clear Cache
  • Manage → Logout All Users

Clear the cache via SSH

SSH into your source webserver. Change directory to your source MODX install.

Some cache files will still be there, we want to remove them all. Be careful of this command.

$ rm -rf core*/cache/*

Back-up source installation

Dump the database

$ mysqldump -u database_user -p database_name > dump.sql

Archive the files and directories

$ tar -cvzf backup.tar.gz .

If you want to exclude any items from the archive

$ tar -cvzf backup.tar.gz . --exclude='folder_name'

Back-up destination installation

SSH into destination server and change directory to the install folder.

Dump the database

$ mysqldump -u database_user -p database_name > dump.sql

Archive the files and directories

$ tar -cvzf backup.tar.gz .

Copy archive to another folder or download it using FTP.

Clean-out destination installation

Only do this if you want a clean destination install. You can usually skip this step.

Create new database

Log-in to your server cPanel or similar, then

  • DROP the destination database
  • Create the destination database
  • Add your database user to the destination database

Remove files and directories

SSH into your destination folder, then remove all the files.

$ rm -rf *
$ rm -rf .*

Copy source to destination

Copy the source archive file to your destination server/folder.

Update destination installation

Extract source archive

$ tar zxvf backup.tar.gz

Update the destination database

Set workspace path

Edit dump.sql

$ nano dump.sql

Edit workspaces table

ctrl + v until you reach the end of the file, then ctrl + y until you find the workspaces table.

Change the path of the first record to {core_path}. This will save you having to change this each time you move installs.

ctrl + o to save, then ctrl + x to exit nano.

Import database

$ mysql -u database_user -p database_name < dump.sql

Check settings

Check config files

After doing any kind of update it is worth checking that your config files contain the correct settings.

$ nano core*/config/config.inc.php

$ nano config.core.php
$ nano connectors*/config.core.php
$ nano manager*/config.core.php

Update .htaccess

Make sure your .htaccess file contains the correct settings.

Re-run setup

Running the setup script makes sure everything is set correctly.

  • Download the same version of MODX that your destination site is on.
  • Copy the setup folder to your destination folder
  • Visit http://yoursite.com/setup
  • Make sure you select Upgrade site

Clean-up

Once working, remove the following files/directories

  • backup.tar.gz
  • dump.sql
  • setup

References