This article provides the standard procedures for creating a compressed backup of the cloudmon database and the steps required to perform a failback (restore) in the event of a system failure or unsuccessful update.
Before performing any system upgrades or major configuration changes, you must take a manual backup to ensure data integrity.
mongodump --uri="mongodb://localhost:27017/cloudmon" --gzip --archive="cloudmon_dump.gz"
--uri: Specifies the connection string to the local MongoDB instance and the specific database (cloudmon).
--gzip: Compresses the output to save disk space.
--archive: Directs the output into a single archive file named cloudmon_dump.gz instead of a folder of BSON files.
If the application fails after an update, use the following steps to restore the database to the previous "known-good" state.
mongorestore --uri="mongodb://localhost:27017" --gzip --archive="cloudmon_dump.gz"File Location: Ensure you are running the command from the same directory where the cloudmon_dump.gz file is located.
Existing Data: If the database already contains data, mongorestore will merge the data. To completely overwrite the existing database with the backup, you may need to add the --drop flag (use with caution).
Verification: After restoration, restart the Cloudmon services to ensure they reconnect to the restored database correctly.
Permission Denied: Ensure you are running the commands with the necessary user privileges (e.g., use sudo if required).
Connection Refused: Verify that the MongoDB service is running using systemctl status mongod.
Nginx Errors: If you see Nginx errors after a restore, it may indicate that the database structure has reverted but the application cache or web server config is still pointing to new (broken) assets. Clear the Nginx cache if necessary.