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 am trying to build an automated background backup program to backup my entire website and its heavy photo folders, using Amazon's cloud storage service, S3.

I am using S3Sync from S3Tools and have successfully tested a dummy backup using only the command line window. When I save the working command line to a batch file (.BAT) and have a Windows schedule call it, it does not work.

I can only think this has something to do with the local paths set in the command line. If I go on to my server and open the command prompt from my 'Start' button, the command prompt has a default of:

c:\Documents and Settings\administrators>_

If I go on to my server and go to c:\windows\system32 directory and open cmd.exe, the default is:

c:\windows\system32>_

Which makes me think this is the problem, I think I'm getting something like this when it's run:

c:\windows\system32c:\home\p\h\photos\private\s3sync\s3sync.exe

What is the sensible way to get around this? Can I change the default directory on the command prompt processor, when it's first loaded? Or is there a way of changing my batch command code to use the local paths correctly? Maybe this isn't the problem at all and it's something else?

Any help greatly appreciated.

My command line code:

c:\home\p\h\photos\private\s3sync\S3Sync.exe -AWSAccessKeyId xxx -AWSSecretAccessKey xxx -SyncDirection upload -LocalFolderPath "C:\home\p\h\photos\www\assets_web2" -BucketName op-photos-web -RequestEndpoint s3-eu-west-1.amazonaws.com
share|improve this question

1 Answer 1

up vote 2 down vote accepted

You can set the directory from the .bat file: (in your case) cd "C:\home\p\h\photos\private\s3sync\" prior to calling the S3Sync.exe. That should get you to that path, given its on the same drive.

If the file is on a different drive, issuing the C:\ (or whichever drive you'd like to navigate to) before calling the application EXE will change to that drive as well.

Other ways also include setting the starting path for the scheduled task in its properties under the Task Scheduler:

On Server 2003: Under Task tab, edit the "Start in" input box accordingly

On Server 2008: Under the Actions tab, edit the appropriate action and set the "Start in (optional):" accordingly.

Hope it helps!

share|improve this answer
    
That's really helpful, thanks. Right, I opened the command prompt window, it had the default location of (c:\Documents & Settings\Administrators>_) and I first typed in cd c:\home\p\h\photos\private\s3sync\ and then I typed s3sync.exe and it worked okay. So now, how can I call two command lines in the same batch file? –  PaparazzoKid May 11 '12 at 16:34
    
You can simply daisy chain them together separated by new lines. –  astigx May 11 '12 at 16:36

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.