Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 754569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:01:43+00:00 2026-05-14T15:01:43+00:00

Locally, I use pgadmin3. On the remote server, however, I have no such luxury.

  • 0

Locally, I use pgadmin3. On the remote server, however, I have no such luxury.

I’ve already created the backup of the database and copied it over, but is there a way to restore a backup from the command line? I only see things related to GUI or to pg_dumps.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T15:01:44+00:00Added an answer on May 14, 2026 at 3:01 pm

    There are two tools to look at, depending on how you created the dump file.

    Your first source of reference should be the man page pg_dump as that is what creates the dump itself. It says:

    Dumps can be output in script or
    archive file formats. Script dumps are
    plain-text files containing the SQL
    commands required to reconstruct
    the database to the state it was
    in at the time it was saved. To
    restore from such a script, feed it to
    psql(1). Script files can be used
    to reconstruct the database even
    on other machines and other
    architectures; with some modifications
    even on other SQL database products.

    The alternative archive file formats
    must be used with pg_restore(1) to
    rebuild the database. They allow
    pg_restore to be selective about what
    is restored, or even to reorder the
    items prior to being restored. The
    archive file formats are designed to
    be portable across architectures.

    So depends on the way it was dumped out. If using Linux/Unix, you can probably figure it out using the excellent file(1) command – if it mentions ASCII text and/or SQL, it should be restored with psql otherwise you should probably use pg_restore.

    Restoring is pretty easy:

    psql -U username -d dbname < filename.sql
    
    -- For Postgres versions 9.0 or earlier
    psql -U username -d dbname -1 -f filename.sql
    

    or

    pg_restore -U username -d dbname -1 filename.dump
    

    Check out their respective manpages – there’s quite a few options that affect how the restore works. You may have to clean out your "live" databases or recreate them from template0 (as pointed out in a comment) before restoring, depending on how the dumps were generated.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a webpage I'd like to use locally, without a web server, by
I have always wondered why you cannot use locally defined classes as predicates to
Locally I use sqllite3 as a database, but in production I use MySQL. When
Can I use a SQL Server Express database as my local database for an
I use SQL Server to locally store data for statistical analysis. I create my
I'm using only CCRC and I don't have ClearCase locally installed. I use CCRC
I'm using only CCRC - I don't have ClearCase locally installed. I use CCRC
We use ASP.NET / C#. We work locally, test locally, check in our code
I'm running a MySQL database locally for development, but deploying to Heroku which uses
I have a MySQL instance running locally on port 3306, but for some legacy

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.