Hi, Here is a suggestion of patch we've been using for almost two decades with INN (a news server). https://inn.eyrie.org/trac/changeset/2777
-- Julien ÉLIE Add a new "-B" option to request saving of the original file when install-sh is overwriting an existing file. "-B" takes an argument: the suffix to use. Example of invokation: "install-sh -B .OLD". * lib/install-sh: Add a new -B option to backup files being overwritten --- install-sh.orig 2018-03-17 14:18:08.701045461 +0100 +++ install-sh.backupsuffix 2018-03-17 14:25:52.267384165 +0100 @@ -69,6 +69,7 @@ # Desired mode of installed file. mode=0755 +backupsuffix= chgrpcmd= chmodcmd=$chmodprog chowncmd= @@ -98,6 +99,7 @@ --help display this help and exit. --version display version info and exit. + -B SUFFIX backup a file with the suffix SUFFIX. -c (ignored) -C install only if different (preserve the last data modification time) -d create directories instead of installing files. @@ -115,6 +117,9 @@ while test $# -ne 0; do case $1 in + -B) backupsuffix="$2" + shift;; + -c) ;; -C) copy_on_change=true;; @@ -477,6 +482,10 @@ then rm -f "$dsttmp" else + # If $backupsuffix is set, rename the existing file if it exists. + if [ x"$backupsuffix" != x ] && [ -f "$dst" ]; then + $doit $mvcmd -f "$dst" "$dst$backupsuffix" 2>/dev/null + fi # Rename the file to the real destination. $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||