Click here to Skip to main content
1,837 members
Articles / Security / .NET 1.1
Article

Utility to backup your folders fast

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
12 Apr 2012 17.7K   7   2   1
I use a procedure based on batch files to copy various versions of my project. I was a bit fed up to wait for the batch file to copy hundreads of files and wrote this small utility to speed up the process. I hope some of you will find it useful.

This article is a sponsored article. Articles such as these are intended to provide you with information on products and services that we consider useful and of value to developers

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


Written By
Software Developer (Senior)
France France
This member doesn't quite have enough reputation to be able to display their biography and homepage.

Comments and Discussions

 
SuggestionLast file write time Pin
ledtech316-Apr-12 18:03
ledtech316-Apr-12 18:03 
you could try to get the last write time from the original and then "Set" the new file to that time.Other wise it would set the last write time to what ever time it actually wrote it.
I have seen a few Projects on The Code Project that shows how to do that.

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

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