If you have question that how to take tar backup by script then here is the solution.
In Linux tar backup is cool idea which make good sense as it allows to create differential archives backup on modified files.
here you go with script and save it as .sh extension file and run on linux system where you want to set backup.
The script is :
tar –create –listed-incremental $LOG_FILE –gzip –verbose –file $TARGETFILEPATH $SOURCEDIR
mkdir -p $FINALBACKUPDIR
cp $TARGETFILEPATH $FINALBACKUPDIR
cp $LOG_FILE $FINALBACKUPDIR
This script you can set as per your requirement to execute. you can place it under /etc/cron.* path as per required.
DATE=$(date +%Y%m%d) : YYYYMMDD
TIME=$(date +%H%M) : HHMM
The file will be in form of “backup_YYYYMMDD.HHMM.tar.gz” and the log file is “backup_YYYYMMDD.snar“.