LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices



Reply
 
Search this Thread
Old 09-28-2004, 08:41 AM   #1
joshheald
LQ Newbie
 
Registered: Sep 2004
Posts: 3

Rep: Reputation: 0
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?

Last edited by joshheald; 09-28-2004 at 08:44 AM.
 
Old 09-28-2004, 11:02 AM   #2
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 56
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 {} \;
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
incremental backup using tar eaglegst Linux - Software 9 02-01-2009 06:00 PM
Incremental Backup (tar command) maginotjr Slackware 4 07-21-2005 02:04 AM
Getting date format right in tar incremental backup jonr Linux - Software 3 08-19-2004 10:53 AM
Incremental Backup shell script. datadriven Linux - General 3 06-02-2004 10:19 AM
Backup script to tar untoldone Programming 2 05-20-2004 04:03 PM


All times are GMT -5. The time now is 12:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration