GardenCloud & systems

Reading an older MongoDB dump-and-restore upgrade notebook

Backup, installation, restore, and application verification are separate recovery steps.

The original notebook was titled as a move from MongoDB 3.6.3 to 4.4.4. Its actual sequence stopped the application, dumped data, replaced packages, restored data, and resumed the application. That is not evidence that skipping intermediate binary upgrade requirements is supported.

Preserve and verify a recoverable backup

mongodump --username DB_USERNAME --password DB_PASSWORD --db DB_NAME --out /var/backups/mongobackups/`date +"%m-%d-%y"`

The credential names are symbolic. A password on a command line can be exposed through process or shell records; the transcript is historical, not a credential-handling recommendation.

The recorded package replacement

sudo systemctl stop mongodb
sudo apt-get purge mongodb-*
wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list
sudo apt-get update
sudo apt-get install -y mongodb-org
sudo systemctl start mongod
sudo systemctl status mongod

The package and repository commands target an old Ubuntu/MongoDB combination. A new server binary does not establish that data files, feature compatibility, tools, or the application driver are compatible. Consult the version-matched vendor upgrade/restore requirements before any real migration.

The source’s broad database roles and listener-on-all-interfaces example are omitted rather than turned into defaults.

Restore is a destructive boundary

sudo systemctl restart mongod
sudo mongorestore --username DB_USERNAME --password DB_PASSWORD --db DB_NAME --drop /var/backups/mongobackups/`date +"%m-%d-%y"`/DB_NAME/

--drop removes destination collections before restoration. A service restart, a completed restore, and a healthy application are separate checks, and a rollback path must exist before replacement.

Source: retrieved notebook revision. No database, package, account, or application was changed for this revision.

← Back to the garden