Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • docker-cubicweb docker-cubicweb
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 18
    • Issues 18
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • cubicweb
  • docker-cubicwebdocker-cubicweb
  • Issues
  • #21
Closed
Open
Created Nov 25, 2021 by Katia Saurfelt@ksaurfeltMaintainer

Allow to restore a database instead of creating from scratch

Provide an option or an environmental variable to decide to create base from scratch or to restore it from a pg dump. Example below for a kubernetes deployment (from FA, not in prod):


apiVersion: apps/v1
kind: Deployment
metadata:
  name: francearchives
spec:
  template:
    spec:
      initContainers:
        - name: francearchives-db-create
          args:
            - "-c"
            - |
              echo "checking postgresql database $CW_DB_NAME if it doesn't exist, create it with pg_restore";
              if [ "$(PGPASSWORD=$CW_DB_PASSWORD psql -h $CW_DB_HOST -p $CW_DB_PORT -d template1 -tAc "SELECT 1 FROM pg_database WHERE datname='$CW_DB_NAME'")" = '1' ]; then
                echo "database exists"
              else
                echo "download dump"
                wget https://example.org/database.tgz
                echo "uncompress dump"
                tar xvfz database.tgz
                echo "createdb"
                PGPASSWORD=$CW_DB_PASSWORD createdb -h $CW_DB_HOST -p $CW_DB_PORT $CW_DB_NAME
                echo "pg_restore"
                PGPASSWORD=$CW_DB_PASSWORD pg_restore -h $CW_DB_HOST -p $CW_DB_PORT -d $CW_DB_NAME --no-owner -F d database
                echo "reset password"
                cubicweb-ctl reset-admin-pwd -p $CW_PASSWORD $CW_INSTANCE
                echo "upgrade"
                cubicweb-ctl upgrade --backup-db=n --fs-only --force --verbosity=0 "$(CW_INSTANCE)"    
              fi
              echo "done"

This could be useful for reviewapps.

Edited Nov 25, 2021 by Katia Saurfelt
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking