Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Tool to synchronize two directories
Message
From
15/03/2010 08:31:41
Guy Pardoe
Pardoe Development Corporation
Peterborough, New Hampshire, United States
 
 
To
14/03/2010 23:38:09
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
VB 9.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01454472
Message ID:
01454509
Views:
68
This message has been marked as a message which has helped to the initial question of the thread.
Hi Michel,

I use RoboCopy for things like this.


You can backup or mirror any single directory or entire tree. I often backup certain designated directories with a batch file like so...

ROBOCOPY C:\ThisFolder E:\MyPC\ThisFolder /MIR /R:5 /W:1 /NP /LOG:C:\Backup_MyPC.Log
ROBOCOPY C:\ThatFolder E:\MyPC\ThatFolder /MIR /R:5 /W:1 /NP /LOG+:C:\Backup_MyPC.Log
ROBOCOPY C:\TheOtherFolder E:\MyPC\TheOtherFolder /MIR /R:5 /W:1 /NP /LOG+:C:\Backup_MyPC.Log


Or you can also backup an entire PC like so...

ROBOCOPY C:\ E:\MyPC\C_Drive\ /MIR /R:5 /W:1 /NP /XF pagefile.sys /LOG:C:\Backup_MyPC.Log


The examples above use the mirroring switch. This copies only the files that have changed. It's also important to understand that if a file is opened, it will not be copied/mirrored. When I backup a PC that has MS SQL Server installed, I also add some lines to the batch file to stop and restart the SQL services, such as...

NET MSSQLSERVER STOP
NET SQLAGENT STOP
...
...
...
NET MSSQLSERVER START
NET SQLAGENT START

That makes sure the SQL databases are also copied.

To explain the switches I often use...

/MIR - mirror the source to the target; copy anything new; delete anything on the target that is not on the source.

/R:5 - retry any file up to 5 times if you hit an error (such as file open, etc)

/W:1 - wait 1 second between retries

/NP - no progress indicator, (such as % copied, etc)

/XF - exclude file (list any files you don't want copied/mirrored)

/LOG: - Filename (if you want a log file written)

Notice also in the first example above, how the + is used in the /LOG: switch to append to the log instead of creating a new log file with each subsequent ROBOCOPY command.

And lastly, if you have spaces in the directory structure that you're specifying, use quotes for the path names like so.

ROBOCOPY "C:\Program Files\My Important Folder" "E:\MyPC\Program Files\My Important Folder" /MIR /R:5 /W:1 /NP /LOG:C:\Backup_MyPC.Log


Hope this helps,
Guy


>I would like to obtain a tool that will help me synchronize my laptop based on a set of directories I have on my PC. Basically, it is not about copying each time the entire directory structure. I am looking for something that will only copy the updated files, the new ones and remove the ones that no longer exists. Is there such a tool somewhere? If I could have something in .NET, that would also be interesting.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform