Backing up database

Hi All

kinda new to linux, trying to use

mysqldump -u <user> -p -h <db-host> <database> > vkunja-backup.sql

using
services:
  db:
    image: mariadb:10
    command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
    environment:
      MYSQL_ROOT_PASSWORD: supersecret
      MYSQL_USER: vikunja
      MYSQL_PASSWORD: secret
      MYSQL_DATABASE: vikunja
    volumes:
      - ./db:/var/lib/mysql
    restart: unless-stopped
  api:
    image: vikunja/api
    environment:
      VIKUNJA_DATABASE_HOST: db
      VIKUNJA_DATABASE_PASSWORD: secret
      VIKUNJA_DATABASE_TYPE: mysql
      VIKUNJA_DATABASE_USER: vikunja
      VIKUNJA_DATABASE_DATABASE: vikunja
    volumes: 
      - ./files:/app/vikunja/files
    depends_on:
      - db
    restart: unless-stopped


of which I am using
mysqldump -u vikunja -p -h db vikunja > vkunja-backup.sql

I enter my password and it hangs.....have I got it right?

The > vikunja-backup.sql at the end of the command redirects everything to a new file vikunja-backup.sql (It’s called a pipe). It appears to hang because it won’t show you any output because all output of the command is redirected to the file.

If you’re not sure it works correctly, try removing the > ... part at the end to see all output.

mysqldump -u <user> -p -h <db-host> <database> > vkunja-backup.sql

where am I getting inputs from database or api
is db_host in api config?

any help?

I need to be able to back up and restore, otherwise I cant use it

The easiest would probably be to run the command from inside the container through docker compose. In your case that would be something like this (running from the directory where the compose file is located):

docker-compose exec db mysqldump -u <user> -p<password>  <database> > vikunja-backup.sql

with the env variables from the docker-compose.yml file.