Last change
on this file since 249 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
|
Line | |
---|
1 | #!/bin/sh
|
---|
2 | #
|
---|
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 | #
|
---|
7 | # Rick van der Zwet <info@rickvanderzwet.nl>
|
---|
8 |
|
---|
9 | TAG=`date "+%Y%m%d.%H:%M"`
|
---|
10 |
|
---|
11 | BACKUPROOT=/usr/local/backup/config
|
---|
12 | TARGET=$BACKUPROOT/etc-$TAG.tar
|
---|
13 |
|
---|
14 | # Check for last backup file
|
---|
15 | mkdir -p $BACKUPROOT
|
---|
16 | LAST=`ls -t1 /usr/local/backup/config/etc-*.tar | head -1`
|
---|
17 |
|
---|
18 | if [ "$LAST" = "$TARGET" ]; then
|
---|
19 | echo "# Error file '$TARGET' does already exists" 1>&2
|
---|
20 | exit 1
|
---|
21 | fi
|
---|
22 |
|
---|
23 | # Create new backup file
|
---|
24 | tar -C / -cf $TARGET etc usr/local/etc 2>&1
|
---|
25 |
|
---|
26 | # If old file this exists, only keep new files if changes exists
|
---|
27 | if [ -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
|
---|
33 | fi
|
---|
Note:
See
TracBrowser
for help on using the repository browser.