source: tools/etcbackup.sh@ 219

Last change on this file since 219 was 216, checked in by Rick van der Zwet, 14 years ago

Por mans configuration backup

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 740 bytes
RevLine 
[215]1#!/bin/sh
2#
[216]3# $Id: etcbackup.sh 216 2010-11-06 16:38:30Z rick $
4# Poor mans configuration backup. Only save the new backup if configuration
5# content changes
6#
[215]7# Rick van der Zwet <info@rickvanderzwet.nl>
8
[216]9TAG=`date "+%Y%m%d"`
[215]10
[216]11BACKUPROOT=/usr/local/backup/config
12TARGET=$BACKUPROOT/etc-$TAG.tar
[215]13
[216]14# Check for last backup file
15mkdir -p $BACKUPROOT
16LAST=`ls -t1 /usr/local/backup/config/etc-*.tar | head -1`
17
18if [ "$LAST" = "$TARGET" ]; then
19 echo "# Error file '$TARGET' does already exists" 1>&2
20 exit 1
21fi
22
23# Create new backup file
24tar -C / -cf $TARGET etc usr/local/etc 2>&1
25
26# If old file this exists, only keep new files if changes exists
27if [ -n "$LAST" ]; then
28 PREV_MD5=`md5 -q $LAST`
29 NEW_MD5=`md5 -q $TARGET`
30 if [ "$PREV_MD5" = "$NEW_MD5" ]; then
31 rm $TARGET
32 fi
33fi
Note: See TracBrowser for help on using the repository browser.