Dears at JetBrains,

I would like to backup my TeamCity (6.5) configuration.  I use a batch to do the backup.  Batch is located in the C:\TeamCity\bin folder.  The batch stops the service (using runAll.bat), then it calls maintainDB.cmd.

SET backupfile=TeamCityBackup

SET TEAMCITY_DATA_PATH=C:\TeamCity\backup\

CALL runAll.bat stop

ECHO Script stops Service, calls maintainDB to create backup %TeamCityBackup%.zip in folder %TEAMCITY_DATA_PATH%

CALL maintainDB.cmd backup --all -F %backupfile%

Following is the ouput I am getting:

Command line arguments: backup --all -F TeamCityBackup
Using TeamCity data directory: C:\TeamCity\backup
Cannot proceed with 'backup' command: Source database not specified and not found.
Critical error has occurred during command execution.:

Best regards

Hi

TEAMCITY_DATA_PATH should point to data directory - a folder that contains config, lib, plugins, and system subfolders.

Michael

Hello Michael,

I would like for the backup to be created in a custom folder.   Documentation (http://confluence.jetbrains.net/display/TCD65/Creating+Backup+via+maintainDB+command-line+tool) states that I need to use the -A option, or set the TEAMCITY_DATA_PATH environment variable.  The error message I am getting makes perfect sense if TEAMCITY_DATA_PATH refers to the folder where TeamCity keepy its data and not to the custome location of the backup file.  The question remains: how can I make maintainDB.cmd drop the backup in a custom folder?

Best regards

You can specify custom filename with -F option.

I would like to specify the name of the file AND the folder where the file will be generated.  Setting the file name is working, what is causing trouble is setting the folder where the backup will be generated, the -A option acording to the documentation.

Ah, that's a typo in our documentation.
You can specify alternate backup location using absolute path:

MaintainDB backup -F \path\to\archive

Michael, Thank you very much for the help, it is working as expected.

I still have one more issue.  I am using a script that I call prior to the backup that:

- stops the service

- creates the backup

- restarts the service

The issue I have is that the cmd windows of the Scripts that restarts the service don't close when the service starts.  They remain open.  This would be a problem since the bakup process runs unattended.  What can I don to get the runall.bat to exit gracefully?  Following is the script I use.  It located within the bin folder of TeamCity.

SET backupfile=c:\TeamCity\backup\TeamCityBackup
CALL DEL backupfile
CALL runall stop
CALL maintainDB.cmd backup --all -F %backupfile%
CALL runall start
EXIT

Best regards

These batch scripts start TeamCity processes within your user session, not as Windows services.

Use

NET stop TeamCityNET stop TCBuildAgent

and

NET start TeamCityNET start TCBuildAgent

commands to interact with Windows service control manager directly.

Also, I see you delete current backup before creating new one, and don't think it's reliable solution.
Better choice would be to keep several backups for last days.
Yesterday's backup helps in data corruption case, but does not help with accidental project deletion.

Michael