Script for taking Daily backup and compress files for Linux Boxes

Linux Shell scripting

is necessary part with Linux and application support activities .

In this Post i am sharing you script which is successfully running with jboss version 6.1.

 

That script will save output in file and will send it over email.


#!/bin/sh
##### SCRIPT CREATED AND MAINTAINED BY #<Keshav Piplani> ######
#####FOR ANY QUERIES PLEASE CONTACT <keshavpiplani@gmail.com> ######
#Directory under which files backup needs to be taken
DIR="/data/jboss6/jboss-6.1.0.Final/server/default/log"
#backup location
backup="/data/jboss6/sonata_log_backup"
Attached script can be downloaded from here. 

 

Points to  remember

  1. Please change  days=1 value to number of days old files backup you want to take.
  2. Please change DIR=”/data/jboss6/jboss-6.1.0.Final/server/default/log” variable to the path of directory which files backup you want to take.
  3. Same with home=”/data/jboss6/jboss-6.1.0.Final/server/default/log” variable. Please change its value to path whose backup you wanna take.
  4. backup=”/data/jboss6/sonata_log_backup” It contains backup location.Please update accordingly.
  5. script=”/data/jboss6/sonata_log_backup/dailyscript_output” OutPut of script will stored here.
  6. These script will make automatically folders under location mkdir -p “$backup/dailyscript_output”
     “$backup/dailyscript_output”/”$date”
    “$backup”/log/”$date” with datewise ,  It will also redirect output of error into error_log  .
    “$backup/dailyscript_output” 2>>/$script/$date/error_log
    “$backup/dailyscript_output”/”$date” 2>>/$script/$date/error_log
    “$backup”/log/ 2>>/$script/$date/error_log
    “$backup”/log/”$date” 2>>/$script/$date/error_log.
  7. You can run script via putting crontab entry or can manually run it.

 

 

If you want me to change anything in script please get in touch over email .

 

 

Please follow and like us:

Leave a Reply

Your email address will not be published. Required fields are marked *