dokku / dokku-postgres

a postgres plugin for dokku

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot export databases with hyphens

tylercal opened this issue · comments

Description of problem

I have several databases with hyphens in their names (and several without). For the ones that include a - in the name. I cannot perform export (or any other functions) on the database. E.g.

dokku postgres:export test-db
pg_dump: [archiver (db)] connection to database "test-db" failed: FATAL:  database "test-db" does not exist

I get a similar error when attempting postgres:clone

How reproducible

This only appears to be happening on older DBs in my installation. If I create a new DB with a hyphen, everything appears to work fine. E.g.

dokku postgres:create test-db
dokku postgres:export test-db
PGDMP
    {test_db15.3 (De...

Environment Information

dokku report output

Report details
~> dokku report
-----> uname: Linux DokkuVM 4.15.0-212-generic #223-Ubuntu SMP Tue May 23 13:09:22 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
-----> memory: 
                     total        used        free      shared  buff/cache   available
       Mem:           7976        1268        3758         229        2949        6174
       Swap:             0           0           0
-----> docker version: 
       Client: Docker Engine - Community
        Version:           24.0.2
        API version:       1.43
        Go version:        go1.20.4
        Git commit:        cb74dfc
        Built:             Thu May 25 21:52:13 2023
        OS/Arch:           linux/amd64
        Context:           default
       
       Server: Docker Engine - Community
        Engine:
         Version:          24.0.2
         API version:      1.43 (minimum version 1.12)
         Go version:       go1.20.4
         Git commit:       659604f
         Built:            Thu May 25 21:52:13 2023
         OS/Arch:          linux/amd64
         Experimental:     false
        containerd:
         Version:          1.6.21
         GitCommit:        3dce8eb055cbb6872793272b4f20ed16117344f8
        runc:
         Version:          1.1.7
         GitCommit:        v1.1.7-0-g860f061
        docker-init:
         Version:          0.19.0
         GitCommit:        de40ad0
-----> docker daemon info: 
       Client: Docker Engine - Community
        Version:    24.0.2
        Context:    default
        Debug Mode: true
        Plugins:
         buildx: Docker Buildx (Docker Inc.)
           Version:  v0.10.5
WARNING: No swap limit support
           Path:     /usr/libexec/docker/cli-plugins/docker-buildx
         compose: Docker Compose (Docker Inc.)
           Version:  v2.18.1
           Path:     /usr/libexec/docker/cli-plugins/docker-compose
       
       Server:
        Containers: 20
         Running: 17
         Paused: 0
         Stopped: 3
        Images: 104
        Server Version: 24.0.2
        Storage Driver: overlay2
         Backing Filesystem: extfs
         Supports d_type: true
         Using metacopy: false
         Native Overlay Diff: true
         userxattr: false
        Logging Driver: json-file
        Cgroup Driver: cgroupfs
        Cgroup Version: 1
        Plugins:
         Volume: local
         Network: bridge host ipvlan macvlan null overlay
         Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
        Swarm: inactive
        Runtimes: io.containerd.runc.v2 runc
        Default Runtime: runc
        Init Binary: docker-init
        containerd version: 3dce8eb055cbb6872793272b4f20ed16117344f8
        runc version: v1.1.7-0-g860f061
        init version: de40ad0
        Security Options:
         apparmor
         seccomp
          Profile: builtin
        Kernel Version: 4.15.0-212-generic
        Operating System: Ubuntu 18.04.6 LTS
        OSType: linux
        Architecture: x86_64
        CPUs: 2
        Total Memory: 7.79GiB
        Name: DokkuVM
        ID: CA3Z:GOHT:SO22:RWHD:BQCZ:QF4Y:ZIUH:POZD:HOZE:D7LY:HD6Y:YQCR
        Docker Root Dir: /var/lib/docker
        Debug Mode: false
        Experimental: false
        Insecure Registries:
         127.0.0.0/8
        Live Restore Enabled: false
       
-----> git version: git version 2.17.1
-----> sigil version: 0.9.0build+bc921b7
-----> herokuish version: 
       herokuish: v0.6.0
       buildpacks:
         heroku-buildpack-multi     v1.2.0
         heroku-buildpack-ruby      v254
         heroku-buildpack-nodejs    v213
         heroku-buildpack-clojure   v90
         heroku-buildpack-python    v232
         heroku-buildpack-java      v72
         heroku-buildpack-gradle    v39
         heroku-buildpack-scala     v96
         heroku-buildpack-play      v26
         heroku-buildpack-php       v234
         heroku-buildpack-go        v174
         heroku-buildpack-nginx     v23
         buildpack-null             v3
-----> dokku version: dokku version 0.30.7
-----> plugn version: plugn: 0.12.0build+3a27594
-----> dokku plugins: 
         00_dokku-standard    0.30.7 enabled    dokku core standard plugin
         20_events            0.30.7 enabled    dokku core events logging plugin
         app-json             0.30.7 enabled    dokku core app-json plugin
         apps                 0.30.7 enabled    dokku core apps plugin
         builder              0.30.7 enabled    dokku core builder plugin
         builder-dockerfile   0.30.7 enabled    dokku core builder-dockerfile plugin
         builder-herokuish    0.30.7 enabled    dokku core builder-herokuish plugin
         builder-lambda       0.30.7 enabled    dokku core builder-lambda plugin
         builder-null         0.30.7 enabled    dokku core builder-null plugin
         builder-pack         0.30.7 enabled    dokku core builder-pack plugin
         buildpacks           0.30.7 enabled    dokku core buildpacks plugin
         caddy-vhosts         0.30.7 enabled    dokku core caddy-vhosts plugin
         certs                0.30.7 enabled    dokku core certificate management plugin
         checks               0.30.7 enabled    dokku core checks plugin
         common               0.30.7 enabled    dokku core common plugin
         config               0.30.7 enabled    dokku core config plugin
         cron                 0.30.7 enabled    dokku core cron plugin
         docker-options       0.30.7 enabled    dokku core docker-options plugin
         domains              0.30.7 enabled    dokku core domains plugin
         enter                0.30.7 enabled    dokku core enter plugin
         git                  0.30.7 enabled    dokku core git plugin
         haproxy-vhosts       0.30.7 enabled    dokku core haproxy-vhosts plugin
         hostname             0.2.0 enabled    Sets the docker hostname option for dokku
         letsencrypt          0.20.0 enabled    Automated installation of let's encrypt TLS certificates
         logs                 0.30.7 enabled    dokku core logs plugin
         logspout             0.4.0 enabled    sends dokku app stdout to a logging service
         maintenance          0.7.2 enabled    Maintenance mode for apps
         network              0.30.7 enabled    dokku core network plugin
         nginx-vhosts         0.30.7 enabled    dokku core nginx-vhosts plugin
         plugin               0.30.7 enabled    dokku core plugin plugin
         postgres             1.34.0 enabled    dokku postgres service plugin
         proxy                0.30.7 enabled    dokku core proxy plugin
         ps                   0.30.7 enabled    dokku core ps plugin
         redirect             0.9.0 enabled    Plugin for managing application redirects
         redis                1.34.0 enabled    dokku redis service plugin
         registry             0.30.7 enabled    dokku core registry plugin
         repo                 0.30.7 enabled    dokku core repo plugin
         resource             0.30.7 enabled    dokku core resource plugin
         run                  0.30.7 enabled    dokku core run plugin
         scheduler            0.30.7 enabled    dokku core scheduler plugin
         scheduler-docker-local 0.30.7 enabled    dokku core scheduler-docker-local plugin
         scheduler-null       0.30.7 enabled    dokku core scheduler-null plugin
         shell                0.30.7 enabled    dokku core shell plugin
         ssh-keys             0.30.7 enabled    dokku core ssh-keys plugin
         storage              0.30.7 enabled    dokku core storage plugin
         trace                0.30.7 enabled    dokku core trace plugin
         traefik-vhosts       0.30.7 enabled    dokku core traefik-vhosts plugin

How (deb/make) and where (AWS, VirtualBox, physical, etc.) was Dokku installed?:

  • Ubuntu 18.04.6 LTS (GNU/Linux 4.15.0-212-generic x86_64)
  • Azure VM

What is the output of dokku postgres:info test-db for these older databases? Feel free to replace the password with a bunch of X characters.

  =====> test-db postgres service information
Config dir:          /var/lib/dokku/services/postgres/test-db/data
Config options:
Data dir:            /var/lib/dokku/services/postgres/test-db/data
Dsn:                 postgres://postgres:xxxxxxxxxxx@dokku-postgres-test-db:5432/test-db
Exposed ports:       -
Id:                  d910d7284d3745f9f6cd92e480ae8d69ba14a2ea135088d083c6f9e90dd50404
Internal ip:         172.17.0.7
Initial network:
Links:               test-db
Post create network:
Post start network:
Service root:        /var/lib/dokku/services/postgres/test-db
Status:              running
Version:             postgres:9.6.4

What are the contents of /var/lib/dokku/services/postgres/test-db/DATABASE_NAME for the older database? Replace test-db with the name of the postgres service.

The contents of all of the /var/lib/dokku/services/postgres/*/DATABASE_NAME files all exactly match, e.g. test-db has a value of test-db

Set the value of that file to use the correct database name (with underscores) for your old databases. I believe that should fix the issues for old DBs.

Yes, that worked! I can now export those DBs. There would be no other unintended consequences, right? I don't need to change the name back to include the hyphen in the DATABASE_NAME file now?

Nope. This should also fix the issues you have with postgres:connect (if you didn't notice them before).