Configs/Server/Root/Main/Server/Scripts/Backup/BackupGlobals.cfg

33 lines
733 B
Bash
Executable File

#!/bin/sh
BackupsBase=/Main/Backup
RunDate="$(date +%F)" # Current date in YYYY-MM-DD format
cd "${BackupsBase}"
. ./.BackupSecrects.sec
# Generate a good key for encrypting files, based on a primary secret key and a secondary string
# NOTE to self: Use this same function to get decryption key, plugging the YYYY-MM-DD date of the Git commit as $2
Hash2() {
BaseKey="$1"
SecStr="$2"
echo "$(echo "${BaseKey}$(echo "${SecStr}" | sha512sum | base64 -w0)" | sha512sum | base64 -w0)"
}
ccencryptNow() {
File="$1"
BaseKey="$2"
ccrypt -e -f -K"$(Hash2 "${BaseKey}" "${RunDate}")" "${File}"
echo "${RunDate}" > "${File}.info"
}
WriteLastLog() {
echo "$0: $(date)" > "${BackupsBase}/Last.log"
}
EchoExec() {
echo "$@"
$@
}