Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back > Forums > Linux Forums > Linux - Server
User Name
Linux - Server This forum is for the discussion of Linux Software used in a server related context.


  Search this Thread
Old 04-03-2007, 12:15 AM   #1
Registered: Nov 2003
Location: USA
Distribution: Ubuntu, Fedora
Posts: 415

Rep: Reputation: 31
Question backups using tar and rsync

I have this little script to make backups:



tar -cvzf /Volumes/DataHD/projects

$RSYNC --exclude-from "/Users/bhadmin/backup_excludes.txt" -avve /usr/bin/ssh /Volumes/DataHD/projects "/Volumes/backupdisk/projects"

I'm not sure how to tar the directories and then use rsync to send the backup to an USB drive(backupdisk). Should I first use tar then rsync? or the opposite? I have tested this script without the tar part and it works fine, but I want to tar the files because they are kind of big. Do I use | for tar?

Old 04-03-2007, 01:05 AM   #2
Senior Member
Registered: Nov 2002
Location: CA
Distribution: redhat 7.3
Posts: 1,440

Rep: Reputation: 52
What you are doing is actually tar'ing the files and then compressing them using gzip. You can tell because you are passing the 'z' flag. I would personally tar/gzip the file first and then rsync it over. Perhaps something like this:


date=`/bin/date "+%Y%m%d"`

# Backup the content
cd ${backup_dir}
tar czvf ${filename}-${date}.tar.gz ${filename}

# Copy the content over
rsync -av -e ssh ${filename}-${date}.tar.gz some_server:/some/location/
As you can see, I like the append the timestamp to files that I backup so that I know when it was created in case I ever needed to restore.

Old 04-03-2007, 01:25 AM   #3
Registered: Nov 2003
Location: USA
Distribution: Ubuntu, Fedora
Posts: 415

Original Poster
Rep: Reputation: 31
This is wonderful twantrd! But how about the exclude-from part. I need to back up some dir from the the /Volumes/DataHD hard drive to an external HD. Actually "projects" is a directory which contain many directories that users create for their respective projects. I don't need to backup all of those directories located inside the "projects" directory. That is why I was using exclude-from. Your solution is very neat and clear, how would I include the exclude-from part? I saw you indicated "filename="projects", but projects is the directory that includes some of the directories I want to backup to the external drive(backupdrive).



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
Rsync backups gabsik Linux - General 3 11-24-2006 08:14 PM
Rsync Errors during backups shawnbishop Linux - Software 4 05-18-2006 04:26 AM
Rsync backups gabsik Linux - Networking 1 03-30-2006 11:31 AM
rsync and cp -al for staggered backups babyphil Linux - Software 2 06-14-2005 01:24 AM
Rsync for incremental backups? Phaethar Linux - Software 3 12-04-2003 02:27 PM

All times are GMT -5. The time now is 07:52 PM.

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