KeyBindings.xml gets corrupted

Sometimes when the system reboots or crashes while Renoise is running, KeyBindings.xml gets corrupted (not fully written to disk).
When I restart Renoise I get the message “Failed to parse KeyBindings.xml”.
So basically all my custom keybindings are lost.

To prevent this from happening again I set the immutable flag (chattr +i KeyBindings.xml)
But now Renoise complains on every exit that it cannot wtrite to KeyBindings.xml.

Is it possible to handle this situation more gracefully?
Thank you!

PS:
I just realised that there is a related issue from ~13 years ago:

i have solved this by simply saving a keybindings.xml every day, whenever I make changes to the keybinds. i retain it inside my tool Paketti, just so it’s always there.

yes, it’s tedious, and not much fun.
but at least I don’t lose my custom keys.

Thanks!
Yes, daily backups is a possibility.
In Russia they call manual/tedious methods and non-elegant workarounds funny names like “костыли”, which means using “crutches”, or “Krücken benutzen” in German.
I think I’ll write a bash script that automates this as much as possible.

Have a great day!

EDIT:

here is my over engineered bash script for those who want a bit more stability.
Customize the first 2 variables to fit your environment, then let it run everytime before you run Renoise:

#!/bin/bash

RNS_CONFIG_DIR="$HOME/.config/Renoise"
BACKUP_FILE="$HOME/Renoise_files/Backup/KeyBindings.xml"

# Find most recently used directory:
VERSION_DIR="$(cd "$(ls -1dt "$RNS_CONFIG_DIR/"*/ | head -n1)"; pwd)"

if [[ -f "$VERSION_DIR/Config.xml" ]]; then
	KEYBND_FILE="$VERSION_DIR/KeyBindings.xml"
	if [[ -f "$KEYBND_FILE" ]] && xmllint --format "$KEYBND_FILE" &>/dev/null; then
	# file exists, good file; make backup if they differ / backup file doesn't exist
		if [[ ! -f "$BACKUP_FILE" ]] || ! diff -q "$KEYBND_FILE" "$BACKUP_FILE" &>/dev/null; then
			if cp "$KEYBND_FILE" "$BACKUP_FILE"; then
				echo "Made backup of $KEYBND_FILE to $BACKUP_FILE"
			fi
		fi
	else
	# file does not exist OR bad file; overwrite with backup file (if it exists)
		if [[ -f "$BACKUP_FILE" ]]; then
			if cp "$BACKUP_FILE" "$KEYBND_FILE"; then
				echo "Corrupt file: $KEYBND_FILE was overwritten with backup file: $BACKUP_FILE"
			fi
		fi
	fi
fi