1. Backup Script

MySQL, ElasticSearch and OpenLink Virtuoso are all dependencies of our research data management platform, Dendro. Here is how we back up the databases.

Backup Script

This script is a basic template for backing up the data of all three servers.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Create backup directory with date timestamp
##get valid timestamp for the backup directory
BACKUP_DIR=$HOME/$(date +"%Y-%m-%d_%H-%M-%S") 
###enter your mysql password here
MYSQL_PASSWORD="MYSQL_PASSWORD" 

###create timestamped backup directory in your home folder
mkdir -p $BACKUP_DIR #create backup directory

# ElasticSearch: 
mkdir -p $BACKUP_DIR/elasticsearch/nodes
sudo cp -r /var/lib/elasticsearch/elasticsearch/nodes/* $BACKUP_DIR/elasticsearch/nodes

# Virtuoso: 
mkdir -p $BACKUP_DIR/virtuoso/db
sudo cp -r /usr/local/virtuoso-opensource/var/lib/virtuoso/db/* $BACKUP_DIR/virtuoso/db 

#MySQL (backup all databases): 
mysqldump --all-databases > $BACKUP_DIR/mysqlbackup.sql -u root -p$MYSQL_PASSWORD