Repository navigation
[MySpotify] docs: Document the manual MongoDB restore #71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,6 +30,35 @@ The stack does not back itself up. Configure a Dokploy compose | |
| backup for the `myspotify-mongo` service (database `your_spotify`, | ||
| type MongoDB, with the root credentials above) and test a restore. | ||
|
|
||
| ## Restoring a backup | ||
|
|
||
| Dokploy's built-in restore does not work for MongoDB: it runs | ||
| `mongorestore --db <name> --archive`, which current MongoDB tools | ||
| reject with `invalid db name`. Restore the backup file by hand. | ||
|
|
||
| `--drop` replaces the collections in the backup, so take a fresh | ||
| backup first if the current data matters. The backup must come | ||
| from the same MongoDB major version (8.x) as the target. | ||
|
|
||
| 1. Download the backup (`.bson.gz`) from the S3 destination. | ||
| 2. Stop the API so nothing writes during the restore: | ||
| `docker stop myspotify-api` | ||
| 3. Restore it with the root user from the container environment: | ||
|
|
||
| ```sh | ||
| docker exec -i myspotify-mongo sh -c 'mongorestore \ | ||
| -u "$MONGO_INITDB_ROOT_USERNAME" -p "$MONGO_INITDB_ROOT_PASSWORD" \ | ||
| --authenticationDatabase admin --archive --gzip --drop \ | ||
| --nsInclude "your_spotify.*"' < backup.bson.gz | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| ``` | ||
|
|
||
| 4. Check the summary line (`N document(s) restored successfully. | ||
| 0 document(s) failed to restore.`), then start the API again: | ||
| `docker start myspotify-api` | ||
|
|
||
| The file has the same format as `mongodump --archive --gzip`, so | ||
| the same command restores a manual dump. | ||
|
Comment on lines
+52
to
+60
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| ## Migrating from the host-path version | ||
|
|
||
| Earlier versions stored MongoDB in `${MYSPOTIFY_DATA}/mongo` | ||
|
|
@@ -40,9 +69,9 @@ migrated automatically. | |
| `docker exec myspotify-mongo mongodump -d your_spotify --archive --gzip > your_spotify.archive.gz` | ||
| 2. Deploy this version, so MongoDB creates the root user in the | ||
| new volume. | ||
| 3. Restore the dump into the new database (Dokploy restore, or | ||
| `mongorestore --archive --gzip --drop` with the root | ||
| credentials) before using the app. | ||
| 3. Restore the dump into the new database before using the app, | ||
| as described in [Restoring a backup](#restoring-a-backup) | ||
| (use `your_spotify.archive.gz` instead of `backup.bson.gz`). | ||
|
|
||
| ## Networks | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Script executed:
rg -n 'myspotify-mongo|MONGO_INITDB_ROOT|mongorestore' myspotifyRepository: finallyjay/selfhosted-docker-services
Length of output: 1768
Script executed:
Repository: finallyjay/selfhosted-docker-services
Length of output: 10194
Web query:
MongoDB database tools mongorestore password command line process status ps warning password visible official documentationResult:
Web query:
MongoDB database tools mongorestore password argv redact process command line obfuscate github source 100Result:
Web query:
Docker docs bridge network host can access container directly container IP host unprivileged process portResult:
Web query:
Docker official mongo 8 image database tools version mongorestore installed database-toolsResult:
Web query:
site:github.com/docker-library/mongo docker-entrypoint.sh "--bind_ip_all" mongod image 8Result:
Web query:
site:mongodb.com/docs/manual mongodb-org-tools mongodb-database-tools package install 8.0 version toolsResult:
Keep the root password out of process arguments.
On a shared host, another user may read the password from the
mongorestoreprocess arguments and use it to access MongoDB. Use a permissions-restricted--configfile for the password instead.