Loading...
 
Skip to main content

History: Migrate a Tiki to a new server with SSH

Source of version: 37 (current)

Copy to clipboard
            ^ This should merge with ((Move Tiki using SSH)) ^

! Migrate a Tiki to a new server with SSH

^ These instruction are more tips/reminders for developers than step by step instructions for end-users ^

Context
* You need to move a Tiki site from server A to server B
* Both servers have SSH and rsync
* Tiki may have been installed by SVN or CVS
* You are not upgrading (you can do this later)
* Downtime is OK while you move the site and change the DNS



!! Close site
* tiki-admin.php?page=general -> navigation -> Site Access -> Close site (except for those with permission)


!! DB
You can use PhpMyAdmin if you have it on both servers, but often, files are too big for web interface or you could get "#1153 - Got a packet bigger than 'max_allowed_packet' bytes ". You can also get this via the command line.


!!! Backup DB

Go to a non web accessible directory and create a new directory

{CODE()}
cd ..
mkdir mysqlbackup
cd mysqlbackup
{CODE}


{CODE(caption="Get the db, user and password from db/local.php")}
mysqldump -u old_db_user -p --opt old_tiki_db > databasebackupfile.sql
{CODE}

{CODE(caption="Check the file to be sure it contains the last table: users_users")}
tail --lines=200 databasebackupfile.sql
{CODE}

!!! Move DB
!!!! SFTP
You may want to compress before you migrate
{CODE(caption="use bzip2")}bzip2 databasebackupfile.sql{CODE}

This will create a file databasebackupfile.sql.bz2 which will be much smaller. Also, if you migrate a compressed file, and there is a transmission problem, you will get a warning when you uncompress at the other end.

Move the file via SFTP and then, uncompress:

{CODE(caption="use bunzip2")}bunzip2 databasebackupfile.sql.bz2{CODE}


!!!! rsync
You can adapt rsync instructions below

!!! Restore DB
Create a new DB via your control panel. This a good opportunity to change the password, so don't use the same as before.

{CODE()}
mysql -u new_db_user -p new_tiki_db < databasebackupfile.sql
{CODE}

It's not unlikely that you get an error like
{CODE()}
ERROR 1153 (08S01) at line 219147: Got a packet bigger than 'max_allowed_packet' bytes
{CODE}
If so, delete your partially created database, search for the solution for your server to increase this value, and try again.

After you restore, compare both databases via PhpMyAdmin to double check all was well transferred. The number of tables and records should be identical, however, the size in megs can vary, and that's OK.



!! Files in web directory

!!! Check for differences
This is a good time to check if the Tiki has been modified. The following commands will show you if files were modified.
It's good to detect if you've been hacked or if their are modifications to Tiki that you need to account for (and reproduce when you upgrade later)

!!!! CVS
{CODE()}
export CVS_RSH=ssh
cvs diff
{CODE}

!!!! SVN
* svn st
* svn diff

!!!! Security check
* tiki-admin_security.php -> Check all tiki files 

!!! Migrate files

!!!! Rsync
SSH in the new site. From here, we'll pull the files

!!!! Create some directories
{CODE()}
cd ..
mkdir temp_directory_to_receive_files
cd temp_directory_to_receive_files
{CODE}

!!!! Do a test run
{CODE(colors="html")} rsync --dry-run --verbose -avz oldusername@olddomain.example.com:/home/oldusername/public_html /home/newusername/temp_directory_to_receive_files/{CODE}

!!!! Do it for real
Remove ''--dry-run'' from above

Once this works, you can move the files from 
/home/newusername/temp_directory_to_receive_files/*.*
to 
/home/newusername/www/*.*

!!!! Zip & (S)FTP
* It's better to compress the files (zip/gzip) before you migrate them to make sure nothing is lost on the way...

!! Adjust the file permissions
{CODE()}sh setup.sh{CODE}

!! Files outside the web directory

Check tiki-admin_system.php

And where attachments are stored for wiki, file gallery, trackers, forums, etc. Ex: tiki-admin.php?page=wiki

Make sure to move these as well...
!! Update database connection

You can do this via tiki-install.php or by editing db/local.php (Edit this file to use new db name/username/password)

!! Switch the DNS
* Ask whoever controls the domain name to switch the DNS


!! Add an alternate domain to the old site
* You can do this via cPanel (park domain)
* It is useful to keep a functioning (and closed) version of the old site so admins can go and check if something is fishy on the new site


!! Open the new site
* tiki-admin.php?page=general -> navigation -> Site Access -> Close site (except for those with permission)



Optional but it can't hurt: log in as an admin and 
Admin → Tiki Cache/Sys Admin → Clear all Tiki caches