Incremental backup as tar file
Disclaimer: Accessing the information on this page means you agree to the Sites Privacy Policy & Terms of Use Agreement.
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“.
This article is contributed by RootLinuxBlog. If you like RootLinuxBlog and would like to contribute, you can submit an article using contact us from. See your article appearing on the RootLinuxBlog main page and help other Techies.
Please write comments if you found any error with the above article would really help us to serve you a better way. Thank you…