# Create a dump file

If this is running on your local machine, do this. You will need to be inside the container or, in a directory/location that is local to the mysql/mariadb database.

```
mysqldump --single-transaction --default-character-set=utf8mb4 -h [server] -u [username] -p[password] [db_name] > nextcloud-sqlbkp_`date +"%Y%m%d"`.bak
```

If it is running in a container, you will need to run this command in that container.

```bash
docker exec [CONTAINER_NAME_OR_ID] /usr/bin/mysqldump -u [USERNAME] --password=[PASSWORD] [DATABASE_NAME] > [BACKUP_FILE.sql]
```

<span class="">Replace:</span>

- <span class="">`[CONTAINER_NAME_OR_ID]`</span><span class=""> with the name or ID of the Docker container running MySQL</span>
- <span class="">`[USERNAME]`</span><span class=""> with the MySQL username</span>
- <span class="">`[PASSWORD]`</span><span class=""> with the MySQL user's password</span>
- <span class="">`[DATABASE_NAME]`</span><span class=""> with the name of the database to dump</span>
- <span class="">`[BACKUP_FILE.sql]`</span><span class=""> with the desired name for the SQL backup file</span>


##### <span class="">Note:</span>

<span class="">The typical process of creating a database dump requires connecting to the running database server and executing a command like `mysqldump` or `pg_dump` to export the database data to a SQL file. However, without a running database instance, these commands cannot be executed.</span>