#!/bin/bash

# Filename: awsbackup-controller
# Author's: Mark Bogner,
#           Thaddeus M. Diede
#
# Updated 2016-09-15 TMD - Include 'b' flag for scp backup
# Updated 2016-11-02 TMD - Added 'dailyaws-cus-backup' script
# Updated 2016-11-03 TMD - Renamed "dailyawss3backup" to "dailyaws-s3backup-controller"
# Updated 2017-01-17 TMD - Renamed the called scripts for better clarity

# This bash script is for launching two scripts which back up a NovaStar system's
# nsdbbackup's and nsrecdata.log's to TriLynx System's Amazon Web Services S3 cloud
# storage
# These tasks are achieved via the use of Amazon Web Services Command Line Interface (AWS-CLI)

# AWS-CLI communicates on TCP Port 443. 
# This port must be open on the NovaStar servers systems on which this is run.

# -------Important!-------
# These scripts need to be run between the hours of 08:00 and 23:30 for
# dates to be correct on the resulting backups.
# ------------------------


# To Setup on a NovaStar host:
# -------------------------------
#  $ sudo apt-get install python-pip
#  $ sudo pip install awscli
#  $ sudo su
#  # aws configure --profile <_Client-Code_>     << must configure as root
#  - Input IAM credentials, us-west-2, text
#  - Download scripts to admin user /Downloads/aws-cli-utils/
#  - Modify *awsbackup.config* to match host information
#  $ chomod 755 *
#  $ chown tomcat7:novastar5 *
#  $ sudo mkdir /usr/ns/bak      - if doesn't exist
#  $ cp /Downloads/aws-cli-utils/* /usr/ns/cus
#  $ schedule awsbackup-controller in NovaStar5 Admin Interface

#----------------------------
# Controller Script Variables
SCRIPTPATH=/usr/ns/cus

#------------------
# Execute scripts

# AWS-S3 offsite backup the previous day's nssyslog and nsrecdata.log files.
$SCRIPTPATH/awsbackup-nslogs-daily

# AWS-S3 offsite backup the operator config files
$SCRIPTPATH/awsbackup-operator

# AWS-S3 offsite backup the contents of '/usr/ns/cus'.
$SCRIPTPATH/awsbackup-nscus-twicemonthly

# AWS-S3 offsite backup the novastar database.
$SCRIPTPATH/awsbackup-nsdb-daily

