aboutsummaryrefslogtreecommitdiffstats
path: root/backup
blob: 609c2827205bb3a0d755f2cc873db505ac290dc1 (plain)
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
#!/usr/bin/zsh

# rsyncs data from one mount point to another. By default all subdirectories of the src mount point are copied to the dst mount point. Nothing happens unless both arguments are valid mount points.

RSYNC_OPTS='-aP \
            --no-owner \
            --delete-during \
            --exclude="lost+found"'

if [ $# -lt 2 ]; then
    echo "Usage: backup <src> <dst>"
    exit 1
fi

if [ ! -e $1 ]; then
    echo "$1 does not exist"
    exit 1
fi

if [ ! -e $2 ]; then
    echo "$2 does not exist"
    exit 1
fi

lsblk | awk '{ print $7 }' | grep -Fx "$1" > /dev/null
if [ $? -ne 0 ]; then
    echo "$1 is not a mount point"
    exit 1
fi

lsblk | awk '{ print $7 }' | grep -Fx "$2" > /dev/null
if [ $? -ne 0 ]; then
    echo "$2 is not a mount point"
    exit 1
fi