How to migrate your MongoDB database instance with mongodump, mongorestore, tar and scp

Migration of MongoDB database is part and parcel of DevOps, especially when you are running your own projects.

MongoDB provides us with two utilities for performing database migration – mongodump and mongorestore.

A simple MongoDB database migration can be performed in 5 steps:

  1. Use the mongodump command to export the data of a MongoDB database instance as files in the source server’s filesystem.
  2. Use the tar command to compress the exported files as a single .tar.gz file in the source server’s filesystem.
  3. Use the scp command to send the .tar.gz file from the source server to the destination server.
  4. Use the tar command to decompress the .tar.gz file at the destination server.
  5. Use the mongorestore to import the extracted files into the destination MongoDB database.

This post discusses how you can perform MongoDB database migration with utilities provided by MongoDB and most Linux servers.

Understanding the difference between the root and alias directives in Nginx

Nginx is a web server that is good for serving as a reverse proxy server, load balancer or HTTP cache.

One of the most important task in configuring Nginx to proxy HTTP / HTTPS traffic is telling Nginx where to look for files that it needs for serving HTTP / HTTPS requests.

This posts discusses the root and alias directives that we can use in Nginx configuration files for mapping a url from a HTTP request to a file on the server file system.

Installing Certbot on Raspbian Stretch Lite for obtaining Let’s Encrypt’s browser-trusted certificates

By offering free browser-trusted certificates, Let’s Encrypt makes it easy for ordinary folks like you and me to deploy secure web applications that serve HTTPS traffic 24-7.

The issuance of Let’s Encrypt certificates is automated by software participating in the ACME protocol. We will need to run such a software on devices which host web servers serving HTTPS traffic.

The Raspbian Stretch Lite operating system is a way to create performant web-based appliances with Raspberry Pis. If you need to secure your web-based applications on Raspbian Stretch Lite, you may choose to install Certbot on Raspbian Stretch Lite as a first step.

This post extends Certbot’s installation instruction on Debian Stretch to provide the steps for installing Certbot on Raspbian Stretch Lite.

How to setup Raspbian Stretch Lite on Raspberry Pi 3 to run Python 3 applications

Raspbian Stretch Lite operating system is the Raspberry Pi Foundation’s official supported operating system for running headless software. It is a good operating system for different Raspberry Pi 3 use cases. Some examples include:

If you are planning to use Raspberry Pi 3 GPIO to interface with the real world, it is recommended that you setup Raspbian Stretch Lite to run Python 3 applications.

This post provides the steps to setup Raspbian Stretch Lite on Raspberry Pi 3 for running Python 3 applications.

How to capture the Northern Lights with an entry level DSLR

My most recent trip to the Aurora Village, Ivalo was a very fruitful one. My wife and I were able to experience what we had wanted to experience – Finnish Christmas Festival, the snow, the starry nights and the Northern Lights or Aurora Borealis.

Prior to taking the trip, I had been pondering over whether to get a Canon EOS 5D Mark IV or stick with my old Canon EOS Rebel T1i to capture the Northern Lights.

Lucky for my wallet, I was able to procrastinate long enough to avoid adding another three grand to our travel expenses. An entry level DSLR like the Canon EOS Rebel T1i or Canon EOS Rebel T5i is capable enough to help ordinary folks like us capture blessings from the northern skies.

If you are also chasing the Northern Lights with an entry level DSLR, here are some tips for you.

Photo of Canon 500D with photo of aurora lights at Aurora Village Ivalo

Setting up a fast git server on Raspberry Pi Zero W with Go Git Service (Gogs) and Raspbian Stretch Lite

The Go Programming Language is a compiled programming language created by Robert Griesemer, Rob Pike, and Ken Thompson from Google in 2009. With Google Go, it is possible to build programs that run efficiently on minimum hardware resources. The compiled code runs close to the speed of C. Use cases of Go Programming language includes Docker, Kubernetes and Go Git Service.

If you happen to need a self-hosted git server to track software projects that you build on the side, you can consider using Go Git Service. With the Raspberry Pi Zero W bundle set, you can set up a fast git server that does not take up too much space on your desk.

This post details how you can setup a fast git server on Raspberry Pi Zero W with Go Git Service and Raspbian Stretch Lite.

Why should programmers blog?

One of the big words on the Internet nowadays is the word ‘blog’. As a noun, this word refers to a website or web page that is updated regularly by an individual or a group, written in an informal or conversational style. What you are reading now is an example of one. As a verb, it refers to the act of adding new content to a blog.

Ever since I started this blog on 14 November 2010 on a self-hosted WordPress instance, I had never stop adding content to it.

Since then, I often came across programmers asking why they should blog. To help them get started, here are some reasons for programmers to blog.

How to setup Raspbian Stretch Lite with remote configuration over WiFi on first boot

Two of the good features of Raspbian Stretch Lite is that it allows us to enable the SSH server and connect to our WiFi network before it boots up for the first time.

Combining these two features is useful for projects based on Raspberry Pi Zero W as we can configure Raspbian Stretch Lite via SSH without connecting extra peripherals to it.

This post documents how you can enable remote configuration of your Raspbian Stretch Lite over WiFi on first boot.

How to enable authenticated MongoDB access for Flask-MongoEngine applications

After having a first look at MongoDB more than 5 years back, I told myself that I will use MongoDB to realise the next functionality of Techcoil.

With exposure to Python 3, Flask and MongoEngine in 2017, I had acquired the skills to build a microsite to recommend gift ideas. This microsite uses MongoDB to store the gift recommendation data.

With Flask and MongoEngine, development of this microsite did not take too much leisure time. With MongoDB not enforcing authentication, there were not much hindrance in setting up the development environment for this microsite.

However, this free-for-all mode of accessing MongoDB is not recommended for production environments. Without authentication, it is easier for ill-intentioned people to mess up the backend database.

To ensure that I have a go-to post for implementing authenticated access to MongoDB backed projects in the future, I document the steps needed for Flask-MongoEngine applications to access MongoDB instances with access control turned on.