How to do automated backup?

I have seen a lot os posts on the subject, but no definitive answer.  How is an automated backup done through TeamCity?
Is there anyway to do incremental backups?  In our corporate environment we are forced to run daily backups to satisfy various policies and regulations.

Can someone advise the best way to approach this?

Thanks,
NSN

13 comments

Hi, I think that all you need to backup is your configuration in the data directory and the database. To backup those you can use common backup techniques. In addition you can backup customizations made to the server like plugins.

0

Hi,

you can use REST API in order to backup,
see notes one the http://confluence.jetbrains.net/display/TW/REST+API+Plugin page.

As of automatic/scheduled backup, currentlu we have no such function,
but there is an issue http://youtrack.jetbrains.net/issue/TW-6448 - you can watch/vote for it.

If REST API doesn't meet your needs, you can use TeamCity open API for backup - see
http://javadoc.jetbrains.net/teamcity/openapi/current/jetbrains/buildServer/serverSide/maintenance/BackupProcessManager.html
for the  javadoc of version 5.1. In 6.0 the backup API will contain more functions.

Feel free to write again if you have any problems with backup or open API or if you get more questions.


P.S. As of an incremental backup - currently we have no such functionality.


Best regards,
Leonid

0

Thanks.  I will take a look at the REST API.  That is basically wanted I wanted to do along with a standard incremental backup of the data directory.

0

Hi,

what kind of tool do you use to perform this http request?

The TC REST API works with HTTP basic authentication. If you're using a kind of browser - it should be automatic detected and done for you.

Best regards,
Leonid

0

I am also having trouble with this feature.
Using the format specified in the documentation, the server returns a 400 error:


[tcuser@bm03 ~]$ wget --post-data 'includeConfigs=true&includeDatabase=true&includeBuildLogs=true&fileName=testBackup.bak' http://myusername:mypassword@teamcity:8111/httpAuth/app/rest/server/backup


--15:36:02--  http://myusername:*password*@teamcity:8111/httpAuth/app/rest/server/backup
Resolving teamcity... 10.101.62.33
Connecting to teamcity|10.101.62.33|:8111... connected.
HTTP request sent, awaiting response... 400 Bad Request
15:36:02 ERROR 400: Bad Request.

0

I made it a little further and I am also getting a 400 error: bad request.
(The server returned 'Bad Request' with the status code BadRequest (400).)

I am now using C# ( System.Net.HttpWebRequest)

SERVER URL: http://SERVER:81/httpAuth/app/rest/server/backup
args:
               StringBuilder data = new StringBuilder();
                data.Append("fileName=" + HttpUtility.UrlEncode("TeamCity_Backup"));
                data.Append("&addTimestamp=" + HttpUtility.UrlEncode("true"));
                data.Append("&includeConfigs=" + HttpUtility.UrlEncode("true"));
                data.Append("&includeDatabase=" + HttpUtility.UrlEncode("true"));
                data.Append("&includeBuildLogs=" + HttpUtility.UrlEncode("false"));
                data.Append("&includePersonalChanges=" + HttpUtility.UrlEncode("false"));



Here is what I see in teamcity-rest.log

[2010-06-14 16:45:26,007]   WARN [/server/backup ] - est.jersey.ExceptionMapperUtil - Error for request http://SERVER:81/app/rest/server/backup. Sending Bad Request error in response: jetbrains.buildServer.server.rest.errors.BadRequestException: No target file name specified.

I tried a few different arguments for the fileName, but the log always seem to complain about that one.  Has anyone else got the backup to work via the REST API?

0

Charles,

Sorry for the delay in replying.

The REST API expects to get the parameters form the URL itself and not content of the POST request.

Try something like:
wget --post-data "" "http://myusername:mypassword@teamcity:8111/httpAuth/app/rest/server/backup?includeConfigs=true&includeDatabase=true&includeBuildLogs=true&fileName=testBackup.bak"

0

no spamnerd,

The server is getting request for URL "http://SERVER:81/app/rest/server/backup", while it is expected to get request for "http://SERVER:81/app/rest/server/backup?includeConfigs=true&includeDatabase=true&includeBuildLogs=true&fileName=<fileName>".

Please also see my previous comment.

0

Yegor,

Thanks for the information.  That worked for me!
I am not sure if I missed that in the documentation or just didn't understand it.

-nsn

0

BTW, I tried if any of the current build runners are capable of using the REST API to perform the backup thus automating it using TC itself but ant cannot because it doesn't have a task to perform HTTP POST out of the box (it's in the contrib but doesn't support basic authentication), and rake requires ruby to be installed, so at the moment there is no ootb way for TC to backup itself.

0

Simone,

For now I'd go with command line and curl or wget that can be committed into VCS or downloaded as artifacts.

0

Hi Yegor,

Using single quoted URL parameter got it working.

Thanks.

0

Please sign in to leave a comment.