AWS S3 backup script

Published on Author admin

Start with updating AWS CLI tool: pip3 install awscli --upgrade --user Script for backing up data into your AWS S3 bucket: #!/bin/bash pathtobackup='/home/USERNAME/data/' pathtoarchivefile='/home/USERNAME' filenameprefix='backup-nextcloud' secret='secretpassword' awsbucket='awsbucket-name' date=`date --iso-8601` archivefilename=$filenameprefix-$date.7z echo echo "Performing backup of $pathtobackup to s3://$awsbucket/$archivefilename" echo echo `date -Is` echo "Compressing $pathtobackup to $pathtoarchivefile/$archivefilename" echo 7za a $pathtoarchivefile/$archivefilename $pathtobackup -p$secret echo echo… Continue reading AWS S3 backup script

Using AWS EC2 CLI - part 2

Published on Author admin

Using AWS EC2 CLI - part 2 Script for checking VMs status: https://github.com/openterprise/scripts/blob/master/aws-status.sh Example user data file script: https://github.com/openterprise/scripts/blob/master/aws-user-data.sh #create VM centos aws ec2 run-instances --image-id ami-18f8df7d --security-group-ids sg-ID --subnet-id subnet-ID --count 1 --instance-type t2.micro --key-name KEY-NAME --user-data file://aws-user-data.sh --block-device-mappings 'DeviceName=/dev/sda1,Ebs={VolumeSize=10,DeleteOnTermination=false}' --query 'Instances[0].InstanceId' #stop ALL instances (only those are running) aws ec2 stop-instances --instance-ids `aws… Continue reading Using AWS EC2 CLI - part 2

Creating AWS EC2 instances from CLI

Published on Author admin

Install Python PIP: yum install python-pip or yum install python3-pip Install AWS CLI using PIP: pip install awscli --user or pip3 install awscli --user PIP installs aws inside $HOME/.local/bin/ directory. Configure $PATH inside ~/.bash_profile PATH=$PATH:$HOME/bin:$HOME/.local/bin Configure AWS client: $ aws configure AWS Access Key ID [None]: AWSACCESSKEYID AWS Secret Access Key [None]: AWSSECRETACCESSKEY Default region… Continue reading Creating AWS EC2 instances from CLI