Script to take backup of any critical directory in Unix/Linux

This is a script which can be used to backup of  your home directory on a day basis where a compressed backup of your home directory /home will be saved inside /backup directory.


You can put this script in the cron file to take backup regularly as per your requirements.(Replace the parameters in blue as per your requirement)
#!/bin/bash
BACKUPDIR=~/backup
HOMEDIR="/home"
BACKUPFILE=scripts.backup.`date +%F`.tar.gz
THRESHOLD=7
if [ ! -e $BACKUPDIR ];
then
echo Creating backup directory it does not exist
mkdir /backup
exit 0
else
COUNT=`ls $BACKUPDIR/home.* | wc -l`
fi
if [ $COUNT -le $THRESHOLD ];
then
tar -czvf $BACKUPDIR/$BACKUPFILE $HOMEDIR
if [ $? != 0 ]; then echo Problems creating backup file; fi
fi

Follow the below links for more tutorials

Configure Red Hat Cluster using VMware, Quorum Disk, GFS2, Openfiler
Tutorial for Monitoring Tools SAR and KSAR with examples in Linux
How to configure Samba 4 Secondary Domain Controller
How to secure Apache web server in Linux using password (.htaccess)
How to register Red Hat Linux with RHN (Red Hat Network )
Red hat Enterprise Linux 5.5 Installation Guide (Screenshots)
15 tips to enhance security of your Linux machine
Why is Linux more secure than windows and any other OS
What is the difference between "su" and "su -" in Linux?
What is swappiness and how do we change its value?
How to log iptables messages in different log file
What are the s and k scripts in the etc rcx.d directories
How to check all the currently running services in Linux
How to auto start service after reboot in Linux
What is virtual memory, paging and swap space?