2 réponses
- Le plus récent
- Le plus de votes
- La plupart des commentaires
1
aws rds describe-db-snapshots --query "DBSnapshots[?SnapshotCreateTime <= \`"$(date --date "30 days ago" +"%Y-%m-%dT%H:%M:%S.000000+00:00")"\`]"
0
First, install the necessary libraries for Python:
pip install python-dateutil
Create a Python script - list_old_snapshots.py
import sys
import json
import dateutil.parser
from datetime import datetime, timedelta
# Load JSON input from stdin
snapshots = json.load(sys.stdin)
# Get the date one month ago
one_month_ago = datetime.now(dateutil.tz.tzutc()) - timedelta(days=30)
# Filter snapshots older than one month
old_snapshots = [snapshot for snapshot in snapshots['DBSnapshots'] if dateutil.parser.parse(snapshot['SnapshotCreateTime']) < one_month_ago]
# Print filtered snapshots as JSON
print(json.dumps(old_snapshots, indent=2, default=str))
Now, use the following command to get the RDS snapshots older than one month:
aws rds describe-db-snapshots | python list_old_snapshots.py
Contenus pertinents
- demandé il y a un an
- demandé il y a 4 mois
- demandé il y a un an
- Comment gérer les adresses IP statiques sur mes instances Lightsail à l'aide des commandes AWS CLI ?AWS OFFICIELA mis à jour il y a 3 ans
- AWS OFFICIELA mis à jour il y a un an
- AWS OFFICIELA mis à jour il y a 4 mois
Thanks. Will check and Let you know.