I am trying to restore database in PostgreSQL docker container using pg_restore from a shellscript taht will be called from docker file .I am getting following error "ERROR: canceling autovacuum task CONTEXT: automatic analyze of table 'tablename'".
DockerFile:
FROM postgres:9.3
ENV POSTGRES_USER postgres
ENV POSTGRES_PASSWORD Abcd1234
ENV POSTGRES_DB Clarion1
COPY DB.backup /var/lib/postgresql/backup/DB.backup
COPY initialize.sh /docker-entrypoint-initdb.d/initialize.sh
initialize.sh
#!/bin/bash
set -e
set -x
echo "******PostgreSQL initialisation******"
pg_restore -C -d DB /var/lib/postgresql/backup/DB.backup
Log:
server started
CREATE DATABASE
/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/initialize.sh
++ echo '******PostgreSQL initialisation******'
++ pg_restore -C -d Clarion1 /var/lib/postgresql/backup/Clarion53.backup
******PostgreSQL initialisation******
ERROR: canceling autovacuum task
But if I try to restore DB from command prompt in host machine from same backup file , it is working fine.
Here is a way to restore from a file located on the host machine:
docker exec -i container_name pg_restore -U postgres_user -v -d database_name < /dir_backup_outside_container/file_name.tar
I don't think the backup restore can be done during the initialization phase. Start your container and then upload the db.
docker run -d --name mydb mypgimage
docker exec mydb sh -c "pg_restore -C -d DB /var/lib/postgresql/backup/DB.backup"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With