flat assembler
Message board for the users of flat assembler.

Index > Windows > The Very Simple Backup Program/File Monitor

Author
Thread Post new topic Reply to topic
kake_zinger



Joined: 15 Jul 2004
Posts: 51
kake_zinger
I got an idea for a very nice freeware program.

All it should do is to monitor a certain directory, and at user set intervals (anything from minutes to hours), check the directory which files have been written to/changed/created, and make a copy of these files to the chosen backup drive:\directory. This could also be used for taking permanent copies of changing temporary data.

The idea of this is its simplicity and hardware facts: it's easy to go out and buy a 1-2 TB raid box, but harder to devise a working backup plan especially when you are in the middle of working on something. So you'd have this progam monitoring your work directory all the time and simply make copies to another drive without bothering you.

Of course it could be evolved into a more complex program, which could also monitor a whole descending directory tree or multiple such trees, but the very simple option should always remain.

Preferrably a program like this would sit in the taskbar tray as an icon. Any takers? I tried to find something like this but came up with nothing. There are many file managers which could be used because they incorporate a function to compare and update directories, but these cannot be automated.
Post 17 Feb 2006, 20:11
View user's profile Send private message Reply with quote
Matrix



Joined: 04 Sep 2004
Posts: 1171
Location: Overflow
Matrix
use raid mirror...
so you don't have to make backups.
Post 17 Feb 2006, 21:03
View user's profile Send private message Visit poster's website Reply with quote
farrier



Joined: 26 Aug 2004
Posts: 274
Location: North Central Mississippi
farrier
kake_zinger,

I just finished something like this for a customer! My program creates a thread, which uses FindFirstChangeNotification/FindNextChangeNotification along with WaitForSingleObject. I have it run in the AllUsers StartUp folder. It sits and waits for a file to be created in a certain folder and, when the file is closed by the program which created it, moves the file to the E:\ drive into a folder created by my program with the name YYYYMMDDDOW. For instance, todays folder would be 20060217FRI.

This could be modified to do what you want.

hth,

farrier


Description:
Download
Filename: QBBU.zip
Filesize: 5.18 KB
Downloaded: 5517 Time(s)


_________________
Some Assembly Required
It's a good day to code!
U.S.Constitution; Bill of Rights; Amendment 1:
... the right of the people peaceably to assemble, ...
The code is dark, and full of errors!
Post 17 Feb 2006, 21:13
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
I was trying to do the same thing but because I have little time and some things to finish before I did't implemented anything but I read in the SDK that there is another funtion to monitor changes, the ReadDirectoryChangesW API function.

Requirements
Client Requires Windows XP, Windows 2000 Professional, or Windows NT Workstation 4.0.
Server Requires Windows Server 2003, Windows 2000 Server, or Windows NT Server 4.0.
Header Declared in Winbase.h; include Windows.h.

Library Link to Kernel32.lib.

DLL Requires Kernel32.dll.

I prefer this one because this function tells you which file was modified also and which kind of modification. Note that with this function is more easy to detect file renamings.

Regards,
HernĂ¡n
Post 17 Feb 2006, 23:32
View user's profile Send private message Reply with quote
kake_zinger



Joined: 15 Jul 2004
Posts: 51
kake_zinger
farrier, thank you very much indeed.

Could I interest you in refining the program just a little bit so that it would ask or take an argument about the paths what it backs up and where? Just a simple version of a single directory to choose would do fine. Of course it'd be superb if it could be turned into a list of directories or even a recursable directory tree. But this is really beyond the scope of a "simple" program.

You know, turning it into a general utility program of this kind. It would really benefit everybody and come into a real need because there is no versioning or constant backup in Windows.

If you're not interested in refining it it's all ok, I just don't to Windows myself and I'd like you to get credit for your own programming especially since you have done this already. Good programming ideas are not that many.
Post 18 Feb 2006, 12:34
View user's profile Send private message Reply with quote
farrier



Joined: 26 Aug 2004
Posts: 274
Location: North Central Mississippi
farrier
locodelassembly,

thanks for the idea about using ReadDirectoryChangesW, it seemed like a good idea. I figured it shouldn't be too hard to make it work! Well, it wasn't easy for me. But, I've got something working. When a Change is detected, an array of FILE_NOTIFY_INFORMATION structures is created, reporting the File which has changed and the change which has occurred. The only thing I could not get a report for was when a file is renamed. I got a report for the OldName but not the NewName. I think I did not process the array properly, and I may look at this some more, maybe.

What this program does is Watch the folder/directory from which the program is run, and reports any file changes which occur in the folder. The buttons on the tool bar will:

Create a file;
Delete a file;
Modify a file;
Rename a file using Movefile;
Move a file from the app's folder to the root of it's drive
Move a file--after creating it--from the root of the app's drive to the app's folder

Results are logged to a ListView, some things are not reported, like when a file is recreated after it is deleted.

hth,

farrier


Description:
Download
Filename: FC.zip
Filesize: 11.26 KB
Downloaded: 100 Time(s)


_________________
Some Assembly Required
It's a good day to code!
U.S.Constitution; Bill of Rights; Amendment 1:
... the right of the people peaceably to assemble, ...
The code is dark, and full of errors!
Post 07 Mar 2006, 05:24
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Since I cannot compile you project because I don't have some of the include files I guess the error is this:
Code:
                        .if     edi, ne, 0
                                add     ebx, edi
                                mov     edi, [ebx]
                        .endif
                .until  edi, e, 0
    

You will always skip the last record because you load to EDI the next record and since the ".until" uses EDI you exit from the loop before processing the last record.

A solution could be fixing the following parts like this:
Code:
                push    ebx
                push    edi 
                push    esi 
                lea             ebx, [bufRDCW]  
               .repeat 
                        mov             edi, [ebx]    

And replace this:
Code:
                        .if     edi, ne, 0
                                add     ebx, edi
                                mov     edi, [ebx]
                        .endif
    
with this:
Code:
add     ebx, edi    


Hope this works

Regards,
LocoDelAssembly
Post 07 Mar 2006, 12:17
View user's profile Send private message Reply with quote
farrier



Joined: 26 Aug 2004
Posts: 274
Location: North Central Mississippi
farrier
locodelassembly,

YES!

I looked at that loop for 2 hours last night and didn't see that! Thanks!! That fixed one of two problems which kept the NewFileName from being displayed. I have a flag--gListAct--used to not display the actions I took to replace files I had modified or deleted. After the MoveFile command, I changed gListAct to stop the display, but the code to display the OldFileName got executed, and the flag gets changed before the code to display the NewFileName got executed.

I put in a timer delay after the FCRename code is executed, when the timer expires, I replace the original file and delete the renamed file.

Try the attached files. The only "non-standard" include file--GlobalMem.inc--is from the Fresh project, and allows us to split up the initialized--iglobal--and uninitialized--uglobal--data to be declared in multiple files, but the separate data declarations are gathered into one segment. That helps me a lot when I use multiple .asm files. Thanks to the Fresh project!

Thanks again for your help!!

farrier


Description:
Download
Filename: FC.zip
Filesize: 10.35 KB
Downloaded: 110 Time(s)


_________________
Some Assembly Required
It's a good day to code!
U.S.Constitution; Bill of Rights; Amendment 1:
... the right of the people peaceably to assemble, ...
The code is dark, and full of errors!
Post 07 Mar 2006, 18:38
View user's profile Send private message Reply with quote
farrier



Joined: 26 Aug 2004
Posts: 274
Location: North Central Mississippi
farrier
Someone on the MASM32 site asked about an app which blinked an LED on screen to match the Disk Drive access light. I adapted the ReadDirectoryChangesW to do this in a crude way, by showing the old fashioned rotating cursor in the window title bar.

farrier


Description:
Download
Filename: DriveAccess.zip
Filesize: 2.79 KB
Downloaded: 108 Time(s)


_________________
Some Assembly Required
It's a good day to code!
U.S.Constitution; Bill of Rights; Amendment 1:
... the right of the people peaceably to assemble, ...
The code is dark, and full of errors!
Post 07 Mar 2006, 20:46
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
farrier, you didn't posted the include files I need. Well GlobalMem.inc I can get it from Fresh but, what about \CSCSC\Working\DateBack\Utilities.asm ?

Regards,
LocoDelAssembly

PS: Well now I don't see GlobalMem.inc in my Fresh so post it too.
Post 07 Mar 2006, 20:59
View user's profile Send private message Reply with quote
farrier



Joined: 26 Aug 2004
Posts: 274
Location: North Central Mississippi
farrier
locodelassembly,

I'm sorry to make this so difficult, attached are the two files. The macros for iglobal and uglobal have changed since I started using them.

Again, thanks for your help!

farrier


Description:
Download
Filename: Utilities.zip
Filesize: 1.58 KB
Downloaded: 127 Time(s)


_________________
Some Assembly Required
It's a good day to code!
U.S.Constitution; Bill of Rights; Amendment 1:
... the right of the people peaceably to assemble, ...
The code is dark, and full of errors!
Post 08 Mar 2006, 00:05
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Well I'm not sure what problem are you talking about but letting the program to display all the monitored events I can see that the program correctly catches all of them Very Happy

When I let the program check the flag first well, the buttons "move from" and "move to" never display anything and the button "create" some times works, some times don't, I can't get what is required to do first in order to get the creation displayed. Anyway I think that the monitoring stuff is working great, I'd tested creating, renaming and deleting files and folders using Windows and those events were displayed too Very HappyVery Happy. I'd tested with monitoring subdirectories enabled and the program had displayed the events showing the relative paths Very HappyVery HappyVery Happy

Thanks to you for posting this code, now I know that it works great Very Happy

Regards,
LocoDelAssembly
Post 08 Mar 2006, 03:46
View user's profile Send private message Reply with quote
farrier



Joined: 26 Aug 2004
Posts: 274
Location: North Central Mississippi
farrier
locodelassembly,

With the help of your inspiration and help!

Thanks again!

Create is pretty straightforward, the MoveFrom and MoveTo move from and to the _Root and the app's folder, you may have adjust the value of _Root in order for button commands to work.

farrier

_________________
Some Assembly Required
It's a good day to code!
U.S.Constitution; Bill of Rights; Amendment 1:
... the right of the people peaceably to assemble, ...
The code is dark, and full of errors!
Post 08 Mar 2006, 08:37
View user's profile Send private message Reply with quote
Crukko



Joined: 26 Nov 2005
Posts: 118
Crukko
Is there a doc file with info about prg and features?
Thx!
Post 10 Apr 2006, 11:48
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.