Backup only postgres - no run?

Hi,

I’m using this code → Install with Docker // Baserow with one change to export database to the host. Instead of "baserow/baserow: i’m using “baserow:backend:”. Otherwise it is starting to download latest version of container.

docker run -it --rm -v baserow_data:/baserow/data -v $PWD:/baserow/host \
   baserow/backend:1.11.0 backend-cmd-with-db backup -f /baserow/host/backup.tar.gz

I changed that because i dont have locally installed baserow:latest or baserow:. My installation is from docker-compose so i have frontend, backend, celery as individual containers.

When i run this command i get… nothing. Just info about what commands are available:

root@server:~/sandbox/baserow# docker run -it --rm -v baserow_data:/baserow/data -v $PWD:/baserow/host \
>    baserow/backend:1.11.0 backend-cmd-with-db backup -f /baserow/host/backup.tar.gz
Command given was backend-cmd-with-db backup -f /baserow/host/backup.tar.gz

The available Baserow backend related commands, services and healthchecks are shown
below:
(...)

Do you know why it’s not working?

hi @rafuru, the baserow/backend image works a bit different compared to the base/baerow image because it doesn’t contain all embedded dependencies like PostgreSQL, Redis, etc. Therefore, the baserow/backend image doesn’t have the backend-cmd-with-db command because no database is embedded into the image.

If you want to make a backup via the baserow/backend image, your command should look like this:

docker run -it \
  --rm \
  -v baserow_data:/baserow/data \
  -v $PWD:/baserow/host \
  -e SECRET_KEY="test" \
  -e DATABASE_HOST="YOUR_PG_DB_HOST" \
  -e DATABASE_NAME="YOUR_PG_DB_NAME" \
  -e DATABASE_USER="YOUR_PG_DB_USER" \
  -e DATABASE_PORT="YOUR_PG_DB_PORT" \
  baserow/backend:1.13.0 \
  backup -f /baserow/host/backup.tar.gz

You need to replace the YOUR_* variables with your PostgreSQL database information. Let me know if that works for you.

Hi @bram
Thanks for your effort.
For now it’s not working, i got this err:

WARNING: Baserow is configured to use a PUBLIC_BACKEND_URL of http://localhost:8000. If you attempt to access Baserow on any other hostname requests to the backend will fail as they will be from an unknown host.Please ensure you set PUBLIC_BACKEND_URL if you will be accessing Baserow from any other URL then http://localhost.
WARNING: Baserow is configured to use a default PUBLIC_WEB_FRONTEND_URL of http://localhost:3000. Emails sent by Baserow will use links pointing to http://localhost:3000 when telling users how to access your server. If this is incorrect please ensure you have set PUBLIC_WEB_FRONTEND_URL to the URL where users can access your Baserow server.
Traceback (most recent call last):
  File "/baserow/backend/src/baserow/manage.py", line 41, in <module>
    main()
  File "/baserow/backend/src/baserow/manage.py", line 37, in main
    execute_from_command_line(sys.argv)
  File "/baserow/venv/lib/python3.7/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/baserow/venv/lib/python3.7/site-packages/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/baserow/venv/lib/python3.7/site-packages/django/core/management/base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/baserow/venv/lib/python3.7/site-packages/django/core/management/base.py", line 398, in execute
    output = self.handle(*args, **options)
  File "/baserow/backend/src/baserow/core/management/commands/backup_baserow.py", line 114, in handle
    backup_file_name = runner.backup_baserow(file, batch_size, additional_args)
  File "/baserow/backend/src/baserow/core/management/backup/backup_runner.py", line 88, in backup_baserow
    raise e
  File "/baserow/backend/src/baserow/core/management/backup/backup_runner.py", line 78, in backup_baserow
    backup_file_name, batch_size, additional_pg_dump_args
  File "/baserow/backend/src/baserow/core/management/backup/backup_runner.py", line 247, in _open_files_and_run_backup
    with tarfile.open(backup_file_name, "w:gz") as backup_output_tar:
  File "/usr/lib/python3.7/tarfile.py", line 1593, in open
    return func(name, filemode, fileobj, **kwargs)
  File "/usr/lib/python3.7/tarfile.py", line 1640, in gzopen
    fileobj = gzip.GzipFile(name, mode + "b", compresslevel, fileobj)
  File "/usr/lib/python3.7/gzip.py", line 163, in __init__
    fileobj = self.myfileobj = builtins.open(filename, mode or 'rb')
PermissionError: [Errno 13] Permission denied: '/baserow/host/backup.tar.gz'

I used this command

docker run -it \
  --rm \
  -v baserow_data:/baserow/data \
  -v $PWD:/baserow/host \
  -e SECRET_KEY="<redacted>" \
  -e DATABASE_HOST="3000" \
  -e DATABASE_NAME="baserow" \
  -e DATABASE_USER="baserow" \
  -e DATABASE_PORT="8000" \
  baserow/backend:1.11.0 \
  backup -f /baserow/host/backup.tar.gz

I don’t have set DATABASE_HOST or DATABASE_PORT in my .env file so i added this.

This is my docker-compose.yml

version: "3.4"

# MAKE SURE YOU HAVE SET THE REQUIRED VARIABLES IN the .env FILE.configs:


services:
  backend:
    image: baserow/backend:1.11.0
    restart: unless-stopped
    ports:
      - "${HOST_PUBLISH_IP:-127.0.0.1}:8000:8000"
    env_file:
      - .env
    depends_on:
      - db
      - redis
    volumes:
      - /home/root/baserow_media:/baserow/media

  web-frontend:
    image: baserow/web-frontend:1.11.0
    restart: unless-stopped
    ports:
      - "${HOST_PUBLISH_IP:-127.0.0.1}:3000:3000"
    env_file:
      - .env
    depends_on:
      - backend

  celery:
    image: baserow/backend:1.11.0
    restart: unless-stopped
    env_file:
      .env
    command: celery-worker
    # The backend image's baked in healthcheck defaults to the django healthcheck
    # override it to the celery one here.
    healthcheck:
      test: [ "CMD-SHELL", "/baserow/backend/docker/docker-entrypoint.sh celery-worker-healthcheck" ]
    depends_on:
      - backend
    volumes:
      - /home/root/baserow_media:/baserow/media

  celery-export-worker:
    image: baserow/backend:1.11.0
    restart: unless-stopped
    command: celery-exportworker
    # The backend image's baked in healthcheck defaults to the django healthcheck
    # override it to the celery one here.
    healthcheck:
      test: [ "CMD-SHELL", "/baserow/backend/docker/docker-entrypoint.sh celery-exportworker-healthcheck" ]
    depends_on:
      - backend
    env_file:
      .env
    volumes:
      - /home/root/baserow_media:/baserow/media

  celery-beat-worker:
    image: baserow/backend:1.11.0
    restart: unless-stopped
    command: celery-beat
    # See https://github.com/sibson/redbeat/issues/129#issuecomment-1057478237
    stop_signal: SIGQUIT
    env_file:
      - .env
    depends_on:
      - backend

  db:
    image: postgres:11.3
    restart: unless-stopped
    env_file:
      - .env
    environment:
      - POSTGRES_USER=${DATABASE_USER:-baserow}
      - POSTGRES_PASSWORD=${DATABASE_PASSWORD:?}
      - POSTGRES_DB=${DATABASE_NAME:-baserow}
    healthcheck:
      test: [ "CMD-SHELL", "su postgres -c \"pg_isready -U ${DATABASE_USER:-baserow}\"" ]
      interval: 10s
      timeout: 5s
      retries: 5
    volumes:
      - pgdata:/var/lib/postgresql/data

  redis:
    image: redis:6.0
    restart: unless-stopped
    command: redis-server --requirepass ${REDIS_PASSWORD:?}
    env_file:
      - .env
    healthcheck:
      test: [ "CMD", "redis-cli", "ping" ]

volumes:
  pgdata:
  media:

That’s odd. Does the backup.tar.gz file already exist on the host file system? If so, what happens if you remove it?