Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

In /opt/zw-vmmc-docker/mongo you need to create mongo-initentrypoint.jssh:

  1. Create file:

    Code Block
    vim /opthome/zw-vmmc-docker/mongo/mongo-init.jsentrypoint.sh
    chmod +x entrypoint.sh
  2. And paste the next lines:

    Code Block
    #!/bin/sh
    sleep 20
    
    echo "Restoring databases..."
    mongorestore --host mongo --port 27017 --username <mongo-user> --password <mongo-password> --authenticationDatabase admin --gzip --archive=/backups/db1-backup.gz
    mongorestore --host mongo --port 27017 --username <mongo-user> --password <mongo-password> --authenticationDatabase admin --gzip --archive=/backups/dbLog-backup.gz
    mongorestore --host mongo Init --port 27017 --username <mongo-user> --password <mongo-password> --authenticationDatabase admin --gzip --archive=/backups/dbOthers-backup.gz
    
    echo "creating users..."
    mongosh --host mongo --port 27017 --username gaspar --password gaspar --authenticationDatabase admin  <<EOF
    
    use admin
    db.createUser(
        {
            user: "<user>",
            pwd: "<password>",
            mechanisms: ["SCRAM-SHA-1"],
    	roles: [
                {
                    role: "readWrite",
                    db: "db1"
                },
                {
                    role: "readWrite",
                    db: "dbOthers"
                },
                {
                    role: "readWrite",
                    db: "dbLog"
                },
            ]
        }
    );
    use db1
    db.createUser(
        {
            user: "<user>",
            pwd: "<password>",
            mechanisms: ["SCRAM-SHA-1"],
    	roles: [
                {
                    role: "readWrite",
                    db: "db1"
                },
                {
                    role: "readWrite",
                    db: "dbOthers"
                },
                {
                    role: "readWrite",
                    db: "dbLog"
                },
            ]
        }
    );
    use dbOthers
    db.createUser(
        {
            user: "<user>",
            pwd: "<password>",
            mechanisms: ["SCRAM-SHA-1"],
    	roles: [
                {
                    role: "readWrite",
                    db: "db1"
                },
                {
                    role: "readWrite",
                    db: "dbOthers"
                },
                {
                    role: "readWrite",
                    db: "dbLog"
                },
            ]
        }
    );
    use dbLog
    db.createUser(
        {
            user: "<user>",
            pwd: "<password>",
            mechanisms: ["SCRAM-SHA-1"],
    	roles: [
                {
                    role: "readWrite",
                    db: "db1"
                },
                {
                    role: "readWrite",
                    db: "dbOthers"
                },
                {
                    role: "readWrite",
                    db: "dbLog"
                },
            ]
        }
    );
    
    exit
    
  3. You will need to replace “<user>” and “<pwd>” with the user and password existing here: mongo-user

  4. You will also need to download backups log-backup.gz, prod-backup.gz and proddbOthers-backup.gz. Temporally, you can get them from api-dev.psi-connect.org, in the next path: /opt/tomcat/mongo-test-backups And paste in /opthome/zw-vmmc-docker/mongo/backups

...