📜 ⬆️ ⬇️

Synchronize RAM disk with HDD

Do you use a RAM disk for applications? It is inconvenient to copy data to it after downloading? Are you afraid of losing data from a RAM disk during Windows BSOD or a sudden power off?

At any time, the Windows may fall (this also happens), the battery is completely discharged (I turned off all the shutdowns when the battery is discharged) or the electricity is turned off, and boh news happens. But the most up-to-date data is always saved, and the up-to-date data is likely to be saved, and not needed data will be lost (well, figs with them).

A topic about a small "tool", which will help to keep up-to-date data on a RAM disk always in a safe state. Regardless of how your session ended in Windows.
More precisely, almost always .
')


Some time ago, I finally updated my laptop and put 8GB of RAM. This gave me the opportunity to realize my long-cherished dream to completely disable swap in Windows and transfer Opera to a virtual disk created in RAM.
There was a problem, the approaches I found offered to restore the data on the RAM disk when booting the OS or when launching the application. And saving the data of the same disk when shutdown or close the application. None of the options I personally approached for ideological reasons. The result was a simple but extremely useful “tool” for “realtime” synchronization between the directories on the HDD (in my case, SSD) and the RAM disk.
The peculiarity of its own "tool" is that it can reflect the changes from the RAM disk to the original directory on the HDD where the original image of the directory is stored. At the same time, “tulza” is able to synchronize changes with a delay, in order to merge changes into groups and immediately apply them, and not constantly torment the disk as browsers like to do during their work :)

What you need:
1. Something to create a RAM Disk (I use RamdDisk Plus is paid but in my opinion is worth it, especially if you have 32-bit Windows and more memory than 3GB, I also met a link to the article on Habré )
2. Compiled tool (link at the end) or its source code to compile by yourself

Warning: all that you do, you do at your own peril and risk .

Written in C #, tested by me personally during the week. No complaints. I posted a shortcut to it in “Startup”.

Works "tulza" according to the principles:
1. According to the source directories specified in the config, their appearance is expected (I’m slightly paranoid, so most of my accessible ones are mounted after loading truecrypt containers and partisans)
2. As soon as the source directory appears, all its contents are copied to the recipient's directory (selective copying, in the sense that the entire copy or missing in the recipient's directory is copied and replaced, and if there are newer files in it, they are copied to the original directory ).
3. Changes in the recipient's directory on the RAM disk are monitored and they are applied to the source directory with a specified delay: changing, deleting and renaming files and folders. At the same time, it is possible to set the delay by mask. For example, for Opera, I have to apply changes for profile / cache once every 30 minutes, profile / sessions / autosave.win once every 30 seconds, for profile / wand.dat once every 1 second.
4. When you exit the tool, go on to synchronize all changes completely.

The configuration is described simply in the xml config, the interface is not: the tray icon and the window (hidden by default), in which the operation log is kept. The config file is in the same directory where the program has and has “RamSync.config.xml” (it’s bad to keep the config where the program is installed, I know, but it's easier for me to save my own configs and developments I use every day, and I update often for myself)

For example, here’s the configuration file with sync description for Opera:
<? xml version ="1.0" encoding ="utf-8" ? >
< AppConfig >
< PulseTime > 00:02:00 </ PulseTime >
< StartupWait > 00:00:05 </ StartupWait >
< SyncDirs >
< SyncDirRule >
< DisplayName > Opera 10 </ DisplayName >
< SourceDir > w:\Program Files\Opera10 </ SourceDir >
< DestinationDir > r:\Opera10 </ DestinationDir >
< DefaultDelay > 00:04:00 </ DefaultDelay >
< DelayRules >
< Rule mask ="profile\sessions\autosave.win" delay ="00:00:30" />
< Rule mask ="profile\bookmarks.adr" delay ="00:00:30" />
< Rule mask ="profile\wand.dat" delay ="00:00:01" />
< Rule mask ="profile\cache\*" delay ="00:30:00" />
</ DelayRules >
</ SyncDirRule >
</ SyncDirs >
</ AppConfig >


* This source code was highlighted with Source Code Highlighter .


It seems to me that all the names of the elements of the config are "speaking" and it is not necessary to describe them.
If I'm wrong, please write, I will definitely sign for it.

Unfortunately, I do not really understand licenses.
If you can not lay out the compiled project using Visual Studio 2010 Express Edition, say, delete the link.
In addition, the tray icons are used from the Android SDK.

Ready-to-use “tools” RamSync-bin.zip and its sources RamSync-src.zip .

Source: https://habr.com/ru/post/92877/


All Articles