4 4 3:PostgreSQL Restore
The restore of PostgreSQL database(s) is quite similar to a regular file system restore. SEP sesam enables you to restore all or only one database from a PostgreSQL server, provided that it was backed up with a separate backup task.
Before you begin, check that all the prerequisites are met.
- PostgreSQL restore is simple, guided and similar to a regular file system restore.
- You can restore the PostgreSQL database(s) to the original or to a new location.
- There are two ways to restore PostgreSQL database(s) in SEP sesam: via the GUI restore wizard or via the web Restore Assistant (as of v. ≥ SEP sesam 5.0.0 Jaglion V2). Although most options are the same in both restore interfaces, the web Restore Assistant interface is more intuitive and offers additional advanced options.
- Scheduling restore is only supported in GUI mode. For details, see Scheduling Restore.
Before performing PostgreSQL restore, check the following prerequisites:
- For a successful restore, all preparation steps must be performed properly. For details, see PostgreSQL Backup.
- Depending on what you want to restore, make sure you have the required restore permissions and access rights. For details, see User Roles and Permissions.
- Make sure that there is sufficient free space on the target system to which you are restoring your data.
Depending on the interface you are using, follow the appropriate procedure to restore PostgreSQL DB:
Restoring a single database (DB)
|To be able to restore a single DB from a PostgreSQL server, you have to create a separate backup task for each PostgreSQL DB. If the PostgreSQL source in the backup task is set as all, you cannot restore an individual database. For details, see PostgreSQL Backup.|
PostgreSQL restore via the GUI
Create a new restore task for the PostgreSQL saveset you want to restore.
- From the SEP sesam GUI menu bar, select Activities -> Restore. The New Restore Task window opens.
- Select what you want to restore. You can search savesets by task name or by filename or path.
- Under the Saved in period drop-down lists, specify the time frame for which you want to conduct the search. Click Next.
- The search results are displayed. From the list of savesets matching your query, select the version you want to restore. Click Next.
- Under the Target Settings, set additional options.
- Under the Target path settings, select one of the following options:
- Restore to original target path (set by default): Restores the data to the same location from which it was backed up. If it is set together with the option Overwrite existing items the target database will be deleted first and a new one will be created from the backup saveset.
- If you select the option New restore target and enter a new database name, the PostgreSQL command createdb creates a database with the specified name. The data is imported into the new database.
- Under the Execution options drop-down list, select one of the following options:
- Do not overwrite existing items (set by default): The database will not be restored if it already exists on the target server.
- Overwrite existing items: If the database exists on the target server, it will be replaced by the restored version.
- Auto recover (and online) after restore: The data will be stored directly into the database without caching in the file system. Because the data is written directly into the database, it is not possible to modify it.
- No recover after restore: Use this option if you want to modify the data before you import it into the database. The restored data will be stored on the file system first. The import of data has to be started on the command line interface of the server's operating system. The data will be written as a dump file onto the file system (usually in the directory <SESAM_VAR>/work). You can use this file as input file for the PostgreSQL program pg_restore as follows:
|You have to set up database users and roles before the database is imported to new target.|
su - postgres pg_restore template1 -C /var/opt/sesam/var/work/pgsql-SF20081128224529.tmp
|The Expert Options button for specifying advanced restore options is available only in advanced UI mode (formerly expert GUI mode). To use Expert Options, make sure your UI mode is set to advanced. For details, see Selecting UI mode.|
A restore task can be scheduled like any other task. If you want to add a restore task to the schedule, see Scheduling Restore.
PostgreSQL restore via the Restore Assistant
You can access the Restore Assistant in one of the following ways:
- via the GUI: by clicking the Restore Assistant icon in the toolbar or from Activities -> Restore Assistant
- from SEP sesam Web UI: left menu -> Restore Assistant
- or by entering the following address in the browser bar: http://[sesamserver]:11401/sep/ui/restore/.
With the web Restore Assistant, you can restore PostgreSQL DB to the original or another location using simple or advanced UI mode. When using advanced UI mode, an additional Options tab is available for setting advanced restore options. You can also restore backup into dump file and restore the data to a single file rather than to original location. In this case, you must specify a restore destination path in the Target window (by browsing or typing the path). Optionally, you can also change the name of the dump file. If the dump file name is not specified, it is generated automatically. For more details, see Restore Assistant.
|You can only restore one database if it was backed up alone, with one task per database.|
You can monitor the restore progress using the Web UI (Monitoring -> Restores) or view the status in the GUI (Main Selection -> Job State -> Restores). The restore overview provides detailed information on the last run of restore jobs, including task name, status (successful, error, in queue...), start and stop time of the last backup, data size, throughput, etc. For details, see SEP sesam Web UI or Restores by State in the GUI.
|In case of errors during the restore (e.g., primary key error), the restore status in the SEP sesam GUI/Web UI is displayed as erroneous. In such a case, check the restore protocol and the data in the database.|
If you have problems with PostgreSQL, check the Troubleshooting Guide.