-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackup-home
More file actions
executable file
·51 lines (44 loc) · 1.33 KB
/
backup-home
File metadata and controls
executable file
·51 lines (44 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash -e
#Install directory
DIR=$(dirname $(readlink -fn $0))
cd "$DIR"
USER='mike';
HOME="$(cat /etc/passwd | grep $USER | cut -d : -f 6)";
source ./pprint
export LOGFILE='/var/log/backup.log'
if [ -e $LOGFILE ] ; then rm $LOGFILE ; fi
touch $LOGFILE
SUB="Backup Script *FAILED*"
if [[ "$UID" != "0" ]] ; then
die_mail "$SUB" "You must be root in order to use this script."
elif [ -z "$HOME" ] ; then
die_mail "$SUB" "Could not discover the user's home directory"
elif [ ! -d "$HOME" ] ; then
die_mail "$SUB" "User's home directory, \"$HOME\" is not a directory"
elif ! mount | grep -q /backup ; then
if mount /backup ; then
info_log "Mounted the /backup file system"
else
die_mail "$SUB" "The /backup file system could not be mounted"
fi
fi
cat > /tmp/exclude-list <<EOF
**/.gvfs
**/.gtk-bookmarks/.gvfs
**/.mount
**/*Cache
**/*cache
**/Trash
**/Downloads
**/Dropbox
**/test
EOF
info_log Starting backup
if ! rdiff-backup -v 6 --print-statistics --exclude-globbing-filelist /tmp/exclude-list --include $HOME --exclude '**' / /backup/ > /tmp/dump ; then
error_log "Backup failed, rdiff-backup's output:"
cat /tmp/dump >> "$LOGFILE"
die_mail "$SUB" "Backup script failed on $(date)"
else
info_log "Backup Script Succeeded"
mail_log "Backup Script Succeeded" "$(date) Backup succeeded"
fi