Gallery restore from backup

dargaud

Joined: 2008-02-13
Posts: 33
Posted: Tue, 2011-10-25 21:37

Hello all,
so I needed to do a full system reinstall. Fine.

I backup Gallery2 from the interface (it creates a file g2data/backups/gallery2...xml). I also keep the /var/www/gallery structure and its config files.

I also backup the entire sql structure. Maybe I shouldn't have, I can't restore it without errors: hundreds of megs, plenty of users, databases, a mess. Maybe I can extract the part specific to G2, but I have no idea how to do that.

I of course keep a copy of the g2data directory.

Now I've read this, but nowhere in it does it say how to restore from the g2data dir and the backup xml file. Trying to piece it together, it seems that you reinstall and then restore the file. But when I reinstall but running the install script again, I get to a point where it says 2.3: "The G2 storage directory has a versions.dat file of an old install. But the Gallery database tables don't exist. Select a clean install to erase all data in the Gallery storage directory and advance to the next step." I don't think I want to [Erase data for a clean install] !

Should I install instead into an empty g2data directory and then copy everything into it and then import the xml file ?

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Tue, 2011-10-25 23:43

simply install gallery2 to your target location.
after its working to your liking, edit gallery2/config.php to point to your old g2data and your old DB creds.

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
dargaud

Joined: 2008-02-13
Posts: 33
Posted: Wed, 2011-10-26 05:27

I can't restore the DB itself. Is the xml backup a replacement, and if so how do you use it ?

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Wed, 2011-10-26 05:34

to restore a gallery xml backup, head to yoursite.com/gallery2/lib/support/

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
dargaud

Joined: 2008-02-13
Posts: 33
Posted: Wed, 2011-10-26 08:28

Thank you, this is exactly the info I was looking for. Why isn't it mentionned on the 'restore from backup' page ?

But when I do it, this happens immediately:

Quote:
Errors Occurred
Error (ERROR_STORAGE_FAILURE)
in modules/core/classes/GalleryStorage.class at line 495 (GalleryCoreApi::error)
in modules/core/classes/Gallery.class at line 209 (GalleryStorage::search)
in modules/core/classes/helpers/GalleryPluginHelper_simple.class at line 317 (Gallery::search)
in modules/core/classes/helpers/GalleryPluginHelper_simple.class at line 222 (GalleryPluginHelper_simple::_fetchAllParameters)
in modules/core/classes/GalleryCoreApi.class at line 302 (GalleryPluginHelper_simple::getParameter)
in modules/core/classes/GalleryStorage/GalleryDatabaseImport.class at line 243 (GalleryCoreApi::getPluginParameter)
in modules/core/classes/GalleryStorage/GalleryDatabaseImport.class at line 194 (GalleryDatabaseImport::_doStatusCheck)
in lib/support/import.php at line 140 (GalleryDatabaseImport::verifyVersions)
in lib/support/import.php at line 74
in lib/support/index.php at line 18

I see nothing obvious in there.

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Wed, 2011-10-26 12:42

So your backup is from a pre 2.3.x version?

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
dargaud

Joined: 2008-02-13
Posts: 33
Posted: Wed, 2011-10-26 15:15

No, the version is exactly the same as the one before. It's the same /var/www/gallery/ directory which I just copied back, no change at all.

$ grep gallery-version g2data/backups/gallery2_f50b5_2011_10_22_2329.xml
<export schema-version="1.1" tables="47" core-version="1.3.0.1" gallery-version="2.3.1">

$ cat g2data/versions.dat
1.3.0.1
2.3.1

$ grep release /var/www/gallery/*
Gallery/README.html: Welcome to Gallery 2. This is the official release of Gallery 2.3.1,

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Wed, 2011-10-26 15:24

is the database name same as the prior install?

I've actually never used this function, I always restore from SQL exports.
The latest phpMyAdmin can handle xml imports as well.

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
dargaud

Joined: 2008-02-13
Posts: 33
Posted: Wed, 2011-10-26 21:07

I've tried restoring without any database/user present. And I've tried with the same database and user. Same error message. Like I said the complete backup I did of the database failed on restore (it was a lot more than just my Gallery). Now I've rebuild some of the rest from other sources, and I don't know how to extract a single database from a complete backup. I thought that was a job for the xml file. Does it expect to find a database+user already ?

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Wed, 2011-10-26 21:35

looking through one of my G2 backups it looks like the plugin status check is making sure the same plugins are installed/active
check yours.

If all else fails I have a method that has helped others.

suprsidr wrote:
My importXML.php script crawls your gallery and compares filename and filesize to that of a gallery xml backup and will import the title, description, summary...

http://gallery.menalto.com/node/94122

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
dargaud

Joined: 2008-02-13
Posts: 33
Posted: Fri, 2011-10-28 07:51

OK, I did a clean install: both from an empty database, empty g2data dir and fresh /var/www/gallery. Then I substituted with my full g2data dir and old (but same version, same passwords, etc) /var/www/gallery. I went to reimport my xml backup and this time it completed successfully.

Clicking on [continue] brought "Maintenance - Site is temporarily down for maintenance". And then the login box. When I login, I'm still in an empty gallery. No images at all.

I do an admin login, remove [Maintenance mode], [Optimize database] but still nothing. All the images are still present in my g2data dir. What happened ? Why isn't the backup restored ? Is there a log of the restore process ?

 
dargaud

Joined: 2008-02-13
Posts: 33
Posted: Fri, 2011-10-28 14:18

I also tried your importXML.php script. It said "Done!" immediately, no error in /var/log/apache2/error.log, but still the gallery remains empty...

Your script did about 47 iterations in the $items loop, 3 iterations in the $relevantTables loop and 12100 iterations in the $entities loop. But then the $ids loop is never executed. I assume $ids is empty.

The database is populated with lots of g2_* tables, but whether they have been modified since the clean install is an open question (I have phpmyadmin installed so I can look some up if you wish).

Thanks.

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Fri, 2011-10-28 22:43

your restored g2data must be readable/writable recursively.
chmod _R 0777 /path/to/g2data

Also check that the g2_Entity table has been populated with all your data

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
dargaud

Joined: 2008-02-13
Posts: 33
Posted: Sat, 2011-10-29 16:02

The g2data dir has correct permissions (www-data user, 755 on dirs, 644 on files).

The g2_entity table contains 9 lines with the columns named g_id g_creationTimestamp g_isLinkable g_linkId g_modificationTimestamp g_serialNumber g_entityType g_onLoadHandlers

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Sat, 2011-10-29 17:49

so your import did not succeed as there should be an entry for each photo you've ever uploaded

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Sat, 2011-10-29 17:56

my importXML.php works like this:

  • Using the server add method, you import all your photos from your old g2data/albums directory
    this method works well as it will keep your album structure the same ass the old gallery, respecting directory relationships.
  • edit line 14 of importXML.php providing full system path to your backup.xml file
  • upload impostXML.php to your gallery2 directory and visit w/ a browser.

If all goes well, my script should transfer title, descriptions, keywords to your gallery items.

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
dargaud

Joined: 2008-02-13
Posts: 33
Posted: Sun, 2011-10-30 08:40

Should the path pointed by line 14 be the same as the g2data directory already set in the config.php file ? I assume your script updates the database without touching the g2data image store.

I've been adding print statements to your code to try to figure out what's missing, but if I know a bit of Php+Sql, I don't know anything about the internals of Gallery2.

I just don't know what to think when 3 different methods of backup restoration all fail.

I'll be off the grid for the next 3 weeks. Hopefully you'll still be willing to give me a hand when I get back !