This repository has been archived by the owner on Jan 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 42
/
backup_diy.rb
55 lines (46 loc) · 1.52 KB
/
backup_diy.rb
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
# frozen_string_literal: true
handle_old_stash_attributes!
settings = merge_stash_settings
include_recipe 'yum-epel' if node['platform_family'] == 'rhel'
package 'jq'
package 'perl-Time-Piece' if node['platform_family'] == 'rhel'
package 'rsync'
directory node['stash']['backup_diy']['install_path'] do
owner node['stash']['user']
mode 00755
action :create
recursive true
end
git 'stash-diy-backup' do
repository node['stash']['backup_diy']['repo_url']
revision node['stash']['backup_diy']['revision']
destination node['stash']['backup_diy']['install_path']
user node['stash']['user']
end
template "#{node['stash']['backup_diy']['install_path']}/stash.diy-backup.vars.sh" do
source 'backup-diy-vars.sh.erb'
owner node['stash']['user']
mode '0600'
variables(
:backup => settings['backup'],
:backup_diy => settings['backup_diy'],
:database => settings['database']
)
end
directory node['stash']['backup']['backup_path'] do
owner node['stash']['user']
mode '0750'
action :create
recursive true
not_if { ::Dir.exist?(node['stash']['backup']['backup_path']) }
end
cron_d 'atlassian-stash-diy-backup' do
hour settings['backup']['cron']['hour']
minute settings['backup']['cron']['minute']
day settings['backup']['cron']['day']
month settings['backup']['cron']['month']
weekday settings['backup']['cron']['weekday']
command "#{node['stash']['backup_diy']['install_path']}/stash.diy-backup.sh"
user node['stash']['user']
action(settings['backup']['cron']['enable'] ? :create : :delete)
end