LoWang

ideas needed - how to read folder's deleted files info

12 posts in this topic

#1 ·  Posted (edited)

Hello, I am about to create my own file sync utility but I wonder how to make its basic functionality - detect deleted files. How do google drive, dropbox and such things do it? I guess they have their own internal databases independent on file system right? One could say - just use robocopy with -mir parameter. But the problem of robocopy is, that is works one way only. You have to specify which folder is source and which is target. It considers source folder as a last state and mirrors the target folder according to source. But I want it to work both ways. That means that if I have two folders with photos and let's say I delete one photo in one folder and edit the same photo in another folder, I want my utility to recognize what change is most recent and sync according to that. For it I would like not only to know that the file is missing in one of the folder but also WHEN was it deleted. Because if it was deleted later then the modification date of the photo in first folder then I want the photo to be deleted from both. Anybody knows how it is usually done and if there is some best practice to handle this? Is it possible to read folder and find deleted file entries with date of deletion? I am not sure if this information is recorded in the folder at all...Maybe maintaining file list and comparing it with actual folder is the only options right? I guess WMI event handlers are also usually used to monitor folder changes, so point me to some tutorials if possible. Thank you.

Edited by LoWang

Share this post


Link to post
Share on other sites



http://security.stackexchange.com/questions/61166/how-to-know-when-a-file-was-deleted-in-a-ntfs-filesystem

how about that? Do you think some common file sync/cloud software use NTFS journaling?

The easy way is to periodically check for changes as JohnOne says.

You should realize that what that post talks about is the USN change journal - not NTFS journaling.

If you really want to do it the hard way, you'll want to start with MSDN (https://msdn.microsoft.com/en-us/library/windows/desktop/aa363798(v=vs.85).aspx) and play with the API.

Share this post


Link to post
Share on other sites

rjframe what do you mean? I talk mainly about the first answer to that post. It contains some links and talks about ntfs journaling. Please be more clear with all those abbreviations and tell me what is USN ;)
BTW msdn link is broken :-\

Share this post


Link to post
Share on other sites

@LoWang

The NTFS journal (or log, or transaction journal) records changes to the volume; it's used to ensure data reliability and consistency, so you don't want to mess with it. I have never studied the NTFS format, so I cannot be more specific than that.

The USN Journal (update sequence number) records changes to directories, files, and streams, and can be monitored by applications via the API, documented at the link above.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

This is how I have figured out what you are trying to do and it works very well for me.

#include <FileConstants.au3>

Send("#m") ;~ this will minimize all open windows

$title = "Xternal Backup By Henry "
$Begtext = "Your Backup is about to commence" _
         & @LF & "Please save and close any open programs." _
         & @LF & "This program will start in 120 seconds."
$Fintext = "Your Backup has completed successfully !               "

$SourcePath = "<this would be the Source path where to copy your stuff to>"
$TargetPath = "<this would be the Target path where to copy your stuff to>"

;~ I also like to use
#NoTrayIcon ;~ hides the trayicon
Break(0) ;~ disables users ability to ctrl+break

;~ whats missing is a couple of these copy and paste it and add any apps that might be open like word or outlook
;~ Closes open programs
Local $MFF = ProcessExists("firefox.exe")
If $MFF Then ProcessClose($MFF)
Sleep(300)

$sm = MsgBox(65 + 262144, $title, $Begtext, 120)
If $sm = 2 Then Exit
If $sm = 1 Then
    $rc = RunWait("robocopy.exe" & " " & $SourcePath & " " & $TargetPath & "/e /eta /LOG+:e:\backup.log /tee")
Else
    $rc = RunWait("robocopy.exe" & " " & $SourcePath & " " & $TargetPath & "/e /eta /LOG+:e:\backup.log /tee")
    MsgBox(262144, $title, $Fintext, 60)
    Exit
EndIf
Break(1) ;~ turns off break
MsgBox(64, $title, $Fintext, 60)

 

 

shared backup.au3

Edited by Caiaphas
pasted code

Share this post


Link to post
Share on other sites

Thanks, but I am really not sure if you understood what I was asking at all :D

Share this post


Link to post
Share on other sites

maybe you're looking for something like this.

Saludos

1 person likes this

Share this post


Link to post
Share on other sites

Actually I am not really interested in some monitoring app which would have to be running. Imagine that google drive also may not be running but once you run it it somehow detects changes and syncs. So I guess this UDF will not work for the type of utility which would not have to be running continuously am I right? But I mayt test that anyway.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now