-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathbackup.sh
More file actions
executable file
·37 lines (35 loc) · 790 Bytes
/
backup.sh
File metadata and controls
executable file
·37 lines (35 loc) · 790 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
30
31
32
33
34
35
36
37
#!/bin/bash
if [[ $1 == 'snapshot' ]]
then
snapshot="snapshot"
else
snapshot=""
fi
currentdir=$(dirname $0)
echo "Host node server backup script (c) Pedro Amador 2011-2014"
# Determine backup period
period=''
if [ `date +%e` -le 7 ] && [ `date +%u` == 6 ]
then
# Monthly; first saturnday of month (monthday <= 6, weekday = 6)
period='monthly'
elif [ `date +%u` == 6 ]
then
# Weekly: all saturnday
period='weekly'
else
period='daily'
fi
# Get exclude list
exclude=`head -n1 $currentdir/$period.exclude 2> /dev/null`
# Exec backup script
$currentdir/_backup_period.sh $period $snapshot $exclude
resul_backup_period=$?
# Do other things
if [ $resul_backup_period == 0 ]
then
$currentdir/post_script.sh $period $snapshot $exclude
exit $?
else
exit $resul_backup_period
fi