PhenoTips » Administration Guide » Daily database backups

Daily database backups

Daily database backups

These instructions are valid for a PhenoTips server running on linux, under Tomcat, with MySQL as the database system.

Manual backups

This script can be used to create a new database backup. By default it uses the connection details configured in the running PhenoTips instance, and saves the backup in a file named data-<yyyy-mm-dd>.sql in the directory /var/lib/phenotips/backups/mysql/.

To use the script, simply download it and execute it from the server.

chmod +x

To save the data in a different directory, run:

BACKUPDIR=/path/to/directory/ ./

To save the data in a file named data.sql, without the date in the filename, pass undated as the first parameter:

./ undated

Automatic periodical backups

crontab can be used to automatically run the script at given intervals. For example, to automatically backup each day at midnight, run crontab -e and put this in the editor that shows up:

0 0 * * * $HOME/
Make sure the user running this crontab has write access to the target directory, /var/lib/phenotips/backups/mysql/
Use the proper path to the backup script, if it is not placed in the user's home directory

Rotating backups

logrotate can be used to automatically discard older backups, keeping only a few daily backups, and then increasingly rare weekly, monthly, and yearly backups. This logrotate configuration saves:

  • daily backups for a week
  • weekly backups for a month
  • monthly backups for a year
  • yearly backups for a decade

To use it, download the configuration and enable it in crontab -e

0 0 * * * $HOME/ undated ; logrotate -f $HOME/backup-phenotips.logrotate.conf
For the logrotate to work, the backup script must be executed with the undated option


PhenoTips® is freely available under the terms of the the GNU Affero General Public License, version 3.0.

 Download the latest release
 Play with our demo
 Get the source code


 Ask for free support (by volunteers):
 Inquire about commercial support:
 Follow us on twitter:

PhenoTips® is an exclusive trademark of Gene42 Inc.