?
Solved

Backup script using tar/rsync or something

Posted on 2009-12-18
8
Medium Priority
?
603 Views
Last Modified: 2013-12-01
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
Comment
Question by:syscrash
8 Comments
 
LVL 5

Expert Comment

by:valheru_m
ID: 26082742
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
 
LVL 1

Author Comment

by:syscrash
ID: 26082964
Yea, I have looked at ribs... not what I want really.
0
 
LVL 5

Expert Comment

by:valheru_m
ID: 26083029
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
NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

 
LVL 1

Author Comment

by:syscrash
ID: 26162503
Just going to use carbon copy cloner for our macs
0
 
LVL 5

Expert Comment

by:bougui
ID: 32677276
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
 
LVL 3

Accepted Solution

by:
gmckeown99 earned 1500 total points
ID: 33065564
Try backuppc.
0
 
LVL 3

Expert Comment

by:rgeers
ID: 33636729
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
 
LVL 1

Author Closing Comment

by:syscrash
ID: 33885246
I decided to use backuppc, this suggestion came after we had been using it for a month.
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft will be releasing the Windows 10 Creators Update in just a matter of weeks. Are you prepared? Follow these steps to ensure everything goes smoothly and you don't lose valuable data on your PC.
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Screencast - Getting to Know the Pipeline
Suggested Courses

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question