Table of Contents

Restore a database backup

By default VPOP3 makes a daily backup of the VPOP3 database to a file 'DBBACK-n.DMP' in the VPOP3 installation directory (it is possible to change this in the settings). These are cycled on a weekly basis so you will usually have the last seven days' worth of backups. These can be useful if the database gets damaged somehow.

If you have a valid backup of the PostgreSQL database used by VPOP3, you can restore it by performing the following steps:

VPOP3 v5 or later

  1. Open a command prompt, and go to the VPOP3 directory
  2. If you are restoring the backup over an existing VPOP3 database (especially if the database files are damaged) you will need to DROP the database first.
    1. To do this, run pgsql\bin\dropdb -U postgres -p 5433 vpop3. When it prompts for the password enter the PostgreSQL master password - default pgsqlpass.
  3. Run pgsql\bin\pg_restore -U postgres -C -p 5433 -v -j 4 -d postgres <filename> where <filename> is the database backup you want to restore. When it prompts for a password enter the PostgreSQL master password - default pgsqlpass

VPOP3 v3 or v4

  1. Open a command prompt, and go to the VPOP3 directory
  2. If you are restoring the backup over an existing VPOP3 database (especially if the database files are damaged) you will need to DROP the database first.
    1. To do this, run pgsql\bin\dropdb -U postgres vpop3. When it prompts for the password enter the PostgreSQL master password - default pgsqlpass.
  3. Run pgsql\bin\pg_restore -U postgres -C -v -d postgres <filename> where <filename> is the database backup you want to restore. When it prompts for a password enter the PostgreSQL master password - default pgsqlpass

Keeping the old database

Sometimes you may want to keep the old database as well (if you have sufficient disk space), for example to be able to recover messages from it that have arrived since the last good backup.

In that case, run

pgsql\bin\psql -U postgres -p 5433

(default password is 'pgsqlpass')

Then

alter database vpop3 rename to vpop3_old;

Then, after restoring the new database, you can restore messages from it using the 'Restore' facility within VPOP3 (https://www.pscs.co.uk/manual/database_restore.html) by telling that to connect to the 'vpop3_old'. In recent versions of VPOP3 you can tell it to restore messages after a certain date (eg when the backup was made)

Then, after restoring all the messages from the old database, you can delete it to free up space, by running

pgsql\bin\dropdb -U postgres vpop3_old

(default password is 'pgsqlpass')