0

I have written PostgreSQL backups scripts that backup all the databases to file. pgAgent.exe (a scheduling daemon) starts the BAT scripts under the local postgres user.

The normal setup is to backup to a local drive and get the backup program to pick up the files but we have a client that would like to backup to a network drive.

I tried running pgAgent and by extension the scripts under the administration user and still did not have any luck. (same user that had the drive mappings)

When i login to the postgres user by running runas.exe /user:postgres cmd.exe and type cd /D Z: I get the error The system cannot find the drive specified.

Now from what i understand, network drives are mapped on a per user session basis. is there a special trick to accessing the network drives from a command prompt?

jscott
  • 24,484
  • 8
  • 79
  • 100
Silverfire
  • 790
  • 4
  • 14
  • If the network share is shared to "everyone" the you can use net use Z: \\SERVERNAME\SHARE – trozz Apr 15 '11 at 07:00
  • I made an login for the postgres user and added at the start of the script "net use Z: \\server\share /user:domain\user *password*" thanks Trozz for pointing me in the right direction :) – Silverfire Apr 15 '11 at 07:26
  • no problem mind just adding a vote to the answer i just attached :) – trozz Apr 15 '11 at 12:56

2 Answers2

2
REM Mount Z:\ as the user with permissions; you may need to add the password
net use z: \\server\share /user:domain\user

REM copy things here
REM ...

REM unmount the drive letter
net use z: /d
jscott
  • 24,484
  • 8
  • 79
  • 100
gWaldo
  • 11,957
  • 8
  • 42
  • 69
1

If the network share is shared to "everyone" the you can use net use Z: \\SERVERNAME\SHARE

jscott
  • 24,484
  • 8
  • 79
  • 100
trozz
  • 557
  • 2
  • 12