[clug] config backups

Antti.Roppola at brs.gov.au Antti.Roppola at brs.gov.au
Tue Jun 29 04:47:41 GMT 2004

Last month's CLUG had an interesting talk  version control
systems, including discussion of how they can be used to
keep track of things like /etc and /home. A nice part of it
is that backups are only made when content is edited.


-----Original Message-----
From: Kim Holburn [mailto:kim.holburn at anu.edu.au]
Sent: Tuesday, 29 June 2004 2:18 PM
To: CLUG List
Subject: [clug] config backups


I want to do what I thought was a simple thing to do.  I have a number 
of systems where I take a backup of the system configuration using tar 
every so often.
I want to automate the process by using a script.  What I would like to 
do is check to see if changes have been made and only backup if changes 
have been made (or every 10,000km whichever comes first).

I was testing the tar -d (--diff) option and I discovered it would do 
everything I wanted except one thing.  It doesn't check for new files 
added into directories since the tar file was created.  I guess it's 
hard for tar to know if the archive was created by pointing to a 
directory or a list of files.

Now to get what I want I have to make a list of all the files I think 
should be there and compare it with the list tar gives me.  Whew.  So 
here's my script.

Can anyone think of an easier way?

# backup if changed


save-it () {
   cd etc
   tar -czf "$oldfile" .

if tar --exclude-from /etc/tar.exclusions --wildcards  -dzf "$oldfile" 
; then
   tar -tzf "$oldfile" |sed -e 's#/$##'| sort >/tmp/tar.list.$$
   find /etc|cut -c6- | grep -v -x -F /etc/tar.exclusions | sort 
   if [ "`diff -bBU0 /tmp/find.list.$$ /tmp/tar.list.$$ |grep '^-[^-]'| 
wc -l`" -gt 0 ]; then
     echo "New file(s) found: "
     diff -bBU0 /tmp/find.list.$$ /tmp/tar.list.$$ |grep '^-[^-]'
#  rm /tmp/find.list.* /tmp/tar.list.*

Kim Holburn
IT Manager, Canberra Research Laboratory
National Information and Communication Technology Australia
Ph: +61 2 61258620 M: +61 417820641
Email: kim.holburn at anu.edu.au  - PGP Public Key on request
Aust. Spam Act: To stop receiving mail from me: reply and let me know.

Democracy imposed from without is the severest form of tyranny.
                           -- Lloyd Biggle, Jr. Analog, Apr 1961

linux mailing list
linux at lists.samba.org

More information about the linux mailing list