-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackup.sh
More file actions
executable file
·64 lines (60 loc) · 1.92 KB
/
Copy pathbackup.sh
File metadata and controls
executable file
·64 lines (60 loc) · 1.92 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
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
#Run this as sudo and to do so do this in advanced
#sudo chown root:root /path/to/file/backup.sh
#sudo chmod 700 /path/to/file/backup.sh
#sudo visudo
#Scroll down to %sudo ALL=(ALL:ALL) ALL
#and add under it: username ALL=(ALL) NOPASSWD: /path/to/file/backup.sh
#save and exit
if [ "$1" == "run_script" ]; then
echo "*************************************************"
echo "-------------------------------------------------"
echo "create_backup has started at $(date)"
echo "-------------------------------------------------"
PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
if ping -c 1 193.168.200.200
then
echo ""
echo "Start backup"
echo ""
#ZREP_PATH=/opt/local/bin/zrep /usr/local/sbin/zrep -S all
echo ""
echo "Backup finished at $(date)"
echo ""
else
echo ""
echo "Backupserver not found"
echo ""
fi
echo ""
echo "-------------------------------------------------"
echo ""
elif [ "$1" == "copy_autostart" ] && [ "x$2" != "x" ] && [ "x$3" != "x" ]; then
shopt -s nullglob dotglob
if [ ! -f "$3" ]; then
echo "*************************************************"
echo "-------------------------------------------------"
echo "copy_autostart has started at $(date)"
echo "-------------------------------------------------"
sudo cp $2 $3
sudo chown marcokuoni:marcokuoni $3
sudo chmod 664 $3
echo ""
echo "-------------------------------------------------"
echo ""
fi
shopt -u nullglob dotglob
elif [ "$1" == "remove_autostart" ] && [ "x$2" != "x" ]; then
shopt -s nullglob dotglob
if [ -f "$2" ]; then
echo "*************************************************"
echo "-------------------------------------------------"
echo "remove_autostart has started at $(date)"
echo "-------------------------------------------------"
sudo rm $2
echo ""
echo "-------------------------------------------------"
echo ""
fi
shopt -u nullglob dotglob
fi