How to find the latest backup via REST API?

Hello,

I manage to trigger a backup on TeamCity 8.1.2 through the REST API.

I now need to find the name of the latest backup through the REST API in order to copy it out of the server.

So far I didn't find a way to do that.

Is this possible? How?

Thanks.

4 comments
Comment actions Permalink

Hi Amos,

There is no special REST API request. The full backup name is returned by REST API request which triggers backup. So you can save and then use it.
Also you can find the latest created file in the <TeamCity Data Directory>/backup folder.

0
Comment actions Permalink

alina.mishina wrote:

Hi Amos,

There is no special REST API request. The full backup name is returned by REST API request which triggers backup. So you can save and then use it.
Also you can find the latest created file in the <TeamCity Data Directory>/backup folder.


That's not correct.

Here is the output I get from triggering the backup:

--2015-01-08 17:37:05--  https://teamcity/httpAuth/app/rest/server/backup?includeConfigs=true&includeDatabase=false&includeBuildLogs=true&filename=amostest   HTTP/1.1 401 Unauthorized   Cache-Control: no-cache   Cache-Control: no-store   Content-Type: text/plain;charset=UTF-8   Date: Thu, 08 Jan 2015 06:37:12 GMT   Expires: Thu, 01 Jan 1970 00:00:00 GMT   Pragma: no-cache   Server: Apache-Coyote/1.1   WWW-Authenticate: Basic realm="TeamCity"   transfer-encoding: chunked   Connection: Close Reusing existing connection to teamcity:443. --2015-01-08 17:37:06--  (try: 2)  https://teamcity/httpAuth/app/rest/server/backup?includeConfigs=true&includeDatabase=false&includeBuildLogs=true&filename=amostest   HTTP/1.1 200 OK   Cache-Control: no-cache   Cache-Control: no-store   Content-Type: text/plain   Date: Thu, 08 Jan 2015 06:37:13 GMT   Expires: Thu, 01 Jan 1970 00:00:00 GMT   Pragma: no-cache   Server: Apache-Coyote/1.1   Set-Cookie: TCSESSIONID=0D6AD6D48305502D3233154CE7052F8C; Path=/; HttpOnly   Set-Cookie: RememberMe=""; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/; HttpOnly   transfer-encoding: chunked   Connection: Close Length: unspecified [text/plain] Saving to: 'wget.out’      0K                                                         484K=0s 2015-01-08 17:37:06 (484 KB/s) - 'wget.out’ saved [4]

And here is the response body:

Idle


Can you please show me a transcript of an API call like you describe?

Thanks.

0
Comment actions Permalink

You should perform POST request. Here is the example of request:

curl -u user:password --request POST http://localhost:8111/httpAuth/app/rest/server/backup?includeConfigs=true'&'includeDatabase=true'&'fileName=testBackup

The answer is:

testBackup_20150108_141924.zip
0
Comment actions Permalink

Thanks. This one worked.

I also had to fix the "filename" parameter to "fileName" (with a capital "N").

0

Please sign in to leave a comment.