Synchronizing folders with external USB backup HDD?

Discussion in 'Software' started by MrPipps, Jun 3, 2008.

  1. MrPipps

    MrPipps Private E-2

    Hello

    I would really like to know how to synchronize the files in a certain way.

    I have a group of folders and subfolders which are stored on my local c: drive. I also have this same group of folders backed up on my external USB HDD e: drive.

    I regularly create new files in my local folder, and would like to be able to use some form of synchronization to be able to copy those files into the relevant sub-directories of the backup drive.

    Would this be possible within Windows XP?

    I look forward to your help.

    Thank you.
     
  2. Mada_Milty

    Mada_Milty MajorGeek

    Are all the files and folders you're looking to synchronize kept in a single parent folder?

    If so, a simple batch script will do the trick. It's what I use in my setup, which is much like your own. (Only I keep my data on a separate partition).
     
  3. MrPipps

    MrPipps Private E-2

    Yes, that's absolutely correct. All the files sit beneath a single parent folder, albeit within many own their own subfolders.

    I would be really grateful if you would share the details of your batch script. This sounds like exactly what I've been looking for! :)
     
  4. Mada_Milty

    Mada_Milty MajorGeek

    Code:
    @echo off
    xcopy [I]<path_to_local_directory>[/I]\*.* e:\*.* /ekidcy
    xcopy e:\*.* [I]<path_to_local_directory>[/I]\*.* /ekidcy
    If you were to copy the above into notepad, replace <path_to_local_directory> with the path to your document directory, and save as filename.bat, you would have a script that would do this for you.

    Pros:
    It does incremental backups. Once the folder has been backed up once, this script will only backup new and changed files, saving a LOT of time, in most cases.
    This is easy to work with, just a text file, and can be scheduled to run with a certain frequency, on login or logout of Windows, or manually on-demand.
    It is bidirectional, so if you take your hard drive to another machine, and put files on it, your local directory will also be synched with the external drive.

    Cons:
    Incremental backups. Files that are removed from one source are not automatically removed from the other. Files must be deleted from both sources, or a new full backup must be done periodically. (Delete entire backup, and make a new one)
    Static directory mappings. Any new directories to be synched must be added to the script if they are not inside the parent folder. Otherwise, they will be missed. Also, the external hard drive must always be at the drive letter E: or the entire sync will fail.
     
  5. MrPipps

    MrPipps Private E-2

    This sounds really good.

    Would you mind confirming how it should work in practice for me on this basis?

    If I substitue <path_to_local_directory> for a folder called Music on both drives, then if I add a new file to c:/Music/June, will it be included in folder e:/Music/June?

    I am hoping that I would not have to specify every single subfolder in my batch file. Can you confirm whether this would be the case?
     
  6. Mada_Milty

    Mada_Milty MajorGeek

    No, you should only need to specify the PARENT folder, and these commands will copy all existing and future subfolders of that parent. Your E: drive should be an exact copy of this parent directory when run, subfolders and all.

    Its when you go outside that parent folder that you will need to add more lines to the script.
     
  7. MrPipps

    MrPipps Private E-2

    That is absolutely brilliant! :)

    And just to confirm, because I'm a little new at this, would the following interpretation of your suggested batch file appear appropriate?

    Code:
    @echo off 
    xcopy C:\Documents and Settings\me\Desktop\Music\April\*.* E:\*.* /ekidcy 
    xcopy E:\*.* E:\Music\April\*.* /ekidcy
    I am excited! :)
     
  8. Mada_Milty

    Mada_Milty MajorGeek

    Last line is in error. (I think)

    The general format of the xcopy command is this:

    Code:
    xcopy source_directory destination_directory [options]
    So, I ~think~ for this to copy from external drive to your local folder, you would need to replace the last line with this:

    Code:
    xcopy e:\*.* c:\documents and settings\me\desktop\music\april\*.* /ekidcy
    This will copy everything from the E: drive into your Music\april folder on your desktop. What you have now should copy everything on the E: drive back into the april folder on the E: drive, and you will end up with a ton of duplicates!

    Side note: Any path that has spaces in it needs to be wrapped in quotes. The computer is too dumb to know the difference between a space in the path, and the next parameter of the command. So, your final script should look like this:

    Code:
    @echo off
    xcopy "c:\documents and settings\me\desktop\music\april\*.*" e:\*.* /ekidcy
    xcopy e:\*.* "c:\documents and settings\me\desktop\music\april\*.*" /ekidcy
    This will make sure that your music\april folder and external hard drive are in sync.
     
  9. MrPipps

    MrPipps Private E-2

    Ah, well to clarify, I will always be creating the new files in the folder on my desktop, and then for the external drive to be periodically updated to reflect the desktop directory.

    In order to achieve that, would you mind advising as to how should I amend the script?

    I am grateful for all your input on this! :)
     
  10. Mada_Milty

    Mada_Milty MajorGeek

    Okay, so for everything inside the Music folder, remove any references to the April folder.

    Unless you want to use the April folder as the parent, in which case, you're okay.
     
  11. MrPipps

    MrPipps Private E-2

    That sounds good. I will do exactly as you say.

    And sorry to ask again, but would you mind confirming - will the following script, that you kind posted, periodically copy all files from the folder on my desktop to the folder on my external drive?

    Code:
    @echo off
    xcopy "c:\documents and settings\me\desktop\music\*.*" e:\*.* /ekidcy
    xcopy e:\*.* "c:\documents and settings\me\desktop\music\*.*" /ekidcy
    Or in other words: c:\desktop\music ---> e:\music ...?
     
  12. Mada_Milty

    Mada_Milty MajorGeek

    As it is now, this will copy the contents of the music folder to the E: drive, but there will be no music folder on the E: drive. If you want to do that, simply change e:\*.* to e:\music\*.*

    As for running periodically, as it is, this will only run when you double-click on the batch file you create. If you want to have it run automatically, that's probably a topic best left for after a successful test of the script.
     
  13. MrPipps

    MrPipps Private E-2

    That is brilliant. I will try it right away! Thank you so much :)
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds