Skip to content

Commit f6d87eb

Browse files
nikblanchetclaude
andauthored
Docs: document --backupdb argument for inv docker.manage (#12617)
Closes #7761 ## Summary - Documents the `--backupdb` argument for `inv docker.manage` - Describes the backup filename pattern: `dump_<DD-MM-YYYY>_<HH_MM_SS>__<git-hash>.sql` - Adds restore instructions with step-by-step commands Note: #8708 proposes a `restoredb` invoke task to automate restoration. The manual workflow documented here can coexist with that automation if it lands. ## Test plan - [x] Built docs locally with `make PROJECT=dev html` - renders correctly - [x] Tested `inv docker.manage --backupdb showmigrations` - backup file created with documented pattern Generated with [Claude Code](https://claude.com/claude-code) Steered and reviewed by @nikblanchet (mostly human) --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 6b64298 commit f6d87eb

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

docs/dev/install.rst

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,43 @@ save some work while typing docker compose commands. This section explains these
150150
``inv docker.manage {command}``
151151
Executes a Django management command in a container.
152152

153+
* ``--backupdb`` creates a database backup before running the command.
154+
The backup is saved to the current directory with a timestamped filename:
155+
``dump_<DD-MM-YYYY>_<HH_MM_SS>__<git-hash>.sql``
156+
153157
.. tip::
154158

155159
Useful when modifying models to run ``makemigrations``.
156160

161+
.. tip::
162+
163+
Use ``--backupdb`` when running ``migrate`` to create a backup before applying migrations:
164+
165+
.. code-block:: bash
166+
167+
inv docker.manage --backupdb migrate
168+
169+
To restore from this backup, follow these steps:
170+
171+
.. code-block:: bash
172+
173+
# Start only the database container
174+
inv docker.compose 'start database'
175+
176+
# Copy the backup file into the container (replace with your actual filename)
177+
docker cp dump_24-11-2025_10_30_00__abc1234.sql community_database_1:/tmp/dump.sql
178+
179+
# Open a shell in the database container
180+
inv docker.shell --container database
181+
182+
Then inside the database container:
183+
184+
.. code-block:: bash
185+
186+
dropdb -U docs_user docs_db
187+
createdb -U docs_user docs_db
188+
psql -U docs_user docs_db < /tmp/dump.sql
189+
157190
``inv docker.down``
158191
Stops and removes all containers running.
159192

0 commit comments

Comments
 (0)