Transfer / Copy / Migrate / Deploy Silverstripe Websites

I have moved a ton of Silverstripe Websites over the years, but I still have to think about the steps every time. So here is a script generator of sorts that helps you transfer a Silverstripe website from one server to another server.

By completing the details in the form below you build a command line (SSH) list of steps you can copy and then paste into a bash file (after careful inspection!) to migrate your website.

Assumptions

The wizard assumes the following about your project:

How this works?

Please complete your details in the form on the left. Doing so will create a script on the right that you can copy line-by-line or as a whole, into a bash-esque script. This script will move a website from an old server to a new server in its entirety.

Need help?

If you need help upgrading or migrating Silverstripe websites then please do not hesitate to contact Sunny Side Up for help. We offer competitive rates and high quality work.

Important note about security

To keep your passwords save, we recommend that you save this page as HTML in your browser and download it as such. After that turn off the internet temporarily and use the page as a stand-alone tool to create your scripts. Safe your generated scripts in a secure place. No data entered into the form below is transferred anywhere.

This page uses localstorage to save details. You can turn off the local storage using a checkbox below. Turning off the local storage, on your next load of this page (CTRL+R), all saved data will be removed.

save data

General Inputs

Settings

Old Server

Old Database

New Website

Versioning

New Server

New Database

# Log in to old server
ssh -p 22 OldSSHUser@OldIP
# Run on old server

# go to web root

cd /var/www/mysite.co.nz

# dump database

mysqldump --user=OldDBUser -p='OldDBPassword' --host=localhost OldDBName > ../db.sql

# log out

exit

# Log in to new server
ssh -p 22 NewSSHUser@NewIP

# Run on new server

# go to web root

cd /var/www/mysite.co.nz

# back up any existing assets

mv assets assets_backup_1442444305646

# RSYNC assets from old server

rsync --stats -chavzPr "ssh -p 22" OldSSHUser@OldIP:/var/www/mysite.co.nz/assets/ /var/www/mysite.co.nz/assets/

# back up any existing db

mv ../db.sql ../db.backup_of_db_file.1442444305646.sql

# move db dump to new server (delete from old server)

rsync --stats --remove-source-files -chavzP "ssh -p 22" OldSSHUser@OldIP:/var/www/mysite.co.nz/../db.sql /var/www/mysite.co.nz/../db.sql

# back up existing database

mysqldump --user=NewDBUser -p'NewDBPassword' --host=localhost NewDBName > ../db.backup.1442444305646.sql

# import database

mysql --user NewDBUser --passwordNewDBPassword --host localhost NewDBName < ../db.sql

# backup any existing .htaccess:

mv .htaccess .htaccess.1442444305646

# download latest .htaccess version:

wget https://raw.githubusercontent.com/silverstripe/silverstripe-installer/3.1/.htaccess -O .htaccess

# backup any _ss_environment.php file:

mv ../_ss_environment.php ../_ss_environment.1442444305646.php

# create ss environment file:

echo "<?php

define('SS_ENVIRONMENT_TYPE', 'dev');
define('SS_DEFAULT_ADMIN_USERNAME', 'CMSUser');
define('SS_DEFAULT_ADMIN_PASSWORD', 'CMSPassword');

define('SS_DATABASE_PREFIX', 'localhost');
define('SS_DATABASE_DATABASE_CLASS','MySQLDatabase');
define('SS_DATABASE_SERVER', 'localhost');
define('SS_DATABASE_USERNAME', 'NewDBUser');
define('SS_DATABASE_PASSWORD', 'NewDBPassword');

global $_FILE_TO_URL_MAPPING; $_FILE_TO_URL_MAPPING['/var/www/mysite.co.nz'] = 'WebsiteDomainName';

/**
  * Here are some useful snippets for future hacks:
  * EXPORT DB: mysqldump --user=NewDBUser -p='NewDBPassword' --host=localhost NewDBName > ../db.sql
  *
  * IMPORT DB: mysql --user NewDBUser --passwordNewDBPassword --host localhost NewDBName < ../db.sql
  *
  * G-ZIP ASSETS: tar -zcvf assets.tar.gz /var/www/mysite.co.nz/assets/
  *
  *
  *
  */
" > ../_ss_environment.php

# run dev/build:

php framework/cli-script.php dev/build flush=all

# run it again to check for any errors:

php framework/cli-script.php dev/build flush=all

# check for cron jobs:

xmessage -buttons Yes:0,"No":1 -default No -nearmouse "Are there any cron-jobs to transfer?" -timeout 10

# check for other tasks:

xmessage -buttons Yes:0,"No":1 -default No -nearmouse "Are there any tasks to run?" -timeout 10



copy to clipboard ...

Please use the script template at your own risk!