Backup from REST API doesn't backup

I'm using the REST API in Team City 6.5 to request a backup is created as follows:

http://teamcity:8111/httpAuth/app/rest/server/backup?includeConfigs=true&includeDatabase=true&includeBuildLogs=true&fileName=filename

as specified in the documentation here:http://confluence.jetbrains.net/display/TW/REST+API+Plugin#RESTAPIPlugin-DataBackup
I've tried calling the api from both a C# application and from browsers, both locally on the server and from my machine. The problem is that it simply returns "idle", as does the backup status call and but no backup appears. I can backup fine from the web interface and I can return a list of users from the REST API without issue. The logs are empty also, other than for instances when I've intentionally used an incorrect url. I'm on a domain but the team city machine is not on the same domain.
I'm starting to suspect I'm missing something obvious but I can't find it.
Cheers

5 comments
Comment actions Permalink

I struggled with this as well.  I was finally able to get it to "work" using cURL and the following command line:

cURL.exe -v -u %USERNAME%:%PASSWORD% --url http://%SERVER%/httpAuth/app/rest/server/backup?fileName=TeamCity_Backup_%SERVER%&includeConfigs=true&includeDatabase=true&includeBuildLogs=true -d %SERVER%

I'm not convinced that triggering a TeamCity backup from a TeamCity build is the best way to accomplish this, but it seems to run without error.  :)

Additionally, I'm not terribly comfortable sending a domain username and password across the wire like this, but I haven't been able to get NTLM authentication working in cURL yet.

Hope this helps,
Bryan

0
Comment actions Permalink

Thanks for the reply Bryan,
I'm afraid that's not helped, as before the Team City API seems to have accepted the command but not really acted upon it. See below

curl -v -u ######:######--url http://######/httpAuth/app/rest/server/backup?fileName=asdsad&includeConfigs=true
&includeDatabase=true&includeBuildLogs=false -d ######
* About to connect() to ####### port ###### (#0)
*   Trying #######... connected
* Server auth using Basic with user '######'
> GET /httpAuth/app/rest/server/backup?fileName=asdsad HTTP/1.1
> Authorization: Basic ######
> User-Agent: curl/7.23.1 (x86_64-pc-win32) libcurl/7.23.1
> Host: ######
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: Apache-Coyote/1.1
< Set-Cookie: JSESSIONID=######; Path=/
< Pragma: no-cache
< Expires: Thu, 01 Jan 1970 00:00:00 GMT
< Cache-Control: no-cache
< Cache-Control: no-store
< Content-Type: text/plain
< Transfer-Encoding: chunked
< Date: Thu, 14 Jun 2012 07:48:28 GMT
<
Idle* Connection #0 to host ###### left intact
* Closing connection #0
'includeConfigs' is not recognized as an internal or external command,
operable program or batch file.
'includeDatabase' is not recognized as an internal or external command,
operable program or batch file.
'includeBuildLogs' is not recognized as an internal or external command,
operable program or batch file.




Incidentally running that command locally on the machine gives an unauthorised page. It's probably worth pointing out that though I'm on a domain, the TeamCity machine is not

0
Comment actions Permalink

In your output, it looks like a GET is being issued.  In my working script, the output indicates a POST instead.

Your cURL command looks the same as mine so I'm not sure why yours would be GETting instead of POSTing.

Which version of TeamCity are you running?

-Bryan

0
Comment actions Permalink

For the command line, try putting quotes around your URL, like the following:

curl -v -u ######:###### --url "http://######/httpAuth/app/rest/server/backup?fileName=asdsad&includeConfigs=true&includeDatabase=true&includeBuildLogs=false" -d ######



This might allow it to POST instead of GET.

-Bryan
0
Comment actions Permalink

That's exactly it, adding the quotes makes it post and the backup works fine.
Thanks a lot!

0

Please sign in to leave a comment.