improve bash script to manage planka #688

Open
opened 2026-02-04 20:50:35 +03:00 by OVERLORD · 3 comments
Owner

Originally created by @yukal on GitHub (Apr 23, 2025).

Is this a feature for the backend or frontend?

Backend

What would you like?

It might be better to have one script file to import and export data from the container?
And, let's say, let's call this script "util"

Why is this needed?

So we could then:

  • run various scenarios using different arguments using one script
  • provide a brief description of this utility and a description of each command that is passed to the utility as arguments

Other information

As an example, let me show you how I use it in my projects:
https://gist.github.com/yukal/228bba6c17bcddba18184334bf4a5745

And this is what the user sees when he runs the utilite without any arguments:

Usage: util [up|down|status|logs|dump|restore]

$ util up
  Create and run new containers using docker compose.

$ util down
  Stop and remove containers locally with its volumes and networks.

$ util status
  Show info about the container status and its configuration
  eg: port, network, container name.

$ util logs
  Show logs of the containers in attached mode.

$ util dump
  Create Database dump and export data from containers.

$ util restore
  Restore Database from the dump file and import user data to containers.
Originally created by @yukal on GitHub (Apr 23, 2025). ### Is this a feature for the backend or frontend? Backend ### What would you like? It might be better to have one script file to import and export data from the container? And, let's say, let's call this script "util" ### Why is this needed? So we could then: - run various scenarios using different arguments using one script - provide a brief description of this utility and a description of each command that is passed to the utility as arguments ### Other information As an example, let me show you how I use it in my projects: https://gist.github.com/yukal/228bba6c17bcddba18184334bf4a5745 And this is what the user sees when he runs the utilite without any arguments: ```txt Usage: util [up|down|status|logs|dump|restore] $ util up Create and run new containers using docker compose. $ util down Stop and remove containers locally with its volumes and networks. $ util status Show info about the container status and its configuration eg: port, network, container name. $ util logs Show logs of the containers in attached mode. $ util dump Create Database dump and export data from containers. $ util restore Restore Database from the dump file and import user data to containers. ```
OVERLORD added the enhancement label 2026-02-04 20:50:35 +03:00
Author
Owner

@yukal commented on GitHub (Apr 23, 2025):

Also, to control the container names, we could explicitly name them like this:

services:
  planka:
    container_name: planka_app

  postgres:
    container_name: planka_db

This will at least help avoid unexpected automatically generated names.
Then in a bash script we could use these names:

PROJECT_NAME=planka

docker exec -t ${PROJECT_NAME}_db \
    pg_dumpall -U postgres --clean --if-exist > "$YOUR_DUMP_FILE"

# Export user files from container
docker cp ${PROJECT_NAME}_app:/app/public/user-avatars/ data/app/public

@yukal commented on GitHub (Apr 23, 2025): Also, to control the container names, we could explicitly name them like this: ```yaml services: planka: container_name: planka_app postgres: container_name: planka_db ``` This will at least help avoid unexpected automatically generated names. Then in a bash script we could use these names: ```bash PROJECT_NAME=planka docker exec -t ${PROJECT_NAME}_db \ pg_dumpall -U postgres --clean --if-exist > "$YOUR_DUMP_FILE" # Export user files from container docker cp ${PROJECT_NAME}_app:/app/public/user-avatars/ data/app/public ```
Author
Owner

@meltyshev commented on GitHub (Apr 23, 2025):

Hey 👋

That sounds super handy! I also like the idea of setting the container name instead of getting a random one.

@meltyshev commented on GitHub (Apr 23, 2025): Hey 👋 That sounds super handy! I also like the idea of setting the container name instead of getting a random one.
Author
Owner

@ludat commented on GitHub (May 14, 2025):

Just to clarify I think it would be better to use the docker-compose cli instead of setting a container name, the command above would be:

docker-compose exec db \
    pg_dumpall -U postgres --clean --if-exist > "$YOUR_DUMP_FILE"
@ludat commented on GitHub (May 14, 2025): Just to clarify I think it would be better to use the `docker-compose` cli instead of setting a container name, the command above would be: ``` docker-compose exec db \ pg_dumpall -U postgres --clean --if-exist > "$YOUR_DUMP_FILE" ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/planka#688