Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add Backup documentation) #4363

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/molgenis/run.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ MOLGENIS EMX2 can be run via
* [cloud deploy on kubernetes + helm](run_helm.md)
* [by compiling the source code (for developers)](run_source.md)
* [OIDC integration](use_permissions.md)
* [Backup](run_backup.md)
53 changes: 53 additions & 0 deletions docs/molgenis/run_backup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Backups


Currently all data is stored in postgresql. In order to guarantee fast recovery after a hardware or software failure, we suggest to make daily backups.

## Backing up the database

Postgres comes with a variety of methods to backup and restore the state of your database.
The ideal tool for handling backups of your database is the the 'pg_dump' utility which comes with PostgreSQL.
We recommend setting up a cron job to do a pg_dump of your database every night


## Example

Script below is making daily backups (max of 14 days) in the /var/molenis-backup folder.
You could use this script as a [cron.daily](https://en.wikipedia.org/wiki/Cron) script.


```
####
#
# Molgenis EMX2 local PGSQL backup.
# - pgsql backups on local server for local backup en restore usage
#
# Restore can be done by:
# su - postgres -c "zstdcat /var/molgenis-backup/posgresql-<<date>>.sql.zst | /usr/bin/psql"
###

USER="molgenis"

# Days to keep (minimal 4 for weekend overlap) increase for your setup
KEEP_DAYS=14

BACKUP_DIR="/var/molgenis-backup/"
CURRENT_DATE=$(date "+%d%m%Y")

if [ ! -d $BACKUP_DIR ]
then
mkdir -p $BACKUP_DIR
mkdir -p $BACKUP_DIR/TMP
chgrp $USER $BACKUP_DIR
fi

# Cleanup Old backups
find $BACKUP_DIR/* -mtime +${KEEP_DAYS} -exec rm {} \;

# backup
sudo -u postgres pg_dump molgenis | zstd >> ${BACKUP_DIR}/postgresql-"${CURRENT_DATE}".sql.zst


```