[clug] config backups
Steven Hanley
sjh at svana.org
Tue Jun 29 04:22:06 GMT 2004
rsync to some other location, only if rsync (in verbose mode maybe) copies
any files will it have found changes.
It means you need a copy of the files elsewhere, but hey that can be on a
backup server.
You can even ask rsync to copy the old versions of changed files to a
different location to be tarred up.
See You
Steve
On Tue, Jun 29, 2004 at 02:18:27PM +1000, Kim Holburn wrote:
> Hi,
>
> 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?
>
>
> #!/bin/sh
> # backup if changed
>
> oldfile="/var/backup/etc.tgz"
>
> 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
> >/tmp/find.list.$$
> 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 '^-[^-]'
> save-it
> fi
> # rm /tmp/find.list.* /tmp/tar.list.*
> else
> save-it
> fi
>
>
> Kim
> --
> 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
> http://lists.samba.org/mailman/listinfo/linux
--
sjh at wibble.net http://svana.org/sjh
You are subtle as a window pane standing in my view
but I will wait for it to rain so that I can see you
Anticipate - Ani
More information about the linux
mailing list