Last change
on this file since 362 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 |
|
---|
12 | TAG=`date "+%Y%m%d.%H:%M"`
|
---|
13 |
|
---|
14 | BACKUPROOT=/usr/backup/`hostname -s`/configbackup
|
---|
15 | TARGET=$BACKUPROOT/config-$TAG.tar
|
---|
16 |
|
---|
17 | # Check for last backup file
|
---|
18 | mkdir -p $BACKUPROOT || exit 1
|
---|
19 | LAST=`ls -t1 $BACKUPROOT/*.tar | head -1`
|
---|
20 |
|
---|
21 | if [ "$LAST" = "$TARGET" ]; then
|
---|
22 | echo "# Error file '$TARGET' does already exists" 1>&2
|
---|
23 | exit 1
|
---|
24 | fi
|
---|
25 |
|
---|
26 | # Create new backup file
|
---|
27 | tar -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
|
---|
30 | if [ -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
|
---|
36 | fi
|
---|
Note:
See
TracBrowser
for help on using the repository browser.