Sign in with
Sign up | Sign in
Your question

"Sync" folders with scrip and xcopy

Tags:
  • Computers
  • Servers
  • Networking
Last response: in Networking
Share
April 24, 2011 7:47:13 AM

My goal is to be able to sync all of my home movies and pictures, to multiple computer with in the house, so if a hardware faller does occur, I Don't loose anything. And to add more from multiple locations as well. Something like dropbox. Only with my own server, an on a local network. I have tried some program in the past, as they all never seamed to work right. So I made my own sorta :) . I wanted to run it by you guys to see if you can see any problems I might run in to.

I have a script file, on my server, very simple, first thing is does it run net use and connects up to all of my local computer shared folders that I want synced.
net use '\\computer1\foldertosync"
net use '\\computer2\foldertosync"
net use '\\computer3\foldertosync"
net use '\\computer4\foldertosync"
then I have xcopy run to copy all of the new files it can find on the computers around the house

xcopy "\\computer1\foldertosync" "local path on server when my sync folder is stored" /D /E /Z
xcopy "\\computer2\foldertosync" "local path on server when my sync folder is stored" /D /E /Z
xcopy "\\computer3\foldertosync" "local path on server when my sync folder is stored" /D /E /Z
xcopy "\\computer4\foldertosync" "local path on server when my sync folder is stored" /D /E /Z

then I have xcopy run agian only reverse to is can distriput all of the new files it found to the other computers.

xcopy "local path on server when my sync folder is stored" "\\computer1\foldertosync" /D /E /Z
xcopy "local path on server when my sync folder is stored" "\\computer2\foldertosync" /D /E /Z
xcopy "local path on server when my sync folder is stored" "\\computer3\foldertosync" /D /E /Z
xcopy "local path on server when my sync folder is stored" "\\computer4\foldertosync" /D /E /Z

/D syntax copies only those files whose source time is newer than the destination time. So when I reverse the copy or run the copy again it doesn't try to recopy everything. because the source time is the same.

/E syntax just copies all the folder (even empty ones)

/Z syntax I heard it will pause the copy if network connection is lost, then resume it when it is back up, but I don't know for sure, just thought it would be fun to try.

I put this scrips in my task scheduler, to run everyday at 5:30.

So there you have it. Any problems you see in this setup?
The only thing I can't do easily is delete something or rename a file. I would need to delete for all location I have is syncing to, or else it will resync.

My next step it so look at moveing files, some computer I don't want the entire media library on it locally, but I do want to be able to add to it. Like a laptop.


Any input it much appreciated.

More about : sync folders scrip xcopy

April 24, 2011 6:34:04 PM

I added the /Y Switch, because it looks like if the copy get interrupted, when it start again the next day, it need to override the file it was copying when the interruption occurred. And require user input to confirm the override or not. This might of happen because of the /Z switch I added, but I am not sure.
m
0
l
!