Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • G gitlabhq1
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 21
    • Issues 21
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 12
    • Merge requests 12
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Infrastructure Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • gpt
  • large_projects
  • gitlabhq1
  • Issues
  • #4217

Closed
Open
Created Jun 05, 2013 by Administrator@rootOwner

PostgreSQL database restoration problem

Created by: andrewwutw

I found PostgreSQL database restore procedure may have bug. In file:

lib/backup/database.rb

https://github.com/gitlabhq/gitlabhq/blob/master/lib/backup/database.rb

PostgreSQL database is dumped by executing pg_dump:

system("pg_dump #{config['database']} > #{db_file_name}")

According to PostgreSQL document, pg_dump outputs a plain-text SQL script file by default:

http://www.postgresql.org/docs/8.4/static/app-pgdump.html

Output a plain-text SQL script file (the default).

And PostgreSQL database is restored by executing pg_restore:

system("pg_restore #{config['database']} #{db_file_name}")

But according to PostgreSQL document, pg_restore can't restore a plain-text dump file:

http://www.postgresql.org/docs/9.2/static/app-pgrestore.html

pg_restore is a utility for restoring a PostgreSQL database from an archive created by pg_dump in one of the non-plain-text formats.

I tried to replace the pg_restore command line to psql like this:

system("psql #{config['database']} -f #{db_file_name}")

Then run:

sudo -u git -H bundle exec rake gitlab:backup:restore RAILS_ENV=production

The restore procedure seems to work, although it prints some warning/error messages. And GitLab database seems to be restored.

This issue should be the cause of #4055 (closed) .

Any ideas?

Assignee
Assign to
Time tracking