- 我正在尝试编写一个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?
1条答案
按热度按时间qrjkbowd1#
为了向您提供准确的帮助,需要了解有关Elasticache Redis集群的更多信息:
同时,您可能会发现以下文档资源很有用: