Skip to main content

Hi,

I wonder how I could relocate the PostgreSQL database simply to another drive.
The installation performed the default installation on the Windows C-drive.
Because we also create an SMB file share backup of a large share, the database grows quickly and we need to enlarge the C-drive often.

So we would like to relocate from the default location to simply another drive (not another computer).

Is this also with the configuration backup migrate method?
Is there something we need to do before?
Can we use the psql tool to do this easier?

regards

Steven

I am not sure as we use external PGSQL servers but PGAdmin should be able to do this.  That way you don’t have to use Veeam Configuration Backup method.


@StevenA -

Below is what was done for SQL, but I wasn’t able to find anything for PSQL. 
 

You can probably contact Veeam Support to help you do what you’re wanting, or search for the PGAdmin tool to migrate your DB to a different storage location.


I’ve done the following with success. (Make a config backup first)

 

1. **Stop Veeam Backup & Replication Services:**
   - Go to `Services.msc` and stop all Veeam-related services to prevent any write operations during the migration.

 

2. **Backup the PostgreSQL Database:**
   - Use `pg_dump` to back up the database before moving it:
     ```bash
     pg_dump -U username] -W -F c -b -v -f "C:\Backup\VeeamDB.backup" edatabase_name]
     ```
   - Replace ` username]`, `adatabase_name]`, and specify the actual path for the backup file.

 

3. **Locate and Move PostgreSQL Data Directory:**
   - Locate the PostgreSQL data directory, usually found in `C:\Program Files\PostgreSQL\XX\data`.
   - Copy this data directory to your new desired location (e.g., `D:\PostgresData\`).

 

4. **Update PostgreSQL Configuration:**
   - Open `postgresql.conf` (usually in the data directory).
   - Update the `data_directory` parameter to the new location:
     ```plaintext
     data_directory = 'D:/PostgresData'
     ```

 

5. **Update Veeam Connection String:** (I think the DB utility can be used here but haven’t tried it for this)
   - Open Veeam’s configuration files to update the database connection string, if applicable.
   - Often, it’s enough to check the `Veeam Backup Service` config file in `Drive:\ProgramData\Veeam\Backup`. (default - C:\ProgramData\Veeam\Backup\VeeamBackup.xml)

 

6. **Restart PostgreSQL and Veeam Services:**
   - Restart the PostgreSQL service, ensuring it points to the new directory.
   - Start the Veeam services back up and test the connection to confirm the move was successful.

 

7. **Verify Database Functionality:**
   - Launch Veeam Backup & Replication and perform some basic tasks to ensure everything is functioning correctly with the new database location.

 

 

- Ensure that the PostgreSQL user account has the necessary permissions for the new data directory.


Comment