LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 04-02-2007, 11:15 PM   #1
cucolin@
Member
 
Registered: Nov 2003
Location: USA
Distribution: Ubuntu, CentOS, RedHat
Posts: 416

Rep: Reputation: 31
Question backups using tar and rsync


I have this little script to make backups:

#!/bin/sh

RSYNC=/usr/local/bin/rsync



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?

Thanks
 
Old 04-03-2007, 12:05 AM   #2
twantrd
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:

Code:
#!/bin/bash

filename="projects"
backup_dir="/Volumes/DataHD/" 
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.

-twantrd
 
Old 04-03-2007, 12:25 AM   #3
cucolin@
Member
 
Registered: Nov 2003
Location: USA
Distribution: Ubuntu, CentOS, RedHat
Posts: 416

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).

Thanks!!
 
  


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

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 07:42 AM.

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