-
Notifications
You must be signed in to change notification settings - Fork 2
/
backup-homedir
executable file
·74 lines (62 loc) · 2.27 KB
/
backup-homedir
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
# backup-to-usb-disk
# makes a backup of some dirs to a usb disk if present
# Copyright (C) 2014-2015 Alexander Swen <alex@swen.nu>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# starten kan met konsole --notoolbar --notabbar --nomenubar -T BACKUP --vt_sz 157x55 -e /data/scripts/backup-to-usb-disk
# of gnome-terminal --window-with-profile=HIER --hide-menubar --geometry=112x50 -t "homedir naar server" --working-directory="/home/alex" -e '/data/scripts/backup-to-usb-disk'
# Alexander Swen
# Private contact: alex@swen.nu
# CHANGELOG:
# 2009-05-27 A.Swen created.
# SETTINGS
date=$(date +%Y%m%d)
me=$(basename $0)
mydir=$(dirname $0)
netwerkmap=/netwerk/home-${LOGNAME}
dirs="~"
# FUNCTIONS
die () {
rc=$1
shift
echo "================================" >&2
echo "==== FATAL ERROR ====" >&2
echo "================================" >&2
echo "" >&2
echo $@ >&2
echo " "
echo "Er is iets mis!"
echo "Bel Alex en vertel hem de error die hierboven staat."
echo "druk op een enter om dit scherm te sluiten"
read whatever
exit $rc
}
do_sync () {
[ -z "${1}" ] && die 4 something went wrong. call admin
echo "backing up ${1}..."
echo " "
/usr/bin/rsync -zav --no-perms --no-owner --no-group "${1}/" ${netwerkmap}
echo " "
}
# SCRIPT
echo "Checking if disk is mounted..."
for dir in ${dirs};do do_sync "${dir}";done
echo " "
echo " "
echo "alles wat je hierboven ziet is gebackupped (plus alles wat al was gebackupped natuurlijk)"
echo "(er staan ook voor elke dir samenvattingen, als er geen files genoemd worden is er kennelijk"
echo "niets veranderd. niets om je zorgen over te maken dus)."
echo " "
echo "druk op een enter om dit scherm te sluiten"
read whatever
# END