Hi folks,
I am currently trying to write a script for an automatic backup that looks like that:
1 #!/bin/sh
2
3 # Load environment variables from the .env1 file
4 if [ -f "/home/uli/.env1" ]; then
5 export $(grep -v '^#' /home/uli/.env1 | xargs)
6 else
7 echo ".env1 file not found!"
8 exit 1
9 fi
10
11 # Define variables
12 RESTIC_REPOSITORY="sftp:udapro.de:/srv/system"
13 EMAIL_RECIPIENT="info@ulikleemann.de"
14 DATE=$(date +"%Y-%m-%d")
15 TIME=$(date +"%H:%M:%S")
16 SUBJECT_SUCCESS="System-Backup Successful"
17 SUBJECT_FAILURE="System-Backup Failure"
18 SSH_KEY="/home/uli/.ssh/id_ed25519"
19 OTP_SECRET="$GOOGLE_SECRET"
20
21 # Function to send email
22 send_email() {
23 local subject="$1"
24 local body="$2"
25 echo "$body" | mail -s "$subject" "$EMAIL_RECIPIENT"
26 }
27
28 # Function to generate OTP
29 generate_otp() {
30 oathtool --totp -b "$OTP_SECRET"
31 }
32
33 # Generate OTP
34 OTP=$(generate_otp)
35
36 # Perform the backup
37 if restic -r "$RESTIC_REPOSITORY" --password-file <echo ("$RESTIC_PASSWORD") --option ssh.command="ssh -i $SSH_KEY -o BatchMode=yes -o StrictHostK eyChecking=no -o ChallengeResponseAuthentication=no -o UsePAM=yes -o AuthenticationMethods=publickey" backup /etc /lib /lib64 /usr /opt /var; then
38 send_email "$SUBJECT_SUCCESS" "The system backup completed successfully on $DATE at $TIME."
39 else
40 send_email "$SUBJECT_FAILURE" "The system backup failed on $DATE at $TIME."
41 exit 1
42 fi
43
In Line 37 a fet a Syntax-Error saying: 37: Syntax error: “(” unexpected (expecting “then”)
Which ( does it mean? and how to write that then statement correctly?
I don’t understand that error, could you please help?
Many thanks in advance ,
Uli