4

I'm looking for a way to track changes of a folder, with sub-folders and files, from time to time - not in real time. Basically I want to know which folders/files that was changed (changed or delete) from the last time I looked.

A simple solution would be to make a copy of the entire folders/files and then do some diff when I want to know what have changed. I could touch the files so they wouldn't take up any space and look at the file date to see if it was changed. ...but it doesn't seem like a good option.

This would take place on a Linux system. The file-system I would watch would be mounted (out of my control) but the other file-system would I be in control of, if anyone was thinking about some specific trick for a file-system.

Do anyone got a good solution?

AxAn
  • 143
  • 12
  • You can use find command with the -mtime flag. For example, find all files modified in the last 24 hours would be: find /directory/or/mount/point -mtime 1. Finding deleted files is a little more difficult. What's the purpose? Are you trying to backup files? – Jason Heithoff Feb 26 '17 at 22:59
  • No, I'm not trying to backup files. I want to know what was done to the file-system (folders/files) so I might do the same to another copy of the file-system. – AxAn Feb 27 '17 at 09:13
  • Do you have any control over the filesystem used? What you're asking for is almost exactly what something like ZFS snapshots can do quite easily. – Andrew Henle Feb 27 '17 at 17:53
  • I do not think a snapshot would help me since I want to go through a list of what have changed and apply it or not based on some rules. – AxAn Feb 27 '17 at 18:15

1 Answers1

1

Git seems like a good solution. You can track changes, go back to different versions of the file, make branches, and get a diff of any commits to what your current state of the file is.

You can do a free class to get started

https://www.codeschool.com/learn/git

You can go into the folder you want to track. Then initialize the folder with

git init

add all files and folders

git add .

commit changes

git commit -m "some message"

after changing files to see changes

git status

add the new changed files

git add "the file you changed"

then do a commit

git commit -m "some message"

aowen
  • 26
  • 2
  • I should have been more clear: The file-system that I will be watching will probably be read-only and even if it would be possible do I not want to add any files to it so using git in that folder will not work. – AxAn Feb 27 '17 at 09:11
  • @AxAn Although there might be a better solution you could try rsync to copy all the items to your local system. Then you could run rsync with --itemize-changes to get the difference between the remote and local. Use option -n to not sync. Take a look at http://serverfault.com/questions/618735/can-i-use-rsync-to-create-a-list-of-only-changed-files and http://stackoverflow.com/questions/9090817/copying-files-using-rsync-from-remote-server-to-local-machine – aowen Feb 27 '17 at 19:28