I'm a complete BASH beginner who needs to make sure this script works. It's supposed to restore an evenstore backup from an azure blob storage. Unfortunately it doesn't work.
When I run it in ShellCheck:
Line 14:
export AZURE_STORAGE_KEY=<Insert key>
^-- SC1009 (info): The mentioned syntax error was in this simple command.
^-- SC1073 (error): Couldn't parse this variable assignment. Fix to allow more checks.
^-- SC1072 (error): Fix any mentioned problems and try again.
When I actually run it :
restore_eventstore.sh: line 14: syntax error near unexpected token `newline'
restore_eventstore.sh: line 14: `export AZURE_STORAGE_KEY=<Insert key>'
I have googled these errors but I was unable to find an answer for my case. Any help appreciated. Here is the script in its entirety:
#!/bin/bash
# Needs azure cli to work.
# Install command: curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
backup_name=$1
if [ -z "$backup_name" ]
then
echo "Must supply an file to use in the restore"
exit
fi
export AZURE_STORAGE_ACCOUNT=stoclbackups
export AZURE_STORAGE_KEY=<Insert key>
echo "Downloading backup $backup_name from blob storage"
az storage blob download --container-name node1backups --name $backup_name --file $backup_name
if [ ! -s "$backup_name" ]
then
echo "Failed to download the backup file $backup_name"
exit
fi
echo "Stopping the eventstore service"
systemctl stop eventstore
if [ -d eventstore_backup ]
then
echo "Removing old local eventstore backup"
rm -rf eventstore_backup
fi
echo "Doing an backup of the current db to eventstore_backup"
mkdir eventstore_backup
cp -r db/* eventstore_backup
echo "Removing the old data from eventstore db directory"
rm -rf db/*
echo "Unpacking the backup $backup_name into the eventstore db directory"
tar -zvxf $backup_name -C db/
echo "Truncate the eventstore data to the latest chaser checkpoint"
cp db/chaser.chk db/truncate.chk
echo "Restore is complete. Start the eventstore service with: sudo systemctl start eventstore"
<Insert key>, or did you replace it with an actual key string?>is missing the filename to redirect to, hence the syntax error.