Problem:
What is the process to regularly back up the ProfileUnity database (MongoDB)?
Resolution:
**NOTE: This method does not work on ProfileUnity 6.8.5 and above. Click the link below for an updated method to backup the database via API call and uses password encryption
ProfileUnity Power Tools - Database Backup
Review most recent modified date for newest entry/script
- Locally run the command below from an elevated command prompt on the ProfileUnity server to create a scheduled task:
SchTasks /Create /TN MongoBackup /RU SYSTEM /SC Daily /ST 00:00 /TR "cmd /V:ON /C \PROGRA~1\MongoDB\bin\mongodump.exe -u prou_services -p prou_services_password -o \PROGRA~1\MongoDB\bin\db_backups\%date:~4,2%%date:~7,2%%date:~10,4%"
Note:
- "MongoBackup" is the name of the scheduled task and can be modified.
- The "Daily" switch can be modified to run backups on an alternative schedule - e.g. weekly, monthly, etc.
- Replace the "prou_services_password" entry with your respective account password created during the installation of ProfileUnity.
- The last string will automatically create a "db_backups" folder in "C:\Program Files\MongoDB\bin" but can be modified to save backups to other locations.
- The directory containing the backup files will use the format, "month-day-year" - e.g. "01-07-2019". If your host is using a different date format, the "%date%" variables will need to be modified accordingly.
(Optional)
- Create a scheduled task to limit the number of backups stored by locally running the command below from an elevated command prompt on the ProfileUnity server:
SchTasks /Create /TN PurgeMongoBackups /RU SYSTEM /SC Weekly /ST 00:00 /TR "FORFILES /P \PROGRA~1\MongoDB\bin\db_backups /D -60 /C \"cmd /C IF @isdir==TRUE rd @path /S /Q\""
Note:
- "PurgeMongoBackups" is the name of the scheduled task and can be modified.
- The "Weekly" switch can be modified to run backups on an alternative schedule - e.g. daily, monthly, etc.
- Modify the path, "\PROGRA~1\MongoDB\bin\db_backups", to reflect the path used in creating the initial backup scheduled task - e.g. "\\server\share\backups" if a network location is used.
- "/D -60" indicates that any directories older than 60 days will be deleted. This value can be set to any other desired duration within the range of 0 - 32768.
Restoring From MongoDB Database Backups:
- Run the command below from an elevated Windows command prompt to restore a backup of the MongoDB database:
\PROGRA~1\MongoDB\bin\mongorestore.exe -u prou_services -p prou_services_password \PROGRA~1\MongoDB\bin\db_backups\directory
Note:
- Replace "prou_services_password" with your respective account password created during installation of ProfileUnity.
- The "directory" string is the "month-day-year" subdirectory containing the database files to be restored.
Product: ProfileUnity
Product Version: 6.8.4 R2 and earlier