-
Notifications
You must be signed in to change notification settings - Fork 69
/
backup_system.sh
executable file
·68 lines (49 loc) · 1.6 KB
/
backup_system.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
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
################################################################
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
################################################################
#!/bin/sh
# Script: Bluebox Backup Script
# Author: Antonio Sangio
# Script will backup the following directories:
BACKUP_CORE="/var/lib/mysql
/opt/freeswitch/sounds/music
/var/www/html/bluebox/uploads
/opt/freeswitch/storage/
/var/log/freeswitch/cdr-csv
/opt/freeswitch/conf"
BACKUP_CONFIG=`find /var/www/html/bluebox/ -name "config" | xargs`
# Specify the directory that will hold the backup
BACKDIR="/root/backup"
# Number of Backups to Keep
KEEP="4"
##
## End Configuration
##
# Create Initial Backup
if [ ! -f $BACKDIR/backup.1.tgz ]; then
tar zcf $BACKDIR/backup.1.tgz $BACKUP_CORE $BACKUP_CONFIG >/dev/null 2>&1
chmod 600 $BACKDIR/backup.1.tgz
exit
fi
# Delete Oldest Backup
if [ -f $BACKDIR/backup.$KEEP.tgz ]; then
rm -f $BACKDIR/backup.$KEEP.tgz
fi
# Perform Backup Cycle
if [ -f $BACKDIR/backup.1.tgz ]; then
if [ -f $BACKDIR/backup.tmp.tgz ]; then
rm -f $BACKDIR/backup.tmp.tgz
fi
tar zcf $BACKDIR/backup.tmp.tgz $BACKUP_CORE $BACKUP_CONFIG >/dev/null 2>&1
chmod 600 $BACKDIR/backup.tmp.tgz
COUNT=`expr $KEEP - 1`
while [ $COUNT -gt 0 ]; do
mv -f $BACKDIR/backup.$COUNT.tgz $BACKDIR/backup.`expr
$COUNT + 1`.tgz
COUNT=`expr $COUNT - 1`
done
mv -f $BACKDIR/backup.tmp.tgz $BACKDIR/backup.1.tgz
fi
#############################################################