-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add script to perform LVM snapshot-based backup * Add grants files for new ispyb expeye roles * Add entry for new version 4.2.0 in HISTORY.rst * Bump version to 4.2.0 * Refresh schema files to v4.2.0
- Loading branch information
Showing
8 changed files
with
415 additions
and
235 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/usr/bin/bash | ||
|
||
# Fail on unset variables | ||
set -u | ||
|
||
# | ||
# Assumptions - adapt as needed to your environment: | ||
# | ||
# - /mnt/snapshot/ exists | ||
# - The user running the script has relevant password-less sudo permissions | ||
# - The volume group is called VolGroup00 | ||
# - The source logical volume name is called varlibmysql | ||
# - The snapshot logical volume name is called mariadb-backup | ||
|
||
# Arguments: | ||
# | ||
# 1: Path to the final destination directory | ||
# | ||
|
||
export DEST_DIR="${1:?arg not defined}" | ||
export LVM_SUPPRESS_FD_WARNINGS=1 | ||
|
||
# Make sure the destination directory exists and has a unique subdir | ||
export DEST_DIR_SUB="${DEST_DIR:?not defined}"/$(date +%Y-%m-%d_%H%M%S-%A) | ||
mkdir "${DEST_DIR_SUB:?not defined}"/ | ||
|
||
# The following lines are run from inside the mariadb client. The reason is | ||
# that the MariaDB "BACKUP STAGE" commands need to all run inside the same | ||
# connection, and the BACKUP STAGE END command needs to run after the lvcreate | ||
# command. | ||
|
||
# shellcheck disable=SC2016 | ||
mariadb -e ' | ||
-- Ensure that all non-transactional tables are properly flushed to disk before | ||
-- the snapshot is done. Using BACKUP STAGE commands is also more efficient than | ||
-- using the FLUSH TABLES WITH READ LOCK command as this set of commands | ||
-- will not block or be blocked by write operations to transactional tables. | ||
BACKUP STAGE START; | ||
BACKUP STAGE BLOCK_COMMIT; | ||
-- When using the LVM backup to set up a replication slave, we need to | ||
-- know the current replication position, so write this to a text file | ||
-- in case we need it later: | ||
system echo $(mariadb -Nse "SELECT @@global.gtid_binlog_pos") > ${DEST_DIR_SUB}/gtid_binlog_pos.txt | ||
-- Create the actual snapshot | ||
system sudo /usr/sbin/lvcreate -l100%FREE -s -n mariadb-backup /dev/VolGroup00/varlibmysql | ||
-- Complete the backup stage | ||
BACKUP STAGE END;' | ||
|
||
# Copy the snapshot to other server/disk | ||
sudo mount /dev/VolGroup00/mariadb-backup /mnt/snapshot -o nouuid -t xfs | ||
sudo cp -pr /mnt/snapshot "${DEST_DIR_SUB:?not defined}"/. | ||
|
||
# Dispose of the snapshot | ||
sudo umount /mnt/snapshot | ||
sudo /usr/sbin/lvremove --yes /dev/VolGroup00/mariadb-backup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
-- Create the Exp-eye Core API role. | ||
CREATE ROLE IF NOT EXISTS ispyb_expeye_core_role; | ||
|
||
-- You must also create a database user and grant this role to them, e.g. | ||
-- CREATE USER ispyb_expeye_core@'%' IDENTIFIED BY 'the_password'; | ||
-- GRANT ispyb_expeye_core_role to ispyb_expeye_core@'%'; | ||
-- SET DEFAULT ROLE ispyb_expeye_core_role FOR ispyb_expeye_core@'%'; | ||
|
||
GRANT ispyb_propagation TO ispyb_expeye_core_role; | ||
|
||
CREATE ROLE ispyb_expeye_acquisition_role; | ||
|
||
GRANT SELECT, INSERT, UPDATE ON RobotAction TO ispyb_expeye_acquisition_role; | ||
GRANT SELECT, INSERT, UPDATE ON GridInfo TO ispyb_expeye_acquisition_role; | ||
GRANT SELECT, INSERT, UPDATE ON DataCollection TO ispyb_expeye_acquisition_role; | ||
GRANT SELECT, INSERT, UPDATE ON DataCollectionGroup TO ispyb_expeye_acquisition_role; | ||
GRANT SELECT, INSERT, UPDATE ON Position TO ispyb_expeye_acquisition_role; | ||
GRANT ispyb_expeye_acquisition_role TO ispyb_expeye_core_role; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
-- Create the Exp-eye Samples API role. | ||
CREATE ROLE IF NOT EXISTS ispyb_expeye_samples_role; | ||
|
||
-- You must also create a database user and grant this role to them, e.g. | ||
-- CREATE USER ispyb_expeye_samples@'%' IDENTIFIED BY 'the_password'; | ||
-- GRANT ispyb_expeye_samples_role to ispyb_expeye_samples@'%'; | ||
-- SET DEFAULT ROLE ispyb_expeye_samples_role FOR ispyb_expeye_core@'%'; | ||
|
||
GRANT SELECT ON Proposal TO ispyb_expeye_samples_role; | ||
GRANT SELECT ON BLSession TO ispyb_expeye_samples_role; | ||
|
||
GRANT SELECT, INSERT, UPDATE, DELETE ON Shipping TO ispyb_expeye_samples_role; | ||
GRANT SELECT, INSERT, UPDATE, DELETE ON ShippingHasSession TO ispyb_expeye_samples_role; | ||
GRANT SELECT, INSERT, UPDATE, DELETE ON Project_has_Shipping TO ispyb_expeye_samples_role; | ||
|
||
GRANT SELECT, INSERT, UPDATE, DELETE ON LabContact TO ispyb_expeye_samples_role; | ||
|
||
GRANT SELECT, INSERT, UPDATE, DELETE ON Dewar TO ispyb_expeye_samples_role; | ||
GRANT SELECT, INSERT, UPDATE, DELETE ON DewarLocation TO ispyb_expeye_samples_role; | ||
GRANT SELECT, INSERT, UPDATE, DELETE ON DewarLocationList TO ispyb_expeye_samples_role; | ||
GRANT SELECT, INSERT, UPDATE, DELETE ON DewarRegistry TO ispyb_expeye_samples_role; | ||
GRANT SELECT, INSERT, UPDATE, DELETE ON DewarRegistry_has_Proposal TO ispyb_expeye_samples_role; | ||
GRANT SELECT, INSERT, UPDATE, DELETE ON DewarReport TO ispyb_expeye_samples_role; | ||
GRANT SELECT, INSERT, UPDATE ON DewarTransportHistory TO ispyb_expeye_samples_role; | ||
|
||
GRANT SELECT, INSERT, UPDATE, DELETE ON Container TO ispyb_expeye_samples_role; | ||
GRANT SELECT, INSERT, UPDATE, DELETE ON ContainerInspection TO ispyb_expeye_samples_role; | ||
GRANT SELECT, INSERT, UPDATE, DELETE ON ContainerQueue TO ispyb_expeye_samples_role; | ||
GRANT SELECT, INSERT, UPDATE, DELETE ON ContainerQueueSample TO ispyb_expeye_samples_role; | ||
GRANT SELECT, INSERT, UPDATE, DELETE ON ContainerRegistry TO ispyb_expeye_samples_role; | ||
GRANT SELECT, INSERT, UPDATE, DELETE ON ContainerRegistry_has_Proposal TO ispyb_expeye_samples_role; | ||
GRANT SELECT, INSERT, UPDATE, DELETE ON ContainerReport TO ispyb_expeye_samples_role; | ||
GRANT SELECT, INSERT, UPDATE, DELETE ON ContainerType TO ispyb_expeye_samples_role; | ||
GRANT SELECT, INSERT, UPDATE ON ContainerHistory TO ispyb_expeye_samples_role; | ||
|
||
GRANT SELECT ON ProcessingPipeline TO ispyb_expeye_samples_role; | ||
GRANT SELECT ON ProcessingPipelineCategory TO ispyb_expeye_samples_role; | ||
|
||
GRANT SELECT, INSERT, UPDATE, DELETE ON BLSample TO ispyb_expeye_samples_role; | ||
GRANT SELECT, INSERT, UPDATE, DELETE ON BLSampleGroup TO ispyb_expeye_samples_role; | ||
GRANT SELECT, INSERT, UPDATE, DELETE ON BLSampleGroup_has_BLSample TO ispyb_expeye_samples_role; | ||
GRANT SELECT, INSERT, UPDATE, DELETE ON BLSubSample TO ispyb_expeye_samples_role; | ||
GRANT SELECT, INSERT, UPDATE, DELETE ON Project_has_BLSample TO ispyb_expeye_samples_role; | ||
|
||
GRANT SELECT ON Protein TO ispyb_expeye_samples_role; | ||
GRANT SELECT ON Crystal TO ispyb_expeye_samples_role; | ||
|
||
GRANT SELECT, INSERT, UPDATE, DELETE ON DiffractionPlan TO ispyb_expeye_samples_role; | ||
|
||
GRANT SELECT ON ComponentType TO ispyb_expeye_samples_role; | ||
GRANT SELECT ON ComponentSubType TO ispyb_expeye_samples_role; | ||
GRANT SELECT, INSERT, UPDATE, DELETE ON Component_has_SubType TO ispyb_expeye_samples_role; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.