LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   Incremental backup script - Tar problem (http://www.linuxquestions.org/questions/linux-software-2/incremental-backup-script-tar-problem-236173/)

joshheald 09-28-2004 07:41 AM

Incremental backup script - Tar problem
 
OK - I've been writing smoe backup scripts recently, but have run in to a problem... tar is archiving everything in anything 1 folder or more depth than I specifically request in the script, and not checking it's date.

That's probably not very clear, so I'll try and explain. Firstly, here's my script:
Code:

echo "Starting changes backup..."
cd /
#The following creates a .tar.gz file, named as so: yymmdd_changes.tar.gz, in the /home/backup directory.
tar -czvf /home/josh/`date +"%y%m%d"`_changes.tar.gz --after-date="`date +%F --date='yesterday'`" /home/josh/backup/addresses/* \
        /home/josh/backup/diary/* \
        /home/josh/docs/* \
        /home/josh/img/* \
        /home/josh/kde/* \
        /home/josh/Mail/* \
        /home/josh/pkg/* \
        /home/josh/public_html/* \
        /home/josh/script/* \
        /home/josh/web/*
echo "Changes backup complete."

I'm trying to make it only archive files which have been changed since yesterday, to any directory depth, but this tar command will only check the dates of files in a specifically requested directory,

eg, /home/josh/docs/file.txt will be checked and acted on appropriately, but /home/josh/docs/work/file.txt won't be checked, and will be archived regardless.

any ideas what I'm doing wrong?

homey 09-28-2004 10:02 AM

Here is an example which may get you going.
The date of the file is checked with the mtime -24 command.

#!/bin/bash

filename=`date '+%m%d%y'`

cd /home/josh
find . -depth -type f -name '*' \
-mtime -24 -exec /bin/tar -cvzf \
/home/josh/${filename}.tar.gz {} \;


All times are GMT -5. The time now is 03:29 PM.