Consistent replication of Linux databases

Consistent replication of Linux databases

To get consistent state of running databases on Linux, e.g. MySQL, PostgreSQL, use pre-backup and post-backup scripts, located in /usr/bin/hlragent/scripts/. These scripts are automatically called during the replication process. To flush the data, add your custom script execution before sync of unfreeze part of the script.

Scripts description:

pre_begin_backup.sh - is called before creating a snapshot
post_begin_backup.sh - is called after creating a snapshot
pre_end_backup.sh -  is called before snapshot deletion
post_end_backup.sh  - is called after replication is complete

Example:

Edit /usr/bin/hlragent/scripts/pre_begin_backup.sh to execute your custom script to flush the data forcibly before taking a snapshot:

  1. #!/usr/bin/env bash

  2. usage() {
  3.     echo "
  4.     usage: $0 --devices {devices list}
  5.     "
  6. }

  7. while [[ $# -gt 0 ]]; do
  8.     key="$1"

  9.     case $key in
  10.         --devices)
  11.             shift;
  12.             devices=("$@")
  13.             break;;
  14.         *)
  15.             usage
  16.             exit 1
  17.             ;;
  18.     esac
  19.     shift
  20. done

  21. <your_script_to_flush_db>.sh
  22. sync
  23. sleep 1