Skip to content
This repository was archived by the owner on Nov 17, 2022. It is now read-only.

Commit

Permalink
Merge pull request #11 from alexfalkowski/arf/fix-backup-restore
Browse files Browse the repository at this point in the history
Arf/fix backup restore
  • Loading branch information
alexfalkowski committed Nov 12, 2014
2 parents dbf4aea + 1d1b5d1 commit c3ec54f
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 42 deletions.
76 changes: 38 additions & 38 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
BOXES = [
{
hostname: 'teamcity',
ip: '192.168.80.10',
ports: [8111, 5432],
role: 'server',
ram: 2048,
cpus: 2,
chef: {
json: {
'teamcity' => {
'password' => '$1$ByY03mDX$4pk9wp9bC19yB6pxSoVB81',
'server' => {
'backup' => 'file:////vagrant/tmp/TeamCity_Backup_20141024_051614.zip',
'database' => {
'username' => 'postgres',
'password' => '3175bce1d3201d16594cebf9d7eb3f9d',
'jar' => 'file:///usr/share/java/postgresql93-jdbc.jar',
'connection_url' => 'jdbc\:postgresql\:///postgres'
}
}
},
'postgresql' => {
'version' => '9.3',
'enable_pgdg_yum' => true,
'password' => {
'postgres' => '3175bce1d3201d16594cebf9d7eb3f9d'
},
'contrib' => {
'packages' => ['postgresql93-jdbc']
}
},
'java' => {
'install_flavor' => 'oracle',
'jdk_version' => 7,
'set_etc_environment' => true,
'oracle' => {
'accept_oracle_download_terms' => true
}
hostname: 'teamcity',
ip: '192.168.80.10',
ports: [8111, 5432],
role: 'server',
ram: 2048,
cpus: 2,
chef: {
json: {
'teamcity' => {
'password' => '$1$ByY03mDX$4pk9wp9bC19yB6pxSoVB81',
'server' => {
'backup' => 'file:///vagrant/tmp/TeamCity_Backup_20141106_054341.zip',
'database' => {
'username' => 'postgres',
'password' => '3175bce1d3201d16594cebf9d7eb3f9d',
'jar' => 'file:///usr/share/java/postgresql93-jdbc.jar',
'connection_url' => 'jdbc\:postgresql\:///postgres'
}
}
},
'postgresql' => {
'version' => '9.3',
'enable_pgdg_yum' => true,
'password' => {
'postgres' => '3175bce1d3201d16594cebf9d7eb3f9d'
},
run_list: %w(recipe[java] recipe[postgresql::contrib] recipe[chef-teamcity::server])
'contrib' => {
'packages' => ['postgresql93-jdbc']
}
},
'java' => {
'install_flavor' => 'oracle',
'jdk_version' => 7,
'set_etc_environment' => true,
'oracle' => {
'accept_oracle_download_terms' => true
}
}
},
run_list: %w(recipe[java] recipe[postgresql::contrib] recipe[chef-teamcity::server])
}
},
{
hostname: 'agent01',
ip: '192.168.80.11',
Expand Down
2 changes: 1 addition & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
license 'Apache 2.0'
description 'Installs/Configures TeamCity agent/server.'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.4.0'
version '0.5.0'
recipe 'chef-teamcity::server', 'Install a TeamCity server'
recipe 'chef-teamcity::agent', 'Installs a TeamCity agent'

Expand Down
18 changes: 15 additions & 3 deletions recipes/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,15 @@
not_if { ::File.exists?(TEAMCITY_PATH) }
end

[TEAMCITY_DATA_PATH, TEAMCITY_LIB_PATH, TEAMCITY_JDBC_PATH, TEAMCITY_CONFIG_PATH, TEAMCITY_BACKUP_PATH].each do |p|
paths = [
TEAMCITY_DATA_PATH,
TEAMCITY_LIB_PATH,
TEAMCITY_JDBC_PATH,
TEAMCITY_CONFIG_PATH,
TEAMCITY_BACKUP_PATH
]

paths.each do |p|
directory p do
owner TEAMCITY_USERNAME
group TEAMCITY_GROUP
Expand All @@ -89,7 +97,9 @@

if TEAMCITY_BACKUP_FILE
backup_file = ::File.basename(URI.parse(TEAMCITY_BACKUP_FILE).path).freeze
processed_backup_file = File.basename(backup_file, '.*').freeze
backup_path = ::File.join(TEAMCITY_BACKUP_PATH, backup_file).freeze
processed_backup_path = ::File.join(TEAMCITY_BACKUP_PATH, processed_backup_file).freeze
home_path = "/home/#{TEAMCITY_USERNAME}".freeze
home_database_props = ::File.join(home_path, TEAMCITY_DATABASE_PROPS_NAME).freeze

Expand All @@ -98,7 +108,7 @@
owner TEAMCITY_USERNAME
group TEAMCITY_GROUP
mode TEAMCITY_READ_MODE
not_if { ::File.exists?(backup_path) }
not_if { ::File.exists?(processed_backup_path) }
end

template home_database_props do
Expand All @@ -115,11 +125,13 @@

bash 'restore' do
user TEAMCITY_USERNAME
group TEAMCITY_GROUP
code <<-EOH
#{TEAMCITY_BIN_PATH}/maintainDB.sh restore -F #{backup_file} -A #{TEAMCITY_DATA_PATH} -T #{home_database_props}
rm -f #{backup_path}
touch #{processed_backup_path}
EOH
only_if { ::File.exists?(backup_path) }
not_if { ::File.exists?(processed_backup_path) }
end
end

Expand Down

0 comments on commit c3ec54f

Please sign in to comment.