how_to:restore_a_database_backup

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
how_to:restore_a_database_backup [2013/09/23 13:35] – [Restore a database backup] paulhow_to:restore_a_database_backup [2025/12/17 09:19] (current) – [VPOP3 v3 or v4] paul
Line 5: Line 5:
  
 =====VPOP3 v5 or later===== =====VPOP3 v5 or later=====
 +  - If the VPOP3 service is still running, then stop it first from the Windows Services app. (Do NOT stop the VPOP3DB service)
   - Open a command prompt, and go to the VPOP3 directory   - Open a command prompt, and go to the VPOP3 directory
   - 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.    - 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. 
Line 11: Line 12:
  
 =====VPOP3 v3 or v4===== =====VPOP3 v3 or v4=====
 +  - If the VPOP3 service is still running, then stop it first from the Windows Services app. (Do NOT stop the VPOP3DB service)
   - Open a command prompt, and go to the VPOP3 directory   - Open a command prompt, and go to the VPOP3 directory
   - 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.    - 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. 
Line 16: Line 18:
   - 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**   - 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')
 +  
how_to/restore_a_database_backup.1379943320.txt.gz · Last modified: 2018/11/14 10:44 (external edit)