This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| how_to:restore_a_database_backup [2010/09/21 08:29] – created paul | how_to:restore_a_database_backup [2025/12/17 09:19] (current) – [VPOP3 v3 or v4] paul | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ======Restore a database backup====== | ======Restore a database backup====== | ||
| + | By default VPOP3 makes a daily backup of the VPOP3 database to a file ' | ||
| + | |||
| If you have a valid backup of the PostgreSQL database used by VPOP3, you can restore it by performing the following steps: | 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===== | ||
| + | - 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 | ||
| + | - 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. | ||
| + | - 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**. | ||
| + | - Run pgsql\bin\pg_restore -U postgres -C -p 5433 -v -j 4 -d postgres < | ||
| + | =====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. | ||
| - | - To do this, run pgsql\bin\dropdb -U postgres vpop3. When it prompts for the password enter the PostgreSQL master password - default pgsqlpass. | + | - To do this, run pgsql\bin\dropdb -U postgres vpop3. When it prompts for the password enter the PostgreSQL master password - default |
| - | - Then you will need to recreate the database - run pgsql\bin\createdb -E SQL_ASCII -O vpop3 -U postgres vpop3 | + | - Run pgsql\bin\pg_restore -U postgres -C -v -d postgres |
| - | - Run pgsql\bin\pg_restore -U postgres -C -d vpop3 DBBACK-<number>.DMP where <number> is the latest number of the database backup | + | |
| + | |||
| + | =====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 ' | ||
| + | |||
| + | Then | ||
| + | alter database vpop3 rename to vpop3_old; | ||
| + | |||
| + | Then, after restoring the new database, you can restore messages from it using the ' | ||
| + | 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 ' | ||
| + | | ||