Bash script to backup using lftp

Can use below script to gzip a folder, and upload to a FTP site. We can use a cron task to schedule it.


#!/bin/bash
Fn=myvps-backup-$(date +%Y%m%d).tar.gz
tar cf - websites | gzip -9 - > $Fn lftp -u user@name,password myhostname.com << EOF
set ssl:check-hostname no
set ssl:verify-certificate false
cd /public_ftp
put $Fn
bye
EOF

Whitepaper on Designing an efficient Virtual Queue Management System

Recently I wrote a research paper on the said topic, and here are the links I published:

  1. Original, updated version @ GitHub – https://github.com/ninethsense/VirtualQueue/blob/master/README.md
  2. Medium – https://medium.com/@ninethsense_8477/yet-another-virtual-queue-management-system-design-44cdee123a0b

Additionally, a small excerpt in a Malayalam online news paper – https://www.janmabhumi.in/read/bevq-failure-is-a-lesson-how-to-build-the-best-virtual-queue-app/

PHP PortPing script – check host connectivity

Here is a script in PHP I wrote to check if a remote host and port are open for you to connect. Do not mistake this as an equivalent to ping command because ping uses ICMP and I used TCP using PHP’s famous fsockopen() function, and a small piece of AJAX.

PortPing

You can get the latest source code from my GitHub code share page – https://github.com/ninethsense/code-share/

PHP:

function ping($host, $port) {
         $startTime = time();
         if ($fs = fsockopen($host, $port, $errCode, $errStr, 1)) {
             $timeTaken = (time()-$startTime)/1000;
         echo "Reply from $host:$port time={$timeTaken}ms";
             fclose($fs);
         } else {   
             echo "Request timed out.";
         }
         echo "<br>";
     }

JavaScript:

var count = 0;
             var intervalID = setInterval(function PortPing() {
                 var xhttp = new XMLHttpRequest();
                 xhttp.onreadystatechange = function() {
                     if (this.readyState == 4 && this.status == 200) {
                         document.getElementById("console").innerHTML += this.responseText;
                     }
                 };
                 xhttp.open("GET", "PortPing.php?source=self&host=<?=$host?>&port=<?=$port?>", true);
                 xhttp.send();
                 if (++count > <?=$t-1?>) {
                     clearInterval(intervalID);
                 }
             },2);

How to setup AWS SES / Simple Email Service

This is a tutorial on how to setup AWS SES / Simple Email Service.

Step 1 – Login to your AWS Console, then choose Services –> Customer Engagement –> Simple Email Service

image

Step 2 – Verify a New Domain

Choose “Domains” from left navigation panel, then click –> Verify a New Domain button

image

Step 2.2 – Enter Domain name

image

Also click checkbox Generate DKIM settings, though optional, I will be using this.

You will be displayed with a list of DNS settings in the next screen.

image

Once you completed the Step 3, click close.

Step 3 – Edit DNS records

You will have to login to your domain control panel and add these.

I will be using cPanel for this exercise. Steps are almost same with any domain/hosting control panel.

image

Step 4 – Wait for the domain to get verified. Click refresh icon on the right-top whenever you are impatient.

image

You have nothing to do here. Just wait for some 2-5-10 minutes.

image

Step 4.1 – Verify Email Address

You cannot even send a test mail, unless you have a email id verified.

Choose ‘Email Addresses’ from the left-navigation panel and click “Verify a New Email Address” button.

image

Make sure you enter an already existing email id.

image

A verification mail will be sent to your inbox.

There will be a URL you are expected to click, and you are verified.

image

Once verified, you should be able to see the verification status updated in AWS console too.

image

Step 5 – Send test mail.

Go back to Domains –> “Send a Test Mail” button.

image