-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackup_script.sh
More file actions
executable file
·29 lines (27 loc) · 972 Bytes
/
backup_script.sh
File metadata and controls
executable file
·29 lines (27 loc) · 972 Bytes
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
#!/bin/bash
EXCLUDE="--exclude-from /home/dash/Documents/backup_exclude_list.txt"
#EXCLUDE=" "
SOURCE_DIR="/mnt/media/"
DEST_DIR="/mnt/media_backup/"
OPTIONS="-hrvtC --delete --delete-excluded --size-only --stats"
DEST_MOUNT="//192.168.1.8/media_backup"
BACKUP_LOG="/home/dash/Documents/backup.log"
# h = human readable
# r = recursive
# v = verbose
# t = preserve modification times
# C = auto-ignore files in the same way CVS does
# delete = delete extraneous files from dest dirs
# delete-excluded = also delete excluded files from dest dirs
# size-only = skip files that match in size
# stats = give some file-transfer stats
if mount|grep $DEST_MOUNT; then
rsync $OPTIONS $EXCLUDE $SOURCE_DIR $DEST_DIR > $BACKUP_LOG
if [ $? = 0 ]; then
cat $BACKUP_LOG | mail -s "Server Backup Report - Successful" dash
else
cat $BACKUP_LOG | mail -s "Server Backup Report - FAILED" dash
fi
else
echo "backup not mounted" | mail -s "Server Backup Report - FAILED" dash
fi