Automated backup and disaster recovery ensures business continuity by protecting data and applications from failures, disasters, or outages.
import boto3
from datetime import datetime
s3 = boto3.client('s3')
def backup_to_s3(file_name, bucket_name):
timestamp = datetime.now().strftime("%Y%m%d%H%M%S")
s3_key = f"backups/{file_name}_{timestamp}.bak"
s3.upload_file(file_name, bucket_name, s3_key)
print(f"Backup {file_name} uploaded to {s3_key} in bucket {bucket_name}")
# Usage
backup_to_s3('database.db', 'my-backup-bucket')
# Create daily backup of RDS
aws rds create-db-snapshot \
--db-instance-identifier mydb \
--db-snapshot-identifier mydb-backup-$(date +%F)
Automated backup and disaster recovery provides reliable data protection and operational continuity, critical for resilient DevOps pipelines.