Hello everybody!
I had a G1 working with more than 1,500 albums and more than 100,000 photos, it was installed inside PHP Nuke but the thing is that I tried to migrate all that into a stand alone G2 but everything got messed up, so right now it's impossible to migrate using the methods provided.
However, I was able to get all albums' folders' paths inside a PHP array and to generate a RSS XML with all additional data such as albums' titles, etc.
So, my plan is as follows: 1st. Create all albums (empty) in G2 using the information I have from the XML file, 2nd. Copy or Import all photos from each G1 album folder to the new locations created in G2.
What I need from you guys is the PHP code to load the G2 core into a plain PHP file and the correct G2 function to create an album inside another. I just want the new album to have the same title from G1, the creation date and if possible the description, I don't care about anything else like thumbs, views, comments or whatever... all albums will be public so no need for users permissions or anything, just a plain album with default settings... from that I think I could do the rest.
I have created some empty albums representing a year (2009, 2008, 2007...) It's inside these albums where I'm going to create the new ones according to the creation/publication date of the G1 albums.
The pseudocode would be:
<?php
Load G2 core code // what I need from you;
Do Loop from XML data {
Call G2 function to create album() // What I need from you;
}
Do Loop from Folders Array {
Copy photos to new location
OR
Call G2 function to add each photo to and album();
}
?>
G2 version: 2.3.1
PHP memory limit: 512MB
--
PHP version (e.g. 5.1.6): 5.2.12
Webserver (e.g. Apache 1.3.33): Apache/2.2.14
Database (e.g. MySql 5.0.32): MySQL 5.0.91
Activated toolkits (e.g. NetPbm, GD): NetPbm, GD, ImageMagick
Operating system (e.g. Linux): Linux
Posts: 8339
Gallery will already import whole directory structures as albums/image, preserving album/sub-album/item...
http://codex.gallery2.org/Gallery2:How_to_Add_Items#How_to_Add_Items_from_the_Local_Server_.28or_with_FTP.29
but:
http://codex.gallery2.org/Gallery2:API
I think adding the entire directory structure through serverAdd mentioned above would be better.
Then you could search through albums editing title, description, summary...
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 16504
Ouch, seriously 1500 albums and more than 100k of photos in G1? Let me guess, it's slow as molasses?
I don't know what php code you'd need and I'm not sure why you'd want to do it the way you're thinking as it still seems like it would run into probably the same resource limits you hit when trying to do the G1 import. Do you know if the G1 -> G2 import is stopping/crashing even before the import starts and while G2 is still reading data from G1? I can see that as a reason to try what you're thinking.
A few suggestions and these still probably won't get over the problems you're running into because to get photos/albums into G2, the photos still need to go through the "import/add item" process and the albums need to go through the "add album" process.
First, in G2, switch to just using the ImageMagick for graphics toolkits and uninstall GD and NetPBM. I'd do this no matter what.
- You could try backing up your G1 install and migrating it to G2 on a different system with a lot more resources and no limitations (like a local workstation)
- You could using G2's Add Items module that adds a "From Local Server" method:
http://codex.gallery2.org/Gallery2:How_to_Add_Items#How_to_Add_Items_from_the_Local_Server_.28or_with_FTP.29
http://codex.gallery2.org/Gallery2:Modules:itemadd
You might still run into timeouts trying to import the whole thing at once.
- Take a look at this user contribution for adding photos via a cron job:
http://gallery.menalto.com/node/81010#comment-284733
That script may help out a lot.
- There's also a Bulk Upload tool, I believe it's only available from the Downloadable Plugins. In G2, go to Site Admin > Plugins > Get More Plugins
http://codex.gallery2.org/Gallery2:Modules:bulkupload
You can feed that a formatted file (not XML, but xls or tab delimited text file)
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here
Posts: 5
Hey guys, thanks for you comments...
My boss is the one to blame for this mess... He tried to migrate G1 to G2 a couple of times without backing up the data nor setting a proper environment, so everything crashed!... We ended up having some albums data lost, albums that are not *found* by G1 but all files still exist (including *.dat)... that's why I have to rely on file system structure...
That said, yes, I tried to import the directory/files structure using Gallery features and plug-ins, but the problem is that it doesn't import the titles, description, etc. (which I have in the XML) and then as one of you said, I would have to search through albums editing title, description, summary... and I'm not kidding when I say I have more than 1,500 albums to fix, we're talking about 30GB of data! that's why I want something more automatic even though I know I will have to do some manual adjustments anyways...
I gave a quick try to suprsidr's code and after playing around a bit I did created an album and added a photo to it, so it must work when I put everything else together, I found some good ideas in the links provided by nivekiam...
If I remember well a problem I had using the "From Local Server" method was that G1 put together all versions of the same photos (including their thumbnails) inside their album directory, so I couldn't just select all files and process them, I had to select one by one the originals... and it's a matter of volume: +100,000 files!
Anyways, I'll try to get something going in the following days and I'll let you know how everything went.
Thank you again!
Posts: 16504
G2 only reads from G1 on that import, there is no modification of data (at least there shouldn't be). Most likely because your G1 install is so damn big is that those files were quite possibly corrupt to begin with, but it's hard telling and I'm only making guesses there. Here is a very detailed guide for migrating G1 to G2 and there is some prep you need to do with G1
FAQ: Can I update from G1 -> G2?
So possibly some of the prep steps were missed or on a G1 install that big the prep steps might have actually corrupted some of those files. At least it does sound like you have the data you need/want in XML format.
Yeah, forgot about that. That would mean deleting/moving the thumbs and resizes or copying/moving the full sizes else where and importing from there.
I will be curious to see how it goes and what you end up doing.
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here