Sunday, November 30, 2008

Sycronize Windows Files to External Drive

Issue:
You want to have the same files at home and at work and keep them in Sync

Quick/Visual/Learning:
I have not been very happy with the speed of the synchronization programs I have tried in the past. There are probably some good ones out there somewhere.

As of right now I am using some free utilities to do the job. Robocopy is a fast command-line copy utility from the Windows Resource Kit that you can download here. There are a lot of options and you can get some instructions for those here.

Typically what I do is copy my work files to an external disk to take home and my home files to an external disk to take to work. (I am sure someone has figured out a secure over the Internet windows to windows sync but I have not taken the time yet to find it).

So I use robocopy in a bat file like this:
robocopy "C:\Sync" F:\Sync /mir /z /R:0 /W:0 /v /np /log:Sync2Home.txt

This is fast and works great. Only newer files get updated. The /mir will remove old things from the F drive that I have deleted from my master file copy on the C drive.

The problem is that if I forget and make a change on my F drive those changes get deleted the next time I run the robocopy command. This happens because the /mir trys to make the target look just like the source and extra stuff on the F drive is deleted.

As a workaround for this I decided to use the /xo /xx switches. The /xo command says to not backup files where the source is older. The /xx says not to delete extra files and directories on the destination.

Now changes on the destination do not get wiped out but I need to reconcile any differences. I need to quickly find the problem areas (these get logged to the log file). I use another tool called baregrep to search for destination files marked as Newer or Extra. This tool can be found at baremetalsoft here.

So what I have now in my bat file is this:

robocopy "C:\Sync" F:\Sync /mir /z /R:0 /W:0 /v /xo /xx /np /log:Sync2Home.txt
baregrep "Newer(vertical bar pipe symbol goes here)EXTRA" robologhmhsync.txt

This shows me a list of things I need to fix. If there were a lot of changes this would be too much work but for now my changes are few.

Extra stuff is easy just copy it over to the source drive.
If the file is newer on the destination drive I could just copy it over as well as long as the source file has not changed too since the last backup. Any file that I might change is either going to be a Word, Excel, or a text file.

For text files I can use the dos FC command to find differences.

> fc C:\Sync\File F:\Sync\File /N

Here is a test I did:

C:\>fc t.txt c:/test/t.txt /n
Both of these files had the letter a through p, on letter to a line.
I added a line of text to the source and another line to the destination file.

Comparing files t.txt and C:/TEST/T.TXT
***** t.txt (YOU SEE TEXT WAS INSERTED ON LINE 3)
2: b
3: Text added to Source File
4: c
***** C:/TEST/T.TXT
2: b
3: c
*****

***** t.txt (YOU SEE THAT TEXT WAS INSERTED ON LINE 9)
9: h
10: i
***** C:/TEST/T.TXT
8: h
9: Text added to Destination File
10: i
*****

For Word and Excel file I can use the merge command to merge any changes.

In Excel
For each workbook, Go to Tools>Share Workbook..
On the Edit tab select the check box that says:
"Allow changes by more than one user at a time to enable workbook merging."
Go to Tools and do Merge command and pick the other file.
Cells get updated with note about changes when done.

Tools / Track Changes / "Accept or Reject Changes"
Lets you approve or reject each change.


In Word (Here is a good page for this)
Open source document
Go to Tools menu / Compare and Merge Documents
Merge (legal blackline unchecked)
Changes are updated and you can accept or reject changes.

1 comment:

Bruce said...

Today,we are proud to announce the launch of the new wedding support service sell ffxi gil,packed with features sure to sell ffxi gils delight adventurers across Vana'diel looking to exchange eternal vows with their beloved!Responding to player demands for greater customization,the new service will grant brides and grooms freedom in choosing location,timing,dialogue,and sell Final Fantasy XI Gil more for their ceremony,allowing them to create a truly memorable event all their own.Information on all the features,including in-game sell ffxi gil item vendors and wedding certificates,can be found on the new wedding support site,so head on over sell ffxi gils and get started planning the wedding of your dreams sell Final Fantasy XIGil!