# Backing up database

**URL:** <https://community.vikunja.io/t/backing-up-database/323>\
**Category:** Support\
**Created:** [3 September 2021 15:08 UTC](https://community.vikunja.io/t/backing-up-database/323 "2021-09-03T15:08:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![magicman32](https://community.vikunja.io/user_avatar/community.vikunja.io/magicman32/32/182_2.png) [@magicman32](https://community.vikunja.io/u/magicman32)\
**Post date:** [3 September 2021 15:08 UTC](https://community.vikunja.io/t/backing-up-database/323/1 "2021-09-03T15:08:30Z")

</div>

Hi All

kinda new to linux, trying to use

```auto
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?

```

---

<div class="post-metadata">

**Author:** ![kolaente](https://community.vikunja.io/user_avatar/community.vikunja.io/kolaente/32/5_2.png) [@kolaente](https://community.vikunja.io/u/kolaente)\
**Post date:** [3 September 2021 16:12 UTC](https://community.vikunja.io/t/backing-up-database/323/2 "2021-09-03T16:12:22Z")

</div>

> [@magicman32](#):
>
> `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.

---

<div class="post-metadata">

**Author:** ![magicman32](https://community.vikunja.io/user_avatar/community.vikunja.io/magicman32/32/182_2.png) [@magicman32](https://community.vikunja.io/u/magicman32)\
**Post date:** [3 September 2021 18:02 UTC](https://community.vikunja.io/t/backing-up-database/323/3 "2021-09-03T18:02:13Z")

</div>

```auto
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?

---

<div class="post-metadata">

**Author:** ![magicman32](https://community.vikunja.io/user_avatar/community.vikunja.io/magicman32/32/182_2.png) [@magicman32](https://community.vikunja.io/u/magicman32)\
**Post date:** [4 September 2021 16:04 UTC](https://community.vikunja.io/t/backing-up-database/323/4 "2021-09-04T16:04:54Z")

</div>

any help?

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

---

<div class="post-metadata">

**Author:** ![kolaente](https://community.vikunja.io/user_avatar/community.vikunja.io/kolaente/32/5_2.png) [@kolaente](https://community.vikunja.io/u/kolaente)\
**Post date:** [4 September 2021 17:08 UTC](https://community.vikunja.io/t/backing-up-database/323/5 "2021-09-04T17:08:56Z")

</div>

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):

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

```

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