source: tools/config-snapshot.sh@ 364

Last change on this file since 364 was 344, checked in by Rick van der Zwet, 13 years ago

Avoid potential directory disaster.

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