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:

sudo su
passwd ubuntu << EOF
apt-get update -y
cd ~
curl -# -o cloudberry-backup.deb \
    -F "__EVENTTARGET=" \
    -F "prod=cbbub1214" \
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:

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!


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

Start discussion:
Related articles:
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
In this very short tutorial we are going to mount S3 bucket from AWS to the local folder of Debian. ... more
Learn how to mount S3 bucket to your Mac OS ... more
over 5 years#amazon s3 #mac #amazon
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 5 years#cloudberrylab #mac
Asterisk IP PBX comes with embedded MixMonitor, that allows us to to record and place those recordings somewhere. ... more
August, 9th, 2016 - passed my Amazon CSAA. Few tips I'd love to share here. ... more
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
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
AWSRus — Official AWS User Group Russia (St. Petersburg). ... more
about 5 years#meetup #awsrus #amazon
CloudAcademy webinar: how to use AWS services for Backup and DR challenges. I am presenter! ... more
In this article you'll learn how to protect your data against hardware and software failures according to the 3-2-1 rule. ... more
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
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
over 4 years#cloudberrylab #ruby
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
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
Send text messages (SMS) with few lines of Python code using Amazon SNS and boto3 SDK. ... more
AWS SES supports SMTP settings for sending through it-self. This is really helpful if we want to configure personal outbound server. ... more
over 4 years#aws ses #smtp #amazon
How to pre-deploy App using user data script for Windows OS with powershell powered script in EC2? Example inside. ... more
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
over 4 years#free tier #amazon
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
about 4 years#aws ec2 #free tier
In this short article you will learn how to use PsExec with remote powershell script to download, execute and clean up software. You can do it for multiple computers in super easy way. ... more
Here at CloudBerry, where one of the goal I have is to help partners decide, pick and build right configurations for dealing with computers data when they need backup solution. FTP, SCP, WebDav and some other proprietary protocols have been here forever, where simplicity and flexibility made them number one in data protection and management fields as primary target configurations. But, there is big BUT... ... more