Upload files to "sk1"
This commit is contained in:
parent
56f3b4397f
commit
3a5ba39fbf
@ -1,22 +1,3 @@
|
||||
#!/usr/bin/env bash
|
||||
# backup.sh — Create a manual RDS snapshot for Notes App
|
||||
# Usage: source .env && ./backup.sh
|
||||
set -euo pipefail
|
||||
#!/bin/bash
|
||||
|
||||
: "${AWS_REGION:?Set AWS_REGION in .env}"
|
||||
|
||||
SNAPSHOT_ID="notes-app-manual-$(date +%Y%m%d-%H%M%S)"
|
||||
|
||||
echo "Creating RDS snapshot: ${SNAPSHOT_ID}..."
|
||||
aws rds create-db-snapshot \
|
||||
--db-instance-identifier notes-app-db \
|
||||
--db-snapshot-identifier "$SNAPSHOT_ID" \
|
||||
--region "$AWS_REGION" \
|
||||
--output none
|
||||
|
||||
echo "Waiting for snapshot to complete..."
|
||||
aws rds wait db-snapshot-completed \
|
||||
--db-snapshot-identifier "$SNAPSHOT_ID" \
|
||||
--region "$AWS_REGION"
|
||||
|
||||
echo "✅ Backup complete: ${SNAPSHOT_ID}"
|
||||
docker exec app_db pg_dump -U notesuser notesdb > backup.sql
|
||||
|
||||
61
sk1/create-vm.sh
Normal file
61
sk1/create-vm.sh
Normal file
@ -0,0 +1,61 @@
|
||||
#!/bin/bash
|
||||
|
||||
# VARIABLES
|
||||
KEY_NAME="my-key"
|
||||
SECURITY_GROUP="notes-app-sg"
|
||||
INSTANCE_NAME="notes-app-vm"
|
||||
AMI_ID="ami-0e872aee57663ae2d"
|
||||
INSTANCE_TYPE="t2.micro"
|
||||
REGION="eu-central-1"
|
||||
|
||||
# CREATE SECURITY GROUP
|
||||
aws ec2 create-security-group \
|
||||
--group-name $SECURITY_GROUP \
|
||||
--description "Security group for Notes App" \
|
||||
--region $REGION
|
||||
|
||||
# OPEN PORTS
|
||||
aws ec2 authorize-security-group-ingress \
|
||||
--group-name $SECURITY_GROUP \
|
||||
--protocol tcp \
|
||||
--port 22 \
|
||||
--cidr 0.0.0.0/0 \
|
||||
--region $REGION
|
||||
|
||||
aws ec2 authorize-security-group-ingress \
|
||||
--group-name $SECURITY_GROUP \
|
||||
--protocol tcp \
|
||||
--port 80 \
|
||||
--cidr 0.0.0.0/0 \
|
||||
--region $REGION
|
||||
|
||||
aws ec2 authorize-security-group-ingress \
|
||||
--group-name $SECURITY_GROUP \
|
||||
--protocol tcp \
|
||||
--port 443 \
|
||||
--cidr 0.0.0.0/0 \
|
||||
--region $REGION
|
||||
|
||||
aws ec2 authorize-security-group-ingress \
|
||||
--group-name $SECURITY_GROUP \
|
||||
--protocol tcp \
|
||||
--port 8080 \
|
||||
--cidr 0.0.0.0/0 \
|
||||
--region $REGION
|
||||
|
||||
aws ec2 authorize-security-group-ingress \
|
||||
--group-name $SECURITY_GROUP \
|
||||
--protocol tcp \
|
||||
--port 8081 \
|
||||
--cidr 0.0.0.0/0 \
|
||||
--region $REGION
|
||||
|
||||
# CREATE INSTANCE
|
||||
aws ec2 run-instances \
|
||||
--image-id $AMI_ID \
|
||||
--count 1 \
|
||||
--instance-type $INSTANCE_TYPE \
|
||||
--key-name $KEY_NAME \
|
||||
--security-groups $SECURITY_GROUP \
|
||||
--tag-specifications "ResourceType=instance,Tags=[{Key=Name,Value=$INSTANCE_NAME}]" \
|
||||
--region $REGION
|
||||
10
sk1/deploy.sh
Normal file
10
sk1/deploy.sh
Normal file
@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
sudo apt update
|
||||
|
||||
sudo apt install docker.io docker-compose nginx certbot python3-certbot-nginx -y
|
||||
|
||||
sudo systemctl enable docker
|
||||
sudo systemctl start docker
|
||||
|
||||
docker-compose up -d --build
|
||||
3
sk1/destroy.sh
Normal file
3
sk1/destroy.sh
Normal file
@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
docker-compose down -v
|
||||
Loading…
Reference in New Issue
Block a user