# Coppermine Photo Gallery v1.5.x: Documentation and Manual

# Backup & Export

This page is meant to explain how to back up a coppermine-driven gallery and how to use the export tool. Those two things must not be mixed up: they are entirely different things, although the use of both tools overlap - that's why the instuctions reside on one page.

## Decide for one method

The decision wether you need to back up or to export depends on what you want to do with the data afterwards: backups can be used to restore your gallery somewhere in case something goes wrong (i.e. server hard-drive crash, hacking, own mistake) or if you want to move (move servers, move to another webhost, use another application). Exporting on the other hand is mainly used to get content that is currently only stored in your gallery somewhere else (e.g. your local PC) without all the clutter and additional information that is needed to maintain the gallery, i.e. if you only want the pics (or whatever content you store in your gallery).

## Backup

Coppermine stores content both on file system level (i.e. on your webspace - that's the hard drive of your webserver) as well as on database level. Think of the database as a giant array of tables that are connected one with the other. Although the database is (technically) being stored in files as well, you can't just backup the file that represents the database. This is being caused by the way that a database works. Additionally, you usually don't have access to the file that represents the database (but don't start the wicth hunt and try to find it - you wouldn't be able to use it anyway). That's why the backup process needs to be two-fold: you need to back up your files and you need to back up your database. Only backing up one of them without the other will result in an incomplete backup that hardly can be usefull.

### File Backup

The backup on file system level is pretty straightforward and you already should be familiar with the technology, assuming that you have installed coppermine in the way the coppermine dev team recommends: using your favorite FTP application. Do not trust buggy tools integrated into WYSIWYG editors. Do not trust wannabe "web-FTP" clients: you need the real thing - a genuine FTP client. If you don't have one already, get one first before continuing.

#### Complete File Backup

The term "complete file backup" means in this case "a file backup of the entire coppermine gallery". It's advisable to perform this at least once, so you have a full backup for disaster recovery.

To actually perform such a backup, create a folder on your local hard drive first. Of course you need to make sure in advance that there is enough room left on the storage device you use (your internal or external hard drive in most cases) to hold the entire gallery once the backup is done. If you're short on disk space on your client, you could burn the contents of your backup to a CD or DVD once your backup is complete and then free the precious hard drive space once you have copied everything to CD/DVD.

#### Partial File Backup

If you perform frequent backups you don't have to make a complete file backup each time, as the coppermine core code will (i.e. all the files that make coppermine work on the server) will not change from one backup to the other. That's why you can then perform a partial back, i.e. only the contents of the albums folder of coppermine that corresponds to `http://example.com/your_coppermine_folder/albums/`. If you need to perform a restore later, you will have to restore your complete backup first and then restore your partial backup that was created later and therfor is more accurate and recent.

#### Incremental File Backup

There are nifty tools available from third parties that will perform an incremental backup by FTP, i.e. they will only backup the files that are new or have changed since the last time the backup was performed. This will reduce the time needed to perform a backup dramatically, but on the other hand will make restoring after a disaster a bit trickier - you should only use that option if you know what you're doing.

### Database Backup

Coppermine creates during initial install several database tables that are being used to store the content:

- The pictures table stores the path on file system level to the content of your gallery (i.e. the images)
- The config table stores your configuration
- The users table stores data about your registered users (including the admin account)
- ...

There are many other tables that store specific aspects of the content of your gallery - for a complete list of all tables and the structure within them, take a look at the database schema. All relevant tables of a coppermine gallery have the same prefix - the one you chose during initial install. To perform a database backup, make sure to backup all coppermine tables, i.e. all that have the prefix you chose during install. If you're not sure about the prefix, download the file include/config.inc.php with your FTP app to your client and then edit/view it using a plain text editor (notepad.exe is fine): the prefix should be named there. By default, the prefix name is `cpg15x_`.

#### Database Backup: what needs to be backed up?

The wording may differ, depending on the tool and it's version you use to perform the backup, you you need to know what exactly to backup.

A full database backup contains both the structure of the database table definitions (i.e. the "instructions" needed to create the empty tables if they have been lost or need to be created on another server) as well as the data (i.e. the actual table content).

The tables coppermine consists of are not equally important though:

- The table cpg15x_hit_stats can become quite large if you have enabled the feature "Keep detailed hit statistics". Subsequently, the backup can become quite large if the contents of that table is being taken into accound during frequent backups. Escepcially when moving a coppermine install from one server to the other it might be a good idea to skip the detailed hits statistics and therefor not backup the contents of this particular table.
- The table cpg15x_sessions tracks sessions for logged in and anonymous users. It gets populated automatically if it is empty, so you don't necessarily to back it up.
- The table cpg15x_temp_messages is used to store messages from one page to the other - the content is very short-lived and will be purged frequently, so the table doesn't need to be preserved when performing frquent backups.

Keep in mind though that coppermine will complain (i.e. there will be an error message) if a table is missing, so you need to create the above-mentioned tables in the first place, but they can be empty.

#### Database Backup Tools

Coppermine does not come with a database backup tool - you need to find one by yourself and use that. However, there is a list of tools the dev team recommends:

- ##### phpMyAdmin

  Open-source web application for database management that can be downloaded (for free) and installed on your webserver (easy installation). It comes with multiple language support. Your webhost may even provide this tool.
  [more]

  Please note that the coppermine dev team can not support you on the usage of phpMyAdmin - so here's just a short summary that is not meant to be a replacement for the documentation for phpMyAdmin:

  - Point your browser to the URL where your copy of phpMyAdmin resides (assuming that you have successfully installed phpMyAdmin on your webspace or that your webhost is providing phpMyAdmin for you)
  - If applicable (i.e. if the security settings of phpMyAdmin are configured accordingly), provide your phpMyAdmin login data if you're prompted for it
  - If applicable (i.e. if you have access to several databases), select the database where your coppermine database tables resides in (the database you have selected when installing coppermine) from the top left frame in the phpMyAdmin interface
  - In the right phpMyAdmin frame at the very top, select "Export" from the navigation
  - On the screen "View dump (schema) of database", select the tables you want to backup (by default, all tables within the selected database are selected) from the box labelled "Export". If you're not sure, back up all coppermine tables, i.e. all tables that have the same table prefix that you specified when installing coppermine in the first place
  - In the "Export" box, leave the radio button "SQL" selected that is already selected by default
  - Make sure that the checkbox "Structure" is ticked
  - Do not tick the checkbox "Drop table" - dropping means "deleting the table after the backup is complete", which is something you almost certainly would not want to happen, as coppermine would stop working immediately and you'd have to perform a restore.
  - Make sure that the checkbox "Data" is ticked
  - It's advisable (although not mandatory) to tick the checkbox "Complete inserts"
  - It's advisable (although not mandatory) to tick the checkbox "Extended inserts"
  - It's advisable to tick the checkbox "Save as file" that will give you a file to download instead of just getting the output of the dump displayed on screen that you would then have to copy & paste into a plain text file.
  - If you're running into time-outs while creating the database dump, try enabling compression for the file (you can of course only use the compression format that is available on your webserver)

  If you're not sure, read the documentation that comes with phpMyAdmin and google for backup tutorials on the internet; the coppermine support board is not the correct place to ask for support on phpMyAdmin usage.

- ##### mySqlDumper

  MySqlDumper is a web app that can be downloaded and installed on your webserver. It is meant to be used to create backups of your mysql databse (and eventually restore those backups). Particularly helpful if you don't have shell access to your webserver and regular mySQL backups fail due to time-outs.
  [more]

- ##### mysqldump

  The tool mysqdump must not be confused with mySqlDumper or vice versa: mysqldump is a script that belongs to the mysql resources themselves that only applies (i.e. that you can only use) if you have shell access (which is rarely the case for most, webhosted users). [more]

- ##### mysqlhotcopy

  The Perl script mysqlhotcopy belongs to the mysql resources. It is the fastest way to make a backup of the database or single tables, but it can be run only on the same machine where the database directories are located. mysqlhotcopy works only for backing up MyISAM and ARCHIVE tables. It runs on Unix and NetWare. [more]

#### After the database backup

After performing the manual database backup it's important to make sure that the dump you just created works as expected. Therefore, you should really try to open the dump file first and see if it not broken. Ideally, you should perform a restore on a testbed to make sure everything works as expected.

There have been many users already who relied on their backup without ever having tested it once: if you never test your backup strategy, you will never know if it will enable you to perform the restore in case of a disaster. Since there are many things that can go wrong, it's really recommended to test your backup.

## Exporting

A new feature has been added in cpg1.5.x that will allow the admin to export the content of albums as HTML pages or as plain images. To access the feature, choose "Export" from the admin menu or manually point your browser to `http://yoursite.tld/your_coppermine_folder/export.php`

The feature is admin-only: regular coppermine users can not access it: they will see an error message if they try.

### Scope

The export feature is not a backup tool to enable you to restore your gallery if something breaks. Instead, it is basically meant as a tool for the admin to easily export content uploaded by others (i.e. your users).

### Usage

Using the feature is pretty straight-forward:

- Choose the export type. Possible options are HTML-embedded files or just the images
- Choose the album to export
- Submit the form by hitting "go"

### Preparations

The third option provides you with an input field to specify the folder where your exported files are supposed to reside. You have to create this folder in advance (using your FTP application) and make sure that it is writable for the script (as suggested in the permissions section of the docs).