Product Version: 6.5+
Expires on: 365 days from publish date
Updated: January 7, 2019
What is the process to regularly back up the ProfileUnity database (MongoDB)?
- 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%"
- "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 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".
- 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 "Powershell dir $env:PROGRAMFILES\MongoDB\bin\db_backups |sort -property name -descending |select -skip 10 |rd -recurse -force" /F
- "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 "dir" path, "$env:PROGRAMFILES\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.
- "10" is the maximum number of subdirectories to be maintained the backup directory and will delete the oldest subdirectory once that number is exceeded.
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
- 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.