Click here to Skip to main content
Click here to Skip to main content

Utility to backup your folders fast

By , 31 Jul 2005
 

Sample Image - sync.png

Introduction

This utility is designed to backup a folder to another folder. It is not rocket science and not that interesting in terms of coding. However it can be useful if you want to copy your source from a machine to another or to make a quick backup. It will run a lot faster than a batch file if you repeat the command regularly.

How does this work

The program is very simple, it will copy only the files that were modified since the previous copy. It will always copy the subfolders and never ask any question. Any file or folder deleted from the source folder will also be deleted in the destination folder.

How to install

Just have to copy sync.exe into your windows\system32 folder.

How to run?

Just type SYNC <source folder> <destination folder> in your DOS command prompt window or batch file.

WARNING

This program despite being very simple is potentially lethal. Used with bad parameters, you can probably manage to erase your hard disk in no time at all. Use it only at your own risks.

Points of interest

Nothing very interesting in this program, this is a DOS utility not a code exploit. For each folder in the source tree, the utility gets a list of files and folders to copy to the destination. To avoid multiple lookups, the list of files in the destination folder are read once as well into a hash table. The program uses the FileSystemInfo.LastWriteTimeUtc to compare the source and destination files. It then copies the new or modified files and deletes the files that were deleted since the last backup. Again be careful how you use this utility, the deletion does not ask any questions.

Revisions

  • 31st July 2005
    • First release.
  • 1st August 2005
    • Force the copy when the files are read-only.
    • Move to .NET framework 1 (was 2 so far).

Questions to readers

When I use the IO.File.Copy method, the FileSystemInfo.LastWriteTimeUtc is modified one or two seconds forward. Anyone knows how to make the date of last write to stay consistent from source to destination?

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Pascal Ganaye
Software Developer (Senior)
United Kingdom United Kingdom
Member
I am a French programmer.
These days I spend most of my time with the .NET framework, JavaScript and html.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralConverted the code to C# and changed the date comparison to SHA CheckSum Pinmemberkittell23 Apr '13 - 6:55 
GeneralMicrosoft's SyncToy PinmemberJalapeno Bob9 Sep '10 - 11:54 
GeneralMy vote of 1 PinmemberYury300024 Aug '09 - 14:59 
GeneralRe: My vote of 1 PinmemberPascal Ganaye15 Sep '11 - 2:16 
GeneralThanks! PinmemberTonny Vaes24 Aug '08 - 2:45 
QuestionConverting to c# Pinmemberchrisclarke1122 Mar '08 - 3:07 
AnswerRe: Converting to c# PinmemberPascal Ganaye15 Sep '11 - 2:20 
Generalpeogram to copy to cd_we or usb Pinmembersyriast29 Jul '06 - 22:46 
GeneralRe: peogram to copy to cd_we or usb PinmemberPascal Ganaye30 Jul '06 - 7:58 
GeneralRobocopy not so good PinmemberManuel JD Alves26 Feb '06 - 22:54 
Robocopy, as its own documentation states, may not behave as expected on a non-english OS. That's a major drawback for me. This one is the little gem I needed and was looking for. Mercy Pascal!
 
Manuel JD Alves
GeneralRobocopy seems faster Pinsussanadem5 Aug '05 - 14:15 
GeneralRe: Robocopy seems faster Pinmemberpascal ganaye6 Aug '05 - 4:46 
QuestionNice, but is this any better than &quot;robocopy&quot;? Pinmembermikestrat3 Aug '05 - 3:10 
AnswerRe: Nice, but is this any better than &quot;robocopy&quot;? Pinmemberpric01123 Aug '05 - 8:48 
GeneralRe: Nice, but is this any better than &quot;robocopy&quot;? PinmemberTLWallace.NET10 Aug '05 - 9:16 
GeneralRe: Nice, but is this any better than &quot;robocopy&quot;? Pinmemberpric011210 Aug '05 - 10:15 
GeneralRe: Nice, but is this any better than &quot;robocopy&quot;? Pinmembercornejoserrano12 Sep '05 - 22:14 
GeneralRe: Nice, but is this any better than &quot;robocopy&quot;? Pinmemberraviaw23 Feb '06 - 9:40 
GeneralDestination issues with +/-RW media. PinmemberMike Whitenton2 Aug '05 - 21:56 
QuestionAnyone understand this bug ? Pinmemberpascal ganaye1 Aug '05 - 1:09 
AnswerRe: Anyone understand this bug ? Pinmemberumeca741 Aug '05 - 7:22 
GeneralRe: Anyone understand this bug ? Pinmemberpascal ganaye1 Aug '05 - 7:46 
GeneralRe: Anyone understand this bug ? PinmemberJohn M. Drescher1 Aug '05 - 10:58 
AnswerRe: Anyone understand this bug ? PinmemberJohn M. Drescher1 Aug '05 - 7:34 
Generala better way PinmemberIsta31 Jul '05 - 19:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web03 | 2.6.130516.1 | Last Updated 31 Jul 2005
Article Copyright 2005 by Pascal Ganaye
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid