This guide provides the steps to restore your CloudM PostgreSQL databases from a previous backup.
This procedure uses the Restore_BackupDatabases.ps1 PowerShell script. All steps must be performed on the machine where your PostgreSQL service is installed.
CRITICAL WARNING: This Process is Destructive
Running this restore script will DROP (delete) and REPLACE any existing databases that share a name with a database in the backup folder.
All current data in those databases will be permanently lost.
Only proceed if you are certain you want to overwrite the current data with the data from your backup files.
Prerequisites: Before You Begin
Before starting the restore, you must prepare the server and the required files.
- Stop CloudM Services:
- First, log in to the CloudM application and verify that no migrations are currently running.
- On the server, open the Windows Services console (run
services.msc). - Locate and Stop the
CloudMigratorService. This is essential to release any active connections to the databases.
- Locate Backup Files:
- Ensure you have the folder containing the database backup files (e.g.,
.backupfiles) you intend to restore. - Example:
C:\Backup_Databases
- Ensure you have the folder containing the database backup files (e.g.,
- Obtain the Restore Script:
- Download the
Restore_BackupDatabases.ps1script. (available at the bottom of this article). - Save the script to a known location on the server.
- Download the
Restore Procedure
Follow these steps to run the PowerShell script and perform the restore.
- Run PowerShell as Administrator:
- Click the Start Menu.
- Type "PowerShell ISE".
- Right-click Windows PowerShell ISE and select Run as administrator.
- Open the Script (if using ISE):
- In PowerShell ISE, go to File > Open.
- Navigate to and open the
Restore_BackupDatabases.ps1script you saved earlier.
- Run the Script:
- Click the Green "Play" button (Run Script) in the toolbar, or press F5.
- If you are not using ISE, navigate to the script's directory and run it (e.g.,
.\Restore_BackupDatabases.ps1).
- Respond to the Prompts:
- The script will stop and ask for four pieces of information in the console.
- PostgreSQL superuser login:
- Enter the username for a PostgreSQL user with the
SUPERUSERrole. - The default user is
postgres(recommended).
- Enter the username for a PostgreSQL user with the
- Password for [user]:
- Enter the password for the superuser you specified.
- Backup folder path:
- Enter the full path to the backup folder containing your
.backupfiles. - Example:
C:\Backup_Databases
- Enter the full path to the backup folder containing your
- Path to pg_restore.exe:
- Enter the full path to the
pg_restore.exeutility, which is part of your PostgreSQL installation. - Default path:
C:\Program Files\PostgreSQL\17\bin\pg_restore.exe
- Enter the full path to the
- Monitor the Restore:
- The script will run and restore all databases found in the backup folder. As noted, it will drop existing databases to replace them.
- Wait for the script to complete.
Final Step: Restart and Verify
After the script has finished, you must restart the CloudM service and verify the restore.
- Start CloudM Service:
- Return to the Windows Services console (
services.msc). - Locate and Start the
CloudMigratorService.
- Return to the Windows Services console (
- Verify Functionality:
- Log in to the CloudM application.
- Check your dashboard, configurations, and migration history to ensure the restored data is present and the application is working as expected.