Project

General

Profile

Backup Strategies on cwyrnd3-server » History » Version 1

chin-yeh, 07/06/2011 09:44 AM

1 1 chin-yeh
h1. Backup Strategies on cwyrnd3-server
2
3
Backup the following folder or files:
4
* /opt/**
5
* /data/**
6
* /var/ecosway
7
8
9
Frequency:
10
* run daily at 0850
11
12
13
Backup from:
14
* Server: cwyrnd3-server (IP: 192.168.2.13)
15
* User: root
16
17
Backup to:
18
* Folder: /data_bak/cwyrnd3-server
19
* Server: cwydb1 (IP: 192.168.2.68)
20
* User: support
21
* Connection Method: SCP with password-less configured
22
23
Scripts:
24
<pre>
25
#!/bin/bash
26
#
27
# Backup files to remote server.
28
#
29
# Must configure the password-less login between local and remote server.
30
#
31
32
# temp workspace
33
tmp_ws=/tmp/backup
34
35
# today's date
36
today_dt=$(date +%Y-%m-%d)
37
38
# files to be backup
39
# application, data, log and etc.
40
app_dir=/opt
41
data_dir=/data
42
log_dir=/var/ecosway
43
44
# remote backup destination
45
remote_ip=192.168.2.68
46
remote_user=support
47
remote_dest_dir=/data_bak/cwyrnd3-server
48
49
50
# compress the files
51
echo "Compressing $app_dir"
52
tar -cvzf ${tmp_ws}/${today_dt}.applications.tgz ${app_dir}
53
54
# compress data files
55
echo "Compressing $data_dir"
56
tar -cvzf ${tmp_ws}/${today_dt}.data.tgz ${data_dir}
57
58
# compress log files
59
echo "Compressing $log_dir"
60
tar -cvzf ${tmp_ws}/${today_dt}.log.tgz ${log_dir}
61
62
echo "Compression is completed."
63
64
65
# transfer files to remote server
66
echo "Transferring file(s) to $remote_ip:$remote_dest_dir"
67
scp /tmp/backup/${today_dt}*.tgz ${remote_user}@${remote_ip}:$remote_dest_dir
68
69
echo "Transfer is completed"
70
71
# remove the temp files
72
echo "Remove temp files..."
73
rm -f ${tmp_ws}/${today_dt}*
74
75
</pre>