Hello and Welcome, this is the first installment of "Weekend Worker" series.

Today as a Weekend Worker i'll be implementing an automatic backup system to backup each individual client website.

We'll be using the following technologies:

  • Linux cron job
  • Bash
  • Ansible
  • Docker
  • AWS ECS
  • VNC server

Our Setup

And we'll setup our dev environment on our home Windows desktop with the following tools:

  • Ansible for Windows (to launch dev tests)
  • Visual Studio Code (for editing and pushing updates)
  • Git (so our remote prod server can grab the code updates)
  • VNCviewer (to access prod remotely)
  • Bitbucket (for source control)

Preparing the Environment

Download Visual Studio Code
Download Git Bash from git-scm
Use terminal window within Visual Studio Code, travel to repository location and initiate git & pull from master. (not within scope of this document)
at same location, we need Ansible-playbook to work so we will get Ansible for Windows.

On second thought, we won't install Ansible for Windows. We will just run the Ansible-playbook on our remote system - after we push and pull the updates from source control. We can use the --check flag or dev inventory for testing.

Starting the Work:
Currently, my client's websites exist within a docker container per website.

The plan is to have a cron job to run an ansible-playbook which will create a Docker Image out of each customer's Docker Container. The Docker Image will be pushed to AWS ECS Docker Registry regularly.

We will have a loop in our Ansible scripts so the backup is individually applied to each item (website) in our Inventory file.

Cron will run the bash script to initiate the ansible-playbook run.

First we will follow this document to allow Ansible to prepare our connectivity and authenticate with AWS ECS

https://dedisource.com/docs/display/Public/Ansible+amazon-ecr-credential-helper+module

Then, we will need to convert these steps to Ansible script actions using the Ansible Command module:

https://dedisource.com/docs/display/Public/Backup+container+to+registry

Lastly, when we have the Ansible Scripts working to Enable Connection to ECS, Package Docker Container to Image,
Tag Image and Push to AWS ECS registry

We will Set Cron Job for Shell Script to run once per day. We will have the

Bash Shell Script to Launch Ansible Playbook

And that will about do it for us today.

Thanks