• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 610
  • Last Modified:

Backup script using tar/rsync or something

I have been attempting to create a backup script heres what I would like to have it do..


Full weekly backup every Sunday.
Incrementals Mon-Fri

Name each backup username-date-.tar.gz(or something similar)

Remove anything older than 7 days

Heres our setup...

We have user home directories stored in /Volumes/Data/homedir all user home directories are seperated via class year IE: 2013, 2012 etc etc.

I have been messing around with scripting for the last couple of days heres what I have so far ( be easy on me I am just learning...)

#! /bin/bash



freshmen="/Volumes/Data/homedir/2013/*"
sophmore="/Volumes/Data/homedir/2012/*"
date=`date +%Y%m%d`
dow=`/bin/date +%a`
dom=`/bin/date +%d`
sophfulltarget="/Volumes/Backups/weekly/2012/"

for u in ${sophmore} ;do
     if [ "${u} in ${sophmore} and ${dow} =Thu" ]
      then
         tar czf $u-${date}.tar $u      
         mv $u-${date}.tar ${sophfulltarget}
     fi
done




0
syscrash
Asked:
syscrash
1 Solution
 
valheru_mCommented:
If you're using tarballs for your backups, it's gonna be really difficult to get good incrementals since your script wont be able to parse the file listing inside the tarball without some really heavy lifting in the script.

Rather than reinvent the wheel, I would suggest to take a look at something that's already been done and tweak it to suit your needs.  Check this out:

http://www.rustyparts.com/ribs.php

This uses rsync to and file compares the backups to the live file store and backups up the changes WHILE keping the history backups intact at the same time.  It's also got some other nifty features in it, such as emailing you a daily backup report, etc.  The only downside is that the backups wont be compressed, but the disk space difference shouldn't be back-breaking and the flexibility you gain might be more than worth the trade off.
0
 
syscrashAuthor Commented:
Yea, I have looked at ribs... not what I want really.
0
 
valheru_mCommented:
My point wasn't so much to say "You should use ribs" as it was to provide a script that already has code snippets and structure that should allow you to pick and choose the functions you want and design your own script based on it. Ribs has built in most of the functionality you want with a lot of other stuff you dont, so take the individual functions out of it and paste them into a new script that accomplishes what you're really looking for.
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
syscrashAuthor Commented:
Just going to use carbon copy cloner for our macs
0
 
bouguiCommented:
Hi would just use rsnapshot which is a wrapper to rsync and have already a daily and weekly incremantal ready to use..

If you need config examples let me know.

http://rsnapshot.org/
0
 
gmckeown99Commented:
Try backuppc.
0
 
rgeersCommented:
If you are using tar to backup, your incremental backup will be a problem, unless you create a file of the data you allready backed up. I don't have a ready solution for you, but you can create this file using the find command and md5sum. Something like find / -type f -exec md5sum \{\} \; > backedupfiles. You can parse this file any number of times and filter out the files you don´t want to backup. Now when you want to create a incremental backup you run this find command again, and take only the difference to create a new backup. Then when done you could overwrite the backedupfiles with this new file. You never need to read your tarred and zipped backupfiles this way.
0
 
syscrashAuthor Commented:
I decided to use backuppc, this suggestion came after we had been using it for a month.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now