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.




Monday 23 January 2017

How to configure SVN Server (Subversion Edge) on CentOS/Red Hat


Apache Subversion (often abbreviated SVN, after its command name svn) is a software versioning and revision control system distributed as open source under the Apache License. Software developers use Subversion to maintain current and historical versions of files such as source code, web pages, and documentation. Its goal is to be a mostly compatible successor to the widely used Concurrent Versions System (CVS).

In this tutorial, I am using CollabNet Subversion Edge. It simplify Apache Subversion installation, automate upgrades, and manage code, instances, and users in a centralized, simple way. You can add your preferred Subversion clients and pick from a range of integrations to further extend your Subversion platform.

You can download free CollabNet Subversion Edge from following link.


Use the following steps to install svn server in your linux system,

1. Install and configure jdk.



    Download jdk-version.tar.gz from


                 http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html


   Extract the downloaded jdk. 


                   # tar -xzf jdk-version.tar.gz


   Set environmental variable. 


                    Edit vim .bash_profile  --->  export PATH=(path of jdk bin):$PATH  (in centos,redhat....) 
           Edit vim .profile           --->  export PATH=(path of jdk bin):$PATH  (in ubuntu,mint....)



2. Create user svn.


[root@centos ~]# useradd svn

[root@centos ~]# passwd svn





3. Copy CollabNetSubversionEdge-5.1.5_linux-x86_64 to svn users home directory.


[root@centos ~]# cp CollabNetSubversionEdge-5.1.5_linux-x86_64.tar.gz  /home/svn/


4. Switch to svn user and add java environmental variable.


[root@centos ~]# su - svn


5. Open ".bash_profile" and add jdk path in it.


[svn@centos ~]$ vim .bash_profile

export PATH=/root/jdk1.8.0_112/bin/:$PATH







6. Extract package 


tar -xvf CollabNetSubversionEdge-5.1.5_linux-x86_64.tar.gz 




7. go to configuration folder and change csvn.conf.dist to csvn.conf


[svn@centos conf]$ cp -rp csvn.conf.dist  csvn.conf







8. Edit csvn.conf


Search for "JAVA_HOME" and uncomment this line and add jdk path. Change RUN_AS_USER=root

[svn@centos conf]$ vim csvn.conf














9. Go to bin directory and start svn.


[root@centos ~]# cd /home/svn/csvn/bin/
[root@centos bin]# ./csvn start









10. Install the application. 


[root@centos csvn]# sudo -E bin/csvn install



This installs the application so that it will run at startup. The script will swap to the user specified before it starts the console. Please note the JAVA_HOME requirement - you must have set the environment variable for your profile (or the entire system) so that it will be visible when the process starts.
When you install csvn as a service, you can control it with these commands:


    $ sudo service csvn status
    $ sudo service csvn start
    $ sudo service csvn stop


11. There are also scripts for Apache server, but you should visit the console first and go the Admin page to set the port and other options before you try to start it. It can also be started from the web UI.


[root@centos csvn]# bin/csvn-httpd start
[root@centos csvn]# sudo bin/csvn-httpd install







12.Test SVN Server.


The default username and password will be "admin"