You can use some SCM software (also known as version control) such as
This way you will avoid huge amount of
bak files in the working directory and keep track of all previous versions in the same time.
IMHO simplest one would be fossil-scm
It is statically complied single file that can handle such jobs. (By the way created by the same programmer who created SQLite, so expect quality)
Your workflow could be like that:
cd to directory where files need to be tracked and init repository
fossil init (it will prepare a single database file)
- Tell fossil to track particular directory:
- Add files/directories recursively to repository
fossil addremove --dotfiles
- Save current status of directory to repository:
fossil commit or if you care about integrity of files then:
fossil commit --sha1sum
All subsequent calls of
fossil is just
fossil commit (If you need to add more new files or remove some from tracking then just issue before commit
fossil addremove --dotfiles)
This way all changes to files will be kept in timeline and can be previewed or compared(diff) or extracted (checkout), from repository ether file by file or restore completely previous state of the whole directory.
You can use
fossil extras --dotfiles to reveal new non tracked files or spot only files that were changed
fossil changes --abs-paths --sha1sum --header -v
If you need to exclude some files or directory, fossil support it too.
You can see timeline of changes over nice web interface produced by the same single file or even use internal WiKi to make a nice annotation to changes.
If you need to remove some content from repository,
fossil provides a mechanism called "shunning" to do that.