Skip to main content
Solved

Move PostGreSQL from drive C to D


Hi

(Veeam version 12.2.0.334)

I want to move the PostGreSQL database from drive C to drive D.

Following my steps, the PostgreSQL service starts correctly. However, the Veeam service doesn't start.

I haven't found a clear procedure for this. Do you have any idea what's missing?

Here are the steps I followed:

I stopped all "Veeam" services and the "postgresql-x64-15" service.

I performed a robocopy.

From : C:\Program Files\PostgreSQL\15\data

Move to : D:\PostgreSQL\15\data

My script :

for /f "tokens=1-5 delims=:" %%d in ("%time%") do set tmptime2=%%dh%%e

set tmpTimeHeureMinute=%tmptime2: =0%

for /f "tokens=1-5 delims=/ " %%d in ("%date%") do set tmpDate=%%d-%%e-%%f

robocopy "C:\Program Files\PostgreSQL\15\data" "D:\PostgreSQL\15\data" /MIR /SEC /NP /ETA /LOG:C:\Robocopy\Log\MovePostGreSQL%tmpDate%-%tmpTimeHeureMinute%.log /R:1 /W:1

No errors, all files have been copied

I renamed the directory C:\Program Files\PostgreSQL\15\data to C:\Program Files\PostgreSQL\15\data-001

 

I changed the Windows service with this command:

sc config postgresql-x64-15 binPath= "\"C:\Program Files\PostgreSQL\15\bin\pg_ctl.exe\" runservice -N \"postgresql-x64-15\" -D \"D:\PostgreSQL\15\data\" -w"

 

I started the postgresql-x64-15 service: Success

I tried to manually start the "Veeam Backup Service" (VeeamBackupSvc): Failed

Reboot the server -> "Veeam Backup Service" (VeeamBackupSvc): Failed

 

Here is the error visible in the Windows Event Viewer (part of the error message was in French because my server is in Canadien French. So, I made a free translation!):

Veeam.Backup.DBCreator.DatabaseException: Failed to connect to PostgreSQL server localhost:5432. 42501: could not open the base file /5/1259 : Permission denied ---> Npgsql.PostgresException: 42501: could not open the base file /5/1259 : Permission denied

 

Original error :

Le service ne peut pas être démarré. Veeam.Backup.DBCreator.DatabaseException: Failed to connect to PostgreSQL server localhost:5432. 42501: n'a pas pu ouvrir le fichier base/5/1259 : Permission denied ---> Npgsql.PostgresException: 42501: n'a pas pu ouvrir le fichier base/5/1259 : Permission denied à Npgsql.Internal.NpgsqlConnector.<<ReadMessage>g__ReadMessageLong|223_0>d.MoveNext() --- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée --- à System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) à Npgsql.Internal.NpgsqlConnector.<<Open>g__OpenCore|203_1>d.MoveNext() --- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée --- à System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) à Npgsql.Inte...

 

Do you have any suggestion?

Best answer by CMF

Hi ​@ITSupport04072025 ,

There was an article last month about this issue by ​@PeteSteven .

 

Regards

Chalid

View original
Did this topic help you find an answer to your question?

5 comments

CMF
Forum|alt.badge.img+8
  • Veeam Legend
  • 86 comments
  • Answer
  • July 4, 2025

Hi ​@ITSupport04072025 ,

There was an article last month about this issue by ​@PeteSteven .

 

Regards

Chalid


Chris.Childerhose
Forum|alt.badge.img+21

In order to move Veeam you need to use the configuration backup and restore it once the Postgres is moved.  That is the easiest way.

You can try running the Database Configuration tool to repoint Veeam to the new location as well.  This might work better than the other option.  This will repoint Veeam and make the changes you need to start services.


Link State
Forum|alt.badge.img+11
  • Veeam Legend
  • 685 comments
  • July 4, 2025

hi ​@ITSupport04072025  check this

PostgreSQL DB relocation | Veeam Community Resource Hub

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.


Marcel.K
Forum|alt.badge.img+9
  • Veeam Legend
  • 273 comments
  • July 4, 2025

If you would like to change database with binaries. Please check my my blog

There is E2E how to do that. Very easy.

I have described there user change as well, but you can skip this part.


Great news!

Moving the files worked perfectly with the article provided (PeteSteven).

Thank you very much!


Comment