Tuesday, August 3, 2021

Script to migrate GIT Repo to AWS CodeCommit | GIT Repo Migration Bash Script


Bash script to migrate GIT repo to AWS CodeCommit : You can just copy this script and run to migrate your repo.

 Note : Make sure before running this script you have created your IAM user and configured on your server 

# cd /opt

# vi script.sh


#!/bin/bash

# This script made for GIT migration on AWS CodeCommit 

RED="\e[31m"

GREEN="\e[32m"

BLUE="\e[34m"

BOLD="\e[1m"

BOLDGREEN="\e[1;${GREEN}m"

ENDCOLOR="\e[0m"

echo -e "${GREEN}Enter Git project name${ENDCOLOR}"

read project

echo -e "${GREEN}Please Enter GIT repo URL${ENDCOLOR}"

read gitpath

echo -e "${GREEN}Please Enter CodeCommit repo URL${ENDCOLOR}"

read CodeCommit

#mirroe git code

git clone --mirror $gitpath $project

cd $project

git branch

git remote add sync $CodeCommit

git push sync --mirror

if [ $? = "0" ]

       then

        echo -e "${GREEN} git url $gitpath migrated successfully${ENDCOLOR}"

       else

        echo -e "${GREEN} git url $gitpath migration failed please check${ENDCOLOR}"

fi

sleep 5

git branch -r

echo -e "${GREEN} Press Enter to complete migration${ENDCOLOR}"

read p




How to Extend LVM Volume without Data loss | How to increase Server Space on Centos 6/7

 Why we need to perform this activity:   When we are facing space issue on server because of data increment we need more space on server so we can increase server Hard Disk through LVM.


    Step Need to perform in this activity -

1.     Add new hard disk in server 
2.     scan new hard disk for visibility 
3.     Create New partition 
4.     Convert partition in physical volume 
5.     Add new physical volume in  volume group 
6.     Increase Logical Volume 

    Let's do this activity step by step 

    Check current status of HDD 

    * To check current status of HDD you can use below command 

        # fdisk -l 




    * Verify current available space on server 

     #df -h  



    * Check existing data 

    # mkdir /opt/mydata

    # echo "https://www.makelinuxinteresting.com/" > /opt/mydata/test.txt

    # cat /opt/mydata/test.txt


1. Now add new hard disk in server : Now added 5 GB hard disk in server 



    2. Now scan hard disk for Availability 

Note : After adding new hard you can reboot your server to get HDD reflected or you can scan your Hard            Disk from command given below .

   * Check available host in server 

    #ls /sys/class/scsi_host/ 

         * Now scan all available host one by one 

    #echo "- - -" > /sys/class/scsi_host/host0/scan

    
echo "- - -" > /sys/class/scsi_host/host1/scan

    # echo "- - -" > /sys/class/scsi_host/host2/scan

    echo "- - -" > /sys/class/scsi_host/host3/scan

    * Now check new hard disk is showing or not

    # fdisk -l 




     3. Now create partition in new hard disk by fdisk command 


        # fdisk /dev/sdb 
         : n ( Press n for New partation)
         : p (Press p to select primary 
         : Press Enter to select default value 
         : Press Enter to select default value
         : w  ( Press w to write change) 
   


    * Now verify new created partition 

    # fdisk -l /dev/sdb












      4. Now convert partition in physical volume 


        # pvcreate /dev/sdb1 








    5. Now add new physical volume in  volume group 

      * check group volume 

     # vgdisplay 













    * Now extend volume group 

           # vgextend  centos /dev/sdb1 

        Note here centos is VG name so change according to your requirement

 





    * Now check volume group available space 

    #vgdisplay 





    










    6. Increase Logical Volume 

    * Check logical volume name 

    #lvdisplay 




    * Now extend partition 

      lvextend -l +100%Free /dev/centos/root





    * Now resize changes 

Note: Here make sure you run command according to OS version 

     >  For Centos 6 

    resize2fs lvname   


    # resize2fs  /dev/centos/root


    > For Centos 7


    # xfs_growfs    /dev/centos/root




    










   Now check space on server 

        # df -h 














Now check total available space is increased  

Now enjoy 

Mastering Cron Jobs in Linux: A Comprehensive Guide with Examples

Introduction: Cron jobs are an indispensable tool in the world of system administration and automation. They allow users to schedule tasks t...