bayouexpert
asked on
Move a folder from one server to another using a vb script, bat or cmd
I have a folder c:\backups on server name ares that I want to move to a mapped drive J:\temp\backups. J: drive is a mapped drive to another server named dellbackup. I need a .vbs, .bat or .cmd script to do this at a scheduled time every day using windows scheduled tasks.
ASKER
Yea, I tried that with the /RS /RC commands and it didn't work. It copies the folder but doesn't delete the source. I need to MOVE the folder so it needs to be gone from the source location
there's a microsoft utility calle robocopy, works like a charm, i use it daily on scheduled task to MIRROR some directories as a backup policy, it updates, deletes an adds as necessary, depending on the OS version you have maybe it's already installed or you'll have to download it from microsoft, once you have it installed in both machines your *.bat file maybe something like this:
robocopy D:\mypath \\172.1.1.5\d$\mypath /E /MIR /NP /R:1 /W:1 > d:\backups\log_backup.txt
ypu can get it from here:
http://www.microsoft.com/downloads/details.aspx?familyid=9d467a69-57ff-4ae7-96ee-b18c4790cffd&displaylang=en
robocopy D:\mypath \\172.1.1.5\d$\mypath /E /MIR /NP /R:1 /W:1 > d:\backups\log_backup.txt
ypu can get it from here:
http://www.microsoft.com/downloads/details.aspx?familyid=9d467a69-57ff-4ae7-96ee-b18c4790cffd&displaylang=en
you'll need to use the following option to delete source once the copy is made:
/MOV :: MOVe files (delete from source after copying).
/MOVE :: MOVE files AND dirs (delete from source after copying).
I like a lot this utility 'cause it resumes the copy process as many times is necessary in case there are communication outages or errors.
/MOV :: MOVe files (delete from source after copying).
/MOVE :: MOVE files AND dirs (delete from source after copying).
I like a lot this utility 'cause it resumes the copy process as many times is necessary in case there are communication outages or errors.
ASKER
I"m going to try it with Robocopy right now. so they command would look like this??
c:\temp z:\backup /MOVE ??? Would this move the TEMP folder to the backup folder or just move everything within the temp folder to the backup folder???
c:\temp z:\backup /MOVE ??? Would this move the TEMP folder to the backup folder or just move everything within the temp folder to the backup folder???
ASKER
Problem. the Target Directory is on a different server. I can't get it to work in DOS but I downloaded the GUI and it works great. How can I get the command that the GUI is running so I can put it into a .vbs and schedule it as a scheduled task?
Here this is what you need to run to do: If you are using Windows 2003 or prior Download and install the GUI on the server where the script will run.
(If you are running this on Windows 2008/2008r2/vista/ or 7 the Robocopy command is already present by default and includes improved functionality. So you would NOT want to install the GUI on these systems)
Then you can schedule the command or a batch file with the Robocopy commands if you want to do something complex or just to keep editing the process more simple than using task scheduler.
To run Robocopy from the command line:
RoboCopy "c:\backups" "J:|Temp\Backups" * /MOVE /ZB /E
NOTE: IT IS ALWAYS BETTER TO USE A UNC PATH TO THE SERVER INSTEAD OF A MAPPED DRIVE! Below is an example of this:
Robocopy "C:\Backups" "\\DellBackup\Share\Temp\B ackup" * /MOVE /ZB /E
(If you are running this on Windows 2008/2008r2/vista/ or 7 the Robocopy command is already present by default and includes improved functionality. So you would NOT want to install the GUI on these systems)
Then you can schedule the command or a batch file with the Robocopy commands if you want to do something complex or just to keep editing the process more simple than using task scheduler.
To run Robocopy from the command line:
RoboCopy "c:\backups" "J:|Temp\Backups" * /MOVE /ZB /E
NOTE: IT IS ALWAYS BETTER TO USE A UNC PATH TO THE SERVER INSTEAD OF A MAPPED DRIVE! Below is an example of this:
Robocopy "C:\Backups" "\\DellBackup\Share\Temp\B
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
xcoyp /?