LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-31-2004, 07:42 PM   #1
datadriven
Member
 
Registered: Jun 2003
Location: Holly Hill, Florida
Distribution: Slackware 10.1
Posts: 317

Rep: Reputation: 30
Incremental Backup shell script.


I've written a shell script to make incremental backups and have a question about flags to tar.

here's an exerpt. variables are set earlier in the script

echo "Saving files from web directory"
# this tars up my web directory into web.tar.gz tarball.
/bin/tar -czf $TMP$WEB_FILENAME --after-date=$LAST /var/www/htdocs

The script works fairly well, but the resulting archives contain a lot of empty folders in addition to the folders containing the files that have been changed since the last backup. What flag, if any could I add to this line to have the empty folders not be included in the archive.
 
Old 06-02-2004, 06:28 AM   #2
datadriven
Member
 
Registered: Jun 2003
Location: Holly Hill, Florida
Distribution: Slackware 10.1
Posts: 317

Original Poster
Rep: Reputation: 30
Is there no answer? Or is it just that nobody knows?
 
Old 06-02-2004, 08:59 AM   #3
SciYro
Senior Member
 
Registered: Oct 2003
Location: hopefully not here
Distribution: Gentoo
Posts: 2,038

Rep: Reputation: 51
check up the man/info pages .... tho I'm not sure if tar can exclude things.. might need a separate program for that
 
Old 06-02-2004, 09:19 AM   #4
datadriven
Member
 
Registered: Jun 2003
Location: Holly Hill, Florida
Distribution: Slackware 10.1
Posts: 317

Original Poster
Rep: Reputation: 30
Are any of these what I need?

-G, --incremental
create/list/extract old GNU-format incremental backup

-g, --listed-incremental F
create/list/extract new GNU-format incremental backup
-i, --ignore-zeros
ignore blocks of zeros in archive (normally mean EOF)

-S, --sparse
handle sparse files efficiently

Here's my current script in case anybody wants to see it.

#
# inc-backup shell script for making incremental backups
#
# generation of ssh keys and tranferring them to the remote
# server prior to running the script is necessary
#

REM_USER="i7500"
REM_ADDR="192.168.1.109"
REMOTE_MACHINE=$REM_USER"@"$REM_ADDR

TMP="/tmp/"

TODAY=`date +%F`

if [ -f /tmp/lastbackup ]; then
LAST=`cat /tmp/lastbackup`
else
LAST=$TODAY
fi

WEB_FILENAME="inc-"$TODAY"-web.tar.gz"

HOME_FILENAME="inc-"$TODAY"-home.tar.gz"

echo "Saving files from web directory"
# this tars up my web directory into web.tar.gz tarball.
/bin/tar -czf $TMP$WEB_FILENAME --after-date=$LAST /var/www/htdocs

echo "Transferring web files to backup server"
# This sends the tarball to the remote directory
cat $TMP$WEB_FILENAME | ssh $REMOTE_MACHINE "cd backup; cat > $WEB_FILENAME"

echo "Removing web backup files"
# remove web backup file from temp directory
rm $TMP$WEB_FILENAME

echo "Saving files from home directory"
# this tars up my home directory into myhome.tar.gz tarball.
/bin/tar -czf $TMP$HOME_FILENAME --after-date=$LAST /home/jeff

echo "Transferring home files to backup server"
# This sends the tarball to the remote directory
cat $TMP$HOME_FILENAME | ssh $REMOTE_MACHINE "cd backup; cat > $HOME_FILENAME"

echo "Removing home backup files"
# remove home backup file from temp directory
rm $TMP$HOME_FILENAME

echo $TODAY > /tmp/lastbackup

exit;
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell Script for backup BBQ_Matt Linux - Software 7 06-30-2005 05:19 PM
Incremental backup script - Tar problem joshheald Linux - Software 1 09-28-2004 10:02 AM
writting a backup shell script yenonn Slackware 2 03-18-2004 07:49 PM
incremental backup reaky Linux - Software 3 03-10-2004 03:02 PM
bash shell backup script turnip Programming 0 04-03-2003 06:00 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:24 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
Open Source Consulting | Domain Registration