Re: Restoring database from backup

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Rich Shepard <rshepard(at)appl-ecosys(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Restoring database from backup
Date: 2024-12-13 19:23:31
Message-ID: f66398c1-e8b6-49d6-b893-c2c0125b0e2c@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 12/13/24 11:18 AM, Rich Shepard wrote:
> On Fri, 13 Dec 2024, Adrian Klaver wrote:
>
>> This needs more information:
>>
>> 1) Have you backed up your database at the current state?
>
> Adrian,
>
> No, the current state is FUBAR'd. The cron backup script runs each night at
> 11:15 p.m.
>
>> 2) What command did you use to create bustrac-2024-12-12.sql?
>
> !/usr/bin/bash
> #
> # This script pg_dump to save the database w/date stamp
>
> cd /data1/database-backups/
> pg_dump -d bustrac -c -f bustrac-$(date +%Y-%m-%d).sql cd

Alright, from here:

https://www.postgresql.org/docs/current/app-pgdump.html

"-c
--clean

Output commands to DROP all the dumped database objects prior to
outputting the commands for creating them. This option is useful when
the restore is to overwrite an existing database. If any of the objects
do not exist in the destination database, ignorable error messages will
be reported during restore, unless --if-exists is also specified.

This option is ignored when emitting an archive (non-text) output
file. For the archive formats, you can specify the option when you call
pg_restore.
"

This means when you run the script with:

psql -d bustrac -f bustrac-2024-12-12.sql

it will clean out the current corrupted objects and replace them with
those in the backup file.

>
> Thanks,
>
> Rich
>
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Durgamahesh Manne 2024-12-13 19:23:55 Subscriptions limit for 32cpus and 128gb
Previous Message Rich Shepard 2024-12-13 19:23:27 Re: Restoring database from backup