[<<]Message[>>]    [<<]Author[>>]    [<<]Subject        [<<]Thread    

Number : 9365 Date : 2004-11-24 Author : John Zeman Subject : Re: Synchronizing two computers Size(KB) : 8
--- In xxcopy@yahoogroups.com, "iberesilva" wrote: > > --- In xxcopy@yahoogroups.com, "John Zeman" wrote: > > > > --- In xxcopy@yahoogroups.com, "Rick Holt" wrote: > > > > > > This has probably been answered before, but... > > > > > > I have two computers in which I want to synchronize a set of > > > directories. For reasons too complicated to mention here, I > can't > > > just connect the two machines. So I want to use a USB flash > drive > > > which I can carry between the two machines. And, of course, I > want to > > > use XXCOPY. > > > > > > One method would be to write the entire directory to the flash > drive > > > and synchronize both machines to that. But most files are old. > Why > > > would I want to keep all of them on my rather small flash drive > when > > > they are never used? > > > > > > A better way (but maybe not supported by XXCOPY) would be to put > a > > > list of files on the flash drive, along with any files which > need to > > > be copied. Doing it this way, I could probably synchronize 1-2G > using > > > just my 256M flash drive. > > > > > > But, does XXCOPY support anything like this? Does any other > simple, > > > command line program like XXCOPY do this? > > > > > > Xxcopy can do this, but it has to do it in multiple > > steps. Here is one way you can solve the problem, > > however it may not be practical if the two computers > > are a great distance apart. You could streamline > > things a bit by using two flash drives, starting with > > one connected to each computer. > > > > The key to this working are the temporary zero byte > > file lists created in steps 2 and 6. These steps > > generate a directory skeleton of files on the flash > > drive that represent the files on the computer that the > > flash drive is connected to. And because the skeleton > > contains only zero byte files, the entire flash drive > > file list takes up very little space. This skeleton > > will have the same file dates that the original files > > will have on either computer 1 or 2, depending which > > step of the process you're at. By comparing those file > > dates, you can synchronize your two computers with the > > flash drive. > > > > Below is an 8 step xxcopy process to synchronize the > > files on two computers using a third transportable > > device. In the batch file I'm not actually using two > > different computers, I'm simulating two machines by > > synchronizing two different locations in the same > > computer. > > > > Computer 1 is represented by > > "C:\test folder\computer 1\" > > > > Computer 2 is represented by > > "C:\test folder\computer 2\" > > > > For you to put this to use, you would need to break the > > batch file apart at the points where I put the pauses > > and adapt it to your needs. > > > > Of course this assumes that the file differences > > between computer 1 and computer 2 will not exceed the > > capacity of your flash drive. > > > > John > > > > > > @echo off > > > > :: Computer 1 = "C:\test folder\computer 1\" > > :: Computer 2 = "C:\test folder\computer 2\" > > :: Flash Drive = I:\ > > > > :: Use these primary options for xxcopy > > set OPTS=/KS/H/E/R/Q/Y/BN/TCW > > > > > > :: Begin with flash drive connected to computer 1 > > > > :: Step 1 Clear flash drive of all files > > cls > > echo Clearing flash drive > > xxcopy I:\ /RMDIR /RSY /Q3 /RSY /Y /ZS > > > > :: Step 2 Create computer 1 zero byte files on flash drive > > cls > > echo Copying computer 1 zero byte file list to flash drive > > xxcopy "C:\test folder\computer 1\" I:\ %OPTS% /tr0 > > > > cls > > echo Move flash drive to second computer before continuing. > > pause > > > > :: Step 3 Using computer 2, back up files to flash drive > > cls > > echo Copying computer 2 to flash drive > > xxcopy "C:\test folder\computer 2\" I:\ %OPTS% > > > > > > cls > > echo Move flash drive to first computer before continuing. > > pause > > > > :: Step 4 Copy flash drive back into computer 1 > > cls > > echo Copy flash drive to computer 1 > > xxcopy I:\ "C:\test folder\computer 1\" %OPTS% /sz!0 > > > > :: Step 5 Clear flash drive of all files > > cls > > echo Clearing flash drive > > xxcopy I:\ /RMDIR /RSY /Q3 /RSY /Y /ZS > > > > > > cls > > echo Move flash drive to second computer before continuing. > > pause > > > > :: Step 6 Create computer 2 zero byte files on flash drive. > > cls > > echo Copying computer 2 zero byte file list to flash drive > > xxcopy "C:\test folder\computer 2\" I:\ %OPTS% /tr0 > > > > cls > > echo Move flash drive to first computer before continuing. > > pause > > > > :: Step 7 Using computer 1, back up files to flash drive > > cls > > echo Copying computer 1 to flash drive > > xxcopy "C:\test folder\computer 1\" I:\ %OPTS% > > > > cls > > echo Move flash drive to second computer before continuing. > > pause > > > > :: Step 8 Copy flash drive back into computer 2 > > xxcopy I:\ "C:\test folder\computer 2\" %OPTS% /sz!0 > > > > cls > > echo All Done > > pause > > Dear John, > > I appreciated very much your explanation. I have the same > situation. However, using your batch file in all the steps, just > COPY and keep all the data into the two computers synchronized. > > But, what if in any computer I delete a file and want to delete the > same file on the other computer? I tried your batch file and this > option did not work. On file deleted in the source is not deleted > on the destination. I would like to be prompted by the batch file > when it finds a file that have to be deleted. Is it possible? > > Thank you for your help on this matter, > > Ibere With one way synchronization, which is what the xxcopy /clone option does, it is pretty straight forward when it comes to xxcopy deleting files. If a file exists on the destination that does not also exist on the source, it is deleted. But when you try to do this during a 2-way synchronization, it could result in creating more problems than it would solve. For example, suppose a file exists in computer 1, that does not exist in computer 2. The question then becomes: Should xxcopy copy that file from computer 1 to computer 2? Or should it delete it from computer 1 so the file no longer exists anywhere? See the problem? If I really set my mind to it, I expect I could write a script that would look at the differences between the source and destination using a flash drive, and then prompt you to either copy or delete a file when it does not exist on both computers. However, this would result in your having to decide in every instance, whether a file should be copied to the other computer or deleted from the one you are using. And just one wrong keystroke while do that could result in a disaster. So what I would suggest instead, would be to synchronize the two computers normally (without deleting anything) so everything is the same between them. Then, using one of the machines, manually delete any unwanted files from it. For example say after synchronizing, you sit down at computer1 and manually delete the extra unwanted files. Once you have done that, you could use xxcopy to delete those same files in computer2 using the flash drive like this: :: Begin Batch File ////////////////////////////// @echo off :: Begin with flash drive connected to computer 1 :: Step 1 Clear flash drive of all files cls echo Clearing flash drive xxcopy I:\ /RMDIR /RSY /Q3 /Y /ZS :: Step 2 Create computer 1 zero byte files on flash drive cls echo Copying computer 1 zero byte file list to flash drive xxcopy "C:\test folder\computer 1\" I:\ /BU /tr0 cls echo Move flash drive to second computer before continuing. pause echo Deleting extra files from computer 2 xxcopy "C:\test folder\computer 2\" "I:\" /H/E/R/Q/BB/RSP/pd0 :: End Batch File ///////////////////////////////// The above script could be used without first synchronzing two computers, any file that exists on computer 2, that does not also exist on computer 1, will be deleted (after you are prompted to do so). As a final note, I should mention that in my original batch file (message #9354) in the sections where the flash drive is being cleared, I inadvertently had two /RSY options. Of course only one is needed so the second one can be removed. John
This message if part of XXCOPY's message Archive. The archive contains all the messages posted at Yahoo!Groups: XXCOPY.