Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to schedule automatic backups in teamcity?

Tags:

We are using Teamcity 6.5.6 professional version, which gives me the option to run a backup but I do not see any option to schedule it to a particular time.

I am not sure if this version of teamcity even supports scheduled backups. If it is not possible through teamcity GUI, I wonder if there is any other option?

Could someone please help?

Thanks.

like image 705
kranthi Avatar asked May 11 '12 09:05

kranthi


People also ask

How to take backup of TeamCity?

TeamCity allows creating a backup of TeamCity data via the Web UI. To create a backup file, navigate to the Administration | Backup page, specify backup parameters as described below, and start the backup process.

What is stored in TeamCity database?

TeamCity Data Directory TeamCity Data Directory is the directory on the file system used by the TeamCity server to store configuration, build results, and current operation files. The directory is the primary storage for all the configuration settings and holds the data critical to the TeamCity installation.


1 Answers

I wrote Powershell script for TeamCity auto backups, which you can schedule and run backup.

Here's the code:

function Execute-HTTPPostCommand() {     param(         [string] $url,         [string] $username,         [string] $password     )      $authInfo = $username + ":" + $password     $authInfo = [System.Convert]::ToBase64String([System.Text.Encoding]::Default.GetBytes($authInfo))      $webRequest = [System.Net.WebRequest]::Create($url)     $webRequest.ContentType = "text/html"     $PostStr = [System.Text.Encoding]::Default.GetBytes("")     $webrequest.ContentLength = $PostStr.Length     $webRequest.Headers["Authorization"] = "Basic " + $authInfo     $webRequest.PreAuthenticate = $true     $webRequest.Method = "POST"      $requestStream = $webRequest.GetRequestStream()     $requestStream.Write($PostStr, 0, $PostStr.length)     $requestStream.Close()      [System.Net.WebResponse] $resp = $webRequest.GetResponse();     $rs = $resp.GetResponseStream();     [System.IO.StreamReader] $sr = New-Object System.IO.StreamReader -argumentList $rs;     [string] $results = $sr.ReadToEnd();      return $results; }  function Execute-TeamCityBackup() {     param(         [string] $server,         [string] $addTimestamp,         [string] $includeConfigs,         [string] $includeDatabase,         [string] $includeBuildLogs,         [string] $includePersonalChanges,         [string] $fileName     )     $TeamCityURL = [System.String]::Format("{0}/httpAuth/app/rest/server/backup?addTimestamp={1}&includeConfigs={2}&includeDatabase={3}&includeBuildLogs={4}&includePersonalChanges={5}&fileName={6}",                                             $server,                                             $addTimestamp,                                             $includeConfigs,                                             $includeDatabase,                                             $includeBuildLogs,                                             $includePersonalChanges,                                             $fileName);      Execute-HTTPPostCommand $TeamCityURL "USER" "PASSWORD" }  $server = "http://YOUR_SERVER" $addTimestamp = $true $includeConfigs = $true $includeDatabase = $true $includeBuildLogs = $true $includePersonalChanges = $true $fileName = "TeamCity_Backup_"  Execute-TeamCityBackup $server $addTimestamp $includeConfigs $includeDatabase $includeBuildLogs $includePersonalChanges $fileName 
like image 173
Ivan Leonenko Avatar answered Oct 24 '22 17:10

Ivan Leonenko