-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogbackup.sh
More file actions
51 lines (51 loc) · 1.33 KB
/
logbackup.sh
File metadata and controls
51 lines (51 loc) · 1.33 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
#!/bin/bash
#
# Author: norman00
# Date: 12/06/2016
#
# Description: The following script copies apache logs
# from 6pm to 9pm to a remote server
#
# Variables explanation
#
# LOG: Log name, to be copied to remote server
# IP: Remote server IP address
# LOGDIRECTORY: Local directory were apache logs reside
# TRANSFERLOG: Local file that logs transfer history and status
# U: Username to make secure copy
# STORE: Directory on remote server were logs are stored
#
# = = = = = = = = = = = = = = = = = = = = = = = = =
LOG=$(date +"%Y_%m_%d_%H".log)
IP=192.168.56.104
LOGDIRECTORY=/home/erascong/Documents/jail/3pic/logs
TRANSFERLOG=/home/erascong/Documents/jail/3pic/transfer.log
U=operator
STORE=/archive/logs/
#
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Functions
# - - - - - - - - - - - - - - - - - - - - - - - - -
#
function tap {
/usr/bin/touch $TRANSFERLOG
}
function check {
date >> $TRANSFERLOG
}
function copy {
#
# secure copies the log file and stores its output to transferlog file
#
scp $LOGDIRECTORY/$LOG $U@$IP:$STORE &>> $TRANSFERLOG
if [ $? -eq 0 ]; then
echo $LOG" Successfully saved"$'\n' >> $TRANSFERLOG
else
echo $LOG" Transfer error"$'\n' >> $TRANSFERLOG
fi
}
#
tap
check
copy
exit