我有一个无法正常运行的脚本。我问了一个关于同一个脚本的问题并让它工作不久以前。但现在同一个脚本给出了其他错误,我不知道为什么。
我收到这些错误消息:
: not foundntstore.sh: 4: restore_eventstore.sh:
: not foundntstore.sh: 6: restore_eventstore.sh:
restore_eventstore.sh: 46: restore_eventstore.sh: Syntax error: end of file unexpected (expecting "then")
当我跑步时
sh restore_eventstore.sh 2023-01-04-03-00.tar.gz
剧本:
#!/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=stocombackups
export AZURE_STORAGE_KEY=HIDDENFORSTACKOVERFLOW
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"