Koozali.org: home of the SME Server

What is the best way to migrate an iBay?

Offline LANMonkey

  • *****
  • 350
  • +0/-0
    • Database Collection of Transcripts for the ICTY
What is the best way to migrate an iBay?
« on: December 14, 2013, 12:12:52 AM »
I would like to test out an existing iBay on a test SME server.  What is the best way to migrate an iBay from one server to another?  Can I just select the directory from a backup and restore it selectively?  Or are there other SME database issues involved?

Offline mmccarn

  • *
  • 2,653
  • +10/-0
Re: What is the best way to migrate an iBay?
« Reply #1 on: December 14, 2013, 05:24:44 PM »
The details of what you need would depend on the details of what you're trying to migrate.  Wordpress has different requirements than DokuWiki, Moodle, or Drupal, for example.

Generally speaking:
- try to have the same "root" path on both systems (http://mainserver/ibay? --> http://testserver/ibay; http://mainibay.abc? -> http://testibay.abc)
- you will need to create an ibay account (and possibly a domain, if you're main ibay is serving content to a domain) on the test/backup server in order to get httpd setup correctly
- if your ibay uses a database, you'll have to backup the db on the old system and restore it on the test system
- if your old system has any peculiarities you may need to duplicate them on your test system (non-standard PHP, python, perl, mysql, or Apache)
- you'll have to correct file and folder ownership on the new system after transferring the contents

Having said that, here's how I go about what it sounds like you're trying to do.  With a little note-taking, this process can leave you with almost everything you need  to write a script to move the same ibay again, or to move from the 'test' server back to the production server.

Assumptions:
Current ibay: myibay
Current mysql database: mydb (user=mydbuser; mydbpass)
Customizations to SME server: none; system fully up-to-date
Current sme server: myserver.sme
Test sme server: testserver.sme

On mysmeserver.sme:
1) Backup the mysql db into the ibay "/files" folder:
Code: [Select]
mysqldump --add-drop-table  --user=mydbuser --password=mydbpass mydb | bzip2 -c > /home/e-smith/files/ibays/myibay/files/mydb.sql.bz2"
2) Enable ssh connection from the test server

3) Determine the values currently in use for mydb, mydbuser, and mydbpass.  Usually you can look these up in the configuration files for your web app if you don't have them recorded anywhere.

4) Lookup the specific settings for 'myibay' in server-manager for Group, User access..., Public access..., and Execution of ...

On testserver.sme:
1) Create myibay in server-manager using the same settings as on mysmeserver.sme

2) Create the database on the new computer using:
Code: [Select]
mysql
create database mydb;
grant all privileges on mydb.* to mydbuser@localhost identified by 'mydbpass' with grant option;
quit

3) Delete the default 'index.html' file:
Code: [Select]
rm /home/e-smith/files/ibays/myibay/html/index.html
4) Get your ibay data from mysmeserver.sme:
Code: [Select]
rsync -rlptDzq -e "ssh" "root@mysmeserver.sme:/home/e-smith/files/ibays/myibay/" "/home/e-smith/files/ibays/myibay/"
5) Restore your database:
Code: [Select]
cd /home/e-smith/files/ibays/myibay/files
bunzip2 -c mydb.sql.bz2 | mysql mydb

6) Set permissions on the ibay to something that will probably work:
Code: [Select]
cd /home/e-smith/files/ibays/myibay
chown -R www:www *

7) Try it out...

Offline LANMonkey

  • *****
  • 350
  • +0/-0
    • Database Collection of Transcripts for the ICTY
Wow! That should cover it.
« Reply #2 on: December 14, 2013, 06:45:28 PM »
Thanks for that very comprehensive tutorial.  I'll be back to try it out.

I should say that I did not anticipate migrating the MySQL role as a part of the problem, but that information is useful anyway.

Offline LANMonkey

  • *****
  • 350
  • +0/-0
    • Database Collection of Transcripts for the ICTY
Works great!
« Reply #3 on: December 15, 2013, 11:37:21 PM »
I tried it out and your instructions work fine.  You have to be careful and identify where to make substitutions.

A few things were slightly disorienting.

For "On myserver.sme", step 3 and 4, don't you have to do that before step 1?  Or is step 3 and 4 just instructions for step 1?

Everything else was very tight.  I was especially pleased about step 5 for "On testserver.sme" where you restore the database.  ... but isn't the database on the original server still?  No, you moved it over with the rest of the files in step 4.

One of the things I did was change the name of the new iBay directory to a new name.  It worked OK for my Wordpress installation, but might cause trouble elsewhere.

Offline LANMonkey

  • *****
  • 350
  • +0/-0
    • Database Collection of Transcripts for the ICTY
Wordpress problems, but not due to these instructions.
« Reply #4 on: December 17, 2013, 09:07:40 PM »
....

One of the things I did was change the name of the new iBay directory to a new name.  It worked OK for my Wordpress installation, but might cause trouble elsewhere.

I am having some problems with the Wordpress migration, but the problems are clearly having to do with Wordpress identifying itself as being installed at a particular web root

Offline janet

  • *****
  • 4,812
  • +0/-0
Re: Wordpress problems, but not due to these instructions.
« Reply #5 on: December 18, 2013, 02:23:36 AM »
LANMonkey

Typically when you move software in the manner you are doing (even when on the same server to a different ibay), then you need to make adjustments to the apps config file eg wp.config or similar.
Further to that you would also probably need to login to the admin section of Wordpress & change settings there to suit your new server domain name & drive/file/ibay location etc.

PS It's also not much use telling us you have problems, we can only guess answers then & potentially waste our time.
You really need to be specific & tell us exactly what those problems are, & provide error messages, log file excerpts & so on.
Usually the source of the problem is identified in the error messages, so these are VERY important pieces of information to tell us if you seriously expect us to answer you.
« Last Edit: December 18, 2013, 02:44:52 AM by janet »
Please search before asking, an answer may already exist.
The Search & other links to useful information are at top of Forum.

Offline mmccarn

  • *
  • 2,653
  • +10/-0
Re: Wordpress problems, but not due to these instructions.
« Reply #6 on: December 18, 2013, 03:12:41 PM »
I am having some problems with the Wordpress migration, but the problems are clearly having to do with Wordpress identifying itself as being installed at a particular web root

There are lots of 'gotchas' to address when migrating wordpress to a new server. There are a couple places that wordpress stores the system URL, and you will have problems if the length of the site's URL changes from one server to the next (wordpress stores the length of each db entry at the beginning of the entry -- but if the length of the URL changes, so does the length of the entry).

You might be able to fix your problem using the wordpress export & import functions (in wp-admin under tools).
* migrate as described above
* follow up with a wordpress export/import

I had (lots of) fun writing a shell script to backup and adjust wordpress installs; my notes can be found here:
http://forums.contribs.org/index.php/topic,49233.msg245622.html#msg245622

Offline LANMonkey

  • *****
  • 350
  • +0/-0
    • Database Collection of Transcripts for the ICTY
This might deserve a new thread
« Reply #7 on: December 18, 2013, 06:09:21 PM »
Thanks all.

My basic concerns about migrating an iBay were more about the structure of iBays than the software that might be stored in those directories.  I assumed that the iBays might have something in SME's system that controlled the directories they represented.

The problems I am having with Wordpress are really a Wordpress issue and not an iBay issue.  I should also say, that I did not install my Wordpress using a contrib, but used Wordpress's own installation procedure.

I would also like to migrate my awstats which was installed with a contrib.  So migrating contribs might warrant a new dedicated thread.  I found that when I used a backup restore to migrate a system, my awstats did not continue where it left off with my old history, it started over with no history and so this data did not find its way into the backups.

Offline janet

  • *****
  • 4,812
  • +0/-0
Re: This might deserve a new thread
« Reply #8 on: December 18, 2013, 06:32:58 PM »
LANMonkey

You do not tell us or specify what backup & restore procedure you used.

A proper (standard sme) backup will include the data, so the data should be restored.
That is what happens in a normal sme server backup & restore.
IIRC the awstats data is stored in the admin users home folder, so did you backup & restore that ?

awstats data is specific to a domain name, so if you used a different domain name then the data will not be displayed.
I think I recall with some fiddly renaming you can change the data from one domain to another, but I would have to look again to recall more of what I did.

As far as data stored in an ibay is concerned, you can just copy the data off the server using local networking/samba, & then copy the data into whatever ibay on the new server, nothing special needed there (in it's most basic way of doing it). If you have an app or contrib installed, then the procedure gets more complicated, & each contrib/app may have specific requirements. Also there is data stored in mysql db's to consider, you need to dump tables to a sql files, then import that into the new server & marry the contrib with the database correctly etc etc.
Please search before asking, an answer may already exist.
The Search & other links to useful information are at top of Forum.

Offline LANMonkey

  • *****
  • 350
  • +0/-0
    • Database Collection of Transcripts for the ICTY
Re: This might deserve a new thread
« Reply #9 on: December 18, 2013, 07:54:04 PM »
LANMonkey

You do not tell us or specify what backup & restore procedure you used.

A proper (standard sme) backup will include the data, so the data should be restored.
That is what happens in a normal sme server backup & restore.
IIRC the awstats data is stored in the admin users home folder, so did you backup & restore that ?

I use the workstation backup offered in the Server Manager.  I see no options to choose what to backup.

As far as data stored in an ibay is concerned, you can just copy the data off the server using local networking/samba, & then copy the data into whatever ibay on the new server, nothing special needed there (in it's most basic way of doing it). ...

And this answers my original question.

Offline janet

  • *****
  • 4,812
  • +0/-0
Re: This might deserve a new thread
« Reply #10 on: December 19, 2013, 12:09:58 AM »
LANMonkey
Quote
I use the workstation backup offered in the Server Manager.  I see no options to choose what to backup.

That backup (& restore) method includes files in ibays, & files in the admin user home folder & data stored in mysql databases.
It does not by default include files in /opt folder, but can be modified to do so.
Also it does not include installed contribs that were installed using rpms or yum, but will include contribs installed to ibays eg web applications that you installed to ibays using tar.gz or zip packages etc.

When you do a full restore you should ALWAYS & ONLY restore to a clean freshly installed sme server OS. After the restore is complete you then reinstall contribs from rpm packages & they will use the restored data for the contrib, the only proviso being the contrib rpm pkg is the same or similar version, & no major changes were made to the application (eg that store or save data differently etc).

In the case of doing a selective restore in server manager, you nominate which file(s) to restore, so the process requires an understanding of the application files & associated data you are restoring.
This method could be prone to mistakes.

With awstats, IIRC the data is named in keeping with the domains being monitored, so if you change your domain name, then you will have to rename many files, depending how much data you have & how long awstats has been monitoring the domain.

You have provided insufficient information about how you did the backup & restore & what makes you think the old data should be available, to be able to comment further.

If backup & restore do not operate as expected, then you should really lodge a bug report & provide all details & follow through providing answers to further queries that may arise.
Please search before asking, an answer may already exist.
The Search & other links to useful information are at top of Forum.