Upload to AWS S3 service

A simple Bash script to upload files into AWS S3 (bucket) service don’t forget to install and configure awscli package “aws configure

#Author:  Rafael E Rumbos S
#Description:  Upload a gzip to AWS S3
# previous “aws configure” execution for credentials
#!/bin/bash

#Get logs from docker
docker logs crossover_test >> mysql_log.txt 2>&1
docker logs apache1  >> apache_log.txt  2>&1

#Compress the files
tar -cvf – mysql_log.txt apache_log.txt | gzip > upload.tar.gz

#Upload the files
aws s3 cp ./upload.tar.gz s3://logscrossover/logs/uploadfinal.tar.gz

#Delete files
rm mysql_log.txt
rm apache_log.txt
rm upload.tar.gz
exit

Leave a Comment