# GNU Health/Control Center
## About the GNU Health Control Center

The GNU Health Control Center (gnuhealth-control) is the main tool for administrative tasks of the GNU Health environment.
It can perform backups and updates of the instance, and it can be used non-interactively (e.g. as a cron job). We recommend using gnuhealth-control to perform the administrative tasks, since it also creates a log file that will be very useful in case of problems.

## Invoking gnuhealth-control

The GNU Health Control Center resides in the UTIL directory of your server.

## Backups

When using gnuhealth-control to perform backups, the application does the following tasks :
* Perform a backup of the database.
* Perform a backup of the $HOME directory of the gnuhealth user, so it stores the kernel, rc files, modules and attach directory.
To perform a backup, you call the gnuhealth-control utility with the database name and target directory where you want to store it.
GNU Health control backup command creates two files on your destination backup directory :
* The compressed database dump: The format is : backup_db-name_timestamp.gz
* The database and filesystems for GNU Health.

## Updating GNU Health with gnuhealth-control

When gnuhealth-control is invoked with the update command, it will update GNU Health components within the same major number The following components will be checked and updated if necessary:
* Trytond: Tryton server version
* Standard Tryton modules included the official GNU Health installation
* Security Advisories to be applied on the default Tryton kernel
* GNU Health patchsets (see Patches and Patchsets for more information)
This will be valid for version with the same major and minor numbers, for example 3.0.x will look for the latest Tryton updates and GNU Health updates associated to that release.

### Checking for new updates

You can check the status on your Tryton and GNU Health server by running a dry-run update. Invoking the update command with the option --dry-run will only check if your server needs to be updated, without doing any changes.

### Installing the updates

The main steps are
* Stop the instance and make a backup
* Run the kernel update with gnuhealth-control tool
* Update the database
Once you have stopped your instance, and made a full offline backup, you are ready to perform the actual update.
With the gnuhealth user, execute the following command. It will download all the Tryton and GNU Health patches, and it will reload the bash environment variables right after it.
Finally, update your database
If everything went well, you have updated to the latest Tryton and GNU Health patchset ! You can now restart the server.
You can get the latest version of GNU Health control center at GNU ftp://ftp.gnu.org/gnu/health

## Restore

GNU Health control center allows you to restore a complete GNU Health instance, including the database and the filesystem. Of course, in order to perform a restore, you need to have a backup. I will concentrate on the backup done with the GNU Health control center.
To restore a database, connect with "gnuhealth" operating system user, and change to the directory where the database backup resides.
1) Create a new database
2) Uncompress the database dump that was generated using GNU Health control
3) Restore the DB using psql