ZenPhoto Database Restore Issue

I'm running zenPhoto 1.2.8. I wanted to try out a newer version, so I downloaded the latest version (I know it says that it's not completely supported to do this). I created a backup (in the zenPhoto admin console) of my database.

I updated my installation and ended up having some problems, so I backed out the changes and attempted to restore the database from the .zdb file.

I initially got some errors about failures inserting into the zp_images table because of duplicate ids. I looked in the zdb file and didn't see any duplicates. So, I dropped all of the tables in the database, and let zenPhoto recreate them.

Then I tried the restore again.

This time, there were no errors, but the restore isn't correct. Titles and tags are now associated with incorrect photos. I looked in the zdb file again and see that, for an image with incorrect title and tags, the entry in the zdb file is correct.

There appears to be an error in the restore. Is there a way to "fix" this?

Comments

  • fretzl Administrator, Developer
    Restoring a database from a fresh install with a backup of an install that old does not work. Too many changes have been applied since.
    I updated my installation and ended up having some problems

    If you can tell what problems you ran into there, may be we can help you.
    So, just upgrade your "old" install as described here: `http://www.zenphoto.org/news/installation-and-upgrading#2`
    and post any problems you encounter.
  • fretzl Administrator, Developer
    Forgot to mention:
    For this to work you first have to install 1.2.8 again and use the database backup you made to get the database the way it was.
    Then proceed as above.
  • pecze Member
    I did re-install 1.2.8 and then restored the database from my backup. The issue appears to be that the image ids in zp_images table do not match the image ids in the zdb file. Something in the restore modified them.
  • If you restored from the Zenphoto backup the ids will necessarily match since the only data will be that from the time of the backup. The zdb file overrites the existing tables. But you can be sure by emptying the tables before you do the restore.
  • pecze Member
    I actually dropped the table before doing the restore.

    I think what's happening is as follows:
    The zp_images table is defined with id as unique and autoincrement. When the restore first happened, the table was emptied, but the mysql index counter was never reset, so the inserts failed because it thought that those IDs were already in use.

    So, I dropped the tables to get around this. Now, I'm wondering how mysql is handling each insert. I'm guessing that it's ignoring the id on the insert and assigning it's own unique id.

    What I'm trying now is having zenphoto create the tables, then removing the auto-increment from the zp_images table before doing the restore.
  • pecze Member
    Ok...So here's what I've found.

    Using ZenPhoto 1.2.8, I created a backup of my database. Everything was in there.

    Using ZenPhoto 1.2.3, the database restore didn't work for my backup file for whatever reason. (Titles weren't properly associated with images and tags weren't associated witht he correct images).

    I created a utility to parse the backup file and create mysql .sql files to restore the information.

    When I did that, my database appears to be back to where it was before I started this whole fiasco. (Titles and tags are fixed).

    What I gather from this is I'll never use the zen photo database backup/restore before attempting upgrades. I will use mysql to do that.

    For the ZenPhoto developers out there, I have over 18,000 images on my site and over 21,000 entries in my obj_to_tag database.

    I'm not sure if those large numbers caused problems for you backup/restore utility or not.
  • The backup restore facility has never been intended to be used across versions because it does not attempt to migrate the database, simply attempts to restore the data. I believe, by the way, that this is the gist of what fretzl told you--revert to the version of Zenphoto you were running when you made the backup and then do the restore.
  • pecze Member
    I apologize for the typo. That should have read 1.2.8, not 1.2.3.

    Here's what I did.

    1. Running 1.2.8, created a backup.
    2. Upgraded to 1.4.2. Encountered a few problems (I'm going to create a test install to see if I can weed these out).
    3. Reverted to 1.2.8 and attempted to restore the database backup. That's when I had all of my problems.
  • acrylian Administrator, Developer
    Well, once again, as decribed on the linked article:

    1. Backup the database from your old 1.2.8 install
    2. Install a new 2nd 1.2.8 in the new place
    3. Import the data from the old 1.2.8 to the new 1.2.8
    4. Upgrade the new 1.2.8 to 1.4.2.x

    If 4. does not work for some reason you should try to upgrade step by step. (Note we consider 1.x.x versions "medium major" releases.)
  • pecze Member
    I guess I'm confused. I did re-install 1.2.8. However, your step 3 (import the data from the old 1.2.8 to the new 1.2.8) is what is failing. I was able to get around it by writing my own utility, but, at least in 1.2.8, the restore function did not work with the zdb backup I created in 1.2.8.
  • The one step I did not see in the above discussions is how you recreated the database when you went back to 1.2.8. If you simply left in place the one from 1.4.2 then it would fail. You need to drop all the 1.4.2 tables before running the 1.2.8 setup. Otherwise you still have a 1.4.2 database that you are trying to load 1.2.8 data into.
  • pecze Member
    I tried several things.

    I dropped all of the tables in the database.
    I created an entirely new database.

    Each time I ran through the zenphoto setup (1.2.8).

    It created the tables, then I selected "Restore" from the next page (rather than set up admin account).
  • Are you on 1.4.2 now? Can you do backup/restore with it?
  • pecze Member
    No, I'm currently on 1.2.8. I'm going to do the incremental updates and backups through mysql. However, once I get to 1.4.2, I will try a backup/restore in my test gallery environment.
  • Thanks. I am sure you understand that we would not fix a problem that exists only in the old release.
Sign In or Register to comment.