I should have made clear that the git
suggestion was not advanced as a solution to the problem, but as a useful way to cope with configuration/scripting files that get whacked from time-to-time by unknown processes. I did not wish to convey the idea that your present backup strategy is insufficient or that you just have to follow this New, Improved Configuration Preservation Process as a permanent workaround because we’re never ever going to address the unknown .json
whacker. I apologize for this inadvertent suggestion.
The root problem is difficult to catch because it happens irregularly and the consequence — deleted files — is only noticed minutes, hours, or days later, long after the horse has left the barn. But — just because tracking down the root cause is hard doesn’t mean the bug should not be addressed. The challenge is setting up the circumstances where it can be caught.
One of a set of circumstances that might help, insofar as Linux systems are concerned, is to set the immutable attribute on the .json
file. The linux ext2
, ext3
, ext4
file systems support a set of extended attributes above and beyond basic read, write, and execute flags. A file with the immutable attribute set cannot be modified: it cannot be deleted or renamed, no (hard) link can be created to the file, most of the file’s metadata can not be modified, and the file can not be opened in write mode.
I advance this not as a permanent solution, but as a way to create an event source that a debugger can catch. It can be used to catalog what events attempt to change the .json
file and — perhaps — if some of those events are unexpected. It is possible this approach might not work: too many false flags from well-known events, perhaps, such as those surrounding favorites being added or deleted.
Setting the attribute requires a super-user account. This would not be something I would do on a production system, but in a sandbox. Here is a demo:
bertha /home/gosgood/.config/gmic # ls -l
total 15084
-rw------- 1 gosgood gosgood 534 Apr 9 11:29 gmic_qt_faves.json
-rw-r--r-- 1 gosgood gosgood 8449944 Apr 9 11:29 gmic_qt_log
-rw------- 1 gosgood gosgood 346 Apr 9 11:29 gmic_qt_params.dat
-rw------- 1 gosgood gosgood 75 Apr 9 11:29 gmic_qt_tags.dat
-rw------- 1 gosgood gosgood 75 Apr 9 11:29 gmic_qt_tags.dat.bak
-rw------- 1 gosgood gosgood 63 Apr 9 11:29 gmic_qt_visibility.dat
-rw-r--r-- 1 gosgood gosgood 629812 Dec 4 2016 sample_greece.png
-rw-r--r-- 1 gosgood gosgood 438447 Aug 7 2017 sample_lena.png
-rw-r--r-- 1 gosgood gosgood 273917 Aug 12 2017 sample_rose.png
-rw-r--r-- 1 gosgood gosgood 707433 Aug 13 2017 sample_tiger.png
-rw------- 1 gosgood gosgood 4911708 Apr 3 14:10 update310.gmic
bertha /home/gosgood/.config/gmic # chattr +i gmic_qt_faves.json
bertha /home/gosgood/.config/gmic # lsattr gmic_qt_faves.json
----i---------e------- gmic_qt_faves.json
bertha /home/gosgood/.config/gmic # rm gmic_qt_faves.json
rm: cannot remove 'gmic_qt_faves.json': Operation not permitted
bertha /home/gosgood/.config/gmic # chmod 1777 gmic_qt_faves.json
chmod: changing permissions of 'gmic_qt_faves.json': Operation not permitted
bertha /home/gosgood/.config/gmic # chown root.root gmic_qt_faves.json
chown: changing ownership of 'gmic_qt_faves.json': Operation not permitted
bertha /home/gosgood/.config/gmic # echo "Be gone with you, then!!!" >>gmic_qt_faves.json
echo "Be gone with you, thenchown root.root gmic_qt_faves.json!" >>gmic_qt_faves.json
bash: gmic_qt_faves.json: Operation not permitted
bertha /home/gosgood/.config/gmic # cat gmic_qt_faves.json
[
{
"Name": "Rectangular Tiling",
"command": "_rec_tileit",
"defaultParameters": [
"1",
"5",
"1.5",
"1",
"4",
"0",
"45",
"0.5"
],
"defaultVisibilities": [
2,
2,
2,
2,
2,
2,
2,
2
],
"originalName": "Rectangular Tiling",
"preview": "gtutor_rectangular_tiling_preview"
}
]
bertha /home/gosgood/.config/gmic #
Might attempt a proof-of-concept this evening.