Install software on EC2 launch (Linux)

Some time ago I wrote about Linux agent from CloudBerry Lab. This time I want to pack all together and show advanced capabilities of AWS.

When we launch AWS EC2 (compute instance in the cloud) we may want to have something pre-installed (or pre-done) before we get into this VM and start working. Let me give you an example. I do launch instances with Linux OS quite often for various reason (customer's demo, testing applications, testing software etc) and I want to have number of steps without my intervention after launch. To be precise I need my software installed when I SSH into my either CentOS or Debian. Think wide now, don't be locked in my software. Use anything you'd love to have. Well this is good article on how to have PHP installed. In my article I'd like to have CBL for Linux installed with storage configured and backup plan scheduled. Sound cool, right? Let's do it.

Command Line steps

We just need the following things:

  • Update system and Linux distributive (well, this is optionally, but I still prefer to do this since I want to make sure I have all security patches and fixes applied to my system)l
  • Change directory my ~ (I will do Ubuntu 16.04 out of marketplace of AMI), so I will be working with ubuntu user-name;
  • curl binaries from vendor's website;
  • Install using package manage (dpkg);
  • Setup storage account (using software's CLI);
  • Add default backup plan (same as above, CLI) with schedule.

Sounds clear. Here is my script example for AWS EC2 user data:


#!/bin/bash
sudo su
passwd ubuntu << EOF
Pa$$w0rd
Pa$$w0rd
EOF
apt-get update -y
cd ~
curl -# -o cloudberry-backup.deb \
    -F "__EVENTTARGET=" \
    -F "prod=cbbub1214" \
    https://www.cloudberrylab.com/download-thanks.aspx
dpkg -i cloudberry-backup.deb

Let's take a look at the above snippet closer. We elevate permissions to root and change password for our default user ubuntu to Pa$$w0rd. We then proceed with system updates and jump into our home directory for binaries download. My curl command gets binaries from CloudBerry Lab website. Finally I install my package using dpkg default package manager! This should be enough to have CBL Backup for Linux installed when EC2 launched. In order to manage it through CLI change your directory to cd /opt/local/CloudBerry Backup/bin/ and pick any of the below attributes:


./cbb
CloudBerry Backup Command Line Interface started
CloudBerry Backup Commands Help:

 addBackupPlan      - Create a new plan to backup files to cloud storage
 addRestorePlan     - Create a new plan to restore files from cloud storage
 editBackupPlan     - Edit an existing backup plan
 editRestorePlan    - Edit an existing resetore plan
 getPlanDetails     - Get plan details
 plan               - Run custom plan now | list plans
 changePlanState    - Change state
 deletePlan         - Delete plan

 addAccount         - Add backup destination storage
 editAccount        - Edit account
 deleteAccount      - Delete account
 account            - Account list
 option             - Set default option

 sendLog            - Send Error Report

 saveLog            - Save Error Report


 exportConfig       - Export backup configuration to the specific file

 importConfig       - Import backup configuration from the file


 version            - Version

 activateLicense    - activate license
 releaseLicense     - release current license

Start with ./cbb activateLicense -e email -t "ultimate/pro" for example. This is trial license request, check official command line interface user guide for further details.

CloudBerry Backup web interface

With release of CBL for Linux 2.1 it comes with web interface what significantly simplifies product management. Make sure you have 43210 port available (check your security group for your EC2). You can change this port later in the UI. If it is available, open up your favorite browser and type IP-of-your-EC2:43210. This should bring you to the login page, where you should use your system user name and password (ubuntu and Pa$$w0rd).

Login page to CloudBerry Backup for Linux (web)

Now, if you'd like to change default ports to something else, check this part of options:

CloudBerry Backup for Linux - ports configuration for web

That's it! Hope it helps someone with EC2 protection!

Appendix

If all above did not make anything, you may want to troubleshoot your script by checking logs (of course you need SSH into this instance). Logs are in /var/log/. This is what I usually do (since system update may take some time I have enough time to SSH and do tail):


tail -f /var/log/cloud-init-output.log

If you need the same for Windows, please do check this article.


In short, this is about:
#aws ec2
#cloudberrylab
#amazon

Start discussion:
Related articles:
81 mount aws s3 bucket to your el capitan preview
Learn how to mount S3 bucket to your Mac OS ... more
83 cloudberry lab for mac os x 1 8 is now live whoohoo preview
Cloudberry 1.8 for Mac OS X is now live! Impressive list of features and storage platforms support! S3 compatible, new UI and etc. ... more
over 1 year#cloudberrylab #mac
105 conveyoring files for backup cloudberry backup with pre post scripts preview
Working with customers is great experience and you always learn or invent something new. I've been working on the case with files portioning ... more
112 how to follow the 3 2 1 rule with cloudberry backup preview
In this article you'll learn how to protect your data against hardware and software failures according to the 3-2-1 rule. ... more
118 how to send sms using amazon sns and python preview
Send text messages (SMS) with few lines of Python code using Amazon SNS and boto3 SDK. ... more
79 mount aws s3 bucket to your debian preview
In this very short tutorial we are going to mount S3 bucket from AWS to the local folder of Debian. ... more
88 amazon solutions architect associate exam preview
August, 9th, 2016 - passed my Amazon CSAA. Few tips I'd love to share here. ... more
125 episode 2 build your own free pbx with asterisk preview
AWS EC2 free tier. In this episode we are going to build absolutely free PBX (telephony system) based on Asterisk free switch hosted on our Amazon free EC2. ... more
86 call recording asterisk preview
Asterisk IP PBX comes with embedded MixMonitor, that allows us to to record and place those recordings somewhere. ... more
61 amazon web services cloudfront with subdirectory preview
In this article we are going to set up CloudFront for static site. And there is nice tip how to nested content (i.e. subfolders) available. ... more
101 aws ec2 linux backup preview
Amazon Web Services (AWS) has its own AWS Linux AMI (also free tier). There are several reasons you want to use this AMI for your projects. ... more
110 awsrus russian st petersburg user group for aws preview
AWSRus — Official AWS User Group Russia (St. Petersburg). ... more
113 grant fullaccess to all mailboxes in exchange 2010 preview
Since FullAccess is disabled even for Administrator's account in Exchange (including 2010) CloudBerry Backup for Exchange can't restore using Administrator's username and password pair for item level restore of any mailbox. Let's fix it. ... more
116 aws efs windows preview
AWS Elastic File System is scalable file system in the cloud, requires NFSv4.1 client and does not support Windows at the moment. However let's see what we can do.. ... more
119 smtp server for notifications preview
AWS SES supports SMTP settings for sending through it-self. This is really helpful if we want to configure personal outbound server. ... more
117 seo friendly aws static website with ssl preview
It's been written many times, however there is no consistency how to make static web site with SSL and SEO friendly urls (301 redirect). Pure AWS based services static website ahead, check details inside! ... more
121 aws ec2 user data script windows preview
How to pre-deploy App using user data script for Windows OS with powershell powered script in EC2? Example inside. ... more
114 how to download random pictures preview
In CloudBerry Lab we help people to move data offsite to the cloud either with backup or file management solution. Sometimes I need sample files, a lot of sample files. ... more
122 what is possible with aws free tier preview
I made light talk on one of our recent #AWSRus community gathering in Moscow and decided to discover this topic with further series of posts in my blog covering various AWS services. ... more
about 1 month#free tier #amazon
111 data backup and disaster recovery with aws preview
CloudAcademy webinar: how to use AWS services for Backup and DR challenges. I am presenter! ... more