-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathbackup.sh
executable file
·39 lines (36 loc) · 1.02 KB
/
backup.sh
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
#!/bin/bash
# Original script : https://wiki.archlinux.org/index.php/Full_System_Backup_with_rsync
# Modified by : Dilawar Singh <[email protected]>
if [ $# -lt 2 ]; then
echo "No source and destination defined. Usage: $0 source destination" >&2
exit 1
elif [ $# -gt 2 ]; then
echo "Too many arguments. Usage: $0 source destination" >&2
exit 1
elif [ ! -d "$1" ]; then
echo "Invalid path: $1" >&2
exit 1
if [ ! -d "$1" ]; then
echo "Invalid path: $2" >&2
exit 1
fi
elif [ ! -w "$2" ]; then
echo "Directory not writable: $2" >&2
exit 1
fi
# Enable it if you are backing up in /media mount point.
case "$2" in
"/mnt") ;;
"/mnt/"*) ;;
"/media") ;;
"/media/"*) ;;
*) echo "Destination not allowed." >&2
exit 1
;;
esac
START=$(date +%s)
outfile=$2/"Backup_$(date '+%A,%d%B%Y,%T')"
rsync -azv --progress $1 $2 | tee $outfile
FINISH=$(date +%s)
echo "total time: $(( ($FINISH-$START) / 60 )) minutes, $(( ($FINISH-$START) % 60 )) seconds"
notify-send "Done backing up $1 to $2"