Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

305
Vistas
How to restore postgres within a docker?

I create backups like this: docker exec DOCKER pg_dump -U USER -F t DB | gzip > ./FILE.tar.gz

What's the best way to restore the database given that the database runs within a container?

about 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

For your case:

docker exec -it <CONTAINER> gunzip < backup.tar.gz | pg_restore -U <USER> -F t -d <DB>

Remote restore is also available if your container is public facing and remote connections are allowed in pg_hba.conf for postresql:

gunzip < backup.tar.gz | pg_restore -U <USER> -F t -d <DB> -h <HOST_IP> -p 5432

As a rule of thumb, it is good idea to document your backup and restore commands specific to the project.

about 4 years ago · Santiago Trujillo Denunciar

0

How take backup of the data which is existing in the running PostgreSQL container


  1. Create some folder in your root

    mkdir -p '/myfolder/bdbackup'
    
  2. download the postgres image which you are using and execute the following command

    docker run --name demo1 -e POSTGRES_PASSWORD=passowrd -v /myfolder/bdbackup:/var/lib/postgresql/data -d postgres 
    
    docker exec -it demo1 psql -U postgres
    
  3. Back up will be stored in the following folder /myfolder/bdbackup

  4. you can kill the container and stop the container any time but data will be stored in the host.
  5. and once again re-run the postgres the container with same command

    docker run --name demo2 -e POSTGRES_PASSWORD=passowrd -v /myfolder/bdbackup:/var/lib/postgresql/data -d postgres 
    
    docker exec -it demo1 psql -U postgres
    

    and execute following query select * from emp;

  6. you can see the data has restored...

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda