source: tools/etcbackup.sh@ 295

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

When script is running multiple times a day, this file names is not 'unique' enough.

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 746 bytes
RevLine 
[215]1#!/bin/sh
2#
[216]3# $Id: etcbackup.sh 236 2010-11-21 12:09:48Z 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
[236]9TAG=`date "+%Y%m%d.%H:%M"`
[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.