Skip to content
backup-retention-policy logo

Backup Retention Policy Expert

backup-retention-policy

Эксперт по политикам бэкапов. Используй для стратегий резервного копирования, retention rules и disaster recovery.

SKILL.md

Full skill instructions

Backup Retention Policy Expert

Эксперт по управлению жизненным циклом данных и восстановления после сбоев.

Правило 3-2-1-1-0

  • 3 копии важных данных (1 основная + 2 резервные)
  • 2 различных типа носителей
  • 1 внешняя/облачная резервная копия
  • 1 автономная/неизменяемая резервная копия
  • 0 ошибок после тестирования

Уровни хранения

УровеньДоступПериодСтоимость
ГорячийЧастый0-30 дней$$$
ТеплыйПериодический30-90 дней$$
ХолодныйРедкий90 дней-7 лет$
АрхивДолгосрочный7+ лет¢

AWS S3 Lifecycle Policy

{
  "Rules": [
    {
      "ID": "BackupLifecycle",
      "Status": "Enabled",
      "Filter": {
        "Prefix": "backups/"
      },
      "Transitions": [
        {
          "Days": 30,
          "StorageClass": "STANDARD_IA"
        },
        {
          "Days": 90,
          "StorageClass": "GLACIER"
        },
        {
          "Days": 365,
          "StorageClass": "DEEP_ARCHIVE"
        }
      ],
      "Expiration": {
        "Days": 2555
      },
      "NoncurrentVersionTransitions": [
        {
          "NoncurrentDays": 30,
          "StorageClass": "GLACIER"
        }
      ],
      "NoncurrentVersionExpiration": {
        "NoncurrentDays": 365
      }
    }
  ]
}

Azure Blob Lifecycle

{
  "rules": [
    {
      "name": "backupRetention",
      "type": "Lifecycle",
      "definition": {
        "actions": {
          "baseBlob": {
            "tierToCool": {"daysAfterModificationGreaterThan": 30},
            "tierToArchive": {"daysAfterModificationGreaterThan": 90},
            "delete": {"daysAfterModificationGreaterThan": 2555}
          },
          "snapshot": {
            "delete": {"daysAfterCreationGreaterThan": 90}
          }
        },
        "filters": {
          "blobTypes": ["blockBlob"],
          "prefixMatch": ["backups/"]
        }
      }
    }
  ]
}

Скрипт ротации бэкапов

#!/​bin/​bash
BACKUP_DIR="/​var/​backups"
DAILY_RETENTION=7
WEEKLY_RETENTION=4
MONTHLY_RETENTION=12

# Удаление ежедневных старше 7 дней
find "$BACKUP_DIR/​daily" -type f -mtime +$DAILY_RETENTION -delete

# Удаление еженедельных старше 4 недель
find "$BACKUP_DIR/​weekly" -type f -mtime +$((WEEKLY_RETENTION * 7)) -delete

# Удаление ежемесячных старше 12 месяцев
find "$BACKUP_DIR/​monthly" -type f -mtime +$((MONTHLY_RETENTION * 30)) -delete

# Логирование
echo "$(date): Rotation completed" >> /​var/​log/​backup_rotation.log

PostgreSQL Backup

#!/​bin/​bash
DB_NAME="production"
BACKUP_DIR="/​var/​backups/​postgres"
DATE=$(date +%Y%m%d_%H%M%S)

# Полный бэкап
pg_dump -Fc -f "$BACKUP_DIR/​full_$DATE.dump" $DB_NAME

# Инкрементальный с WAL
pg_basebackup -D "$BACKUP_DIR/​base_$DATE" -Ft -z -P

# Архивация WAL логов
archive_command = 'cp %p /​var/​backups/​wal/%f'

MySQL Backup

#!/​bin/​bash
MYSQL_USER="backup_user"
MYSQL_PASS="secure_password"
BACKUP_DIR="/​var/​backups/​mysql"
DATE=$(date +%Y%m%d_%H%M%S)

# Полный бэкап
mysqldump --user=$MYSQL_USER --password=$MYSQL_PASS \
    --all-databases --single-transaction \
    --routines --triggers --events \
    | gzip > "$BACKUP_DIR/​full_$DATE.sql.gz"

# Инкрементальный с binlog
mysqlbinlog --read-from-remote-server \
    --host=localhost --user=$MYSQL_USER \
    --raw --stop-never mysql-bin.000001

Compliance Requirements

СтандартТребование
GDPRПраво на удаление, минимизация данных
SOX7 лет для финансовых записей
HIPAA6 лет для медицинских данных
PCI DSS1 год минимум для аудита

RTO/​RPO Planning

Критические системы:
  RPO: 1 час
  RTO: 4 часа
  Стратегия: Синхронная репликация + горячий standby

Бизнес-системы:
  RPO: 4 часа
  RTO: 24 часа
  Стратегия: Асинхронная репликация + теплый standby

Архивные системы:
  RPO: 24 часа
  RTO: 72 часа
  Стратегия: Ежедневные бэкапы + холодное хранение

Валидация политик на Python

from datetime import datetime, timedelta
from typing import List, Dict

class BackupRetentionValidator:
    def __init__(self, retention_policy: Dict):
        self.policy = retention_policy

    def validate_backup(self, backup_date: datetime, backup_type: str) -> bool:
        """Проверка соответствия бэкапа политике хранения"""
        retention_days = self.policy.get(backup_type, {}).get('retention_days', 0)
        expiry_date = backup_date + timedelta(days=retention_days)
        return datetime.now() < expiry_date

    def get_expired_backups(self, backups: List[Dict]) -> List[Dict]:
        """Получить список просроченных бэкапов"""
        expired = []
        for backup in backups:
            if not self.validate_backup(backup['date'], backup['type']):
                expired.append(backup)
        return expired

    def calculate_storage_forecast(self, daily_backup_size_gb: float) -> Dict:
        """Прогноз использования хранилища"""
        total_storage = 0
        for backup_type, config in self.policy.items():
            retention = config.get('retention_days', 0)
            frequency = config.get('frequency_days', 1)
            copies = retention // frequency
            total_storage += copies * daily_backup_size_gb

        return {
            'total_gb': total_storage,
            'monthly_cost_estimate': total_storage * 0.023  # S3 Standard pricing
        }

График тестирования

Тип тестаЧастотаОхват
Выборочное восстановлениеЕжемесячно10% данных
Полное восстановлениеЕжеквартальноКритические системы
DR ученияЕжегодноПолный сценарий
Аудит политикЕжегодноВсе политики

Мониторинг и алерты

Алерты:
  backup_failed:
    severity: critical
    notification: [pagerduty, slack]

  backup_size_anomaly:
    threshold: 20%
    severity: warning

  retention_violation:
    severity: high
    action: auto_remediate

  storage_threshold:
    threshold: 80%
    severity: warning

Лучшие практики

  1. Тестируйте восстановление — бэкап без теста = нет бэкапа
  2. Шифруйте данные — AES-256 для данных в покое
  3. Версионирование — храните несколько версий
  4. Географическое распределение — минимум 2 региона
  5. Immutable storage — защита от ransomware
  6. Документируйте процедуры — runbooks для DR

More Other skills

Delegate independent tasks to specialized agents working concurrently with isolated context.

295.4K 206.3K
View

Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.

179.7K 100.1K
View

Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with colors/fonts that you can apply to any artifact that has been creating, or can generate a new theme on-the-fly.

179.7K 89.5K
View

A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill whenever asked to write some sort of internal communications (status reports, leadership updates, 3P updates, company newsletters, FAQs, incident reports, project updates, etc.).

179.7K 76.1K
View

Fundamental design principles for writing maintainable, testable Python code.

40.2K 21.9K
View

Modern responsive layouts using container queries, fluid typography, CSS Grid, and mobile-first strategies.

40.2K 20K
View

Generate Playwright tests from scenarios using interactive browser exploration and validation.

39.7K 18.2K
View

Modern React state management with Redux Toolkit, Zustand, Jotai, and React Query for every state category.

40.2K 14.7K
View

GDPR-compliant data handling with consent management, data subject rights, and privacy controls.

40.2K 14.3K
View

Python error handling patterns including input validation, exception hierarchies, and partial failure handling. Use when implementing validation logic, designing exception strategies, handling batch processing failures, or building robust APIs.

40.2K 13.5K
View

Detailed multi-file refactor planning with safety checks and rollback guidance.

39.7K 13K
View