Check your script
Code:
day=$(date +%d-%m-%y)
echo "$day"
19-09-18
Code:
hostname=$(hostname -s)
echo "$hostname"
localhost
Code:
archive_file="$hostname-$day"
echo "$archive_file"
localhost-19-09-18
Code:
echo "BACKUP LOG" >> $log
bash: $log: ambiguous redirect
echo >> $log
bash: $log: ambiguous redirect
You are trying to echo to a variable that you haven't defined.
If you want a log file then make it, then you can echo to it.
Code:
touch log
echo "BACKUP LOG" >> log
cat log
BACKUP LOG
Or if you want the log stored as a variable
Code:
var1=$(echo "BACKUP LOG")
echo "$var1"
BACKUP LOG
If you want to concatenate the entry to the variable
Code:
var1+="$(echo -e "\nBACKUP LOG")"
echo "$var1"
BACKUP LOG BACKUP LOG