timestamp=`date +%Y%m%d`
cd /path/to/logs # goto log location
printf "\nArchiving custom log...\n\n"
log=custom.log # the log filename
nlog=$log.$timestamp.log # the archive filename
sudo cp $log $nlog # copy the data
sudo gzip -f -9 $nlog # archive log
printf "\n\t Archive of "$nlog" complete.\n"
the_log=$log # ref
the_log_archive=$nlog # ref
aws s3 cp $the_log_archive s3://bucket-name/folder/for/backups # move copy to AWS
sudo truncate -s0 $the_log # empty the old log
Creates a compressed log file, empties the original and copies the archive to an AWS S3 Bucket folder.
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.