Migrating Gallery2 from one host to another

apeacock

Joined: 2005-03-08
Posts: 14
Posted: Wed, 2005-03-09 02:18

I'm going to be changing hosts soon - I know I shouldn't have too many problems moving the site (just an sql dump), but I'm wondering - is there a way for me to go from using a MySQL backend on one site to a PostgreSql backend on another, without re-creating all all my albums?
----

Gallery URL (optional):
Gallery version: 2 CVS
Webserver (with version):
Datatabase (with version):
PHP version (eg 4.2.1):
phpinfo URL (optional):
Graphics Toolkit(s):
Operating system:
Web browser/version:
G1 version (for migration bugs):

 
volksport
volksport's picture

Joined: 2002-10-06
Posts: 239
Posted: Wed, 2005-03-09 06:19

you need the sql dump and all the files in G2DATA folder. G2data holds all the actual item files.

I'm not sure about moving from mysql to postgres though.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Wed, 2005-03-09 08:50

aren't there import and archive modules in the works? AFAIK one of them is on application level, so it should be independent of DBMS.

 
mayurpatel

Joined: 2005-08-15
Posts: 7
Posted: Fri, 2005-08-19 16:33

I actually just moved hosts. My new host moved over all the files for me including all the MySQL DB's. But, when my gallery install on my new host was finally up, I accessed it and it went straight to the upgrade (???). Went I tried to go through that, it complained of problems with some core files and complained about an inability to do something with the DB, even though nothing changed... even my DB names and passwords were the same. Anyway, luckily my install was just a test bed for a future gallery and no data loss occured. I just had to start all over with a clean install.

The reason I posted is that it looks like I will be moving ONCE again. My gallery is no longer a test bed and I don't want to lose data. What can I do to avoid this or what went wrong the first time?

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Sat, 2005-08-20 01:03

Follow these steps:
http://codex.gallery2.org/index.php/Gallery2:faq#How_can_I_move_my_gallery_installation_from_one_server_to_another.3F

and stick with FreeBSD or Linux based hosts. Using a Windows based host is only asking for problems.

 
Grey Mouser

Joined: 2006-06-22
Posts: 4
Posted: Tue, 2006-08-15 20:23

Those directions don't work for dick. I tried 4 freakin times.

dump the sql tables to a file
take the g2 data from old host to new host
extract g2 on new host
move g2data to right directory
chmod g2data
upload the sql to the right database
run the g2 installer, telling it to reuse the same db.

all of this, and i get broken thumbnails, broken image links and some of the admin features give me errors. a fresh install without migrating the g2data folder do not give me any of these.

it shouldn't be this difficult to migrate a damn gallery around.

 
pwilliewilson

Joined: 2004-04-22
Posts: 3
Posted: Wed, 2007-02-21 18:40

I'm getting the same problem after "successfully" migrating gallery from one machine to another - all the links are broken. I've done it no less that 8 times, all with the same results.

The image links show as:

http://127.0.0.1/gallery/main.php?g2_view=core.DownloadItem&g2_itemId=47&g2_serialNumber=7

How can I tell what directory gallery "thinks" it should be pulling these files from?

Note: in my last attempt I've placed the g2data folder in the web root to ensure that Apache had proper access to it.

Getting extremely frustrated here.

~ Patrick

 
jorgfe

Joined: 2007-02-11
Posts: 2
Posted: Sun, 2007-02-25 02:34

I just had a situation where I decided to rename the directory that gallery2 was located in for a new setup that had about 300 pictures in it. I needed to move it from http://mysite.com/g2/ to http://mysite.com/s/g2/ on the same website account. Since it was on the same hosting account there was no need to rename the database that it was using, but if I had been migrating it to another *nix hosting account the process would have gone much the same. The move was successful, and easy to do. This is what I discovered along the way.

1. There should not be any reason to change a thing in your mySQL database for the Gallery2 tables. The only references I found to my old directory path were text descriptions in the table `g2_MaintenanceMap` that are recorded when you flush the cache, etc, as a site administrator. If you are just renaming the Gallery 2 directories, but keeping them on the same website, there is no reason to even touch the database.

2. ***BEFORE*** renaming (perhaps via FTP) the directories that Gallery2 programs and data (albums, etc) are located in, be sure to go into Site Admin | Admin Options | Modules, and deactive both URL Rewrite and Permalinks. In addition, I de-installed the two so I would no that there was no old references sitting around. Be sure to note any special permalink settings that you want to reactivate later. (After the rename process is complete I reactivated and reconfigured them.)

3. Guess what? The URL Rewrite process will leave a .htaccess (rewrite) file in your /g2 directory. If you have any question why your past migrations have failed with broken links, etc, a quick look at the /g2/.htaccess file may help to explain it! It has numerous references to directories, etc, and is custom generated when you initially activate URL Rewrite and Permalinks in Site Admin. BE SURE to rename it to something like .htaccessx so it will no longer be active. If Apache sees it, Apache will use it -- even if you have URL Rewrite turned off in Gallery!

4. The lone reference to where your G2 data directory is located is in /g2/config.php on the line that starts out "$gallery->setConfig('data.gallery.base',". If this is not pointing to a valid set of files when you run Gallery2 it will ask you if you want to do an upgrade. It would appear that all you have to do if you want to move your G2 data directory is to 1) move it, and 2)also change this reference in config.php.

5. Next rename your Gallery2 URL. In my case, I changed it from http://mysite.com/g2/ to http://mysite.com/s/g2/. I did this by using FTP to create a directory called "s", and then moved the g2 directory inside of it. Since this was a brand new site, I wasn't worried about user's browser references to the old links. If I had been I could have created a 404 page, and used a .htaccess at the webroot to capture "page not found errors" and redirect to the new URL.

6. Access your existing copy of Gallery2 at its new URL, eg http://mysite.com/s/g2/ and log in as admin. All your thumbnails and pictures should display fine.

7. As admin, go into Site Admin and reactivate URL Rewrite and Permalinks and set them to the original values. This will write out a new /g2/.htaccess file.

8. Rerun your Site Admin Maintenance functions to clear the old caches, sessions, etc.

If you understand the logic behind the steps listed above, the process should be pretty straight forward and simple.

If you are at all unsure of what you are doing, be sure to make a backup first. In my case I was just moving the g2/ directory and so I only had to "touch" one file -- the custom configured /g2/.htaccess file which tells Gallery2 where to find everything ***IF*** Rewrite URL has been previously turned on. Remember that if an old copy of this file even exists as /g2/.htaccess, Apache will try to use it. That is most like the major problem occuring in the other posts listed above.

The process listed above took me about 15 minutes for a second site that I did this to. The first one took me about 1 hour to figure it out.

If you still have questions feel free to PM me.

Gilbert Jorgensen

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sun, 2007-02-25 15:45
 
jorgfe

Joined: 2007-02-11
Posts: 2
Posted: Sun, 2007-02-25 15:49

Very nice, valiant! Much more succinct than my instructions. :)

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sun, 2007-02-25 15:57

Too bad we had the instructions already :) But contributions for G2 docs are sure welcome!
In case you want to document other things, I suggest you do a quick google search (or use the "search" link on this website) to see there's already something about it.
And our wiki at codex.gallery2.org is usually a better place to write, organize and find docs.
Thanks!

--------------
Doumentation: Support / Troubleshooting | Installation, Upgrade, Configuration and Usage

 
pwilliewilson

Joined: 2004-04-22
Posts: 3
Posted: Mon, 2007-02-26 02:01

In his write up jorgfe included a much needed piece of information - to go into the site admin and rerun the functions to clear the old caches, sessions, etc. After I did this all of the image links became functional again. This was the critical piece of information that is missing from the FAQ.

Yes indeed I'd seen the FAQ and read it about 20 times in between pulling my hair out as to why it was not working. In my humble opinion the step about rerunning the admin functions should be included in an update FAQ, it would have certainlt saved me a few hours of frustration.

Thanks jorgfe.

~ pwilliewilson

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Mon, 2007-02-26 02:33
Quote:
In my humble opinion the step about rerunning the admin functions should be included in an update FAQ,

Can you update the docs for us? Thanks

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team