Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Database dump with just base image doesn't work #50

Open
noahjahn opened this issue Nov 8, 2021 · 1 comment
Open

Database dump with just base image doesn't work #50

noahjahn opened this issue Nov 8, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@noahjahn
Copy link

noahjahn commented Nov 8, 2021

Description

The database dump functionality when using a postgres database no longer works. It looks like the postgres client was just removed from the image Since the database dump from the control panel requires the postgres client to be installed, does it make sense to keep that dependency in the image?

Steps to reproduce

  1. Create a new craft project: https://craftcms.com/docs/3.x/installation.html
  2. Update the .env file with the following credentials:
DB_DRIVER=pgsql
DB_SERVER=host.docker.internal
DB_PORT=5432
DB_DATABASE=craft
DB_USER=craft
DB_PASSWORD=secret
DB_SCHEMA=public
DB_TABLE_PREFIX=
  1. Start a PostgreSQL database: docker run --rm --env POSTGRES_USER=craft --env POSTGRES_PASSWORD=secret -d -p 5432:5432 postgres:13
  2. From within the project directory, start the web server in the Craft docker image: docker run --rm -d -v "$(pwd):/app" -p 80:8080 craftcms/nginx:8.0
  3. In your browser, follow through the install steps: http://localhost/index.php?p=admin/install
  4. Login with the account you just created
  5. In Utilities > Database Backup, click Backup
  6. See error!
2021-11-08 11:15:52 [-][1][fa3bd882bbbcddbef1853ef1b38cadb3][error][yii\base\Exception] yii\base\Exception: Could not create backup: The shell command "PGPASSWORD="••••••" pg_dump --dbname=craft --host=host.docker.internal --port=5432 --username=craft --if-exists --clean --no-owner --no-privileges --no-acl --file="/app/storage/backups/test--2021-11-08-191552--v3.7.20.sql" --schema=public --column-inserts --exclude-table-data 'public.assetindexdata' --exclude-table-data 'public.assettransformindex' --exclude-table-data 'public.sessions' --exclude-table-data 'public.templatecaches' --exclude-table-data 'public.templatecachequeries' --exclude-table-data 'public.templatecacheelements' --exclude-table-data 'public.cache' --exclude-table-data 'public.templatecachecriteria'" failed with exit code 127: sh: pg_dump: not found in /app/vendor/craftcms/cms/src/controllers/UtilitiesController.php:346
Stack trace:
#0 [internal function]: craft\controllers\UtilitiesController->actionDbBackupPerformAction()
#1 /app/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#2 /app/vendor/yiisoft/yii2/base/Controller.php(181): yii\base\InlineAction->runWithParams(Array)
#3 /app/vendor/yiisoft/yii2/base/Module.php(534): yii\base\Controller->runAction('db-backup-perfo...', Array)
#4 /app/vendor/craftcms/cms/src/web/Application.php(287): yii\base\Module->runAction('utilities/db-ba...', Array)
#5 /app/vendor/craftcms/cms/src/web/Application.php(596): craft\web\Application->runAction('utilities/db-ba...', Array)
#6 /app/vendor/craftcms/cms/src/web/Application.php(266): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#7 /app/vendor/yiisoft/yii2/base/Application.php(392): craft\web\Application->handleRequest(Object(craft\web\Request))
#8 /app/web/index.php(26): yii\base\Application->run()
#9 {main}

Additional info

  • Craft version: 3.7.20
  • PHP version: 8.0
  • Database driver & version: Postgresql 13
  • Plugins & versions: N/A
@noahjahn noahjahn added the bug Something isn't working label Nov 8, 2021
@noahjahn
Copy link
Author

noahjahn commented Nov 8, 2021

A workaround is to just add the postgresql-client in a Dockerfile pulling from the Craft image:

FROM craftcms/nginx:8.0

USER root

RUN apk --no-cache add postgresql-client && \

USER www-data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant