Gallery2:How To Restore From Backup - Gallery Codex
Personal tools

Gallery2:How To Restore From Backup

From Gallery Codex


How to restore Gallery 2 from a backup?

  • Either you have a regular backup consisting of:
    • A database backup
    • A storage directory (g2data) backup from the same point in time as the database backup (including all files / directories within g2data, not just g2data/albums)
    • A backup of your config.php and optionally of your whole gallery2 directory
  • Or something bad happened and you only have your old g2data or just the g2data/albums folder

Then Gallery 2 can be restored from your backup. If you have just the g2data folder and not the database, then only the album structure with all images can be restored. The registered users, comments, customfields etc. are all lost if you don't have a database backup. Also, all item titles, summries, descriptions etc. are lost without a database backup.

If you have just a database backup and no g2data backup, you've lost all your albums and images. And G2 cannot be restored from the database only.

See:

Restoring Gallery 2 from a full backup

  • If you have a complete backup (database, g2data folder, gallery2 folder including config.php), then just put those things back in place and make sure the webserver user has write permissions on the g2data folder (chmod -R 777 g2data) and it should work again
  • If you have lost config.php or if your g2data backup is incomplete (only albums/ folder, or lost g2data/versions.dat file, ...) then...
    • you need to run the installer again, but point to your existing storage folder (g2data) and to your existing database in the appropriate installer steps (step 4 and 5).
    • In the setup storage directory step, it will automatically recreate the missing folders if there are any (locks, sessions, ...). Make sure the webserver user has write permissions on the g2data folder (chmod -R 777 g2data)
    • If you have lost or did not make a backup of g2data/versions.dat, you need to manually create a new one (or recover the first line). A versions.dat file is just a text file and has 2 lines, e.g.
1.0.0
Gallery-2.0

or something like that. The second line isn't important. The first line must be the version of your g2 core module. You can find the version in the database.

SELECT g_parameterValue FROM g2_PluginParameterMap WHERE g_pluginId = 'core' and g_parameterName = '_version';
    • In the Database Setup Step, enter the database connection information to use your existing Gallery 2 database. After hitting save, you should see 2 new options: "erase" and "reuse". Reuse will reuse your existing g2data/database and that's what you want. Click reuse. (Warning: Erase would delete everything in your database and in g2data and you'd lose everything).
    • And after the write config.php step (step 7), you can stop the installer and just browse to main.php. Your Gallery 2 should be up and running again.

Recovering Gallery 2 from the storage directory only

If you have lost everything but your g2data folder or just g2data/albums/ , then you can recover the whole album structure with all images with a few clicks

  1. Move your albums/ folder away into another directory
  2. Then install a fresh Gallery 2. Forget about your old g2data folder, it's of no use anymore (just make sure your old albums folder is in a safe place, outside your new g2data directory).
  3. After the installation has been completed, use the "Add items" -> "from local server" method to add the whole old structure with all albums and images.
See: How to Add items from the Local Server