Posts

Backup Mysql Database to AWS S3 storage - Script

Hi , Below is the mysql backup script -  where you can backup it to the AWS S3 storage. Add this script to the cron tab for automated backups daily.   #!/bin/bash # Basic variables mysqluser=" " mysqlpass=" " bucket="s3://bucket-name" AWSPATH="/usr/local/bin/aws" # Timestamp (sortable AND readable) stamp=`date +"%s - %A %d %B %Y @ %H%M"` # List all the databases databases=`mysql -u$mysqluser -p$mysqlpass -e "SHOW DATABASES;" | tr -d "| " | grep -v "\(Database\|information_schema\|performance_schema\|mysql\|test\)"` # Feedback echo -e "Dumping to \e[1;32m$bucket/$stamp/\e[00m" # Loop the databases for db in $databases; do # Define our filenames filename="$stamp - $db.sql.gz" tmpfile="/tmp/$filename" object="$bucket/$stamp/$filename" # Dump and zip echo -e "  creating \e[0;35m$tmpfile\e[00m" mysqldump -u$mysqluser -p$mysqlpass --force --opt --databases "$...

LetsEncrypt SSL Nginx on Ubuntu 16.04

The first step to using Let’s Encrypt to obtain an SSL certificate is to install the Certbot software on your server . First, add the repository. sudo add-apt-repository ppa:certbot/certbot Update the package list to pick up the new repository’s package information. sudo apt-get update Finally, install Certbot’s Nginx package with apt-get. sudo apt-get install python-certbot-nginx Now you the certbot installed in your system.  Certbot can automatically configure SSL for Nginx, but it needs to be able to find the correct server block in your config. It does this by looking for a server_name directive that matches the domain you’re requesting a certificate for. If you’re starting out with a fresh Nginx install, you can update the default config file. Open it with nano or your favorite text editor. sudo nano /etc/nginx/sites-available/default Changes in the Server tab  server_name example.com www.example.com; Reload Nginx  sudo systemctl r...

Backup Mongo Database to S3 Script

Hi , Some people face problems in automating the mongo database and storing into Aws S3 Before that please add a role of s3 to the instance and please do not keep you Aws credentials in your server . Below is the script where you can backup your mongo Db and store in your S3 account #!/bin/sh echo "Started" DIR=`date +%m%d%y` AWSPATH="/home/ubuntu/.local/bin/aws" MONGODUMP_PATH="/usr/bin/mongodump" ORGDEST=~/db_backups DEST=~/db_backups/$DIR S3FILES=$(aws s3 ls s3:// s3-name /db_backups/ 2>&1 | grep "$DIR" ) if [ ! -z "$S3FILES" ]; then    echo "$S3FILES exist"    exit 1 fi mkdir -p $DEST $MONGODUMP_PATH -u admin -p "Your Passoword" --authenticationDatabase admin  -o $DEST --oplog cd $ORGDEST tar cvzf $DIR.tar.gz $DIR rm -r $DIR $AWSPATH s3 cp $DIR.tar.gz s3:// s3-name /db_backups/ rm -rf $DIR.tar.gz You can run this script in your cron tab for periodically Backup 

Sendy Nginx Configuration

Hi , I have seen many people struggling of nginx configuration of the sendy application.  As the sendy application is not tested on the nginx and its rewrite rules, I have written the configuration and tested it.   I will add the configuration below here server {         listen 80 default_server;         listen [::]:80 default_server;         root /var/www/html; # Add index.php to the list if you are using PHP         index index.php index.html index.htm index.nginx-debian.html;         server_name (domain_name);    location / {                 # First attempt to serve request as file, then                 # as directory, then fall back to displaying a 404.                 #try_files $uri $uri/ =404;     ...

Swap Memory On Amazon AWS(Linux Servers)

Hi ,  Although this is my first blog , Please excuse me , if I am wrong some where . I am experienced Junior Software Developer with a demonstrated history of working in the computer software industry in Mumbai. Skills include analytical thinking ,creative problem solving ,PHP frameworks and Server Engineering. Proficient with database programs including MongoDb and MYSQL Server. I will post commands to create a swap memory in aws .  This Below command will show you the existing swap memory in the server .                      total       used          free           shared      buff/cache   available Mem:           983M     284M        150M        768K        549M        ...