Page MenuHomeDevCentral

Backup db-B
Open, HighPublic

Description

The following strategy can be used to backup db-B:

  1. Get a list of databases
  2. Dump and compress databases
  3. rsync to $NASQUERON_BACKUP_ROOT/databases/db-B

The first two steps can be done as easily as the script currently in /root/support/backup:

1#!/bin/sh
2
3# -------------------------------------------------------------
4# Backup MariaDB or MySQL databases
5# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
6# Project: Nasqueron
7# License: BSD-2-Clause
8# -------------------------------------------------------------
9
10set -e
11
12BACKUP_DIR=/var/backups/db
13
14# -------------------------------------------------------------
15# Ensure user is root
16#
17# Note: POSIX shells don't always define $UID or $EUID.
18# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
19
20if [ "${EUID:-$(id -u)}" -ne 0 ]; then
21 echo "This command must be run as root." >&2
22 exit 1
23fi
24
25# -------------------------------------------------------------
26# Collect information
27#
28# :: Databases to dump
29# :: Timestamp
30# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
31
32DATABASES=$(mysql -Ns -e "show databases" | grep -v -E 'information_schema|performance_schema|mysql-innodb-')
33SUBDIR=$(hostname -s)-$(date +"%s")
34
35# -------------------------------------------------------------
36# Backup
37# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
38
39mkdir "$BACKUP_DIR/$SUBDIR"
40
41for database in $DATABASES; do
42 mysqldump $database | gzip > "$BACKUP_DIR/$SUBDIR/$database.sql.gz"
43done

The rsync test can be done with keys from T2075.

Event Timeline

dereckson triaged this task as High priority.Sun, Oct 27, 00:58
dereckson created this task.
dereckson moved this task from Backlog to Services / Features on the DBA board.
dereckson moved this task from Backlog to Analysis / under discussion on the Servers board.
dereckson added a project: Backups.