docker-db-backup
docker-db-backup copied to clipboard
Unable to make mongodb restore
Summary
I'm trying to restore mongodb backup made by db-backup container to database which is in the same docker-compose stack.
Steps to reproduce
My docker-compose.yml file:
version: '3.7'
services:
mongodb:
container_name: mongodb
image: mongo:latest
ports:
- "27017:27017"
volumes:
- ./data:/data/db
restart: always
environment:
MONGO_INITDB_ROOT_USERNAME: ${MONGO_INITDB_ROOT_USERNAME}
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_INITDB_ROOT_PASSWORD}
# Database backup
mongo-backup:
container_name: mongo-backup
image: tiredofit/db-backup
links:
- mongodb
volumes:
- ./backups:/backup
environment:
- DB_TYPE=mongo
- DB_AUTH=admin
- DB_HOST=mongodb
- DB_NAME=xxx
- DB_USER=${MONGO_INITDB_ROOT_USERNAME}
- DB_PASS=${MONGO_INITDB_ROOT_PASSWORD}
- DB_DUMP_BEGIN=0500
- DB_DUMP_FREQ=1440
- DB_CLEANUP_TIME=10080
restart: always
What is the expected correct behavior?
Backup is performing normally, so i guess env's are correct and service is able to connect.
Relevant logs and/or screenshots
[tiredofit/db-backup:3.2.1 05:03:26] # restore
## tiredofit/db-backup Restore Script Version 1.0.1
## Visit https://github.com/tiredofit/docker-db-backup/
## ####################################################
1) /backup/zzz_20220407-050000.archive.gz
2) /backup/zzz_20220407-050500.archive.gz
3) Custom
4) Quit
Please select a file to restore: 1
What Database Type are you looking to restore?
E ) Environment Variable DB_TYPE: 'mongo'
F ) Parsed Filename Type: 'mongo'
M ) MySQL / MariaDB
O ) MongoDB
P ) Postgresql
Q ) Quit
** Enter Value (E) | (F) | (M) | (P) : E
What Hostname do you wish to restore to:
C ) Custom Entered Hostname
E ) Environment Variable DB_HOST: 'mongodb'
F ) Parsed Filename Host: 'mongodb'
Q ) Quit
** Enter Value (C) | (E) | (F) : E
What Database Name do you want to restore to?
C ) Custom Entered Database Name
E ) Environment Variable DB_NAME: 'xxx'
F ) Parsed Filename DB Name: 'xxx'
Q ) Quit
** Enter Value (C) | (E) | (F) : E
What database user will be used for restore:
C ) Custom Entered Database User
E ) Environment Variable DB_USER: 'xxx'
Q ) Quit
** Enter Value (C) | (E) : E
What Database Password will be used to restore?
C ) Custom Entered Database Password
E ) Environment Variable DB_PASS
Q ) Quit
** Enter Value (C) | (E) : C
** What DB Password do you wish to use: xxx
What Database Port do you wish to use?
C ) Custom Entered Database Port
E ) Environment Variable DB_PORT: '27017'
Q ) Quit
** Enter Value (C) | (E) : E
2022-04-07.05:07:19 [INFO] ** [db-backup-restore] Restoring '/backup/zzz_20220407-050000.archive.gz' into 'mongodb'/'xxx'
Enter password:
2022-04-07T05:07:29.117+0000 error connecting to host: could not connect to server: connection() : auth error: sasl conversation error: unable to authenticate using mechanism "SCRAM-SHA-1": (AuthenticationFailed) Authentication failed.
2022-04-07.05:07:29 [ERROR] ** [db-backup-restore] Restore reported errors
Environment
- Image version / tag: latest
- Host OS: OSX
Additional information
If's weird for me too that after passing an ENV DB_PASS i'm still propting about password as the end step of restore process. I'm missing only a step where user need to pass DB_AUTH=admin (as default in mongo) it might be a case? It's defined in ENV for tis service.
In my case, everything is the same but after press "E" when promted on Database Port, it ask me again and again. It never stops and doesn't work "C" for custom neither.
Same here,
any news on this @tiredofit
Can we help?
I've solved it going back to v3.2.5 and blocking any update.
Hi there, not sure what happened - I remember repairing this before and I then went on a long trip- Its now back to the way it was with newly released 3.3.5
- Please let me know if indeed solved.
Hi.
Still facing the same error:
2022-08-12.17:50:13 [INFO] ** [db-backup-restore] Restoring '/backup/mongo_mongo_20220812-010004.archive.gz' into 'mongo'/'s_2'
Enter password:
2022-08-12T17:50:55.020+0000 error connecting to host: could not connect to server: connection() : auth error: sasl conversation error: unable to authenticate using mechanism "SCRAM-SHA-1": (AuthenticationFailed) Authentication failed.
2022-08-12.17:50:55 [ERROR] ** [db-backup-restore] Restore reported errors
Am i doing something wrong ?
Same issue here.
Looks like mongorestore command should pass correct --authenticationDatabase
param
@Yozer you are right, after adding --authenticationDatabase=admin
in https://github.com/tiredofit/docker-db-backup/blob/main/install/usr/local/bin/restore#L928 it works. But im not sure, if this is correct solution and will work for others too.