Tuesday, 21 November 2017

How to clear catalina.out without disabling further logging

Delete Apache Tomcat catalina.out log


Step 1 : Go to apache tomcat log directory
 
                     [root@centos ~]#   cd /apache-tomcat-8.5.12/logs/


Step 2 :  Clear the file catalina.out



                       [root@centos ~]#  echo > catalina.out





Tuesday, 24 January 2017

Backup Directories to Google Drive Automatically on CentOS/Red Hat


This tutorial explains how to backup directories to google drive.

1. Install google drive.

            Use the following link ti download google drive

           https://drive.google.com/open?id=0B2iJNfzwHersOVYzV0xsa09SZ1U

2. Move this file to "/usr/sbin/" folder.
  
       
           [root@centos ~]# mv drive /usr/sbin/drive





3. Assign right permission to the file.

              [root@centos ~]# chmod 755 /usr/sbin/drive


 


4. Now run command "dive". It will ask authentication.

      You will get a link like this.

"https://accounts.google.com/o/oauth3/auth?client_id=3453453533-7n0vf5gghru6on6o3fjinrghpdoe88eg.apps.googleusercontent.com&redirectghct_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=code&scope=https%3A%2F%2Fwww.goohgheapis.com%2Fauth%3Fdrive&state=state"

  Go  to the above link on browser, you will get verification code. Type verification code and hit Enter.






5. Create backup script.

----------------------------------------------------------------------------------

#!/bin/sh


# tar the bkp directory
tar -zcf "dir-backup-$(date '+%Y-%m-%d').tar.gz" /root/AAA/aby/

# encrypt the tar
#openssl aes-256-cbc -a -salt -in "dir-backup-$(date '+%Y-%m-%d').tar.gz" -out "dir-backup-$(date '+%Y-%m-%d').tar.gz.enc" -pass 'pass:123456'

# remove the original tar
#rm -rf "dir-backup-$(date '+%Y-%m-%d').tar.gz"

# upload to google drive
drive upload --file "dir-backup-$(date '+%Y-%m-%d').tar.gz" -p 0B2iJNfzwHersN3Yxa0N3U1lqeU0

----------------------------------------------------------------------------------------------------------------------





6. Execute the script.




You can Schedule this script on crontab and schedule this autobackup.