shell 导出到S3时出现错误Elasticache快照未就绪

sr4lhrrt  于 2023-08-07  发布在  Shell
关注(0)|答案(1)|浏览(145)
  • 我正在尝试编写一个bash脚本,通过在AWS EC2示例上的Amazon Linux 2内运行的cron作业,自动将elasticache快照存储到s3

当我运行下面的代码时,它给我一个错误,说快照没有准备好

#!/bin/sh

cache_cluster_id="test-elasticache-001"
current_time="$(date +"%Y-%m-%d-%H-%M-%S")";
file_name="test-elasticache-${current_time}";
max_number_of_backups_to_keep=8;

snapshot_status=$(aws elasticache create-snapshot --cache-cluster-id $cache_cluster_id --snapshot-name $file_name);
echo $snapshot_status;
export_status=$(aws elasticache copy-snapshot --source-snapshot-name $file_name --target-snapshot-name $file_name --target-bucket test-elasticache-manual-backups);
echo $export_status;

# https://gist.github.com/luckyjajj/463b98e5ec8127b21c6b
# Check if number of stored backups is 8
if [ $(aws elasticache describe-snapshots --cache-cluster-id $cache_cluster_id |grep SnapshotName | wc -l)  = "$max_number_of_backups_to_keep" ]; then
    # Get the name of the oldest snapshot
    old_snapshot="$(aws elasticache describe-snapshots --cache-cluster-id $cache_cluster_id |grep SnapshotName | head -1 | cut -d \" -f 4)"
    aws elasticache delete-snapshot --snapshot-name $old_snapshot
fi

字符串
如何等待快照准备就绪,然后将其导出到S3?

qrjkbowd

qrjkbowd1#

为了向您提供准确的帮助,需要了解有关Elasticache Redis集群的更多信息:

  • 请指定您使用的是启用群集模式(CME)还是禁用群集模式(CMD)?
  • 你目前使用的是哪个版本的Redis?
  • 您使用的是哪种发动机?
  • 等等。

同时,您可能会发现以下文档资源很有用:

相关问题