这是indexloc提供的服务,不要输入任何密码
Skip to content

[COMMUNITY] Add some handy bash to community for simpler development #2255

@mnlbox

Description

@mnlbox

I'm creating this bash to dump data and schema. If useful we can add such a small and handy tools or bash in community content folder in this repo.

#!/bin/bash

docker ps
echo -e "Hi, please enter postgres container id for dump schemas: \c "
read  postgres_container_id

echo -e "Please enter postgres database name: [for example: postgres] \c "
read  database_name
mkdir -p data_dump
cd data_dump

while :
do
  echo -e "Press <CTRL+C> to exit or Enter schema name for dump: \c "
  read  schema_name

  mkdir -p schema
  cd schema
  docker exec $postgres_container_id pg_dump -O -x -U $database_name --schema-only --schema $schema_name > ./$schema_name.sql
  mkdir -p clean
  curl --data-binary @./$schema_name.sql https://hasura-edit-pg-dump.now.sh > ./clean/$schema_name.sql

  cd ..
  mkdir -p data
  cd data
  docker exec $postgres_container_id pg_dump -O -x -U $database_name --data-only --schema $schema_name > ./$schema_name.sql
  mkdir -p clean
  curl --data-binary @./$schema_name.sql https://hasura-edit-pg-dump.now.sh > ./clean/$schema_name.sql

  cd ..
  mkdir -p schema_with_data
  cd schema_with_data
  docker exec $postgres_container_id pg_dump -O -x -U $database_name --schema $schema_name > ./$schema_name.sql
  mkdir -p clean
  curl --data-binary @./$schema_name.sql https://hasura-edit-pg-dump.now.sh > ./clean/$schema_name.sql

  cd ..
done

What is your opinion?

@shahidhk Some handy tools like your stream about migration. 😉

Metadata

Metadata

Assignees

No one assigned

    Labels

    c/communityRelated to community contentk/ideasDiscuss new ideas / pre-proposals / roadmap

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions