I have a file named backup.sh
. I just want to take backup only html
directory and its all sub directories and files. But I'm getting all the parent directory of html
directories as well like var
, www
which is not required for me.
I'm pasting the code below:
#!/bin/bash
#Purpose = Backup of Important Data
DATE=$(date +"%d-%b-%Y")
SRCDIR="/var/www/html"
DESDIR="/media/HDD-01/html"
FILENAME=html-$DATE.tar.gz
# Making backup with compress
tar -cpzf $DESDIR/$FILENAME $SRCDIR
I got this code from below link:
http://broexperts.com/2012/06/how-to-backup-files-and-directories-in-linux-using-tar-cron-jobs/
Can anyone suggest me how can I solved my problem?
Thanks in advance.
/media/HDD-01/html
is available. – AReddy Feb 24 '16 at 08:56