> For the complete documentation index, see [llms.txt](https://hatchbox.gitbook.io/hatchbox/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hatchbox.gitbook.io/hatchbox/databases.md).

# Databases

## How can I setup automatic backups for my app?

Take a look at: <https://hatchbox.gitbook.io/hatchbox/apps/backups>

## Where do I find my database credentials?

If you open your App in Hatchbox, click on Resources -> Database and all the details for connecting to your database will be listed there.

## How can I manually backup my app database?

Backing up your database manually is pretty easy but takes a couple steps.

To find your Database&#x20;

First, SSH into your server. Then we'll run pg\_dump to dump our database. This will make a compressed dump of our database so it's smaller and easier to manage.

```
pg_dump -Fc database_name -U username -h localhost > database.bak
```

You'll now have a file called `database.bak` that you can download from the server.

On your local machine, you can use the following command to download the file from the remote server to the current directory your local machine.

```
scp deploy@IPADDRESS:~/database.bak .
```

## How can I restore a backup of my database?

Similar to the above, but in reverse order

First, you'll copy your database up to the server using:

```
scp database.bak deploy@IPADDRESS:~
```

Then SSH into the server and run one of the following commands:

If your database *already exists*, you can run this command to restore to it:

```
pg_restore -U username -W -h 127.0.0.01 -d appname --no-acl --no-owner database.bak
```

If your database *does not exist*, you can run this command to create the database and restore it:

```
pg_restore -C -U username -W -h 127.0.0.01 -d appname --no-acl --no-owner database.bak
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://hatchbox.gitbook.io/hatchbox/databases.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
