Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
    
If the network share is shared to "everyone" the you can use net use Z: \\SERVERNAME\SHARE –  Trozz Apr 15 '11 at 7: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 7:26
    
no problem mind just adding a vote to the answer i just attached :) –  Trozz Apr 15 '11 at 12:56
add comment

2 Answers

up vote 2 down vote accepted
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
share|improve this answer
    
yea, I suppose that language-specific comments might be helpful... –  gWaldo Apr 19 '11 at 0:16
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.