我是一个完全的 BASH 初学者,需要确保这个脚本有效。它应该从 azure blob 存储恢复 Evenstore 备份。不幸的是它不起作用。
当我在 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.
当我实际运行它时:
restore_eventstore.sh: line 14: syntax error near unexpected token `newline'
restore_eventstore.sh: line 14: `export AZURE_STORAGE_KEY=<Insert key>'
我已经用谷歌搜索了这些错误,但无法找到我的案例的答案。任何帮助表示赞赏。这是完整的脚本:
#!/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"
答案1
用于的值AZURE_STORAGE_KEY
是一个占位符文本字符串,表示<Insert Key>
。这需要替换为 Azure 存储帐户的实际密钥。