-
Notifications
You must be signed in to change notification settings - Fork 0
/
atlbackup
executable file
·69 lines (51 loc) · 2.89 KB
/
atlbackup
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
#!/bin/bash
# 백업파일을 보관하고 싶은 디렉토리를 지정합니다.
backup_dir="/var/atlassian-backup"
# 백업파일을 보관하고 싶은 기간(일)
duration=30
# 백업대상 아틀라시안 제품의 데이터 디렉토리를 지정합니다.
jira_backup_dir="/var/atlassian/application-data/jira"
confluence_backup_dir="/var/atlassian/application-data/confluence/backups"
bitbucket_backup_dir="/var/atlassian/application-data/bitbucket"
bamboo_backup_dir="/var/atlassian/application-data/backups"
# 백업대상 postgresql databases
databases="jira confluence bitbucket bamboo sonar"
dbuser="DATABASE USER"
dbpasswd="DATABASE PASSWORD"
### Backup Process for Atlassian Products ###
# tar command options
# c - create a new backup archive.
# v - verbose mode, tar will print what it's doing to the screen.
# p - preserves the permissions of the files put in the archive for restoration later.
# z - compress the backup file with 'gzip' to make it smaller.
# f <filename> - specifies where to store the backup, backup.tar.gz is the filename used in this example. It will be stored in the current working directory, the one you set when you used the cd command.
#
dateinfo=`date '+%Y-%m-%d-%H%M'`
bdate=`date '+%Y-%m-%d'`
# Jira
# 지라의 자동백업파일을 보관하는 경우는 아래 주석 해제
#today_jira_backup_file=`sudo find ${jira_backup_dir}/ -ctime 0 -name *.zip`
#/bin/cp "${today_jira_backup_file}" "$backup_dir/jira-${dateinfo}.zip"
tar -cvpzf "$backup_dir/jira-${dateinfo}.tar.gz" ${jira_backup_dir}
# Confluence
# 컨플루언스의 자동백업파일을 보관하는 경우는 아래 주석 해제
#today_confluence_backup_file=`sudo find ${confluence_backup_dir}/ -ctime 0 -name *.zip`
#/bin/cp "${today_confluence_backup_file}" "$backup_dir/confluence-${dateinfo}.zip"
tar -cvpzf "$backup_dir/confluence-${dateinfo}.tar.gz" ${confluence-$}
# Bitbucket
tar -cvpzf "$backup_dir/bitbucket-${dateinfo}.tar.gz" ${bitbucket_backup_dir}
# Bamboo
# 밤부의 자동백업파일을 보관하는 경우는 아래 주석 해제
#today_bamboo_backup_file=`sudo find ${bamboo_backup_dir}/ -ctime 0 -name *.zip`
#/bin/cp "${today_bamboo_backup_file}" "$backup_dir/bamboo-${dateinfo}.zip"
tar -cvpzf "$backup_dir/bamboo-${dateinfo}.tar.gz" ${bamboo_backup_dir}
# postgresql database backup for Atlassian Products
for i in $databases; do
/usr/bin/vacuumdb -z -U ${dbuser} $i >/dev/null 2>&1
PGPASSWORD="${dbpasswd}" pg_dump -h localhost -p 5432 -U ${dbuser} -F c -b $i -f $backup_dir/$i-db-${dateinfo}.backup
# /usr/bin/pg_dump -U ${dbuser} -F c -b $i -f $backup_dir/$i-db-${dateinfo}.backup
done
# 백업파일 보존기간이 지난 파일은 삭제
/usr/bin/find ${backup_dir} -name *.zip -mtime +${duration} -exec rm -f {} \;
/usr/bin/find ${backup_dir} -name *.gz -mtime +${duration} -exec rm -f {} \;
/usr/bin/find ${backup_dir} -name *.backup -mtime +${duration} -exec rm -f {} \;