Incremental backup as tar file

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 :

#!/bin/sh
DATE=$(date +%Y%m%d)
TIME=$(date +%H%M)
BACKUPDIR=/path/where/backups/are/stored
SOURCEDIR=/path/of/dir/to/backup
BACKUP=/where/is/NextCloud/Or/OwnCloud
TARGETFILEPATH=”$BACKUPDIR/backup_$DATE.$TIME.tar.gz”
LOG_FILE=”$BACKUPDIR/backup_$DATE.snar”
tar –create –listed-incremental $LOG_FILE –gzip –verbose –file $TARGETFILEPATH $SOURCEDIR
FINALBACKUPDIR=”$BACKUP/$DATE”
mkdir -p $FINALBACKUPDIR
cp $TARGETFILEPATH $FINALBACKUPDIR
cp $LOG_FILE $FINALBACKUPDIR

Description :

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“.

Please follow and like us:
Linux Backup With Tar

Leave a Reply

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

Enjoy this blog? Please spread the word :)

Facebook106
Facebook
LINKEDIN98