This page provides example commands and scripts to help you perform backups of your server for several typical backup scenarios. These examples presume you are using Postgres. They can be customized to your needs.
In each example,
Perform a full backup of the Postgres Database
- backupFile is the file in which the backup is stored.
- dbName is the name of the database for the LabKey Server. This is normally labkey
The following command will perform a full backup of the database named dbname and store it in the file backupFile.
Perform a full backup on a Linux Server, where the Postgres Database is being run as the postgres user
pg_dump --compress=5 --format=c -f backupFile dbName
Perform full backup of your Postgres Database and all files stored in Site-level File Root (see File Terminology)
su - postgres -c '/usr/bin/pg_dump --compress=5 --format=c -f /labkey/backups/labkey_database_backup.bak labkey'
The sample Perl script lkDataBackup.pl
works on a Linux Server, but can be easily changed to work on other operating systems.
You can easily customize the script to fit your LabKey installation by changing the variables at the top of the file. To customize the script, you can change the variables:
- $labkeyHome: this is the directory where have installed the LabKey binaries. Normally /usr/local/labkey
- $labkeyFiles: this is the site-level file root. By default this located in the files subdirectory of $labkeyHome
- $labkeyBackupDir: the directory where the backup files will be stored
- $labkeyDbName: the name of the LabKey database. By default this is named labkey.
The script assumes:
- You have perl installed on your server
- You are using the PostgreSQL database and it is installed on the same computer as the LabKey server.
- PostgreSQL binaries are installed are on the path.
- See the script for more information
Error and status messages for the script are written to the log file data_backup.log
. It will be located in the backup directory.