From 2c15e0ebf68e92a208f124aae272b03563716de5 Mon Sep 17 00:00:00 2001 From: CrossDrain <32982516+CrossDrain@users.noreply.github.com> Date: Fri, 1 May 2026 21:47:38 +0000 Subject: [PATCH 1/2] Update self-hosting.mdx to include better explanations or the backup restore process Improved clarity of database restore instructions Fixed order so that files (which need to be restored first) appear higher in the page --- self-hosting.mdx | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/self-hosting.mdx b/self-hosting.mdx index accd7c8..5d3eaad 100644 --- a/self-hosting.mdx +++ b/self-hosting.mdx @@ -282,26 +282,42 @@ You can use cron syntax or these shortcuts: - `@monthly` - Once per month - Custom cron: `0 2 * * *` (2 AM daily) -### Restore from a PostgreSQL backup +### Restore uploaded files + + +Since the database refernces files (paths, IDs, metadata), file restore should PRECEDE the restore of the database. + + +If your Sure instance stores uploaded files (attachments, profile pictures, etc.) on the local filesystem, restoring the database alone is not enough. You must also restore the files themselves from the corresponding backup. + +The exact restore path depends on how you mapped volumes in `compose.yml`. Restore the backup at the same directory that Sure uses for storage. By default, sure will use the `app-storage` Docker volume. + +If you are using external object storage instead of local disk, restore those files using that provider's backup or versioning workflow instead. + +### Restore the database from a PostgreSQL backup Use this process when you have a SQL dump created by the backup service or with `pg_dump`. -> [!NOTE] -> If you customized the PostgreSQL username, password, or database name in your `.env` or `compose.yml`, replace `sure_user` and `sure_production` in the commands below. + +The following process will wipe the current database and will replace it with the backup. All data currently being used by Sure will be lost. + + + +If you customized the PostgreSQL username, password, or database name in your `.env` or `compose.yml`, replace `sure_user` and `sure_production` in the commands below. + -1. Stop the application containers so they do not write to the database during the restore: +1. Stop the application containers so they do not write to the database during the restore. ```bash -docker compose stop web worker +docker compose down ``` -2. Start or keep the database container running: - +2. Start only the Postgres database container ```bash docker compose up -d db ``` -3. Locate the backup file in your backup directory, for example `/opt/sure-data/backups`. +3. Locate the backup file in your backup directory, for example in the backup service's `sure-backups` volume. 4. Restore the SQL backup into PostgreSQL: @@ -312,17 +328,9 @@ docker compose exec -T db psql -U sure_user -d sure_production < /path/to/backup 5. Restart the app: ```bash -docker compose up -d web worker +docker compose up -d ``` -### Restore local uploaded files - -If your Sure instance stores uploaded files on the local filesystem, restoring the database alone is not enough. You must also restore the app's storage directory from the matching file backup. - -The exact host path depends on how you mapped volumes in `compose.yml`. Restore the same directory that Sure uses for local storage, then restart the app containers. - -If you are using external object storage instead of local disk, restore those files using that provider's backup or versioning workflow instead. - ### Verify the restore After restoring, check the following: From 62c0bd913a393e578b9cbfce0558033691a4d6e0 Mon Sep 17 00:00:00 2001 From: CrossDrain <32982516+CrossDrain@users.noreply.github.com> Date: Fri, 1 May 2026 22:01:28 +0000 Subject: [PATCH 2/2] Update self-hosting.mdx --- self-hosting.mdx | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/self-hosting.mdx b/self-hosting.mdx index 5d3eaad..1650d33 100644 --- a/self-hosting.mdx +++ b/self-hosting.mdx @@ -284,13 +284,13 @@ You can use cron syntax or these shortcuts: ### Restore uploaded files - + Since the database refernces files (paths, IDs, metadata), file restore should PRECEDE the restore of the database. - + If your Sure instance stores uploaded files (attachments, profile pictures, etc.) on the local filesystem, restoring the database alone is not enough. You must also restore the files themselves from the corresponding backup. -The exact restore path depends on how you mapped volumes in `compose.yml`. Restore the backup at the same directory that Sure uses for storage. By default, sure will use the `app-storage` Docker volume. +The exact restore path depends on how you mapped volumes in `compose.yml`. Restore the backup at the same directory that Sure uses for storage. By default, Sure will use the `app-storage` Docker volume. If you are using external object storage instead of local disk, restore those files using that provider's backup or versioning workflow instead. @@ -306,29 +306,24 @@ The following process will wipe the current database and will replace it with th If you customized the PostgreSQL username, password, or database name in your `.env` or `compose.yml`, replace `sure_user` and `sure_production` in the commands below. -1. Stop the application containers so they do not write to the database during the restore. +1. While the stack is running, stop the application containers so they do not write to the database during the restore: ```bash -docker compose down +docker compose stop web worker ``` -2. Start only the Postgres database container -```bash -docker compose up -d db -``` - -3. Locate the backup file in your backup directory, for example in the backup service's `sure-backups` volume. +2. Locate the backup file in your backup directory, for example in the backup service's `sure-backups` volume. -4. Restore the SQL backup into PostgreSQL: +3. Restore the SQL backup into PostgreSQL: ```bash docker compose exec -T db psql -U sure_user -d sure_production < /path/to/backup.sql ``` -5. Restart the app: +4. Restart the rest of the containers: ```bash -docker compose up -d +docker compose up -d web worker ``` ### Verify the restore