diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100755 index 00000000000..a18485abdbb --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,39 @@ +#------------------------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. +#------------------------------------------------------------------------------------------------------------- + +# To fully customize the contents of this image, use the following Dockerfile instead: +# https://github.com/microsoft/vscode-dev-containers/blob/master/containers/python-3/.devcontainer/Dockerfile + +# [Choice] Python version: 3, 3.8, 3.7, 3.6 +ARG VARIANT=3 +FROM mcr.microsoft.com/vscode/devcontainers/python:${VARIANT} + +# [Option] Install Node.js +ARG INSTALL_NODE="true" +ARG NODE_VERSION="lts/*" +RUN if [ "${INSTALL_NODE}" = "true" ]; then su vscode -c "source /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi + +# [Optional] If your pip requirements rarely change, uncomment this section to add them to the image. +# COPY requirements.txt /tmp/pip-tmp/ +# RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \ +# && rm -rf /tmp/pip-tmp + +# [Optional] Uncomment this section to install additional OS packages. +# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ +# && apt-get -y install --no-install-recommends + +# latest gatsby, yarn +RUN su vscode -c "source /usr/local/share/nvm/nvm.sh \ + && npm install -g gatsby-cli \ + && npm install -g yarn" 2>&1 + +# Enable docker-in-docker (see: https://github.com/microsoft/vscode-dev-containers/blob/master/script-library/docs/docker-in-docker.md) +COPY library-scripts/*.sh /tmp/library-scripts/ +RUN wget -O- https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \ + && apt-get update \ + && /bin/bash /tmp/library-scripts/docker-in-docker-debian.sh +ENTRYPOINT ["/usr/local/share/docker-init.sh"] +VOLUME [ "/var/lib/docker" ] +CMD ["sleep", "infinity"] diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100755 index 00000000000..0217cb1f24d --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,33 @@ +// For format details, see https://aka.ms/vscode-remote/devcontainer.json +{ + "name": "EDB Docs w/ Python 3 and Node.js 14", + "dockerFile": "Dockerfile", + + // Set *default* container specific settings.json values on container create. + "settings": { + "terminal.integrated.shell.linux": "/bin/bash" + }, + + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "dbaeumer.vscode-eslint", + "ms-azuretools.vscode-docker", + "eamodio.gitlens", + "github.vscode-pull-request-github" + ], + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [8000], + "appPort": [8000], + + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "yarn install && git submodule update --init", + + // docker in docker (https://github.com/microsoft/vscode-dev-containers/blob/master/script-library/docs/docker-in-docker.md) + "runArgs": ["--init", "--privileged"], + "overrideCommand": false + + // Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root. + // "remoteUser": "node" +} + diff --git a/.devcontainer/library-scripts/docker-in-docker-debian.sh b/.devcontainer/library-scripts/docker-in-docker-debian.sh new file mode 100644 index 00000000000..40c7a695482 --- /dev/null +++ b/.devcontainer/library-scripts/docker-in-docker-debian.sh @@ -0,0 +1,186 @@ +#!/usr/bin/env bash +#------------------------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. +#------------------------------------------------------------------------------------------------------------- +# +# Docs: https://github.com/microsoft/vscode-dev-containers/blob/master/script-library/docs/docker-in-docker.md +# Maintainer: The VS Code and Codespaces Teams +# +# Syntax: ./docker-in-docker-debian.sh [enable non-root docker access flag] [non-root user] [use moby] + +ENABLE_NONROOT_DOCKER=${1:-"true"} +USERNAME=${2:-"automatic"} +USE_MOBY=${3:-"true"} + +set -e + +if [ "$(id -u)" -ne 0 ]; then + echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' + exit 1 +fi + +# Determine the appropriate non-root user +if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then + USERNAME="" + POSSIBLE_USERS=("vscode" "node" "codespace" "$(awk -v val=1000 -F ":" '$3==val{print $1}' /etc/passwd)") + for CURRENT_USER in ${POSSIBLE_USERS[@]}; do + if id -u ${CURRENT_USER} > /dev/null 2>&1; then + USERNAME=${CURRENT_USER} + break + fi + done + if [ "${USERNAME}" = "" ]; then + USERNAME=root + fi +elif [ "${USERNAME}" = "none" ] || ! id -u ${USERNAME} > /dev/null 2>&1; then + USERNAME=root +fi + +# Function to run apt-get if needed +apt-get-update-if-needed() +{ + if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then + echo "Running apt-get update..." + apt-get update + else + echo "Skipping apt-get update." + fi +} + +# Ensure apt is in non-interactive to avoid prompts +export DEBIAN_FRONTEND=noninteractive + +# Install docker/dockerd dependencies if missing +if ! dpkg -s apt-transport-https curl ca-certificates lsb-release lxc pigz iptables > /dev/null 2>&1 || ! type gpg > /dev/null 2>&1; then + apt-get-update-if-needed + apt-get -y install --no-install-recommends apt-transport-https curl ca-certificates lsb-release lxc pigz iptables gnupg2 +fi + +# Swap to legacy iptables for compatibility +update-alternatives --set iptables /usr/sbin/iptables-legacy +update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy + +# Install Docker / Moby CLI if not already installed +if type docker > /dev/null 2>&1 && type dockerd > /dev/null 2>&1; then + echo "Docker / Moby CLI and Engine already installed." +else + if [ "${USE_MOBY}" = "true" ]; then + DISTRO=$(lsb_release -is | tr '[:upper:]' '[:lower:]') + CODENAME=$(lsb_release -cs) + curl -s https://packages.microsoft.com/keys/microsoft.asc | (OUT=$(apt-key add - 2>&1) || echo $OUT) + echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-${DISTRO}-${CODENAME}-prod ${CODENAME} main" > /etc/apt/sources.list.d/microsoft.list + apt-get update + apt-get -y install --no-install-recommends moby-cli moby-engine + else + curl -fsSL https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/gpg | (OUT=$(apt-key add - 2>&1) || echo $OUT) + echo "deb [arch=amd64] https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]') $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list + apt-get update + apt-get -y install --no-install-recommends docker-ce-cli docker-ce + fi +fi + +echo "Finished installing docker / moby" + +# Install Docker Compose if not already installed +if type docker-compose > /dev/null 2>&1; then + echo "Docker Compose already installed." +else + LATEST_COMPOSE_VERSION=$(curl -sSL "https://api.github.com/repos/docker/compose/releases/latest" | grep -o -P '(?<="tag_name": ").+(?=")') + curl -sSL "https://github.com/docker/compose/releases/download/${LATEST_COMPOSE_VERSION}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose + chmod +x /usr/local/bin/docker-compose +fi + +# If init file already exists, exit +if [ -f "/usr/local/share/docker-init.sh" ]; then + echo "/usr/local/share/docker-init.sh already exists, so exiting." + exit 0 +fi +echo "docker-init doesnt exist..." + +# Add user to the docker group +if [ "${ENABLE_NONROOT_DOCKER}" = "true" ]; then + if ! getent group docker > /dev/null 2>&1; then + groupadd docker + fi + usermod -aG docker ${USERNAME} +fi + +tee /usr/local/share/docker-init.sh > /dev/null \ +<< 'EOF' +#!/usr/bin/env bash +#------------------------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. +#------------------------------------------------------------------------------------------------------------- + +sudoIf() +{ + if [ "$(id -u)" -ne 0 ]; then + sudo "$@" + else + "$@" + fi +} + +# explicitly remove dockerd and containerd PID file to ensure that it can start properly if it was stopped uncleanly +# ie: docker kill +sudoIf find /run /var/run -iname 'docker*.pid' -delete || : +sudoIf find /run /var/run -iname 'container*.pid' -delete || : + +set -e + +## Dind wrapper script from docker team +# Maintained: https://github.com/moby/moby/blob/master/hack/dind + +export container=docker + +if [ -d /sys/kernel/security ] && ! sudoIf mountpoint -q /sys/kernel/security; then + sudoIf mount -t securityfs none /sys/kernel/security || { + echo >&2 'Could not mount /sys/kernel/security.' + echo >&2 'AppArmor detection and --privileged mode might break.' + } +fi + +# Mount /tmp (conditionally) +if ! sudoIf mountpoint -q /tmp; then + sudoIf mount -t tmpfs none /tmp +fi + +# cgroup v2: enable nesting +if [ -f /sys/fs/cgroup/cgroup.controllers ]; then + # move the init process (PID 1) from the root group to the /init group, + # otherwise writing subtree_control fails with EBUSY. + sudoIf mkdir -p /sys/fs/cgroup/init + sudoIf echo 1 > /sys/fs/cgroup/init/cgroup.procs + # enable controllers + sudoIf sed -e 's/ / +/g' -e 's/^/+/' < /sys/fs/cgroup/cgroup.controllers \ + > /sys/fs/cgroup/cgroup.subtree_control +fi +## Dind wrapper over. + +# Handle DNS +set +e +cat /etc/resolv.conf | grep -i 'internal.cloudapp.net' +if [ $? -eq 0 ] +then + echo "Setting dockerd Azure DNS." + CUSTOMDNS="--dns 168.63.129.16" +else + echo "Not setting dockerd DNS manually." + CUSTOMDNS="" +fi +set -e + +# Start docker/moby engine +( sudoIf dockerd $CUSTOMDNS > /tmp/dockerd.log 2>&1 ) & + +set +e + +# Execute whatever commands were passed in (if any). This allows us +# to set this script to ENTRYPOINT while still executing the default CMD. +exec "$@" +EOF + +chmod +x /usr/local/share/docker-init.sh +chown ${USERNAME}:root /usr/local/share/docker-init.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000000..72e8ffc0db8 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +* diff --git a/.github/ISSUE_TEMPLATE/problem-with-topic.md b/.github/ISSUE_TEMPLATE/problem-with-topic.md new file mode 100644 index 00000000000..b5d95a52cdd --- /dev/null +++ b/.github/ISSUE_TEMPLATE/problem-with-topic.md @@ -0,0 +1,27 @@ +--- +name: Problem with a topic +about: Report a problem you've observed while reading a topic +title: 'Problem on (PUT PAGE PATH / URL / TITLE HERE)' +labels: '' +assignees: '' + +--- + +## Summary +A short description of the problem you observed. Ex: "Code sample fails with error", "Link is broken" + +## Where did you see the problem? + +Describe the location within the text, ex: "in the section titled 'Further reading', the 2nd link doesn't load" + +## Expected behavior +Describe what you expected, changes you'd like to see, etc. + +## Screenshots +If applicable, paste / upload screenshots to illustrate the problem you saw + +## Browser / Platform +Include the name of the browser and operating system you were using, along with versions + +## Additional notes +Anything else you'd like to add that might help us to fix the problem diff --git a/.github/ISSUE_TEMPLATE/propose-new-topic.md b/.github/ISSUE_TEMPLATE/propose-new-topic.md new file mode 100644 index 00000000000..6510c4332fb --- /dev/null +++ b/.github/ISSUE_TEMPLATE/propose-new-topic.md @@ -0,0 +1,20 @@ +--- +name: Propose a new topic +about: Suggest the addition of a new page or section +title: '' +labels: 'enhancement' +assignees: '' + +--- + +## Summary +A short description of what you'd like to see covered + +## Background info + +What do you already know about the topic? What would you like to learn? What sort of things will this information help you to do? + +(If you're proposing this topic because you think it would benefit *someone else*, then summarize *their* background knowledge and needs) + +## Additional notes +Anything else you'd like to add that might help us to fix the problem diff --git a/.github/ISSUE_TEMPLATE/suggest-addition-to-topic.md b/.github/ISSUE_TEMPLATE/suggest-addition-to-topic.md new file mode 100644 index 00000000000..b78246a02ac --- /dev/null +++ b/.github/ISSUE_TEMPLATE/suggest-addition-to-topic.md @@ -0,0 +1,19 @@ +--- +name: Suggest an addition +about: Suggest an improvement to a topic +title: 'Idea for (PUT PAGE PATH / URL / TITLE HERE)' +labels: 'enhancement' +assignees: '' + +--- + +## Summary +A short description of what you'd like to see. Ex: "An example using a Lateral Join would be nice" + +## Where would you like to see this added? + +Describe the location within the page's text that would be improved by addition (if relevant). + +## Rationale +Why you'd like to see this addition. Be detailed! Ex: "Results currently require post-processing to bring in contextual info; the use of a lateral join to perform this step would simplify the example while demonstrating a pure-SQL solution" + diff --git a/.github/ISSUE_TEMPLATE/typo-or-minor-flaw.md b/.github/ISSUE_TEMPLATE/typo-or-minor-flaw.md new file mode 100644 index 00000000000..6a3a8b95df9 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/typo-or-minor-flaw.md @@ -0,0 +1,10 @@ +--- +name: There is a typo (or minor mistake) +about: Report a small problem you've observed while reading a topic +title: 'Problem on (PUT PAGE PATH / URL / TITLE HERE)' +labels: '' +assignees: '' + +--- + +Please write a short description of the problem you observed. Ex: "thier is a misspelling", "https://grogle.com/search is broken" diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 00000000000..6790a75e768 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,17 @@ +## What Changed? + +Please list, at a high level, what changed in your branch. If you changed content, include the product, guide, and version as applicable. + +**Examples** +- Fixed typo in EPAS 13 epas_inst_linux guide +- Added more detail to ARK 3.5 getting started guide introduction +- Fixed broken link on `/supported-open-source/pgbackrest/05-retention_policy/` page + +## Checklist + +Please check all boxes that apply (`[ ]` is unchecked, `[x]` is checked) + +**Content** +- [ ] This PR adds new content +- [ ] This PR changes existing content +- [ ] This PR removes existing content diff --git a/.github/workflows/deploy-develop.yml b/.github/workflows/deploy-develop.yml new file mode 100644 index 00000000000..23dfe120095 --- /dev/null +++ b/.github/workflows/deploy-develop.yml @@ -0,0 +1,66 @@ +name: Deploy Develop to Netlify +on: + push: + branches: + - develop +jobs: + build-deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + ref: develop + fetch-depth: 0 # fetch whole repo so git-restore-mtime can work + - name: Update submodules + run: git submodule update --init --remote + - name: Adjust file watchers limit + run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p + + - uses: actions/setup-node@v1 + with: + node-version: '14.x' + - name: Install yarn + run: sudo npm -g install yarn + - name: Yarn install + run: yarn install --immutable + env: + NODE_ENV: ${{ secrets.NODE_ENV }} + + - name: Checking Gatsby cache + id: gatsby-cache-build + uses: actions/cache@v2 + with: + path: | + public + .cache + key: ${{ runner.os }}-gatsby-build-develop-${{ github.run_id }} + restore-keys: | + ${{ runner.os }}-gatsby-build-develop- + + - name: Fix mtimes + run: yarn fix-mtimes --force + - name: Gatsby build + run: yarn build + env: + APP_ENV: staging + NODE_ENV: ${{ secrets.NODE_ENV }} + NODE_OPTIONS: --max-old-space-size=4096 + ALGOLIA_API_KEY: ${{ secrets.ALGOLIA_API_KEY }} + ALGOLIA_APP_ID: ${{ secrets.ALGOLIA_APP_ID }} + ALGOLIA_INDEX_NAME: edb-docs-staging + INDEX_ON_BUILD: true + + - name: Netlify deploy + run: | + sudo yarn global add netlify-cli + netlify deploy --dir=public --prod + env: + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} + NETLIFY_SITE_ID: ${{ secrets.NETLIFY_DEVELOP_SITE_ID }} + + - uses: act10ns/slack@v1 + with: + status: ${{ job.status }} + if: failure() + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} diff --git a/.github/workflows/deploy-main.yml b/.github/workflows/deploy-main.yml new file mode 100644 index 00000000000..a71d90cd432 --- /dev/null +++ b/.github/workflows/deploy-main.yml @@ -0,0 +1,67 @@ +name: Deploy Main to Netlify +on: + push: + branches: + - main +jobs: + build-deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + ref: main + fetch-depth: 0 # fetch whole repo so git-restore-mtime can work + - name: Update submodules + run: git submodule update --init --remote + - name: Adjust file watchers limit + run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p + + - uses: actions/setup-node@v1 + with: + node-version: '14.x' + - name: Install yarn + run: sudo npm -g install yarn + - name: Yarn install + run: yarn install --immutable + env: + NODE_ENV: ${{ secrets.NODE_ENV }} + + - name: Checking Gatsby cache + id: gatsby-cache-build + uses: actions/cache@v2 + with: + path: | + public + .cache + key: ${{ runner.os }}-gatsby-build-main-${{ github.run_id }} + restore-keys: | + ${{ runner.os }}-gatsby-build-main- + + - name: Fix mtimes + run: yarn fix-mtimes --force + - name: Gatsby build + run: yarn build + env: + APP_ENV: production + NODE_ENV: ${{ secrets.NODE_ENV }} + NODE_OPTIONS: --max-old-space-size=4096 + ALGOLIA_API_KEY: ${{ secrets.ALGOLIA_API_KEY }} + ALGOLIA_APP_ID: ${{ secrets.ALGOLIA_APP_ID }} + ALGOLIA_INDEX_NAME: edb-docs + GTM_ID: GTM-5W8M67 + INDEX_ON_BUILD: true + + - name: Netlify deploy + run: | + sudo yarn global add netlify-cli + netlify deploy --dir=public --prod + env: + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} + NETLIFY_SITE_ID: ${{ secrets.NETLIFY_MAIN_SITE_ID }} + + - uses: act10ns/slack@v1 + with: + status: ${{ job.status }} + if: always() + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} diff --git a/.github/workflows/update-pdfs-on-develop.yml b/.github/workflows/update-pdfs-on-develop.yml new file mode 100644 index 00000000000..aa50ae4db49 --- /dev/null +++ b/.github/workflows/update-pdfs-on-develop.yml @@ -0,0 +1,53 @@ +name: Update PDFs on Develop +on: + push: + branches: + - develop + paths: + - product_docs/docs/**.mdx + - scripts/pdf/generate_pdf.py + - .github/workflows/update-pdfs-on-develop.yml +jobs: + build-pdfs: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + with: + ref: develop + ssh-key: ${{ secrets.ADMIN_SECRET_SSH_KEY }} + - name: Update submodules + run: git submodule update --init --remote + + - uses: actions/setup-node@v1 + with: + node-version: '14.x' + - uses: actions/setup-python@v2 + with: + python-version: '3.x' + - uses: r-lib/actions/setup-pandoc@v1 + with: + pandoc-version: '2.10.1' + - name: Install wkhtmltopdf + run: | + curl -L https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.focal_amd64.deb > wkhtmltopdf.deb + sudo apt-get install ./wkhtmltopdf.deb + + - name: Build all pdfs + run: npm run build-all-pdfs-ci + + - run: git status + - run: git pull + - name: Commit pdfs to develop + run: | + git config user.name josh-heyer + git config user.email josh.heyer@enterprisedb.com + git add *.pdf + git commit -m "New PDFs generated by Github Actions" + git push + + - uses: act10ns/slack@v1 + with: + status: ${{ job.status }} + if: failure() + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000000..2df3774fd5b --- /dev/null +++ b/.gitignore @@ -0,0 +1,82 @@ +# yarn is preferred for us (and heroku) +package-lock.json + +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Typescript v1 declaration files +typings/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# dotenv environment variables file +.env* + +# gatsby files +.cache/ +public + +# Mac files +.DS_Store + +# Yarn +yarn-error.log +.pnp/ +.pnp.js +# Yarn Integrity file +.yarn-integrity + +__pycache__ + +# Project specific +dev-sources.json +product_docs/content/ +product_docs/content_build/ +static/nginx_redirects.generated +temp_kubernetes/ +advocacy_docs/kubernetes/cloud_native_postgresql/*.md.in diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000000..3dc7cbadc26 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "static/edb-icons"] + path = static/edb-icons + url = https://edb-submodule-user:nMGifi48LiyofYrYkpjx78Bj7hQUWQXER494dyfHTDEx9UiMnK7WpovFVMpBJBxG@github.com/rocketinsights/edb-icons diff --git a/.husky/.gitignore b/.husky/.gitignore new file mode 100644 index 00000000000..31354ec1389 --- /dev/null +++ b/.husky/.gitignore @@ -0,0 +1 @@ +_ diff --git a/.husky/_/husky.sh b/.husky/_/husky.sh new file mode 100644 index 00000000000..ca2720e08aa --- /dev/null +++ b/.husky/_/husky.sh @@ -0,0 +1,30 @@ +#!/bin/sh +if [ -z "$husky_skip_init" ]; then + debug () { + [ "$HUSKY_DEBUG" = "1" ] && echo "husky (debug) - $1" + } + + readonly hook_name="$(basename "$0")" + debug "starting $hook_name..." + + if [ "$HUSKY" = "0" ]; then + debug "HUSKY env variable is set to 0, skipping hook" + exit 0 + fi + + if [ -f ~/.huskyrc ]; then + debug "sourcing ~/.huskyrc" + . ~/.huskyrc + fi + + export readonly husky_skip_init=1 + sh -e "$0" "$@" + exitCode="$?" + + if [ $exitCode != 0 ]; then + echo "husky - $hook_name hook exited with code $exitCode (error)" + exit $exitCode + fi + + exit 0 +fi diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 00000000000..470f973fd60 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +yarn pretty-quick --staged --pattern 'src/**/*.js' --pattern 'gatsby-*.js' diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 00000000000..b009dfb9d9f --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +lts/* diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 00000000000..a20502b7f06 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,4 @@ +{ + "singleQuote": true, + "trailingComma": "all" +} diff --git a/.slugignore b/.slugignore new file mode 100644 index 00000000000..a920d567f19 --- /dev/null +++ b/.slugignore @@ -0,0 +1 @@ +/product_docs diff --git a/.storybook/main.js b/.storybook/main.js new file mode 100644 index 00000000000..3036098563c --- /dev/null +++ b/.storybook/main.js @@ -0,0 +1,4 @@ +module.exports = { + stories: ['../stories/**/*.stories.js'], + addons: ['@storybook/addon-actions', '@storybook/addon-links'], +}; diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000000..e938ebd3ea3 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "python.linting.pylintEnabled": true, + "python.linting.enabled": true, + "cSpell.enableFiletypes": [ + "mdx" + ] +} \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000000..261eeb9e9f8 --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md index e1b055fc6be..7a2a0bdda05 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,201 @@ -## Setup -1. This project uses `nvm` to manage the node version. You should install the correct node version with `nvm install`. -2. Install yarn and gatsby with `npm i -g gatsby-cli` and `npm i -g yarn` -3. Install all the bits and bobs with `yarn` -4. Run the site locally with `gatsby develop` +EDB Docs -## Deployment -Deploy the site to GH Pages with `yarn run deploy` +![Deploy Main to Netlify](https://github.com/EnterpriseDB/docs/workflows/Deploy%20Main%20to%20Netlify/badge.svg) +![Deploy Develop to Netlify](https://github.com/EnterpriseDB/docs/workflows/Deploy%20Develop%20to%20Netlify/badge.svg) +![Update PDFs on Develop](https://github.com/EnterpriseDB/docs/workflows/Update%20PDFs%20on%20Develop/badge.svg) -## Migrating RST files -To migrate RST files, place the folder in a new `content` folder and run this script in the terminal -`for i in content/**/*.rst ; do python3 scripts/pre_pandoc_script.py ${i%}; echo "$i" && pandoc --wrap=none $i -f rst -t gfm -o ${i%.*}.mdx ; done ; python3 scripts/post_pandoc_script.py` +This repo contains the React/Gatsby application that powers the EDB Docs website. The site pulls [Markdown](https://www.markdownguide.org/) content from several repos in a process called "sourcing", and then renders it all into high-performance markup. You can install the application on your local computer for easy editing, viewing, and eventually publishing to the GitHub repo. -The results will show up in the `content_build` folder. These can then be moved to the `docs` folder. +## MacOS Installation -The folder structure in docs is `{product}/{version number}/{content folder}`. If there is no version involved, just make it "1" -# edb_docs_advocacy +We recommend using MacOS to work with the EDB Docs application. + +1. Install [Homebrew](https://brew.sh/), if it's not already installed. (Use `brew -v` to check.) + +1. Install Git using Homebrew with `brew install git`, if it's not already installed. (Use `git --version` to check.) + +1. Set up an SSH key in GitHub, if you haven't done so already. (Go to [GitHub's SSH Keys page](https://github.com/settings/keys) to check.) If you don't have an SSH Key set up yet, you'll need to set one up to authenticate you to GitHub. See [GitHub's SSH docs](https://docs.github.com/en/github-ae@latest/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent) for more information. + +1. Clone the [EDB Docs GitHub repo](https://github.com/EnterpriseDB/docs) to your local machine using [GitHub Desktop](https://desktop.github.com/), or via the Terminal with `git clone https://github.com/EnterpriseDB/docs.git` + +1. Navigate to the cloned repo directory in your Terminal, if you haven't already done so. + +1. Install [Node.js version 14 LTS](https://nodejs.org/en/download/). We recommend using Node version 14 LTS (the Long Term Support release) as version 15 is not compatible with some of our dependencies at this time. + + - If you already have Node installed, you can verify your version by running `node -v` in the cloned repo directory. + + - If you already have a different version of Node installed, you may want to consider using Node Version Manager (NVM) for a simpler way to manage multiple versions of Node.js. Follow the [directions to install NVM](https://github.com/nvm-sh/nvm#installing-and-updating), then run `nvm install` in the cloned repo directory, followed by `nvm use` which will auto-detect the correct version of Node.js to use (currently 14 LTS). + +1. Install Python 3 with `brew install python3`, if it's not already installed. (Use `python3 -V` to check that you have version 3.6 or higher.) Python is not needed for the core Gatsby system, but is required by several source scripts. + +1. Install Yarn with `npm i -g yarn`. Yarn is the package manager we're using for this project, instead of NPM. NPM may fail with a permissions related issue. To fix that, ensure that your user account owns the required directory: `sudo chown -R $(whoami) /usr/local/lib/node_modules` + +1. Install Gatsby with `npm i -g gatsby-cli`. Gatsby is the software that powers the EDB Docs site. + +1. Install all required packages by running `yarn`. + +1. Pull the shared icon files down with `git submodule update --init`. This needs to be run inside of the project folder, if you have cloned the repo using GitHub Desktop, ensure that you have `cd` into the project. + +1. And finally, you can start up the site locally with `yarn develop`, which should make it live at `http://localhost:8000/`. Huzzah! + +### Installation of PDF / Doc Conversion Tools (optional) + +If you need to build PDFs locally, you'll need to install Docker via Homebrew: `brew install docker`. + +If you need to run parts of the RST to MDX conversion pipeline, you'll need to install `pandoc`, a general purpose document conversion tool. This can also be installed with homebrew - `brew install pandoc`. + +## Windows Installation + +If you are a Windows user, you can work with Docs without installing it locally by using a Docker container and VSCode. See [Working on Docs in a Docker container using VSCode](README_DOCKER_VSCODE.md) + + +## Sources + +- Advocacy (`/advocacy_docs`, always loaded) + +- EDB Product Docs (`/product_docs`) + + - For a list of these sources, see [product_docs/docs](https://github.com/EnterpriseDB/docs/tree/develop/product_docs/docs) + +### Configuring Which Sources are Loaded + +By default, all document sources will be loaded into the app during development. It's possible to set up a configuration file, `dev-sources.json`, to only load specific sources, but this is not required. + +#### `yarn config-sources` + +Run `yarn config-sources` to setup your `dev-sources.json` file. This file tells Gatsby which sources to load. The script is interactive! + +Alternatively, you can setup your `dev-sources.json` file manually by copying `dev-sources.sample` to `dev-sources.json`, and editing as desired. The sample file will source everything by default. + +### Types of Sources + +**Advocacy Docs** are tutorial content, getting-started material, and anything that is about a subject matter area, but not explicitly tied to a product version. + +**Product Docs** are versioned documentation for products. They follow a slightly stricter file structure to allow for version switching and other features. + +More details can be found on the [Adding New Sources](README_ADDING_NEW_SOURCES.md) page. + +### Adding New Sources + +See [Adding New Sources](README_ADDING_NEW_SOURCES.md) for a guide to choosing a source type, adding the files, and other configuration. + +## Resolving issues + +If you experience errors or other issues with the site, try the following in the project folder: + +1. `rm -rf node_modules` to clean out installed JavaScript packages +1. `yarn` to reinstall JavaScript packages +1. `yarn clean` to clean up Gatsby cache +1. `yarn develop` to start the development environment again. Keep in mind this will take longer than usual as Gatsby will need to rebuild everything. + +## Development + +All changes should have a pull request opened against the default branch, `develop`. When a pull request is opened, Heroku should automatically create a review build, which should be linked in the pull request under "deployments". Review builds only include advocacy content. When a pull request is merged, `develop` will automatically deploy the changes to the staging environment. + +To deploy to production, create a pull request merging `develop` into `main`. When that PR is merged, `main` will automatically build and deploy to the production site. + +### Environment Details + +Deployments of the site use the `build-sources.json` file to determine which sources need to be loaded. All environments are continuously deployed - new commits to relevant branches will trigger a build of the associated environment. The builds are done using Github Actions, so you can view deployment progress by clicking the "Actions" tab. + +#### Staging + +Staging is hosted on Netlify, and is built from the `develop` branch. The build and deployment process is handled by the `deploy-develop.yml` GitHub workflow. + +#### Production + +Production is hosted on Netlify, and is built from the `main` branch. The build and deployment process is handled by the `deploy-main.yml` GitHub workflow. The production deployment process will update the search index on Algolia. + +#### Review Builds + +Review builds are automatically created for pull requests. These builds are created by Heroku, and only include advocacy content, no other sources. + +## Redirects + +The app is concerned with two different types of redirects that can be defined in frontmatter. + +### Internal Redirects (within Docs 2.0) + +#### `redirects` + +The `redirects` frontmatter is to be used for redirects internal to Docs. For example, if you had a file `great_file.mdx` with this following frontmatter... + +```yaml +redirects: + - '/old_path' + - '/another_old_path' +``` + +both `/old_path` and `/another_old_path` would redirect to `great_file.mdx`'s current path. This is perfect for setting up redirects when moving a file around within Docs. Redirects created with `redirects` are permanent (301). + +### Docs 1.0 to Docs 2.0 redirects + +This app builds a list of nginx style redirects that are loaded into a separate server. These redirects direct users from links to the old docs site, to the appropriate page on the new docs site. + +#### `legacyRedirectsGenerated` + +This frontmatter is an automatically generated list of redirects for Docs 1.0 to Docs 2.0 (this repo). These redirects are built by `scripts/legacy_redirects/add_legecy_redirects.py`, and **should not be manually edited**. + +#### `legacyRedirects` + +If you need to setup a redirect from Docs 1.0 to Docs 2.0 manually, this is the place to do it. If the `legacyRedirectsGenerated` frontmatter does not include the redirect you need, you should add it here. + +# Advocacy Docs (left over from previous README, needs attention) + +Advocacy doc files are in [advocacy_docs/getting-started](https://github.com/EnterpriseDB/docs/tree/master/advocacy_docs/getting-started) + +New docs need a `.mdx` suffix to be used by Gatsby. + +## frontmatter + +Each document requires a `frontmatter` section at the top with a title. This looks like this: + +``` +--- +title: Title of page +--- +``` + +The title can be in quotes, but they are not needed unless you want an apostrophe in there. There also needs to be a space after `title:` + +In addition to `title`, there is also the option of adding `navTitle` and `description` to look like this: + +``` +--- +title: An exhaustive guide to all things wonderful about Postgres +navTitle: Postgres guide +description: Everything you need to know about Postgres +--- +``` + +The `navTitle` is used for the left navigation so it can take up less space. It is also used in "cards". + +The `description` is used in cards as well. + +## Markdown styling + +All of these files use Markdown for styling. The options for what can be done can be seen [here](https://github.com/EnterpriseDB/docs/blob/master/advocacy_docs/playground/1/01_examples/index.mdx) + +## Ordering of files + +The items in the left nav are sorted alphabetically by file name. This can be done with a numerical prefix. The titles of each page are used for the names in the left nav. + +## Content submission + +To add content to this site, changes must be submitted as a PR. There are two options for this: + +Option 1: locally + +1. Clone repo +2. Make a new branch +3. Add commits to branch and push to github +4. Create a new PR on github + +Option 2: on github + +1. Edit a file on github +2. Submit changes as a PR on a new branch + +## Search + +Content is indexed for search when the production site builds. diff --git a/README_ADDING_NEW_SOURCES.md b/README_ADDING_NEW_SOURCES.md new file mode 100644 index 00000000000..7265d5113d9 --- /dev/null +++ b/README_ADDING_NEW_SOURCES.md @@ -0,0 +1,81 @@ +# Adding New Sources + +## 1. Choose Source Type + +The first step to get a new doc source integrated into the app is to determine which source type fits your data best. + +### Advocacy Docs +Advocacy Docs are tutorial content, getting-started material, and anything that is about a subject matter area, but not explicitly tied to a product version. + +### Product Docs +Product Docs are versioned documentation for products. They follow a slightly stricter file structure to allow for version switching and other features. + +### Summary Table + +| Source Type | Sourcing | Versioned | Location +|---------------|-----------------|-----------|------------- +| Advocacy Docs | always loaded * | no | `advocacy_docs` +| Product Docs | configurable | yes | `product_docs/docs` + +\* While Advocacy Docs are currently always loaded, this could be changed in the future as needed + +## 2. Structure the Markdown Files + +In general, the best way to get a sense of the required file/folder structure will be to look at existing examples. However, here is a brief overview of what is required for each source type. + +### All Source Types + +#### Markdown + +Markdown files must have the `.mdx` extension, which allows optional Javascript templating with the the file. If a file is just `.md` or `.markdown`, it will not be loaded. + +All markdown files loaded must have a yaml frontmatter section, with at minumum a `title` set. + +#### Folders + +Folders must contain an `index.mdx` file, which will be the content used when users view the root of this directory. + +If there are multiple folders in the same directory, they should be prefixed with a number, IE `01_installation`, `02_getting_started`, etc. This is not strictly required, but can be used for sorting and ordering. + +### Product Docs + +Product Docs must confirm to a specific folder structing to enable version switching and other product doc specific features. + +```/product_docs/docs/[PRODUCT_SOURCE_NAME]/[VERSION_NUMBER]/...``` + +Once you're within the versioned directory, things should be structured like other source types. + +## 3. Update Sourcing Process + +If your new doc is a Product Doc, you will need to update the sourcing process, as this source type is configurable. You can skip this section if you're adding a standard Advocacy Doc. + +### `config_sources.py` + +This is the script that is run when a user runs `yarn config-sources`. It will need to be edited to present your new option to the user, and to write the source name to `dev-sources.json`. **This source name should match the top level folder name for your doc!** + +If you're adding a Product Doc, you'll want to add your source name to `PRODUCT_DOCS`. Next, you'll need to add your source to `OPTIONS`. New Product Docs should be inserted at the end of the current product doc listings. + +Once you've made your changes, run `yarn config-sources` and confirm that the output in `dev-sources.json` is as expected. + +### `gatsby-config.js` + +Once `dev-sources.json` looks as expected, you'll need to update `gatsby-config.js` to tell gatsby to load your source. To do this, you need to update `sourceToPluginConfig` with your source name and path. + +### `build-sources.json` + +This file must be updated with your source if you intend for it to be deployed to a server. This file shares the same structure with `dev-sources.json`, only it is used to determine which sources to load on a full build of the site. + +### `dev-sources.sample` + +This sample file should also be updated with your new source key, for those who may be manually configuring their sources. + +### Other Files + +#### `gatsby-node.js` + +If the source requires something different than previous sources have, or if there is something different about your source that we have not previously supported, it is likely some changes will need to be made in `gatsby-node.js`. + +### 4. You're Hopefully Done! + +At this point, you should have your new source integrated in the site! + diff --git a/README_DOCKER_VSCODE.md b/README_DOCKER_VSCODE.md new file mode 100644 index 00000000000..ff4a6813bda --- /dev/null +++ b/README_DOCKER_VSCODE.md @@ -0,0 +1,22 @@ +# Working on Docs in a Docker container using VSCode + +If you cannot or do not wish to install the prerequisite versions of Python, Node, Yarn, Gatsby, etc. on your local machine, *and* you're fond of using VSCode, then you can skip past the first eleven steps under the "installation" section in the [README](README.md) and work with Docs entirely from within a Docker container managed by VSCode. + +## Prerequesites + +1. [Docker](https://docs.docker.com/get-docker/) (for MacOS or Windows, that'll be Docker Desktop) +2. [Visual Studio Code](https://code.visualstudio.com/docs/setup/setup-overview) +3. The [Remote Development Extension Pack](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack) for VSCode + +If you intend to edit using VSCode, I also recommend installing the [MDX extension](https://marketplace.visualstudio.com/items?itemName=silvenon.mdx) - this is not required, but it is handy! + +## Installation + +1. In VSCode, from the command pallet select the `Remote-Containers: Clone Repository in Container Volume...` command +2. Paste in the URL of this repository, or a GitHub branch URL, or a GitHub PR URL +3. Choose "isolated volume" (in most cases this will be what you want) +4. Wait for VSCode to build the container, then open a terminal +8. Run the site locally with `yarn develop`. VSCode will remap port 8000 used within the container to a free port on your machine, which you can view from the Remote Explorer panel in the left sidebar - or ctrl+click the URL that Gatsby prints in the terminal to open directly. + +You can create as many distinct containers and volumes as you wish, which can be handy for comparing PRs side-by-side without disturbing your primary work. To browse them (or clean them up) open the "Remote Explorer" tool in VSCode. + diff --git a/advocacy_docs/community/contributing/index.mdx b/advocacy_docs/community/contributing/index.mdx new file mode 100644 index 00000000000..bcff7ae8dfe --- /dev/null +++ b/advocacy_docs/community/contributing/index.mdx @@ -0,0 +1,25 @@ +--- +title: We love feedback! +navTitle: Feedback +description: Guidelines for offering feedback to EDB Docs. +iconName: ideasharing +--- + +All feedback is welcome: + +1. an idea for something new +2. you feel there's something missing +3. a mistake + +Github Issues is the fastest way to get that feedback in front of us. + +[Open an issue on Github →](https://github.com/rocketinsights/edb_docs_advocacy/issues) + +--- + +### Have code or content to contribute? + +The only things we love more than feedback are pull requests. Check out [the README on Github](https://github.com/EnterpriseDB/docs) to get started. + + + diff --git a/advocacy_docs/community/contributing/repo.mdx b/advocacy_docs/community/contributing/repo.mdx new file mode 100644 index 00000000000..4e5efa00f67 --- /dev/null +++ b/advocacy_docs/community/contributing/repo.mdx @@ -0,0 +1,96 @@ +--- +title: Working with the Repo +navTitle: Working with the Repo +description: Step by step instructions to install and use the docs repo +iconName: codewriting +--- + +Below are detailed steps to get started with [this repository](https://github.com/EnterpriseDB/docs). Instructions are optimized for macOS. + +> **Note**: Items in code blocks indicate the Terminal command you should input; Terminal is a program that comes standard on MacOS. + +Example: + + ```shell + echo "hi!" + __OUTPUT__ + hi! + ``` + +## How to Install an IDE, Git, and Homebrew +1. Download VS Code from https://code.visualstudio.com/download (Skip this step if you already have an IDE or favorite editor) +2. Install [Homebrew](https://brew.sh/) + Go to your Mac Terminal and enter the following command + ```shell + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + ``` + This will take a few minutes +3. Install [git](https://git-scm.com/) from Terminal + ```shell + brew install git + ``` + +## How to Install the Repository and dependencies +4. Clone the docs repo into your local environment + ```shell + git clone https://github.com/EnterpriseDB/docs.git + ``` +5. Add the new repository folder to VS Code + Go to VS Code > File menu > Add Folder to Workspace > browse to “docs” + Click on > docs to expand it within VS Code +6. Install Node.js 12 or higher from the [Node.js website](https://nodejs.org/en/download/) +7. Go to the docs directory in Terminal + ```shell + cd docs + ``` +8. Install node + ```shell + brew install node + ``` +9. Install python + ```shell + brew install python + ``` +10. Install yarn and gatsby + ```shell + npm i -g gatsby-cli + npm i -g yarn + ``` +11. Install required packages with yarn + ```shell + yarn + ``` +12. Pull down shared icon files + ```shell + git submodule update --init + ``` +13. Select sources with yarn + ```shell + yarn config-sources + ``` + You'll be prompted to choose the packages you'd like to access; you can use comma separated values to choose more than one + ```shell + yarn develop + ``` +14. Go to the localhost port in your browser, e.g. http://localhost:8000/ (your url will be mentioned in Terminal) + +### Tips to Use Terminal +- ⌘+T (press the command key and T key together) opens a new tab - use this to execute terminal commands while yarn develop is running +- CTRL+C closes a process - use this to return to the terminal prompt after you're done testing with yarn develop + +## How to Make changes and Submit Pull Requests +You'll make edits and additions via your IDE (VS Code). We recommend using [Github Desktop](https://desktop.github.com/) unless you're familiar with git. + +15. Get in the habit of pulling the latest changes from the `develop` branch of the Github repository on a regular basis, so that you don't have to manually merge your changes with those made by others. Use the "Fetch origin" and "Pull origin" buttons in Github Desktop at the start of your work day to update your local files with those from the server. You should also do this again before submitting a pull request. For details, see: [Syncing your branch +](https://docs.github.com/en/desktop/contributing-and-collaborating-using-github-desktop/syncing-your-branch) + +16. To submit a pull request + - Make changes to the repository in VS code (or your IDE of choice) + - Save changes (CTRL+S in VS Code) + - Create a new branch and name it in Github Desktop + - Follow remaining steps in Github Desktop, most likely starting with "Commit to branch-name" + + +## Further reading + +- [Format & Style](/community/contribute/style) diff --git a/advocacy_docs/dummy.mdx b/advocacy_docs/dummy.mdx new file mode 100644 index 00000000000..c7d653cb3f0 --- /dev/null +++ b/advocacy_docs/dummy.mdx @@ -0,0 +1,6 @@ +--- +redirects: + - https://www.example.com +iconName: dottedbox +productStub: false +--- diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/api_reference.mdx b/advocacy_docs/kubernetes/cloud_native_postgresql/api_reference.mdx new file mode 100644 index 00000000000..d1d62a5efa3 --- /dev/null +++ b/advocacy_docs/kubernetes/cloud_native_postgresql/api_reference.mdx @@ -0,0 +1,429 @@ +--- +title: 'API Reference' +originalFilePath: 'src/api_reference.md' +product: 'Cloud Native Operator' +--- + +Cloud Native PostgreSQL extends the Kubernetes API defining the following +custom resources: + +- [Backup](#backup) +- [Cluster](#cluster) +- [ScheduledBackup](#scheduledbackup) + +All the resources are defined in the `postgresql.k8s.enterprisedb.io/v1` +API. + +Please refer to the ["Configuration Samples" page](samples.md)" of the +documentation for examples of usage. + +Below you will find a description of the defined resources: + + + +- [AffinityConfiguration](#AffinityConfiguration) +- [Backup](#Backup) +- [BackupConfiguration](#BackupConfiguration) +- [BackupList](#BackupList) +- [BackupSpec](#BackupSpec) +- [BackupStatus](#BackupStatus) +- [BarmanObjectStoreConfiguration](#BarmanObjectStoreConfiguration) +- [BootstrapConfiguration](#BootstrapConfiguration) +- [BootstrapInitDB](#BootstrapInitDB) +- [BootstrapRecovery](#BootstrapRecovery) +- [Cluster](#Cluster) +- [ClusterList](#ClusterList) +- [ClusterSpec](#ClusterSpec) +- [ClusterStatus](#ClusterStatus) +- [DataBackupConfiguration](#DataBackupConfiguration) +- [MonitoringConfiguration](#MonitoringConfiguration) +- [NodeMaintenanceWindow](#NodeMaintenanceWindow) +- [PostgresConfiguration](#PostgresConfiguration) +- [RecoveryTarget](#RecoveryTarget) +- [RollingUpdateStatus](#RollingUpdateStatus) +- [S3Credentials](#S3Credentials) +- [ScheduledBackup](#ScheduledBackup) +- [ScheduledBackupList](#ScheduledBackupList) +- [ScheduledBackupSpec](#ScheduledBackupSpec) +- [ScheduledBackupStatus](#ScheduledBackupStatus) +- [SecretsResourceVersion](#SecretsResourceVersion) +- [StorageConfiguration](#StorageConfiguration) +- [WalBackupConfiguration](#WalBackupConfiguration) + + + + +## `AffinityConfiguration` + +AffinityConfiguration contains the info we need to create the affinity rules for Pods + +Name | Description | Type +--------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------- +`enablePodAntiAffinity` | Activates anti-affinity for the pods. The operator will define pods anti-affinity unless this field is explicitly set to false | *bool +`topologyKey ` | TopologyKey to use for anti-affinity configuration. See k8s documentation for more info on that - *mandatory* | string +`nodeSelector ` | NodeSelector is map of key-value pairs used to define the nodes on which the pods can run. More info: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/ | map[string]string + + + +## `Backup` + +Backup is the Schema for the backups API + +Name | Description | Type +-------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ +`metadata` | | [metav1.ObjectMeta](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#objectmeta-v1-meta) +`spec ` | Specification of the desired behavior of the backup. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status | [BackupSpec](#BackupSpec) +`status ` | Most recently observed status of the backup. This data may not be up to date. Populated by the system. Read-only. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status | [BackupStatus](#BackupStatus) + + + +## `BackupConfiguration` + +BackupConfiguration defines how the backup of the cluster are taken. Currently the only supported backup method is barmanObjectStore. For details and examples refer to the Backup and Recovery section of the documentation + +Name | Description | Type +----------------- | ------------------------------------------------- | ------------------------------------------------------------------ +`barmanObjectStore` | The configuration for the barman-cloud tool suite | [*BarmanObjectStoreConfiguration](#BarmanObjectStoreConfiguration) + + + +## `BackupList` + +BackupList contains a list of Backup + +Name | Description | Type +-------- | ---------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- +`metadata` | Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds | [metav1.ListMeta](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#listmeta-v1-meta) +`items ` | List of backups - *mandatory* | [[]Backup](#Backup) + + + +## `BackupSpec` + +BackupSpec defines the desired state of Backup + +Name | Description | Type +------- | --------------------- | ---------------------------------------------------------------------------------------------------------------------------- +`cluster` | The cluster to backup | [v1.LocalObjectReference](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#localobjectreference-v1-core) + + + +## `BackupStatus` + +BackupStatus defines the observed state of Backup + +Name | Description | Type +--------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------- +`s3Credentials ` | The credentials to use to upload data to S3 - *mandatory* | [S3Credentials](#S3Credentials) +`endpointURL ` | Endpoint to be used to upload data to the cloud, overriding the automatic endpoint discovery | string +`destinationPath` | The path where to store the backup (i.e. s3://bucket/path/to/folder) this path, with different destination folders, will be used for WALs and for data - *mandatory* | string +`serverName ` | The server name on S3, the cluster name is used if this parameter is omitted | string +`encryption ` | Encryption method required to S3 API | string +`backupId ` | The ID of the Barman backup | string +`phase ` | The last backup status | BackupPhase +`startedAt ` | When the backup was started | [*metav1.Time](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#time-v1-meta) +`stoppedAt ` | When the backup was terminated | [*metav1.Time](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#time-v1-meta) +`error ` | The detected error | string +`commandOutput ` | The backup command output | string +`commandError ` | The backup command output | string + + + +## `BarmanObjectStoreConfiguration` + +BarmanObjectStoreConfiguration contains the backup configuration using Barman against an S3-compatible object storage + +Name | Description | Type +--------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------- +`s3Credentials ` | The credentials to use to upload data to S3 - *mandatory* | [S3Credentials](#S3Credentials) +`endpointURL ` | Endpoint to be used to upload data to the cloud, overriding the automatic endpoint discovery | string +`destinationPath` | The path where to store the backup (i.e. s3://bucket/path/to/folder) this path, with different destination folders, will be used for WALs and for data - *mandatory* | string +`serverName ` | The server name on S3, the cluster name is used if this parameter is omitted | string +`wal ` | The configuration for the backup of the WAL stream. When not defined, WAL files will be stored uncompressed and may be unencrypted in the object store, according to the bucket default policy. | [*WalBackupConfiguration](#WalBackupConfiguration) +`data ` | The configuration to be used to backup the data files When not defined, base backups files will be stored uncompressed and may be unencrypted in the object store, according to the bucket default policy. | [*DataBackupConfiguration](#DataBackupConfiguration) + + + +## `BootstrapConfiguration` + +BootstrapConfiguration contains information about how to create the PostgreSQL cluster. Only a single bootstrap method can be defined among the supported ones. `initdb` will be used as the bootstrap method if left unspecified. Refer to the Bootstrap page of the documentation for more information. + +Name | Description | Type +-------- | ----------------------------------- | ---------------------------------------- +`initdb ` | Bootstrap the cluster via initdb | [*BootstrapInitDB](#BootstrapInitDB) +`recovery` | Bootstrap the cluster from a backup | [*BootstrapRecovery](#BootstrapRecovery) + + + +## `BootstrapInitDB` + +BootstrapInitDB is the configuration of the bootstrap process when initdb is used Refer to the Bootstrap page of the documentation for more information. + +Name | Description | Type +-------- | -------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- +`database` | Name of the database used by the application. Default: `app`. - *mandatory* | string +`owner ` | Name of the owner of the database in the instance to be used by applications. Defaults to the value of the `database` key. - *mandatory* | string +`secret ` | Name of the secret containing the initial credentials for the owner of the user database. If empty a new secret will be created from scratch | [*corev1.LocalObjectReference](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#localobjectreference-v1-core) +`redwood ` | If we need to enable/disable Redwood compatibility. Requires EPAS and for EPAS defaults to true | *bool +`options ` | The list of options that must be passed to initdb when creating the cluster | []string + + + +## `BootstrapRecovery` + +BootstrapRecovery contains the configuration required to restore the backup with the specified name and, after having changed the password with the one chosen for the superuser, will use it to bootstrap a full cluster cloning all the instances from the restored primary. Refer to the Bootstrap page of the documentation for more information. + +Name | Description | Type +-------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- +`backup ` | The backup we need to restore - *mandatory* | [corev1.LocalObjectReference](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#localobjectreference-v1-core) +`recoveryTarget` | By default the recovery will end as soon as a consistent state is reached: in this case that means at the end of a backup. This option allows to fine tune the recovery process | [*RecoveryTarget](#RecoveryTarget) + + + +## `Cluster` + +Cluster is the Schema for the PostgreSQL API + +Name | Description | Type +-------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ +`metadata` | | [metav1.ObjectMeta](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#objectmeta-v1-meta) +`spec ` | Specification of the desired behavior of the cluster. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status | [ClusterSpec](#ClusterSpec) +`status ` | Most recently observed status of the cluster. This data may not be up to date. Populated by the system. Read-only. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status | [ClusterStatus](#ClusterStatus) + + + +## `ClusterList` + +ClusterList contains a list of Cluster + +Name | Description | Type +-------- | ---------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- +`metadata` | Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds | [metav1.ListMeta](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#listmeta-v1-meta) +`items ` | List of clusters - *mandatory* | [[]Cluster](#Cluster) + + + +## `ClusterSpec` + +ClusterSpec defines the desired state of Cluster + +Name | Description | Type +--------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- +`description ` | Description of this PostgreSQL cluster | string +`imageName ` | Name of the container image | string +`postgresUID ` | The UID of the `postgres` user inside the image, defaults to `26` | int64 +`postgresGID ` | The GID of the `postgres` user inside the image, defaults to `26` | int64 +`instances ` | Number of instances required in the cluster - *mandatory* | int32 +`minSyncReplicas ` | Minimum number of instances required in synchronous replication with the primary. Undefined or 0 allow writes to complete when no standby is available. | int32 +`maxSyncReplicas ` | The target value for the synchronous replication quorum, that can be decreased if the number of ready standbys is lower than this. Undefined or 0 disable synchronous replication. | int32 +`postgresql ` | Configuration of the PostgreSQL server | [PostgresConfiguration](#PostgresConfiguration) +`bootstrap ` | Instructions to bootstrap this cluster | [*BootstrapConfiguration](#BootstrapConfiguration) +`superuserSecret ` | The secret containing the superuser password. If not defined a new secret will be created with a randomly generated password | [*corev1.LocalObjectReference](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#localobjectreference-v1-core) +`imagePullSecrets ` | The list of pull secrets to be used to pull the images. If the license key contains a pull secret that secret will be automatically included. | [[]corev1.LocalObjectReference](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#localobjectreference-v1-core) +`storage ` | Configuration of the storage of the instances | [StorageConfiguration](#StorageConfiguration) +`startDelay ` | The time in seconds that is allowed for a PostgreSQL instance to successfully start up (default 30) | int32 +`stopDelay ` | The time in seconds that is allowed for a PostgreSQL instance node to gracefully shutdown (default 30) | int32 +`affinity ` | Affinity/Anti-affinity rules for Pods | [AffinityConfiguration](#AffinityConfiguration) +`resources ` | Resources requirements of every generated Pod. Please refer to https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ for more information. | [corev1.ResourceRequirements](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#resourcerequirements-v1-core) +`primaryUpdateStrategy` | Strategy to follow to upgrade the primary server during a rolling update procedure, after all replicas have been successfully updated: it can be automated (`unsupervised` - default) or manual (`supervised`) | PrimaryUpdateStrategy +`backup ` | The configuration to be used for backups | [*BackupConfiguration](#BackupConfiguration) +`nodeMaintenanceWindow` | Define a maintenance window for the Kubernetes nodes | [*NodeMaintenanceWindow](#NodeMaintenanceWindow) +`licenseKey ` | The license key of the cluster. When empty, the cluster operates in trial mode and after the expiry date (default 30 days) the operator will cease any reconciliation attempt. For details, please refer to the license agreement that comes with the operator. | string +`monitoring ` | The configuration of the monitoring infrastructure of this cluster | [*MonitoringConfiguration](#MonitoringConfiguration) + + + +## `ClusterStatus` + +ClusterStatus defines the observed state of Cluster + +Name | Description | Type +---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------- +`instances ` | Total number of instances in the cluster | int32 +`readyInstances ` | Total number of ready instances in the cluster | int32 +`instancesStatus ` | Instances status | map[utils.PodStatus][]string +`latestGeneratedNode ` | ID of the latest generated node (used to avoid node name clashing) | int32 +`currentPrimary ` | Current primary instance | string +`targetPrimary ` | Target primary instance, this is different from the previous one during a switchover or a failover | string +`pvcCount ` | How many PVCs have been created by this cluster | int32 +`jobCount ` | How many Jobs have been created by this cluster | int32 +`danglingPVC ` | List of all the PVCs created by this cluster and still available which are not attached to a Pod | []string +`initializingPVC ` | List of all the PVCs that are being initialized by this cluster | []string +`licenseStatus ` | Status of the license | licensekey.Status +`writeService ` | Current write pod | string +`readService ` | Current list of read pods | string +`phase ` | Current phase of the cluster | string +`phaseReason ` | Reason for the current phase | string +`secretsResourceVersion` | The list of resource versions of the secrets managed by the operator. Every change here is done in the interest of the instance manager, which will refresh the secret data | [SecretsResourceVersion](#SecretsResourceVersion) + + + +## `DataBackupConfiguration` + +DataBackupConfiguration is the configuration of the backup of the data directory + +Name | Description | Type +------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------- +`compression ` | Compress a backup file (a tar file per tablespace) while streaming it to the object store. Available options are empty string (no compression, default), `gzip` or `bzip2`. | CompressionType +`encryption ` | Whenever to force the encryption of files (if the bucket is not already configured for that). Allowed options are empty string (use the bucket policy, default), `AES256` and `aws:kms` | EncryptionType +`immediateCheckpoint` | Control whether the I/O workload for the backup initial checkpoint will be limited, according to the `checkpoint_completion_target` setting on the PostgreSQL server. If set to true, an immediate checkpoint will be used, meaning PostgreSQL will complete the checkpoint as soon as possible. `false` by default. | bool +`jobs ` | The number of parallel jobs to be used to upload the backup, defaults to 2 | *int32 + + + +## `MonitoringConfiguration` + +MonitoringConfiguration is the type containing all the monitoring configuration for a certain cluster + +Name | Description | Type +---------------------- | ----------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- +`customQueriesConfigMap` | The list of config maps containing the custom queries | [[]corev1.ConfigMapKeySelector](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#configmapkeyselector-v1-core) +`customQueriesSecret ` | The list of secrets containing the custom queries | [[]corev1.SecretKeySelector](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#secretkeyselector-v1-core) + + + +## `NodeMaintenanceWindow` + +NodeMaintenanceWindow contains information that the operator will use while upgrading the underlying node. + +This option is only useful when the chosen storage prevents the Pods from being freely moved across nodes. + +Name | Description | Type +---------- | ------------------------------------------------------------------------------------------ | ----- +`inProgress` | Is there a node maintenance activity in progress? - *mandatory* | bool +`reusePVC ` | Reuse the existing PVC (wait for the node to come up again) or not (recreate it elsewhere) - *mandatory* | *bool + + + +## `PostgresConfiguration` + +PostgresConfiguration defines the PostgreSQL configuration + +Name | Description | Type +---------- | ----------------------------------------------------------------------------------------- | ----------------- +`parameters` | PostgreSQL configuration options (postgresql.conf) | map[string]string +`pg_hba ` | PostgreSQL Host Based Authentication rules (lines to be appended to the pg_hba.conf file) | []string + + + +## `RecoveryTarget` + +RecoveryTarget allows to configure the moment where the recovery process will stop. All the target options except TargetTLI are mutually exclusive. + +Name | Description | Type +--------------- | ------------------------------------------------------------------------- | ------ +`targetTLI ` | The target timeline ("latest", "current" or a positive integer) | string +`targetXID ` | The target transaction ID | string +`targetName ` | The target name (to be previously created with `pg_create_restore_point`) | string +`targetLSN ` | The target LSN (Log Sequence Number) | string +`targetTime ` | The target time, in any unambiguous representation allowed by PostgreSQL | string +`targetImmediate` | End recovery as soon as a consistent state is reached | *bool +`exclusive ` | Set the target to be exclusive (defaults to true) | *bool + + + +## `RollingUpdateStatus` + +RollingUpdateStatus contains the information about an instance which is being updated + +Name | Description | Type +--------- | ----------------------------------- | ------------------------------------------------------------------------------------------------ +`imageName` | The image which we put into the Pod - *mandatory* | string +`startedAt` | When the update has been started | [metav1.Time](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#time-v1-meta) + + + +## `S3Credentials` + +S3Credentials is the type for the credentials to be used to upload files to S3 + +Name | Description | Type +--------------- | -------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- +`accessKeyId ` | The reference to the access key id - *mandatory* | [corev1.SecretKeySelector](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#secretkeyselector-v1-core) +`secretAccessKey` | The reference to the secret access key - *mandatory* | [corev1.SecretKeySelector](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#secretkeyselector-v1-core) + + + +## `ScheduledBackup` + +ScheduledBackup is the Schema for the scheduledbackups API + +Name | Description | Type +-------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ +`metadata` | | [metav1.ObjectMeta](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#objectmeta-v1-meta) +`spec ` | Specification of the desired behavior of the ScheduledBackup. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status | [ScheduledBackupSpec](#ScheduledBackupSpec) +`status ` | Most recently observed status of the ScheduledBackup. This data may not be up to date. Populated by the system. Read-only. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status | [ScheduledBackupStatus](#ScheduledBackupStatus) + + + +## `ScheduledBackupList` + +ScheduledBackupList contains a list of ScheduledBackup + +Name | Description | Type +-------- | ---------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- +`metadata` | Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds | [metav1.ListMeta](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#listmeta-v1-meta) +`items ` | List of clusters - *mandatory* | [[]ScheduledBackup](#ScheduledBackup) + + + +## `ScheduledBackupSpec` + +ScheduledBackupSpec defines the desired state of ScheduledBackup + +Name | Description | Type +-------- | -------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- +`suspend ` | If this backup is suspended of not | *bool +`schedule` | The schedule in Cron format, see https://en.wikipedia.org/wiki/Cron. - *mandatory* | string +`cluster ` | The cluster to backup | [v1.LocalObjectReference](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#localobjectreference-v1-core) + + + +## `ScheduledBackupStatus` + +ScheduledBackupStatus defines the observed state of ScheduledBackup + +Name | Description | Type +---------------- | -------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- +`lastCheckTime ` | The latest time the schedule | [*metav1.Time](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#time-v1-meta) +`lastScheduleTime` | Information when was the last time that backup was successfully scheduled. | [*metav1.Time](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#time-v1-meta) +`nextScheduleTime` | Next time we will run a backup | [*metav1.Time](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#time-v1-meta) + + + +## `SecretsResourceVersion` + +SecretsResourceVersion is the resource versions of the secrets managed by the operator + +Name | Description | Type +------------------------ | ----------------------------------------------------------------- | ------ +`superuserSecretVersion ` | The resource version of the "postgres" user secret - *mandatory* | string +`replicationSecretVersion` | The resource version of the "streaming_replication" user secret - *mandatory* | string +`applicationSecretVersion` | The resource version of the "app" user secret - *mandatory* | string +`caSecretVersion ` | The resource version of the "ca" secret version - *mandatory* | string +`serverSecretVersion ` | The resource version of the PostgreSQL server-side secret version - *mandatory* | string + + + +## `StorageConfiguration` + +StorageConfiguration is the configuration of the storage of the PostgreSQL instances + +Name | Description | Type +------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------- +`storageClass ` | StorageClass to use for database data (`PGDATA`). Applied after evaluating the PVC template, if available. If not specified, generated PVCs will be satisfied by the default storage class | *string +`size ` | Size of the storage. Required if not already specified in the PVC template. Changes to this field are automatically reapplied to the created PVCs. Size cannot be decreased. - *mandatory* | string +`resizeInUseVolumes` | Resize existent PVCs, defaults to true | *bool +`pvcTemplate ` | Template to be used to generate the Persistent Volume Claim | [*corev1.PersistentVolumeClaimSpec](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#persistentvolumeclaim-v1-core) + + + +## `WalBackupConfiguration` + +WalBackupConfiguration is the configuration of the backup of the WAL stream + +Name | Description | Type +----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------- +`compression` | Compress a WAL file before sending it to the object store. Available options are empty string (no compression, default), `gzip` or `bzip2`. | CompressionType +`encryption ` | Whenever to force the encryption of files (if the bucket is not already configured for that). Allowed options are empty string (use the bucket policy, default), `AES256` and `aws:kms` | EncryptionType + diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/architecture.mdx b/advocacy_docs/kubernetes/cloud_native_postgresql/architecture.mdx new file mode 100644 index 00000000000..4dccd20f717 --- /dev/null +++ b/advocacy_docs/kubernetes/cloud_native_postgresql/architecture.mdx @@ -0,0 +1,126 @@ +--- +title: 'Architecture' +originalFilePath: 'src/architecture.md' +product: 'Cloud Native Operator' +--- + +For High Availability goals, the PostgreSQL database management system provides administrators with built-in **physical replication** capabilities based on **Write Ahead Log (WAL) shipping**. + +PostgreSQL supports both asynchronous and synchronous streaming replication, as well as asynchronous file-based log shipping (normally used as a fallback option, for example, to store WAL files in an object store). Replicas are usually called *standby servers* and can also be used for read-only workloads, thanks to the *Hot Standby* feature. + +Cloud Native PostgreSQL currently supports clusters based on asynchronous and synchronous streaming replication to manage multiple hot standby replicas, with the following specifications: + +* One primary, with optional multiple hot standby replicas for High Availability +* Available services for applications: + * `-rw`: applications connect to the only primary instance of the cluster + * `-ro`: applications connect to the only hot standby replicas for read-only-workloads + * `-r`: applications connect to any of the instances for read-only workloads +* Shared-nothing architecture recommended for better resilience of the PostgreSQL cluster: + * PostgreSQL instances should reside on different Kubernetes worker nodes and share only the network + * PostgreSQL instances can reside in different availability zones in the same region + * All nodes of a PostgreSQL cluster should reside in the same region + +## Read-write workloads + +Applications can decide to connect to the PostgreSQL instance elected as *current primary* +by the Kubernetes operator, as depicted in the following diagram: + +![Applications writing to the single primary](./images/architecture-rw.png) + +Applications can use the `-rw` suffix service. + +In case of temporary or permanent unavailability of the primary, Kubernetes +will move the `-rw` to another instance of the cluster for high availability +purposes. + +## Read-only workloads + +!!! Important + Applications must be aware of the limitations that [Hot Standby](https://www.postgresql.org/docs/current/hot-standby.html) + presents and familiar with the way PostgreSQL operates when dealing with these workloads. + +Applications can access hot standby replicas through the `-ro` service made available +by the operator. This service enables the application to offload read-only queries from the +primary node. + +The following diagram shows the architecture: + +![Applications reading from hot standby replicas in round robin](./images/architecture-read-only.png) + +Applications can also access any PostgreSQL instance at any time through the `-r` service at connection time. + +## Application deployments + +Applications are supposed to work with the services created by Cloud Native PostgreSQL +in the same Kubernetes cluster: + +* `[cluster name]-rw` +* `[cluster name]-ro` +* `[cluster name]-r` + +Those services are entirely managed by the Kubernetes cluster and +implement a form of Virtual IP as described in the +["Service" page of the Kubernetes Documentation](https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies). + +!!! Hint + It is highly recommended to use those services in your applications, + and avoid connecting directly to a specific PostgreSQL instance, as the latter + can change during the cluster lifetime. + +You can use these services in your applications through: + +* DNS resolution +* environment variables + +As far as the credentials to connect to PostgreSQL are concerned, you can +use the secrets generated by the operator. + +!!! Warning + The operator will create another service, named `[cluster name]-any`. That + service is used internally to manage PostgreSQL instance discovery. + It's not supposed to be used directly by applications. + +## DNS resolution + +You can use the Kubernetes DNS service, which is required by this operator, +to point to a given server. +You can do that by just using the name of the service if the application is +deployed in the same namespace as the PostgreSQL cluster. +In case the PostgreSQL cluster resides in a different namespace, you can use the +full qualifier: `service-name.namespace-name`. + +DNS is the preferred and recommended discovery method. + +## Environment variables + +If you deploy your application in the same namespace that contains the +PostgreSQL cluster, you can also use environment variables to connect to the database. + +For example, suppose that your PostgreSQL cluster is called `pg-database`, +you can use the following environment variables in your applications: + +* `PG_DATABASE_R_SERVICE_HOST`: the IP address of the service + pointing to all the PostgreSQL instances for read-only workloads + +* `PG_DATABASE_RO_SERVICE_HOST`: the IP address of the + service pointing to all hot-standby replicas of the cluster + +* `PG_DATABASE_RW_SERVICE_HOST`: the IP address of the + service pointing to the *primary* instance of the cluster + +## Secrets + +The PostgreSQL operator will generate two secrets for every PostgreSQL cluster +it deploys: + +* `[cluster name]-superuser` +* `[cluster name]-app` + +The secrets contain the username, password, and a working +[`.pgpass file`](https://www.postgresql.org/docs/current/libpq-pgpass.html) +respectively for the `postgres` user and the *owner* of the database. + +The `-app` credentials are the ones that should be used by applications +connecting to the PostgreSQL cluster. + +The `-superuser` ones are supposed to be used only for administrative purposes. diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/backup_recovery.mdx b/advocacy_docs/kubernetes/cloud_native_postgresql/backup_recovery.mdx new file mode 100644 index 00000000000..b96cf1ec629 --- /dev/null +++ b/advocacy_docs/kubernetes/cloud_native_postgresql/backup_recovery.mdx @@ -0,0 +1,423 @@ +--- +title: 'Backup and Recovery' +originalFilePath: 'src/backup_recovery.md' +product: 'Cloud Native Operator' +--- + +The operator can orchestrate a continuous backup infrastructure +that is based on the [Barman](https://pgbarman.org) tool. Instead +of using the classical architecture with a Barman server, which +backup many PostgreSQL instances, the operator will use the +`barman-cloud-wal-archive` and `barman-cloud-backup` tools. +As a result, base backups will be *tarballs*. Both base backups and WAL files +can be compressed and encrypted. + +For this, it is required an image with `barman-cli-cloud` installed. +You can use the image `quay.io/enterprisedb/postgresql` for this scope, +as it is composed of a community PostgreSQL image and the latest +`barman-cli-cloud` package. + +## Cloud credentials + +You can archive the backup files in any service whose API is compatible +with AWS S3. You will need the following information about your +environment: + +- `ACCESS_KEY_ID`: the ID of the access key that will be used + to upload files in S3 + +- `ACCESS_SECRET_KEY`: the secret part of the previous access key + +- `ACCESS_SESSION_TOKEN`: the optional session token in case it is required + +The access key used must have permission to upload files in +the bucket. Given that, you must create a k8s secret with the +credentials, and you can do that with the following command: + +```sh +kubectl create secret generic aws-creds \ + --from-literal=ACCESS_KEY_ID= \ + --from-literal=ACCESS_SECRET_KEY= +# --from-literal=ACCESS_SESSION_TOKEN= # if required +``` + +The credentials will be stored inside Kubernetes and will be encrypted +if encryption at rest is configured in your installation. + +## Configuring the Cluster + +### S3 + +Given that secret, you can configure your cluster like in +the following example: + +```yaml +apiVersion: postgresql.k8s.enterprisedb.io/v1 +kind: Cluster +[...] +spec: + backup: + barmanObjectStore: + destinationPath: "" + s3Credentials: + accessKeyId: + name: aws-creds + key: ACCESS_KEY_ID + secretAccessKey: + name: aws-creds + key: ACCESS_SECRET_KEY +``` + +The destination path can be every URL pointing to a folder where +the instance can upload the WAL files, e.g. +`s3://BUCKET_NAME/path/to/folder`. + +### Other S3-compatible Object Storages providers + +In case you're using S3-compatible object storage, like MinIO or +Linode Object Storage, you can specify an endpoint instead of using the +default S3 one. + +In this example, it will use the `bucket` bucket of Linode in the region +`us-east1`. + +```yaml +apiVersion: postgresql.k8s.enterprisedb.io/v1 +kind: Cluster +[...] +spec: + backup: + barmanObjectStore: + destinationPath: "" + endpointURL: bucket.us-east1.linodeobjects.com + s3Credentials: + [...] +``` + +### MinIO Gateway + +Optionally, you can use MinIO Gateway as a common interface which +relays backup objects to other cloud storage solutions, like S3, GCS or +Azure. For more information, please refer to [MinIO official documentation](https://docs.min.io/). + +Specifically, the Cloud Native PostgreSQL cluster can directly point to a local +MinIO Gateway as an endpoint, using previously created credentials and service. + +MinIO secrets will be used by both the PostgreSQL cluster and the MinIO instance. +Therefore you must create them in the same namespace: + +```sh +kubectl create secret generic minio-creds \ + --from-literal=MINIO_ACCESS_KEY= \ + --from-literal=MINIO_SECRET_KEY= +``` + +!!! Note + Cloud Object Storage credentials will be used only by MinIO Gateway in this case. + +!!! Important + In order to allow PostgreSQL to reach MinIO Gateway, it is necessary to create a + `ClusterIP` service on port `9000` bound to the MinIO Gateway instance. + +For example: + +```yaml +apiVersion: v1 +kind: Service +metadata: + name: minio-gateway-service +spec: + type: ClusterIP + ports: + - port: 9000 + targetPort: 9000 + protocol: TCP + selector: + app: minio +``` + +!!! Warning + At the time of writing this documentation, the official [MinIO Operator](https://github.com/minio/minio-operator/issues/71) + for Kubernetes does not support the gateway feature. As such, we will use a + `deployment` instead. + +The MinIO deployment will use cloud storage credentials to upload objects to the +remote bucket and relay backup files to different locations. + +Here is an example using AWS S3 as Cloud Object Storage: + +```yaml +apiVersion: apps/v1 +kind: Deployment +[...] + spec: + containers: + - name: minio + image: minio/minio:RELEASE.2020-06-03T22-13-49Z + args: + - gateway + - s3 + env: + # MinIO access key and secret key + - name: MINIO_ACCESS_KEY + valueFrom: + secretKeyRef: + name: minio-creds + key: MINIO_ACCESS_KEY + - name: MINIO_SECRET_KEY + valueFrom: + secretKeyRef: + name: minio-creds + key: MINIO_SECRET_KEY + # AWS credentials + - name: AWS_ACCESS_KEY_ID + valueFrom: + secretKeyRef: + name: aws-creds + key: ACCESS_KEY_ID + - name: AWS_SECRET_ACCESS_KEY + valueFrom: + secretKeyRef: + name: aws-creds + key: ACCESS_SECRET_KEY +# Uncomment the below section if session token is required +# - name: AWS_SESSION_TOKEN +# valueFrom: +# secretKeyRef: +# name: aws-creds +# key: ACCESS_SESSION_TOKEN + ports: + - containerPort: 9000 +``` + +Proceed by configuring MinIO Gateway service as the `endpointURL` in the `Cluster` +definition, then choose a bucket name to replace `BUCKET_NAME`: + +```yaml +apiVersion: postgresql.k8s.enterprisedb.io/v1 +kind: Cluster +[...] +spec: + backup: + barmanObjectStore: + destinationPath: s3://BUCKET_NAME/ + endpointURL: http://minio-gateway-service:9000 + s3Credentials: + accessKeyId: + name: minio-creds + key: MINIO_ACCESS_KEY + secretAccessKey: + name: minio-creds + key: MINIO_SECRET_KEY + [...] +``` + +Verify on `s3://BUCKET_NAME/` the presence of archived WAL files before +proceeding with a backup. + +## On-demand backups + +To request a new backup, you need to create a new Backup resource +like the following one: + +```yaml +apiVersion: postgresql.k8s.enterprisedb.io/v1 +kind: Backup +metadata: + name: backup-example +spec: + cluster: + name: pg-backup +``` + +The operator will start to orchestrate the cluster to take the +required backup using `barman-cloud-backup`. You can check +the backup status using the plain `kubectl describe backup ` +command: + +```text +Name: backup-example +Namespace: default +Labels: +Annotations: API Version: postgresql.k8s.enterprisedb.io/v1 +Kind: Backup +Metadata: + Creation Timestamp: 2020-10-26T13:57:40Z + Self Link: /apis/postgresql.k8s.enterprisedb.io/v1/namespaces/default/backups/backup-example + UID: ad5f855c-2ffd-454a-a157-900d5f1f6584 +Spec: + Cluster: + Name: pg-backup +Status: + Phase: running + Started At: 2020-10-26T13:57:40Z +Events: +``` + +When the backup has been completed, the phase will be `completed` +like in the following example: + +```text +Name: backup-example +Namespace: default +Labels: +Annotations: API Version: postgresql.k8s.enterprisedb.io/v1 +Kind: Backup +Metadata: + Creation Timestamp: 2020-10-26T13:57:40Z + Self Link: /apis/postgresql.k8s.enterprisedb.io/v1/namespaces/default/backups/backup-example + UID: ad5f855c-2ffd-454a-a157-900d5f1f6584 +Spec: + Cluster: + Name: pg-backup +Status: + Backup Id: 20201026T135740 + Destination Path: s3://backups/ + Endpoint URL: http://minio:9000 + Phase: completed + s3Credentials: + Access Key Id: + Key: ACCESS_KEY_ID + Name: minio + Secret Access Key: + Key: ACCESS_SECRET_KEY + Name: minio + Server Name: pg-backup + Started At: 2020-10-26T13:57:40Z + Stopped At: 2020-10-26T13:57:44Z +Events: +``` + +!!!Important + This feature will not backup the secrets for the superuser and the + application user. The secrets are supposed to be backed up as part of + the standard backup procedures for the Kubernetes cluster. + +## Scheduled backups + +You can also schedule your backups periodically by creating a +resource named `ScheduledBackup`. The latter is similar to a +`Backup` but with an added field, called `schedule`. + +This field is a [Cron](https://en.wikipedia.org/wiki/Cron) schedule +specification with a prepended field for seconds. This schedule format +is the same used in Kubernetes CronJobs. + +This is an example of a scheduled backup: + +```yaml +apiVersion: postgresql.k8s.enterprisedb.io/v1 +kind: ScheduledBackup +metadata: + name: backup-example +spec: + schedule: "0 0 0 * * *" + cluster: + name: pg-backup +``` + +The proposed specification will schedule a backup every day at midnight. + +## WAL archiving + +WAL archiving is enabled as soon as you choose a destination path +and you configure your cloud credentials. + +If required, you can choose to compress WAL files as soon as they +are uploaded and/or encrypt them: + +```yaml +apiVersion: postgresql.k8s.enterprisedb.io/v1 +kind: Cluster +[...] +spec: + backup: + barmanObjectStore: + [...] + wal: + compression: gzip + encryption: AES256 +``` + +You can configure the encryption directly in your bucket, and the operator +will use it unless you override it in the cluster configuration. + +## Recovery + +You can use the data uploaded to the object storage to bootstrap a +new cluster from a backup. The operator will orchestrate the recovery +process using the `barman-cloud-restore` tool. + +When a backup is completed, the corresponding Kubernetes resource will +contain every information needed to restore it, just like in the +following example: + +```text +Name: backup-example +Namespace: default +Labels: +Annotations: API Version: postgresql.k8s.enterprisedb.io/v1 +Kind: Backup +Metadata: + Creation Timestamp: 2020-10-26T13:57:40Z + Self Link: /apis/postgresql.k8s.enterprisedb.io/v1/namespaces/default/backups/backup-example + UID: ad5f855c-2ffd-454a-a157-900d5f1f6584 +Spec: + Cluster: + Name: pg-backup +Status: + Backup Id: 20201026T135740 + Destination Path: s3://backups/ + Endpoint URL: http://minio:9000 + Phase: completed + s3Credentials: + Access Key Id: + Key: ACCESS_KEY_ID + Name: minio + Secret Access Key: + Key: ACCESS_SECRET_KEY + Name: minio + Server Name: pg-backup + Started At: 2020-10-26T13:57:40Z + Stopped At: 2020-10-26T13:57:44Z +Events: +``` + +Given the following cluster definition: + +```yaml +apiVersion: postgresql.k8s.enterprisedb.io/v1 +kind: Cluster +metadata: + name: cluster-restore +spec: + instances: 3 + + storage: + size: 5Gi + + bootstrap: + recovery: + backup: + name: backup-example +``` + +The operator will inject an init container in the first instance of the +cluster and the init container will start recovering the backup from the +object storage. + +When the recovery process is completed, the operator will start the instance +to allow it to recover the transaction log files needed for the +consistency of the restored data directory. + +Once the recovery is complete, the operator will set the required +superuser password into the instance. The new primary instance will start +as usual, and the remaining instances will join the cluster as replicas. + +The process is transparent for the user and it is managed by the instance +manager running in the Pods. + +You can optionally specify a `recoveryTarget` to perform a point in time +recovery. If left unspecified, the recovery will continue up to the latest +available WAL on the default target timeline (`current` for PostgreSQL up to +11, `latest` for version 12 and above). diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/before_you_start.mdx b/advocacy_docs/kubernetes/cloud_native_postgresql/before_you_start.mdx new file mode 100644 index 00000000000..6b9d5f3a4f9 --- /dev/null +++ b/advocacy_docs/kubernetes/cloud_native_postgresql/before_you_start.mdx @@ -0,0 +1,49 @@ +--- +title: 'Before You Start' +originalFilePath: 'src/before_you_start.md' +product: 'Cloud Native Operator' +--- + +Before we get started, it is essential to go over some terminology that is +specific to Kubernetes and PostgreSQL. + +## Kubernetes terminology + +| Resource | Description | +|-------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| [Node](https://kubernetes.io/docs/concepts/architecture/nodes/) | A *node* is a worker machine in Kubernetes, either virtual or physical, where all services necessary to run pods are managed by the control plane node(s). | +| [Pod](https://kubernetes.io/docs/concepts/workloads/pods/pod/) | A *pod* is the smallest computing unit that can be deployed in a Kubernetes cluster and is composed of one or more containers that share network and storage. | +| [Service](https://kubernetes.io/docs/concepts/services-networking/service/) | A *service* is an abstraction that exposes as a network service an application that runs on a group of pods and standardizes important features such as service discovery across applications, load balancing, failover, and so on. | +| [Secret](https://kubernetes.io/docs/concepts/configuration/secret/) | A *secret* is an object that is designed to store small amounts of sensitive data such as passwords, access keys, or tokens, and use them in pods. | +| [Storage Class](https://kubernetes.io/docs/concepts/storage/storage-classes/) | A *storage class* allows an administrator to define the classes of storage in a cluster, including provisioner (such as AWS EBS), reclaim policies, mount options, volume expansion, and so on. | +| [Persistent Volume](https://kubernetes.io/docs/concepts/storage/persistent-volumes/) | A *persistent volume* (PV) is a resource in a Kubernetes cluster that represents storage that has been either manually provisioned by an administrator or dynamically provisioned by a *storage class* controller. A PV is associated with a pod using a *persistent volume claim* and its lifecycle is independent of any pod that uses it. Normally, a PV is a network volume, especially in the public cloud. A [*local persistent volume* (LPV)](https://kubernetes.io/docs/concepts/storage/volumes/#local) is a persistent volume that exists only on the particular node where the pod that uses it is running. | +| [Persistent Volume Claim](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims) | A *persistent volume claim* (PVC) represents a request for storage, which might include size, access mode, or a particular storage class. Similar to how a pod consumes node resources, a PVC consumes the resources of a PV. | +| [Namespace](https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/) | A *namespace* is a logical and isolated subset of a Kubernetes cluster and can be seen as a *virtual cluster* within the wider physical cluster. Namespaces allow administrators to create separated environments based on projects, departments, teams, and so on. | +| [RBAC](https://kubernetes.io/docs/reference/access-authn-authz/rbac/) | *Role Based Access Control* (RBAC), also known as *role-based security*, is a method used in computer systems security to restrict access to the network and resources of a system to authorized users only. Kubernetes has a native API to control roles at the namespace and cluster level and associate them with specific resources and individuals. | +| [CRD](https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/) | A *custom resource definition* (CRD) is an extension of the Kubernetes API and allows developers to create new data types and objects, *called custom resources*. | +| [Operator](https://kubernetes.io/docs/concepts/extend-kubernetes/operator/) | An *operator* is a custom resource that automates those steps that are normally performed by a human operator when managing one or more applications or given services. An operator assists Kubernetes in making sure that the resource's defined state always matches the observed one. | +| [kubectl](https://kubernetes.io/docs/reference/kubectl/overview/) | `kubectl` is the command-line tool used to manage a Kubernetes cluster. | + +Cloud Native PostgreSQL requires Kubernetes 1.16 or higher. + +## PostgreSQL terminology + +| Resource | Description | +|-------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| Instance | A Postgres server process running and listening on a pair "IP address(es)" and "TCP port" (usually 5432). | +| Primary | A PostgreSQL instance that can accept both read and write operations. | +| Replica | A PostgreSQL instance replicating from the only primary instance in a cluster and is kept updated by reading a stream of Write-Ahead Log (WAL) records. A replica is also known as *standby* or *secondary* server. PostgreSQL relies on physical streaming replication (async/sync) and file-based log shipping (async). | +| Hot Standby | PostgreSQL feature that allows a *replica* to accept read-only workloads. | +| Cluster | To be intended as High Availability (HA) Cluster: a set of PostgreSQL instances made up by a single primary and an optional arbitrary number of replicas. | + +## Cloud terminology + +| Resource | Description | +|-------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| Region | A *region* in the Cloud is an isolated and independent geographic area organized in *availability zones*. Zones within a region have very little round-trip network latency. | +| Zone | An *availability zone* in the Cloud (also known as *zone*) is an area in a region where resources can be deployed. Usually, an availability zone corresponds to a data center or an isolated building of the same data center. | + +## What to do next + +Now that you have familiarized with the terminology, you can decide to +[test Cloud Native PostgreSQL on your laptop using a local cluster](quickstart.md) before deploying the operator in your selected cloud environment. diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/bootstrap.mdx b/advocacy_docs/kubernetes/cloud_native_postgresql/bootstrap.mdx new file mode 100644 index 00000000000..a6288dce3c4 --- /dev/null +++ b/advocacy_docs/kubernetes/cloud_native_postgresql/bootstrap.mdx @@ -0,0 +1,308 @@ +--- +title: 'Bootstrap' +originalFilePath: 'src/bootstrap.md' +product: 'Cloud Native Operator' +--- + +This section describes the options you have to create a new +PostgreSQL cluster and the design rationale behind them. + +When a PostgreSQL cluster is defined, you can configure the +*bootstrap* method using the `bootstrap` section of the cluster +specification. + +In the following example: + +```yaml +apiVersion: postgresql.k8s.enterprisedb.io/v1 +kind: Cluster +metadata: + name: cluster-example-initdb +spec: + instances: 3 + + bootstrap: + initdb: + database: appdb + owner: appuser + + storage: + size: 1Gi +``` + +The `initdb` bootstrap method is used. + +We currently support the following bootstrap methods: + +- `initdb`: initialise an empty PostgreSQL cluster +- `recovery`: create a PostgreSQL cluster restoring from an existing backup + and replaying all the available WAL files. + +## initdb + +The `initdb` bootstrap method is used to create a new PostgreSQL cluster from +scratch. It is the default one unless specified differently. + +The following example contains the full structure of the `initdb` configuration: + +```yaml +apiVersion: postgresql.k8s.enterprisedb.io/v1 +kind: Cluster +metadata: + name: cluster-example-initdb +spec: + instances: 3 + + superuserSecret: + name: superuser-secret + + bootstrap: + initdb: + database: appdb + owner: appuser + secret: + name: appuser-secret + + storage: + size: 1Gi +``` + +The above example of bootstrap will: + +1. create a new `PGDATA` folder using PostgreSQL's native `initdb` command +2. set a *superuser* password from the secret named `superuser-secret` +3. create an *unprivileged* user named `appuser` +4. set the password of the latter using the one in the `appuser-secret` secret +5. create a database called `appdb` owned by the `appuser` user. + +Thanks to the *convention over configuration paradigm*, you can let the +operator choose a default database name (`app`) and a default application +user name (same as the database name), as well as randomly generate a +secure password for both the superuser and the application user in +PostgreSQL. + +Alternatively, you can generate your passwords, store them as secrets, +and use them in the PostgreSQL cluster - as described in the above example. + +The supplied secrets must comply with the specifications of the +[`kubernetes.io/basic-auth` type](https://kubernetes.io/docs/concepts/configuration/secret/#basic-authentication-secret). +The operator will only use the `password` field of the secret, +ignoring the `username` one. If you plan to reuse the secret for application +connections, you can set the `username` field to the same value as the `owner`. + +The following is an example of a `basic-auth` secret: + +```yaml +apiVersion: v1 +data: + password: cGFzc3dvcmQ= +kind: Secret +metadata: + name: cluster-example-app-user +type: kubernetes.io/basic-auth +``` + +The application database is the one that should be used to store application +data. Applications should connect to the cluster with the user that owns +the application database. + +!!! Important + Future implementations of the operator might allow you to create + additional users in a declarative configuration fashion. + +The superuser and the `postgres` database are supposed to be used only +by the operator to configure the cluster. + +In case you don't supply any database name, the operator will proceed +by convention and create the `app` database, and adds it to the cluster +definition using a *defaulting webhook*. +The user that owns the database defaults to the database name instead. + +The application user is not used internally by the operator, which instead +relies on the superuser to reconcile the cluster with the desired status. + +!!! Important + For now, changes to the name of the superuser secret are not applied + to the cluster. + +The actual PostgreSQL data directory is created via an invocation of the +`initdb` PostgreSQL command. If you need to add custom options to that +command (i.e., to change the locale used for the template databases or to +add data checksums), you can add them to the `options` section like in +the following example: + +```yaml +apiVersion: postgresql.k8s.enterprisedb.io/v1 +kind: Cluster +metadata: + name: cluster-example-initdb +spec: + instances: 3 + + bootstrap: + initdb: + database: appdb + owner: appuser + options: + - "-k" + - "--locale=en_US" + storage: + size: 1Gi +``` + +### Compatibility Features + +EDB Postgres Advanced adds many compatibility features to the +plain community PostgreSQL. You can find more information about that +in the [EDB Postgres Advanced](https://www.enterprisedb.com/edb-docs/p/edb-postgres-advanced-server). + +Those features are already enabled during cluster creation on EPAS and +are not supported on the community PostgreSQL image. To disable them +you can use the `redwood` flag in the `initdb` section +like in the following example: + +```yaml +apiVersion: postgresql.k8s.enterprisedb.io/v1 +kind: Cluster +metadata: + name: cluster-example-initdb +spec: + instances: 3 + imageName: + licenseKey: + + bootstrap: + initdb: + database: appdb + owner: appuser + redwood: false + storage: + size: 1Gi +``` + +!!! Important + EDB Postgres Advanced requires a valid license key (trial or production) to start. + +## recovery + +The `recovery` bootstrap mode lets you create a new cluster from +an existing backup. You can find more information about the recovery +feature in the ["Backup and recovery" page](backup_recovery.md). + +The following example contains the full structure of the `recovery` +section: + +```yaml +apiVersion: postgresql.k8s.enterprisedb.io/v1 +kind: Cluster +metadata: + name: cluster-example-initdb +spec: + instances: 3 + + superuserSecret: + name: superuser-secret + + bootstrap: + recovery: + backup: + name: backup-example + + storage: + size: 1Gi +``` + +This bootstrap method allows you to specify just a reference to the +backup that needs to be restored. + +The application database name and the application database user are preserved +from the backup that is being restored. The operator does not currently attempt +to backup the underlying secrets, as this is part of the usual maintenance +activity of the Kubernetes cluster itself. + +In case you don't supply any `superuserSecret`, a new one is automatically +generated with a secure and random password. The secret is then used to +reset the password for the `postgres` user of the cluster. + +By default, the recovery will continue up to the latest +available WAL on the default target timeline (`current` for PostgreSQL up to +11, `latest` for version 12 and above). +You can optionally specify a `recoveryTarget` to perform a point in time +recovery (see the ["Point in time recovery" chapter](#point-in-time-recovery)). + +### Point in time recovery + +Instead of replaying all the WALs up to the latest one, +we can ask PostgreSQL to stop replaying WALs at any given point in time. +PostgreSQL uses this technique to implement *point-in-time* recovery. +This allows you to restore the database to its state at any time after +the base backup was taken. + +The operator will generate the configuration parameters required for this +feature to work if a recovery target is specified like in the following +example: + +```yaml +apiVersion: postgresql.k8s.enterprisedb.io/v1 +kind: Cluster +metadata: + name: cluster-restore-pitr +spec: + instances: 3 + + storage: + size: 5Gi + + bootstrap: + recovery: + backup: + name: backup-example + + recoveryTarget: + targetTime: "2020-11-26 15:22:00.00000+00" +``` + +Beside `targetTime`, you can use the following criteria to stop the recovery: + +- `targetXID` specify a transaction ID up to which recovery will proceed + +- `targetName` specify a restore point (created with `pg_create_restore_point` + to which recovery will proceed) + +- `targetLSN` specify the LSN of the write-ahead log location up to which + recovery will proceed + +- `targetImmediate` specify to stop as soon as a consistent state is + reached + +You can choose only a single one among the targets above in each +`recoveryTarget` configuration. + +Additionally, you can specify `targetTLI` force recovery to a specific +timeline. + +By default, the previous parameters are considered to be exclusive, stopping +just before the recovery target. You can request inclusive behavior, +stopping right after the recovery target, setting the `exclusive` parameter to +`false` like in the following example: + +```yaml +apiVersion: postgresql.k8s.enterprisedb.io/v1 +kind: Cluster +metadata: + name: cluster-restore-pitr +spec: + instances: 3 + + storage: + size: 5Gi + + bootstrap: + recovery: + backup: + name: backup-example + + recoveryTarget: + targetName: "maintenance-activity" + exclusive: false +``` diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/cloud_setup.mdx b/advocacy_docs/kubernetes/cloud_native_postgresql/cloud_setup.mdx new file mode 100644 index 00000000000..55699d23447 --- /dev/null +++ b/advocacy_docs/kubernetes/cloud_native_postgresql/cloud_setup.mdx @@ -0,0 +1,114 @@ +--- +title: 'Cloud Setup' +originalFilePath: 'src/cloud_setup.md' +product: 'Cloud Native Operator' +--- + +This section describes how to orchestrate the deployment and management +of a PostgreSQL High Availability cluster in a [Kubernetes](https://www.kubernetes.io/) cluster in the public cloud using +[CustomResourceDefinitions](https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/) +such as `Cluster`. Like any other Kubernetes application, it is deployed +using regular manifests written in YAML. + +The Cloud Native PostgreSQL Operator is systematically tested on the following public cloud environments: + +- [Microsoft Azure Kubernetes Service (AKS)](https://azure.microsoft.com/en-in/services/kubernetes-service/) +- [Amazon Elastic Kubernetes Service (EKS)](https://aws.amazon.com/eks/) +- [Google Kubernetes Engine (GKE)](https://cloud.google.com/kubernetes-engine/) + +Below you can find specific instructions for each of the above environments. +Once the steps described on this page have been completed, and your `kubectl` +can connect to the desired cluster, you can install the operator and start +creating PostgreSQL `Clusters` by following the instructions you find in the +["Installation"](installation.md) section. + +!!! Important + `kubectl` is required to proceed with setup. + +## Microsoft Azure Kubernetes Service (AKS) + +Follow the instructions contained in +["Quickstart: Deploy an Azure Kubernetes Service (AKS) cluster using the Azure portal"](https://docs.microsoft.com/bs-latn-ba/azure/aks/kubernetes-walkthrough-portal) +available on the Microsoft documentation to set up your Kubernetes cluster in AKS. + +In particular, you need to configure `kubectl` to connect to your Kubernetes cluster +(called `myAKSCluster` using resources in `myResourceGroup` group) through the +`az aks get-credentials` command. +This command downloads the credentials and configures your `kubectl` to use them: + +```sh +az aks get-credentials --resource-group myResourceGroup --name myAKSCluster +``` + +!!! Note + You can change the name of the `myAKSCluster` cluster and the resource group `myResourceGroup` + from the Azure portal. + +You can use any of the storage classes that work with Azure disks: + +- `default` +- `managed-premium` + +!!! Seealso "About AKS storage classes" + For more information and details on the available storage classes in AKS, please refer to the + ["Storage classes" section in the official documentation from Microsoft](https://docs.microsoft.com/en-us/azure/aks/concepts-storage#storage-classes). + +## Amazon Elastic Kubernetes Service (EKS) + +Follow the instructions contained in +["Creating an Amazon EKS Cluster"](https://docs.aws.amazon.com/eks/latest/userguide/create-cluster.html) +available on the AWS documentation to set up your Kubernetes cluster in EKS. + +!!! Important + Keep in mind that Amazon puts limitations on how many pods a node can create. + It depends on the type of instance that you choose to use when you create + your cluster. + +After the setup, `kubectl` should point to your newly created EKS cluster. + +By default, a `gp2` storage class is available after cluster creation. However, Amazon EKS offers multiple +storage types that can be leveraged to create other storage classes for `Clusters`' volumes: + +- `gp2`: general-purpose SSD volume +- `io1`: provisioned IOPS SSD +- `st1`: throughput optimized HDD +- `sc1`: cold HDD + +!!! Seealso "About EKS storage classes" + For more information and details on the available storage classes in EKS, please refer to the + ["Amazon EBS Volume Types" page](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-volume-types.html) + in the official documentation for AWS and the + ["AWS-EBS" page](https://kubernetes.io/docs/concepts/storage/storage-classes/#aws-ebs) + in the Kubernetes documentation. + +## Google Kubernetes Engine (GKE) + +Follow the instructions contained in +["Creating a cluster"](https://cloud.google.com/kubernetes-engine/docs/how-to/creating-a-cluster) +available on the Google Cloud documentation to set up your Kubernetes cluster in GKE. + +!!! Warning + Google Kubernetes Engine uses the deprecated `kube-dns` server instead of the + recommended [CoreDNS](https://coredns.io/). To work with Cloud Native PostgreSQL Operator, + you need to disable `kube-dns` and replace it with `coredns`. + +To replace `kube-dns` with `coredns` in your GKE cluster, follow these instructions: + +```sh +kubectl scale --replicas=0 deployment/kube-dns-autoscaler --namespace=kube-system +kubectl scale --replicas=0 deployment/kube-dns --namespace=kube-system +git clone https://github.com/coredns/deployment.git +./deployment/kubernetes/deploy.sh | kubectl apply -f - +``` + +By default, a `standard` storage class is available after cluster creation, using +standard hard disks. For other storage types, you'll need to create specific +storage classes. + +!!! Seealso "About GKE storage classes" + For more information and details on the available storage types in GKE, please refer to the + ["GCE PD" section](https://kubernetes.io/docs/concepts/storage/storage-classes/#gce-pd) + of the Kubernetes documentation and the + ["Persistent volumes with Persistent Disks" page](https://cloud.google.com/kubernetes-engine/docs/concepts/persistent-volumes) + and related ones in the official documentation for Google Cloud. + diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/cnp-plugin.mdx b/advocacy_docs/kubernetes/cloud_native_postgresql/cnp-plugin.mdx new file mode 100644 index 00000000000..c0c89663bed --- /dev/null +++ b/advocacy_docs/kubernetes/cloud_native_postgresql/cnp-plugin.mdx @@ -0,0 +1,144 @@ +--- +title: 'Cloud Native PostgreSQL Plugin' +originalFilePath: 'src/cnp-plugin.md' +product: 'Cloud Native Operator' +--- + +Cloud Native PostgreSQL provides a plugin for `kubectl` to manage a cluster in Kubernetes. +The plugin also works with `oc` in an OpenShift environment. + +## Install + +You can install the plugin in your system with: + +```sh +curl -sSfL \ + https://github.com/EnterpriseDB/kubectl-cnp/raw/main/install.sh | \ + sudo sh -s -- -b /usr/local/bin +``` + +## Use + +Once the plugin was installed and deployed, you can start using it like this: + +```shell +kubectl cnp +``` + +### Status + +The `status` command provides a brief of the current status of your cluster. + +```shell +kubectl cnp status cluster-example +``` + +```shell +Cluster in healthy state +Name: cluster-example +Namespace: default +PostgreSQL Image: quay.io/enterprisedb/postgresql:13 +Primary instance: cluster-example-1 +Instances: 3 +Ready instances: 3 + +Instances status +Pod name Current LSN Received LSN Replay LSN System ID Primary Replicating Replay paused Pending restart +-------- ----------- ------------ ---------- --------- ------- ----------- ------------- --------------- +cluster-example-1 0/6000060 6927251808674721812 ✓ ✗ ✗ ✗ +cluster-example-2 0/6000060 0/6000060 6927251808674721812 ✗ ✓ ✗ ✗ +cluster-example-3 0/6000060 0/6000060 6927251808674721812 ✗ ✓ ✗ ✗ + +``` + +You can also get a more verbose version of the status by adding `--verbose` or just `-v` + +```shell +kubectl cnp status cluster-example --verbose +``` + +```shell +Cluster in healthy state +Name: cluster-example +Namespace: default +PostgreSQL Image: quay.io/enterprisedb/postgresql:13 +Primary instance: cluster-example-1 +Instances: 3 +Ready instances: 3 + +PostgreSQL Configuration +archive_command = '/controller/manager wal-archive %p' +archive_mode = 'on' +archive_timeout = '5min' +full_page_writes = 'on' +hot_standby = 'true' +listen_addresses = '*' +logging_collector = 'off' +max_parallel_workers = '32' +max_replication_slots = '32' +max_worker_processes = '32' +port = '5432' +ssl = 'on' +ssl_ca_file = '/tmp/ca.crt' +ssl_cert_file = '/tmp/server.crt' +ssl_key_file = '/tmp/server.key' +unix_socket_directories = '/var/run/postgresql' +wal_keep_size = '512MB' +wal_level = 'logical' +wal_log_hints = 'on' + + +PostgreSQL HBA Rules +# Grant local access +local all all peer + +# Require client certificate authentication for the streaming_replica user +hostssl postgres streaming_replica all cert clientcert=1 +hostssl replication streaming_replica all cert clientcert=1 + +# Otherwise use md5 authentication +host all all all md5 + + +Instances status +Pod name Current LSN Received LSN Replay LSN System ID Primary Replicating Replay paused Pending restart +-------- ----------- ------------ ---------- --------- ------- ----------- ------------- --------------- +cluster-example-1 0/6000060 6927251808674721812 ✓ ✗ ✗ ✗ +cluster-example-2 0/6000060 0/6000060 6927251808674721812 ✗ ✓ ✗ ✗ +cluster-example-3 0/6000060 0/6000060 6927251808674721812 ✗ ✓ ✗ ✗ +``` + +The command also supports output in `yaml` and `json` format. + +### Promote + +The meaning of this command is to `promote` a pod in the cluster to primary, so you +can start with maintenance work or test a switch-over situation in your cluster + +```shell +kubectl cnp promote cluster-example cluster-example-2 +``` + +### Certificates + +Clusters created using the Cloud Native PostgreSQL operator work with a CA to sign +a TLS authentication certificate. + +To get a certificate, you need to provide a name for the secret to store +the credentials, the cluster name, and a user for this certificate + +```shell +kubectl cnp certificate cluster-cert --cnp-cluster cluster-example --cnp-user appuser +``` + +After the secrete it's created, you can get it using `kubectl` + +```shell +kubectl get secret cluster-cert +``` + +And the content of the same in plain text using the following commands: + +```shell +kubectl get secret cluster-cert -o json | jq -r '.data | map(@base64d) | .[]' +``` diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/container_images.mdx b/advocacy_docs/kubernetes/cloud_native_postgresql/container_images.mdx new file mode 100644 index 00000000000..cb6f1125251 --- /dev/null +++ b/advocacy_docs/kubernetes/cloud_native_postgresql/container_images.mdx @@ -0,0 +1,57 @@ +--- +title: 'Container Image Requirements' +originalFilePath: 'src/container_images.md' +product: 'Cloud Native Operator' +--- + +The Cloud Native PostgreSQL operator for Kubernetes is designed to +work with any compatible container image of PostgreSQL that complies +with the following requirements: + +- PostgreSQL 10+ executables that must be in the path: + - `initdb` + - `postgres` + - `pg_ctl` + - `pg_controldata` + - `pg_basebackup` +- Barman Cloud executables that must be in the path: + - `barman-cloud-wal-archive` + - `barman-cloud-wal-restore` + - `barman-cloud-backup` + - `barman-cloud-restore` + - `barman-cloud-backup-list` +- Sensible locale settings + +No entry point and/or command is required in the image definition, as Cloud +Native PostgreSQL overrides it with its instance manager. + +!!! Warning + Application Container Images will be used by Cloud Native PostgreSQL + in a **Primary with multiple/optional Hot Standby Servers Architecture** + only. + +EnterpriseDB provides and supports public container images for Cloud Native +PostgreSQL and publishes them on [Quay.io](https://quay.io/repository/enterprisedb/postgresql). + +## Image tag requirements + +While the image name can be anything valid for Docker, the Cloud Native +PostgreSQL operator relies on the *image tag* to detect the Postgres major +version carried out by the image. + +The image tag must start with a valid PostgreSQL major version number (e.g. 9.6 +or 12) optionally followed by a dot and the patch level. + +The prefix can be followed by any valid character combination that is valid and +accepted in a Docker tag, preceded by a dot, an underscore, or a minus sign. + +Examples of accepted image tags: + +- `9.6.19-alpine` +- `12.4` +- `11_1` +- `13` +- `12.3.2.1-1` + +!!! Warning + `latest` is not considered a valid tag for the image. diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/credits.mdx b/advocacy_docs/kubernetes/cloud_native_postgresql/credits.mdx new file mode 100644 index 00000000000..9eaff9e1de0 --- /dev/null +++ b/advocacy_docs/kubernetes/cloud_native_postgresql/credits.mdx @@ -0,0 +1,23 @@ +--- +title: 'Credits' +originalFilePath: 'src/credits.md' +product: 'Cloud Native Operator' +--- + +Cloud Native PostgreSQL (Operator for Kubernetes/OpenShift) has been designed, +developed, and tested by the EnterpriseDB Cloud Native team: + +- Gabriele Bartolini +- Jonathan Battiato +- Francesco Canovai +- Leonardo Cecchi +- Valerio Del Sarto +- Niccolò Fei +- Jonathan Gonzalez +- Danish Khan +- Anand Nednur +- Marco Nenciarini +- Gabriele Quaresima +- Jitendra Wadle +- Adam Wright + diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/e2e.mdx b/advocacy_docs/kubernetes/cloud_native_postgresql/e2e.mdx new file mode 100644 index 00000000000..8d69486b837 --- /dev/null +++ b/advocacy_docs/kubernetes/cloud_native_postgresql/e2e.mdx @@ -0,0 +1,57 @@ +--- +title: 'End-to-End Tests' +originalFilePath: 'src/e2e.md' +product: 'Cloud Native Operator' +--- + +Cloud Native PostgreSQL operator is automatically tested after each +commit via a suite of **End-to-end (E2E) tests**. It ensures that +the operator correctly deploys and manages the PostgreSQL clusters. + +Moreover, the following Kubernetes versions are tested for each commit, +ensuring failure and bugs detection at an early stage of the development +process: + +* 1.20 +* 1.19 +* 1.18 +* 1.17 +* 1.16 + +The following PostgreSQL versions are tested: + +* PostgreSQL 13 +* PostgreSQL 12 +* PostgreSQL 11 +* PostgreSQL 10 + +For each tested version of Kubernetes and PostgreSQL, a Kubernetes +cluster is created using [kind](https://kind.sigs.k8s.io/), +and the following suite of E2E tests are performed on that cluster: + +* Installation of the operator; +* Creation of a `Cluster`; +* Usage of a persistent volume for data storage; +* Connection via services, including read-only; +* Scale-up of a `Cluster`; +* Scale-down of a `Cluster`; +* Failover; +* Switchover; +* Manage PostgreSQL configuration changes; +* Rolling updates when changing PostgreSQL images; +* Backup and ScheduledBackups execution; +* Synchronous replication; +* Restore from backup; +* Pod affinity using `NodeSelector`; +* Metrics collection; +* Operator pod deletion; +* Primary endpoint switch in case of failover in less than 10 seconds; +* Primary endpoint switch in case of switchover in less than 20 seconds; +* Recover from a degraded state in less than 60 seconds. + +The E2E tests suite is also run for OpenShift 4.6 and the latest Kubernetes +and PostgreSQL releases on clusters created on the following services: + +* Google GKE +* Amazon EKS +* Microsoft Azure AKS diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/evaluation.mdx b/advocacy_docs/kubernetes/cloud_native_postgresql/evaluation.mdx new file mode 100644 index 00000000000..13c0ada93b5 --- /dev/null +++ b/advocacy_docs/kubernetes/cloud_native_postgresql/evaluation.mdx @@ -0,0 +1,41 @@ +--- +title: 'Free evaluation' +originalFilePath: 'src/evaluation.md' +product: 'Cloud Native Operator' +--- + +Cloud Native PostgreSQL is available for a free evaluation. +The process is different between Vanilla/Community PostgreSQL +and EDB Postgres Advanced. + +Please refer to the ["License and License keys" section](license_keys.md) +for terms and more details. + +## Evaluating PostgreSQL + +By default, Cloud Native PostgreSQL installs the latest available +version of Community PostgreSQL. The operator will automatically +generate an implicit trial license for the cluster that lasts for +30 days. + +This license is ideal for evaluation, proof of concept, integration with CI/CD pipelines, and so on. + +PostgreSQL container images are available at +[quay.io/enterprisedb/postgresql](https://quay.io/repository/enterprisedb/postgresql). + +## Evaluating EDB Postgres Advanced + +You can use Cloud Native PostgreSQL with EDB Postgres Advanced +too. You need to request a trial license key from the +[EnterpriseDB website](https://cloud-native.enterprisedb.com). + +EDB Postgres Advanced container images are available at +[quay.io/enterprisedb/edb-postgres-advanced](https://quay.io/repository/enterprisedb/edb-postgres-advanced). + +Once you have received the license key, you can use EDB Postgres Advanced +by setting in the `spec` section of the `Cluster` deployment configuration file: + +- `imageName` to point to the `quay.io/enterprisedb/edb-postgres-advanced` repository +- `licenseKey` to your license key (in the form of a string) + +Please refer to the full example in the [configuration samples](samples.md) section. diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/expose_pg_services.mdx b/advocacy_docs/kubernetes/cloud_native_postgresql/expose_pg_services.mdx new file mode 100644 index 00000000000..bca1c0e31ce --- /dev/null +++ b/advocacy_docs/kubernetes/cloud_native_postgresql/expose_pg_services.mdx @@ -0,0 +1,147 @@ +--- +title: 'Exposing Postgres Services' +originalFilePath: 'src/expose_pg_services.md' +product: 'Cloud Native Operator' +--- + +This section explains how to expose a PostgreSQL service externally, allowing access +to your PostgreSQL database **from outside your Kubernetes cluster** using +NGINX Ingress Controller. + +If you followed the [QuickStart](./quickstart.md), you should have by now +a database that can be accessed inside the cluster via the +`cluster-example-rw` (primary) and `cluster-example-r` (read-only) +services in the `default` namespace. Both services use port `5432`. + +Let's assume that you want to make the primary instance accessible from external +accesses on port `5432`. A typical use case, when moving to a Kubernetes +infrastructure, is indeed the one represented by **legacy applications** +that cannot be easily or sustainably "containerized". A sensible workaround +is to allow those applications that most likely reside in a virtual machine +or a physical server, to access a PostgreSQL database inside a Kubernetes cluster +in the same network. + +!!! Warning + Allowing access to a database from the public network could expose + your database to potential attacks from malicious users. Ensure you + secure your database before granting external access or that your + Kubernetes cluster is only reachable from a private network. + +For this example, you will use [NGINX Ingress Controller](https://kubernetes.github.io/ingress-nginx/), +since it is maintained directly by the Kubernetes project and can be set up +on every Kubernetes cluster. Many other controllers are available (see the +[Kubernetes documentation](https://kubernetes.io/docs/concepts/services-networking/ingress-controllers/) +for a comprehensive list). + +We assume that: + +* the NGINX Ingress controller has been deployed and works correctly +* it is possible to create a service of type `LoadBalancer` in your cluster + + +!!! Important + Ingresses are only required to expose HTTP and HTTPS traffic. While the NGINX + Ingress controller can, not all Ingress objects can expose arbitrary ports or + protocols. + +The first step is to create a `tcp-services` `ConfigMap` whose data field +contains info on the externally exposed port and the namespace, service and +port to point to internally. + +```yaml +apiVersion: v1 +kind: ConfigMap +metadata: + name: tcp-services + namespace: ingress-nginx +data: + 5432: default/cluster-example-rw:5432 +``` + +Then, if you've installed NGINX Ingress Controller as suggested in their +documentation, you should have an `ingress-nginx` service. You'll have to add +the 5432 port to the `ingress-nginx` service to expose it. +The ingress will redirect incoming connections on port 5432 to your database. + +```yaml +apiVersion: v1 +kind: Service +metadata: + name: ingress-nginx + namespace: ingress-nginx + labels: + app.kubernetes.io/name: ingress-nginx + app.kubernetes.io/part-of: ingress-nginx +spec: + type: LoadBalancer + ports: + - name: http + port: 80 + targetPort: 80 + protocol: TCP + - name: https + port: 443 + targetPort: 443 + protocol: TCP + - name: postgres + port: 5432 + targetPort: 5432 + protocol: TCP + selector: + app.kubernetes.io/name: ingress-nginx + app.kubernetes.io/part-of: ingress-nginx +``` + +You can use [`cluster-expose-service.yaml`](../samples/cluster-expose-service.yaml) and apply it +using `kubectl`. + +!!! Warning + If you apply this file directly, you will overwrite any previous change + in your `ConfigMap` and `Service` of the Ingress + +Now you will be able to reach the PostgreSQL Cluster from outside your Kubernetes cluster. + +!!! Important + Make sure you configure `pg_hba` to allow connections from the Ingress. + +## Testing on Minikube + +On Minikube you can setup the ingress controller running: + +```sh +minikube addons enable ingress +``` + +Then, patch the `tcp-service` ConfigMap to redirect to the primary the +connections on port 5432 of the Ingress: + +```sh +kubectl patch configmap tcp-services -n kube-system \ + --patch '{"data":{"5432":"default/cluster-example-rw:5432"}}' +``` + +You can then patch the deployment to allow access on port 5432. +Create a file called `patch.yaml` with the following content: + +```yaml +spec: + template: + spec: + containers: + - name: nginx-ingress-controller + ports: + - containerPort: 5432 + hostPort: 5432 +``` + +and apply it to the `nginx-ingress-controller deployment`: + +```sh +kubectl patch deployment nginx-ingress-controller --patch "$(cat patch.yaml)" -n kube-system +``` + +You can access the primary from your machine running: + +```sh +psql -h $(minikube ip) -p 5432 -U postgres +``` diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/failure_modes.mdx b/advocacy_docs/kubernetes/cloud_native_postgresql/failure_modes.mdx new file mode 100644 index 00000000000..38c30061989 --- /dev/null +++ b/advocacy_docs/kubernetes/cloud_native_postgresql/failure_modes.mdx @@ -0,0 +1,156 @@ +--- +title: 'Failure Modes' +originalFilePath: 'src/failure_modes.md' +product: 'Cloud Native Operator' +--- + +This section provides an overview of the major failure scenarios that +PostgreSQL can face on a Kubernetes cluster during its lifetime. + +!!! Important + In case the failure scenario you are experiencing is not covered by this + section, please immediately contact EnterpriseDB for support and assistance. + +## Liveness and readiness probes + +Each pod of a `Cluster` has a `postgres` container with a **liveness** +and a **readiness** +[probe](https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#container-probes). + +The liveness and readiness probes check if the database is up and able to accept +connections using the superuser credentials. +The two probes will report a failure if the probe command fails 3 times with a +10 seconds interval between each check. + +For now, the operator doesn't configure a `startupProbe` on the Pods, since +startup probes have been introduced only in Kubernetes 1.17. + +The liveness probe is used to detect if the PostgreSQL instance is in a +broken state and needs to be restarted. The value in `startDelay` is used +to delay the probe's execution, which is used to prevent an +instance with a long startup time from being restarted. + +## Storage space usage + +The operator will instantiate one PVC for every PostgreSQL instance to store the `PGDATA` content. + +Such storage space is set for reuse in two cases: + +- when the corresponding Pod is deleted by the user (and a new Pod will be recreated) +- when the corresponding Pod is evicted and scheduled on another node + +If you want to prevent the operator from reusing a certain PVC you need to +remove the PVC before deleting the Pod. For this purpose, you can use the +following command: + +```sh +kubectl delete -n [namespace] pvc/[cluster-name]-[serial] --wait=false +kubectl delete -n [namespace] pod/[cluster-name]-[serial] +``` + +For example: + +```sh +$ kubectl delete -n default pvc/cluster-example-1 --wait=false +persistentvolumeclaim "cluster-example-1" deleted + +$ kubectl delete -n default pod/cluster-example-1 +pod "cluster-example-1" deleted +``` + +## Failure modes + +A pod belonging to a `Cluster` can fail in the following ways: + +* the pod is explicitly deleted by the user; +* the readiness probe on its `postgres` container fails; +* the liveness probe on its `postgres` container fails; +* the Kubernetes worker node is drained; +* the Kubernetes worker node where the pod is scheduled fails. + +Each one of these failures has different effects on the `Cluster` and the +services managed by the operator. + +### Pod deleted by the user + +The operator is notified of the deletion. A new pod belonging to the +`Cluster` will be automatically created reusing the existing PVC, if available, +or starting from a physical backup of the *primary* otherwise. + +!!! Important + In case of deliberate deletion of a pod, `PodDisruptionBudget` policies + will not be enforced. + +Self-healing will happen as soon as the *apiserver* is notified. + +### Readiness probe failure + +After 3 failures, the pod will be considered *not ready*. The pod will still +be part of the `Cluster`, no new pod will be created. + +If the cause of the failure can't be fixed, it is possible to delete the pod +manually. Otherwise, the pod will resume the previous role when the failure +is solved. + +Self-healing will happen after three failures of the probe. + +### Liveness probe failure + +After 3 failures, the `postgres` container will be considered failed. The +pod will still be part of the `Cluster`, and the *kubelet* will try to restart +the container. If the cause of the failure can't be fixed, it is possible +to delete the pod manually. + +Self-healing will happen after three failures of the probe. + +### Worker node drained + +The pod will be evicted from the worker node and removed from the service. A +new pod will be created on a different worker node from a physical backup of the +*primary* if the `reusePVC` option of the `nodeMaintenanceWindow` parameter +is set to `off` (default: `on` during maintenance windows, `off` otherwise). + +The `PodDisruptionBudget` may prevent the pod from being evicted if there +is at least one node that is not ready. + +Self-healing will happen as soon as the *apiserver* is notified. + +### Worker node failure + +Since the node is failed, the *kubelet* won't execute the liveness and +the readiness probes. The pod will be marked for deletion after the +toleration seconds configured by the Kubernetes cluster administrator for +that specific failure cause. Based on how the Kubernetes cluster is configured, +the pod might be removed from the service earlier. + +A new pod will be created on a different worker node from a physical backup +of the *primary*. The default value for that parameter in a Kubernetes +cluster is 5 minutes. + +Self-healing will happen after `tolerationSeconds`. + +## Self-healing + +If the failed pod is a standby, the pod is removed from the `-r` service +and from the `-ro` service. +The pod is then restarted using its PVC if available; otherwise, a new +pod will be created from a backup of the current primary. The pod +will be added again to the `-r` service and to the `-ro` service when ready. + +If the failed pod is the primary, the operator will promote the active pod +with status ready and the lowest replication lag, then point the `-rw`service +to it. The failed pod will be removed from the `-r` service and from the +`-ro` service. +Other standbys will start replicating from the new primary. The former +primary will use `pg_rewind` to synchronize itself with the new one if its +PVC is available; otherwise, a new standby will be created from a backup of the +current primary. + +## Manual intervention + +In the case of undocumented failure, it might be necessary to intervene +to solve the problem manually. + +!!! Important + In such cases, please do not perform any manual operation without the + support and assistance of EnterpriseDB engineering team. diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/images/apps-in-k8s.png b/advocacy_docs/kubernetes/cloud_native_postgresql/images/apps-in-k8s.png new file mode 100644 index 00000000000..7caff576b5e Binary files /dev/null and b/advocacy_docs/kubernetes/cloud_native_postgresql/images/apps-in-k8s.png differ diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/images/apps-outside-k8s.png b/advocacy_docs/kubernetes/cloud_native_postgresql/images/apps-outside-k8s.png new file mode 100644 index 00000000000..af7051bd473 Binary files /dev/null and b/advocacy_docs/kubernetes/cloud_native_postgresql/images/apps-outside-k8s.png differ diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/images/architecture-in-k8s.png b/advocacy_docs/kubernetes/cloud_native_postgresql/images/architecture-in-k8s.png new file mode 100644 index 00000000000..fe256373d25 Binary files /dev/null and b/advocacy_docs/kubernetes/cloud_native_postgresql/images/architecture-in-k8s.png differ diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/images/architecture-r.png b/advocacy_docs/kubernetes/cloud_native_postgresql/images/architecture-r.png new file mode 100644 index 00000000000..533de16a6f0 Binary files /dev/null and b/advocacy_docs/kubernetes/cloud_native_postgresql/images/architecture-r.png differ diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/images/architecture-read-only.png b/advocacy_docs/kubernetes/cloud_native_postgresql/images/architecture-read-only.png new file mode 100644 index 00000000000..85a11f18568 Binary files /dev/null and b/advocacy_docs/kubernetes/cloud_native_postgresql/images/architecture-read-only.png differ diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/images/architecture-rw.png b/advocacy_docs/kubernetes/cloud_native_postgresql/images/architecture-rw.png new file mode 100644 index 00000000000..c4d95b9826a Binary files /dev/null and b/advocacy_docs/kubernetes/cloud_native_postgresql/images/architecture-rw.png differ diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/images/network-storage-architecture.png b/advocacy_docs/kubernetes/cloud_native_postgresql/images/network-storage-architecture.png new file mode 100644 index 00000000000..6acbb881ab9 Binary files /dev/null and b/advocacy_docs/kubernetes/cloud_native_postgresql/images/network-storage-architecture.png differ diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/images/operator-capability-level.png b/advocacy_docs/kubernetes/cloud_native_postgresql/images/operator-capability-level.png new file mode 100644 index 00000000000..45e6439c632 Binary files /dev/null and b/advocacy_docs/kubernetes/cloud_native_postgresql/images/operator-capability-level.png differ diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/images/public-cloud-architecture-storage-replication.png b/advocacy_docs/kubernetes/cloud_native_postgresql/images/public-cloud-architecture-storage-replication.png new file mode 100644 index 00000000000..f71025ef9a6 Binary files /dev/null and b/advocacy_docs/kubernetes/cloud_native_postgresql/images/public-cloud-architecture-storage-replication.png differ diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/images/public-cloud-architecture.png b/advocacy_docs/kubernetes/cloud_native_postgresql/images/public-cloud-architecture.png new file mode 100644 index 00000000000..06d20eb0721 Binary files /dev/null and b/advocacy_docs/kubernetes/cloud_native_postgresql/images/public-cloud-architecture.png differ diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/images/shared-nothing-architecture.png b/advocacy_docs/kubernetes/cloud_native_postgresql/images/shared-nothing-architecture.png new file mode 100644 index 00000000000..1cde6413492 Binary files /dev/null and b/advocacy_docs/kubernetes/cloud_native_postgresql/images/shared-nothing-architecture.png differ diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/index.mdx b/advocacy_docs/kubernetes/cloud_native_postgresql/index.mdx new file mode 100644 index 00000000000..befdeef638c --- /dev/null +++ b/advocacy_docs/kubernetes/cloud_native_postgresql/index.mdx @@ -0,0 +1,122 @@ +--- +title: 'Cloud Native PostgreSQL' +originalFilePath: 'src/index.md' +product: 'Cloud Native Operator' +indexCards: none +directoryDefaults: + prevNext: true + iconName: kubernetes + +navigation: + - index + - before_you_start + - evaluation + - use_cases + - architecture + - installation + - quickstart + - interactive_demo + - cloud_setup + - bootstrap + - resource_management + - security + - failure_modes + - rolling_update + - backup_recovery + - postgresql_conf + - operator_conf + - storage + - labels_annotations + - samples + - monitoring + - expose_pg_services + - ssl_connections + - kubernetes_upgrade + - e2e + - cnp-plugin + - license_keys + - container_images + - operator_capability_levels + - api_reference + - release_notes + - credits + +--- + +**Cloud Native PostgreSQL** is an [operator](https://kubernetes.io/docs/concepts/extend-kubernetes/operator/) +designed by [EnterpriseDB](https://www.enterprisedb.com) +to manage [PostgreSQL](https://www.postgresql.org/) workloads on any supported [Kubernetes](https://kubernetes.io) +cluster running in private, public, or hybrid cloud environments. +Cloud Native PostgreSQL adheres to DevOps principles and concepts +such as declarative configuration and immutable infrastructure. + +It defines a new Kubernetes resource called "Cluster" representing a PostgreSQL +cluster made up of a single primary and an optional number of replicas that co-exist +in a chosen Kubernetes namespace for High Availability and offloading of +read-only queries. + +Applications that reside in the same Kubernetes cluster can access the +PostgreSQL database using a service which is solely managed by the operator, +without having to worry about changes of the primary role following a failover +or a switchover. Applications that reside outside the Kubernetes cluster, need +to configure an Ingress object to expose the service via TCP. + +Cloud Native PostgreSQL works with PostgreSQL and [EDB Postgres Advanced](https://www.enterprisedb.com/products/edb-postgres-advanced-server-secure-ha-oracle-compatible) +and is available under the [EnterpriseDB Limited Use License](https://www.enterprisedb.com/limited-use-license). + +You can [evaluate Cloud Native PostgreSQL for free](evaluation.md). +You need a valid license key to use Cloud Native PostgreSQL in production. + +!!! Important + Currently, based on the [Operator Capability Levels model](operator_capability_levels.md), + users can expect a **"Level III - Full Lifecycle"** set of capabilities from the + Cloud Native PostgreSQL Operator. + +## Requirements + +Cloud Native PostgreSQL requires Kubernetes 1.16 or higher, tested on AWS, Google, Azure (with multiple availability zones). + +Cloud Native PostgreSQL has also been certified for +[RedHat OpenShift Container Platform (OCP)](https://www.openshift.com/products/container-platform) +4.5+ and is available directly from the [RedHat Catalog](https://catalog.redhat.com/). +OpenShift Container Platform is an open-source distribution of Kubernetes which is +[maintained and commercially supported](https://access.redhat.com/support/policy/updates/openshift#ocp4) +by Red Hat. + +## Supported PostgreSQL versions + +PostgreSQL and EDB Postgres Advanced 13, 12, 11 and 10 are currently supported. + +## Main features + +* Direct integration with Kubernetes API server for High Availability, + without requiring an external tool +* Self-Healing capability, through: + * failover of the primary instance by promoting the most aligned replica + * automated recreation of a replica +* Planned switchover of the primary instance by promoting a selected replica +* Scale up/down capabilities +* Definition of an arbitrary number of instances (minimum 1 - one primary server) +* Definition of the *read-write* service, to connect your applications to the only primary server of the cluster +* Definition of the *read-only* service, to connect your applications to any of the instances for reading workloads +* Support for Local Persistent Volumes with PVC templates +* Reuse of Persistent Volumes storage in Pods +* Rolling updates for PostgreSQL minor versions and operator upgrades +* TLS connections and client certificate authentication +* Continuous backup to an S3 compatible object store +* Full recovery and Point-In-Time recovery from an S3 compatible object store backup +* Support for Synchronous Replicas +* Support for node affinity via `nodeSelector` +* Standard output logging of PostgreSQL error messages + +## About this guide + +Follow the instructions in the ["Quickstart"](quickstart.md) to test Cloud Native PostgreSQL +on a local Kubernetes cluster using Minikube or Kind. + +In case you are not familiar with some basic terminology on Kubernetes and PostgreSQL, +please consult the ["Before you start" section](before_you_start.md). + +!!! Note + Although the guide primarily addresses Kubernetes, all concepts can + be extended to OpenShift as well. diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/installation.mdx b/advocacy_docs/kubernetes/cloud_native_postgresql/installation.mdx new file mode 100644 index 00000000000..64ce5f8b0a0 --- /dev/null +++ b/advocacy_docs/kubernetes/cloud_native_postgresql/installation.mdx @@ -0,0 +1,100 @@ +--- +title: 'Installation' +originalFilePath: 'src/installation.md' +product: 'Cloud Native Operator' +--- + +## Installation on Kubernetes + +### Directly using the operator manifest + +The operator can be installed like any other resource in Kubernetes, +through a YAML manifest applied via `kubectl`. + +You can install the [latest operator manifest](https://get.enterprisedb.io/cnp/postgresql-operator-1.3.0.yaml) +as follows: + +```sh +kubectl apply -f \ + https://get.enterprisedb.io/cnp/postgresql-operator-1.3.0.yaml +``` + +Once you have run the `kubectl` command, Cloud Native PostgreSQL will be installed in your Kubernetes cluster. + +You can verify that with: + +```sh +kubectl get deploy -n postgresql-operator-system postgresql-operator-controller-manager +``` + +### Using the Operator Lifecycle Manager (OLM) + +OperatorHub is a community-sourced index of operators available via the +[Operator Lifecycle Manager](https://github.com/operator-framework/operator-lifecycle-manager), +which is a package managing system for operators. + +You can install Cloud Native PostgreSQL using the metadata available in the +[Cloud Native PostgreSQL page](https://operatorhub.io/operator/cloud-native-postgresql) +from the [OperatorHub.io website](https://operatorhub.io), following the installation steps listed on that page. + +## Installation on Openshift + +### Via the web interface + +Log in to the console as `kubeadmin` and navigate to the `Operator → OperatorHub` page. + +Find the `Cloud Native PostgreSQL` box scrolling or using the search filter. + +Select the operator and click `Install`. Click `Install` again in the following +`Install Operator`, using the default settings. For an in-depth explanation of +those settings, see the [Openshift documentation](https://docs.openshift.com/container-platform/4.6/operators/admin/olm-adding-operators-to-cluster.html#olm-installing-from-operatorhub-using-web-console_olm-adding-operators-to-a-cluster). + +The operator will soon be available in all the namespaces. + +Depending on the security levels applied to the OpenShift cluster you may be +required to create a proper set of roles and permissions for the operator to +be used in different namespaces. +For more information on this matter see the +[Openshift documentation](https://docs.openshift.com/container-platform/4.6/operators/understanding/olm/olm-understanding-operatorgroups.html). + +### Via the `oc` command line + +You can add the [`subscription`](../samples/subscription.yaml) to install the operator in all the namespaces +as follows: + +```sh +oc apply -f \ + https://docs.enterprisedb.io/cloud-native-postgresql/latest/samples/subscription.yaml +``` + +The operator will soon be available in all the namespaces. + +More information on +[how to install operators via CLI](https://docs.openshift.com/container-platform/4.6/operators/admin/olm-adding-operators-to-cluster.html#olm-installing-operator-from-operatorhub-using-cli_olm-adding-operators-to-a-cluster) +is available in the Openshift documentation. + +## Details about the deployment + +In Kubernetes, the operator is by default installed in the `postgresql-operator-system` namespace as a Kubernetes +`Deployment` called `postgresql-operator-controller-manager`. You can get more information by running: + +```sh +kubectl describe deploy -n postgresql-operator-system postgresql-operator-controller-manager +``` + +As any deployment, it sits on top of a replica set and supports rolling upgrades. +By default, we currently support only 1 replica. In future versions we plan to +support multiple replicas and leader election, as well as taints and tolerations +so to enable deployment on the Kubernetes control plane. + +In case the node where the pod is running is not reachable anymore, +the pod will be rescheduled on another node. + +As far as OpenShift is concerned, details might differ depending on the +selected installation method. + +!!! Seealso "Operator configuration" + You can change the default behavior of the operator by overriding + some default options. For more information, please refer to the + ["Operator configuration"](operator_conf.md) section. + diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/interactive_demo.mdx b/advocacy_docs/kubernetes/cloud_native_postgresql/interactive_demo.mdx new file mode 100644 index 00000000000..1256c5d2db7 --- /dev/null +++ b/advocacy_docs/kubernetes/cloud_native_postgresql/interactive_demo.mdx @@ -0,0 +1,343 @@ +--- +title: "Installation, Configuration and Deployment Demo" +description: "Walk through the process of installing, configuring and deploying the Cloud Native PostgreSQL Operator via a browser-hosted Minikube console" +navTitle: Install, Configure, Deploy +product: 'Cloud Native PostgreSQL Operator' +platform: ubuntu +tags: + - postgresql + - cloud-native-postgresql-operator + - kubernetes + - minikube + - live-demo +katacodaPanel: + scenario: minikube + codelanguages: shell, yaml +showInteractiveBadge: true +--- + +Want to see what it takes to get the Cloud Native PostgreSQL Operator up and running? This section will demonstrate the following: + +1. Installing the Cloud Native PostgreSQL Operator +2. Deploying a three-node PostgreSQL cluster +3. Installing and using the kubectl-cnp plugin +4. Testing failover to verify the resilience of the cluster + +It will take roughly 5-10 minutes to work through. + +!!!interactive This demo is interactive + You can follow along right in your browser by clicking the button below. Once the environment initializes, you'll see a terminal open at the bottom of the screen. + + + +[Minikube](https://kubernetes.io/docs/setup/learning-environment/minikube/) is already installed in this environment; we just need to start the cluster: + +```shell +minikube start +__OUTPUT__ +* minikube v1.8.1 on Ubuntu 18.04 +* Using the none driver based on user configuration +* Running on localhost (CPUs=2, Memory=2460MB, Disk=145651MB) ... +* OS release is Ubuntu 18.04.4 LTS +* Preparing Kubernetes v1.17.3 on Docker 19.03.6 ... + - kubelet.resolv-conf=/run/systemd/resolve/resolv.conf +* Launching Kubernetes ... +* Enabling addons: default-storageclass, storage-provisioner +* Configuring local host environment ... +* Waiting for cluster to come online ... +* Done! kubectl is now configured to use "minikube" +``` + +This will create the Kubernetes cluster, and you will be ready to use it. +Verify that it works with the following command: + +```shell +kubectl get nodes +__OUTPUT__ +NAME STATUS ROLES AGE VERSION +minikube Ready master 66s v1.17.3 +``` + +You will see one node called `minikube`. If the status isn't yet "Ready", wait for a few seconds and run the command above again. + +## Install Cloud Native PostgreSQL + +Now that the Minikube cluster is running, you can proceed with Cloud Native PostgreSQL installation as described in the ["Installation"](installation.md) section: + +```shell +kubectl apply -f https://get.enterprisedb.io/cnp/postgresql-operator-1.3.0.yaml +__OUTPUT__ +namespace/postgresql-operator-system created +customresourcedefinition.apiextensions.k8s.io/backups.postgresql.k8s.enterprisedb.io created +customresourcedefinition.apiextensions.k8s.io/clusters.postgresql.k8s.enterprisedb.io created +customresourcedefinition.apiextensions.k8s.io/scheduledbackups.postgresql.k8s.enterprisedb.io created +mutatingwebhookconfiguration.admissionregistration.k8s.io/postgresql-operator-mutating-webhook-configuration created +serviceaccount/postgresql-operator-manager created +clusterrole.rbac.authorization.k8s.io/postgresql-operator-manager created +clusterrolebinding.rbac.authorization.k8s.io/postgresql-operator-manager-rolebinding created +service/postgresql-operator-webhook-service created +deployment.apps/postgresql-operator-controller-manager created +validatingwebhookconfiguration.admissionregistration.k8s.io/postgresql-operator-validating-webhook-configuration created +``` + +And then verify that it was successfully installed: + +```shell +kubectl get deploy -n postgresql-operator-system postgresql-operator-controller-manager +__OUTPUT__ +NAME READY UP-TO-DATE AVAILABLE AGE +postgresql-operator-controller-manager 1/1 1 1 52s +``` + +## Deploy a PostgreSQL cluster + +As with any other deployment in Kubernetes, to deploy a PostgreSQL cluster +you need to apply a configuration file that defines your desired `Cluster`. + +The [`cluster-example.yaml`](../samples/cluster-example.yaml) sample file +defines a simple `Cluster` using the default storage class to allocate +disk space: + +```yaml +cat < cluster-example.yaml +# Example of PostgreSQL cluster +apiVersion: postgresql.k8s.enterprisedb.io/v1 +kind: Cluster +metadata: + name: cluster-example +spec: + instances: 3 + + # Example of rolling update strategy: + # - unsupervised: automated update of the primary once all + # replicas have been upgraded (default) + # - supervised: requires manual supervision to perform + # the switchover of the primary + primaryUpdateStrategy: unsupervised + + # Require 1Gi of space + storage: + size: 1Gi +EOF +``` + +!!! Note "There's more" + For more detailed information about the available options, please refer + to the ["API Reference" section](api_reference.md). + +In order to create the 3-node PostgreSQL cluster, you need to run the following command: + +```shell +kubectl apply -f cluster-example.yaml +__OUTPUT__ +cluster.postgresql.k8s.enterprisedb.io/cluster-example created +``` + +You can check that the pods are being created with the `get pods` command. It'll take a bit to initialize, so if you run that +immediately after applying the cluster configuration you'll see the status as `Init:` or `PodInitializing`: + +```shell +kubectl get pods +__OUTPUT__ +NAME READY STATUS RESTARTS AGE +cluster-example-1-initdb-kq2vw 0/1 PodInitializing 0 18s +``` + +...give it a minute, and then check on it again: + +```shell +kubectl get pods +__OUTPUT__ +NAME READY STATUS RESTARTS AGE +cluster-example-1 1/1 Running 0 56s +cluster-example-2 1/1 Running 0 35s +cluster-example-3 1/1 Running 0 19s +``` + +Now we can check the status of the cluster: + +```shell +kubectl get cluster cluster-example -o yaml +__OUTPUT__ +apiVersion: postgresql.k8s.enterprisedb.io/v1 +kind: Cluster +metadata: + annotations: + kubectl.kubernetes.io/last-applied-configuration: | + {"apiVersion":"postgresql.k8s.enterprisedb.io/v1","kind":"Cluster","metadata":{"annotations":{},"name":"cluster-example","namespace":"default"},"spec":{"instances":3,"primaryUpdateStrategy":"unsupervised","storage":{"size":"1Gi"}}} + creationTimestamp: "2021-04-27T15:11:21Z" + generation: 1 + name: cluster-example + namespace: default + resourceVersion: "2572" + selfLink: /apis/postgresql.k8s.enterprisedb.io/v1/namespaces/default/clusters/cluster-example + uid: 6a693046-a9d0-41b0-ac68-7a96d7e2ff07 +spec: + affinity: + topologyKey: "" + bootstrap: + initdb: + database: app + owner: app + imageName: quay.io/enterprisedb/postgresql:13.2 + instances: 3 + postgresql: + parameters: + logging_collector: "off" + max_parallel_workers: "32" + max_replication_slots: "32" + max_worker_processes: "32" + wal_keep_size: 512MB + primaryUpdateStrategy: unsupervised + resources: {} + storage: + size: 1Gi +status: + currentPrimary: cluster-example-1 + instances: 3 + instancesStatus: + healthy: + - cluster-example-1 + - cluster-example-2 + - cluster-example-3 + latestGeneratedNode: 3 + licenseStatus: + isImplicit: true + isTrial: true + licenseExpiration: "2021-05-27T15:11:21Z" + licenseStatus: Implicit trial license + repositoryAccess: false + valid: true + phase: Cluster in healthy state + pvcCount: 3 + readService: cluster-example-r + readyInstances: 3 + secretsResourceVersion: + applicationSecretVersion: "1479" + caSecretVersion: "1475" + replicationSecretVersion: "1477" + serverSecretVersion: "1476" + superuserSecretVersion: "1478" + targetPrimary: cluster-example-1 + writeService: cluster-example-rw +``` + +!!! Note + By default, the operator will install the latest available minor version + of the latest major version of PostgreSQL when the operator was released. + You can override this by setting [the `imageName` key in the `spec` section of + the `Cluster` definition](api_reference/#clusterspec). + +!!! Important + The immutable infrastructure paradigm requires that you always + point to a specific version of the container image. + Never use tags like `latest` or `13` in a production environment + as it might lead to unpredictable scenarios in terms of update + policies and version consistency in the cluster. + +## Install the kubectl-cnp plugin + +Cloud Native PostgreSQL provides a plugin for kubectl to manage a cluster in Kubernetes, along with a script to install it: + +```shell +curl -sSfL \ + https://github.com/EnterpriseDB/kubectl-cnp/raw/main/install.sh | \ + sudo sh -s -- -b /usr/local/bin +__OUTPUT__ +EnterpriseDB/kubectl-cnp info checking GitHub for latest tag +EnterpriseDB/kubectl-cnp info found version: 1.3.0 for v1.3.0/linux/x86_64 +EnterpriseDB/kubectl-cnp info installed /usr/local/bin/kubectl-cnp +``` + +The `cnp` command is now available in kubectl: + +```shell +kubectl cnp status cluster-example +__OUTPUT__ +Cluster in healthy state +Name: cluster-example +Namespace: default +PostgreSQL Image: quay.io/enterprisedb/postgresql:13.2 +Primary instance: cluster-example-1 +Instances: 3 +Ready instances: 3 + +Instances status +Pod name Current LSN Received LSN Replay LSN System ID Primary Replicating Replay paused Pending restart Status +-------- ----------- ------------ ---------- --------- ------- ----------- ------------- --------------- ------ +cluster-example-1 0/5000060 6955855494195015697 ✓ ✗ ✗ ✗ OK +cluster-example-2 0/5000060 0/5000060 6955855494195015697 ✗ ✓ ✗ ✗ OK +cluster-example-3 0/5000060 0/5000060 6955855494195015697 ✗ ✓ ✗ ✗ OK +``` + +!!! Note "There's more" + See [the Cloud Native PostgreSQL Plugin page](cnp-plugin/) for more commands and options. + +## Testing failover + +As our status checks show, we're running two replicas - if something happens to the primary instance of PostgreSQL, the cluster will fail over to one of them. Let's demonstrate this by killing the primary pod: + +```shell +kubectl delete pod --wait=false cluster-example-1 +__OUTPUT__ +pod "cluster-example-1" deleted +``` + +This simulates a hard shutdown of the server - a scenario where something has gone wrong. + +Now if we check the status... +```shell +kubectl cnp status cluster-example +__OUTPUT__ +Failing over Failing over to cluster-example-2 +Name: cluster-example +Namespace: default +PostgreSQL Image: quay.io/enterprisedb/postgresql:13.2 +Primary instance: cluster-example-2 +Instances: 3 +Ready instances: 2 + +Instances status +Pod name Current LSN Received LSN Replay LSN System ID Primary Replicating Replay paused Pending restart Status +-------- ----------- ------------ ---------- --------- ------- ----------- ------------- --------------- ------ +cluster-example-1 - - - - - - - - unable to upgrade connection: container not found ("postgres") - +cluster-example-2 0/7000230 6955855494195015697 ✓ ✗ ✗ ✗ OK +cluster-example-3 0/70000A0 0/70000A0 6955855494195015697 ✗ ✓ ✗ ✗ OK +``` + +...the failover process has begun, with the second pod promoted to primary. Once the failed pod has restarted, it will become a replica of the new primary: + +```shell +kubectl cnp status cluster-example +__OUTPUT__ +Cluster in healthy state +Name: cluster-example +Namespace: default +PostgreSQL Image: quay.io/enterprisedb/postgresql:13.2 +Primary instance: cluster-example-2 +Instances: 3 +Ready instances: 3 + +Instances status +Pod name Current LSN Received LSN Replay LSN System ID Primary Replicating Replay paused Pending restart Status +-------- ----------- ------------ ---------- --------- ------- ----------- ------------- --------------- ------ +cluster-example-1 0/7004268 0/7004268 6955855494195015697 ✗ ✓ ✗ ✗ OK +cluster-example-2 0/7004268 6955855494195015697 ✓ ✗ ✗ ✗ OK +cluster-example-3 0/7004268 0/7004268 6955855494195015697 ✗ ✓ ✗ ✗ OK +``` + + +### Further reading + +This is all it takes to get a PostgreSQL cluster up and running, but of course there's a lot more possible - and certainly much more that is prudent before you should ever deploy in a production environment! + +- Deploying on public cloud platforms: see the [Cloud Setup](cloud_setup/) section. + +- Design goals and possibilities offered by the Cloud Native PostgreSQL Operator: check out the [Architecture](architecture/) and [Use cases](use_cases/) sections. + +- Configuring a secure and reliable system: read through the [Security](security/), [Failure Modes](failure_modes/) and [Backup and Recovery](backup_recovery/) sections. + +- Webinar: [Watch Gabriele Bartolini discuss and demonstrate Cloud Native PostgreSQL lifecycle management](https://www.youtube.com/watch?v=S-I9y-HnAnI) + +- Development: [Leonardo Cecchi writes about setting up a local environment using Cloud Native PostgreSQL for application development](https://www.enterprisedb.com/blog/cloud-native-postgresql-application-developers) + diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/kubernetes_upgrade.mdx b/advocacy_docs/kubernetes/cloud_native_postgresql/kubernetes_upgrade.mdx new file mode 100644 index 00000000000..5f54cc93609 --- /dev/null +++ b/advocacy_docs/kubernetes/cloud_native_postgresql/kubernetes_upgrade.mdx @@ -0,0 +1,90 @@ +--- +title: 'Kubernetes Upgrade' +originalFilePath: 'src/kubernetes_upgrade.md' +product: 'Cloud Native Operator' +--- + +Kubernetes clusters must be kept updated. This becomes even more +important if you are self-managing your Kubernetes clusters, especially +on **bare metal**. + +Planning and executing regular updates is a way for your organization +to clean up the technical debt and reduce the business risks, despite +the introduction in your Kubernetes infrastructure of controlled +downtimes that temporarily take out a node from the cluster for +maintenance reasons (recommended reading: +["Embracing Risk"](https://landing.google.com/sre/sre-book/chapters/embracing-risk/) +from the Site Reliability Engineering book). + +For example, you might need to apply security updates on the Linux +servers where Kubernetes is installed, or to replace a malfunctioning +hardware component such as RAM, CPU, or RAID controller, or even upgrade +the cluster to the latest version of Kubernetes. + +Usually, maintenance operations in a cluster are performed one node +at a time by: + +1. evicting the workloads from the node to be updated (`drain`) +2. performing the actual operation (for example, system update) +3. re-joining the node to the cluster (`uncordon`) + +The above process requires workloads to be either stopped for the +entire duration of the upgrade or migrated on another node. + +While the latest case is the expected one in terms of service +reliability and self-healing capabilities of Kubernetes, there can +be situations where it is advised to operate with a temporarily +degraded cluster and wait for the upgraded node to be up again. + +In particular, if your PostgreSQL cluster relies on **node-local storage** +\- that is *storage which is local to the Kubernetes worker node where +the PostgreSQL database is running*. +Node-local storage (or simply *local storage*) is used to enhance performance. + +!!! Note + If your database files are on shared storage over the network, + you may not need to define a maintenance window. If the volumes currently + used by the pods can be reused by pods running on different nodes after + the drain, the default self-healing behavior of the operator will work + fine (you can then skip the rest of this section). + +When using local storage for PostgreSQL, you are advised to temporarily +put the cluster in **maintenance mode** through the `nodeMaintenanceWindow` +option to avoid standard self-healing procedures to kick in, +while, for example, enlarging the partition on the physical node or +updating the node itself. + +!!! Warning + Limit the duration of the maintenance window to the shortest + amount of time possible. In this phase, some of the expected + behaviors of Kubernetes are either disabled or running with + some limitations, including self-healing, rolling updates, + and Pod disruption budget. + +The `nodeMaintenanceWindow` option of the cluster has two further +settings: + +`inProgress`: +Boolean value that states if the maintenance window for the nodes +is currently in progress or not. By default, it is set to `off`. +During the maintenance window, the `reusePVC` option below is +evaluated by the operator. + +`reusePVC`: +Boolean value that defines if an existing PVC is reused or +not during the maintenance operation. By default, it is set to `on`. +When **enabled**, Kubernetes waits for the node to come up +again and then reuses the existing PVC; the `PodDisruptionBudget` +policy is temporarily removed. +When **disabled**, Kubernetes forces the recreation of the +Pod on a different node with a new PVC by relying on +PostgreSQL's physical streaming replication, then destroys +the old PVC together with the Pod. This scenario is generally +not recommended unless the database's size is small, and re-cloning +the new PostgreSQL instance takes shorter than waiting. + +!!! Note + When performing the `kubectl drain` command, you will need + to add the `--delete-local-data` option. + Don't be afraid: it refers to another volume internally used + by the operator - not the PostgreSQL data directory. diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/labels_annotations.mdx b/advocacy_docs/kubernetes/cloud_native_postgresql/labels_annotations.mdx new file mode 100644 index 00000000000..a9235008ed6 --- /dev/null +++ b/advocacy_docs/kubernetes/cloud_native_postgresql/labels_annotations.mdx @@ -0,0 +1,84 @@ +--- +title: 'Labels and annotations' +originalFilePath: 'src/labels_annotations.md' +product: 'Cloud Native Operator' +--- + +Resources in Kubernetes are organized in a flat structure, with no hierarchical +information or relationship between them. However, such resources and objects +can be linked together and put in relationship through **labels** and +**annotations**. + +!!! info + For more information, please refer to the Kubernetes documentation on + [annotations](https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/) and + [labels](https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/). + +In short: + +- an annotation is used to assign additional non-identifying information to + resources with the goal to facilitate integration with external tools +- a label is used to group objects and query them through Kubernetes' native + selector capability + +You can select one or more labels and/or annotations you will use +in your Cloud Native PostgreSQL deployments. Then you need to configure the operator +so that when you define these labels and/or annotations in a cluster's metadata, +they are automatically inherited by all resources created by it (including pods). + +!!! Note + Label and annotation inheritance is the technique adopted by Cloud Native + PostgreSQL in lieu of alternative approaches such as pod templates. + +## Pre-requisites + +By default, no label or annotation defined in the cluster's metadata is +inherited by the associated resources. +In order to enable label/annotation inheritance, you need to follow the +instructions provided in the ["Operator configuration"](operator_conf.md) section. + +Below we will continue on that example and limit it to the following: + +- annotations: `categories` +- labels: `app`, `environment`, and `workload` + +!!! Note + Feel free to select the names that most suit your context for both + annotations and labels. Remember that you can also use wildcards + in naming and adopt strategies like `mycompany/*` for all labels + or annotations starting with `mycompany/` to be inherited. + +## Defining cluster's metadata + +When defining the cluster, **before** any resource is deployed, you can +properly set the metadata as follows: + +```yaml +apiVersion: postgresql.k8s.enterprisedb.io/v1 +kind: Cluster +metadata: + name: cluster-example + annotations: + categories: database + labels: + environment: production + workload: database + app: sso +spec: + # ... +``` + +Once the cluster is deployed, you can verify, for example, that the labels +have been correctly set in the pods with: + +```shell +kubectl get pods --show-labels +``` + +## Current limitations + +Cloud Native PostgreSQL does not currently support synchronization of labels +or annotations after a resource has been created. For example, suppose you +deploy a cluster. When you add a new annotation to be inherited and define it +in the existing cluster, the operator will not automatically set it +on the associated resources. diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/license_keys.mdx b/advocacy_docs/kubernetes/cloud_native_postgresql/license_keys.mdx new file mode 100644 index 00000000000..0c7b1e489e0 --- /dev/null +++ b/advocacy_docs/kubernetes/cloud_native_postgresql/license_keys.mdx @@ -0,0 +1,92 @@ +--- +title: 'License and License Keys' +originalFilePath: 'src/license_keys.md' +product: 'Cloud Native Operator' +--- + +A license key is always required for the operator to work. + +The only exception is when you run the operator with Community PostgreSQL: +in this case, if the license key is unset, a cluster will be started with the default +trial license - which automatically expires after 30 days. + +!!! Important + After the license expiration, the operator will cease any reconciliation attempt + on the cluster, effectively stopping to manage its status. + The pods and the data will still be available. + +## Company level license keys + +A license key allows you to create an unlimited number of PostgreSQL +clusters in your installation. + +The license key needs to be available in a `ConfigMap` in the same +namespace where the operator is deployed. + +In Kubernetes the operator is deployed by default in +the `postgresql-operator-system` namespace. +When instead OLM is used (i.e. on OpenShift), the operator is installed +by default in the `openshift-operators` namespace. + +Given the namespace name, and the license key, you can create +the config map with the following command: + +``` +kubectl create configmap -n [NAMESPACE_NAME_HERE] \ + postgresql-operator-controller-manager-config \ + --from-literal=EDB_LICENSE_KEY=[LICENSE_KEY_HERE] +``` + +The following command can be used to reload the config map: + +``` +kubectl rollout restart deployment -n [NAMESPACE_NAME_HERE] \ + postgresql-operator-controller-manager +``` + +!!! Seealso "Operator configuration" + For more information, please refer to the ["Operator configuration"](operator_conf.md) section. + +The validity of the license key can be checked inside the cluster status. + +```sh +kubectl get cluster cluster_example -o yaml +[...] +status: + [...] + licenseStatus: + licenseExpiration: "2021-11-06T09:36:02Z" + licenseStatus: Trial + valid: true + isImplicit: false + isTrial: true +[...] +``` + +## Cluster level license keys + +Each `Cluster` resource has a `licenseKey` parameter in its definition. +You can find the expiration date, as well as more information about the license, +in the cluster status: + +```sh +kubectl get cluster cluster_example -o yaml +[...] +status: + [...] + licenseStatus: + licenseExpiration: "2021-11-06T09:36:02Z" + licenseStatus: Trial + valid: true + isImplicit: false + isTrial: true +[...] +``` + +A cluster license key can be updated with a new one at any moment, to extend +the expiration date or move the cluster to a production license. + +Cloud Native PostgreSQL is distributed under the EnterpriseDB Limited Usage License +Agreement, available at [enterprisedb.com/limited-use-license](https://www.enterprisedb.com/limited-use-license). + +Cloud Native PostgreSQL: Copyright (C) 2019-2021 EnterpriseDB. diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/monitoring.mdx b/advocacy_docs/kubernetes/cloud_native_postgresql/monitoring.mdx new file mode 100644 index 00000000000..32d00655b38 --- /dev/null +++ b/advocacy_docs/kubernetes/cloud_native_postgresql/monitoring.mdx @@ -0,0 +1,95 @@ +--- +title: 'Monitoring' +originalFilePath: 'src/monitoring.md' +product: 'Cloud Native Operator' +--- + +For each PostgreSQL instance, the operator provides an exporter of metrics for +[Prometheus](https://prometheus.io/) via HTTP, on port 9187. +The operator comes with a predefined set of metrics, as well as a highly +configurable and customizable system to define additional queries via one or +more `ConfigMap` objects - and, future versions, `Secret` too. + +The exporter can be accessed as follows: + +```shell +curl http://:9187/metrics +``` + +All monitoring queries are: + +- transactionally atomic (one transaction per query) +- executed with the `pg_monitor` role + +Please refer to the +["Default roles" section in PostgreSQL documentation](https://www.postgresql.org/docs/current/default-roles.html) +for details on the `pg_monitor` role. + +## User defined metrics + +Users will be able to define metrics through the available interface +that the operator provides. This interface is currently in *beta* state and +only supports definition of custom queries as `ConfigMap` and `Secret` objects +using a YAML file that is inspired by the [queries.yaml file](https://github.com/prometheus-community/postgres_exporter/blob/main/queries.yaml) +of the PostgreSQL Prometheus Exporter. + +Queries must be defined in a `ConfigMap` to be referenced in the `monitoring` +section of the `Cluster` definition, as in the following example: + +```yaml +apiVersion: postgresql.k8s.enterprisedb.io/v1 +kind: Cluster +metadata: + name: cluster-example +spec: + instances: 3 + + storage: + size: 1Gi + + monitoring: + customQueriesConfigMap: + - name: example-monitoring + key: custom-queries +``` + +Specifically, the `monitoring` section looks for an array with the name +`customQueriesConfigMap`, which, as the name suggests, needs a list of +`ConfigMap` key references to be used as the source of custom queries. + +For example: + +```yaml +--- +apiVersion: v1 +kind: ConfigMap +metadata: + namespace: default + name: example-monitoring +data: + custom-queries: | + pg_replication: + query: "SELECT CASE WHEN NOT pg_is_in_recovery() + THEN 0 + ELSE GREATEST (0, + EXTRACT(EPOCH FROM (now() - pg_last_xact_replay_timestamp()))) + END AS lag" + primary: true + metrics: + - lag: + usage: "GAUGE" + description: "Replication lag behind primary in seconds" +``` + +The object must have a name and be in the same namespace as the `Cluster`. +Note that the above query will be executed on the `primary` node, with the +following output. + +```text +# HELP custom_pg_replication_lag Replication lag behind primary in seconds +# TYPE custom_pg_replication_lag gauge +custom_pg_replication_lag 0 +``` + +This framework enables the definition of custom metrics to monitor the database +or the application inside the PostgreSQL cluster. diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/operator_capability_levels.mdx b/advocacy_docs/kubernetes/cloud_native_postgresql/operator_capability_levels.mdx new file mode 100644 index 00000000000..b9c9151477f --- /dev/null +++ b/advocacy_docs/kubernetes/cloud_native_postgresql/operator_capability_levels.mdx @@ -0,0 +1,412 @@ +--- +title: 'Operator Capability Levels' +originalFilePath: 'src/operator_capability_levels.md' +product: 'Cloud Native Operator' +--- + +This section provides a summary of the capabilities implemented by Cloud Native PostgreSQL, +classified using the +["Operator SDK definition of Capability Levels"](https://sdk.operatorframework.io/docs/advanced-topics/operator-capabilities/operator-capabilities/) +framework. + +![Operator Capability Levels](./images/operator-capability-level.png) + +Each capability level is associated with a certain set of management features the operator offers: + +1. Basic Install +2. Seamless Upgrades +3. Full Lifecycle +4. Deep Insights +5. Auto Pilot + +!!! Note + We consider this framework as a guide for future work and implementations in the operator. + +## Level 1 - Basic Install + +Capability level 1 involves **installation** and **configuration** of the +operator. This category includes usability and user experience +enhancements, such as improvements in how users interact with the +operator and a PostgreSQL cluster configuration. + +!!! Important + We consider **Information Security** part of this level. + +### Operator deployment via declarative configuration + +The operator is installed in a declarative way using a Kubernetes manifest +which defines 3 `CustomResourceDefinition` objects: `Cluster`, `Backup`, +`ScheduledBackup`. + +### PostgreSQL cluster deployment via declarative configuration + +A PostgreSQL cluster (operand) is defined using the `Cluster` custom resource +in a fully declarative way. The PostgreSQL version is determined by the +operand container image defined in the CR, which is automatically fetched +from the requested registry. When deploying an operand, the operator also +automatically creates the following resources: `Pod`, `Service`, `Secret`, +`ConfigMap`,`PersistentVolumeClaim`, `PodDisruptionBudget`, `ServiceAccount`, +`RoleBinding`, `Role`. + +### Override of operand images through the CRD + +The operator is designed to support any operand container image with +PostgreSQL inside. +By default, the operator uses the latest available minor +version of the latest stable major version supported by the PostgreSQL +Community and published on Quay.io by EnterpriseDB. +You can use any compatible image of PostgreSQL supporting the +primary/standby architecture directly by setting the `imageName` +attribute in the CR. The operator also supports `imagePullSecretsNames` +to access private container registries. + +### Self-contained instance manager + +Instead of relying on an external tool such as Patroni or Stolon to +coordinate PostgreSQL instances in the Kubernetes cluster pods, the operator +injects the operator executable inside each pod, in a file named +`/controller/manager`. The application is used to control the underlying +PostgreSQL instance and to reconcile the pod status with the instance itself +based on the PostgreSQL cluster topology. The instance manager also starts a +web server that is invoked by the `kubelet` for probes. Unix signals invoked +by the `kubelet` are filtered by the instance manager and, where appropriate, +forwarded to the `postgres` process for fast and controlled reactions to +external events. The instance manager is written in Go and has no external +dependencies. + +### Storage configuration + +Storage is a critical component in a database workload. Taking advantage of +Kubernetes native capabilities and resources in terms of storage, the +operator gives users enough flexibility to choose the right storage for their +workload requirements, based on what the underlying Kubernetes environment +can offer. This implies choosing a particular storage class in +a public cloud environment or fine-tuning the generated PVC through a +PVC template in the CR's `storage` parameter. + +### Replica configuration + +The operator automatically detects replicas in a cluster +through a single parameter called `instances`. If set to `1`, the cluster +comprises a single primary PostgreSQL instance with no replica. If higher +than `1`, the operator manages `instances -1` replicas, including high +availability through automated failover and rolling updates through +switchover operations. + +### Database configuration + +The operator is designed to manage a PostgreSQL cluster with a single +database. The operator transparently manages access to the database through +three Kubernetes services automatically provisioned and managed for read-write, +read, and read-only workloads. +Using the convention over configuration approach, the operator creates a +database called `app`, by default owned by a regular Postgres user with the +same name. Both the database name and the user name can be specified if +required. +Although no configuration is required to run the cluster, users can customize +both PostgreSQL run-time configuration and PostgreSQL Host-Based +Authentication rules in the `postgresql` section of the CR. + +### Pod Security Policies + +For InfoSec requirements, the operator does not need privileged mode for the +execution of containers and access to volumes both in the operator and in the +operand. + +### Affinity + +The operator supports basic pod affinity/anti-affinity rules to deploy PostgreSQL +pods on different nodes, based on the selected `topologyKey` (for example `node` or +`zone`). Additionally, it supports node affinity through the `nodeSelector` +configuration attribute, as [expected by Kubernetes](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/). + +### License keys + +The operator comes with support for license keys, with the possibility to +programmatically define a default behavior in case of the absence of a key. +Cloud Native PostgreSQL has been programmed to create an implicit 30-day +trial license for every deployed cluster. +License keys are signed strings that the operator can verify using an +asymmetric key technique. The content is a JSON object that includes the +type, the product, the expiration date, and, if required, the cluster +identifiers (namespace and name), the number of instances, the credentials to be used +as a secret by the operator to pull down an image from a protected container +registry. Beyond the expiration date, the operator will stop any +reconciliation process until the license key is restored. + +### Current status of the cluster + +The operator continuously updates the status section of the CR with the +observed status of the cluster. The entire PostgreSQL cluster status is +continuously monitored by the instance manager running in each pod: the +instance manager is responsible for applying the required changes to the +controlled PostgreSQL instance to converge to the required status of +the cluster (for example: if the cluster status reports that pod `-1` is the +primary, pod `-1` needs to promote itself while the other pods need to follow +pod `-1`). The same status is used by Kubernetes client applications to +provide details, including the `cnp` plugin for `kubectl` and the OpenShift dashboard. + +### Operator's certification authority + +The operator automatically creates a certification authority for itself. +It creates and signs with the operator certification authority a leaf certificate +to be used by the webhook server, to ensure safe communication between the +Kubernetes API Server and the operator itself. + +### Cluster's certification authority + +The operator automatically creates a certification authority for every PostgreSQL +cluster, which is used to issue and renew TLS certificates for the authentication +of streaming replication standby servers and applications (instead of passwords). +The operator will use the Certification Authority to sign every cluster +certification authority. Certificates can be issued with the `cnp` plugin +for `kubectl`. + +### TLS connections + +The operator transparently and natively supports TLS/SSL connections +to encrypt client/server communications for increased security using the +cluster's certification authority. + +### Certificate authentication for streaming replication + +The operator relies on TLS client certificate authentication to authorize streaming +replication connections from the standby servers, instead of relying on a password +(and therefore a secret). + +### Continuous configuration management + +The operator enables users to apply changes to the `Cluster` resource YAML +section of the PostgreSQL configuration and makes sure that all instances +are properly reloaded or restarted, depending on the configuration option. +*Current limitations:* changes with `ALTER SYSTEM` are not detected, meaning +that the cluster state is not enforced; proper restart order is not implemented +with [hot standby sensitive parameters](https://www.postgresql.org/docs/current/hot-standby.html#HOT-STANDBY-ADMIN) +such as `max_connections` and `max_wal_senders`. + +### Multiple installation methods + +The operator can be installed through a Kubernetes manifest via `kubectl +apply`, to be used in a traditional Kubernetes installation in public +and private cloud environments. Additionally, it can be deployed through +the Operator Lifecycle Manager (OLM) from OperatorHub.io and the OpenShift +Container Platform by RedHat. + +### Convention over configuration + +The operator supports the convention over configuration paradigm, deciding +standard default values while allowing users to override them and customize +them. You can specify a deployment of a PostgreSQL cluster using +the `Cluster` CRD in a couple of YAML code lines. + +## Level 2 - Seamless Upgrades + +Capability level 2 is about enabling **updates of the operator and the actual +workload**, in our case PostgreSQL servers. This includes **PostgreSQL minor +release updates** (security and bug fixes normally) as well as **major online +upgrades**. + +### Upgrade of the operator + +You can upgrade the operator seamlessly as a new deployment. A change in the +operator does not require a change in the operand - thanks to the instance +manager's injection. The operator can manage older versions of the operand. + +### Upgrade of the managed workload + +The operand can be upgraded using a declarative configuration approach as +part of changing the CR and, in particular, the `imageName` parameter. The +operator prevents major upgrades of PostgreSQL while making it possible to go +in both directions in terms of minor PostgreSQL releases within a major +version (enabling updates and rollbacks). + +In the presence of standby servers, the operator performs rolling updates +starting from the replicas by dropping the existing pod and creating a new +one with the new requested operand image that reuses the underlying storage. +Depending on the value of the `primaryUpdateStrategy`, the operator proceeds +with a switchover before updating the former primary (`unsupervised`) or waits +for the user to manually issue the switchover procedure (`supervised`) via the +`cnp` plugin for `kubectl`. +Which setting to use depends on the business requirements as the operation +might generate some downtime for the applications, from a few seconds to +minutes based on the actual database workload. + +### Display cluster availability status during upgrade + +At any time, convey the cluster's high availability status, for example, `OK`, +`Failover in progress`, `Switchover in progress`, `Upgrade in progress`, or +`Upgrade failed`. + +## Level 3 - Full Lifecycle + +Capability level 3 requires the operator to manage aspects of **business +continuity** and **scalability**. +**Disaster recovery** is a business continuity component that requires +that both backup and recovery of a database work correctly. While as a +starting point, the goal is to achieve RPO < 5 minutes, the long term goal is +to implement RPO=0 backup solutions. **High Availability** is the other +important component of business continuity that, through PostgreSQL native +physical replication and hot standby replicas, allows the operator to perform +failover and switchover operations. This area includes enhancements in: + +- control of PostgreSQL physical replication, such as synchronous replication, + (cascading) replication clusters, and so on; +- connection pooling, to improve performance and control through a + connection pooling layer with pgBouncer. + +### PostgreSQL Backups + +The operator has been designed to provide application-level backups using +PostgreSQL’s native continuous backup technology based on +physical base backups and continuous WAL archiving. Specifically, +the operator currently supports only backups on AWS S3 or S3-compatible +object stores and gateways like MinIO. + +WAL archiving and base backups are defined at the cluster level, declaratively, +through the `backup` parameter in the cluster definition, by specifying +an S3 protocol destination URL (for example, to point to a specific folder in +an AWS S3 bucket) and, optionally, a generic endpoint URL. WAL archiving, +a prerequisite for continuous backup, does not require any further +action from the user: the operator will automatically and transparently set +the the `archive_command` to rely on `barman-cloud-wal-archive` to ship WAL +files to the defined endpoint. Users can decide the compression algorithm. + +You can define base backups in two ways: on-demand (through the `Backup` +custom resource definition) or scheduled (through the `ScheduledBackup` +customer resource definition, using a cron-like syntax). They both rely on +`barman-cloud-backup` for the job (distributed as part of the application +container image) to relay backups in the same endpoint, alongside WAL files. + +Both `barman-cloud-wal-restore` and `barman-cloud-backup` are distributed in +the application container image under GNU GPL 3 terms. + +### Full restore from a backup + +The operator enables users to bootstrap a new cluster (with its settings) +starting from an existing and accessible backup taken using +`barman-cloud-backup`. Once the bootstrap process is completed, the operator +initiates the instance in recovery mode and replays all available WAL files +from the specified archive, exiting recovery and starting as a primary. +Subsequently, the operator will clone the requested number of standby instances +from the primary. + +### Point-In-Time Recovery (PITR) from a backup + +The operator enables users to create a new PostgreSQL cluster by recovering +an existing backup to a specific point-in-time, defined with a timestamp, a +label or a transaction ID. This capability is built on top of the full restore +one and supports all the options available in +[PostgreSQL for PITR](https://www.postgresql.org/docs/13/runtime-config-wal.html#RUNTIME-CONFIG-WAL-RECOVERY-TARGET). + +### Zero Data Loss clusters through synchronous replication + +Achieve *Zero Data Loss* (RPO=0) in your local High Availability Cloud Native PostgreSQL +cluster through quorum based synchronous replication support. The operator provides +two configuration options that control the minimum and maximum number of +expected synchronous standby replicas available at any time. The operator will +react accordingly, based on the number of available and ready PostgreSQL +instances in the cluster, through the following formula: + +``` +0 <= minSyncReplicas <= maxSyncReplicas < instances +``` + +### Liveness and readiness probes + +The operator defines liveness and readiness probes for the Postgres +Containers that are then invoked by the kubelet. They are mapped respectively +to the `/healthz` and `/readyz` endpoints of the web server managed +directly by the instance manager. They both use Go to connect to the cluster +and issue a simple query (`;`) to verify that the server is ready to accept +connections. + +### Rolling deployments + +The operator supports rolling deployments to minimize the downtime and, if a +PostgreSQL cluster is exposed publicly, the Service will load-balance the +read-only traffic only to available pods during the initialization or the +update. + +### Scale up and down of replicas + +The operator allows users to scale up and down the number of instances in a +PostgreSQL cluster. New replicas are automatically started up from the +primary server and will participate in the cluster's HA infrastructure. +The CRD declares a "scale" subresource that allows the user to use the +`kubectl scale` command. + +### Maintenance window and PodDisruptionBudget for Kubernetes nodes + +The operator creates a `PodDisruptionBudget` resource to limit the number of +concurrent disruptions to one. This configuration prevents the maintenance +operation from deleting all the pods in a cluster, allowing the specified +number of instances to be created. +The PodDisruptionBudget will be applied during the node draining operation, +preventing any disruption of the cluster service. + +While this strategy is correct for Kubernetes Clusters where +storage is shared among all the worker nodes, it may not be the best solution +for clusters using Local Storage or for clusters installed in a private +cloud. The operator allows users to specify a Maintenance Window and +configure the reaction to any underlying node eviction. The `ReusePVC` option +in the maintenance window section enables to specify the strategy to be used: +allocate new storage in a different PVC for the evicted instance or wait +for the underlying node to be available again. + +### Reuse of Persistent Volumes storage in Pods + +When the operator needs to create a pod that has been deleted by the user or +has been evicted by a Kubernetes maintenance operation, it reuses the +`PersistentVolumeClaim` if available, avoiding the need +to re-clone the data from the primary. + +### CPU and memory requests and limits + +The operator allows administrators to control and manage resource usage by +the cluster's pods, through the `resources` section of the manifest. In +particular `requests` and `limits` values can be set for both CPU and RAM. + +## Level 4 - Deep Insights + +Capability level 4 is about **observability**: in particular, monitoring, +alerting, trending, log processing. This might involve the use of external tools +such as Prometheus, Grafana, Fluent Bit, as well as extensions in the +PostgreSQL engine for the output of error logs directly in JSON format. + +### Prometheus exporter with configurable queries + +The instance manager provides a pluggable framework and, via its own +web server, exposes an endpoint to export metrics for the +[Prometheus](https://prometheus.io/) monitoring and alerting tool. +The operator supports custom monitoring queries defined as `ConfigMap` +and `Secret` objects using a syntax that is compatible with +[`postgres_exporter` for Prometheus](https://github.com/prometheus-community/postgres_exporter). + + +### Kubernetes events + +Record major events as expected by the Kubernetes API, such as creating resources, +removing nodes, upgrading, and so on. Events can be displayed through +the `kubectl describe` and `kubectl get events` command. + +## Level 5 - Auto Pilot + +Capability level 5 is focused on **automated scaling**, **healing** and +**tuning** - through the discovery of anomalies and insights emerged +from the observability layer. + +### Automated Failover for self-healing + +In case of detected failure on the primary, the operator will change the +status of the cluster by setting the most aligned replica as the new target +primary. As a consequence, the instance manager in each alive pod will +initiate the required procedures to align itself with the requested status of +the cluster, by either becoming the new primary or by following it. +In case the former primary comes back up, the same mechanism will avoid a +split-brain by preventing applications from reaching it, running `pg_rewind` on +the server and restarting it as a standby. + +### Automated recreation of a standby + +In case the pod hosting a standby has been removed, the operator initiates +the procedure to recreate a standby server. diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/operator_conf.mdx b/advocacy_docs/kubernetes/cloud_native_postgresql/operator_conf.mdx new file mode 100644 index 00000000000..67809bdff32 --- /dev/null +++ b/advocacy_docs/kubernetes/cloud_native_postgresql/operator_conf.mdx @@ -0,0 +1,86 @@ +--- +title: 'Operator configuration' +originalFilePath: 'src/operator_conf.md' +product: 'Cloud Native Operator' +--- + +The operator for Cloud Native PostgreSQL is installed from a standard +deployment manifest and follows the convention over configuration paradigm. +While this is fine in most cases, there are some scenarios where you want +to change the default behavior, such as: + +- setting a company license key that is shared by all deployments managed + by the operator +- defining annotations and labels to be inherited by all resources created + by the operator and that are set in the cluster resource +- defining a different default image for PostgreSQL or an additional pull secret + +By the default, the operator is installed in the `postgresql-operator-system` +namespace as a Kubernetes `Deployment` called `postgresql-operator-controller-manager`. + +!!! Note + In the examples below we assume the default name and namespace for the operator deployment. + +The behavior of the operator can be customized through a `ConfigMap` that +is located in the same namespace of the operator deployment and with the +same name of the operator followed by the `-config` suffix. + +As a result, if you have installed the operator using the standard deployment +manifest, the default `ConfigMap` is `postgresql-operator-controller-manager-config` +in the `postgresql-operator-system` namespace. + +!!! Important + Any change to the config map will not be automatically detected by the operator, + - and as such, it needs to be reloaded (see below). Moreover, changes only + apply to the resources created after the configuration is reloaded. + +## Available options + +The operator looks for the following environment variables to be defined in the config map: + +Name | Description +---- | ----------- +`EDB_LICENSE_KEY` | default license key (to be used only if the cluster does not define one) +`INHERITED_ANNOTATIONS` | list of annotation names that, when defined in a `Cluster` metadata, will be inherited by all the generated resources, including pods +`INHERITED_LABELS` | list of label names that, when defined in a `Cluster` metadata, will be inherited by all the generated resources, including pods +`PULL_SECRET_NAME` | name of an additional pull secret to be defined in the operator's namespace and to be used to download images + +By default, the above variables are not set. + +Values in `INHERITED_ANNOTATIONS` and `INHERITED_LABELS` support path-like wildcards. For example, the value `example.com/*` will match +both the value `example.com/one` and `example.com/two`. + +## Defining an operator config map + +The example below customizes the behavior of the operator, by defining a +default license key (namely a company key) and the label/annotation names to be +inherited by the resources created by any `Cluster` object that is deployed +at a later time. + +```yaml +apiVersion: v1 +kind: ConfigMap +metadata: + name: postgresql-operator-controller-manager-config + namespace: postgresql-operator-system +data: + INHERITED_ANNOTATIONS: categories + INHERITED_LABELS: environment, workload, app + EDB_LICENSE_KEY: +``` + +For the change to be effective, you need to reload the config map by issuing: + +```shell +kubectl rollout restart deployment \ + -n postgresql-operator-system \ + postgresql-operator-controller-manager +``` + +!!! Warning + Customizations will be applied only to `Cluster` resources created + after the reload of the operator deployment. + +Following the above example, if the `Cluster` definition contains a `categories` +annotation and any of the `environment`, `workload`, or `app` labels, these will +be inherited by all the resources generated by the deployment. diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/postgresql_conf.mdx b/advocacy_docs/kubernetes/cloud_native_postgresql/postgresql_conf.mdx new file mode 100644 index 00000000000..1f3715fac76 --- /dev/null +++ b/advocacy_docs/kubernetes/cloud_native_postgresql/postgresql_conf.mdx @@ -0,0 +1,231 @@ +--- +title: 'PostgreSQL Configuration' +originalFilePath: 'src/postgresql_conf.md' +product: 'Cloud Native Operator' +--- + +Users that are familiar with PostgreSQL are aware of the existence of the following two files +to configure an instance: + +- `postgresql.conf`: main run-time configuration file of PostgreSQL +- `pg_hba.conf`: clients authentication file + +Due to the concepts of declarative configuration and immutability of the PostgreSQL +containers, users are not allowed to directly touch those files. Configuration +is possible through the `postgresql` section of the `Cluster` resource definition +by defining custom `postgresql.conf` and `pg_hba.conf` settings via the +`parameters` and the `pg_hba` keys. +A reference for custom settings usage is included in the samples, see +[`cluster-example-custom.yaml`](../samples/cluster-example-custom.yaml). + +These settings are the same across all instances. + +!!! Warning + **OpenShift users:** due to a current limitation of the OpenShift user interface, + it is possible to change PostgreSQL settings from the YAML pane only. + +## The `postgresql` section + +The PostgreSQL instance in the pod starts with a default `postgresql.conf` file, +to which these settings are automatically added: + +```text +listen_addresses = '*' +include custom.conf +``` + +The `custom.conf` file will contain the user-defined settings. Refer to the +PostgreSQL documentation for [more information on the available parameters](https://www.postgresql.org/docs/current/runtime-config.html). +The content of `custom.conf` is automatically generated and maintained by the +operator by applying the following sections in this order: + +- Global default parameters +- Default parameters that depend on the PostgreSQL major version +- User-provided parameters +- Fixed parameters + +The **global default parameters** are: + +```text +logging_collector = 'off' +max_parallel_workers = '32' +max_replication_slots = '32' +max_worker_processes = '32' +``` + +The **default parameters for PostgreSQL 13 or higher** are: + +```text +wal_keep_size = '512MB' +``` + +The **default parameters for PostgreSQL 10 to 12** are: + +```text +wal_keep_segments = '32' +``` + +The following parameters are **fixed** and exclusively controlled by the operator: + +```text +archive_command = '/controller/manager wal-archive %p' +archive_mode = 'on' +archive_timeout = '5min' +full_page_writes = 'on' +hot_standby = 'true' +listen_addresses = '*' +port = '5432' +ssl = 'on' +ssl_ca_file = '/tmp/ca.crt' +ssl_cert_file = '/tmp/server.crt' +ssl_key_file = '/tmp/server.key' +unix_socket_directories = '/var/run/postgresql' +wal_level = 'logical' +wal_log_hints = 'on' +``` + +Since the fixed parameters are added last, they can't be overridden by the +user via the YAML configuration. Those parameters are required for correct WAL +archiving and replication. + +### Replication settings + +The `primary_conninfo` and `recovery_target_timeline` parameters are managed +automatically by the operator according to the state of the instance in +the cluster. + +```text +primary_conninfo = 'host=cluster-example-rw user=postgres dbname=postgres' +recovery_target_timeline = 'latest' +``` + +## The `pg_hba` section + +`pg_hba` is a list of PostgreSQL Host Based Authentication rules +used to create the `pg_hba.conf` used by the pods. + +Since the first matching rule is used for authentication, the `pg_hba.conf` file +generated by the operator can be seen as composed of three sections: + +1. Fixed rules +2. User-defined rules +3. Default rules + +Fixed rules: + +```text +local all all peer + +hostssl postgres streaming_replica all cert clientcert=1 +hostssl replication streaming_replica all cert clientcert=1 +``` + +Default rules: + +```text +host all all all md5 +``` + +The resulting `pg_hba.conf` will look like this: + +```text +local all all peer + +hostssl postgres streaming_replica all cert clientcert=1 +hostssl replication streaming_replica all cert clientcert=1 + + + +host all all all md5 +``` + +Refer to the PostgreSQL documentation for [more information on `pg_hba.conf`](https://www.postgresql.org/docs/current/auth-pg-hba-conf.html). + +## Changing configuration + +You can apply configuration changes by editing the `postgresql` section of +the `Cluster` resource. + +After the change, the cluster instances will immediately reload the +configuration to apply the changes. +If the change involves a parameter requiring a restart, the operator will +perform a rolling upgrade. + +## Fixed parameters + +Some PostgreSQL configuration parameters should be managed exclusively by the +operator. The operator prevents the user from setting them using a webhook. + +Users are not allowed to set the following configuration parameters in the +`postgresql` section: + +- `allow_system_table_mods` +- `archive_cleanup_command` +- `archive_command` +- `archive_mode` +- `archive_timeout` +- `bonjour_name` +- `bonjour` +- `cluster_name` +- `config_file` +- `data_directory` +- `data_sync_retry` +- `dynamic_shared_memory_type` +- `event_source` +- `external_pid_file` +- `full_page_writes` +- `hba_file` +- `hot_standby` +- `huge_pages` +- `ident_file` +- `jit_provider` +- `listen_addresses` +- `log_destination` +- `log_directory` +- `log_file_mode` +- `log_filename` +- `log_rotation_age` +- `log_rotation_size` +- `log_truncate_on_rotation` +- `logging_collector` +- `port` +- `primary_conninfo` +- `primary_slot_name` +- `promote_trigger_file` +- `recovery_end_command` +- `recovery_min_apply_delay` +- `recovery_target_action` +- `recovery_target_inclusive` +- `recovery_target_lsn` +- `recovery_target_name` +- `recovery_target_time` +- `recovery_target_timeline` +- `recovery_target_xid` +- `recovery_target` +- `restart_after_crash` +- `restore_command` +- `shared_memory_type` +- `ssl_ca_file` +- `ssl_cert_file` +- `ssl_ciphers` +- `ssl_crl_file` +- `ssl_dh_params_file` +- `ssl_ecdh_curve` +- `ssl_key_file` +- `ssl_max_protocol_version` +- `ssl_min_protocol_version` +- `ssl_passphrase_command_supports_reload` +- `ssl_passphrase_command` +- `ssl_prefer_server_ciphers` +- `ssl` +- `stats_temp_directory` +- `synchronous_standby_names` +- `syslog_facility` +- `syslog_ident` +- `syslog_sequence_numbers` +- `syslog_split_messages` +- `unix_socket_directories` +- `unix_socket_group` +- `unix_socket_permissions` +- `wal_level` +- `wal_log_hints` diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/quickstart.mdx b/advocacy_docs/kubernetes/cloud_native_postgresql/quickstart.mdx new file mode 100644 index 00000000000..6036c14988b --- /dev/null +++ b/advocacy_docs/kubernetes/cloud_native_postgresql/quickstart.mdx @@ -0,0 +1,183 @@ +--- +title: 'Quickstart' +originalFilePath: 'src/quickstart.md' +product: 'Cloud Native Operator' +--- + +This section describes how to test a PostgreSQL cluster on your laptop/computer +using Cloud Native PostgreSQL on a local Kubernetes cluster in +[Minikube](https://kubernetes.io/docs/setup/learning-environment/minikube/) or +[Kind](https://kind.sigs.k8s.io/). + + + +!!! Tip "Live demonstration" + Don't want to install anything locally just yet? Try a demonstration directly in your browser: + + [Cloud Native PostgreSQL Operator Interactive Quickstart](interactive_demo) + + +RedHat OpenShift Container Platform users can test the certified operator for +Cloud Native PostgreSQL on the [Red Hat CodeReady Containers (CRC)](https://developers.redhat.com/products/codeready-containers/overview) +for OpenShift. + +!!! Warning + The instructions contained in this section are for demonstration, + testing, and practice purposes only and must not be used in production. + +Like any other Kubernetes application, Cloud Native PostgreSQL is deployed using +regular manifests written in YAML. + +By following the instructions on this page you should be able to start a PostgreSQL +cluster on your local Kubernetes/Openshift installation and experiment with it. + +!!! Important + Make sure that you have `kubectl` installed on your machine in order + to connect to the Kubernetes cluster, or `oc` if using CRC for OpenShift. + Please follow the Kubernetes documentation on [how to install `kubectl`](https://kubernetes.io/docs/tasks/tools/install-kubectl/) + or the Openshift one on [how to install `oc`](https://docs.openshift.com/container-platform/4.6/cli_reference/openshift_cli/getting-started-cli.html). + + +!!! Note + If you are running Openshift, use `oc` every time `kubectl` is mentioned + in this documentation. `kubectl` commands are compatible with `oc` ones. + +## Part 1 - Setup the local Kubernetes/Openshift playground + +The first part is about installing Minikube, Kind, or CRC. Please spend some time +reading about the systems and decide which one to proceed with. +After setting up one of them, please proceed with part 2. + +### Minikube + +Minikube is a tool that makes it easy to run Kubernetes locally. Minikube runs a +single-node Kubernetes cluster inside a Virtual Machine (VM) on your laptop for +users looking to try out Kubernetes or develop with it day-to-day. Normally, it +is used in conjunction with VirtualBox. + +You can find more information in the official [Kubernetes documentation on how to +install Minikube](https://kubernetes.io/docs/tasks/tools/install-minikube) in your local personal environment. +When you installed it, run the following command to create a minikube cluster: + +```sh +minikube start +``` + +This will create the Kubernetes cluster, and you will be ready to use it. +Verify that it works with the following command: + +```sh +kubectl get nodes +``` + +You will see one node called `minikube`. + +### Kind + +If you do not want to use a virtual machine hypervisor, then Kind is a tool for running +local Kubernetes clusters using Docker container "nodes" (Kind stands for "Kubernetes IN Docker" indeed). + +Install `kind` on your environment following the instructions in the [Quickstart](https://kind.sigs.k8s.io/docs/user/quick-start), +then create a Kubernetes cluster with: + +```sh +kind create cluster --name pg +``` + +### CodeReady Containers (CRC) + +[Download RedHat CRC](https://developers.redhat.com/products/codeready-containers/overview) +and move the binary inside a directory in your `PATH`. + +You can then run the following commands: +``` +crc setup +crc start +``` + +The `crc start` output will explain how to proceed. You'll then need to +execute the output of the `crc oc-env` command. +After that, you can log in as `kubeadmin` with the printed `oc login` +command. You can also open the web console running `crc console`. +User and password are the same as for the `oc login` command. + +CRC doesn't come with a StorageClass, so one has to be configured. +You can follow the [Dynamic volume provisioning wiki page](https://github.com/code-ready/crc/wiki/Dynamic-volume-provisioning) +and install `rancher/local-path-provisioner`. + +## Part 2 - Install Cloud Native PostgreSQL + +Now that you have a Kubernetes or OpenShift installation up and running +on your laptop, you can proceed with Cloud Native PostgreSQL installation. + +Please refer to the ["Installation"](installation.md) section and then proceed +with the deployment of a PostgreSQL cluster. + +## Part 3 - Deploy a PostgreSQL cluster + +As with any other deployment in Kubernetes, to deploy a PostgreSQL cluster +you need to apply a configuration file that defines your desired `Cluster`. + +The [`cluster-example.yaml`](../samples/cluster-example.yaml) sample file +defines a simple `Cluster` using the default storage class to allocate +disk space: + +```yaml +# Example of PostgreSQL cluster +apiVersion: postgresql.k8s.enterprisedb.io/v1 +kind: Cluster +metadata: + name: cluster-example +spec: + instances: 3 + + # Example of rolling update strategy: + # - unsupervised: automated update of the primary once all + # replicas have been upgraded (default) + # - supervised: requires manual supervision to perform + # the switchover of the primary + primaryUpdateStrategy: unsupervised + + # Require 1Gi of space + storage: + size: 1Gi +``` + +!!! Note "There's more" + For more detailed information about the available options, please refer + to the ["API Reference" section](api_reference.md). + +In order to create the 3-node PostgreSQL cluster, you need to run the following command: + +```sh +kubectl apply -f cluster-example.yaml +``` + +You can check that the pods are being created with the `get pods` command: + +```sh +kubectl get pods +``` + +By default, the operator will install the latest available minor version +of the latest major version of PostgreSQL when the operator was released. +You can override this by setting the `imageName` key in the `spec` section of +the `Cluster` definition. For example, to install PostgreSQL 12.5: + +```yaml +apiVersion: postgresql.k8s.enterprisedb.io/v1 +kind: Cluster +metadata: + # [...] +spec: + # [...] + imageName: quay.io/enterprisedb/postgresql:12.5 + #[...] +``` + +!!! Important + The immutable infrastructure paradigm requires that you always + point to a specific version of the container image. + Never use tags like `latest` or `13` in a production environment + as it might lead to unpredictable scenarios in terms of update + policies and version consistency in the cluster. diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/release_notes.mdx b/advocacy_docs/kubernetes/cloud_native_postgresql/release_notes.mdx new file mode 100644 index 00000000000..e344ecc40d7 --- /dev/null +++ b/advocacy_docs/kubernetes/cloud_native_postgresql/release_notes.mdx @@ -0,0 +1,102 @@ +--- +title: 'Release notes' +originalFilePath: 'src/release_notes.md' +product: 'Cloud Native Operator' +--- + +History of user-visible changes for Cloud Native PostgreSQL. + +## Version 1.3.0 + +**Release date:** 23 Apr 2021 + +Features: + +- Inheritance of labels and annotations +- Set resource limits for every container + +Security Enhancements: + +- Support for restricted security context constraint on RedHat OpenShift to + limit pod execution to a namespace allocated UID and SELinux context +- Pod security contexts explicitly defined by the operator to run as + non-root, non-privileged and without privilege escalation + +Changes: + +- Prometheus exporter endpoint listening on port 9187 (port 8000 is now + reserved to instance coordination with API server) +- Documentation improvements +- E2E tests enhancements, including GKE environment +- Minor bug fixes + +## Version 1.2.1 + +**Release date:** 6 Apr 2021 + +- ScheduledBackup are no longer owners of the Backups, meaning that backups + are not removed when ScheduledBackup objects are deleted +- Update on ubi8-minimal image to solve RHSA-2021:1024 (Security Advisory: Important) + +## Version 1.2.0 + +**Release date:** 31 Mar 2021 + +- Introduce experimental support for custom monitoring queries as ConfigMap and + Secret objects using a compatible syntax with `postgres_exporter` for Prometheus +- Support Operator Lifecycle Manager (OLM) deployments, with the subsequent + presence on OperatorHub.io +- Expand license key support for company-wide usage (previous restrictions limited only to a single cluster namespace) +- Enhance container security by applying guidelines from the US Department of + Defense (DoD)'s Defense Information Systems Agency (DISA) and the Center for + Internet Security (CIS) and verifying them directly in the pipeline with + Dockle +- Improve E2E tests on AKS +- Minor bug fixes + +## Version 1.1.0 + +**Release date:** 3 Mar 2021 + +- Add `kubectl cnp status` to pretty-print the status of a cluster, including + JSON and YAML output +- Add `kubectl cnp certificate` to enable TLS authentication for client applications +- Add the `-ro` service to route connections to the available hot + standby replicas only, enabling offload of read-only queries from + the cluster's primary instance +- Rollback scaling down a cluster to a value lower than `maxSyncReplicas` +- Request a checkpoint before demoting a former primary +- Send `SIGINT` signal (fast shutdown) to PostgreSQL process on `SIGTERM` +- Minor bug fixes + +## Version 1.0.0 + +**Release date:** 4 Feb 2021 + +The first major stable release of Cloud Native PostgreSQL implements `Cluster`, +`Backup` and `ScheduledBackup` in the API group `postgresql.k8s.enterprisedb.io/v1`. +It uses these resources to create and manage PostgreSQL clusters inside +Kubernetes with the following main capabilities: + +- Direct integration with Kubernetes API server for High Availability, without + requiring an external tool +- Self-Healing capability, through: + - failover of the primary instance by promoting the most aligned replica + - automated recreation of a replica +- Planned switchover of the primary instance by promoting a selected replica +- Scale up/down capabilities +- Definition of an arbitrary number of instances (minimum 1 - one primary server) +- Definition of the *read-write* service to connect your applications to the + only primary server of the cluster +- Definition of the *read* service to connect your applications to any of the + instances for reading workloads +- Support for Local Persistent Volumes with PVC templates +- Reuse of Persistent Volumes storage in Pods +- Rolling updates for PostgreSQL minor versions and operator upgrades +- TLS connections and client certificate authentication +- Continuous backup to an S3 compatible object store +- Full recovery and point-in-time recovery from an S3 compatible object store backup +- Support for synchronous replicas +- Support for node affinity via `nodeSelector` property +- Standard output logging of PostgreSQL error messages + diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/resource_management.mdx b/advocacy_docs/kubernetes/cloud_native_postgresql/resource_management.mdx new file mode 100644 index 00000000000..6257b775957 --- /dev/null +++ b/advocacy_docs/kubernetes/cloud_native_postgresql/resource_management.mdx @@ -0,0 +1,100 @@ +--- +title: 'Resource management' +originalFilePath: 'src/resource_management.md' +product: 'Cloud Native Operator' +--- + +In a typical Kubernetes cluster, pods run with unlimited resources. By default, +they might be allowed to use as much CPU and RAM as needed. + +Cloud Native PostgreSQL allows administrators to control and manage resource usage by the pods of the cluster, +through the `resources` section of the manifest, with two knobs: + +- `requests`: initial requirement +- `limits`: maximum usage, in case of dynamic increase of resource needs + +For example, you can request an initial amount of RAM of 32MiB (scalable to 128MiB) and 50m of CPU (scalable to 100m) +as follows: + +```yaml + resources: + requests: + memory: "32Mi" + cpu: "50m" + limits: + memory: "128Mi" + cpu: "100m" +``` + +Memory requests and limits are associated with containers, but it is useful to think of a pod as having a memory request +and limit. The pod's memory request is the sum of the memory requests for all the containers in the pod. + +Pod scheduling is based on requests and not on limits. A pod is scheduled to run on a Node only if the Node has enough +available memory to satisfy the pod's memory request. + +For each resource, we divide containers into 3 Quality of Service (QoS) classes, in decreasing order of priority: + +- *Guaranteed* +- *Burstable* +- *Best-Effort* + +For more details, please refer to the ["Configure Quality of Service for Pods"](https://kubernetes.io/docs/tasks/configure-pod-container/quality-service-pod/#qos-classes) +section in the Kubernetes documentation. + +For a PostgreSQL workload it is recommended to set a "Guaranteed" QoS. + +To avoid resources related issues in Kubernetes, we can refer to the best practices for "out of resource" handling +while creating a cluster: + +- Specify your required values for memory and CPU in the resources section of the manifest file. + This way, you can avoid the `OOM Killed` (where "OOM" stands for Out Of Memory) and `CPU throttle` or any other + resources related issues on running instances. +- For your cluster's pods to get assigned to the "Guaranteed" QoS class, you must set limits and requests + for both memory and CPU to the same value. +- Specify your required PostgreSQL memory parameters consistently with the pod resources (as you would do + in a VM or physical machine scenario - see below). +- Set up database server pods on a dedicated node using nodeSelector. + See the ["nodeSelector field of the affinityconfiguration resource on the API reference page"](api_reference.md#affinityconfiguration). + +You can refer to the following example manifest: + +```yaml +apiVersion: postgresql.k8s.enterprisedb.io/v1 +kind: Cluster +metadata: + name: postgresql-resources +spec: + + instances: 3 + + postgresql: + parameters: + shared_buffers: "256MB" + + resources: + requests: + memory: "1024Mi" + cpu: 1 + limits: + memory: "1024Mi" + cpu: 1 + + storage: + size: 1Gi +``` + +In the above example, we have specified `shared_buffers` parameter with a value of `256MB` - i.e., how much memory is +dedicated to the PostgreSQL server for caching data (the default value for this parameter is `128MB` in case +it's not defined). + +A reasonable starting value for `shared_buffers` is 25% of the memory in your system. +For example: if your `shared_buffers` is 256 MB, then the recommended value for your container memory size is 1 GB, +which means that within a pod all the containers will have a total of 1 GB memory that Kubernetes will always preserve, +enabling our containers to work as expected. +For more details, please refer to the ["Resource Consumption"](https://www.postgresql.org/docs/current/runtime-config-resource.html) +section in the PostgreSQL documentation. + +!!! Seealso "Managing Compute Resources for Containers" + For more details on resource management, please refer to the + ["Managing Compute Resources for Containers"](https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/) + page from the Kubernetes documentation. diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/rolling_update.mdx b/advocacy_docs/kubernetes/cloud_native_postgresql/rolling_update.mdx new file mode 100644 index 00000000000..b6fb6400a8b --- /dev/null +++ b/advocacy_docs/kubernetes/cloud_native_postgresql/rolling_update.mdx @@ -0,0 +1,46 @@ +--- +title: 'Rolling Updates' +originalFilePath: 'src/rolling_update.md' +product: 'Cloud Native Operator' +--- + +The operator allows changing the PostgreSQL version used in a cluster while +applications are running against it. + +!!! Important + Only upgrades for PostgreSQL minor releases are supported. + +Rolling upgrades are started when: + +- the user changes the `imageName` attribute of the cluster specification; + +- after the operator is updated, to ensure the Pods run the latest instance + manager; + +- when a change in the PostgreSQL configuration requires a restart to be + applied. + +The operator starts upgrading all the replicas, one Pod at a time, starting +from the one with the highest serial. + +The primary is the last node to be upgraded. This operation is configurable and +managed by the `primaryUpdateStrategy` option, accepting these two values: + +- `unsupervised`: the rolling update process is managed by Kubernetes + and is entirely automated, with the *switchover* operation + starting once all the replicas have been upgraded +- `supervised`: the rolling update process is suspended immediately + after all replicas have been upgraded and can only be completed + with a manual switchover triggered by an administrator with + `kubectl cnp promote [cluster] [pod]`. The plugin can be downloaded from the + [`kubectl-cnp` project page](https://github.com/EnterpriseDB/kubectl-cnp) + on GitHub. + +The default and recommended value is `unsupervised`. + +The upgrade keeps the Cloud Native PostgreSQL identity and does not +re-clone the data. Pods will be deleted and created again with the same PVCs. + +During the rolling update procedure, the services endpoints move to reflect +the cluster's status, so the applications ignore the node that +is updating. diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/samples.mdx b/advocacy_docs/kubernetes/cloud_native_postgresql/samples.mdx new file mode 100644 index 00000000000..3c3da7196ca --- /dev/null +++ b/advocacy_docs/kubernetes/cloud_native_postgresql/samples.mdx @@ -0,0 +1,22 @@ +--- +title: 'Configuration Samples' +originalFilePath: 'src/samples.md' +product: 'Cloud Native Operator' +--- + +In this section, you can find some examples of configuration files to set up your PostgreSQL `Cluster`. + +* [`cluster-example.yaml`](../samples/cluster-example.yaml): + a basic example of `Cluster` that uses the default storage class. For demonstration and experimentation purposes + on a personal Kubernetes cluster with Minikube or Kind as described in the ["Quickstart"](quickstart.md). +* [`cluster-example-custom.yaml`](../samples/cluster-example-custom.yaml): + a basic example of `Cluster` that uses the default storage class and custom parameters for `postgresql.conf` and + `pg_hba.conf` files +* [`cluster-storage-class.yaml`](../samples/cluster-storage-class.yaml): + a basic example of `Cluster` that uses a specified storage class. +* [`cluster-pvc-template.yaml`](../samples/cluster-pvc-template.yaml): + a basic example of `Cluster` that uses a persistent volume claim template. +* [`cluster-example-full.yaml`](../samples/cluster-example-full.yaml): + an example of `Cluster` that sets most of the available options. + +For a list of available options, please refer to the ["API Reference" page](api_reference.md). diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/samples/backup-example.yaml b/advocacy_docs/kubernetes/cloud_native_postgresql/samples/backup-example.yaml new file mode 100644 index 00000000000..20584cc403d --- /dev/null +++ b/advocacy_docs/kubernetes/cloud_native_postgresql/samples/backup-example.yaml @@ -0,0 +1,7 @@ +apiVersion: postgresql.k8s.enterprisedb.io/v1 +kind: Backup +metadata: + name: backup-example +spec: + cluster: + name: pg-backup diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/samples/cluster-example-custom.yaml b/advocacy_docs/kubernetes/cloud_native_postgresql/samples/cluster-example-custom.yaml new file mode 100644 index 00000000000..49223affa68 --- /dev/null +++ b/advocacy_docs/kubernetes/cloud_native_postgresql/samples/cluster-example-custom.yaml @@ -0,0 +1,28 @@ +apiVersion: postgresql.k8s.enterprisedb.io/v1 +kind: Cluster +metadata: + name: cluster-example-custom +spec: + instances: 3 + + # Parameters and pg_hba configuration will be append + # to the default ones to make the cluster work + postgresql: + parameters: + max_worker_processes: "60" + pg_hba: + # To access through TCP/IP you will need to get username + # and password from the secret cluster-example-custom-app + - host all all all md5 + + + # Example of rolling update strategy: + # - unsupervised: automated update of the primary once all + # replicas have been upgraded (default) + # - supervised: requires manual supervision to perform + # the switchover of the primary + primaryUpdateStrategy: unsupervised + + # Require 1Gi of space per instance using default storage class + storage: + size: 1Gi diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/samples/cluster-example-epas.yaml b/advocacy_docs/kubernetes/cloud_native_postgresql/samples/cluster-example-epas.yaml new file mode 100644 index 00000000000..c06d19e1b7d --- /dev/null +++ b/advocacy_docs/kubernetes/cloud_native_postgresql/samples/cluster-example-epas.yaml @@ -0,0 +1,14 @@ +apiVersion: postgresql.k8s.enterprisedb.io/v1 +kind: Cluster +metadata: + name: cluster-example +spec: + instances: 3 + # imageName: docker-epas:13 + + bootstrap: + initdb: + redwood: false + + storage: + size: 1Gi diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/samples/cluster-example-full.yaml b/advocacy_docs/kubernetes/cloud_native_postgresql/samples/cluster-example-full.yaml new file mode 100644 index 00000000000..71e497e2baf --- /dev/null +++ b/advocacy_docs/kubernetes/cloud_native_postgresql/samples/cluster-example-full.yaml @@ -0,0 +1,104 @@ +# Example of definition of a test cluster using all the elements available +# in the CRD. Please change values appropriately for your environment. +# Remember that you can take advantage of convention over configuration +# and normally you don't need to use all these definitions. + +apiVersion: v1 +data: + password: cGFzc3dvcmQ= +kind: Secret +metadata: + name: cluster-example-app-user +type: kubernetes.io/basic-auth +--- +apiVersion: v1 +data: + password: cGFzc3dvcmQ= +kind: Secret +metadata: + name: cluster-example-superuser +type: kubernetes.io/basic-auth +--- +apiVersion: v1 +kind: Secret +metadata: + name: backup-creds +data: + ACCESS_KEY_ID: a2V5X2lk + ACCESS_SECRET_KEY: c2VjcmV0X2tleQ== +--- +apiVersion: postgresql.k8s.enterprisedb.io/v1 +kind: Cluster +metadata: + name: cluster-example-full +spec: + description: "Example of cluster" + imageName: quay.io/enterprisedb/postgresql:13.2 + # imagePullSecret is only required if the images are located in a private registry + # imagePullSecrets: + # - name: private_registry_access + instances: 3 + #licenseKey: insert_valid_license_here + startDelay: 300 + stopDelay: 300 + primaryUpdateStrategy: unsupervised + + postgresql: + parameters: + shared_buffers: 256MB + pg_hba: + - host all all 10.244.0.0/16 md5 + + bootstrap: + initdb: + database: appdb + owner: appuser + secret: + name: cluster-example-app-user + # Alternative bootstrap method: start from a backup + #recovery: + # backup: + # name: backup-example + + superuserSecret: + name: cluster-example-superuser + + storage: + storageClass: standard + size: 1Gi + + backup: + barmanObjectStore: + destinationPath: s3://cluster-example-full-backup/ + endpointURL: http://custom-endpoint:1234 + s3Credentials: + accessKeyId: + name: backup-creds + key: ACCESS_KEY_ID + secretAccessKey: + name: backup-creds + key: ACCESS_SECRET_KEY + wal: + compression: gzip + encryption: AES256 + data: + compression: gzip + encryption: AES256 + immediateCheckpoint: false + jobs: 2 + + resources: + requests: + memory: "512Mi" + cpu: "1" + limits: + memory: "1Gi" + cpu: "2" + + affinity: + enablePodAntiAffinity: true + topologyKey: failure-domain.beta.kubernetes.io/zone + + nodeMaintenanceWindow: + inProgress: false + reusePVC: false diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/samples/cluster-example-initdb.yaml b/advocacy_docs/kubernetes/cloud_native_postgresql/samples/cluster-example-initdb.yaml new file mode 100644 index 00000000000..31a014f535e --- /dev/null +++ b/advocacy_docs/kubernetes/cloud_native_postgresql/samples/cluster-example-initdb.yaml @@ -0,0 +1,16 @@ +apiVersion: postgresql.k8s.enterprisedb.io/v1 +kind: Cluster +metadata: + name: cluster-example-initdb +spec: + instances: 3 + + bootstrap: + initdb: + database: appdb + owner: appuser + options: + - "-k" + - "--locale=en_US" + storage: + size: 1Gi diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/samples/cluster-example-monitoring.yaml b/advocacy_docs/kubernetes/cloud_native_postgresql/samples/cluster-example-monitoring.yaml new file mode 100644 index 00000000000..88edcf51db9 --- /dev/null +++ b/advocacy_docs/kubernetes/cloud_native_postgresql/samples/cluster-example-monitoring.yaml @@ -0,0 +1,235 @@ +apiVersion: postgresql.k8s.enterprisedb.io/v1 +kind: Cluster +metadata: + name: cluster-example +spec: + instances: 3 + + storage: + size: 1Gi + + monitoring: + customQueriesConfigMap: + - name: example-monitoring + key: custom-queries + customQueriesSecret: + - name: example-monitoring-secret + key: pg-database +--- +apiVersion: v1 +kind: ConfigMap +metadata: + namespace: default + name: example-monitoring +data: + custom-queries: | + pg_replication: + query: "SELECT CASE WHEN NOT pg_is_in_recovery() THEN 0 ELSE GREATEST (0, EXTRACT(EPOCH FROM (now() - pg_last_xact_replay_timestamp()))) END AS lag" + primary: true + metrics: + - lag: + usage: "GAUGE" + description: "Replication lag behind primary in seconds" + + pg_postmaster: # wokeignore:rule=master + query: "SELECT pg_postmaster_start_time as start_time_seconds from pg_postmaster_start_time()" # wokeignore:rule=master + primary: true + metrics: + - start_time_seconds: + usage: "GAUGE" + description: "Time at which postmaster started" # wokeignore:rule=master + + pg_stat_user_tables: + query: | + SELECT + current_database() datname, + schemaname, + relname, + seq_scan, + seq_tup_read, + idx_scan, + idx_tup_fetch, + n_tup_ins, + n_tup_upd, + n_tup_del, + n_tup_hot_upd, + n_live_tup, + n_dead_tup, + n_mod_since_analyze, + COALESCE(last_vacuum, '1970-01-01Z') as last_vacuum, + COALESCE(last_autovacuum, '1970-01-01Z') as last_autovacuum, + COALESCE(last_analyze, '1970-01-01Z') as last_analyze, + COALESCE(last_autoanalyze, '1970-01-01Z') as last_autoanalyze, + vacuum_count, + autovacuum_count, + analyze_count, + autoanalyze_count + FROM + pg_stat_user_tables + metrics: + - datname: + usage: "LABEL" + description: "Name of current database" + - schemaname: + usage: "LABEL" + description: "Name of the schema that this table is in" + - relname: + usage: "LABEL" + description: "Name of this table" + - seq_scan: + usage: "COUNTER" + description: "Number of sequential scans initiated on this table" + - seq_tup_read: + usage: "COUNTER" + description: "Number of live rows fetched by sequential scans" + - idx_scan: + usage: "COUNTER" + description: "Number of index scans initiated on this table" + - idx_tup_fetch: + usage: "COUNTER" + description: "Number of live rows fetched by index scans" + - n_tup_ins: + usage: "COUNTER" + description: "Number of rows inserted" + - n_tup_upd: + usage: "COUNTER" + description: "Number of rows updated" + - n_tup_del: + usage: "COUNTER" + description: "Number of rows deleted" + - n_tup_hot_upd: + usage: "COUNTER" + description: "Number of rows HOT updated (i.e., with no separate index update required)" + - n_live_tup: + usage: "GAUGE" + description: "Estimated number of live rows" + - n_dead_tup: + usage: "GAUGE" + description: "Estimated number of dead rows" + - n_mod_since_analyze: + usage: "GAUGE" + description: "Estimated number of rows changed since last analyze" + - last_vacuum: + usage: "GAUGE" + description: "Last time at which this table was manually vacuumed (not counting VACUUM FULL)" + - last_autovacuum: + usage: "GAUGE" + description: "Last time at which this table was vacuumed by the autovacuum daemon" + - last_analyze: + usage: "GAUGE" + description: "Last time at which this table was manually analyzed" + - last_autoanalyze: + usage: "GAUGE" + description: "Last time at which this table was analyzed by the autovacuum daemon" + - vacuum_count: + usage: "COUNTER" + description: "Number of times this table has been manually vacuumed (not counting VACUUM FULL)" + - autovacuum_count: + usage: "COUNTER" + description: "Number of times this table has been vacuumed by the autovacuum daemon" + - analyze_count: + usage: "COUNTER" + description: "Number of times this table has been manually analyzed" + - autoanalyze_count: + usage: "COUNTER" + description: "Number of times this table has been analyzed by the autovacuum daemon" + + pg_statio_user_tables: + query: "SELECT current_database() datname, schemaname, relname, heap_blks_read, heap_blks_hit, idx_blks_read, idx_blks_hit, toast_blks_read, toast_blks_hit, tidx_blks_read, tidx_blks_hit FROM pg_statio_user_tables" + metrics: + - datname: + usage: "LABEL" + description: "Name of current database" + - schemaname: + usage: "LABEL" + description: "Name of the schema that this table is in" + - relname: + usage: "LABEL" + description: "Name of this table" + - heap_blks_read: + usage: "COUNTER" + description: "Number of disk blocks read from this table" + - heap_blks_hit: + usage: "COUNTER" + description: "Number of buffer hits in this table" + - idx_blks_read: + usage: "COUNTER" + description: "Number of disk blocks read from all indexes on this table" + - idx_blks_hit: + usage: "COUNTER" + description: "Number of buffer hits in all indexes on this table" + - toast_blks_read: + usage: "COUNTER" + description: "Number of disk blocks read from this table's TOAST table (if any)" + - toast_blks_hit: + usage: "COUNTER" + description: "Number of buffer hits in this table's TOAST table (if any)" + - tidx_blks_read: + usage: "COUNTER" + description: "Number of disk blocks read from this table's TOAST table indexes (if any)" + - tidx_blks_hit: + usage: "COUNTER" + description: "Number of buffer hits in this table's TOAST table indexes (if any)" + + pg_stat_activity: + query: | + WITH + metrics AS ( + SELECT + application_name, + SUM(EXTRACT(EPOCH FROM (CURRENT_TIMESTAMP - state_change))::bigint)::float AS process_idle_seconds_sum, + COUNT(*) AS process_idle_seconds_count + FROM pg_stat_activity + WHERE state = 'idle' + GROUP BY application_name + ), + buckets AS ( + SELECT + application_name, + le, + SUM( + CASE WHEN EXTRACT(EPOCH FROM (CURRENT_TIMESTAMP - state_change)) <= le + THEN 1 + ELSE 0 + END + )::bigint AS bucket + FROM + pg_stat_activity, + UNNEST(ARRAY[1, 2, 5, 15, 30, 60, 90, 120, 300]) AS le + GROUP BY application_name, le + ORDER BY application_name, le + ) + SELECT + application_name, + process_idle_seconds_sum, + process_idle_seconds_count, + ARRAY_AGG(le) AS process_idle_seconds, + ARRAY_AGG(bucket) AS process_idle_seconds_bucket + FROM metrics JOIN buckets USING (application_name) + GROUP BY 1, 2, 3 + metrics: + - application_name: + usage: "LABEL" + description: "Application Name" + - process_idle_seconds: + usage: "HISTOGRAM" + description: "Idle time of server processes" +--- +apiVersion: v1 +kind: Secret +metadata: + namespace: default + name: example-monitoring-secret +stringData: + pg-database: | + pg_database: + query: "SELECT pg_database.datname, pg_database_size(pg_database.datname) as size_bytes FROM pg_database" + primary: true + cache_seconds: 30 + metrics: + - datname: + usage: "LABEL" + description: "Name of the database" + - size_bytes: + usage: "GAUGE" + description: "Disk space used by the database" diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/samples/cluster-example-secret.yaml b/advocacy_docs/kubernetes/cloud_native_postgresql/samples/cluster-example-secret.yaml new file mode 100644 index 00000000000..991261172d5 --- /dev/null +++ b/advocacy_docs/kubernetes/cloud_native_postgresql/samples/cluster-example-secret.yaml @@ -0,0 +1,35 @@ +apiVersion: postgresql.k8s.enterprisedb.io/v1 +kind: Cluster +metadata: + name: cluster-example-secret +spec: + instances: 3 + + bootstrap: + initdb: + database: appdb + owner: appuser + secret: + name: cluster-example-app-user + + superuserSecret: + name: cluster-example-superuser + + storage: + size: 1Gi +--- +apiVersion: v1 +data: + password: cGFzc3dvcmQ= +kind: Secret +metadata: + name: cluster-example-app-user +type: kubernetes.io/basic-auth +--- +apiVersion: v1 +data: + password: cGFzc3dvcmQ= +kind: Secret +metadata: + name: cluster-example-superuser +type: kubernetes.io/basic-auth diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/samples/cluster-example-syncreplicas.yaml b/advocacy_docs/kubernetes/cloud_native_postgresql/samples/cluster-example-syncreplicas.yaml new file mode 100644 index 00000000000..2c0e4da2d86 --- /dev/null +++ b/advocacy_docs/kubernetes/cloud_native_postgresql/samples/cluster-example-syncreplicas.yaml @@ -0,0 +1,12 @@ +apiVersion: postgresql.k8s.enterprisedb.io/v1 +kind: Cluster +metadata: + name: cluster-example-syncreplicas +spec: + instances: 5 + + minSyncReplicas: 1 + maxSyncReplicas: 3 + + storage: + size: 1G diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/samples/cluster-example.yaml b/advocacy_docs/kubernetes/cloud_native_postgresql/samples/cluster-example.yaml new file mode 100644 index 00000000000..230b7b5fcc5 --- /dev/null +++ b/advocacy_docs/kubernetes/cloud_native_postgresql/samples/cluster-example.yaml @@ -0,0 +1,9 @@ +apiVersion: postgresql.k8s.enterprisedb.io/v1 +kind: Cluster +metadata: + name: cluster-example +spec: + instances: 3 + + storage: + size: 1Gi diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/samples/cluster-expose-service.yaml b/advocacy_docs/kubernetes/cloud_native_postgresql/samples/cluster-expose-service.yaml new file mode 100644 index 00000000000..201b25e1643 --- /dev/null +++ b/advocacy_docs/kubernetes/cloud_native_postgresql/samples/cluster-expose-service.yaml @@ -0,0 +1,36 @@ +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: tcp-services + namespace: ingress-nginx +data: + 5432: default/cluster-example-rw:5432 + +--- +apiVersion: v1 +kind: Service +metadata: + name: ingress-nginx + namespace: ingress-nginx + labels: + app.kubernetes.io/name: ingress-nginx + app.kubernetes.io/part-of: ingress-nginx +spec: + type: LoadBalancer + ports: + - name: http + port: 80 + targetPort: 80 + protocol: TCP + - name: https + port: 443 + targetPort: 443 + protocol: TCP + - name: postgres + port: 5432 + targetPort: 5432 + protocol: TCP + selector: + app.kubernetes.io/name: ingress-nginx + app.kubernetes.io/part-of: ingress-nginx diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/samples/cluster-pvc-template.yaml b/advocacy_docs/kubernetes/cloud_native_postgresql/samples/cluster-pvc-template.yaml new file mode 100644 index 00000000000..7e608bd8bca --- /dev/null +++ b/advocacy_docs/kubernetes/cloud_native_postgresql/samples/cluster-pvc-template.yaml @@ -0,0 +1,24 @@ +apiVersion: postgresql.k8s.enterprisedb.io/v1 +kind: Cluster +metadata: + name: postgresql-pvc-template +spec: + instances: 3 + + # Example of rolling update strategy: + # - unsupervised: automated update of the primary once all + # replicas have been upgraded (default) + # - supervised: requires manual supervision to perform + # the switchover of the primary + primaryUpdateStrategy: unsupervised + + # Persistent storage configuration + storage: + pvcTemplate: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 1Gi + storageClassName: standard + volumeMode: Filesystem diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/samples/cluster-restore-pitr.yaml b/advocacy_docs/kubernetes/cloud_native_postgresql/samples/cluster-restore-pitr.yaml new file mode 100644 index 00000000000..0fd04c6f1a4 --- /dev/null +++ b/advocacy_docs/kubernetes/cloud_native_postgresql/samples/cluster-restore-pitr.yaml @@ -0,0 +1,17 @@ +apiVersion: postgresql.k8s.enterprisedb.io/v1 +kind: Cluster +metadata: + name: cluster-restore-pitr +spec: + instances: 3 + + storage: + size: 5Gi + + bootstrap: + recovery: + backup: + name: backup-example + + recoveryTarget: + targetTime: "2020-11-26 15:22:00.00000+00" diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/samples/cluster-restore.yaml b/advocacy_docs/kubernetes/cloud_native_postgresql/samples/cluster-restore.yaml new file mode 100644 index 00000000000..ae3f0bc74a5 --- /dev/null +++ b/advocacy_docs/kubernetes/cloud_native_postgresql/samples/cluster-restore.yaml @@ -0,0 +1,14 @@ +apiVersion: postgresql.k8s.enterprisedb.io/v1 +kind: Cluster +metadata: + name: cluster-restore +spec: + instances: 3 + + storage: + size: 5Gi + + bootstrap: + recovery: + backup: + name: backup-example diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/samples/cluster-storage-class-with-backup.yaml b/advocacy_docs/kubernetes/cloud_native_postgresql/samples/cluster-storage-class-with-backup.yaml new file mode 100644 index 00000000000..a2d62d06b2f --- /dev/null +++ b/advocacy_docs/kubernetes/cloud_native_postgresql/samples/cluster-storage-class-with-backup.yaml @@ -0,0 +1,32 @@ +apiVersion: postgresql.k8s.enterprisedb.io/v1 +kind: Cluster +metadata: + name: pg-backup +spec: + instances: 3 + + # Example of rolling update strategy: + # - unsupervised: automated update of the primary once all + # replicas have been upgraded (default) + # - supervised: requires manual supervision to perform + # the switchover of the primary + primaryUpdateStrategy: unsupervised + + # Persistent storage configuration + storage: + storageClass: standard + size: 1Gi + + # Backup properties + backup: + barmanObjectStore: + destinationPath: s3://BUCKET_NAME/path/to/folder + s3Credentials: + accessKeyId: + name: aws-creds + key: ACCESS_KEY_ID + secretAccessKey: + name: aws-creds + key: ACCESS_SECRET_KEY + wal: + compression: gzip diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/samples/cluster-storage-class.yaml b/advocacy_docs/kubernetes/cloud_native_postgresql/samples/cluster-storage-class.yaml new file mode 100644 index 00000000000..f3e614e39ee --- /dev/null +++ b/advocacy_docs/kubernetes/cloud_native_postgresql/samples/cluster-storage-class.yaml @@ -0,0 +1,18 @@ +apiVersion: postgresql.k8s.enterprisedb.io/v1 +kind: Cluster +metadata: + name: postgresql-storage-class +spec: + instances: 3 + + # Example of rolling update strategy: + # - unsupervised: automated update of the primary once all + # replicas have been upgraded (default) + # - supervised: requires manual supervision to perform + # the switchover of the primary + primaryUpdateStrategy: unsupervised + + # Persistent storage configuration + storage: + storageClass: standard + size: 1Gi diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/samples/scheduled-backup-example.yaml b/advocacy_docs/kubernetes/cloud_native_postgresql/samples/scheduled-backup-example.yaml new file mode 100644 index 00000000000..b51ecc29deb --- /dev/null +++ b/advocacy_docs/kubernetes/cloud_native_postgresql/samples/scheduled-backup-example.yaml @@ -0,0 +1,8 @@ +apiVersion: postgresql.k8s.enterprisedb.io/v1 +kind: ScheduledBackup +metadata: + name: backup-example +spec: + schedule: "0 0 0 * * *" + cluster: + name: pg-backup diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/samples/subscription.yaml b/advocacy_docs/kubernetes/cloud_native_postgresql/samples/subscription.yaml new file mode 100644 index 00000000000..20ff6874ee6 --- /dev/null +++ b/advocacy_docs/kubernetes/cloud_native_postgresql/samples/subscription.yaml @@ -0,0 +1,10 @@ +apiVersion: operators.coreos.com/v1alpha1 +kind: Subscription +metadata: + name: cloud-native-postgresql + namespace: openshift-operators +spec: + channel: stable + name: cloud-native-postgresql + source: certified-operators + sourceNamespace: openshift-marketplace diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/security.mdx b/advocacy_docs/kubernetes/cloud_native_postgresql/security.mdx new file mode 100644 index 00000000000..0be2c0e122f --- /dev/null +++ b/advocacy_docs/kubernetes/cloud_native_postgresql/security.mdx @@ -0,0 +1,138 @@ +--- +title: 'Security' +originalFilePath: 'src/security.md' +product: 'Cloud Native Operator' +--- + +This section contains information about security for Cloud Native PostgreSQL, +that are analyzed at 3 different layers: Code, Container and Cluster. + +!!! Warning + The information contained in this page must not exonerate you from + performing regular InfoSec duties on your Kubernetes cluster. Please + familiarize with the ["Overview of Cloud Native Security"](https://kubernetes.io/docs/concepts/security/overview/) + page from the Kubernetes documentation. + +!!! Seealso "About the 4C's Security Model" + Please refer to ["The 4C’s Security Model in Kubernetes"](https://www.enterprisedb.com/blog/4cs-security-model-kubernetes) + blog article to get a better understanding and context of the approach EDB + has taken with security in Cloud Native PostgreSQL. + +## Code + +Source code of Cloud Native PostgreSQL is *systematically scanned* for static analysis purposes, +including **security problems**, using a popular open-source linter for Go called +[GolangCI-Lint](https://github.com/golangci/golangci-lint) directly in the CI/CD pipeline. +GolangCI-Lint can run several *linters* on the same source code. + +One of these is [Golang Security Checker](https://github.com/securego/gosec), or simply `gosec`, +a linter that scans the abstract syntactic tree of the source against a set of rules aimed at +the discovery of well-known vulnerabilities, threats, and weaknesses hidden in +the code such as hard-coded credentials, integer overflows and SQL injections - to name a few. + +!!! Important + A failure in the static code analysis phase of the CI/CD pipeline is a blocker + for the entire delivery of Cloud Native PostgreSQL, meaning that each commit is validated + against all the linters defined by GolangCI-Lint. + +Source code is also regularly inspected through [Coverity Scan by Synopsys](https://scan.coverity.com/) +via EnterpriseDB's internal CI/CD pipeline. + +## Container + +Every container image that is part of Cloud Native PostgreSQL is automatically built via CI/CD pipelines following every commit. +Such images include not only the operator's, but also the operands' - specifically every supported PostgreSQL and EDB Postgres Advanced version. +Within the pipelines, images are scanned with: + +- [Dockle](https://github.com/goodwithtech/dockle): for best practices in terms + of the container build process +- [Clair](https://github.com/quay/clair): for vulnerabilities found in both the + underlying operating system as well as libraries and applications that they run + +!!! Important + All operand images are automatically rebuilt once a day by our pipelines in case + of security updates at the base image and package level, providing **patch level updates** + for the container images that EDB distributes. + +The following guidelines and frameworks have been taken into account for container-level security: + +- the ["Container Image Creation and Deployment Guide"](https://dl.dod.cyber.mil/wp-content/uploads/devsecops/pdf/DevSecOps_Enterprise_Container_Image_Creation_and_Deployment_Guide_2.6-Public-Release.pdf), + developed by the Defense Information Systems Agency (DISA) of the United States Department of Defense (DoD) +- the ["CIS Benchmark for Docker"](https://www.cisecurity.org/benchmark/docker/), + developed by the Center for Internet Security (CIS) + +!!! Seealso "About the Container level security" + Please refer to ["Security and Containers in Cloud Native PostgreSQL"](https://www.enterprisedb.com/blog/security-and-containers-cloud-native-postgresql) + blog article for more information about the approach that EDB has taken on + security at container level in Cloud Native PostgreSQL. + +## Cluster + +Security at the cluster level takes into account all Kubernetes components that +form both the control plane and the nodes, as well as the applications that run in +the cluster (PostgreSQL included). + +### Pod Security Policies + +A [Pod Security Policy](https://kubernetes.io/docs/concepts/policy/pod-security-policy/) +is the Kubernetes way to define security rules and specifications that a pod needs to meet +to run in a cluster. +For InfoSec reasons, every Kubernetes platform should implement them. + +Cloud Native PostgreSQL does not require *privileged* mode for containers execution. +PostgreSQL servers run as `postgres` system user. No component whatsoever requires to run as `root`. + +Likewise, Volumes access does not require *privileges* mode or `root` privileges either. +Proper permissions must be properly assigned by the Kubernetes platform and/or administrators. + +The operator explicitly sets the required security contexts. + +On RedHat OpenShift, Cloud Native PostgreSQL runs in `restricted` security context constraint, +the most restrictive one. The goal is to limit the execution of a pod to a namespace allocated UID +and SELinux context. + +!!! Seealso "Security Context Constraints in OpenShift" + For further information on Security Context Constraints (SCC) in + OpenShift, please refer to the + ["Managing SCC in OpenShift"](https://www.openshift.com/blog/managing-sccs-in-openshift) + article. + +### Network Policies + +The pods created by the `Cluster` resource can be controlled by Kubernetes +[network policies](https://kubernetes.io/docs/concepts/services-networking/network-policies/) +to enable/disable inbound and outbound network access at IP and TCP level. + +!!! Important + The operator needs to communicate to each instance on TCP port 8000 + to get information about the status of the PostgreSQL server. Make sure + you keep this in mind in case you add any network policy. + +Network policies are beyond the scope of this document. +Please refer to the ["Network policies"](https://kubernetes.io/docs/concepts/services-networking/network-policies/) +section of the Kubernetes documentation for further information. + +### PostgreSQL + +The current implementation of Cloud Native PostgreSQL automatically creates +passwords and `.pgpass` files for the `postgres` superuser and the database owner. +See the ["Secrets" section in the "Architecture" page](architecture.md#secrets). + +You can use those files to configure application access to the database. + +By default, every replica is automatically configured to connect in **physical +async streaming replication** with the current primary instance, with a special +user called `streaming_replica`. The connection between nodes is **encrypted** +and authentication is via **TLS client certificates** (please refer to the +["Client TLS/SSL Connections"](ssl_connections.md#Client TLS/SSL Connections) page +for details). + +Currently, the operator allows administrators to add `pg_hba.conf` lines directly in the manifest +as part of the `pg_hba` section of the `postgresql` configuration. The lines defined in the +manifest are added to a default `pg_hba.conf`. + +For further detail on how `pg_hba.conf` is managed by the operator, see the +["PostgreSQL Configuration" page](postgresql_conf.md#the-pg_hba-section) of the documentation. + +!!! Important + Examples assume that the Kubernetes cluster runs in a private and secure network. diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/ssl_connections.mdx b/advocacy_docs/kubernetes/cloud_native_postgresql/ssl_connections.mdx new file mode 100644 index 00000000000..bda8a53b6bb --- /dev/null +++ b/advocacy_docs/kubernetes/cloud_native_postgresql/ssl_connections.mdx @@ -0,0 +1,169 @@ +--- +title: 'Client TLS/SSL Connections' +originalFilePath: 'src/ssl_connections.md' +product: 'Cloud Native Operator' +--- + +The Cloud Native PostgreSQL operator has been designed to work with TLS/SSL for both encryption in transit and +authentication, on server and client sides. Clusters created using the CNP operator come with a Certification +Authority (CA) to create and sign TLS client certificates. Through the `cnp` plugin for `kubectl` you can +issue a new TLS client certificate which can be used to authenticate a user in lieu of passwords. + +Please refer to the following steps to authenticate via TLS/SSL certificates, which assume you have +installed a cluster using the [cluster-example.yaml](../samples/cluster-example.yaml) deployment manifest. +According to the convention over configuration paradigm, that file automatically creates a `app` database +which is owned by a user called `app` (you can change this convention through the `initdb` configuration +in the `bootstrap` section). + + +## Issuing a new certificate + +!!! See also "About CNP plugin for kubectl" + Please refer to the ["Certificates" section in the "Cloud Native PostgreSQL Plugin"](cnp-plugin.md#certificates) + page for details on how to use the plugin for `kubectl`. + +You can create a certificate for the `app` user in the `cluster-example` PostgreSQL cluster as follows: + +```shell +kubectl cnp certificate cluster-app \ + --cnp-cluster cluster-example \ + --cnp-user app +``` + +You can now verify the certificate with: + +```shell +kubectl get secret cluster-app \ + -o jsonpath="{.data['tls\.crt']}" \ + | base64 -d | openssl x509 -text -noout \ + | head -n 11 +``` + +Output: + +```console + +Certificate: + Data: + Version: 3 (0x2) + Serial Number: + 5d:e1:72:8a:39:9f:ce:51:19:9d:21:ff:1e:4b:24:5d + Signature Algorithm: ecdsa-with-SHA256 + Issuer: OU = default, CN = cluster-example + Validity + Not Before: Mar 22 10:22:14 2021 GMT + Not After : Mar 22 10:22:14 2022 GMT + Subject: CN = app +``` + +As you can see, TLS client certificates by default are created with one year of validity, and with a simple CN that +corresponds to the username in PostgreSQL. This is necessary to leverage the `cert` authentication method for `hostssl` +entries in `pg_hba.conf`. + +## Testing the connection via a TLS certificate + +Now we will test this client certificate by configuring a demo client application that connects to our Cloud Native +PostgreSQL cluster. + +The following manifest called `cert-test.yaml` creates a demo Pod with a test application +in the same namespace where your database cluster is running: + +```yaml +apiVersion: apps/v1 +kind: Deployment +metadata: + name: cert-test +spec: + replicas: 1 + selector: + matchLabels: + app: webtest + template: + metadata: + labels: + app: webtest + spec: + containers: + - image: leonardoce/webtest:1.0.0 + name: cert-test + volumeMounts: + - name: secret-volume-root-ca + mountPath: /etc/secrets/ca + - name: secret-volume-app + mountPath: /etc/secrets/app + ports: + - containerPort: 8080 + env: + - name: DATABASE_URL + value: > + sslkey=/etc/secrets/app/tls.key + sslcert=/etc/secrets/app/tls.crt + sslrootcert=/etc/secrets/ca/ca.crt + host=cluster-example-rw.default.svc + dbname=app + user=app + sslmode=verify-full + - name: SQL_QUERY + value: SELECT 1 + readinessProbe: + httpGet: + port: 8080 + path: /tx + volumes: + - name: secret-volume-root-ca + secret: + secretName: cluster-example-ca + defaultMode: 0600 + - name: secret-volume-app + secret: + secretName: cluster-app + defaultMode: 0600 +``` + +This Pod will mount secrets managed by the Cloud Native PostgreSQL operator, including: + +* TLS client certificate +* TLS client certificate private key +* TLS Certification Authority certificate + +They will be used to create the default resources that `psql` (and other libpq based applications like `pgbench`) +requires to establish a TLS encrypted connection to the Postgres database. + +By default `psql` searches for certificates inside the `~/.postgresql` directory of the current user, but we can use +the sslkey, sslcert, sslrootcert options to point libpq to the actual location of the cryptographic material. +The content of the above files is gathered from the secrets that were previously created by using the `cnp` plugin for +kubectl. + +Now deploy the application: + +```shell +kubectl create -f cert-test.yaml +``` + +Then we will use created Pod as PostgreSQL client to validate SSL connection and +authentication using TLS certificates we just created. + +A readiness probe has been configured to ensure that the application is ready when the database server can be +reached. + +You can verify that the connection works by executing an interactive `bash` inside the Pod's container to run `psql` using the necessary +options. The PostgreSQL server is exposed through the read-write Kubernetes service. We will point the `psql` +command to connect to this service: + +```shell +kubectl exec -it cert-test -- bash -c "psql +'sslkey=/etc/secrets/app/tls.key sslcert=/etc/secrets/appuser/tls.crt +sslrootcert=/etc/secrets/ca/ca.crt host=cluster-example-rw.default.svc dbname=app +user=app sslmode=verify-full' -c 'select version();'" +``` + +Output : + +```console + version +-------------------------------------------------------------------------------------- +------------------ +PostgreSQL 13.2 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.3.1 20191121 (Red Hat +8.3.1-5), 64-bit +(1 row) +``` diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/storage.mdx b/advocacy_docs/kubernetes/cloud_native_postgresql/storage.mdx new file mode 100644 index 00000000000..c3028831f95 --- /dev/null +++ b/advocacy_docs/kubernetes/cloud_native_postgresql/storage.mdx @@ -0,0 +1,184 @@ +--- +title: 'Storage' +originalFilePath: 'src/storage.md' +product: 'Cloud Native Operator' +--- + +**Storage is the most critical component in a database workload**. +Expectations are for storage to be always available, scale, perform well, +and guarantee consistency and durability. The same expectations and +requirements that apply to traditional environments, such as virtual machines +and bare metal, are also valid in container contexts managed by Kubernetes. + +!!! Important + Kubernetes has its own specificities when it comes to dynamically + provisioned storage. These include *storage classes*, *persistent + volumes*, and *persistent volume claims*. You need to own these + concepts, on top of all the valuable knowledge you have built over + the years in terms of storage for database workloads on VMs and + physical servers. + +There are two primary methods of access to storage: + +- **network**: either directly or indirectly (think of an NFS volume locally mounted on a host running Kubernetes) +- **local**: directly attached to the node where a Pod is running (this also includes directly attached disks on bare metal installations of Kubernetes) + +Network storage, which is the most common usage pattern in Kubernetes, +presents the same issues of throughput and latency that you can +experience in a traditional environment. These can be accentuated in +a shared environment, where I/O contention with several applications +increases the variability of performance results. + +Local storage enables shared-nothing architectures, which is more suitable +for high transactional and Very Large DataBase (VLDB) workloads, as it +guarantees higher and more predictable performance. + +!!! Warning + Before you deploy a PostgreSQL cluster with Cloud Native PostgreSQL, + make sure that the storage you are using is recommended for database + workloads. Our advice is to clearly set performance expectations by + first benchmarking the storage using tools such as [fio](https://fio.readthedocs.io/en/latest/fio_doc.html), + and then the database using [pgbench](https://www.postgresql.org/docs/current/pgbench.html). + +## Persistent Volume Claim + +The operator creates a persistent volume claim (PVC) for each PostgreSQL +instance, with the goal to store the `PGDATA`, and then mounts it into each Pod. + +## Configuration via a storage class + +The easier way to configure the storage for a PostgreSQL class is to just +request storage of a certain size, like in the following example: + +```yaml +apiVersion: postgresql.k8s.enterprisedb.io/v1 +kind: Cluster +metadata: + name: postgresql-storage-class +spec: + instances: 3 + storage: + size: 1Gi +``` + +Using the previous configuration, the generated PVCs will be satisfied by the default storage +class. If the target Kubernetes cluster has no default storage class, or if you need your PVCs +to satisfied by a known storage class, you can set it into the custom resource: + +```yaml +apiVersion: postgresql.k8s.enterprisedb.io/v1 +kind: Cluster +metadata: + name: postgresql-storage-class +spec: + instances: 3 + storage: + storageClass: standard + size: 1Gi +``` + +## Configuration via a PVC template + +To further customize the generated PVCs, you can provide a PVC template inside the Custom Resource, +like in the following example: + +```yaml +apiVersion: postgresql.k8s.enterprisedb.io/v1 +kind: Cluster +metadata: + name: postgresql-pvc-template +spec: + instances: 3 + + storage: + pvcTemplate: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 1Gi + storageClassName: standard + volumeMode: Filesystem +``` + +## Volume expansion + +Kubernetes exposes an API allowing [expanding PVCs](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#expanding-persistent-volumes-claims) +that is enabled by default but needs to be supported by the underlying `StorageClass`. + +To check if a certain `StorageClass` supports volume expansion, you can read the `allowVolumeExpansion` +field for your storage class: + +``` +$ kubectl get storageclass -o jsonpath='{$.allowVolumeExpansion}' premium-storage +true +``` + +### Using the volume expansion Kubernetes feature + +Given the storage class supports volume expansion, you can change the size requirement +of the `Cluster`, and the operator will apply the change to every PVC. + +If the `StorageClass` supports [online volume resizing](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#resizing-an-in-use-persistentvolumeclaim) +the change is immediately applied to the Pods. If the underlying Storage Class doesn't support +that, you will need to delete the Pod to trigger the resize. + +The best way to proceed is to delete one Pod at a time, starting from replicas and waiting +for each Pod to be back up. + +### Recreating storage + +Suppose the storage class does not support volume expansion. In that case, you can still regenerate your cluster +on different PVCs by allocating new PVCs with increased storage and then move the +database there. This operation is feasible only when the cluster contains more than one node. + +While you do that, you need to prevent the operator from changing the existing PVC +by disabling the `resizeInUseVolumes` flag, like in the following example: + +```yaml +apiVersion: postgresql.k8s.enterprisedb.io/v1 +kind: Cluster +metadata: + name: postgresql-pvc-template +spec: + instances: 3 + + storage: + storageClass: standard + size: 1Gi + resizeInUseVolumes: False +``` + +To move the entire cluster to a different storage area, you need to recreate all the PVCs and +all the Pods. Let's suppose you have a cluster with three replicas like in the following +example: + +``` +$ kubectl get pods +NAME READY STATUS RESTARTS AGE +cluster-example-1 1/1 Running 0 2m37s +cluster-example-2 1/1 Running 0 2m22s +cluster-example-3 1/1 Running 0 2m10s +``` + +To recreate the cluster using different PVCs, you can edit the cluster definition to disable +`resizeInUseVolumes`, and then recreate every instance in a different PVC. + +As an example, to recreate the storage for `cluster-example-3` you can: + +``` +$ kubectl delete pvc cluster-example-3 --wait=false +$ kubectl delete pod cluster-example-3 --wait=false +``` + +Having done that, the operator will orchestrate the creation of another replica with a +resized PVC: + +``` +$ kubectl get pods +NAME READY STATUS RESTARTS AGE +cluster-example-1 1/1 Running 0 5m58s +cluster-example-2 1/1 Running 0 5m43s +cluster-example-4-join-v2bfg 0/1 Completed 0 17s +cluster-example-4 1/1 Running 0 10s +``` diff --git a/advocacy_docs/kubernetes/cloud_native_postgresql/use_cases.mdx b/advocacy_docs/kubernetes/cloud_native_postgresql/use_cases.mdx new file mode 100644 index 00000000000..862ace48153 --- /dev/null +++ b/advocacy_docs/kubernetes/cloud_native_postgresql/use_cases.mdx @@ -0,0 +1,50 @@ +--- +title: 'Use cases' +originalFilePath: 'src/use_cases.md' +product: 'Cloud Native Operator' +--- + +Cloud Native PostgreSQL has been designed to work with applications +that reside in the same Kubernetes cluster, for a full cloud native +experience. + +However, it might happen that, while the database can be hosted +inside a Kubernetes cluster, applications cannot be containerized +at the same time and need to run in a *traditional environment* such +as a VM. + +## Case 1: Applications inside Kubernetes + +In a typical situation, the application and the database run in the same +namespace inside a Kubernetes cluster. + +![Application and Database inside Kubernetes](./images/apps-in-k8s.png) + +The application, normally stateless, is managed as a standard `Deployment`, +with multiple replicas spread over different Kubernetes node, and internally +exposed through a `ClusterIP` service. + +The service is exposed externally to the end user through an `Ingress` and the +provider's load balancer facility, via HTTPS. + +The application uses the backend PostgreSQL database to keep track of the state +in a reliable and persistent way. The application refers to the read-write +service exposed by the `Cluster` resource defined by Cloud Native PostgreSQL, +which points to the current primary instance, through a TLS connection. The +`Cluster` resource embeds the logic of single primary and multiple standby +architecture, hiding the complexity of managing a high availability cluster in +Postgres. + +![Close-up view of application and database inside Kubernetes](./images/architecture-in-k8s.png) + +## Case 2: Applications outside Kubernetes + +Another possible use case is to manage your PostgreSQL database inside +Kubernetes, while having your applications outside of it (for example in a +virtualized environment). In this case, PostgreSQL is represented by an IP +address (or host name) and a TCP port, corresponding to the defined Ingress +resource in Kubernetes. + +The application can still benefit from a TLS connection to PostgreSQL. + +![Application outside Kubernetes](./images/apps-outside-k8s.png) diff --git a/advocacy_docs/playground/1/01_examples/admonitions.mdx b/advocacy_docs/playground/1/01_examples/admonitions.mdx new file mode 100644 index 00000000000..88cd0f049cb --- /dev/null +++ b/advocacy_docs/playground/1/01_examples/admonitions.mdx @@ -0,0 +1,50 @@ +--- +title: Admonitions +--- + +!!! Note with a title + +!!! Note "with a quoted title" + +!!! Note + with a default title + +!!! Note "" + without any title + +!!!important IMPORTANT TITLE HERE + You can have [markdown](www.google.com) in here, neat + +1. A list + +2. With items + + > !!!tip TIP TITLE HERE + > You can have [markdown](www.google.com) in here, neat + > ``` + including fenced code + ``` + +3. And stuff + +!!!note NOTE TITLE HERE +You can have [markdown](www.google.com) in here, neat +!!! + +!!!warning "" + You can have [markdown](www.google.com) in here, neat + +!!! danger Indented code block in fenced admonition + + You can have [markdown](www.google.com) in here, neat + +!!! + + +!!! Note How about... Admonition within an admonition? + + Blah blah blah + + !!! Danger + Whoa! + diff --git a/advocacy_docs/playground/1/01_examples/code-blocks.mdx b/advocacy_docs/playground/1/01_examples/code-blocks.mdx new file mode 100644 index 00000000000..4ba74dcf2a0 --- /dev/null +++ b/advocacy_docs/playground/1/01_examples/code-blocks.mdx @@ -0,0 +1,35 @@ +--- +title: Code blocks +--- + +``` +test +``` + +```bash +sh bash.txt | grep blah + +__OUTPUT__ + +asadad +``` + +~~~markdown +```bash +test +``` +~~~ + +
+
+```bash
+cat /etc/lsb-release
+```
+
+
+ +
+asdasd
+asdasd
+asdasdafasfa
+
diff --git a/advocacy_docs/playground/1/01_examples/directory_defaults/index.mdx b/advocacy_docs/playground/1/01_examples/directory_defaults/index.mdx new file mode 100644 index 00000000000..cf377d277d2 --- /dev/null +++ b/advocacy_docs/playground/1/01_examples/directory_defaults/index.mdx @@ -0,0 +1,7 @@ +--- +title: Directory Defaults Test +directoryDefaults: + description: This description should be inherited by my children +--- + +Hi I'm an index file with `directoryDefaults` set in the frontmatter diff --git a/advocacy_docs/playground/1/01_examples/directory_defaults/sibling.mdx b/advocacy_docs/playground/1/01_examples/directory_defaults/sibling.mdx new file mode 100644 index 00000000000..c7b774be6cc --- /dev/null +++ b/advocacy_docs/playground/1/01_examples/directory_defaults/sibling.mdx @@ -0,0 +1,5 @@ +--- +title: Sibling File +--- + +Hi I'm a sibling file that should have the defaults set in index.mdx diff --git a/advocacy_docs/playground/1/01_examples/directory_defaults/sub_folder/index.mdx b/advocacy_docs/playground/1/01_examples/directory_defaults/sub_folder/index.mdx new file mode 100644 index 00000000000..ed521b2fd31 --- /dev/null +++ b/advocacy_docs/playground/1/01_examples/directory_defaults/sub_folder/index.mdx @@ -0,0 +1,5 @@ +--- +title: Sub Folder Index +--- + +Hi I'm an index file that should inherit the `directoryDefaults` from the index.mdx file above me diff --git a/advocacy_docs/playground/1/01_examples/directory_defaults/sub_folder/sibling.mdx b/advocacy_docs/playground/1/01_examples/directory_defaults/sub_folder/sibling.mdx new file mode 100644 index 00000000000..1d8248d4a96 --- /dev/null +++ b/advocacy_docs/playground/1/01_examples/directory_defaults/sub_folder/sibling.mdx @@ -0,0 +1,6 @@ +--- +title: Sub Folder Sibling File +--- + +Hi I'm a sibling file that should inherit the `directoryDefaults` from the index.mdx file above me + diff --git a/advocacy_docs/playground/1/01_examples/icons.mdx b/advocacy_docs/playground/1/01_examples/icons.mdx new file mode 100644 index 00000000000..fc4418a6fbe --- /dev/null +++ b/advocacy_docs/playground/1/01_examples/icons.mdx @@ -0,0 +1,8 @@ +--- +title: Icons +iconName: dottedbox +--- + +import { IconList } from '../../../../src/components/icon/iconList'; + + diff --git a/advocacy_docs/playground/1/01_examples/images/building_Razvan_Mirel.jpeg b/advocacy_docs/playground/1/01_examples/images/building_Razvan_Mirel.jpeg new file mode 100644 index 00000000000..37c450467c2 Binary files /dev/null and b/advocacy_docs/playground/1/01_examples/images/building_Razvan_Mirel.jpeg differ diff --git a/advocacy_docs/playground/1/01_examples/index.mdx b/advocacy_docs/playground/1/01_examples/index.mdx new file mode 100644 index 00000000000..9f51fae76e6 --- /dev/null +++ b/advocacy_docs/playground/1/01_examples/index.mdx @@ -0,0 +1,176 @@ +--- +title: Examples +redirects: + - /product/epas/old + - /product/epas/broken + +navigation: + - code-blocks +--- + +Here are some of the most common things you'll need to use for content. For a full list, go to this [cheatsheet](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet). Fair warning: not all of those examples will work here. + +## Text styling + +``` +Emphasis, aka italics, with *asterisks* or _underscores_. + +Strong emphasis, aka bold, with **asterisks** or __underscores__. + +Combined emphasis with **asterisks and _underscores_**. +``` + +becomes + +Emphasis, aka italics, with _asterisks_ or _underscores_. + +Strong emphasis, aka bold, with **asterisks** or **underscores**. + +Combined emphasis with **asterisks and _underscores_**. + +## Headers + +Headers are what create the bigger, bolder text right above this sentence. These break out sections and get used on the right side as part of the page's Table of Contents. + +Here's the format: +`## Header name` + +That is for an h2 `html` element. For different headers, use more `#` signs. + +`### h3 header name` + +which makes + +### h3 header name + +The `h3` is slightly smaller and still creates an anchor tag, but it does not get used in the page's Table of Contents. + +## Lists + +(In this example, leading and trailing spaces are shown with with dots: ⋅) + +``` +1. First ordered list item +2. Another item +⋅⋅* Unordered sub-list. +1. Actual numbers don't matter, just that it's a number +⋅⋅1. Ordered sub-list +4. And another item. + +⋅⋅⋅You can have properly indented paragraphs within list items. Notice the blank line + above, and the leading spaces (at least one, but we'll use three here to also align + the raw Markdown). + +⋅⋅⋅To have a line break without a paragraph, you will need to use two trailing spaces.⋅⋅ +⋅⋅⋅Note that this line is separate, but within the same paragraph.⋅⋅ +⋅⋅⋅(This is contrary to the typical GFM line break behaviour, where trailing spaces + are not required.) + +* Unordered list can use asterisks +- Or minuses ++ Or pluses +``` + +1. First ordered list item +2. Another item +3. Actual numbers don't matter, just that it's a number +4. And another item. + + You can have properly indented paragraphs within list items. Notice the blank line above, and the leading spaces (at least one, but we'll use three here to also align the raw Markdown). + + To have a line break without a paragraph, you will need to use two trailing spaces. + Note that this line is separate, but within the same paragraph. + (This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.) + +- Unordered list can use asterisks + +* Or minuses + +- Or pluses + +## Code and Styntax Highlighting + +``` +Inline `code` has `back-ticks around` it. +``` + +Inline `code` has `back-ticks around` it. + +Blocks of code are fenced by lines with three back-ticks ``` + +```` +``` +Here we can use html tags like this bold or emthat won't do anything. +``` +```` + +``` +Here we can use html tags like this bold or emthat won't do anything. +``` + +## Links + +``` +[I'm an inline-style link](https://www.google.com) + +[I'm an inline-style link with title](https://www.google.com "Google's Homepage") + +[I'm a reference-style link][arbitrary case-insensitive reference text] + +[I'm an inline link to an anchor in the same document](#headers) + +[I'm an inline link to another page in the same site](link) + +[You can use numbers for reference-style link definitions][1] + +[I'm a link to a sibling directory ../name](../new_guide) + +Or leave it empty and use the [link text itself]. + +URLs and URLs in angle brackets will automatically get turned into links. +http://www.example.com or and sometimes +example.com (but not on Github, for example). + +Some text to show that the reference links can follow later. + +[arbitrary case-insensitive reference text]: https://www.mozilla.org +[1]: http://slashdot.org +[link text itself]: http://www.reddit.com +``` + +[I'm an inline-style link](https://www.google.com) + +[I'm an inline-style link with title](https://www.google.com "Google's Homepage") + +[I'm a reference-style link][arbitrary case-insensitive reference text] + +[I'm an inline link to an anchor in the same document](#headers) + +[I'm an inline link to another page in the same site](link) + +[You can use numbers for reference-style link definitions][1] + +[I'm a link to a sibling directory ../name](../new_guide) + +Or leave it empty and use the [link text itself]. + +URLs and URLs in angle brackets will automatically get turned into links. +http://www.example.com or , for example. + +Some text to show that the reference links can follow later. + +[arbitrary case-insensitive reference text]: https://www.mozilla.org +[1]: http://slashdot.org +[link text itself]: http://www.reddit.com + +## Images + +![building](images/building_Razvan_Mirel.jpeg) + +Add image to `images` folder and use it like this: + +`![{alt text}]({image location})` + +here that's + +`![building](images/building_Razvan_Mirel.jpeg)` diff --git a/advocacy_docs/playground/1/01_examples/link-test.mdx b/advocacy_docs/playground/1/01_examples/link-test.mdx new file mode 100644 index 00000000000..5815e78e1ff --- /dev/null +++ b/advocacy_docs/playground/1/01_examples/link-test.mdx @@ -0,0 +1,157 @@ +--- +title: Link Test +--- + +## Expected behavior base paths correspond to named file & end without slash + +**Base path:** /playground/1/01_examples/link-test + +*this is the **desired** behavior for our link rewriters - it matches what one would +expect if there were no alterations to the original filesystem (i.e., path ended with filename not slash)* + +| Relative path | Result | +| ------------------------------ | ----------------------------------------- | +| [icons](icons) | /playground/1/01_examples/icons | +| [./icons](./icons) | /playground/1/01_examples/icons | +| [../icons](../icons) | /playground/1/icons | +| [#links](#links) | /playground/1/01_examples/link-test#links | +| [.#links](.#links) | /playground/1/01_examples/#links | +| [./#links](./#links) | /playground/1/01_examples/#links | +| [..#links](..#links) | /playground/1/#links | +| [../#links](../#links) | /playground/1/#links | +| [link-tests](link-tests) | /playground/1/01_examples/link-tests | +| [./link-tests](./link-tests) | /playground/1/01_examples/link-tests | +| [../link-tests](../link-tests) | /playground/1/link-tests | + +## Expected behavior base paths correspond to named file & end with slash + +**Base path:** /playground/1/01_examples/link-test/ + +| Relative path | Result | +| ------------------------------ | ---------------------------------------------- | +| [icons](icons) | /playground/1/01_examples/link-test/icons | +| [./icons](./icons) | /playground/1/01_examples/link-test/icons | +| [../icons](../icons) | /playground/1/01_examples/icons | +| [#links](#links) | /playground/1/01_examples/link-test/#links | +| [.#links](.#links) | /playground/1/01_examples/link-test/#links | +| [./#links](./#links) | /playground/1/01_examples/link-test/#links | +| [..#links](..#links) | /playground/1/01_examples/#links | +| [../#links](../#links) | /playground/1/01_examples/#links | +| [link-tests](link-tests) | /playground/1/01_examples/link-test/link-tests | +| [./link-tests](./link-tests) | /playground/1/01_examples/link-test/link-tests | +| [../link-tests](../link-tests) | /playground/1/01_examples/link-tests | + +(see (link-tests)[/playground/1/01_examples/link-tests/] for how these work with default (index) files) + +## Other tests + +[evan@rocketinsights.com](mailto:evan@rocketinsights.com) + +[http://www.google.com](http://www.google.com) + +[//www.google.com](//www.google.com) + +[ftp://user:password@host:port/path](ftp://user:password@host:port/path) + +## Rationale for our weird-ass URL rewriting + +Ok, so here's the deal: links are written in these files while looking at a filesystem heirarchy. Then, that heirarchy is transformed into a *similar* but *different* heirarchy. And those links, even with relative paths in them, still gotta work. + +To put it another way: people (and scripts) have to be able to write links while looking at one heirarchy without making assumptions that won't hold in a different heirarchy. + +## The gritty details + +[RFC 3986](https://tools.ietf.org/html/rfc3986) tells us how relative paths work in URLs. Of particular interest is [section 5.2.3](https://tools.ietf.org/html/rfc3986#section-5.2.3) as well as section 5.2.4 that follows it, which together detail the particular steps that must be followed when merging a relative path with a base path. + +There's a wrinkle though: the filesystem that Gatsby generates from our nested directories and MDX files, and how browsers merge relative and base paths. + +To examine this, let's examine how they might work for a relative URL, `../link.mdx`, contained within the source file for this very page, `playground/1/01_examples/link-test.mdx`. First... + +### Browsers and path merging + +RFC 3986 describes path merging in [section 5.2.3](https://tools.ietf.org/html/rfc3986#section-5.2.3): + +> The pseudocode above refers to a "merge" routine for merging a +> relative-path reference with the path of the base URI. This is +> accomplished as follows: +> +> - If the base URI has a defined authority component and an empty +> path, then return a string consisting of "/" concatenated with the +> reference's path; otherwise, +> +> - return a string consisting of the reference's path component +> appended to all but the last segment of the base URI's path (i.e., +> **excluding any characters after the right-most "/" in the base URI +> path,** or excluding the entire base URI path if it does not contain +> any "/" characters). + +The emphasis there is mine: it means that the merged path for our example becomes, `playground/1/01_examples/../link-test.mdx` - resolving the dots (described in [section 5.2.4](https://tools.ietf.org/html/rfc3986#section-5.2.4)) then leaves us with `playground/1/link` when what we intended was `playground/1/01_examples/link.mdx`. + +That's fine though; everyone is pretty used to it, because if you think of the path as a filesystem path (which it may or may not be), then you just ignore the file and treat the rest as if you were walking the filesystem. So the ACTUAL relative path we'd use would be one of, + +- `../01_examples/link.mdx` -> `playground/1/01_examples/../01_examples/link-test.mdx` -> `playground/1/01_examples/link.mdx` +- `./link.mdx` -> `playground/1/01_examples/./link.mdx` -> `playground/1/01_examples/link.mdx` +- `link.mdx` -> `playground/1/01_examples/link.mdx` + +### Gatsby's build output + +Things get weird when Gatsby builds HTML from the MDX files though. + +See, Gatsby wants a filesystem where the only HTML files are named `index.html`, and live in directories named after the files they were generated from. So `playground/1/01_examples/link-test.mdx` (this file) becomes `playground/1/01_examples/link-test/index.html` and `playground/1/01_examples/link.mdx` becomes `playground/1/01_examples/link/index.html`. The `index.html` files are considered "defaults" - the web server provides them for a directory when no actual file is specified in the matching path. The practical effect of this is that you can have URLs with less extranious information in them: instead of every path ending with `.html`, the last word is whatever meaningful name you gave the file. + +There's a problem though: paths now end with a slash, which means a relative URL here to `link` is now appended to `playground/1/01_examples/link-test/` to give us `playground/1/01_examples/link-test/link` - an invalid path. The alternative `../01_examples/link` is also a problem, resulting in the equally-invalid `playground/1/01_examples/01_examples/link`. Our original attempt works though: `../link` results in `playground/1/01_examples/link`... + +...but note the slight of hand: the files we're authoring are, uh, files - they end with `.mdx`. The behavior of the browser assumes that we naturally calculate relative paths based on the directory the file lives in, which means we have to assume that folks will write `link` or `./link` NOT `../link`. And in fact, they do and have been. + +Gatsby tried to get around this by dropping the slash at the end of the directory name, leading the browsers to interpret it as a filename and drop it from the base path during merging. Unfortunately, getting web servers to do the same thing ends up being... Difficult. + +So we need another way of making relative URLs written based on the authoring filesystem work reliably in the browser... + +## Solution: build-time link-rewriting + +Turns out, we can just rewrite relative URLs at the same time Gatsby is restructuring the filesystem. The *web server* and *browser* may not know that the last segment of the path is logically a filename, but *we* do - so, we can just as easily implement the behavior described in RFC3986 Section 5.2.3 with that in mind. In effect, we would rewrite the last requirement as follows: + +> - return a string consisting of the reference's path component +> appended to all but the last segment of the base URI's path (i.e., +> excluding any characters after the right-most "/" in the base URI +> path **after stripping the right-most slash on the base path** or +> excluding the entire base URI > path if it does not contain any "/" +> characters left of the right-most position). + +That should do it! Except... For `index.mdx` files. These also get turned into `index.html`, but they *don't* get their own subdirectory - because logically they're *already* the index for a subdirectory! And now that subdirectory *should* be the base path for any relative links... **Which the rewritten spec above would ruin!** + +Now we need information beyond what's contained in the URLs being merged: we need the path of the file that *generated* the base URL. With this information, we can determine if the base path corresponds to an `index.mdx` file (logically, a complete path) or from a different `.mdx` file (logically, the last segment of the path is a filename). And our 3rd revision of the spec might become: + +> - return a string consisting of the reference's path component +> appended to the base URI's path, OR all but the last segment of the +> base URI's path if that path corresponds to a non-index file (i.e., +> for source files other than index.mdx, excluding any characters after +> the right-most "/" in the base URI path **after stripping the right- +> most slash on the base path** or excluding the entire base URI path +> if it does not contain any "/" characters left of the right-most position). + +Or, in pseudo-JavaScript: + +```javascript +let basePath = `playground/1/01_examples/link-test/`; +let baseOriginalFilepath = `playground/1/01_examples/link-test.mdx`; +const relativePath = `link`; + +// normalize base path +if (basePath.endsWith('/')) basePath = basePath.slice(0,-1); +if (basePath.startsWith('/')) basePath = basePath.slice(1); + +// relative path normalization omitted for brevity + +// remove right-most segment, if it exists, unless source is index.mdx +if (!baseOriginalFilepath.endsWith('index.mdx')) +{ + const segments = basePath.split('/'); + if (segments.length > 0) segments.pop(); + basePath = segments.join('/'); +} + +const mergedPath = basePath + '/' + relativePath; +``` + +An actual implementation of this should also resolve dot segments as per RFC 3986 Section 3.2.4 here, and probably also ensure that the path *does* end with a slash in order to avoid unnecessary redirects. diff --git a/advocacy_docs/playground/1/01_examples/link-tests/index.mdx b/advocacy_docs/playground/1/01_examples/link-tests/index.mdx new file mode 100644 index 00000000000..ec88f362b31 --- /dev/null +++ b/advocacy_docs/playground/1/01_examples/link-tests/index.mdx @@ -0,0 +1,53 @@ +--- +title: Link tests in a default (index) file +navTitle: Link tests +--- + +## Expected behavior base paths correspond to default file & end without slash + +**Base path:** /playground/1/01_examples/link-tests + +| Relative path | Result | +| ---------------------------------- | ----------------------------------- | +| [link](link) | /playground/1/01_examples/link | +| [./link](./link) | /playground/1/01_examples/link | +| [../link](../link) | /playground/1/link | +| [.#links](.#links) | /playground/1/01_examples/#links | +| [./#links](./#links) | /playground/1/01_examples/#links | +| [../#links](../#links) | /playground/1/#links | +| [./..#links](./..#links) | /playground/1/#links | +| [./../#links](./../#links) | /playground/1/#links | +| [../..#links](../..#links) | /playground/#links | +| [../../#links](../../#links) | /playground/#links | +| [link-test](link-test) | /playground/1/01_examples/link-test | +| [./link-test](./link-test) | /playground/1/01_examples/link-test | +| [../link-test](../link-test) | /playground/1/link-test | +| [./../link-test](./../link-test) | /playground/1/link-test | +| [../../link-test](../../link-test) | /playground/link-test | + +## Expected behavior base paths correspond to default file & end with slash + +*this is the **desired** behavior for our link rewriters - it matches what one would +expect if there were no alterations to the original filesystem (i.e., path ended in index.mdx)* + +**Base path:** /playground/1/01_examples/link-tests/ + +| Relative path | Result | +| ---------------------------------- | ---------------------------------------------- | +| [link](link) | /playground/1/01_examples/link-tests/link | +| [./link](./link) | /playground/1/01_examples/link-tests/link | +| [../link](../link) | /playground/1/01_examples/link | +| [.#links](.#links) | /playground/1/01_examples/link-tests/#links | +| [./#links](./#links) | /playground/1/01_examples/link-tests/#links | +| [../#links](../#links) | /playground/1/01_examples/#links | +| [./..#links](./..#links) | /playground/1/01_examples/#links | +| [./../#links](./../#links) | /playground/1/01_examples/#links | +| [../..#links](../..#links) | /playground/1/#links | +| [../../#links](../../#links) | /playground/1/#links | +| [link-test](link-test) | /playground/1/01_examples/link-tests/link-test | +| [./link-test](./link-test) | /playground/1/01_examples/link-tests/link-test | +| [../link-test](../link-test) | /playground/1/01_examples/link-test | +| [./../link-test](./../link-test) | /playground/1/01_examples/link-test | +| [../../link-test](../../link-test) | /playground/1/link-test | + +(see (link-tests)[/playground/1/01_examples/link-test/] for how these work with named (non-index) files) diff --git a/advocacy_docs/playground/1/01_examples/link-tests/link.mdx b/advocacy_docs/playground/1/01_examples/link-tests/link.mdx new file mode 100644 index 00000000000..b5bbe3fb2f8 --- /dev/null +++ b/advocacy_docs/playground/1/01_examples/link-tests/link.mdx @@ -0,0 +1,6 @@ +--- +title: Link destination +navTitle: Link +--- + +You made it here! diff --git a/advocacy_docs/playground/1/01_examples/link.mdx b/advocacy_docs/playground/1/01_examples/link.mdx new file mode 100644 index 00000000000..0c796fc73df --- /dev/null +++ b/advocacy_docs/playground/1/01_examples/link.mdx @@ -0,0 +1,5 @@ +--- +title: Link +--- + +Hi, you got here from a link. You lucky devil. diff --git a/advocacy_docs/playground/1/01_examples/navigation/a.mdx b/advocacy_docs/playground/1/01_examples/navigation/a.mdx new file mode 100644 index 00000000000..6b9b6d627e5 --- /dev/null +++ b/advocacy_docs/playground/1/01_examples/navigation/a.mdx @@ -0,0 +1,5 @@ +--- +title: A +--- + +A diff --git a/advocacy_docs/playground/1/01_examples/navigation/b.mdx b/advocacy_docs/playground/1/01_examples/navigation/b.mdx new file mode 100644 index 00000000000..e003e21378f --- /dev/null +++ b/advocacy_docs/playground/1/01_examples/navigation/b.mdx @@ -0,0 +1,5 @@ +--- +title: B +--- + +B diff --git a/advocacy_docs/playground/1/01_examples/navigation/c.mdx b/advocacy_docs/playground/1/01_examples/navigation/c.mdx new file mode 100644 index 00000000000..6d119cc3dd8 --- /dev/null +++ b/advocacy_docs/playground/1/01_examples/navigation/c.mdx @@ -0,0 +1,5 @@ +--- +title: C +--- + +C diff --git a/advocacy_docs/playground/1/01_examples/navigation/directory/index.mdx b/advocacy_docs/playground/1/01_examples/navigation/directory/index.mdx new file mode 100644 index 00000000000..f553a8a5d54 --- /dev/null +++ b/advocacy_docs/playground/1/01_examples/navigation/directory/index.mdx @@ -0,0 +1,6 @@ +--- +title: Directory Index +navTitle: Directory Nav Title +--- + +Directory Index diff --git a/advocacy_docs/playground/1/01_examples/navigation/index.mdx b/advocacy_docs/playground/1/01_examples/navigation/index.mdx new file mode 100644 index 00000000000..73a34e8e692 --- /dev/null +++ b/advocacy_docs/playground/1/01_examples/navigation/index.mdx @@ -0,0 +1,9 @@ +--- +title: Navigation +navigation: + - b + - directory + - a +--- + +Root diff --git a/advocacy_docs/playground/1/01_examples/no-title.mdx b/advocacy_docs/playground/1/01_examples/no-title.mdx new file mode 100644 index 00000000000..27217978249 --- /dev/null +++ b/advocacy_docs/playground/1/01_examples/no-title.mdx @@ -0,0 +1,5 @@ +--- +description: this has no title +--- + +There is no title for this page diff --git a/advocacy_docs/playground/1/01_examples/redirects.mdx b/advocacy_docs/playground/1/01_examples/redirects.mdx new file mode 100644 index 00000000000..14a524cc764 --- /dev/null +++ b/advocacy_docs/playground/1/01_examples/redirects.mdx @@ -0,0 +1,8 @@ +--- +title: 'Redirects' +redirects: + - '/redirect-demo' + +legacyRedirects: + - '/edb-docs/redirect-demo' +--- diff --git a/advocacy_docs/playground/1/index.mdx b/advocacy_docs/playground/1/index.mdx new file mode 100644 index 00000000000..8a49f35b1d9 --- /dev/null +++ b/advocacy_docs/playground/1/index.mdx @@ -0,0 +1,5 @@ +--- +title: Docs Site Playground +navigation: + - new_guide +--- diff --git a/advocacy_docs/playground/1/new_guide/index.mdx b/advocacy_docs/playground/1/new_guide/index.mdx new file mode 100644 index 00000000000..3fc863fd274 --- /dev/null +++ b/advocacy_docs/playground/1/new_guide/index.mdx @@ -0,0 +1,5 @@ +--- +title: New Guide +--- + +this is a new guide diff --git a/advocacy_docs/playground/community-archive/contributing.mdx b/advocacy_docs/playground/community-archive/contributing.mdx new file mode 100644 index 00000000000..7473048d237 --- /dev/null +++ b/advocacy_docs/playground/community-archive/contributing.mdx @@ -0,0 +1,68 @@ +--- +title: Contribute +description: Guidelines for contributing to EDB Docs. +iconName: developer +--- + +*Note: per [Github convention](https://help.github.com/en/github/building-a-strong-community/setting-guidelines-for-repository-contributors), this content may move this project to a CONTRIBUTING.md file in this project's root directory.* + +Got information that'd useful as a part of these docs? A link that's relevant to a topic here? An idea for a demo? Spot something that could be improved? We welcome all contributors! + +## Thanks for contributing! + +It's folks like you, working together, that make PostgreSQL such a great community to be a part of. We appreciate everyone's effort and time to help us make this documentation project the best that it can be, for people new to PostgreSQL, EDB customers, the good people who support those customers, and anyone else who uses PostgreSQL in anger and with love. + +## How can I contribute? + +There are lots of ways to contribute, and all of them involve Github. We love Github. For detailed instructions on pulling and building this repository locally, see [Authoring](/community/authoring) + +### Fixing problems + +Spot a typo? A bug in a code sample? Awkward or misleading phrasing? Submit a correction! + +1. Click the "Edit this page" link at the top-right of the page where you spotted the problem. This will take you to GitHub (you may need to log in first). +2. Click the "Fork this project" button to create your own working copy of the docs. GitHub will open the relevant [MDX file](https://www.gatsbyjs.org/docs/mdx/writing-pages/) for editing. +3. Make whatever corrections you see fit, then describe the reason for the changes in the text fields at the bottom of the page. +4. Click "Propose changes" - GitHub create a branch containing your change and show you a diff. At this point you can make further changes in your patch branch, or - if the changes are sufficient - submit a pull request for us to review. +5. Click "Create pull request" - GitHub will give you another chance to describe the reason for your changes; once you're satisfied, click "Create pull request" again. +6. We'll be notified of the pull request - if we have any questions or concerns, we'll comment on it, when it looks good we'll merge it in and build out the changes! + +### Report bugs + +See a problem, but not sure how it should be fixed? [Create an Issue on GitHub!](/community/feedback) + +### Share ideas + +The best way to share ideas for how we can improve EDB Docs is to use [Github Issues](/community/feedback). Please be open to discussion - the best ideas come from collaboration! + +### Share knowledge + +Have ideas for improving an existing topic? Maybe some examples to add, a better demonstration of a concept or technique, or corrections & clarifications? You can make a pull request (as described above) using the "Edit this page" link - we'll review your changes & merge them into the live site! + +Have ideas for a *new* topic? Awesome! You can use a pull request for that too, but first let's talk about writing... + +## Writing topics + +You've got the knowledge and expertise to help - let's work together to share that with folks learning PostgreSQL! + +An effective topic reflects the needs of a specific group of people, its "**audience**". As a person progresses in learning and using PostgreSQL, their needs change and so do the topics that they look to for assistance: + +- **Starting out:** topics that introduce terminology and foundational concepts + *Formats:* [Tutorials](/community/contribute/planning/tutorial), [Live Demos](/community/contribute/planning/demo) +- **Digging in:** topics that solve real problems + *Formats:* [HOWTOs](/community/contribute/planning/guide) +- **Stepping back:** topics that explain how individual tools and concepts fit into the larger system + *Formats:* [Guides](/community/contribute/planning/guide) +- **Retrieving:** Topics that allow fast retrieval of detailed information on specific syntax, settings, capabilities, workflows. + *Formats:* Reference documentation, [Guides](/community/contribute/planning/guide) + +This is a simplification of course: one might be comfortably familiar with the practical tasks involved in configuring a system while still digging in when it comes to tasks such as querying or scaling; we should never assume that a beginner in one area is a beginner in *all* areas! + +So, **start by identifying your audience**, thinking about *who* you're writing for in addition to *what* you're writing about. These together will determine *how* you write! + +Once that's done, + +1. [Plan your article](/community/contribute/planning) +2. [Write it up using Markdown / MDX](/community/contribute/style) +3. [Test it!](/community/contribute/planning/robustness) +4. [Submit a pull request](/community/authoring#how-to-make-changes-and-submit-pull-requests) diff --git a/advocacy_docs/playground/community-archive/planning/demo.mdx b/advocacy_docs/playground/community-archive/planning/demo.mdx new file mode 100644 index 00000000000..665aa2ab689 --- /dev/null +++ b/advocacy_docs/playground/community-archive/planning/demo.mdx @@ -0,0 +1,169 @@ +--- +title: Live Demo Guidelines +navTitle: Live Demo +description: Tips and guidance for constructing live demos (Katacoda) +tags: + - documentation + - contributing +--- + + + +## Start with something you want to demonstrate + +The Katacoda format is ideal for step-by-step tutorials, but can also be used for demonstrating ad-hoc code or commands. + +Write this out in Markdown format, and spend some time testing it out; Katacoda builds can take a long time, you don't want to have to spend a lot of time waiting on them to fix problems! + +## Decide on the format + +There are two ways of embedding Katacoda: + +1. Panel embeds ([example](/getting-started/installing_postgres/docker)) pop up a console at the bottom of the page, and allow execution of commands embedded within the rest of the page. + These allow a lot of flexibility and don't tie you to a strict step-by-step format - anything you want to demo that can be executed in the console can be included anywhere on the page. +2. Multi-pane embeds ([example](/getting-started/connecting_to_postgres/java/02_JDBC)) put the entire Katacoda environment inline on the page. They can thus include the file browser, editor, etc. as-needed. + Interaction with the rest of the page is not really practical for this format. + +The crucial decision here will generally boil down to whether or not you need an editor. Sure, you can use vim in the console... But that adds a certain level of friction for many readers. **So, if you need the reader to edit files, use the multi-pane embed; otherwise, go for the panel embed.** + +## Panel embed format + +1. [Pull the repository](https://github.com/rocketinsights/edb_docs_advocacy) and create a local working branch + +2. Take your Markdown-formatted tutorial and [add the necessary Frontmatter metadata](../style) + +3. Add a `katacodaPanel` key to the Frontmatter at the top of the page. The value will be key-value pairs for the account and scenario that will be used, along with the language(s) that will be executed in the terminal: + + ```yaml + katacodaPanel: + account: enterprisedb + scenario: sandbox + codelanguages: sql + ``` + The scenario attribute defines the environment that will be used; `sandbox` is a custom PostgreSQL-on-Ubuntu image that Dave put together with the Pagila example database pre-installed, suitable for demonstrating SQL and some management. The property `codelanguages` specifies a comma-separated list of language names: code blocks highlighted in these languages will execute in the terminal when clicked. Specify the highlighting language for a code block next to the opening fence, e.g. + + ~~~ + ```sql + Select * From films; + ``` + ~~~ + + Note: in some cases, you won't need a scenario, just a base environment (for example, demonstrating installation on Ubuntu needs only an Ubuntu environment). In these cases, omit the `account` property and specify the name of the environment in the `scenario` property. If no `codelanguages` value is specified, then code blocks marked with `shell` will be executable. + + ```yaml + # panel defintion suitable for demonstrating shell commands on ubuntu + katacodaPanel: + scenario: ubuntu1804 + ``` + +4. Make sure code blocks are marked with the language represented in them (sql, shell, etc) + +5. Add a `` element - this will render a button that will allow the reader to load Katacoda in the page, based on the definition provided in the page's Frontmatter in step #3: + + ```markdown + This is an interactive tutorial - you may launch a console + in your browser to run the examples below. + + ``` + +6. Drop your file (with an mdx extension) in the relevant section of this repository + +7. Test locally - see README for local build instructions + +8. Commit, push your branch to remote, and create a PR + +9. Let the remote branch build, and test that + +10. Merge + +11. View it live! + +## Multi-pane embed format + +1. Pull [the Katacoda repository](https://github.com/EnterpriseDB/katacoda-scenarios) (for experimentation, you can create your own) + +2. Use [the katacoda-cli tool](https://www.katacoda.com/cli) to create a new scenario + + ``` + katacoda scenario:create + ``` + + Follow the prompts, and refer to the tutorial you started with for the number of steps you'll want. + +3. The tool generates a .md file for each step and an `index.json` file to tie them all together: copy each step into its respective .md file, and edit the index.json to give them descriptive names. + + *You can also create custom environments by adding build scripts under the ./environments directory. See [the Katacoda docs](https://www.katacoda.community/custom-environment.html) for details. If using a custom environment, reference it from the backend.imageid value in `index.json`. + +4. **Special markup** + + - To make code blocks clickable to execute in the terminal, add `{{execute}}` to the block's closing: + + ~~~ + ```shell + ls /etc + ```{{execute}} + ~~~ + + - To allow a code block to be copied to the clipboard, add `{{copy}}` to the blocks + + ~~~ + ```python + print('hello') + ```{{copy}} + ~~~ + + - To allow the reader to open a file in the editor, use inline code formatting and add `{{open}}` to the end: + + ~~~ + `index.json`{{open}} + ~~~ + + - To allow the reader copy an entire code block into the editor, replacing its current contents, with a single click... Wrap it in a specially-formatted `
` element:
+
+     ```
+     
+
+     Cheese.say();
+
+     
+ ``` + Note: to avoid having to escape the contents, ensure there is a blank line at the start and end. If this is unworkable, ensure the contents are HTML-safe (ampersands, less-than signs escaped). + +5. Commit changes & push to Katacoda repo + + (then wait for it to build) + +6. [Pull the repository](https://github.com/rocketinsights/edb_docs_advocacy) and create a local working branch + +7. Create article page (see [Format](../style) for details) + + Add a `kataCodaPages` key in the Frontmatter at the top of the page. The value will be a list of Katacoda scenario names with an associated Katacoda account for each. + + ```yaml + katacodaPages: + - scenario: install-ubuntu + account: enterprisedb + - scenario: java-jdbc + account: shog9 + ``` + + The scenario name will be used to refer to the scenario later in the page, *and* will be used in the path for the scenario page within the site; for this reason, avoid using the same scenario name across different accounts on the same page (this should never be necessary). + + Once you've defined the relevant scenarios, you'll link to them within the article text using the `KatacodaPageLink` element: + + ```markdown + + ``` + + Include at least a short into / explanation for the link. A good place to start is the description defined in the scenario itself. Ex: + + > This tutorial demonstrates how to connect to an existing PostgreSQL database from Java using JDBC. + + Name the article with an .mdx extension and put it in the relevant section of this repository + +8. Test locally - see README for local build instructions + +9. Commit to branch, push and create PR + +10. Live! diff --git a/advocacy_docs/playground/community-archive/planning/guide.mdx b/advocacy_docs/playground/community-archive/planning/guide.mdx new file mode 100644 index 00000000000..f8cba441408 --- /dev/null +++ b/advocacy_docs/playground/community-archive/planning/guide.mdx @@ -0,0 +1,52 @@ +--- +title: Guide Guidelines +navTitle: Guides +description: Tips and guidance for constructing Guides +tags: + - documentation + - contributing +--- + +### Preface: Usage +The distinction in these guides between Guides, [HOWTOs](howto) and [Tutorials](tutorial) is drawn for the benefit of the authors and contributors; readers by and large will not care so long as they get the help they're looking for. Use your knowledge of your target audience to choose the format for your article, and title it according to the information it provides. + +## The goal of a Guide + +Provide knowledge gained by experience to the reader, guiding them toward understanding the design and limitations of the system, tool or concept. + +A Guide should be written as instructions on how to *think* about a given system, in contrast to a HOWTO or Tutorial which aim to teach the reader how to *use* the system. + +## The nature of your target audience + +You would write a Guide when your target audience has some hands-on experience with a given tool or platform, and desires a deeper understanding. For example, someone who finds themselves working with PostgreSQL indexes on a regular basis and wishes to gain the ability to intuit their effects on performance might seek out material that explains the purpose of various index types, their design goals, limitations, and contrasting storage requirements. + +## Tips + +1. **Structure your outline** to avoid unnecessary backtracking; try to lay out each feature, problem or idea such that it builds on previously-introduced features, problems or ideas. It is easier to retain a narrative than a jumbled collection of ideas. +2. **Identify prerequisites up-front,** provide links to other guides, reference material, HOWTOs, etc. A reader who hasn't yet become proficient in the topic may wish to refer to them first, or in parallel with your article. +3. **Highlight the problem it solves** when introducing a new feature, function or idea. For example, "Range queries can be slow on b-tree indexes; BRIN indexes were created to speed up range query performance while reducing index size". This helps readers more easily recall the information when they most need it! + +## Testing + +- Build a collection of support questions concerned with the subject of the article, and compare them to the information you've presented: + 1. Is the point of confusion underlying the question addressed in the guide? + 2. Does the guide's language and terminology mirror that of the askers'? + 3. Are the general problems faced by the askers called out in the explanations included in the guide? + 4. Could the guide be cited in answers to the questions without becoming gratuitous? + Add or adjust explanations to better match what you observe. +- Discuss the guide with support people and other experts in the subject. Adjust recommendations made by the guide to reflect practical concerns. +- Compare each assertion in the guide to the canonical documentation. Correct any errors or omissions. This becomes increasingly important as the guide ages. + +## Usage + +- Reference the Guide from HOWTOs and Tutorials covering the same tools, systems or platforms. +- Include as prerequisite reading for more advanced Guides. +- Reference the Guide when answering support questions. + + + +## Further reading + +- [Planning an article](.) +- [Writing Style and Approach](../style/style) +- [Creating and Maintaining a Robust Article](robustness) diff --git a/advocacy_docs/playground/community-archive/planning/howto.mdx b/advocacy_docs/playground/community-archive/planning/howto.mdx new file mode 100644 index 00000000000..b3463e15d29 --- /dev/null +++ b/advocacy_docs/playground/community-archive/planning/howto.mdx @@ -0,0 +1,55 @@ +--- +title: HOWTO Guidelines +navTitle: HOWTOs +description: Tips and guidance for constructing HOWTO articles +tags: + - documentation + - contributing +--- + +### Preface: Usage +The distinction in these guides between [Guides](guide), HOWTOs and [Tutorials](tutorial) is drawn for the benefit of the authors and contributors; readers by and large will not care so long as they get the help they're looking for. Use your knowledge of your target audience to choose the format for your article, and title it according to the information it provides. + +There is some small value in *calling* a HOWTO a tutorial, as this is a common search term. + +## The goal of a HOWTO article + +Walk a reader through the process of accomplishing **a practical task**, the outcome of which is of immediate use to them. A reader may seek out a HOWTO to remind them of the steps needed to complete an infrequently-performed task, or to provide safety when undertaking a complex task which they've never had to take on before. + +The format of a HOWTO is similar to that of a [Tutorial](tutorial), but a tutorial need not produce any useful outcome beyond that of increasing the reader's familiarity with the subject matter. + +If you were cooking breakfast, you might refer first to a tutorial to learn how to crack eggs, and then a HOWTO to learn the steps involved in making a crepe. + +## The nature of your target audience + +You would choose to write a HOWTO when your target audience is already familiar with the platform and terminology, but not the steps involved in the specific task they wish to accomplish. + +## Tips + +1. **Perform the task yourself:** taking notes on each action you perform, how long it takes you, and the final result. If you find yourself looking up syntax for commands or other references while performing the task, make notes on these resources as well. +2. **Establish prerequisites:** Identify the desired outcome, prerequisite knowledge and estimated time to complete at the start of your article. Provide links to tutorials, guides or other resources for those who may lack the required familiarity with the target platform. +3. **Record the actions:** each discrete action should be a step in the HOWTO. Keep each step compact so that they're easy to pick out for a distracted reader. +4. **Describe the steps:** Be succinct, so as not to distract from the action itself. Link to additional reading (reference or [guide](guide)) for actions that may not be familiar to the audience. +5. **Highlight potential errors:** It won't be possible to anticipate *every* error, but when a step is known to fail in common situations, call this out and provide a work-around. +6. **Provide links to additional reading material:** Start with any references you used yourself in #1, add other material you linked from step descriptions. + +## Testing + +1. Work through the steps yourself, carefully taking no actions that aren't explicit in the article. Make corrections to address any errors or omissions you encounter. +2. Ask a friend or colleague to work through the HOWTO; observe them quietly if possible, noting any friction points, errors, or dead-ends. + +In both cases, compare the final result of the test to the result you obtained when you started writing. If there are differences, try to figure out how they arose and adjust the steps as needed. + +See also: [Creating and Maintaining a Robust Article](robustness) + +## Usage + +- Reference HOWTOs in answers to support questions +- Link to HOWTOs from articles on related topics - start with any guides or tutorials you included in your "Further reading" section. + +## Further reading + +- [Planning an article](.) +- [Writing Style and Approach](../style) +- [Creating and Maintaining a Robust Article](robustness) +- [Tutorial Guidelines](tutorial) diff --git a/advocacy_docs/playground/community-archive/planning/index.mdx b/advocacy_docs/playground/community-archive/planning/index.mdx new file mode 100644 index 00000000000..d933d6cf479 --- /dev/null +++ b/advocacy_docs/playground/community-archive/planning/index.mdx @@ -0,0 +1,62 @@ +--- +title: Planning an article +navTitle: Planning +description: Tips and guidelines for preparing to write an article +tags: + - documentation + - contributing +--- + +So, you'd like to contribute an article to this repository? That's awesome! Below are a few tips that you might find useful. These are all just guidelines - use what you can, ignore what you cannot; you're here to share your knowledge, and we're here to help you do that! + +## Core philosophy + +This repository exists to make PostgreSQL easier to learn and use for people from myriad different backgrounds, possessing different levels of knowledge and understanding. Each article assumes a prerequisite level of knowledge and sets out to assist the reader in gaining more - thus allowing them to solve new problems, perform new tasks, and understand more advanced articles. + +No one article can or should be equally useful to all people; each of us possesses unique sets of knowledge - you can be an expert in many things and still know nothing about many more. Every article should be written with the goal of [telling *someone* about *something* for the very first time](https://xkcd.com/1053/)! + +## Identifying your audience + +Every article has an intended audience, a group of 1 or more people that you, the author, wish to help. You probably don't know *everyone* in that group, but you've certainly interacted with at least a few of its members - folks you've worked with, talked with, or assisted in some way. Try to identify them, and keep them firmly in mind while writing; doing so will help you to stay focused, help you to avoid falling into the trap of writing an article that *no actual person needs to read!* + +In particular, try to identify: + +1. **What your audience needs to know, and why they need it.** What problems does this information allow them to solve? What new tasks will it allow them to perform? Which new opportunities for learning will understand the concepts you present open for them? +2. **What your audience *already* knows.** There is a limit to how much you can convey in the space of a single article. By identifying the prerequisite knowledge up-front, you can guide readers who lack it to other resources, while providing encouragement to those who already possess the necessary background information that your article will suit them. + +Your audience's needs should determine the nature of the article you write. If they're... + +- ...Just getting started? [Write a Tutorial](tutorial) or a [Live Demo](demo) +- ...Seeking to perform a specific task? [Write a HOWTO](howto) +- ...Wanting to better understand a tool, system or concept? [Write a Guide](guide) + +## Hang on to what you learned + +The topic you're presenting was new to you at one point too... You may not remember every struggle you encountered along the way, but at least you may know what you've forgotten and had to look up again while preparing to write! Hang on to that, keep notes on resources you drew on to refresh your memory, new things you learned along the way, and anything that struck you as unexpectedly delightful or interesting - chances are, your readers will appreciate them too. + +## Start with an outline + +Even if your article seems fairly linear, an outline is useful to quickly present the summary, structure, and a rough idea of length. The system used to present these articles provides an outline in the form of the table of contents, built from the headings used within the document - as illustrated on this very page! + +Starting with an outline can also help avoid mistakes, such as omitting important steps or sub-topics. And if you find your outline is growing unwieldy, you may wish to consider breaking it up into multiple articles. + +## Create a test project + +Whenever possible, the code and instructions presented in an article should be tested - both prior to publication, and regularly thereafter. Few things are more frustrating to a reader than diligently following instructions only to face an error! + +Create a project that allows you to test each action described in your article, and use it (or recreate it) regularly as you write and test. For more on testing, see: [Creating and Maintaining a Robust Article](/community/contribute/planning/robustness). + +## Keep notes on related and more advanced topics + +Your article should not be a dead-end! Keep a list of related topics that you encounter as you write; work links into the text where immediately relevant, or include them in a "Further reading" section at the end of your article. + +## Don't let the perfect become the enemy of the good + +Every article here, including this one, is a living document: mistakes can be corrected, new information added, obsolete information removed. There's an "Edit this page" button at the top here, and there will be on your article as well - so don't worry about getting it perfect the first time, as you and others will be able to return to it as need-be. What's important is that we're able to work together and help someone learn. + +## Further reading + +- [Writing Style and Approach](/community/contribute/style/style) +- [Creating and Maintaining a Robust Article](/community/contribute/planning/robustness) + + diff --git a/advocacy_docs/playground/community-archive/planning/robustness.mdx b/advocacy_docs/playground/community-archive/planning/robustness.mdx new file mode 100644 index 00000000000..a0b1f1265fe --- /dev/null +++ b/advocacy_docs/playground/community-archive/planning/robustness.mdx @@ -0,0 +1,35 @@ +--- +title: Creating and Maintaining a Robust Article +navTitle: Robustness +description: Tips for writing and modifying articles such that they can be tested and kept up-to-date +tags: + - documentation + - contributing +--- + +No matter how useful an article might be when first written, there will be mistakes... And over time, information will become obsolete, inaccurate, or misleading. This is unavoidable - but we can make identifying and fixing problems easier! + +## Test all code and commands + +All commands included in an article should be *run*; all code should be compiled and/or run. And the preceding text and code should be sufficient to allow someone else to create an environment in which to run them, successfully. If, at some later date, the code or command no longer runs successfully then it will be obvious that the article must be updated. + +## Capture expected output + +This is useful anyway: a reader who wishes to know if their command or code executed successfully can compare their results to those in the article. And it serves double-duty for maintenance: if the output changes, then the article is out of date. + +For [live demos](demo) there's a third advantage: programmatically verifying that a step has been completed successfully before moving on to the next step. + +## Include a link to a repository or project that contains the final, working code + +This is primarily relevant for tutorials and HOWTOs: when the goal of the article is to allow the reader to produce a certain result, that result can be produced ahead of time: if it no longer functions, then either the repository is out of date, the article is out of date, or both are out of date. + +Make sure to include a README file with the repository or project that links to the article's source, so that both can be updated at once when bugs are identified. + +### Verify that the repository can be created from the instructions provided in the article + +If you *started* with a test project, and then wrote a tutorial or HOWTO to document the steps required to create that, you should follow the steps in the article. Compare those results to what you started with, and ensure that what you're providing to readers matches what they can reasonably be expected to produce on their own! + +## Ask someone else to test + +It's hard to see your own blind spots - so ask someone else to test! A friend, co-worker, ideally someone in your target audience... Another set of eyes to help you see what your work looks like to others. If they can't successfully reproduce the results, then either the instructions are incorrect, or could use some clarification. + diff --git a/advocacy_docs/playground/community-archive/planning/tutorial.mdx b/advocacy_docs/playground/community-archive/planning/tutorial.mdx new file mode 100644 index 00000000000..60d6f4e237f --- /dev/null +++ b/advocacy_docs/playground/community-archive/planning/tutorial.mdx @@ -0,0 +1,58 @@ +--- +title: Tutorial Guidelines +navTitle: Tutorials +description: Tips and guidance for constructing Tutorials +tags: + - documentation + - contributing +--- + +### Preface: Usage +The distinction in these guides between [Guides](guide), [HOWTOs](howto) and Tutorials is drawn for the benefit of the authors and contributors; readers by and large will not care so long as they get the help they're looking for. Use your knowledge of your target audience to choose the format for your article, and title it according to the information it provides. + +There is some small value in *calling* a tutorial a tutorial, as this is a common search term. + +## The goal of a Tutorial + +Walk through the steps needed to accomplish some simple task in a system, introducing core concepts and terms along the way. A reader may seek out a tutorial to gain a basic understanding of a system before delving into more practical or advanced topics. They may even scan through a tutorial when evaluating a product, as a way to gauge the difficulty involved in using it. + +Unlike a [HOWTO](howto), the end result of completing a Tutorial need not be of any practical use beyond that of providing the reader familiarity with the system and its terminology. + +Both Tutorials and HOWTOs are rote learning, akin to memorizing multiplication tables, playing scales, or following a recipe in a cookbook. They are a poor way of learning, but for people who are new to a topic they allow the learner to quickly demonstrate basic competency. By providing a foundation on which to build, a good tutorial enables self-learning! + +## The nature of your target audience + +You would choose to write a Tutorial when your target audience has little or no past exposure to a given tool or platform and wishes to quickly gain enough familiarity to evaluate or research it. + +## Tips + +1. **Keep it short:** choose small tasks that can be accomplished in minutes, not hours. Err on the side of simplicity over practicality - remember, the goal is to introduce concepts not necessarily accomplish anything of practical use, though if you can do both so much the better! +2. **Perform the task yourself:** taking notes on each action you perform, how long it takes you, and the final result. If you find yourself looking up syntax for commands or other references while performing the task, make notes on these resources as well. +3. **Minimize the prerequisites** required to work through the tutorial, and note them explicitly at the top along with links to further reading. For example, a tutorial on basic SQL syntax should not require familiarity with `psql` commands or relational algebra, but may require the PostgreSQL client to be installed, a database to be configured, and a working knowledge of the bash shell. +4. **Walk through the initial setup carefully**, introducing terms and tools as they're used. Always use correct terminology for your subject matter, and link to further information on each term or tool: the reader is here to learn, not to be patronized. +5. **Record the actions:** each logically-connected group of actions should be a step in the Tutorial. For example, a many-to-many relationship might involve creating several tables - include them all in a step so that you're able to explain the concept and the reader is able to associate each action with the term and result. +6. **Describe the steps:** Detail the work to be done before presenting the action. Avoid jargon that is not essential to describing the step, and take time to define new terminology upon first use. Link to additional reading (reference or [guide](guide)) for concepts, terms and actions that may not be familiar to the audience. +7. **Keep it short, but avoid "[lies to children](https://en.wikipedia.org/wiki/Lie-to-children)"**, or otherwise-inaccurate explanations that will trip them up later; again, do not patronize the reader. In situations where you cannot fully explain a term or concept in a paragraph or two, note that your explanation is an approximation and provide the reader with a link for further study. +8. **Provide links to additional reading material:** Start with any references you used yourself in #1, add other material you linked from step descriptions. + +## Testing + +- Walk through the steps yourself, doing NOTHING that isn't spelled out as an action in the Tutorial. Make note of any errors or omissions and correct them. +- Skip steps or actions and note the resulting errors; if the cause isn't obvious, consider adding a note to the subsequent step that will allow the reader to recognize the error if they encounter it. +- Ask a friend or colleague to work through the Tutorial, ideally someone in your target audience. Observe them quietly if possible, and note all mistakes or errors encountered. Revise the steps to mitigate such errors. + +In all cases, compare the final result of the test to the result you obtained when you started writing. If there are differences, try to figure out how they arose and adjust the steps as needed. + +See also: [Creating and Maintaining a Robust Article](robustness) + +## Usage + +- Tutorials can be a good starting point: reference them on introductory pages, and ensure they can be found by search engines. +- Link to Tutorials from articles on related topics - start with any guides or tutorials you included in your "Further reading" section. + +## Further reading + +- [Planning an article](/community/contribute/planning) +- [Writing Style and Approach](../style/style) +- [Creating and Maintaining a Robust Article](robustness) +- [HOWTO Guidelines](howto) diff --git a/advocacy_docs/playground/community-archive/style/code.mdx b/advocacy_docs/playground/community-archive/style/code.mdx new file mode 100644 index 00000000000..e6909d15e03 --- /dev/null +++ b/advocacy_docs/playground/community-archive/style/code.mdx @@ -0,0 +1,26 @@ +--- +title: Use of Code in Articles +navTitle: Code +description: Tips for using code in articles +tags: + - documentation + - contributing +--- + +- Use Markdown "code fences" along with a language hint to demarcate code: + + ~~~markdown + ```python + import psycopg2 + ``` + ~~~ + + produces: + + ```python + import psycopg2 + ``` +- Avoid very long listings - if most of the code in the listing *isn't* being described in the article text, put it in a repository somewhere and provide a link to it. Then list *just* the code that you're writing about. + +- Try to keep lines short, to avoid horizontal scrolling on average-sized screens. Also, limit your indentation to between 2 and 4 characters when possible. + diff --git a/advocacy_docs/playground/community-archive/style/images.mdx b/advocacy_docs/playground/community-archive/style/images.mdx new file mode 100644 index 00000000000..0d5523cffb3 --- /dev/null +++ b/advocacy_docs/playground/community-archive/style/images.mdx @@ -0,0 +1,11 @@ +--- +title: Use of Images in Articles +navTitle: Images +description: Tips for using images in articles +tags: + - documentation + - contributing +--- + +- Prefer text when possible: it is readable on more screens, and accessible to more people. +- If an image is important to the article, include alt text which [provides equivalent information](https://writing.codidact.com/help/alt-text) diff --git a/advocacy_docs/playground/community-archive/style/index.mdx b/advocacy_docs/playground/community-archive/style/index.mdx new file mode 100644 index 00000000000..b08dab42434 --- /dev/null +++ b/advocacy_docs/playground/community-archive/style/index.mdx @@ -0,0 +1,78 @@ +--- +title: Article format and style +navTitle: Format & Style +description: Guide to the formatting and writing style used in articles +tags: + - documentation + - contributing +--- + +Every article here starts with a block of [Frontmatter](https://www.gatsbyjs.com/docs/adding-markdown-pages/#frontmatter-for-metadata-in-markdown-files) metadata (YAML format): + +```yaml +--- +title: #The full title of the article +navTitle: #(optional) 1-2 word title for the navigation sidebar +description: #(optional) summary description for links on the index page +product: #(optional) product the article is about (ex. postgres-advanced-server) +platform: #(optional) the platform which the article is about (ex. ubuntu) +tags: #list of relevant keywords (used for related articles) Ex. + - postgresql + - ubuntu + - psql + - live-demo +katacodaPages: #(optional) list of Katacoda scenarios linked in the page, Ex. + - scenario: install-ubuntu + account: enterprisedb +katacodaPanel: #(optional) definition of the Katacoda scenario to be embedded in the page, Ex. + account: enterprisedb + scenario: sandbox + codelanguages: sql +--- + +``` + +Below the Frontmatter's closing dashes is the MDX (Markdown) formatted text of the article. MDX is based on [CommonMark](https://github.com/mdx-js/specification), which minimizes distracting markup - but JSX components or raw HTML may also be mixed in where needed: + +```markdown +## Introduction + +Briefly introduce the purpose of the article. +Level 2 headings (##) will be linked in the table of contents +generated automatically for the page. + +## Step 1 + +Get into the *actual* information. + +### Subsection + +Break up long runs of text into subsections. +Level 3 headings (###) will *not* appear +in the table of contents. + +## Demo + +MDX allows including and referencing React components +as well, which is handy for things like Katacoda embeds: + + + + + +``` + +## A note on search engines + +Readers may find your article from a search engine. If your article is split into separate pages, keep in mind that readers may view the pages out of order. It might be useful to alert them to important details that previous pages cover. To do so, we recommend using notes at the top of your article where prior context would be useful: + +```markdown +!!! note + Don't forget to [install prerequisite](/link/article) before trying to connect! +``` + +## Further reading + +- [Planning an article](/community/contribute/planning) diff --git a/advocacy_docs/playground/community-archive/style/style.mdx b/advocacy_docs/playground/community-archive/style/style.mdx new file mode 100644 index 00000000000..e9b5857a36c --- /dev/null +++ b/advocacy_docs/playground/community-archive/style/style.mdx @@ -0,0 +1,34 @@ +--- +title: Writing Style and Approach +navTitle: Style +description: Tips for choosing a consistent style when writing an article +tags: + - documentation + - contributing +--- + +This is a small collection of tips aimed at helping you to write effectively; use what you find helpful, and ignore what you don't. + +## Start with your own voice + +You're drawing from your own knowledge and experience when writing, so start by writing in your own words. You've probably explained the topic you're writing about to others before, so draw on that experience: what worked, and what did not. + +You will want to go back later and revise what you've written before submitting it, but initially the only person reading it is you - so make sure that at least *you* can understand what you've written! + +## Be prescriptive instead of descriptive + +Readers have work to get done, and need information on how to do it. When there are multiple options, they must spend time and energy trying to decide which option to take - the easier we make this for them, the more useful these articles become. So whenever possible, indicate both the preferred course of action and when / why other options might be relevant. **It is ok to be opinionated!** Empower readers to make their own decisions, but don't pretend all options are equally valid; if one approach will be best in most situations, *say that!* + +### Avoid awkward passive phrasing + +Most of us have spent a great deal of time reading existing reference documentation, and too often we mirror its style - even when we're not writing reference documentation. Reference docs strive to reflect facts and avoid opinions, even when those opinions are well-supported by facts - this can lead to stilted, hard-to-understand sentences. + +When something you've written appears awkward upon review, pretend that you're writing for a colleague whose work will affect your own: you may quickly find a more direct way to communicate. + +## Prefer gender-neutral language + +Most of the subjects we're writing about here have no gender, so this is usually pretty easy. Should you find it useful to include an example involving *people*, then prefer to use "they/them/their" as pronouns unless your example includes *real* people *and* you happen to know their genders. + +## Further reading + +- [Planning an article](/community/contribute/planning) diff --git a/advocacy_docs/postgresql_journey/01_planning/index.mdx b/advocacy_docs/postgresql_journey/01_planning/index.mdx new file mode 100644 index 00000000000..dabe9ebf694 --- /dev/null +++ b/advocacy_docs/postgresql_journey/01_planning/index.mdx @@ -0,0 +1,4 @@ +--- +title: Planning a PostgreSQL system +navTitle: Planning +--- diff --git a/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/01_requirements_overview.mdx b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/01_requirements_overview.mdx new file mode 100644 index 00000000000..e9be5010999 --- /dev/null +++ b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/01_requirements_overview.mdx @@ -0,0 +1,45 @@ +--- +title: "Requirements Overview" +--- + +## Supported Platforms + +PostgreSQL 13.0 is certified on the following platforms: + +64 bit Windows: + +> Windows 2016 +> +> Windows 2019 + +MAC OS X: + +> OS X Server 10.13, 10.14, and 10.15 + +## Hardware Requirements + +The following installation requirements assume you have selected the default options during the installation process. The minimum hardware required to install and run PostgreSQL are: + +- a 1 GHz processor +- 2 GB of RAM +- 512 MB of HDD + +Additional disk space is required for data or supporting components. + +## Software Prerequisites + +**User Privileges** + +On a Mac system, you must have superuser privileges to perform a PostgreSQL installation. To perform an installation on a Windows system, you must have administrator privileges. + +If you are installing PostgreSQL into a Windows system that is configured with User Account Control (UAC) enabled, you can assume sufficient privileges to invoke the graphical installer by right clicking on the name of the installer and selecting `Run as administrator` from the context menu. If prompted, enter an administrator password to continue. + +**Windows-specific Software Requirements** + +Be sure to apply Windows operating system updates before invoking the PostgreSQL installer. If (during the installation process) the installer encounters errors, exit the installation, and ensure that your version of Windows is up-to-date before restarting the installer. + +**Mac OS X-specific Software Requirements** + +PostgreSQL installation on Mac OS X differs slightly from other platforms as the distribution is in a different format, and some additional configuration may be required. + +The Mac OS X installer is an App Bundle (a set of files and directories in a prescribed format). The installer is available as a disk image (`.dmg`) file from the website or as an archive (`.zip`) from Stack Builder. To extract the installer, simply mount the disk image and copy the installer to the desired location, or run it directly from the disk image. diff --git a/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/02_installing_postgresql_with_the_graphical_installation_wizard/01_invoking_the_graphical_installer.mdx b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/02_installing_postgresql_with_the_graphical_installation_wizard/01_invoking_the_graphical_installer.mdx new file mode 100644 index 00000000000..647d0e83b07 --- /dev/null +++ b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/02_installing_postgresql_with_the_graphical_installation_wizard/01_invoking_the_graphical_installer.mdx @@ -0,0 +1,83 @@ +--- +title: "Invoking the Graphical Installer" +--- + +To perform an installation using the graphical installation wizard, you must have superuser or administrator privileges. To start the installation wizard, assume sufficient privileges and double-click the installer icon; if prompted, provide a password. + +Note that in some versions of Windows, you can invoke the installer with `Administrator` privileges by right clicking on the installer icon and selecting `Run as Administrator` from the context menu. + +The PostgreSQL setup wizard opens: + +![The PostgreSQL setup wizard welcome dialog](../images/welcome.png) + +Click `Next` to continue. The `Installation Directory` window opens. + +![The Installation Directory dialog](../images/installation_directory.png) + +Accept the default installation directory, or specify an alternate location and click `Next` to continue. + +![Select Components](../images/select_components.png) + +Use options on the `Select Components` dialog to select which software components will be installed; select: + +- `PostgreSQL Server` to install the PostgreSQL database server. + +- `pgAdmin 4` is available for PostgreSQL version 13.0. + +- `Stack Builder` to install the Stack Builder utility; for more information about the Stack Builder utility, see [Using Stackbuilder](../03_using_stackbuilder). + +- `Command Line Tools` to install PostgreSQL tools such as: + + > `psql, pg_isready`, and `pgbench` + > + > `clusterdb, createdb`, and `dropdb` + > + > `createuser` and `dropuser` + > + > `pg_basebackup, pg_dump, pg_dumpall`, and `pg_restore` + > + > `reindexdb, vacuumdb`, and `vacuumlo` + > + > This is not a comprehensive list; the command line tools installed may vary by platform. + +Click `Next` to continue. The `Data Directory` window opens. + +![The Data Directory dialog](../images/data_directory.png) + +Accept the default location or specify the name of the alternate directory in which you wish to store the data files, and click `Next` to continue. + +The `Password` window opens. + +![The Password dialog](../images/password.png) + +PostgreSQL uses the password specified on the `Password` window for both the database superuser and the PostgreSQL service account. + +PostgreSQL runs as a service in the background; the PostgreSQL service account is named `postgres`. If you have already created a service account with the name `postgres`, you must specify same password as the existing password for the `postgres` service account. + +The specified password must conform to any security policies existing on the PostgreSQL host. After entering a password in the `Password` field, and confirming the password in the `Retype Password` field, click `Next` to continue. + +![The Port dialog](../images/the_port_dialog.png) + +Use the `Port` field to specify the port number on which the server should listen. The default listener port is `5432`. Click `Next` to continue. + +![The Advanced Options dialog](../images/advanced_options.png) + +Use the `Locale` field to specify the locale that will be used by the new database cluster. The `Default locale` is the operating system locale. Click `Next` to continue. + +![The Pre Installation Summary dialog](../images/preinstallation.png) + +The `Pre Installation Summary` dialog displays the installation preferences that you have specified with the installation wizard. Review the settings; you can use the `Back` button to return to a previous dialog to modify a setting, or click `Next` to continue. + +![The Ready to Install dialog](../images/ready_to_install.png) + +The wizard will inform you that it has the information required to install PostgreSQL; click `Next` to continue. + +![The Installing dialog](../images/installing.png) + +During the installation, the setup wizard confirms the installation progress of PostgreSQL via a series of progress bars. + +![The installation wizard offers to Launch Stack Builder at exit](../images/installation_complete.png) + +Before the setup wizard completes the PostgreSQL installation, it offers to launch Stack Builder at exit. + +The Stack Builder utility provides a graphical interface that downloads and installs applications and drivers that work with PostgreSQL. You can optionally uncheck the `Stack Builder` box and click `Finish` to complete the PostgreSQL installation or accept the default and proceed to Stack Builder. diff --git a/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/02_installing_postgresql_with_the_graphical_installation_wizard/index.mdx b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/02_installing_postgresql_with_the_graphical_installation_wizard/index.mdx new file mode 100644 index 00000000000..8a96a809aae --- /dev/null +++ b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/02_installing_postgresql_with_the_graphical_installation_wizard/index.mdx @@ -0,0 +1,23 @@ +--- +title: "Installing PostgreSQL with the Graphical Installation Wizard" +--- + +The graphical installation wizard provides a quick and easy way to install PostgreSQL on a Mac or Windows system. As the installation wizard’s easy-to-follow dialogs lead you through the installation process, specify information about your system. When the dialogs are complete, the setup wizard will perform an installation based on the selections made during the setup process. + +Note that if you are invoking the graphical installer to perform a system upgrade, the installer will preserve the configuration options specified during the previous installation. + +When the PostgreSQL installation finishes, you will be offered the option to invoke the Stack Builder package manager. Stack Builder provides an easy-to-use graphical interface that downloads and installs applications, drivers and utilities and their dependencies. See [Using Stackbuilder](../03_using_stackbuilder) for more information. + +The graphical PostgreSQL installer is available from the EnterpriseDB website at: + +> + +The PostgreSQL Beta installer is available at the following link: + +> + +
+ +invoking_the_graphical_installer + +
diff --git a/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/03_using_stackbuilder.mdx b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/03_using_stackbuilder.mdx new file mode 100644 index 00000000000..9619443e1f2 --- /dev/null +++ b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/03_using_stackbuilder.mdx @@ -0,0 +1,65 @@ +--- +title: "Using Stack Builder" +--- + + + +The Stack Builder utility provides a graphical interface that simplifies the process of downloading and installing modules that complement your PostgreSQL installation. When you install a module with Stack Builder, Stack Builder automatically resolves any software dependencies. + +Stack Builder requires Internet access; if your installation of PostgreSQL resides behind a firewall (with restricted Internet access), Stack Builder can download program installers through a proxy server. The module provider determines if the module can be accessed through an HTTP proxy or an FTP proxy; currently, all updates are transferred via an HTTP proxy and the FTP proxy information is not used. + +You can invoke Stack Builder at any time after the installation has completed by selecting the `Application Stack Builder` menu option from the `PostgreSQL 13` menu. Enter your system password (if prompted), and the Stack Builder welcome window opens. + +![The Stack Builder welcome window](images/stack_builder_welcome.png) + +Use the drop-down listbox on the welcome window to select your PostgreSQL installation. + +If the selected PostgreSQL installation has restricted Internet access, use the `Proxy Servers` button on the `Welcome` window to open the `Proxy servers` dialog. + +![The Proxy servers dialog](images/the_proxy_servers_dialog.png) + +Enter the IP address and port number of the proxy server in the `HTTP proxy` or `FTP proxy` fields on the `Proxy servers` dialog. Currently, all Stack Builder modules are distributed via HTTP proxy (FTP proxy information is ignored). Click `OK` to continue. + +![The Stack Builder module selection window](images/module_selection.png) + +The tree control on the Stack Builder module selection window contains a node for each module category; click on a category heading to expose the modules within that category. + +Each entry within the tree control is the name of a module that can be installed with Stack Builder. + +- If the module is installed, you will see the word (`installed`) to the right of the module name. +- Boxes next to the modules that are already installed, but eligible for update are automatically checked. +- To add new modules to the selected PostgreSQL installation, check the box to the left of the module name and click `Next`. + +![Check the box to add new module](images/checkbox_module.png) + +The `Selected packages` window confirms the packages selected. + +![A summary window displays a list of selected packages](images/summary_of_selected_packages.png) + +The package installers are downloaded to the directory specified in the `Download directory` field. Use the button to the right of the `Download directory` field to open a file selector, and choose an alternate location to store the downloaded installers. + +Click `Next` to connect to the server and download the required installation files. When the downloads complete, a window opens confirming that the installation files have been downloaded and are ready for installation. + +![Confirmation that the download process is complete](images/download_completes.png) + +You can check the box next to `Skip Installation` and select `Next` to exit Stack Builder without installing the downloaded files, or leave the box unchecked and click `Next` to start the installation process. + +Each downloaded installer has different requirements. As the installers execute, they may prompt you to confirm acceptance of license agreements, to enter passwords, and enter configuration information. + +During the installation process, you may be prompted by one (or more) of the installers to restart your system. Select `No` or `Restart Later` until all installations are completed. When the last installation has completed, re-boot the system to apply all of the updates. + +You may occasionally encounter packages that don’t install successfully. If a package fails to install, Stack Builder will alert you to the installation error with a popup dialog, and write a message to the log file at stored in `%TEMP%`. + +When the installation is complete, the installer will alert you to the success or failure of the installations of the requested packages. If you were prompted by an installer to restart your computer, re-boot now. + +
+ +
+ +Note + +
+ +The modules supported by Stack Builder are subject to change and vary by platform. + +
diff --git a/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/04_installation_troubleshooting.mdx b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/04_installation_troubleshooting.mdx new file mode 100644 index 00000000000..2a9d4da2c89 --- /dev/null +++ b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/04_installation_troubleshooting.mdx @@ -0,0 +1,12 @@ +--- +title: "Installation Troubleshooting" +--- + +If you encounter any problems during installation, please consult the installation logfile. The log file is created in: + +- `/tmp` on Mac OS X +- `%TEMP%` on Windows + +The installation log file is called `install-postgresql.log`. The logfile may contain the superuser password specified during the installation, which should be replaced before sharing the log with anyone. + +If you are unable to resolve the problem after reviewing the logfile, please search the [EnterpriseDB forums](http://forums.enterprisedb.com/forums/show/9.page) or your favourite search engine for a solution. If you still cannot resolve the issue, please post details of the problem, along with system details and any appropriate parts of the installation logfile to the [installer forum](http://forums.enterprisedb.com/forums/show/9.page). diff --git a/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/05_uninstalling_postgresql.mdx b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/05_uninstalling_postgresql.mdx new file mode 100644 index 00000000000..5a9474d0682 --- /dev/null +++ b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/05_uninstalling_postgresql.mdx @@ -0,0 +1,53 @@ +--- +title: "Uninstalling PostgreSQL" +--- + +The PostgreSQL installer creates an uninstaller in the PostgreSQL installation directory. + +## Uninstalling PostgreSQL on a Windows System + +You can use the graphical interface provided by Windows to uninstall PostgreSQL. Navigate through the Windows `Control Panel` to open the Windows `Uninstall or change a program` dialog. + +![The Uninstall or change a program dialog](images/change_program.png) + +Right click on `PostgreSQL 13`, and select `Uninstall/Change` from the context menu. + +![Confirm that you wish to uninstall PostgreSQL](images/uninstalling_postgreSQL_comfirmation.png) + +If you wish to remove the `Entire application`, click `Next` to continue. If you choose to remove `Individual components`, a selection screen opens, allowing you to select which components you wish to uninstall. + +![Select the components to uninstall](images/select_the_components_to_uninstall.png) + +Select the components you wish to uninstall, and click `Next` to start uninstalling components. + +![Uninstalling PostgreSQL](images/uninstallingpostgres1.png) + +A progress bar will keep you informed as PostgreSQL is removed. + +![An Info dialog confirms the uninstallation](images/uninstallationcomplete.png) + +When the uninstaller completes, an `Info` dialog opens to confirm. Click `OK` to exit. + +## Uninstalling PostgreSQL on a Mac System + +To uninstall PostgreSQL on a Mac system, assume the identity of an operating system superuser, and navigate into the folder in which the uninstaller resides: + +> `/Library/PostgreSQL/13` + +Then, invoke the uninstaller with the command: + +> `open uninstall-postgres.app` + +If prompted, provide a password that allows the uninstaller to make changes to your system. The uninstaller will open, asking you if you wish to uninstall the `Entire application` or `Individual components`. + +![Remove the entire application or components](images/remove_the_entire_application_or_components.png) + +If you wish to remove the `Entire application`, click `Next` to continue. If you choose to remove `Individual components`, a selection screen opens, allowing you to select which components you wish to uninstall. + +![Selecting the components to uninstall](images/selecting_the_components_to_uninstall.png) + +Select the components you wish to uninstall, and click `Next` to start uninstalling components. Progress bars are displayed as each component is removed; an `Info` popup informs you when the uninstallation is complete. + +![The Uninstallation is completed](images/uninstallationcomplete.png) + +Click `OK` to exit the uninstaller. diff --git a/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/advanced_options.png b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/advanced_options.png new file mode 100755 index 00000000000..2ca758a825c Binary files /dev/null and b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/advanced_options.png differ diff --git a/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/change_program.png b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/change_program.png new file mode 100755 index 00000000000..6785f6ad314 Binary files /dev/null and b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/change_program.png differ diff --git a/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/checkbox_module.png b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/checkbox_module.png new file mode 100755 index 00000000000..ddc6e458c92 Binary files /dev/null and b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/checkbox_module.png differ diff --git a/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/data_directory.png b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/data_directory.png new file mode 100755 index 00000000000..1d021b9e0f9 Binary files /dev/null and b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/data_directory.png differ diff --git a/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/download_completes.png b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/download_completes.png new file mode 100755 index 00000000000..7eef261a3ca Binary files /dev/null and b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/download_completes.png differ diff --git a/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/installation_complete.png b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/installation_complete.png new file mode 100755 index 00000000000..1f1324d2cfe Binary files /dev/null and b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/installation_complete.png differ diff --git a/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/installation_directory.png b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/installation_directory.png new file mode 100755 index 00000000000..da8a4d753b9 Binary files /dev/null and b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/installation_directory.png differ diff --git a/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/installing.png b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/installing.png new file mode 100755 index 00000000000..6cab0ac1b1c Binary files /dev/null and b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/installing.png differ diff --git a/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/module_selection.png b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/module_selection.png new file mode 100755 index 00000000000..eec567f5c6a Binary files /dev/null and b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/module_selection.png differ diff --git a/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/password.png b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/password.png new file mode 100755 index 00000000000..0de022eae4d Binary files /dev/null and b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/password.png differ diff --git a/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/preinstallation.png b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/preinstallation.png new file mode 100755 index 00000000000..ac0ac7f5c29 Binary files /dev/null and b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/preinstallation.png differ diff --git a/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/ready_to_install.png b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/ready_to_install.png new file mode 100755 index 00000000000..3a536ed2c8e Binary files /dev/null and b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/ready_to_install.png differ diff --git a/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/remove_the_entire_application_or_components.png b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/remove_the_entire_application_or_components.png new file mode 100755 index 00000000000..9aa13df20d3 Binary files /dev/null and b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/remove_the_entire_application_or_components.png differ diff --git a/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/select_components.png b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/select_components.png new file mode 100755 index 00000000000..7d926c2883c Binary files /dev/null and b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/select_components.png differ diff --git a/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/select_the_components_to_uninstall.png b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/select_the_components_to_uninstall.png new file mode 100755 index 00000000000..e3b3ce31a9f Binary files /dev/null and b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/select_the_components_to_uninstall.png differ diff --git a/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/selecting_the_components_to_uninstall.png b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/selecting_the_components_to_uninstall.png new file mode 100755 index 00000000000..54e78a418d7 Binary files /dev/null and b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/selecting_the_components_to_uninstall.png differ diff --git a/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/stack_builder_welcome.png b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/stack_builder_welcome.png new file mode 100755 index 00000000000..c8650433886 Binary files /dev/null and b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/stack_builder_welcome.png differ diff --git a/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/summary_of_selected_packages.png b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/summary_of_selected_packages.png new file mode 100755 index 00000000000..6cdca9d9ee1 Binary files /dev/null and b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/summary_of_selected_packages.png differ diff --git a/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/the_port_dialog.png b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/the_port_dialog.png new file mode 100755 index 00000000000..62c243e29ee Binary files /dev/null and b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/the_port_dialog.png differ diff --git a/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/the_proxy_servers_dialog.png b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/the_proxy_servers_dialog.png new file mode 100755 index 00000000000..0c7d751d2d4 Binary files /dev/null and b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/the_proxy_servers_dialog.png differ diff --git a/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/uninstallationcomplete.png b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/uninstallationcomplete.png new file mode 100755 index 00000000000..90a6951c505 Binary files /dev/null and b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/uninstallationcomplete.png differ diff --git a/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/uninstalling_postgreSQL_comfirmation.png b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/uninstalling_postgreSQL_comfirmation.png new file mode 100755 index 00000000000..bafe03f9d94 Binary files /dev/null and b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/uninstalling_postgreSQL_comfirmation.png differ diff --git a/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/uninstallingpostgres1.png b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/uninstallingpostgres1.png new file mode 100755 index 00000000000..badac839aab Binary files /dev/null and b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/uninstallingpostgres1.png differ diff --git a/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/welcome.png b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/welcome.png new file mode 100755 index 00000000000..96e02bd3459 Binary files /dev/null and b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/images/welcome.png differ diff --git a/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/index.mdx b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/index.mdx new file mode 100644 index 00000000000..5b0b58e91a9 --- /dev/null +++ b/advocacy_docs/postgresql_journey/02_installing/01_EDB_installer/index.mdx @@ -0,0 +1,23 @@ +--- +navTitle: EDB PostgreSQL Installers +title: "Introduction" +--- + +The PostgreSQL installers created by EnterpriseDB are designed to make it quick and simple to install PostgreSQL on your computer. The installer provides: + +- a distribution-independent PostgreSQL installation. +- the popular open-source PostgreSQL administration tool, pgAdmin. +- the StackBuilder package manager (used to download and install drivers, tools and applications to complement your PostgreSQL installation). + +The sections that follow provide information about using the PostgreSQL 13.0 installer. It also provides information about: + +- how to satisfy hardware requirements and software prerequisites before installing PostgreSQL. +- step-by-step instructions explaining the installation options available with the setup wizard. +- how to use StackBuilder to install modules that provide enhanced functionality for PostgreSQL 13.0. +- uninstalling PostgreSQL. + +
+ +requirements_overview installing_postgresql_with_the_graphical_installation_wizard using_stackbuilder installation_troubleshooting uninstalling_postgresql conclusion + +
diff --git a/advocacy_docs/postgresql_journey/02_installing/02_windows.mdx b/advocacy_docs/postgresql_journey/02_installing/02_windows.mdx new file mode 100644 index 00000000000..9a4daa1ba94 --- /dev/null +++ b/advocacy_docs/postgresql_journey/02_installing/02_windows.mdx @@ -0,0 +1,38 @@ +--- +title: Installing PostgreSQL on Windows +navTitle: Windows +description: Overview and instructions for installing PostgreSQL on Windows systems +product: postgresql +platform: windows +tags: + - postgresql + - windows +iconName: windowscolor +--- + +Windows installers for PostgreSQL are provided by EDB at , and greatly simplify the process of setting up a working server or installing client tooling, extensions, add-ons, and drivers for various development platforms. + +Detailed installation instructions for the installer can be found here: <01_EDB_installer/02_installing_postgresql_with_the_graphical_installation_wizard/01_invoking_the_graphical_installer> + +If you're installing EDB's Postgres Advanced Server, [instructions for Windows systems can be found on this site](/epas/latest/epas_inst_windows/). + +## Command line tools + +By default, the installer does not modify the system path. If you wish to use the command line tools (such as psql), you'll want to add PostgreSQL to the path after installation. + +1. Open the System Properties control panel and select the Advanced tab (or run SystemPropertiesAdvanced.exe) +2. Activate the "Environment Variables..." button to open the envornment variables editor +3. Find the `Path` variable under the "System variables" heading, and click "Edit..." +4. Add the path that you specified as the installation directory during installation, with `\bin` appended (by default: `c:\program files\postgresql\12\bin`, where 12 is the version of PostgreSQL that you installed). + +To test your installation, open a new command prompt and run, + +```shell +psql -U postgres +``` + +You'll be prompted for the password you provided during installation. [More about psql...](http://postgresguide.com/utilities/psql.html) + +## Development tools + +To develop applications which connect to a PostgreSQL server, you'll need libraries for this purpose. For details, see: [Connecting to Postgres](/postgresql_journey/04_developing/connecting_to_postgres). diff --git a/advocacy_docs/postgresql_journey/02_installing/03_linux.mdx b/advocacy_docs/postgresql_journey/02_installing/03_linux.mdx new file mode 100644 index 00000000000..b2f0b3d5702 --- /dev/null +++ b/advocacy_docs/postgresql_journey/02_installing/03_linux.mdx @@ -0,0 +1,139 @@ +--- +title: Installing PostgreSQL on Linux +navTitle: Linux +description: Overview and instructions for installing PostgreSQL on Linux-based systems +product: postgresql +platform: linux +tags: + - postgresql + - linux + - ubuntu + - live-demo +iconName: linuxcolor +katacodaPanel: + scenario: ubuntu1804 +--- + +## Basic installation + +You can quickly install PostgreSQL on most Linux systems by configuring your system's package manager to reference the postgresql.org repositories. + +Pre-built packages and instructions for most common Linux & Unix systems are available from postgresql.org: + +If you're installing EDB's Postgres Advanced Server, [instructions for Linux & Unix systems can be found on this site](/epas/latest/epas_inst_linux/), along with [a tool to generate installation scripts for each supported platform](https://repos.enterprisedb.com/). + +## Server installation details + +A Linux-based PostgreSQL server installation must accomplish the following tasks: + +1. Installing the binaries, documentation, and data directory into the filesystem +2. Creating the `postgres` superuser to own the processes and initial [cluster](https://www.postgresql.org/docs/current/creating-cluster.html) +3. Configuring paths and environmental variables +4. Initializing the default database cluster with a default database (named `postgres`) and default template (`template1`) +5. Configure and start the `postgres` service for the default database cluster + +The platform-native installation packages will accomplish all of the above, although some Linux distributions may require manual steps to intialize the default database and start the service. For additional tools, extensions and libraries (for instance, pgAdmin or PostGIS), additional packages will need to be installed - you can find many of these listed in [the PostgreSQL software catalog](https://www.postgresql.org/download/product-categories/). + +### Live tutorial + +This tutorial will walk through the steps for installing a PostgreSQL server on Ubuntu 18.04.4 LTS. + + + +First, we need to add the Postgresql.org repository as a source for Ubuntu's APT package manager: + +```shell +sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' +``` + +The command `lsb_release -cs` retrieves the name of the installed OS version, in this case "bionic" - this ensures that we're pulling from the correct repository for this release of the operating system. Supported releases can be found on [the PostgreSQL wiki](https://wiki.postgresql.org/wiki/Apt). The resulting [sources file](https://wiki.debian.org/SourcesList) looks like this: + +```output +deb http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main +``` + +APT won't trust the new source until we provide it with [a trusted key](http://manpages.ubuntu.com/manpages/xenial/man8/apt-secure.8.html) - we can pull that from postgresql.org and add it with the apt-key utility: + +```shell +wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc \ + | sudo apt-key add - +__OUTPUT__ +OK +``` + +With APT configured, we can update the list of packages and install the desired version of PostgreSQL: + +```shell +sudo apt-get update +sudo apt-get -y install postgresql +``` + +If you desired a version other than the latest, you'd specify that instead - for instance, `sudo apt-get install postgresql-12`. + +The Ubuntu installation script runs [`initdb`](https://www.postgresql.org/docs/current/app-initdb.html) to configure the default database cluster. You'll see this within the output once the cluster has been initialized: + +```output +Success. You can now start the database server using: + + pg_ctlcluster 12 main start +``` + +Don't actually run that though; the installation script also configures and starts services to automatically, as you can see from the rest of the installation output: + +```output +Ver Cluster Port Status Owner Data directory Log file +12 main 5432 down postgres /var/lib/postgresql/12/main /var/log/postgresql/postgresql-12-main.log +update-alternatives: using /usr/share/postgresql/12/man/man1/postmaster.1.gz to provide /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz) in auto mode +Setting up postgresql (12+216.pgdg18.04+1) ... +Processing triggers for man-db (2.8.3-2ubuntu0.1) ... +Processing triggers for ureadahead (0.100.0-21) ... +Processing triggers for libc-bin (2.27-3ubuntu1.2) ... +Processing triggers for systemd (237-3ubuntu10.41) ... +``` + +When the APT installation completes, you can log in as `postgres`... + +```shell +su - postgres +__OUTPUT__ +postgres@host01:~$ +``` + +...and try it out! + +```shell +psql -c "select count(*) from information_schema.tables;" +__OUTPUT__ + count +------- + 194 +(1 row) +``` + +You can also observe the directory structure created as described above: + +```shell +ls -R /etc/postgresql/ +ls -R /var/lib/postgresql +ls -R /usr/share/postgresql +ls -R /usr/lib/postgresql +ls -R /etc/postgresql-common +``` + +Aren't you glad you didn't have to worry about all that? APT is a great tool. But if you want to learn more about what's involved in a Postgres installation, peruse [Installation from Source Code](https://www.postgresql.org/docs/current/installation.html) in the PostgreSQL documentation. + +### Further reading + +- Tutorial: [How to Install Postgres on Ubuntu](https://www.enterprisedb.com/postgres-tutorials/how-install-postgres-ubuntu) +- [PostgreSQL APT documentation](https://wiki.postgresql.org/wiki/Apt) +- [PostgreSQL Ubuntu documentation](https://www.postgresql.org/download/linux/ubuntu/) + +## Client-only installation details + +A client-only installation, suitable for connecting to an existing server, need only provide client libraries and tools, e.g. psql. If you already have a database server that you intend to use, installing a client package can save a bit of time and disk space. When in doubt, install the full server package will ensure that the standard tools are available and configured. + +Additional client tools can be found in [the PostgreSQL software catalog](https://www.postgresql.org/download/products/1-administrationdevelopment-tools/). + +## Development installation details + +To develop applications which connect to a PostgreSQL server, you'll need libraries for this purpose. For details, see: [Connecting to Postgres](/getting-started/connecting_to_postgres). diff --git a/advocacy_docs/postgresql_journey/02_installing/04_macos.mdx b/advocacy_docs/postgresql_journey/02_installing/04_macos.mdx new file mode 100644 index 00000000000..ef487e6868e --- /dev/null +++ b/advocacy_docs/postgresql_journey/02_installing/04_macos.mdx @@ -0,0 +1,37 @@ +--- +title: Installing PostgreSQL on MacOS +navTitle: MacOS +description: Overview of installing PostgreSQL on MacOS systems +product: postgresql +platform: macos +tags: + - postgresql + - macos +iconName: macoscolor +--- + +MacOS installers for PostgreSQL are provided by EDB at , and greatly simplify the process of setting up a working server or installing client tooling, extensions, add-ons, and drivers for various development platforms. + +A detailed installation walkthrough can be found here: + +## Command line tools + +Once installed, you can run the command line tools by referencing them in the `bin` directory under the installation path you specified during installation. For example, to run psql from the default installation directory you would type, + +```shell +/Library/PostgreSQL/12/bin/psql -U postgres +``` + +For ease of use, you'll probably want to add this directory to your PATH, by adding a line to your `~/.bash_profile` (or `~/.zshrc` if using zsh): + +```shell +export PATH="/Library/PostgreSQL/12/bin/:$PATH" +``` + +This step is *especially* important if you plan to use scripts or other software (such as Python's psycopg2) that rely on PostgreSQL tools. You may instead [add this directory to the system path](https://apple.stackexchange.com/questions/106355/setting-the-system-wide-path-environment-variable-in-mavericks/106814#106814). + +There are several other options for installing PostgreSQL on MacOS, with varying levels of flexibility, version support, add-ons, etc. More details can be found on [the PostgreSQL website](https://www.postgresql.org/download/macosx/). + +## Development tools + +To develop applications which connect to a PostgreSQL server, you'll need libraries for this purpose. For details, see: [Connecting to Postgres](/postgresql_journey/04_developing/connecting_to_postgres). diff --git a/advocacy_docs/postgresql_journey/02_installing/05_docker.mdx b/advocacy_docs/postgresql_journey/02_installing/05_docker.mdx new file mode 100644 index 00000000000..ba740473326 --- /dev/null +++ b/advocacy_docs/postgresql_journey/02_installing/05_docker.mdx @@ -0,0 +1,226 @@ +--- +title: Using PostgreSQL in a Docker container +navTitle: Docker +description: Overview and instructions for running PostgreSQL within a container +product: postgresql +platform: docker +tags: + - postgresql + - docker + - docker-compose + - live-demo + - ubuntu +iconName: dockercolor +katacodaPanel: + scenario: ubuntu1804 +--- + +Docker containers are an environment which exist and run independently from whatever else is running on a given machine. Containers are created from "images", which define what a given environment will look like - file system layout, running processes, etc. This makes them very convenient for side-stepping the whole "installation" problem: an image in which the necessary software has already been installed and configured can be distributed and used to create containers on any machine with Docker available. + +## Creating a container from an official image + +Let's start by spinning up a local PostgreSQL server using one of the images available on the public Docker Hub repository: + +Make sure you have Docker installed. If not, install it using [the instructions on the Docker website](https://docs.docker.com/get-docker/). + +Alternately, you can follow these steps in your browser: + +1. Retrieve the PostgreSQL image from the Docker Hub repository (if not already cached) and run it: + + ```shell + docker run --name test_postgres -e POSTGRES_PASSWORD=password -e POSTGRES_DB=testdb -d postgres + __OUTPUT__ + 3cf208bf260dd3714bba84ec606b6a7bd92b34466fc159a17b5a12596d96e86c + ``` + + The output will be the container ID of the newly-running container, a [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier) that distinguishes it from other running containers. **This will be different each time the container is started,** so we also passed the `--name` option to give us something consistent to refer to in the examples that follow. + + The postgres image has PostgreSQL installed, but no database initialized. During startup, the default database cluster will be initialized, and then the database specified in the `POSTGRES_DB` environmental variable will be created. + + We can view the initialization progress by retrieving the Docker logs for the container: + + ```shell + docker logs test_postgres + __OUTPUT__ + The files belonging to this database system will be owned by user "postgres". + + ... other messages describing the initialization ... + + LOG: database system is ready to accept connections + ``` + +2. Run some commands against the database from within the container: + + ```shell + docker exec -it test_postgres psql -U postgres -d testdb -c \ + "create table Test (Id integer, Name text);" + __OUTPUT__ + CREATE TABLE + ``` + + This uses the `psql` command to run SQL as the `postgres` superuser to create a new table in our testdb database + (Note: if you see a message such as "psql: error: could not connect to server: FATAL: database "testdb" does not exist" then the database is still being initialized - check the logs as described in step #1) + + ```shell + docker exec -it test_postgres psql -U postgres -d testdb -c \ + "insert into Test values (1, 'Bob');" + __OUTPUT__ + INSERT 0 1 + ``` + + ```shell + docker exec -it test_postgres psql -U postgres -d testdb -c \ + "select * from Test;" + __OUTPUT__ + id | name + ----+------ + 1 | Bob + (1 row) + ``` + +3. Stop and then delete the container: + + ```shell + docker kill test_postgres + docker rm test_postgres + __OUTPUT__ + test_postgres + ``` + +## Using a volume to persist the database + +By default, any databases created will be stored in the container itself and will disappear when the container is deleted. This can be desirable for testing purposes! But otherwise, you'll want to make sure the databases are stored on a Docker *volume*, a storage area that exists outside of the container itself. + +Here's an example: + +1. Start the container with a named volume for the data directory: + + ```shell + docker run -v pgdata:/var/lib/postgresql/data \ + --name test_postgres \ + -e POSTGRES_PASSWORD=password \ + -e POSTGRES_DB=testdb \ + -d postgres + __OUTPUT__ + [UUID] + ``` + + The volume - named "pgdata" - will persist even after the container is removed; if a new container is created & pointed to the same volume, any data stored will be immediately available! + +2. Store some data: + + ```shell + docker exec -it test_postgres psql -U postgres -d testdb -c \ + "create table Test (Id integer, Name text); + insert into Test values (1, 'Bob');" + __OUTPUT__ + INSERT 0 1 + ``` + +3. Stop and delete the container: + + ```shell + docker kill test_postgres + docker rm test_postgres + __OUTPUT__ + test_postgres + ``` + +4. Create it again against the same volume: + + ```shell + docker run -v pgdata:/var/lib/postgresql/data \ + --name test_postgres \ + -e POSTGRES_PASSWORD=password \ + -e POSTGRES_DB=testdb \ + -d postgres + __OUTPUT__ + [UUID] + ``` + +5. Query it, observing that the data stored in step #2 is still there: + + ```shell + docker exec -it test_postgres psql -U postgres -d testdb -c \ + "select * from Test;" + __OUTPUT__ + id | name + ----+------ + 1 | Bob + (1 row) + ``` + +!!! warning + Don't try to run multiple postgres containers simultaneously sharing the same volume for data - your database will probably be corrupted! + +To remove the volume, use the command: + +```shell +docker volume rm pgdata +__OUTPUT__ +pgdata +``` + +Docker will ensure that no existing containers are referencing the volume before it'll let you remove it - you must stop and delete them first. + +## Spinning up a development or testing environment, including Postgres, using Docker Compose + +Docker Compose takes the basic options outlined above and allows you to configure, start & stop multiple containers together. This is very handy for standardizing a development environment, or even just keeping multiple projects separate on your workstation. + +For example, you might spend some time working on a Java app, backed by a PostgreSQL database. It's built against a specific version of Java, which you don't want interfering with other projects on your machine - so, you put together a configuration like this: + +```docker +version: "3.7" +services: + javadb: + image: "postgres" + environment: + POSTGRES_PASSWORD: password + POSTGRES_DB: testdb + volumes: + - pgdata:/var/lib/postgresql/data + - pgconf:/etc/postgresql + - pglog:/var/log/postgresql + + java: + image: openjdk:15 + volumes: + - .:/var/tests + environment: + DATABASE_URL: postgres://postgres:password@javadb:5432/testdb + working_dir: /var/tests + init: true + command: tail -f /dev/null + +volumes: + pgdata: + driver: local + pgconf: + driver: local + pglog: + driver: local +``` + +This configures two services - containers - along with local volumes for database storage, a test database, and the connection string configured as an environmental variable in the container where you'll be doing your OpenJDK 15 Java work. + +If you drop this (along with your application code) in a directory named javatestdev, you can launch both containers in the background with, + +```bash +docker-compose up -d +``` + +...and then get an interactive terminal on the Java image with, + +```bash +docker exec -it javatestdev_java_1 /bin/bash +``` + +(the name of the container is created based on the directory and service name) + +## Further reading + +For more on Docker, see: + +For more on Docker Compose, see: + +For more PostgreSQL Docker image configuration options, examples and Play With Docker live demos, see: diff --git a/advocacy_docs/postgresql_journey/02_installing/index.mdx b/advocacy_docs/postgresql_journey/02_installing/index.mdx new file mode 100644 index 00000000000..14d55150fca --- /dev/null +++ b/advocacy_docs/postgresql_journey/02_installing/index.mdx @@ -0,0 +1,16 @@ +--- +title: Installing PostgreSQL +navTitle: Installing +directoryDefaults: + iconName: install +--- + +A PostgreSQL installation involves one or more of: + +1. The database engine itself, one or more database clusters, one or more databases, and their configuration +2. Tools for managing the database +3. Extensions and add-on software + +Which of these are required depends on the purpose of the installation: a full production server might involve all of them, while a development environment might not need any (although it's usually wise to have *some* tools for examining the databases being built against, for example [pgAdmin](https://www.pgadmin.org/) or [psql](http://postgresguide.com/utilities/psql.html)). + +Read on for details on installing these components across various platforms. diff --git a/advocacy_docs/postgresql_journey/03_configuration/index.mdx b/advocacy_docs/postgresql_journey/03_configuration/index.mdx new file mode 100644 index 00000000000..460f76397ee --- /dev/null +++ b/advocacy_docs/postgresql_journey/03_configuration/index.mdx @@ -0,0 +1,3 @@ +--- +title: Configuration +--- diff --git a/advocacy_docs/postgresql_journey/04_developing/connecting_to_postgres/index.mdx b/advocacy_docs/postgresql_journey/04_developing/connecting_to_postgres/index.mdx new file mode 100644 index 00000000000..5a4a916c341 --- /dev/null +++ b/advocacy_docs/postgresql_journey/04_developing/connecting_to_postgres/index.mdx @@ -0,0 +1,10 @@ +--- +title: Connecting to PostgreSQL +iconName: connect +--- + +From the perspective of a PostgreSQL server, a connection is an active channel through which [messages are exchanged](https://www.postgresql.org/docs/current/protocol.html) between a server process and a client. + +...but this is rarely what you will work with directly. Most platforms offer libraries and tools to abstract away the low-level details of a connection and allow you to think about the problem you're using PostgreSQL to solve. + +This category covers the basics of setting up a connection and querying a PostgreSQL server from the perspective of various popular platforms. \ No newline at end of file diff --git a/advocacy_docs/postgresql_journey/04_developing/connecting_to_postgres/java/01_hibernate.mdx b/advocacy_docs/postgresql_journey/04_developing/connecting_to_postgres/java/01_hibernate.mdx new file mode 100644 index 00000000000..84b155c9c04 --- /dev/null +++ b/advocacy_docs/postgresql_journey/04_developing/connecting_to_postgres/java/01_hibernate.mdx @@ -0,0 +1,87 @@ +--- +title: Connecting to PostgreSQL from Java using Hibernate +navTitle: Hibernate +description: Configuration options and walk-throughs for using PostgreSQL from Hibernate +product: postgresql +platform: java +tags: + - postgresql + - java + - hibernate + - jpa +--- + +Hibernate is a widely-used ORM framework which attempts to abstract away the tasks involved when storing and retrieving Java objects. It is configured via settings, which may be specified programmatically, via a configuration file, or provided via an IOC container (see also: [Spring Data](03_springdata)). + +For more information, see [the Bootstrapping topics in the Hibernate user guide](https://docs.jboss.org/hibernate/orm/5.4/userguide/html_single/Hibernate_User_Guide.html#bootstrap). + +Configuring Hibernate programmatically: + +```java +ServiceRegistry standardRegistry = new StandardServiceRegistryBuilder() + .applySetting("hibernate.connection.url", + "jdbc:postgresql://host:5432/database?user=username&password=password") + .build(); +``` + +Configuring Hibernate via JPA's persistence.xml: + +```xml + + + + org.hibernate.jpa.HibernatePersistenceProvider + + + + + + + +``` + +In both scenarios, Hibernate is able to determine the correct driver and connection settings from a single setting containing a complete connection string. But if needed, a specific JDBC driver can be specified as well: + +```java +.applySetting("hibernate.connection.driver_class", "org.postgresql.Driver") +``` +```xml + +``` + +Internally, Hibernate connects using [JDBC](02_JDBC) and configures itself to generate queries based on information returned by the JDBC driver - but you can override this if necessary by specifying a Dialect: + +```java +.applySetting("hibernate.dialect", "org.hibernate.dialect.PostgreSQL10Dialect") +``` +```xml + +``` + +If you store credentials (username + password) separately from your database connection string, these may be provided separately to Hibernate as well: + +```java +.applySetting("hibernate.connection.username", "username") +.applySetting("hibernate.connection.password", "password") +``` +```xml + + +``` + +There are numerous other settings which control how Hibernate behaves; refer to [the Configuration section of the Hibernate user guide](https://docs.jboss.org/hibernate/orm/5.4/userguide/html_single/Hibernate_User_Guide.html#configurations). + +One setting worth calling out is `hibernate.globally_quoted_identifiers`: due to how PostgreSQL handles [character case in identifiers](https://www.postgresql.org/docs/current/sql-syntax-lexical.html), if a column is defined with a quoted name then it will need to be referenced with the same name, in the same case, also enclosed in quotes. Normally this isn't an issue - but if you're using Hibernate to work with a schema that was defined with quoted identifiers, it may be necessary to force Hibernate to also use quotes even in cases where its default behavior would be to omit them. For more fine-grained control over this behavior, see: [PhysicalNamingStrategy](https://docs.jboss.org/hibernate/orm/5.4/userguide/html_single/Hibernate_User_Guide.html#PhysicalNamingStrategy). + +## Interactive tutorial + +TODO diff --git a/advocacy_docs/postgresql_journey/04_developing/connecting_to_postgres/java/02_JDBC.mdx b/advocacy_docs/postgresql_journey/04_developing/connecting_to_postgres/java/02_JDBC.mdx new file mode 100644 index 00000000000..01c1580b3fc --- /dev/null +++ b/advocacy_docs/postgresql_journey/04_developing/connecting_to_postgres/java/02_JDBC.mdx @@ -0,0 +1,74 @@ +--- +title: Connecting to PostgreSQL from Java using JDBC +navTitle: JDBC +description: Installation and configuration for the PostgreSQL JDBC driver +product: postgresql +platform: java +tags: + - postgresql + - java + - jdbc + - live-demo +katacodaPages: + - scenario: java-jdbc + account: shog9 +--- + +JDBC is the fundamental database connector framework for Java. To use it to access Postgres, you need a driver: https://jdbc.postgresql.org/download.html - just download it and reference the .jar file in your [classpath](https://docs.oracle.com/javase/8/docs/technotes/tools/findingclasses.html) somewhere. For this example, it is convenient to just drop the driver into the directory where you save the class file, but in a more robust project you might wish to install it in a shared location where it could be used by multiple applications. + +JDBC versions 4 and newer will automatically find and load the appropriate driver for a given connection, as long as the driver can be found via classpath. + +```java +// save as Example.java +// compile: javac Example.java +// run: java -classpath ".:/path/to/postgres-jdbc-driver.jar" Example +import java.sql.*; + +public class Example +{ + public static void main(String[] args) + { + try + { + // this is only needed when running against JDBC versions < 4 + // Class.forName("org.postgresql.Driver"); + + String url = "jdbc:postgresql://javadb:5432/coffee?user=postgres&password=password"; + Connection conn = DriverManager.getConnection(url); + + Statement st = conn.createStatement(); + ResultSet rs = st.executeQuery("select table_schema, table_name from information_schema.tables"); + while (rs.next()) + { + System.out.format("%s: %s\n", rs.getString(1), rs.getString(2)); + } + rs.close(); + st.close(); + } + catch (SQLException e) + { + System.err.println(e); + } + } +} +``` + +Observe that with JDBC 4, the only Postgres-specific parts of the code are in the connection string and the query - both can (and generally should) be separated from application logic to allow easier maintenance and potentially even migration between different databases. + +If you're used to working with Oracle and wish to move to PostgreSQL while retaining your existing queries, EDB's Postgres Advanced Server offers a custom JDBC driver, with extensive Oracle compatibility options - details can be found in the [EDB Postgres Connectors JDBC Guide](/edb-docs/d/edb-postgres-connectors/user-guides/jdbc-guide/11.0.3/toc.html) + +## Interactive tutorial + +This tutorial demonstrates how to connect to an existing PostgreSQL database from Java using JDBC. It runs in your browser, and should take about 5 minutes to complete. + + + +- - - + +## Further reading + +More tutorials from around EDB. These aren't yet a part of this EDB Docs site, but we plan to bring them in. + +- [How to connect to the PostgreSQL database using Eclipse and Netbeans](https://www.enterprisedb.com/postgres-tutorials/how-connect-postgres-database-using-eclipse-and-netbeans) +- [How to query PostgreSQL data using the SELECT statement in Java](https://www.enterprisedb.com/postgres-tutorials/how-query-postgresql-data-using-select-statement-java) +- [How to use Java to create a table in PostgreSQL](https://www.enterprisedb.com/postgres-tutorials/how-use-java-create-table-postgresql) diff --git a/advocacy_docs/postgresql_journey/04_developing/connecting_to_postgres/java/03_springdata.mdx b/advocacy_docs/postgresql_journey/04_developing/connecting_to_postgres/java/03_springdata.mdx new file mode 100644 index 00000000000..21fbec8d46e --- /dev/null +++ b/advocacy_docs/postgresql_journey/04_developing/connecting_to_postgres/java/03_springdata.mdx @@ -0,0 +1,38 @@ +--- +title: Connecting to PostgreSQL from Java using Spring Data +navTitle: Spring Data +description: Configuration options and walk-throughs for using PostgreSQL with Spring Data and Spring Boot +product: postgresql +platform: java +tags: + - postgresql + - java + - spring + - spring-boot + - spring-data +--- + +The Spring Framework is a collection of libraries, tools and practices aimed at easing the amount of work that needs to be done to write and configure applications built from components. For details, see [Core Technologies](https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#beans) in the Spring documentation. + +[Spring Data](https://spring.io/projects/spring-data) is a satellite framework which allows the use of various data-access strategies to integrate smoothly into Spring applications. Like Hibernate, its fundamental goal is that of an ORM - mapping data stored in Java objects to some other data storage or transmission system. In fact, the [Spring Data JPA](https://spring.io/projects/spring-data-jdbc) library can use Hibernate as an intermediary for storage or retrieval, but there are other Spring Data libraries such as [Spring Data JDBC](https://spring.io/projects/spring-data-jdbc) which impose less overhead and may be a preferable option for applications which do not require the full functionality that Hibernate / JPA provide. + +[Spring Boot](https://spring.io/projects/spring-boot) is a set of tools and libraries which simplify the creation of standalone applications built on the Spring frameworks. Spring's core philosophies of inversion of control allow very flexible application design, but tend to impose a substantial amount of overhead in the code and configuration that must be written; when there are an infinite number of ways to accomplish a task, choosing one can be challenging... Spring Boot takes an "opinionated" approach for common application types, thus reducing the effort needed to get an application running quickly and simplifying the knowledge needed to modify existing applications. + +## Configuration + +For both Spring Data JPA and Spring Data JDBC, there is only one essential setting required to connect to Postgres: `spring.datasource.url`. This is usually specified via Spring's `application.properties` configuration file: + +``` +spring.datasource.url=jdbc:postgresql://host:5432/database?user=username&password=password +``` + +Username and password can be specified separately, if desired: + +``` +spring.datasource.username=username +spring.datasource.password=password +``` + +## Interactive tutorial + +TODO diff --git a/advocacy_docs/postgresql_journey/04_developing/connecting_to_postgres/java/index.mdx b/advocacy_docs/postgresql_journey/04_developing/connecting_to_postgres/java/index.mdx new file mode 100644 index 00000000000..89dbf0f77aa --- /dev/null +++ b/advocacy_docs/postgresql_journey/04_developing/connecting_to_postgres/java/index.mdx @@ -0,0 +1,21 @@ +--- +title: Connecting to PostgreSQL from Java +navTitle: Java +description: Guides to connecting to PostgreSQL from various Java libraries & frameworks +product: postgresql +platform: java +tags: + - postgresql + - java +iconName: javacolor +--- + +In this section, we'll cover the basics of connecting to PostgreSQL from Java. You'll find JDBC and Hibernate mentioned frequently: as these underpin most Java data access strategies, let's take a moment to talk about their history... + +In the beginning, there was JDBC, and it was good. + +Well; it was better than ODBC, slightly. Serviceable. And it still is. If you're spinning up a simple app or want to create your own data access framework, you'll be happy with JDBC. + +But... It requires you to manually adapt your software's strategies for handling data to the way in which a relational database handles data. This can be tedious; frustrating; error-prone. And so Object Relational Mapping (ORM) was created. Hibernate wasn't the first ORM, but it was the first widely-used - and arguably the first *usable* - Java ORM. And it set the benchmark for what came after: build your app, then map its data to the storage system (relational database or other). + +Today, the core core ideas of Hibernate are baked into the Java platform via the Java Persistence API. Hibernate itself has matured, and provides fast and flexible tools with which to integrate Java applications with various databases. \ No newline at end of file diff --git a/advocacy_docs/postgresql_journey/04_developing/connecting_to_postgres/python/01_psycopg2.mdx b/advocacy_docs/postgresql_journey/04_developing/connecting_to_postgres/python/01_psycopg2.mdx new file mode 100644 index 00000000000..69ef52c0905 --- /dev/null +++ b/advocacy_docs/postgresql_journey/04_developing/connecting_to_postgres/python/01_psycopg2.mdx @@ -0,0 +1,38 @@ +--- +title: Connecting to PostgreSQL from Python using Psycopg2 +navTitle: psycopg2 +description: Psycopg2 - better than 1, not as good as 3 will be +product: postgresql +platform: python +tags: + - postgresql + - python + - psycopg2 +--- + +!!! note + First, [install psycopg2](/postgresql_journey/04_developing/connecting_to_postgres/python) + +Call `psycopg2.connect()` to open a connection: + +```python +import psycopg2 + +# can also use a standard URL format for the connection string: +# psycopg2.connect('postgres://username:password@host:port/database') +with psycopg2.connect( + user='username', + password='password', + host='localhost', + port='5432', + dbname='database') as connection: + connection.autocommit = True + + with connection.cursor() as cursor: + # list all tables in this database + cursor.execute('select table_schema, table_name from information_schema.tables') + results = cursor.fetchall() + print(results) +``` + +See [the Psycopg2 documentation for details and other options](https://www.psycopg.org/docs/module.html#psycopg2.connect). diff --git a/advocacy_docs/postgresql_journey/04_developing/connecting_to_postgres/python/02_django.mdx b/advocacy_docs/postgresql_journey/04_developing/connecting_to_postgres/python/02_django.mdx new file mode 100644 index 00000000000..c49a0536f5d --- /dev/null +++ b/advocacy_docs/postgresql_journey/04_developing/connecting_to_postgres/python/02_django.mdx @@ -0,0 +1,54 @@ +--- +title: Connecting to PostgreSQL from Python using Django +navTitle: Django +description: quick info on how to connect using Django +product: postgresql +platform: python +tags: + - postgresql + - python + - django + - live-demo +katacodaPages: + - scenario: django2 + account: shog9 +--- + +!!! note + Don't forget to [install psycopg2](/postgresql_journey/04_developing/connecting_to_postgres/python) before trying to connect! + +Django allows persisting and querying data models via [a rich set of options to map classes to database tables](https://docs.djangoproject.com/en/3.0/topics/db/). The connection to PostgreSQL is configured via the "default" key in the `DATABASES` dictionary in Django settings (usually configured by editing a project's `settings.py`): + +```python +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.postgresql', + 'HOST': 'host', + 'PORT': '5432', + 'NAME': 'database', + 'USER': 'username', + 'PASSWORD': 'password' + } +} +``` + +If you prefer to use a connection URL, you may use [the dj-database-url library](https://pypi.org/project/dj-database-url/) to translate this into Django's dictionary format. Django also allows [multiple database connections](https://docs.djangoproject.com/en/3.0/topics/db/multi-db/) to be configured. + +Refer to [the Django documentation](https://docs.djangoproject.com/en/3.0/topics/db/) for more options. + +## Interactive tutorial + +This tutorial demonstrates how to use PostgreSQL together with the Python web application framework Django. It is an adaptation of Richard Yen's tutorial found at: https://www.enterprisedb.com/postgres-tutorials/how-use-postgresql-django + + + +--- + +## Further reading + +[Why Django is so impressive for developing with PostgreSQL and Python](https://www.enterprisedb.com/postgres-tutorials/why-django-so-impressive-developing-postgresql-and-python) + +And some more tutorials from around EDB. These aren't yet a part of this EDB Docs site, but we plan to bring them in. + +- [How to use PostgreSQL with Django](https://www.enterprisedb.com/postgres-tutorials/how-use-postgresql-django) +- [How to implement faceted search with Django and PostgreSQL](https://www.enterprisedb.com/postgres-tutorials/how-implement-faceted-search-django-and-postgresql) diff --git a/advocacy_docs/postgresql_journey/04_developing/connecting_to_postgres/python/03_SQLAlchemy.mdx b/advocacy_docs/postgresql_journey/04_developing/connecting_to_postgres/python/03_SQLAlchemy.mdx new file mode 100644 index 00000000000..e3ad4a7f12f --- /dev/null +++ b/advocacy_docs/postgresql_journey/04_developing/connecting_to_postgres/python/03_SQLAlchemy.mdx @@ -0,0 +1,36 @@ +--- +title: Connecting to PostgreSQL from Python using SQLAlchemy +navTitle: SQLAlchemy +description: quick info on how to connect using SQLAlchemy and psycopg2 +product: postgresql +platform: python +tags: + - postgresql + - python + - sqlalchemy +--- + +!!! note + Don't forget to [install psycopg2](/postgresql_journey/04_developing/connecting_to_postgres/python) before trying to connect! + +SQLAlchemy is a flexible data access library which builds on psycopg2 to add a Python expression language, and then builds a full ORM on that. You can use it as a thin wrapper around psycopg2, an extensive object mapper, or anything in between. + +Connect to PostgreSQL by calling `create_engine` to define the connection, then calling connect() on that: +```python +import sqlalchemy +from sqlalchemy import Table, Column, String, MetaData + +engine = sqlalchemy.create_engine('postgres://username:password@host:port/database') + +with engine.connect() as connection: + metadata = MetaData() + tables = Table('tables', metadata, + Column('table_schema', String), + Column('table_name', String), + schema='information_schema') + results = connection.execute(tables.select().where(tables.c.table_schema=='pg_catalog')) + for result in results: + print(result) +``` + +See [the SQLAlchemy documentation for more](https://docs.sqlalchemy.org/en/13/core/expression_api.html). diff --git a/advocacy_docs/postgresql_journey/04_developing/connecting_to_postgres/python/index.mdx b/advocacy_docs/postgresql_journey/04_developing/connecting_to_postgres/python/index.mdx new file mode 100644 index 00000000000..1a810a67150 --- /dev/null +++ b/advocacy_docs/postgresql_journey/04_developing/connecting_to_postgres/python/index.mdx @@ -0,0 +1,18 @@ +--- +title: Connecting to PostgreSQL from Python +navTitle: Python +description: Guides to connecting to PostgreSQL from Python using various libraries & frameworks +product: postgresql +platform: python +tags: + - postgresql + - python + - psycopg2 +iconName: pythoncolor +--- + +There are multiple ways of connecting to PostgreSQL from Python, and most of them will require installing [a PEP 249-compliant](https://www.python.org/dev/peps/pep-0249/) adapter library. There is [a list of such adapters on the PostgreSQL wiki](https://wiki.postgresql.org/wiki/Python); we strongly recommend [Psycopg2](https://wiki.postgresql.org/wiki/Psycopg2), as it is widely compatible and fast. You can install psycopg2 using pip: + + pip install psycopg2 + +If you encounter errors, it's likely that pg_config is not installed or cannot be found; fixing this will usually involve either installing the necessary PostgreSQL libraries or reconfiguring your search path; solutions for various operating systems can be found [on Stack Overflow](https://stackoverflow.com/questions/11618898/pg-config-executable-not-found). See also: [Installing Postgres](/postgresql_journey/02_installing). diff --git a/advocacy_docs/postgresql_journey/04_developing/index.mdx b/advocacy_docs/postgresql_journey/04_developing/index.mdx new file mode 100644 index 00000000000..5a257208ec6 --- /dev/null +++ b/advocacy_docs/postgresql_journey/04_developing/index.mdx @@ -0,0 +1,6 @@ +--- +title: Developing with PostgreSQL +navTitle: Developing +directoryDefaults: + iconName: 'connect' +--- diff --git a/advocacy_docs/postgresql_journey/04_developing/querying/index.mdx b/advocacy_docs/postgresql_journey/04_developing/querying/index.mdx new file mode 100644 index 00000000000..d61a22af56e --- /dev/null +++ b/advocacy_docs/postgresql_journey/04_developing/querying/index.mdx @@ -0,0 +1,5 @@ +--- +title: Storing and Querying Data Using PostgreSQL +navTitle: Querying +iconName: sql +--- diff --git a/advocacy_docs/postgresql_journey/04_developing/querying/views.mdx b/advocacy_docs/postgresql_journey/04_developing/querying/views.mdx new file mode 100644 index 00000000000..04704c7c560 --- /dev/null +++ b/advocacy_docs/postgresql_journey/04_developing/querying/views.mdx @@ -0,0 +1,261 @@ +--- +title: How to create, modify, delete, and manage views in PostgreSQL +navTitle: Views +description: "This article discusses VIEW in PostgreSQL. It describes how a VIEW functions as a shortcut if calling the same query multiple times, then defines the following commands: CREATE VIEW, ALTER VIEW, DROP VIEW" +product: postgresql +platform: ubuntu +tags: + - postgresql + - ubuntu + - psql + - live-demo +katacodaPanel: + account: enterprisedb + scenario: sandbox + codelanguages: sql +--- + +*adapted from: https://www.enterprisedb.com/postgres-tutorials/how-create-modify-delete-and-manage-views-postgresql* + +### Introduction + +PostgreSQL’s VIEW is a versatile tool for “viewing” the data in a database. A VIEW is a query that you give a name to so that you can reference it just like you would a table. There are also MATERIALIZED VIEWs, which are similar but slightly different, and we cover that here. A VIEW doesn’t replace a table—VIEWs require tables to pull information from them. However, once those tables are in place, you can use VIEWs to examine and use those tables’ data. This can be useful for a number of situations. For example, if there’s a query that you run really often, and you don’t want to keep typing it, you can use a VIEW. + +This is an interactive tutorial - you can run the examples below against a sample database right in your browser. + + + +## Creating a view + +Here, I have an example of a situation where I have two tables that I pull information from, “customer_table” and “city_table.” + +```sql +select first_name, last_name, email, city +from customer +join address on address.address_id=customer.address_id +join city on city.city_id=address.city_id +where city='London'; +__OUTPUT__ + first_name | last_name | email | city +------------+-----------+-----------------------------------+-------- + MATTIE | HOFFMAN | MATTIE.HOFFMAN@sakilacustomer.org | London + CECIL | VINES | CECIL.VINES@sakilacustomer.org | London +(2 rows) +``` + +If this is a query that is run often, or we want to run a query that involves information that this query already involves, we can create a VIEW with this query: + +```sql +create view my_view as + select first_name, last_name, email, city + from customer + join address on address.address_id=customer.address_id + join city on city.city_id=address.city_id + where city='London'; +__OUTPUT__ +CREATE VIEW +``` + +Then in the future, we can just call the VIEW itself: + +```sql +select * from my_view; +__OUTPUT__ + first_name | last_name | email | city +------------+-----------+-----------------------------------+-------- + MATTIE | HOFFMAN | MATTIE.HOFFMAN@sakilacustomer.org | London + CECIL | VINES | CECIL.VINES@sakilacustomer.org | London +(2 rows) +``` + +Once we’ve created a VIEW, we can look at the details of that view using the \d+ command: + +```sql +\d+ my_view +__OUTPUT__ + View "public.my_view" + Column | Type | Collation | Nullable | Default | Storage | Description +------------+------+-----------+----------+---------+----------+------------- + first_name | text | | | | extended | + last_name | text | | | | extended | + email | text | | | | extended | + city | text | | | | extended | +View definition: + SELECT customer.first_name, + customer.last_name, + customer.email, + city.city + FROM customer + JOIN address ON address.address_id = customer.address_id + JOIN city ON city.city_id = address.city_id + WHERE city.city = 'London'::text; +``` + +The view itself doesn't store data - every time it's used, the defining query is run. Observe that changing the tables used in the definition will cause the results to change: + +```sql +update address set city_id=312 where city_id=544; +select * from my_view; +__OUTPUT__ +UPDATE 1 + first_name | last_name | email | city +------------+-----------+-----------------------------------+-------- + MATTIE | HOFFMAN | MATTIE.HOFFMAN@sakilacustomer.org | London + CECIL | VINES | CECIL.VINES@sakilacustomer.org | London + VIRGINIA | GREEN | VIRGINIA.GREEN@sakilacustomer.org | London +(3 rows) +``` + +We can make VIEWs that pull information from other VIEWs as well, giving you even more flexibility over how you want to access your data. + +## Creating or replacing a view + +If you ever need to change an existing VIEW, the command you use depends on what you want to change. If you want to change the query that is being used, you can use a modified version of the CREATE command: + +```sql +create or replace view my_view as +select first_name, last_name, email, city, country +from customer +join address on address.address_id=customer.address_id +join city on city.city_id=address.city_id +join country on country.country_id=city.country_id +where city='London'; +__OUTPUT__ +CREATE VIEW +``` + +Examining the view shows the updated definition: + +```sql +\d+ my_view +__OUTPUT__ + View "public.my_view" + Column | Type | Collation | Nullable | Default | Storage | Description +------------+------+-----------+----------+---------+----------+------------- + first_name | text | | | | extended | + last_name | text | | | | extended | + email | text | | | | extended | + city | text | | | | extended | + country | text | | | | extended | +View definition: + SELECT customer.first_name, + customer.last_name, + customer.email, + city.city, + country.country + FROM customer + JOIN address ON address.address_id = customer.address_id + JOIN city ON city.city_id = address.city_id + JOIN country ON country.country_id = city.country_id + WHERE city.city = 'London'::text; +``` + +## Altering a view + +On the other hand, if you want to change the properties of the VIEW, such as the owner, or rename the VIEW, you can use the ALTER VIEW command. + +```sql +alter view my_view rename to customers_london; +__OUTPUT__ +ALTER VIEW +``` + +One way to manage your VIEWs is to use “pg_views.” This will allow you to see all of the VIEWs that currently exist, who created them, the name of the VIEW, the schema they are in, and the definition. + +```sql +select * from pg_views where viewname='customers_london'; +__OUTPUT__ + schemaname | viewname | viewowner | definition +------------+------------------+-----------+-------------------------------------------------------------------- + public | customers_london | postgres | SELECT customer.first_name, + + | | | customer.last_name, + + | | | customer.email, + + | | | city.city, + + | | | country.country + + | | | FROM (((customer + + | | | JOIN address ON ((address.address_id = customer.address_id)))+ + | | | JOIN city ON ((city.city_id = address.city_id))) + + | | | JOIN country ON ((country.country_id = city.country_id))) + + | | | WHERE (city.city = 'London'::text); +(1 row) +``` + +## Dropping a view + +Finally, if you decide you no longer need a VIEW, simply use the DROP VIEW command to remove it. + +```sql +drop view customers_london; +__OUTPUT__ +DROP VIEW +``` + +## Materializing a view + +[A "materialized" view](https://www.postgresql.org/docs/current/rules-materializedviews.html) is one where the results are stored - in effect, it's a table that remembers the query used to create it. Unlike the example above, a materialized view does *not* automatically reflect changes made to the tables in its definition. + +Let's create the view used above again, but as a materialized view: + +```sql +create materialized view customers_london as +select first_name, last_name, email, city, country +from customer +join address on address.address_id=customer.address_id +join city on city.city_id=address.city_id +join country on country.country_id=city.country_id +where city='London'; +__OUTPUT__ +SELECT 3 +``` + +Query the new view: + +```sql +select * from customers_london; +__OUTPUT__ + first_name | last_name | email | city | country +------------+-----------+-----------------------------------+--------+---------------- + VIRGINIA | GREEN | VIRGINIA.GREEN@sakilacustomer.org | London | United Kingdom + CECIL | VINES | CECIL.VINES@sakilacustomer.org | London | United Kingdom + MATTIE | HOFFMAN | MATTIE.HOFFMAN@sakilacustomer.org | London | United Kingdom +(3 rows) +``` + +And now modify the underlying data and re-query: + +```sql +update address set city_id=312 where city_id=545; +select * from customers_london; +__OUTPUT__ +UPDATE 1 + first_name | last_name | email | city | country +------------+-----------+-----------------------------------+--------+---------------- + VIRGINIA | GREEN | VIRGINIA.GREEN@sakilacustomer.org | London | United Kingdom + CECIL | VINES | CECIL.VINES@sakilacustomer.org | London | United Kingdom + MATTIE | HOFFMAN | MATTIE.HOFFMAN@sakilacustomer.org | London | United Kingdom +(3 rows) +``` + +Observe that the results *haven't* changed, even though the data has - the materialized view maintains its own copy of the results. To refresh those results, we must use `refresh materialized view`: + +```sql +refresh materialized view customers_london; +__OUTPUT__ +REFRESH MATERIALIZED VIEW +``` + +Querying the view again will now return current results: + +```sql +select * from customers_london; +__OUTPUT__ + first_name | last_name | email | city | country +------------+-----------+-----------------------------------+--------+---------------- + EDWARD | BAUGH | EDWARD.BAUGH@sakilacustomer.org | London | United Kingdom + VIRGINIA | GREEN | VIRGINIA.GREEN@sakilacustomer.org | London | United Kingdom + CECIL | VINES | CECIL.VINES@sakilacustomer.org | London | United Kingdom + MATTIE | HOFFMAN | MATTIE.HOFFMAN@sakilacustomer.org | London | United Kingdom +(4 rows) +``` + +Materialized views are useful in situations where results are expensive to obtain, and *don't* always need to be current - you can refresh them on a schedule or as-needed without imposing the cost of the defining query on every query that uses them. diff --git a/advocacy_docs/postgresql_journey/05_maintenance/index.mdx b/advocacy_docs/postgresql_journey/05_maintenance/index.mdx new file mode 100644 index 00000000000..605ee6bb2d5 --- /dev/null +++ b/advocacy_docs/postgresql_journey/05_maintenance/index.mdx @@ -0,0 +1,9 @@ +--- +title: Maintaining a PostgreSQL System +navTitle: Maintenance +--- + +- Monitoring +- Tuning +- Patching +- Backup & Recovery diff --git a/advocacy_docs/postgresql_journey/06_upgrades/index.mdx b/advocacy_docs/postgresql_journey/06_upgrades/index.mdx new file mode 100644 index 00000000000..eb7e7d8ebb7 --- /dev/null +++ b/advocacy_docs/postgresql_journey/06_upgrades/index.mdx @@ -0,0 +1,8 @@ +--- +title: Upgrading a PostgreSQL System +navTitle: Upgrading +--- + +- Planning +- Checklists +- Best Practices diff --git a/advocacy_docs/postgresql_journey/07_disaster_recovery/index.mdx b/advocacy_docs/postgresql_journey/07_disaster_recovery/index.mdx new file mode 100644 index 00000000000..f2e2841759e --- /dev/null +++ b/advocacy_docs/postgresql_journey/07_disaster_recovery/index.mdx @@ -0,0 +1,4 @@ +--- +title: "Planning for Disaster: preparing, analyzing and recovering from damage to a PostgreSQL System" +navTitle: Disaster Recovery +--- diff --git a/advocacy_docs/supported-open-source/barman/index.mdx b/advocacy_docs/supported-open-source/barman/index.mdx new file mode 100644 index 00000000000..04c9f3ef2e1 --- /dev/null +++ b/advocacy_docs/supported-open-source/barman/index.mdx @@ -0,0 +1,34 @@ +--- +title: Barman +navTitle: Barman +description: EDB supports Barman. +tags: + - barman + - backup + - recovery + - replication + - rsync + - postgresql +directoryDefaults: + iconName: coffee + product: barman +--- + +Barman (Backup and Recovery Manager) is an open-source administration tool for remote backups and disaster recovery of PostgreSQL servers in business-critical environments. It relies on PostgreSQL’s robust and reliable Point In Time Recovery technology, allowing DBAs to remotely manage a complete catalogue of backups and the recovery phase of multiple remote servers – all from one location. Barman is distributed under GNU GPL 3 and maintained by EDB. + +!!! Note + Looking for Barman documentation? Head over to [http://docs.pgbarman.org/](http://docs.pgbarman.org/) + + +Key capabilities include: + +- Remote backup and restore with rsync and the PostgreSQL protocol +- Support for file level incremental backups with rsync +- Retention policy support +- WAL Archive Compression with gzip, bzip2, or pigz +- Backup data verification +- Backup with RPO=0 using a synchronous physical streaming replication connection +- Rate limiting +- Tested with custom WAL sizes + +For more about Barman’s features and goals, see https://www.pgbarman.org/about/ diff --git a/advocacy_docs/supported-open-source/barman/single-server-streaming/index.mdx b/advocacy_docs/supported-open-source/barman/single-server-streaming/index.mdx new file mode 100644 index 00000000000..9fba571a480 --- /dev/null +++ b/advocacy_docs/supported-open-source/barman/single-server-streaming/index.mdx @@ -0,0 +1,25 @@ +--- +title: "Backup and Recovery: Single-Server Streaming with Barman" +description: "A quick demonstration of Barman installation, configuration, and basic backup and restore operations" +navTitle: "Demo: Single-Server Streaming" +tags: + - ubuntu + - barman + - postgresql + - streaming-replication + - live-demo +iconName: coffee +directoryDefaults: + platform: ubuntu + prevNext: true +showInteractiveBadge: true +--- + +This section demonstrates setting up a backup and recovery scenario using a Barman server and a PostgreSQL server. It covers: + +1. Configuring the database server to allow Barman to collect data via streaming replication +2. Installing and configuring Barman for streaming replication and testing that configuration +3. Running a full backup +4. Restoring a full backup + +Each of these steps is interactive, with the prerequisites and results of the previous step captured in a Docker image. You can work through the entire scenario in order, or skip to the step that interests you. diff --git a/advocacy_docs/supported-open-source/barman/single-server-streaming/step01-db-setup.mdx b/advocacy_docs/supported-open-source/barman/single-server-streaming/step01-db-setup.mdx new file mode 100644 index 00000000000..d2bf33714f4 --- /dev/null +++ b/advocacy_docs/supported-open-source/barman/single-server-streaming/step01-db-setup.mdx @@ -0,0 +1,151 @@ +--- +title: "Backup and Recovery: Single-Server Streaming - Configuring PostgreSQL" +description: "Configuring a PostgreSQL server for Barman streaming replication" +navTitle: "Database Server Configuration" +product: barman +platform: ubuntu +tags: + - ubuntu + - barman + - postgresql + - streaming-replication + - live-demo +katacodaPanel: + scenario: ubuntu:2004 + initializeCommand: wget -q https://raw.githubusercontent.com/josh-heyer/barmantutorial/main/step01-db-setup/docker-compose.yaml ; docker-compose up -d ; clear ; docker exec -it -u postgres pg /bin/bash + codelanguages: shell, sql, ini +iconName: coffee +--- + +In this step, we'll configure a PostgreSQL server, preparing it to be backed up using Barman. + +!!!interactive This demo is interactive + You can follow along right in your browser. When you click "Start Now," Katacoda will load a Docker Compose + environment with two container images representing a PostgreSQL 13 server with + [the Pagila database](https://github.com/devrimgunduz/pagila) loaded (named `pg`) + and a backup server for Barman (named `backup`). + + Once you see a `postgres@pg` prompt, you can follow the steps below. + + + +For Barman to back up this server, a few things need to be done to prepare it: + +1. Installing the Barman CLI tools +2. Creating a dedicated superuser for Barman to connect as +3. Creating a dedicated streaming user with the replication attribute and remote login permissions +4. Ensuring there are free replication slots + +### Barman CLI installation + +We'll start by installing the barman-cli package: this contains the [`barman-wal-archive`](http://docs.pgbarman.org/release/2.12/barman-wal-archive.1.html) and [`barman-wal-restore`](http://docs.pgbarman.org/release/2.12/barman-wal-restore.1.html) commands that will be used to transmit data to and from our backup server. + +Since PostgreSQL is already installed, [the PostgreSQL apt repository](https://wiki.postgresql.org/wiki/Apt) is already configured and we can just request the package: + +```shell +sudo apt-get update +sudo apt-get -y install barman-cli +__OUTPUT__ +... +Setting up barman-cli-cloud (2.12-1.pgdg100+1) ... +Processing triggers for ca-certificates (20200601~deb10u2) ... +Updating certificates in /etc/ssl/certs... +0 added, 0 removed; done. +Running hooks in /etc/ca-certificates/update.d... +done. +``` + +!!! Tip Further reading + For more details on this package and installation instructions for other supported platforms, see: [the Barman client utilities section in the Barman guide](http://docs.pgbarman.org/release/2.12/index.html#barman-client-utilities-barman-cli). + +### User provisioning + +Let's call our dedicated backup user, "barman". We'll create it interactively via the [`createuser`](https://www.postgresql.org/docs/current/app-createuser.html) utility: + +```shell +createuser --superuser --replication -P barman +__OUTPUT__ +Enter password for new role: +Enter it again: +``` + +Enter `example-password` when prompted (twice). + +!!! Note Make note of that password + We'll need to add it to the ~/.pgpass file on the backup server later! + +We're making this a superuser account, which will allow it full control of all databases on this server. **Be very careful** with superuser credentials! Anyone who can connect as a superuser account owns your data. + +Now we will create the streaming replication user, "streaming_barman". This doesn't need to be a superuser, but it does need the replication attribute: + +```shell +createuser --replication -P streaming_barman +__OUTPUT__ +Enter password for new role: +Enter it again: +``` + +Enter `example-password` when prompted (twice). + +We'll also need to edit `pg_hba.conf` to allow the streaming user to connect from the backup server, by [explicitly allowing it to connect in replication mode](https://www.postgresql.org/docs/current/auth-pg-hba-conf.html): + +```shell +sed -i '$ a host replication streaming_barman all md5' /var/lib/postgresql/data/pg_hba.conf +cat /var/lib/postgresql/data/pg_hba.conf +__OUTPUT__ +... +local replication all trust +host replication all 127.0.0.1/32 trust +host replication all ::1/128 trust + +host all all all md5 +host replication streaming_barman all md5 +``` + +### Database settings for streaming + +We'll also need to make sure there are replication slots available, and that PostgreSQL will allow another sender to connect. We'll use psql to check the current settings: + +```shell +psql -d pagila +``` + +```sql +Show max_wal_senders; +Show max_replication_slots; +__OUTPUT__ + max_wal_senders +----------------- + 10 +(1 row) + + max_replication_slots +----------------------- + 10 +(1 row) +``` + +The default for both of these (for PostgreSQL 10 and above) is 10, so we're fine - but if we needed more (or if they'd been previously set to 0, thus [disabling replication](https://www.postgresql.org/docs/current/runtime-config-replication.html)) then we'd need to increase them. + + +### Gazing fondly at data + +Before we end, let's query some data - this is what we're going to back up! + +```sql +select * from actor where last_name='KILMER'; +\q +__OUTPUT__ + actor_id | first_name | last_name | last_update +----------+------------+-----------+------------------------ + 23 | SANDRA | KILMER | 2020-02-15 09:34:33+00 + 45 | REESE | KILMER | 2020-02-15 09:34:33+00 + 55 | FAY | KILMER | 2020-02-15 09:34:33+00 + 153 | MINNIE | KILMER | 2020-02-15 09:34:33+00 + 162 | OPRAH | KILMER | 2020-02-15 09:34:33+00 +(5 rows) +``` + +We'll verify later on that this can be restored reliably. + +Continue on with [Step #2: Backup Server Configuration](step02-backup-setup). diff --git a/advocacy_docs/supported-open-source/barman/single-server-streaming/step02-backup-setup.mdx b/advocacy_docs/supported-open-source/barman/single-server-streaming/step02-backup-setup.mdx new file mode 100644 index 00000000000..38417b944c9 --- /dev/null +++ b/advocacy_docs/supported-open-source/barman/single-server-streaming/step02-backup-setup.mdx @@ -0,0 +1,198 @@ +--- +title: "Backup and Recovery: Single-Server Streaming - Installing and Configuring Barman" +description: "Installing Barman on an Ubuntu-based backup server, creating a configuration file and testing the connection" +navTitle: "Barman Installation & Configuration" +tags: + - ubuntu + - barman + - postgresql + - streaming-replication + - live-demo +katacodaPanel: + scenario: ubuntu:2004 + initializeCommand: wget -q https://raw.githubusercontent.com/josh-heyer/barmantutorial/main/step02-backup-setup/docker-compose.yaml ; docker-compose up -d ; clear ; docker exec -it backup /bin/bash + codelanguages: shell, sql, ini +iconName: coffee +--- + +In [the previous step](step01-db-setup), we configured the PostgreSQL server, creating users for Barman to connect and manage backups. In this step, we'll install and configure Barman on the backup server. + +!!!interactive This demo is interactive + You can follow along right in your browser. When you click "Start Now," Katacoda will load a Docker Compose + environment with two container images representing a PostgreSQL 13 server with + [the Pagila database](https://github.com/devrimgunduz/pagila) loaded (named `pg`) + and a backup server for Barman (named `backup`). + + Once you see a `root@backup` prompt, you can follow the steps below. + + + +This demonstration uses an Ubuntu environment, so the first step is to configure the PostgreSQL repository ([details are on the PostgreSQL wiki](https://wiki.postgresql.org/wiki/Apt)) + +1. Install prerequesite software + + ```shell + apt-get update + apt-get install -y curl ca-certificates gnupg + __OUTPUT__ + ... + done + ``` +2. Add PostgreSQL's authentication key + + ```shell + curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - + __OUTPUT__ + % Total % Received % Xferd Average Speed Time Time Time Current + Dload Upload Total Spent Left Speed + 100 4812 100 4812 0 0 24426 0 --:--:-- --:--:-- --:--:-- 24426 + OK + ``` + +3. Add the PostgreSQL repository to the list of sources, and update available packages + + ```shell + sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' + apt-get update + __OUTPUT__ + ... + Reading package lists... Done + ``` + +With the repository configured, we can use apt to install Barman and its dependencies: + +```shell +apt-get -y install barman +__OUTPUT__ +... +Processing triggers for systemd (245.4-4ubuntu3.4) ... +Processing triggers for libc-bin (2.31-0ubuntu9.1) ... +``` + +!!! Tip Further reading + For more details on installation (including instructions for other supported operating systems), see [the Installation section in the Barman guide](http://docs.pgbarman.org/release/2.12/#installation). + +## Configuration + +All the important details for a Barman server go into a server configuration file, by default located in `/etc/barman.d`. These are in the classic INI format, with relevant settings in a section named after the server we're going to back up. We'll also use that name for the configuration file itself. Since the server we intend to back up is named "pg", we'll use that: + +```ini +cat <<'EOF' >> /etc/barman.d/pg.conf +[pg] +description = "Example of PostgreSQL Database (Streaming-Only)" +conninfo = host=pg user=barman dbname=pagila +streaming_conninfo = host=pg user=streaming_barman dbname=pagila +backup_method = postgres +streaming_archiver = on +slot_name = barman +create_slot = auto +EOF +``` + +Note that this references the users (`barman` and `streaming_barman`) that we created [in step #1 - Database Server Configuration](../step01-db-setup/). Also of interest is the value for `slot_name` - this is a replication slot that will also have to be created on the server - but we can instruct Barman to do that for us by setting `create_slot` to `auto`. + +The installation process created a brand-new barman user on the backup server, so let's switch to that for the rest of this: + +```shell +su - barman +``` + +### PostgreSQL Connection Password File + +In order for Barman to connect via the user specified, we'll need to add the password we specified in the previous step to Barman's [.pgpass file](https://www.postgresql.org/docs/current/libpq-pgpass.html): + +```shell +cat <<'EOF' >>~/.pgpass +pg:*:*:barman:example-password +pg:*:*:streaming_barman:example-password +EOF +chmod 0600 ~/.pgpass +``` + +Note the change in permissions - this is necessary to protect the visibility of the file, and PostgreSQL will not use it unless permissions are restricted. + +!!! Tip Further reading + For more details on configuration files, see: [the Configuration section in the Barman guide](http://docs.pgbarman.org/release/2.12/#configuration). + +### Verifying the configuration + +During installation, [Barman will have installed a cron service](http://docs.pgbarman.org/release/2.12/index.html#cron) that runs every minute to maintenance tasks. Since we only just gave it a configuration, let's make sure those tasks have run before continuing: + +```shell +barman cron +__OUTPUT__ +Starting WAL archiving for server pg +Starting streaming archiver for server pg +``` + +Now that the configuration is done and initialization has been performed, we can use Barman's check command to verify that it works: + +```shell +barman check pg +__OUTPUT__ +Server pg: + WAL archive: FAILED (please make sure WAL shipping is setup) + PostgreSQL: OK + superuser or standard user with backup privileges: OK + PostgreSQL streaming: OK + wal_level: OK + replication slot: OK + directories: OK + retention policy settings: OK + backup maximum age: OK (no last_backup_maximum_age provided) + compression settings: OK + failed backups: OK (there are 0 failed backups) + minimum redundancy requirements: OK (have 0 backups, expected at least 0) + pg_basebackup: OK + pg_basebackup compatible: OK + pg_basebackup supports tablespaces mapping: OK + systemid coherence: OK (no system Id stored on disk) + pg_receivexlog: OK + pg_receivexlog compatible: OK + receive-wal running: OK + archiver errors: OK +``` + +Uh-oh! WAL archive failed? Not a problem - that just means Barman hasn't seen any new WAL archives come in yet, which isn't surprising given this is an example +database with no writes happening! We can trigger an archive manually and verify that this works: + +```shell +barman switch-wal --archive --archive-timeout 60 pg +__OUTPUT__ +The WAL file 000000010000000000000002 has been closed on server 'pg' +Waiting for the WAL file 000000010000000000000002 from server 'pg' (max: 60 seconds) +Processing xlog segments from streaming for pg + 000000010000000000000002 +``` +This forces WAL rotation and (with the `--archive` option) waits for the WAL to arrive. We'll give it 60 seconds (with the `--archive-timeout` option) to complete; +if it doesn't complete within that amount of time, try again. For more detail on these commands and their options, refer to [the Barman manual](https://docs.pgbarman.org/release/2.12/barman.1.html#commands). + +Once switch-wal has completed successfully, run the check again and you should see all checks passing: + +```shell +barman check pg +__OUTPUT__ +Server pg: + PostgreSQL: OK + superuser or standard user with backup privileges: OK + PostgreSQL streaming: OK + wal_level: OK + replication slot: OK + directories: OK + retention policy settings: OK + backup maximum age: OK (no last_backup_maximum_age provided) + compression settings: OK + failed backups: OK (there are 0 failed backups) + minimum redundancy requirements: OK (have 0 backups, expected at least 0) + pg_basebackup: OK + pg_basebackup compatible: OK + pg_basebackup supports tablespaces mapping: OK + systemid coherence: OK (no system Id stored on disk) + pg_receivexlog: OK + pg_receivexlog compatible: OK + receive-wal running: OK + archiver errors: OK +``` + + +Continue on with [Step #3: Running Backups](step03-backup). diff --git a/advocacy_docs/supported-open-source/barman/single-server-streaming/step03-backup.mdx b/advocacy_docs/supported-open-source/barman/single-server-streaming/step03-backup.mdx new file mode 100644 index 00000000000..ad834c11ea7 --- /dev/null +++ b/advocacy_docs/supported-open-source/barman/single-server-streaming/step03-backup.mdx @@ -0,0 +1,106 @@ +--- +title: "Backup and Recovery: Single-Server Streaming - Running a Base Backup" +description: "Running a full backup using Barman" +navTitle: "Base Backup" +tags: + - ubuntu + - barman + - postgresql + - streaming-replication + - live-demo +katacodaPanel: + scenario: ubuntu:2004 + initializeCommand: wget -q https://raw.githubusercontent.com/josh-heyer/barmantutorial/main/step03-backup/docker-compose.yaml ; docker-compose up -d ; clear ; docker exec -it -u barman backup /bin/bash + codelanguages: shell, sql, ini +iconName: coffee +--- + +With [the Barman server configured in our last step](step02-backup-setup), we can run a full backup (or "base backup"). + +!!!interactive This demo is interactive + You can follow along right in your browser. When you click "Start Now," Katacoda will load a Docker Compose + environment with two container images representing a PostgreSQL 13 server with + [the Pagila database](https://github.com/devrimgunduz/pagila) loaded (named `pg`) + and a backup server for Barman (named `backup`). + + Once you see a `barman@backup` prompt, you can follow the steps below. + + + +To run a full backup, we use [Barman's `backup` command](http://docs.pgbarman.org/release/2.12/#backup): + +```shell +barman backup pg --wait +__OUTPUT__ +Starting backup using postgres method for server pg in /var/lib/barman/pg/base/20210329T235157 +Backup start at LSN: 0/3000000 (000000010000000000000002, 00000000) +Starting backup copy via pg_basebackup for 20210329T235157 +Copy done (time: 1 second) +Finalising the backup. +This is the first backup for server pg +WAL segments preceding the current backup have been found: + 000000010000000000000002 from server pg has been removed +Backup size: 38.3 MiB +Backup end at LSN: 0/4000000 (000000010000000000000003, 00000000) +Backup completed (start time: 2021-03-29 23:51:57.146435, elapsed time: 2 seconds) +Waiting for the WAL file 000000010000000000000003 from server 'pg' +Processing xlog segments from streaming for pg + 000000010000000000000003 +``` + +The `--wait` option causes Barman to wait for arrival and processing of the WAL file corresponding to the end of the backup, to ensure the backup is complete before the command returns. + +!!! Note + Since the cron job is doing this periodically in the background, the WAL segments you see listed may be different than the output listed above! + +Verify that it completed by listing backups for the server: + +```shell +barman list-backup pg +__OUTPUT__ +pg 20210329T235157 - Mon Mar 29 23:51:59 2021 - Size: 54.3 MiB - WAL Size: 0 B +``` +(the timestamps will be different for you) + +Of course, we've configured streaming backups - so we shouldn't need to depend on having a base backup for every change made to the database. Let's make a small modification to the data and verify that it arrives. + +First, log into the database (we'll use our barman user for convenience in this demonstration): + +```shell +psql -h pg -d pagila -U barman +__OUTPUT__ +psql (13.2 (Ubuntu 13.2-1.pgdg20.04+1)) +Type "help" for help. +``` + +Then make a modifications, and view the results: + +```sql +Update actor Set first_name='ALOYSIUS' where actor_id=23; +Select * From actor Where last_name='KILMER'; +\q +__OUTPUT__ +UPDATE 1 + actor_id | first_name | last_name | last_update +----------+------------+-----------+------------------------------- + 45 | REESE | KILMER | 2020-02-15 09:34:33+00 + 55 | FAY | KILMER | 2020-02-15 09:34:33+00 + 153 | MINNIE | KILMER | 2020-02-15 09:34:33+00 + 162 | OPRAH | KILMER | 2020-02-15 09:34:33+00 + 23 | ALOYSIUS | KILMER | 2021-03-29 23:53:22.302271+00 +(5 rows) +``` + +Ok, let's see if it showed up: + +```shell +grep 'ALOYSIUS' ~/pg/streaming/* +__OUTPUT__ +Binary file /var/lib/barman/pg/streaming/000000010000000000000004.partial matches +``` + +There it is! The current WAL segment hasn't been rotated yet, but we have the most recent data in the *partial* WAL streamed to Barman. So in theory, nothing would be lost of something *terrible* happened to the database right now... + +Now, the crucial question with backups is always the same: "can you get the data *back?*" + +We'll answer this in [Step #4: Restoring a Backup](step04-restore). diff --git a/advocacy_docs/supported-open-source/barman/single-server-streaming/step04-restore.mdx b/advocacy_docs/supported-open-source/barman/single-server-streaming/step04-restore.mdx new file mode 100644 index 00000000000..872d8b1c98a --- /dev/null +++ b/advocacy_docs/supported-open-source/barman/single-server-streaming/step04-restore.mdx @@ -0,0 +1,236 @@ +--- +title: "Backup and Recovery: Single-Server Streaming - Recovery" +description: "Recovering from data loss by using Barman to restore a full backup remotely" +navTitle: "Restore" +tags: + - ubuntu + - barman + - postgresql + - streaming-replication + - live-demo +katacodaPanel: + scenario: ubuntu:2004 + initializeCommand: wget -q https://raw.githubusercontent.com/josh-heyer/barmantutorial/main/step04-restore/docker-compose.yaml ; docker-compose up -d ; clear ; docker exec -it -u barman backup /bin/bash + codelanguages: shell, sql, ini +iconName: coffee +--- + +In the previous step, [we created a full backup of the example database](step03-backup). But it's not a real backup until we've successfully restored it - so let's end with that. + +!!!interactive This demo is interactive + You can follow along right in your browser. When you click "Start Now," Katacoda will load a Docker Compose + environment with two container images representing a PostgreSQL 13 server with + [the Pagila database](https://github.com/devrimgunduz/pagila) loaded (named `pg`) + and a backup server for Barman (named `backup`). + + Once you see a `barman@backup` prompt, you can follow the steps below. + + + +Something terrible has happened to our example database! This should list all the tables: + +```shell +psql -h pg -d pagila -U barman -c '\dt' +__OUTPUT__ +Did not find any relations. +``` + +All the data is gone! + +Ok, I just didn't populate the data for this step, in order to demonstrate a total loss. Fortunately, we still have a backup! + +```shell +barman list-backup pg +``` + +Let's instruct Barman to ssh into the database server and restore the backup. + +1. Connect to pg and shut down the database cluster: + + ```shell + ssh postgres@pg /usr/lib/postgresql/13/bin/pg_ctl \ + --pgdata=/var/lib/postgresql/data stop + __OUTPUT__ + waiting for server to shut down.... done + server stopped + ``` + +2. Back up the corrupt data directory, just in case something goes wrong. Then delete the corrupt data. + + ```shell + ssh postgres@pg "cp -a /var/lib/postgresql/data \ + /var/lib/postgresql/old_data \ + && rm -rf /var/lib/postgresql/data/*" + ``` + +3. Use [Barman's recover command](http://docs.pgbarman.org/release/2.12/#recover) to connect to pg and restore the latest backup + + ```shell + barman recover --remote-ssh-command 'ssh postgres@pg' \ + pg latest \ + /var/lib/postgresql/data + __OUTPUT__ + Starting remote restore for server pg using backup 20210330T040549 + Destination directory: /var/lib/postgresql/data + Remote command: ssh postgres@pg + Using safe horizon time for smart rsync copy: 2021-03-30 04:05:58+00:00 + Copying the base backup. + Copying required WAL segments. + Generating archive status files + Identify dangerous settings in destination directory. + + Recovery completed (start time: 2021-03-31 02:29:23.555186, elapsed time: 1 second) + + Your PostgreSQL server has been successfully prepared for recovery! + ``` + + Barman handles connecting to the destination server, but we do have to provide a valid path *on* that server. In this example, the PostgreSQL cluster lives in /var/lib/postgresql/data and we're asking Barman to overwrite it with the backup. + +4. Restart the server: + + ```shell + ssh postgres@pg "/usr/lib/postgresql/13/bin/pg_ctl \ + --pgdata=/var/lib/postgresql/data \ + -l /var/log/postgresql/pg.log \ + start \ + ; tail /var/log/postgresql/pg.log" + __OUTPUT__ + waiting for server to start.... done + server started + 2021-03-31 02:29:12.761 UTC [2201] LOG: database system is shut down + 2021-03-31 02:30:13.156 UTC [2515] LOG: starting PostgreSQL 13.2 (Debian 13.2-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit + 2021-03-31 02:30:13.157 UTC [2515] LOG: listening on IPv4 address "0.0.0.0", port 5432 + 2021-03-31 02:30:13.157 UTC [2515] LOG: listening on IPv6 address "::", port 5432 + 2021-03-31 02:30:13.160 UTC [2515] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" + 2021-03-31 02:30:13.164 UTC [2516] LOG: database system was interrupted; last known up at 2021-03-30 04:05:58 UTC + 2021-03-31 02:30:13.337 UTC [2516] LOG: redo starts at 0/4000028 + 2021-03-31 02:30:13.337 UTC [2516] LOG: consistent recovery state reached at 0/4000138 + 2021-03-31 02:30:13.337 UTC [2516] LOG: redo done at 0/4000138 + 2021-03-31 02:30:13.363 UTC [2515] LOG: database system is ready to accept connections + ``` + +Now we should be able to reconnect to the database: + +```shell +psql -h pg -d pagila -U barman +__OUTPUT__ +psql (13.2 (Ubuntu 13.2-1.pgdg20.04+1)) +Type "help" for help. + +pagila=# +``` + +...And re-run the query we started out with: + +```sql +select * from actor where last_name='KILMER'; +\q +__OUTPUT__ + actor_id | first_name | last_name | last_update +----------+------------+-----------+------------------------ + 23 | SANDRA | KILMER | 2020-02-15 09:34:33+00 + 45 | REESE | KILMER | 2020-02-15 09:34:33+00 + 55 | FAY | KILMER | 2020-02-15 09:34:33+00 + 153 | MINNIE | KILMER | 2020-02-15 09:34:33+00 + 162 | OPRAH | KILMER | 2020-02-15 09:34:33+00 +(5 rows) +``` + +Ok, so far so good - but, we're missing the update we wrote to this data! Remember, that wasn't in the base backup, it was in a partial WAL file... Fortunately, Barman still has it and knows how to use it. + +Let's try this recovery process again: + +1. Connect to pg and shut down the database cluster: + + ```shell + ssh postgres@pg /usr/lib/postgresql/13/bin/pg_ctl \ + --pgdata=/var/lib/postgresql/data stop + ``` + +2. Back up the corrupt data directory, just in case something goes wrong. Then delete the corrupt data. + + ```shell + ssh postgres@pg "cp -a /var/lib/postgresql/data \ + /var/lib/postgresql/old_data \ + && rm -rf /var/lib/postgresql/data/*" + __OUTPUT__ + waiting for server to shut down.... done + server stopped + ``` + +3. Instruct Barman to connect to pg and restore the latest backup *with the `--get-wal` option* - this triggers WAL fetching, including partial WAL files, during the recovery process. + ```shell + barman recover --remote-ssh-command 'ssh postgres@pg' \ + --get-wal \ + pg latest \ + /var/lib/postgresql/data + __OUTPUT__ + Starting remote restore for server pg using backup 20210330T040549 + Destination directory: /var/lib/postgresql/data + Remote command: ssh postgres@pg + Copying the base backup. + Generating recovery configuration + Identify dangerous settings in destination directory. + + WARNING: 'get-wal' is in the specified 'recovery_options'. + Before you start up the PostgreSQL server, please review the postgresql.auto.conf file + inside the target directory. Make sure that 'restore_command' can be executed by the PostgreSQL user. + + Recovery completed (start time: 2021-03-31 00:47:46.722740, elapsed time: 1 second) + + Your PostgreSQL server has been successfully prepared for recovery! + ``` + +4. Restart the server: + + ```shell + ssh postgres@pg "/usr/lib/postgresql/13/bin/pg_ctl \ + --pgdata=/var/lib/postgresql/data \ + -l /var/log/postgresql/pg.log \ + start \ + ; tail /var/log/postgresql/pg.log" + __OUTPUT__ + waiting for server to start..... done + server started + 2021-03-31 00:47:52.278 UTC [250] LOG: listening on IPv6 address "::", port 5432 + 2021-03-31 00:47:52.282 UTC [250] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" + 2021-03-31 00:47:52.286 UTC [251] LOG: database system was interrupted; last known up at 2021-03-30 04:05:58 UTC + ERROR: WAL file '00000002.history' not found in server 'pg' (SSH host: 192.168.80.2) + ERROR: Remote 'barman get-wal' command has failed! + 2021-03-31 00:47:52.863 UTC [251] LOG: starting archive recovery + 2021-03-31 00:47:53.350 UTC [251] LOG: restored log file "000000010000000000000004" from archive + 2021-03-31 00:47:53.362 UTC [251] LOG: redo starts at 0/4000028 + 2021-03-31 00:47:53.362 UTC [251] LOG: consistent recovery state reached at 0/4000138 + 2021-03-31 00:47:53.363 UTC [250] LOG: database system is ready to accept read only connections + ``` + +!!! Note about those errors... + You may notice two lines starting with "ERROR:" mid-way through the recovery log. They're fine - that's just PostgreSQL scanning to make sure it has the most recent timeline. + By going through this recovery, we've actually created a *new* timeline - in fact, if you were to run through the four steps above again, you'd see that now `00000002.history` is found and PostgreSQL goes looking for `00000003.history`... Try it! + + For more on PostgreSQL backup timelines, see [Continuous Archiving in the PostgreSQL documentation](https://www.postgresql.org/docs/current/continuous-archiving.html#BACKUP-TIMELINES). + +Now check the data again: + +```shell +psql -h pg -d pagila -U barman -c \ + "select * from actor where last_name='KILMER'" +__OUTPUT__ + actor_id | first_name | last_name | last_update +----------+------------+-----------+------------------------------- + 45 | REESE | KILMER | 2020-02-15 09:34:33+00 + 55 | FAY | KILMER | 2020-02-15 09:34:33+00 + 153 | MINNIE | KILMER | 2020-02-15 09:34:33+00 + 162 | OPRAH | KILMER | 2020-02-15 09:34:33+00 + 23 | ALOYSIUS | KILMER | 2021-03-30 04:06:55.101099+00 +(5 rows) +``` + +Good ol' Aloysius is back! + +!!! Tip Further Reading + For more details on recovery of partial WAL files, see: [Limitations of partial WAL files with recovery in the Barman guide](http://docs.pgbarman.org/release/2.12/index.html#limitations-of-partial-wal-files-with-recovery). + +## Conclusion + +This demonstration barely scratches the surface of what is possible with Barman, but hopefully it has provided you with a taste of its capabilities! For more details, visit https://pgbarman.org/ diff --git a/advocacy_docs/supported-open-source/pgadmin/index.mdx b/advocacy_docs/supported-open-source/pgadmin/index.mdx new file mode 100644 index 00000000000..a949058eb2e --- /dev/null +++ b/advocacy_docs/supported-open-source/pgadmin/index.mdx @@ -0,0 +1,29 @@ +--- +title: pgAdmin +navTitle: pgAdmin +description: EDB supports pgAdmin. +directoryDefaults: + iconName: postgresql + product: pgAdmin +--- + +pgAdmin is an open source, multi-platform console for PostgreSQL management and administration. + +!!! Note + Looking for pgAdmin documentation? Head over to [https://www.pgadmin.org/docs/](https://www.pgadmin.org/docs/) + +pgAdmin is available in desktop or web-based deployment models and is compatible with PostgreSQL or EDB Postgres Advanced Server 9.5 or higher. The intuitive graphical user interface (GUI) provides tools for managing, querying, and analyzing PostgreSQL databases. + +Key capabilities include: + +- Powerful query tool with color syntax highlighting +- Fast datagrid for display/entry of data +- Graphical query plan display +- Grant Wizard for rapid updates to ACLs +- Procedural language debugger (supporting pl/pgsql and edb-spl) +- Schema diff tool for managing differences between schemas +- Auto-vacuum management +- Monitoring dashboard +- Backup, restore, vacuum and analyze on demand +- SQL/shell/batch job scheduling agent + diff --git a/advocacy_docs/supported-open-source/pgbackrest/02-installation.mdx b/advocacy_docs/supported-open-source/pgbackrest/02-installation.mdx new file mode 100644 index 00000000000..9736290998d --- /dev/null +++ b/advocacy_docs/supported-open-source/pgbackrest/02-installation.mdx @@ -0,0 +1,61 @@ +--- +title: 'Installation' +description: 'Instructions for installing pgBackRest on supported systems, including EDB Postgres Advanced Server' +tags: + - installation + - EPAS + - pgBackRest +--- + +### Available platforms + +pgBackRest packages are available on the following platforms. + +#### Debian/Ubuntu + +To install pgBackRest, configure the [PostgreSQL](https://www.postgresql.org/download/linux/ubuntu/) or the [EDB](https://www.enterprisedb.com/repository-access-thank-you-page) **apt** repository and then run: + +```bash +$ sudo apt-get install pgbackrest +``` + +The following additional packages will be installed: + +* `postgresql-client-common` +* `postgresql-common` + +#### RHEL/CentOS + +pgBackRest can be installed from the [PostgreSQL](https://yum.postgresql.org/) or the [EDB](https://www.enterprisedb.com/repository-access-thank-you-page) **yum** repositories, and requires Extra Packages for Enterprise Linux ([EPEL](https://fedoraproject.org/wiki/EPEL)). + +Once you configured the repositories, run the following command to install pgBackRest: + +```bash +$ sudo yum install pgbackrest +``` + +The following additional packages will be installed: + +* `postgresql-libs` +* `libzstd` + +### EDB Postgres Advanced Server + +The PGDG packages will fetch **PostgreSQL** libraries and create the `postgres` system user. + +If **EDB Postgres Advanced Server** is already installed on the system, the libraries installed at that time would be used. + +By default, the packages create the following directories owned by `postgres`: +* `/var/lib/pgbackrest` +* `/var/log/pgbackrest` +* `/var/spool/pgbackrest` + +The `pg_hba.conf` settings should allow the `postgres` user to execute the `pgbackrest` command. + +If you are using **EDB Postgres Advanced Server**, the `enterprisedb` system user will execute the `pgbackrest` command. The following commands will change the ownership of the pgBackRest directories: + +```bash +$ sudo chown -R enterprisedb: /var/lib/pgbackrest +$ sudo chown -R enterprisedb: /var/log/pgbackrest +$ sudo chown -R enterprisedb: /var/spool/pgbackrest +``` diff --git a/advocacy_docs/supported-open-source/pgbackrest/03-quick_start.mdx b/advocacy_docs/supported-open-source/pgbackrest/03-quick_start.mdx new file mode 100644 index 00000000000..1a269773b3c --- /dev/null +++ b/advocacy_docs/supported-open-source/pgbackrest/03-quick_start.mdx @@ -0,0 +1,187 @@ +--- +title: 'Quick Start' +description: "A walkthrough: configuring pgBackRest, then running, examining and restoring a backup of a database cluster" +tags: + - configuration + - backup + - restore + - pgBackRest + - EPAS +--- + +This section walks you through basic pgBackRest configuration process and how to take a first backup of the database cluster running locally. It also gives a brief introduction of the `backup`, `restore`, and `info` commands. + +The [installation](02-installation) procedure must be followed before proceeding to this section. + +### Configuration + +The default pgBackRest configuration file location is `/etc/pgbackrest/pgbackrest.conf`. If it does not exist, then `/etc/pgbackrest.conf` is used next. + +For more information about configuration parameters, see the [appendix section](98-appendix/#configuration-reference). + +The following example configures a `demo` stanza to take a backup of a database cluster running on the local host. + +For **EDB Postgres Advanced Server**: + +```ini +[global] +repo1-path=/var/lib/edb/as13/backups + +[demo] +pg1-path=/var/lib/edb/as13/data +pg1-user=enterprisedb +pg1-port=5444 +``` + +For **PostgreSQL**: + +```ini +[global] +repo1-path=/var/lib/pgsql/13/backups + +[demo] +pg1-path=/var/lib/pgsql/13/data +pg1-user=postgres +pg1-port=5432 +``` + +Once pgBackRest is configured, set up the database archiver process: + +```ini +# postgresql.conf +archive_mode = on +archive_command = 'pgbackrest --stanza=demo archive-push %p' +``` + +As changing the `archive_mode` parameter requires a service restart, and changing the `archive_command` only requires a configuration reload, we recommend enabling `archive_mode` with an empty `archive_command` (or pointing to /bin/true) when initiating a new database cluster. + +Assume the identity of a system user (`postgres` or `enterprisedb`) and initiate the pgBackRest repository: + +```bash +$ pgbackrest --stanza=demo --log-level-console=info stanza-create +``` + +Check the configuration and the archiving process: + +```bash +$ pgbackrest --stanza=demo --log-level-console=info check +``` + +### Backups + +When invoking pgBackRest, you can specify any one of the backup type: + +* Full backup - `full` + * Copies all database cluster files. + * No dependencies on previous backups. + +For example: + +```bash +$ pgbackrest --stanza=demo --type=full backup +``` + +* Incremental backup - `incr` + * Copies only the database cluster files that have changed since the last backup. + * Depends on other backups to restore the incremental backup. + +For example: + +```bash +$ pgbackrest --stanza=demo --type=incr backup +``` + +* Differential backup - `diff` + * Copies only the database cluster files that have changed since the last full backup. + * Similar to an incremental backup, but always depends on the last full backup. + +For example: + +```bash +$ pgbackrest --stanza=demo --type=diff backup +``` + +If there is no full backup to base an incremental or differential backup on, pgBackRest will run in full backup mode instead. + +### Backup Information + +Use the `info` command to get information about backups. + +```bash +$ pgbackrest --stanza=demo info +stanza: demo + status: ok + cipher: none + + db (current) + wal archive min/max (13-1): 000000010000000000000001/000000010000000000000007 + + full backup: 20201019-162148F + timestamp start/stop: 2020-10-19 16:21:48 / 2020-10-19 16:21:58 + wal start/stop: 000000010000000000000003 / 000000010000000000000003 + database size: 23.9MB, backup size: 23.9MB + repository size: 2.9MB, repository backup size: 2.9MB +... +``` + +By default, the `info` command provides a human-readable summary of backups for the stanza requested. Without specifying `--stanza`, the `info` command will operate on all stanzas. + +### Restore + +Use the `restore` command to restore a backup. The `--delta` option allows to keep the existing database cluster files and only recover as required, where as without the `--delta` option all files will be restored. Before running the restore command, stop the database cluster and (unless the `--delta` option is used) remove all files from the data directory, and from tablespaces. + +```bash +$ pgbackrest --stanza=demo restore +``` + +Currently, the only way to verify the consistency of a backup is to restore it. We then recommend to try restore backups on a regular basis. + +#### Recovery target + +By default, the `restore` command will restore the latest backup and apply all of the archived WAL files found in the repository. + +To choose the recovery target type for the restore, include the `--type` command-line option with one of the following keywords: + +* `default` - recover to the end of the archive stream. +* `immediate` - recovery only until the database becomes consistent. +* `name` - recover to the restore point. +* `xid` - recover to the transaction ID. +* `time` - recover to a specific timestamp. +* `preserve` - preserve the existing recovery settings. +* `standby` - add `standby_mode=on` or `standby.signal`. +* `none` - no recovery settings provided. + +When `--type` is set to **name**, transaction ID (**xid**), or **time**, use the `--target` option to specify a restore point. + +pgBackRest will automatically select the correct backup set to restore if a recovery target time is specified. Otherwise, the latest backup set will be used. To restore a specific backup set, use the `--set` option. + +To change the `recovery_target_action` PostgreSQL setting, use the restore `--target-action` option: + +* `pause` - pause when recovery target is reached (default). +* `promote` - promote and switch timeline when recovery target is reached. +* `shutdown` - shutdown server when recovery target is reached. + +### Glossary + +#### pgBackRest + +[`delta`](https://pgbackrest.org/configuration.html#section-general/option-delta) +[`log-level-console`](https://pgbackrest.org/configuration.html#section-log/option-log-level-console) +[`pg-path`](https://pgbackrest.org/configuration.html#section-stanza/option-pg-path) +[`pg-port`](https://pgbackrest.org/configuration.html#section-stanza/option-pg-port) +[`pg-user`](https://pgbackrest.org/configuration.html#section-stanza/option-pg-user) +[`repo-path`](https://pgbackrest.org/configuration.html#section-repository/option-repo-path) + +##### `restore` command + +[restore `--set`](https://pgbackrest.org/command.html#command-restore/category-command/option-set) +[restore `--target`](https://pgbackrest.org/command.html#command-restore/category-command/option-target) +[restore `--target-action`](https://pgbackrest.org/command.html#command-restore/category-command/option-target-action) +[restore `--type`](https://pgbackrest.org/command.html#command-restore/category-command/option-type) + +#### PostgreSQL + +[`archive_command`](https://www.postgresql.org/docs/current/runtime-config-wal.html#GUC-ARCHIVE-COMMAND) +[`archive_mode`](https://www.postgresql.org/docs/current/runtime-config-wal.html#GUC-ARCHIVE-MODE) +[`recovery_target_action`](https://www.postgresql.org/docs/current/runtime-config-wal.html#GUC-RECOVERY-TARGET-ACTION) +[`standby_mode`](https://www.postgresql.org/docs/11/standby-settings.html#STANDBY-MODE) diff --git a/advocacy_docs/supported-open-source/pgbackrest/04-recommended_settings.mdx b/advocacy_docs/supported-open-source/pgbackrest/04-recommended_settings.mdx new file mode 100644 index 00000000000..2ba5ddab616 --- /dev/null +++ b/advocacy_docs/supported-open-source/pgbackrest/04-recommended_settings.mdx @@ -0,0 +1,77 @@ +--- +title: 'Recommended Settings' +description: "Recommendations & rationale for pgBackRest configuration settings" +--- + +This section walks you through the recommended settings while using pgBackRest. + +### Encryption + +Use the following settings to encrypt the files in the repository `repo1`: + +```ini +repo1-cipher-pass=FIXME +repo1-cipher-type=aes-256-cbc +``` + +The `cipher-pass` should be **base64** encoded. For example, to generate a random passphrase use the following setting: + +```bash +$ openssl rand -base64 48 +``` + +### Maximum Number of Processes + +Use the following setting to set the maximum number of processes for compression usage and file transfer: + +```ini +process-max=FIXME +``` + +Each process will perform compression and transfer to make the command run faster, but do not set `process-max` so high that it impacts server load and performance. + +### Backup Fast Start + +Use the `start-fast=y` setting to force a checkpoint to start the backup quickly. This is achieved inside pgBackRest by passing **true** to the fast parameter of the **pg_start_backup()** database function. The backup will then begin immediately rather than waiting for the next regular checkpoint triggered by the database server itself. + +### Delta + +Use the `delta=y` setting to restore or backup using checksums. + +During a restore, the data and tablespaces directories are expected to be present, but empty. This option performs a delta restore using checksums. + +During a backup, this option will use checksums instead of timestamps to determine if files will be copied. + +### Log Levels + +The output of each command will be printed in the console and a log file. + +Use the following `log-level-console` and `log-level-file` settings to apply the log level: + +- **off**; +- **error**; +- **warn**; +- **info**; +- **detail**; +- **debug**; +- **trace**. + +**CAUTION:** Trace-level logging may expose secrets such as keys and passwords. + +To add more output in the log file in case the executed command encounters an error and to avoid re-executing the command for more information, use the following settings: + +```ini +log-level-console=info +log-level-file=debug +``` + +### Glossary + +#### pgBackRest + +[`delta`](https://pgbackrest.org/configuration.html#section-general/option-delta) +[`log-level-console`](https://pgbackrest.org/configuration.html#section-log/option-log-level-console) +[`log-level-file`](https://pgbackrest.org/configuration.html#section-log/option-log-level-file) +[`process-max`](https://pgbackrest.org/configuration.html#section-general/option-process-max) +[`repo-cipher-pass`](https://pgbackrest.org/configuration.html#section-repository/option-repo-cipher-pass) +[`repo-cipher-type`](https://pgbackrest.org/configuration.html#section-repository/option-repo-cipher-type) diff --git a/advocacy_docs/supported-open-source/pgbackrest/05-retention_policy.mdx b/advocacy_docs/supported-open-source/pgbackrest/05-retention_policy.mdx new file mode 100644 index 00000000000..5c700dbb666 --- /dev/null +++ b/advocacy_docs/supported-open-source/pgbackrest/05-retention_policy.mdx @@ -0,0 +1,72 @@ +--- +title: 'Retention Policy' +description: "Configuration options and considerations for the removal of obsolete backups and WAL archives" +--- + +Setting retention policy options allows to remove obsolete backups. Those settings will then be a trade-off between saving space and data retention. + +### Full backup retention + +Full backup retention is determined by the `repo1-retention-full-type` and `repo1-retention-full` options. + +The `repo1-retention-full-type` option can be set to `count` (default) to retain a specific number of full backups. As an example, if `repo1-retention-full-type=count` and `repo1-retention-full=2`, pgBackRest will retain the 2 last successful full backups. + +Alternatively the `repo1-retention-full-type` option can be set to `time` to retain full backups for a specific time duration. With this configuration, at least one full backup older than the retention period will remain to fulfill the retention requirement. All other full backups older than the `repo1-retention-full` value, measured in days, will be removed from the repository. As an example, if `repo1-retention-full-type=time` and `repo1-retention-full=30` (days), one full backup older than 30 days will be preserved. If in this example the repository would hold five full backups - one 25 days old, one 35 days old, and the rest older - the 35-days-old full backup would still be required to restore to the period between 30 and 25 days ago, and as such is kept even though it is older than the configured retention period. All other older backups will be removed during retention maintenance. + +When a full backup expires, all differential and incremental backups associated with it will also expire. When the `repo1-retention-full` option is not defined, a warning will be issued. + +Archived WAL files that are older than the remaining oldest full backup will be automatically removed, but this behavior can be changed with the archive retention settings (`repo1-retention-archive-type` and `repo1-retention-archive`). + +Set the `repo1-retention-full` option to its maximum value (9999999) to retain all backups indefinitely. + +### Differential backup retention + +Differential backup retention is determined by the `repo1-retention-diff` option. + +When a differential backup expires, all incremental backups associated with the differential backup will also expire. + +When not defined, all differential backups will be retained until the dependent full backups expires. + +### Archive retention + +pgBackRest allows to define a specific retention policy for archives. + +> :warning: pgBackRest relies on backup start location to define the archives to clean. In some cases, the oldest archived WAL file in the repository might be older than the first backup start location, in which case it will not be removed until the first backup expires. + +#### `repo1-retention-archive-type` + +The `repo1-retention-archive-type` option can be set to define the backup types counted for WAL retention. + +If the `repo1-retention-archive-type` option is set to `full` (default), pgBackRest will keep archived WAL files for the number of full backups as defined by `repo1-retention-archive`. + +If the `repo1-retention-archive-type` option is set to `diff` (differential), pgBackRest will keep archives for the number of full and differential backups defined by `repo1-retention-archive`. As an example, if the last backup taken was a full backup, it will be counted as a differential for the purpose of the repository retention. + +If the `repo1-retention-archive-type` option is set to `incr` (incremental), pgBackRest will keep archives for the number of full, differential, and incremental backups defined by `repo1-retention-archive`. + +> :warning: It is recommended to keep the `repo1-retention-archive-type` option with its default, in which case archives will be removed along with full backups. + +#### `repo1-retention-archive` + +The `repo1-retention-archive` option can be set to define the number of backups preserved for continuous WAL retention. + +> :warning: WAL segments required to make a backup consistent (based on the full and differential backups retention policies) are always retained until the backup expires regardless of how the `repo1-retention-archive` option is configured. + +The `repo1-retention-archive` is highly dependent on other options: + +- If `repo1-retention-full-type` is set to `time`, then the `repo1-retention-archive` value will default to removing archived WAL files that are older than the oldest full backup retained after satisfying the `repo1-retention-full` setting. + +- When `repo1-retention-archive-type` is set to `incr`, the `repo1-retention-archive` must be set. + +- If the `repo1-retention-archive` value is not set, and `repo1-retention-full-type` is set to **count** (default), then the `repo1-retention-archive-type` value defines how archives will expire: when `repo1-retention-archive-type` is set to `full` or `diff`, archives expiry will default to the `repo1-retention-full` or `repo1-retention-diff` respectively. This configuration will ensure that the archived WAL files are only removed for corresponding expired backups. + +Using the `repo1-retention-archive` setting in conjunction with `repo1-retention-archive-type` can reclaim disk-space by removing extra WAL segments. This configuration is **not recommended** as it negates the ability to perform point-in-time recovery from the backups with expired WAL. + +### Glossary + +#### pgBackRest + +[`repo-retention-archive-type`](https://pgbackrest.org/configuration.html#section-repository/option-repo-retention-archive-type) +[`repo-retention-archive`](https://pgbackrest.org/configuration.html#section-repository/option-repo-retention-archive) +[`repo-retention-diff`](https://pgbackrest.org/configuration.html#section-repository/option-repo-retention-diff) +[`repo-retention-full-type`](https://pgbackrest.org/configuration.html#section-repository/option-repo-retention-full-type) +[`repo-retention-full`](https://pgbackrest.org/configuration.html#section-repository/option-repo-retention-full) diff --git a/advocacy_docs/supported-open-source/pgbackrest/06-use_case_1.mdx b/advocacy_docs/supported-open-source/pgbackrest/06-use_case_1.mdx new file mode 100644 index 00000000000..905641e2c6d --- /dev/null +++ b/advocacy_docs/supported-open-source/pgbackrest/06-use_case_1.mdx @@ -0,0 +1,222 @@ +--- +title: 'Use Case 1: Running pgBackRest Locally on the Database Host' +navTitle: 'Use Case 1' +description: "Examines a configuration used to run pgBackRest locally, on the database host" +tags: + - configuration + - pgBackRest + - EPAS +--- + +### Description + +* pgBackRest runs locally on database servers and stores repository on remote storage (NFS, S3, Azure or GCS compatible object stores). +* Cron task active on the node where to take backups. +* Manually reconfigure cron task to take backup from another server. + +![Use case diagram](images/use_case_1-01.png) + +--- + +### Configuration + +#### Global Section + +The `[global]` section will contain the: +* repository location; +* recommended settings; +* retention policy. + +This section's settings should be the same for all the nodes (primary and standbys). + +##### Mount Points + +Set `repo1-type` to **posix** or **cifs** and specify the `repo1-path` location to store backups and archives on a shared space: + +```ini +repo1-type=posix +repo1-path=/backup_space +``` + +##### S3-compatible Object Stores + +```ini +repo1-type=s3 +repo1-path=/repo1 +repo1-s3-bucket=bucket-name +repo1-s3-endpoint=... +repo1-s3-key=accessKey1 +repo1-s3-key-secret=*** +repo1-s3-region=... +``` + +The backups and archives will be stored in `bucket-name/repo1`. + +It is possible to automatically retrieve temporary credentials when the AWS instance is associated with an IAM role. Credentials are automatically updated when they are <= 5 minutes from expiring. + +To do this, instead of setting `repo1-s3-key` and `repo1-s3-key-secret`, use: + +```ini +repo1-s3-key-type=auto +repo1-s3-role=authrole +``` + +##### Azure-compatible Object Stores + +```ini +repo1-type=azure +repo1-azure-key-type=shared +repo1-path=/repo1 +repo1-azure-container=container-name +repo1-azure-account=pgbackrest +repo1-azure-key=*** +``` + +To use the shared access signatures, set the `repo1-azure-key-type` option to **sas** and the `repo1-azure-key` option to the shared access signature token. + +##### GCS-compatible Object Stores + +```ini +repo1-type=gcs +repo1-gcs-key-type=service +repo1-path=/repo1 +repo1-gcs-bucket=bucket-name +repo1-gcs-key=/etc/pgbackrest/gcs-key.json +``` + +`repo1-gcs-key` is a **token** or **service** key file depending on the `repo1-gcs-key-type` option. + +##### Recommended Settings + +Use those settings to enable encryption, parallel operations and ensure displaying enough information in the console and in the log file: + +```ini +repo1-cipher-type=aes-256-cbc +repo1-cipher-pass=FIXME +process-max=FIXME +log-level-console=info +log-level-file=debug +start-fast=y +delta=y +``` + +Adjust the encryption passphrase and the maximum number of processes to use for compression usage and file transfer. + +See the [Recommended settings](04-recommended_settings) page for more details. + +##### Retention Policy + +To be able to delete old backups and archives, you have to define a retention policy. Use the following setting to only keep the latest full backup: + +```ini +repo1-retention-full=1 +``` + +See the [Retention policy](05-retention_policy) page for more options and details. + +#### Stanza Section + +The `[demo]` stanza section will be different on each database server and should contain: + +* the location of the **PostgreSQL** configuration files + +```ini +pg1-path=/var/lib/pgsql/13/data +``` + +or for **EDB Postgres Advanced Server** + +```ini +pg1-path=/var/lib/edb/as13/data +pg1-user=enterprisedb +pg1-port=5444 +``` + +* for every other **PostgreSQL** node + +```ini +pg2-host=other_node_hostname_or_ip +pg2-path=/var/lib/pgsql/13/data +``` + +or for **EDB Postgres Advanced Server** + +```ini +pg2-host=other_node_hostname_or_ip +pg2-host-user=enterprisedb +pg2-path=/var/lib/edb/as13/data +``` + +* specific recovery option to set the replication `primary_conninfo` after the restore command is executed: + +```ini +recovery-option=primary_conninfo=host=primary_vip user=replication_user ... +``` + +#### Setup Archiving + +Once pgBackRest is configured, set up the database archiver process on each node: + +```ini +# postgresql.conf +archive_mode = on +archive_command = 'pgbackrest --stanza=demo archive-push %p' +``` + +As changing the `archive_mode` parameter requires a service restart, and changing the `archive_command` only requires a configuration reload, we recommend enabling `archive_mode` with an empty `archive_command` (or pointing to /bin/true) when initiating a new database cluster. + +See the [Quick start](03-quick_start) page to set up a simple **demo** stanza configuration. + +Assume the identity of the system user (`postgres` or `enterprisedb`) and initiate the pgBackRest repository from the primary server: + +```bash +$ pgbackrest --stanza=demo stanza-create +``` + +Check the configuration and the archiving process: + +```bash +$ pgbackrest --stanza=demo check +``` + +### Backup and Restore + +See the **Quick start** [backups](03-quick_start#backups) and [restore](03-quick_start#restore) sections for more details about those two commands. + +### Glossary + +#### pgBackRest + +[`delta`](https://pgbackrest.org/configuration.html#section-general/option-delta) +[`log-level-console`](https://pgbackrest.org/configuration.html#section-log/option-log-level-console) +[`log-level-file`](https://pgbackrest.org/configuration.html#section-log/option-log-level-file) +[`pg-host-user`](https://pgbackrest.org/configuration.html#section-stanza/option-pg-host-user) +[`pg-host`](https://pgbackrest.org/configuration.html#section-stanza/option-pg-host) +[`pg-path`](https://pgbackrest.org/configuration.html#section-stanza/option-pg-path) +[`pg-port`](https://pgbackrest.org/configuration.html#section-stanza/option-pg-port) +[`pg-user`](https://pgbackrest.org/configuration.html#section-stanza/option-pg-user) +[`process-max`](https://pgbackrest.org/configuration.html#section-general/option-process-max) +[`recovery-option`](https://pgbackrest.org/configuration.html#section-restore/option-recovery-option) +[`repo-azure-account`](https://pgbackrest.org/configuration.html#section-repository/option-repo-azure-account) +[`repo-azure-container`](https://pgbackrest.org/configuration.html#section-repository/option-repo-azure-container) +[`repo-azure-key-type`](https://pgbackrest.org/configuration.html#section-repository/option-repo-azure-key-type) +[`repo-azure-key`](https://pgbackrest.org/configuration.html#section-repository/option-repo-azure-key) +[`repo-cipher-pass`](https://pgbackrest.org/configuration.html#section-repository/option-repo-cipher-pass) +[`repo-cipher-type`](https://pgbackrest.org/configuration.html#section-repository/option-repo-cipher-type) +[`repo-path`](https://pgbackrest.org/configuration.html#section-repository/option-repo-path) +[`repo-retention-full`](https://pgbackrest.org/configuration.html#section-repository/option-repo-retention-full) +[`repo-s3-bucket`](https://pgbackrest.org/configuration.html#section-repository/option-repo-s3-bucket) +[`repo-s3-endpoint`](https://pgbackrest.org/configuration.html#section-repository/option-repo-s3-endpoint) +[`repo-s3-key-secret`](https://pgbackrest.org/configuration.html#section-repository/option-repo-s3-key-secret) +[`repo-s3-key-type`](https://pgbackrest.org/configuration.html#section-repository/option-repo-s3-key-type) +[`repo-s3-key`](https://pgbackrest.org/configuration.html#section-repository/option-repo-s3-key) +[`repo-s3-region`](https://pgbackrest.org/configuration.html#section-repository/option-repo-s3-region) +[`repo-s3-role`](https://pgbackrest.org/configuration.html#section-repository/option-repo-s3-role) +[`repo-type`](https://pgbackrest.org/configuration.html#section-repository/option-repo-type) +[`start-fast`](https://pgbackrest.org/configuration.html#section-backup/option-start-fast) + +#### PostgreSQL + +[`archive_command`](https://www.postgresql.org/docs/current/runtime-config-wal.html#GUC-ARCHIVE-COMMAND) +[`archive_mode`](https://www.postgresql.org/docs/current/runtime-config-wal.html#GUC-ARCHIVE-MODE) +[`primary_conninfo`](https://www.postgresql.org/docs/current/runtime-config-replication.html#GUC-PRIMARY-CONNINFO) diff --git a/advocacy_docs/supported-open-source/pgbackrest/07-use_case_2.mdx b/advocacy_docs/supported-open-source/pgbackrest/07-use_case_2.mdx new file mode 100644 index 00000000000..b17e31abdf2 --- /dev/null +++ b/advocacy_docs/supported-open-source/pgbackrest/07-use_case_2.mdx @@ -0,0 +1,189 @@ +--- +title: 'Use Case 2: Running pgBackRest from a Dedicated Repository Host' +navTitle: 'Use Case 2' +description: "Examines a configuration used to run pgBackRest from a dedicated repository host" +tags: + - configuration + - pgBackRest + - EPAS +--- + +### Description + +* pgBackRest runs on a dedicated backup server and stores repository on local or remote storage (NFS, S3, Azure or GCS compatible object stores). +* Cron task active to take backups from the primary database cluster. +* Manually reconfigure cron task to take backup from another server. + +![Use case diagram](images/use_case_2-01.png) + +### Create a Dedicated User on the Repository Host + +The `pgbackrest` user is created to own the backups and archives repository. Any user can own the repository, but it is recommended not to use `postgres` or `enterprisedb` to avoid confusion. + +```bash +$ sudo groupadd pgbackrest +$ sudo adduser -g pgbackrest -n pgbackrest +$ sudo chown pgbackrest: /var/log/pgbackrest +``` + +### Setup Passwordless SSH Connection + +pgBackRest requires a passwordless SSH connection to enable communication between the hosts. + +The following example SSH commands should succeed without prompting you for a password: + +```bash +# From the PostgreSQL nodes +$ sudo -u postgres ssh pgbackrest@backup-server + +# From the EDB Postgres Advanced Server nodes +$ sudo -u enterprisedb ssh pgbackrest@backup-server + +# From the repository host +$ sudo -u pgbackrest ssh postgres@postgres-node-1 +$ sudo -u pgbackrest ssh postgres@postgres-node-2 +$ ... +``` + +### Configuration + +#### Backup Server + +The repository should be reachable from the backup server. It can be located on the various supported types described in the [first use case](06-use_case_1#global-section). + +For example, let us create `/backup_space` to store our backups and archives locally: + +```bash +$ sudo mkdir /backup_space +$ sudo chown pgbackrest: /backup_space +``` + +The `[global]` section of the configuration file will look like this: + +```ini +[global] +repo1-path=/backup_space +repo1-retention-full=2 +repo1-cipher-type=aes-256-cbc +repo1-cipher-pass=FIXME +process-max=FIXME +log-level-console=info +log-level-file=debug +start-fast=y +delta=y +``` + +Adjust the encryption passphrase and the maximum number of processes to use for compression usage and file transfer. + +See the [Recommended settings](05-retention_policy) pages for more details. + +The `[demo]` stanza section will contain specific `pg-` options for each database node. + +* the primary database server configuration for **PostgreSQL** + +```ini +pg1-host=postgres-node-1 +pg1-path=/var/lib/pgsql/13/data +``` + +or for **EDB Postgres Advanced Server** + +```ini +pg1-host=postgres-node-1 +pg1-host-user=enterprisedb +pg1-path=/var/lib/edb/as13/data +``` + +* for every other **PostgreSQL** node + +```ini +pg2-host=other_node_hostname_or_ip +pg2-path=/var/lib/pgsql/13/data +``` + +or for **EDB Postgres Advanced Server** + +```ini +pg2-host=other_node_hostname_or_ip +pg2-host-user=enterprisedb +pg2-path=/var/lib/edb/as13/data +``` + +Define multiple nodes using `pg2`, `pg3`,... to reach standby servers only when those servers are available. + +#### Database server(s) + +Update the pgBackRest configuration file on the database server(s): + +```ini +# pgbackrest.conf +[global] +repo1-host=backup-server +repo1-host-user=pgbackrest +log-level-console=info +log-level-file=debug +delta=y + +[demo] +pg1-path=/var/lib/pgsql/13/data +recovery-option=primary_conninfo=host=primary_vip user=replication_user ... +``` + +The `[demo]` stanza section will be different for **PostgreSQL** or for **EDB Postgres Advanced Server**, and the `recovery-option` is used to set the replication `primary_conninfo` after executing the restore command. For more details, please refer to the [Use case 1](06-use_case_1#stanza-section) page for more details. + +#### Setup Archiving + +Once pgBackRest is configured, set up the database archiver process on each node: + +```ini +# postgresql.conf +archive_mode = on +archive_command = 'pgbackrest --stanza=demo archive-push %p' +``` + +As changing the `archive_mode` parameter requires a service restart, and changing the `archive_command` only requires a configuration reload, we recommend enabling `archive_mode` with an empty `archive_command` (or pointing to /bin/true) when initiating a new database cluster. + +From the backup server (also called repository host), initiate the pgBackRest repository with the system user we created earlier: + +```bash +$ sudo -u pgbackrest pgbackrest --stanza=demo stanza-create +``` + +Check the configuration and the archiving process: + +```bash +$ sudo -u pgbackrest pgbackrest --stanza=demo check +``` + +### Backup and Restore + +See the **Quick start** [backups](03-quick_start#backups) and [restore](03-quick_start#restore) sections for more details about those two commands. + +The `backup` command will be executed on the repository host (aka. _backup-server_), while the `restore` command should be executed on database nodes (aka. _postgres-node-1_,...). + +### Glossary + +#### pgBackRest + +[`delta`](https://pgbackrest.org/configuration.html#section-general/option-delta) +[`log-level-console`](https://pgbackrest.org/configuration.html#section-log/option-log-level-console) +[`log-level-file`](https://pgbackrest.org/configuration.html#section-log/option-log-level-file) +[`pg-host`](https://pgbackrest.org/configuration.html#section-stanza/option-pg-host) +[`pg-path`](https://pgbackrest.org/configuration.html#section-stanza/option-pg-path) +[`pg-port`](https://pgbackrest.org/configuration.html#section-stanza/option-pg-port) +[`pg-user`](https://pgbackrest.org/configuration.html#section-stanza/option-pg-user) +[`process-max`](https://pgbackrest.org/configuration.html#section-general/option-process-max) +[`recovery-option`](https://pgbackrest.org/configuration.html#section-restore/option-recovery-option) +[`repo-cipher-pass`](https://pgbackrest.org/configuration.html#section-repository/option-repo-cipher-pass) +[`repo-cipher-type`](https://pgbackrest.org/configuration.html#section-repository/option-repo-cipher-type) +[`repo-host`](https://pgbackrest.org/configuration.html#section-repository/option-repo-host) +[`repo-host-user`](https://pgbackrest.org/configuration.html#section-repository/option-repo-host-user) +[`repo-path`](https://pgbackrest.org/configuration.html#section-repository/option-repo-path) +[`repo-retention-full`](https://pgbackrest.org/configuration.html#section-repository/option-repo-retention-full) +[`start-fast`](https://pgbackrest.org/configuration.html#section-backup/option-start-fast) + +#### PostgreSQL + +[`archive_command`](https://www.postgresql.org/docs/current/runtime-config-wal.html#GUC-ARCHIVE-COMMAND) +[`archive_mode`](https://www.postgresql.org/docs/current/runtime-config-wal.html#GUC-ARCHIVE-MODE) +[`primary_conninfo`](https://www.postgresql.org/docs/current/runtime-config-replication.html#GUC-PRIMARY-CONNINFO) diff --git a/advocacy_docs/supported-open-source/pgbackrest/98-appendix.mdx b/advocacy_docs/supported-open-source/pgbackrest/98-appendix.mdx new file mode 100644 index 00000000000..cbfd00afe50 --- /dev/null +++ b/advocacy_docs/supported-open-source/pgbackrest/98-appendix.mdx @@ -0,0 +1,99 @@ +--- +title: 'Appendix' +description: "Definitions for terms and concepts used in this guide, along with notes on configuration terminology" +--- + +### Concepts + +The following concepts are defined as they are relevant to pgBackRest, PostgreSQL, and this user guide. + +#### Backup + +A backup is a consistent copy of a database cluster that can be restored to recover from a hardware failure, perform point-in-time recovery, or to bring up a new standby. + +**Full Backup**: pgBackRest copies the entire content of the database cluster to the backup. The first backup of the database cluster is always a full backup. pgBackRest restores a full backup directly. The full backup does not depend on any files outside of the full backup for consistency. + +**Differential Backup**: pgBackRest copies only the database cluster files that have changed since the last full backup. To restore a differential backup, pgBackRest copies all of the files in the chosen differential backup and the appropriate unchanged files from the previous full backup. The advantage of a differential backup is that it requires less disk space than a full backup, however, the differential backup and the full backup must be valid to restore the differential backup. + +**Incremental Backup**: pgBackRest copies only the database cluster files that have changed since the last backup (which can be an incremental backup, a differential backup, or a full backup). Since an incremental backup only includes the files changed since the prior backup, they are generally much smaller than a full or differential backup. An incremental backup requires other backups to be valid before restoring the incremental backup. Since the incremental backup includes only those files that have been changed or added since the last backup, all prior incremental backups (back to the prior differential and the prior full backup) must be valid to restore the incremental backup. If no differential backup exists, then all prior incremental backups (back to the prior full backup and the full backup itself) must be valid to restore the incremental backup. + +#### Restore + +A restore is an act of copying a backup to a system where it will be started as a live database cluster. A restore requires the backup files and one or more WAL segments in order to work correctly. + +#### Write Ahead Log (WAL) + +WAL logging is the mechanism that PostgreSQL uses to ensure that no committed changes are lost. Transactions are written sequentially to the WAL and a transaction is considered to be committed when those writes are flushed to disk. Later, a background writer process writes the changes into the main database cluster files (also known as the heap). In the event of a crash, the WAL is replayed to make the database consistent. + +WAL is conceptually infinite but in practice is broken up into individual 16MB files called segments. WAL segments follow the naming convention 0000000100000A1E000000FE where the first eight hexadecimal digits represent the timeline and the next 16 digits are the log sequence number (LSN). + +#### Encryption + +Encryption is the process of converting data into a format that is unrecognizable unless you provide the appropriate password (also referred to as passphrase). To prevent unauthorized access to data stored within the repository, pgBackRest will encrypt the repository after authentication with a user-provided password. + +--- + +### Configuration Reference + +You can find a complete list of commands and configuration keys in the project documentation: + +- [Command reference](http://www.pgbackrest.org/command.html) for command-line operations. + +- [Configuration reference](http://www.pgbackrest.org/configuration.html) for creating pgBackRest configurations. + +You can use pgBackRest entirely with command-line parameters, but a configuration file is more practical for complex installations when configuring multiple options instantly. The default location for the configuration file is `/etc/pgbackrest/pgbackrest.conf`. If the configuration file does not exist in that location, then the old `/etc/pgbackrest.conf` file will be loaded instead (if it exists). + +It is also recommended to use a configuration file in order to avoid specifying secrets in command-line options. + +#### Global + +Use the global section of the configuration file to set the default values. + +The global section also allows you to define values that will be used when invoking specific commands. For example, the following configuration setting would specify the compress level for the `archive-push` command: + +``` +[global:archive-push] +compress-level=3 +``` + +#### Stanza + +A **stanza** is a database cluster configuration that defines where the database cluster is located, how to take a backup of the database cluster, available archiving options, etc. Most database servers will only have one database cluster and, therefore, one stanza; whereas backup servers will have a stanza for each database cluster that needs to be backed up. + +Because the stanza name will be used for the primary and all replicas, it is recommended to choose a name that describes the cluster's databases and actual function, such as app or dw, rather than the local instance name, such as main or prod. + +The stanza-level settings overrides any global configuration settings. + +#### Command Line Arguments and Environment Variables + +You can also configure options as command line argument or environment variables. + +- To use a non-boolean argument on the command line, simply prefix the option with a double dash. + +- To set a boolean option to false on the command line, use the `--no-` prefix. + +- To set an environment variable, capitalize the option name, prefix it with *PGBACKREST_*, and replace dashes with underscores. + +The following table illustrates how to specify an option using the `pgbackrest.conf` file, command line argument, and environment variable. + +| Configuration File | Command Line Argument | Environment Variable | +|---------------------------|-----------------------|-------------------------------| +| `pg1-host=1.2.3.4` | `--pg1-host=1.2.3.4` | `PGBACKREST_PG1_HOST=1.2.3.4` | +| `compress=y` | `--compress` | `PGBACKREST_COMPRESS=y` | +| `delta=n` | `--no-delta` | `PGBACKREST_DELTA=n` | + +#### Options Precedence + +For all options, the order of precedence (highest to lowest) is as follows: + +- Command line argument +- Environment variable +- `[stanza:command]` +- `[stanza]` +- `[global:command]` +- `[global]` +- Default (internal) + +#### Configuring Multiple Database Hosts in a Stanza + +Each stanza could configure multiple database hosts. As such, you can also configure every `pg1-*` configuration option for host 2 with `pg2-*`, for host 3 with `pg3-*`, etc. This assumes that those database clusters are linked together (e.g. using [Streaming Replication](https://www.postgresql.org/docs/current/warm-standby.html#STREAMING-REPLICATION)). diff --git a/advocacy_docs/supported-open-source/pgbackrest/99-faq.mdx b/advocacy_docs/supported-open-source/pgbackrest/99-faq.mdx new file mode 100644 index 00000000000..216b6a869c4 --- /dev/null +++ b/advocacy_docs/supported-open-source/pgbackrest/99-faq.mdx @@ -0,0 +1,17 @@ +--- +title: 'Frequently Asked Questions' +navTitle: 'FAQ' +description: 'Answers to Frequently Asked Questions' +--- + +- Why do we have to specify the `--stanza` option even if only one stanza is defined in the configuration file? + +Except for the repository specific commands (`info`, `start`, `stop`), the `--stanza` option is required so that adding a stanza does not cause the commands that did not have a stanza specified to suddenly throw errors because they do not know which stanza to use. + +--- + +- Is it possible to only restore a specific database from a complete database cluster backup? + +Yes. You can restore a specific database using the [restore `--db-include`](https://pgbackrest.org/command.html#command-restore/category-command/option-db-include) option. After recovery, you can then extract the selected databases with the [`pg_dump`](https://www.postgresql.org/docs/current/app-pgdump.html) command. + +The databases that are not explicitly included with this option will be restored as sparse, zeroed files to save space; however, it still allows PostgreSQL to perform the recovery using less disk space. You can then remove these databases with the [`DROP DATABASE`](https://www.postgresql.org/docs/current/sql-dropdatabase.html) command since they will no longer be accessible. diff --git a/advocacy_docs/supported-open-source/pgbackrest/images/use_case_1-01.png b/advocacy_docs/supported-open-source/pgbackrest/images/use_case_1-01.png new file mode 100644 index 00000000000..4530d3fb9e8 Binary files /dev/null and b/advocacy_docs/supported-open-source/pgbackrest/images/use_case_1-01.png differ diff --git a/advocacy_docs/supported-open-source/pgbackrest/images/use_case_2-01.png b/advocacy_docs/supported-open-source/pgbackrest/images/use_case_2-01.png new file mode 100644 index 00000000000..f1afc29224d Binary files /dev/null and b/advocacy_docs/supported-open-source/pgbackrest/images/use_case_2-01.png differ diff --git a/advocacy_docs/supported-open-source/pgbackrest/index.mdx b/advocacy_docs/supported-open-source/pgbackrest/index.mdx new file mode 100644 index 00000000000..ecbc123c429 --- /dev/null +++ b/advocacy_docs/supported-open-source/pgbackrest/index.mdx @@ -0,0 +1,22 @@ +--- +title: 'pgBackRest' +description: 'Introduction to pgBackRest, a reliable PostgreSQL backup & restore tool' +tags: + - backup + - restore + - pgBackRest + - EPAS +indexCards: simple +directoryDefaults: + iconName: 'postgressupport' + product: 'pgBackRest' +--- + +pgBackRest is an easy-to-use backup and restore tool that aims to enable your organization to implement disaster recovery solutions for PostgreSQL databases. + +!!! Note + Looking for pgBackRest documentation? Head over to [http://www.pgbackrest.org](http://www.pgbackrest.org) + +pgBackRest [v2.33](https://github.com/pgbackrest/pgbackrest/releases/tag/release/2.33) is the current stable release. Release notes are on the [Releases](http://www.pgbackrest.org/release.html) page. + +EDB collaborates with the community on this open-source software. The packages provided in EDB repositories are technically equivalent to the packages provided by the **PostgreSQL** community. All of the use cases shown in this document are fully tested and supported by **EDB Postgres Advanced Server**. diff --git a/advocacy_docs/supported-open-source/postgresql/index.mdx b/advocacy_docs/supported-open-source/postgresql/index.mdx new file mode 100644 index 00000000000..2f61c4e068a --- /dev/null +++ b/advocacy_docs/supported-open-source/postgresql/index.mdx @@ -0,0 +1,15 @@ +--- +title: PostgreSQL +navTitle: PostgreSQL +description: EDB supports PostgreSQL. +directoryDefaults: + iconName: postgresql + product: PostgreSQL +--- + +PostgreSQL is a popular, free, open-source relational database management system (RDBMS). It has earned a reputation for reliability, performance, and extensibility, with a robust feature set to securely store and scale even the most complex workloads. + +!!! Note + Looking for PostgreSQL documentation? Head over to [postgresql.org/docs](https://www.postgresql.org/docs/) + +EDB is deeply involved with and committed to the PostgreSQL community with the goal of constantly improving and building upon the software. We’re active in promoting the adoption of PostgreSQL and related software worldwide, contributing every year since 2006. Some of our team members have been involved with the project since its inception in 1996, and continue to play a key role in shaping its future. diff --git a/advocacy_docs/supported-open-source/postgresql/installer/01_requirements_overview.mdx b/advocacy_docs/supported-open-source/postgresql/installer/01_requirements_overview.mdx new file mode 100644 index 00000000000..db06e8ae87b --- /dev/null +++ b/advocacy_docs/supported-open-source/postgresql/installer/01_requirements_overview.mdx @@ -0,0 +1,49 @@ +--- +title: "Requirements Overview" +legacyRedirects: + - "/edb-docs/d/postgresql/installation-getting-started/installation-guide/13.0/requirements_overview.html" +--- + + + +## Supported Platforms + +For information about the platforms and versions supported by PostgreSQL, visit the [EDB website](https://www.enterprisedb.com/services-support/edb-supported-products-and-platforms/) + +**Note** + +PostgreSQL version 13.0 is no longer supported on CentOS/RHEL/OEL 6.x platforms. It is strongly recommended that EDB products running on these platforms be migrated to a supported platform. + +To download PostgreSQL installers for Windows, Mac, and the Linux versions listed above, visit the [EDB website](https://www.enterprisedb.com/downloads/postgresql) + +PostgreSQL is also available for other Linux-based hosts. For more information, visit [PostgreSQL website](https://www.postgresql.org/download/). + +## Hardware Requirements + +The following installation requirements assume you have selected the default options during the installation process. The minimum hardware required to install and run PostgreSQL are: + +- 1 GHz processor +- 2 GB of RAM +- 512 MB of HDD + +Additional disk space is required for data or supporting components. + + + +## Software Prerequisites + +**User Privileges** + +On a Mac system, you must have superuser privileges to perform a PostgreSQL installation. To perform an installation on a Windows system, you must have administrator privileges. + +If you are installing PostgreSQL on a Windows system that is configured with User Account Control (UAC) enabled, you can assume sufficient privileges to invoke the graphical installer by clicking on the right side of the installer name and selecting `Run as administrator` from the context menu. If prompted, enter an administrator password to continue. + +**Windows-specific Software Requirements** + +Apply the Windows operating system updates before invoking the PostgreSQL installer. If the installer encounters errors during the installation process, exit the installation and ensure that your Windows version is up-to-date before restarting the installer. + +**Mac OS X-specific Software Requirements** + +PostgreSQL installation on Mac OS X differs slightly from other platforms as the distribution is in a different format, and some additional configuration may be required. + +The Mac OS X installer is an App Bundle (a set of files and directories in a prescribed format). The installer is available as a disk image (`.dmg`) file from the website or as an archive (`.zip`) from Stack Builder. To extract the installer, simply mount the disk image and copy the installer to the desired location, or run it directly from the disk image. diff --git a/advocacy_docs/supported-open-source/postgresql/installer/02_installing_postgresql_with_the_graphical_installation_wizard/01_invoking_the_graphical_installer.mdx b/advocacy_docs/supported-open-source/postgresql/installer/02_installing_postgresql_with_the_graphical_installation_wizard/01_invoking_the_graphical_installer.mdx new file mode 100644 index 00000000000..b12378b3e3b --- /dev/null +++ b/advocacy_docs/supported-open-source/postgresql/installer/02_installing_postgresql_with_the_graphical_installation_wizard/01_invoking_the_graphical_installer.mdx @@ -0,0 +1,94 @@ +--- +title: "Invoking the Graphical Installer" +legacyRedirects: + - "/edb-docs/d/postgresql/installation-getting-started/installation-guide/13.0/invoking_the_graphical_installer.html" +--- + + + +To perform an installation using the graphical installation wizard, you must have superuser or administrator privileges. + +The following section walks you through installing PostgreSQL on a Windows host. + +To start the installation wizard, assume sufficient privileges and double-click the installer icon; if prompted, provide a password. + +Note that in some versions of Windows, to invoke the installer with Administrator privileges, you need to right-click on the installer icon and select `Run as Administrator` from the context menu. + +The PostgreSQL setup wizard opens. Click `Next` to continue. + +![The PostgreSQL setup wizard welcome dialog](../images/welcome.png) + +Fig. 1: The PostgreSQL setup wizard welcome dialog + +The `Installation Directory` window opens. Accept the default installation directory, or specify an alternate location and click `Next` to continue. + +![The Installation Directory dialog](../images/installation_directory.png) + +Fig. 2: The Installation Directory dialog + +Use options on the `Select Components` dialog to select which software components will be installed. + +Select: + +- `PostgreSQL Server` to install the PostgreSQL database server. +- `pgAdmin 4` to install pgAdmin 4. This is available for PostgreSQL version 13.0. +- `Stack Builder` to install the Stack Builder utility; for more information about the Stack Builder utility, see [Using Stack Builder](../03_using_stackbuilder). +- `Command Line Tools` to install PostgreSQL tools such as `psql, pg_isready`, and `pgbench`, `clusterdb, createdb`, and `dropdb`, `createuser` and `dropuser`, `pg_basebackup, pg_dump, pg_dumpall`, and `pg_restore`, `reindexdb, vacuumdb`, and `vacuumlo`. This is not a comprehensive list; the command line tools installed may vary by platform. + +![Select Components](../images/select_components.png) + +Fig. 3: Select Components + +Click `Next` to continue. + +The `Data Directory` window opens. Accept the default location or specify the name of the alternate directory in which you wish to store the data files. + +![The Data Directory dialog](../images/data_directory.png) + +Fig. 4: The Data Directory dialog + +Click `Next` to continue. + +The `Password` window opens. + +![The Password dialog](../images/password.png) + +Fig. 5: The Password dialog + +PostgreSQL uses the password specified on the `Password` window for both the database superuser and the PostgreSQL service account. + +PostgreSQL runs as a service in the background; the PostgreSQL service account is named `postgres`. If you have already created a service account with the name `postgres`, you must specify same password as the existing password for the `postgres` service account. + +The specified password must conform to any security policies existing on the PostgreSQL host. After entering a password in the `Password` field, and confirming the password in the `Retype Password` field, click `Next` to continue. + +Use the `Port` field to specify the port number on which the server should listen. The default listener port is `5432`. Click `Next` to continue. + +Use the `Locale` field to specify the locale that will be used by the new database cluster. The `Default locale` is the operating system locale. Click `Next` to continue. + +![The Advanced Options dialog](../images/aug11_ad.png) + +Fig. 6: The Advanced Options dialog + +The `Pre Installation Summary` dialog displays the installation preferences that you have specified with the installation wizard. Review the settings; you can use the `Back` button to return to a previous dialog to modify a setting, or click `Next` to continue. + +![The Pre Installation Summary dialog](../images/preinstallation.png) + +Fig. 7: The Pre Installation Summary dialog + +The wizard will inform you that it has the information required to install PostgreSQL; click `Next` to continue. + +![The Ready to Install dialog](../images/ready_to_install.png) + +Fig. 8: The Ready to Install dialog + +During the installation, the setup wizard confirms the installation progress of PostgreSQL via a series of progress bars. + +![The Installing dialog](../images/installing.png) + +Fig. 9: The Installing dialog + +Before the setup wizard completes the PostgreSQL installation, it offers to launch Stack Builder at exit. The Stack Builder utility provides a graphical interface that downloads and installs applications and drivers that work with PostgreSQL. You can optionally uncheck the `Stack Builder` box and click `Finish` to complete the PostgreSQL installation or accept the default and proceed to launch Stack Builder. + +![The installation wizard offers to Launch Stack Builder at exit](../images/installation_complete.png) + +Fig. 10: The installation wizard offers to Launch Stack Builder at exit diff --git a/advocacy_docs/supported-open-source/postgresql/installer/02_installing_postgresql_with_the_graphical_installation_wizard/index.mdx b/advocacy_docs/supported-open-source/postgresql/installer/02_installing_postgresql_with_the_graphical_installation_wizard/index.mdx new file mode 100644 index 00000000000..4f309f702d5 --- /dev/null +++ b/advocacy_docs/supported-open-source/postgresql/installer/02_installing_postgresql_with_the_graphical_installation_wizard/index.mdx @@ -0,0 +1,22 @@ +--- +title: "Installing PostgreSQL with the Graphical Installation Wizard" +legacyRedirects: + - "/edb-docs/d/postgresql/installation-getting-started/installation-guide/13.0/installing_postgresql_with_the_graphical_installation_wizard.html" +--- + +The graphical installation wizard provides a quick and easy way to install PostgreSQL on a Mac or Windows system. As the installation wizard’s easy-to-follow dialogs lead you through the installation process, specify information about your system. When the dialogs are complete, the setup wizard will perform an installation based on the selections made during the setup process. + +!!! Note + If you are invoking the graphical installer to perform a system upgrade, the installer will preserve the configuration options specified during the previous installation. + +When the PostgreSQL installation finishes, you will be offered the option to invoke the Stack Builder package manager. Stack Builder provides an easy-to-use graphical interface that downloads and installs applications, drivers and utilities and their dependencies. See [Using Stack Builder](../03_using_stackbuilder) for more information. + +The graphical PostgreSQL installer is available on the [EDB website](http://www.enterprisedb.com/downloads/postgres-postgresql-downloads). + +The PostgreSQL installer is available on the [EDB website](https://www.enterprisedb.com/postgresql-early-experience). + +
+ +invoking_the_graphical_installer + +
diff --git a/advocacy_docs/supported-open-source/postgresql/installer/03_using_stackbuilder.mdx b/advocacy_docs/supported-open-source/postgresql/installer/03_using_stackbuilder.mdx new file mode 100644 index 00000000000..4d937889198 --- /dev/null +++ b/advocacy_docs/supported-open-source/postgresql/installer/03_using_stackbuilder.mdx @@ -0,0 +1,72 @@ +--- +title: "Using Stack Builder" +legacyRedirects: + - "/edb-docs/d/postgresql/installation-getting-started/installation-guide/13.0/using_stackbuilder.html" +--- + + + +The Stack Builder utility provides a graphical interface that simplifies the process of downloading and installing modules that complement your PostgreSQL installation. When you install a module with Stack Builder, Stack Builder automatically resolves any software dependencies. + +Stack Builder requires Internet access; if your installation of PostgreSQL resides behind a firewall (with restricted Internet access), Stack Builder can download program installers through a proxy server. The module provider determines if the module can be accessed through an HTTP proxy or an FTP proxy; currently, all updates are transferred via an HTTP proxy and the FTP proxy information is not used. + +You can invoke Stack Builder at any time after the installation has completed by selecting the `Application Stack Builder` menu option from the `PostgreSQL 13` menu. Enter your system password (if prompted), and the Stack Builder welcome window opens. + +Use the drop-down listbox on the welcome window to select your PostgreSQL installation. + +![The Stack Builder welcome window](images/stack_builder_welcome.png) + +Fig. 1: The Stack Builder welcome window + +If the selected PostgreSQL installation has restricted Internet access, use the `Proxy Servers` button on the `Welcome` window to open the Proxy servers dialog. + +Enter the IP address and port number of the proxy server in the `HTTP proxy` or `FTP proxy` fields on the Proxy servers dialog. Currently, all Stack Builder modules are distributed via HTTP proxy (FTP proxy information is ignored). Click `OK` to continue. + +![The Proxy servers dialog](images/the_proxy_servers_dialog.png) + +Fig. 2: The Proxy servers dialog + +The tree control on the Stack Builder module selection window contains a node for each module category. Click on a category heading to expose the modules within that category. + +![The Stack Builder module selection window](images/module_selection.png) + +Fig. 3: The Stack Builder module selection window + +Each entry within the tree control is the name of a module that can be installed with Stack Builder. + +- If the module is installed, you will see the word (`installed`) to the right of the module name. +- Boxes next to the modules that are already installed, but eligible for update are automatically checked. +- To add new modules to the selected PostgreSQL installation, check the box to the left of the module name and click `Next`. + +![Check the box to add new module](images/checkbox_module.png) + +Fig. 4: Check the box to add new module + +The `Selected packages` window confirms the packages selected. + +![A summary window displays a list of selected packages](images/summary_of_selected_packages.png) + +Fig. 5: A summary window displays a list of selected packages + +The package installers are downloaded to the directory specified in the `Download directory` field. Use the button to the right of the `Download directory` field to open a file selector, and choose an alternate location to store the downloaded installers. + +Click `Next` to connect to the server and download the required installation files. + +When the downloads complete, a window opens confirming that the installation files have been downloaded and are ready for installation. + +![Confirmation that the download process is complete](images/download_completes.png) + +Fig. 6: Confirmation that the download process is complete + +You can check the box next to `Skip Installation` and select `Next` to exit Stack Builder without installing the downloaded files, or leave the box unchecked and click `Next` to start the installation process. + +Each downloaded installer has different requirements. As the installers execute, they may prompt you to confirm acceptance of license agreements, to enter passwords, and enter configuration information. + +During the installation process, you may be prompted by one (or more) of the installers to restart your system. Select `No` or `Restart Later` until all installations are completed. When the last installation has completed, re-boot the system to apply all of the updates. + +You may occasionally encounter packages that don’t install successfully. If a package fails to install, Stack Builder will alert you to the installation error with a popup dialog, and write a message to the log file stored in `%TEMP%`. + +When the installation is complete, the installer will alert you to the success or failure of the installations of the requested packages. If you were prompted by an installer to restart your computer, re-boot now. + +!!! Note + The modules supported by Stack Builder are subject to change and vary by platform. diff --git a/advocacy_docs/supported-open-source/postgresql/installer/04_installation_troubleshooting.mdx b/advocacy_docs/supported-open-source/postgresql/installer/04_installation_troubleshooting.mdx new file mode 100644 index 00000000000..a442fda7a35 --- /dev/null +++ b/advocacy_docs/supported-open-source/postgresql/installer/04_installation_troubleshooting.mdx @@ -0,0 +1,18 @@ +--- +title: "Installation Troubleshooting" +legacyRedirects: + - "/edb-docs/d/postgresql/installation-getting-started/installation-guide/13.0/installation_troubleshooting.html" +--- + + + + + +If you encounter any problems during installation, please consult the installation logfile. The log file is created in: + +- `/tmp` on Mac OS X +- `%TEMP%` on Windows + +The installation log file is called `install-postgresql.log`. The logfile may contain the superuser password specified during the installation, which should be replaced before sharing the log with anyone. + +If you are unable to resolve the problem after reviewing the logfile, please search the self-service content available at the [EDB website](https://www.enterprisedb.com/postgres-tutorials) for a solution. If you still cannot resolve the issue, please write details of the problem, along with system details and any appropriate parts of the installation logfile to . diff --git a/advocacy_docs/supported-open-source/postgresql/installer/05_uninstalling_postgresql.mdx b/advocacy_docs/supported-open-source/postgresql/installer/05_uninstalling_postgresql.mdx new file mode 100644 index 00000000000..b218c633aa4 --- /dev/null +++ b/advocacy_docs/supported-open-source/postgresql/installer/05_uninstalling_postgresql.mdx @@ -0,0 +1,76 @@ +--- +title: "Uninstalling PostgreSQL" +legacyRedirects: + - "/edb-docs/d/postgresql/installation-getting-started/installation-guide/13.0/uninstalling_postgresql.html" +--- + + + +The PostgreSQL installer creates an uninstaller in the PostgreSQL installation directory. This section walks you through uninstalling PostgreSQL on a Windows as well as a Mac host. + +## Uninstalling PostgreSQL on Windows + +To uninstall PostgreSQL, navigate to the Windows `Control Panel` to open the `Uninstall or change a program` dialog and Right-click the `PostgreSQL 13` and select `Uninstall/Change` from the context menu. + +![The Uninstall or change a program dialog](images/change_program.png) + +Fig. 1: The Uninstall or change a program dialog + +You can either remove the entire application or individual components. + +- If you wish to remove the entire application, select the `Entire application` option and click `Next` to start uninstalling components. +- If you wish to remove individual components, select the `Individual components` option and click `Next`, a selection screen opens, allowing you to select which components you wish to uninstall. Select the components you wish to uninstall, and click `Next` to start uninstalling components. + +![Confirm that you wish to uninstall PostgreSQL](images/uninstalling_postgreSQL_comfirmation.png) + +Fig. 2: Confirm that you wish to uninstall PostgreSQL + +Select the components you want to uninstall. Click `Next` when you are ready to continue. + +![Select the components to uninstall](images/select_the_components_to_uninstall.png) + +Fig. 3: Select the components to uninstall +s +A progress bar will keep you informed as PostgreSQL is removed. + +![Uninstalling PostgreSQL](images/uninstallingpostgres1.png) + +Fig. 4: Uninstalling PostgreSQL + +When the uninstaller completes, click `OK` to exit. + +![An Info dialog confirms the uninstallation](images/uninstallationcomplete.png) + +Fig. 5: An Info dialog confirms the uninstallation + +## Uninstalling PostgreSQL on Mac + +To uninstall PostgreSQL on a Mac system, assume the identity of an operating system superuser, and navigate into the folder in which the uninstaller resides: + +`/Library/PostgreSQL/13` + +Then, invoke the uninstaller with the command: + +`open uninstall-postgres.app` + +If prompted, provide a password that allows the uninstaller to make changes to your system. The uninstaller will open, asking you if you wish to uninstall the entire application or individual components. + +To remove the entire application, select the `Entire application` option and click `Next` to start uninstalling components. + +To remove individual components, select the `Individual components` option, a selection screen opens allowing you to select which components you wish to uninstall. + +![Remove the entire application or components](images/remove_the_entire_application_or_components.png) + +Fig. 6: Remove the entire application or components + +Select the components you wish to uninstall, and click `Next` to start uninstalling components. + +![Selecting the components to uninstall](images/selecting_the_components_to_uninstall.png) + +Fig. 7: Selecting the components to uninstall + +Progress bars are displayed as each component is removed. When the uninstaller completes, click `OK` to exit the uninstaller. + +![The Uninstallation is completed](images/uninstallationcomplete.png) + +Fig. 8: The Uninstallation is completed diff --git a/advocacy_docs/supported-open-source/postgresql/installer/images/EDB_logo.png b/advocacy_docs/supported-open-source/postgresql/installer/images/EDB_logo.png new file mode 100644 index 00000000000..39a54822d85 Binary files /dev/null and b/advocacy_docs/supported-open-source/postgresql/installer/images/EDB_logo.png differ diff --git a/advocacy_docs/supported-open-source/postgresql/installer/images/Stackbuilder_welcome.png b/advocacy_docs/supported-open-source/postgresql/installer/images/Stackbuilder_welcome.png new file mode 100644 index 00000000000..4f6760b685c Binary files /dev/null and b/advocacy_docs/supported-open-source/postgresql/installer/images/Stackbuilder_welcome.png differ diff --git a/advocacy_docs/supported-open-source/postgresql/installer/images/_static/edb.png b/advocacy_docs/supported-open-source/postgresql/installer/images/_static/edb.png new file mode 100755 index 00000000000..71e5bdde787 Binary files /dev/null and b/advocacy_docs/supported-open-source/postgresql/installer/images/_static/edb.png differ diff --git a/advocacy_docs/supported-open-source/postgresql/installer/images/a_summary_window_displays_a_list_of_selected_packages.png b/advocacy_docs/supported-open-source/postgresql/installer/images/a_summary_window_displays_a_list_of_selected_packages.png new file mode 100755 index 00000000000..c273345a074 Binary files /dev/null and b/advocacy_docs/supported-open-source/postgresql/installer/images/a_summary_window_displays_a_list_of_selected_packages.png differ diff --git a/advocacy_docs/supported-open-source/postgresql/installer/images/aug11_ad.png b/advocacy_docs/supported-open-source/postgresql/installer/images/aug11_ad.png new file mode 100644 index 00000000000..ceb9c812bfd Binary files /dev/null and b/advocacy_docs/supported-open-source/postgresql/installer/images/aug11_ad.png differ diff --git a/advocacy_docs/supported-open-source/postgresql/installer/images/change_program.png b/advocacy_docs/supported-open-source/postgresql/installer/images/change_program.png new file mode 100644 index 00000000000..6785f6ad314 Binary files /dev/null and b/advocacy_docs/supported-open-source/postgresql/installer/images/change_program.png differ diff --git a/advocacy_docs/supported-open-source/postgresql/installer/images/check_the_box_to_add_new_module.png b/advocacy_docs/supported-open-source/postgresql/installer/images/check_the_box_to_add_new_module.png new file mode 100755 index 00000000000..ad87330a234 Binary files /dev/null and b/advocacy_docs/supported-open-source/postgresql/installer/images/check_the_box_to_add_new_module.png differ diff --git a/advocacy_docs/supported-open-source/postgresql/installer/images/checkbox_module.png b/advocacy_docs/supported-open-source/postgresql/installer/images/checkbox_module.png new file mode 100644 index 00000000000..2dd45bb2442 Binary files /dev/null and b/advocacy_docs/supported-open-source/postgresql/installer/images/checkbox_module.png differ diff --git a/advocacy_docs/supported-open-source/postgresql/installer/images/data_directory.png b/advocacy_docs/supported-open-source/postgresql/installer/images/data_directory.png new file mode 100644 index 00000000000..1d021b9e0f9 Binary files /dev/null and b/advocacy_docs/supported-open-source/postgresql/installer/images/data_directory.png differ diff --git a/advocacy_docs/supported-open-source/postgresql/installer/images/download_completes.png b/advocacy_docs/supported-open-source/postgresql/installer/images/download_completes.png new file mode 100644 index 00000000000..7eef261a3ca Binary files /dev/null and b/advocacy_docs/supported-open-source/postgresql/installer/images/download_completes.png differ diff --git a/advocacy_docs/supported-open-source/postgresql/installer/images/download_process_is_complete.png b/advocacy_docs/supported-open-source/postgresql/installer/images/download_process_is_complete.png new file mode 100755 index 00000000000..07a15e3a7f7 Binary files /dev/null and b/advocacy_docs/supported-open-source/postgresql/installer/images/download_process_is_complete.png differ diff --git a/advocacy_docs/supported-open-source/postgresql/installer/images/edb.png b/advocacy_docs/supported-open-source/postgresql/installer/images/edb.png new file mode 100755 index 00000000000..71e5bdde787 Binary files /dev/null and b/advocacy_docs/supported-open-source/postgresql/installer/images/edb.png differ diff --git a/advocacy_docs/supported-open-source/postgresql/installer/images/edb_logo.svg b/advocacy_docs/supported-open-source/postgresql/installer/images/edb_logo.svg new file mode 100644 index 00000000000..f24d1dfefee --- /dev/null +++ b/advocacy_docs/supported-open-source/postgresql/installer/images/edb_logo.svg @@ -0,0 +1,19 @@ + + + edb-logo-disc-dark + + + + \ No newline at end of file diff --git a/advocacy_docs/supported-open-source/postgresql/installer/images/edblogo.png b/advocacy_docs/supported-open-source/postgresql/installer/images/edblogo.png new file mode 100755 index 00000000000..71e5bdde787 Binary files /dev/null and b/advocacy_docs/supported-open-source/postgresql/installer/images/edblogo.png differ diff --git a/advocacy_docs/supported-open-source/postgresql/installer/images/image2.png b/advocacy_docs/supported-open-source/postgresql/installer/images/image2.png new file mode 100755 index 00000000000..4818744bb9d Binary files /dev/null and b/advocacy_docs/supported-open-source/postgresql/installer/images/image2.png differ diff --git a/advocacy_docs/supported-open-source/postgresql/installer/images/installation_complete.png b/advocacy_docs/supported-open-source/postgresql/installer/images/installation_complete.png new file mode 100644 index 00000000000..b037e251883 Binary files /dev/null and b/advocacy_docs/supported-open-source/postgresql/installer/images/installation_complete.png differ diff --git a/advocacy_docs/supported-open-source/postgresql/installer/images/installation_directory.png b/advocacy_docs/supported-open-source/postgresql/installer/images/installation_directory.png new file mode 100644 index 00000000000..da8a4d753b9 Binary files /dev/null and b/advocacy_docs/supported-open-source/postgresql/installer/images/installation_directory.png differ diff --git a/advocacy_docs/supported-open-source/postgresql/installer/images/installing.png b/advocacy_docs/supported-open-source/postgresql/installer/images/installing.png new file mode 100644 index 00000000000..6cab0ac1b1c Binary files /dev/null and b/advocacy_docs/supported-open-source/postgresql/installer/images/installing.png differ diff --git a/advocacy_docs/supported-open-source/postgresql/installer/images/module_selection.png b/advocacy_docs/supported-open-source/postgresql/installer/images/module_selection.png new file mode 100644 index 00000000000..eec567f5c6a Binary files /dev/null and b/advocacy_docs/supported-open-source/postgresql/installer/images/module_selection.png differ diff --git a/advocacy_docs/supported-open-source/postgresql/installer/images/password.png b/advocacy_docs/supported-open-source/postgresql/installer/images/password.png new file mode 100644 index 00000000000..0de022eae4d Binary files /dev/null and b/advocacy_docs/supported-open-source/postgresql/installer/images/password.png differ diff --git a/advocacy_docs/supported-open-source/postgresql/installer/images/port_Aug11.png b/advocacy_docs/supported-open-source/postgresql/installer/images/port_Aug11.png new file mode 100644 index 00000000000..ee01a2cd9c5 Binary files /dev/null and b/advocacy_docs/supported-open-source/postgresql/installer/images/port_Aug11.png differ diff --git a/advocacy_docs/supported-open-source/postgresql/installer/images/preinstallation.png b/advocacy_docs/supported-open-source/postgresql/installer/images/preinstallation.png new file mode 100644 index 00000000000..ac0ac7f5c29 Binary files /dev/null and b/advocacy_docs/supported-open-source/postgresql/installer/images/preinstallation.png differ diff --git a/advocacy_docs/supported-open-source/postgresql/installer/images/ready_to_install.png b/advocacy_docs/supported-open-source/postgresql/installer/images/ready_to_install.png new file mode 100644 index 00000000000..3a536ed2c8e Binary files /dev/null and b/advocacy_docs/supported-open-source/postgresql/installer/images/ready_to_install.png differ diff --git a/advocacy_docs/supported-open-source/postgresql/installer/images/remove_the_entire_application_or_components.png b/advocacy_docs/supported-open-source/postgresql/installer/images/remove_the_entire_application_or_components.png new file mode 100755 index 00000000000..9aa13df20d3 Binary files /dev/null and b/advocacy_docs/supported-open-source/postgresql/installer/images/remove_the_entire_application_or_components.png differ diff --git a/advocacy_docs/supported-open-source/postgresql/installer/images/select_components.png b/advocacy_docs/supported-open-source/postgresql/installer/images/select_components.png new file mode 100644 index 00000000000..7d926c2883c Binary files /dev/null and b/advocacy_docs/supported-open-source/postgresql/installer/images/select_components.png differ diff --git a/advocacy_docs/supported-open-source/postgresql/installer/images/select_the_components_to_uninstall.png b/advocacy_docs/supported-open-source/postgresql/installer/images/select_the_components_to_uninstall.png new file mode 100755 index 00000000000..e3b3ce31a9f Binary files /dev/null and b/advocacy_docs/supported-open-source/postgresql/installer/images/select_the_components_to_uninstall.png differ diff --git a/advocacy_docs/supported-open-source/postgresql/installer/images/selecting_the_components_to_uninstall.png b/advocacy_docs/supported-open-source/postgresql/installer/images/selecting_the_components_to_uninstall.png new file mode 100755 index 00000000000..54e78a418d7 Binary files /dev/null and b/advocacy_docs/supported-open-source/postgresql/installer/images/selecting_the_components_to_uninstall.png differ diff --git a/advocacy_docs/supported-open-source/postgresql/installer/images/stack_builder_welcome.png b/advocacy_docs/supported-open-source/postgresql/installer/images/stack_builder_welcome.png new file mode 100644 index 00000000000..c8650433886 Binary files /dev/null and b/advocacy_docs/supported-open-source/postgresql/installer/images/stack_builder_welcome.png differ diff --git a/advocacy_docs/supported-open-source/postgresql/installer/images/summary_of_selected_packages.png b/advocacy_docs/supported-open-source/postgresql/installer/images/summary_of_selected_packages.png new file mode 100644 index 00000000000..36bc9a4340c Binary files /dev/null and b/advocacy_docs/supported-open-source/postgresql/installer/images/summary_of_selected_packages.png differ diff --git a/advocacy_docs/supported-open-source/postgresql/installer/images/the_Stack_Builder_module_selection_window.png b/advocacy_docs/supported-open-source/postgresql/installer/images/the_Stack_Builder_module_selection_window.png new file mode 100755 index 00000000000..dd1014a8faa Binary files /dev/null and b/advocacy_docs/supported-open-source/postgresql/installer/images/the_Stack_Builder_module_selection_window.png differ diff --git a/advocacy_docs/supported-open-source/postgresql/installer/images/the_advanced_options_dialog.png b/advocacy_docs/supported-open-source/postgresql/installer/images/the_advanced_options_dialog.png new file mode 100755 index 00000000000..e2360245035 Binary files /dev/null and b/advocacy_docs/supported-open-source/postgresql/installer/images/the_advanced_options_dialog.png differ diff --git a/advocacy_docs/supported-open-source/postgresql/installer/images/the_data_directory_dialog.png b/advocacy_docs/supported-open-source/postgresql/installer/images/the_data_directory_dialog.png new file mode 100755 index 00000000000..5b933402419 Binary files /dev/null and b/advocacy_docs/supported-open-source/postgresql/installer/images/the_data_directory_dialog.png differ diff --git a/advocacy_docs/supported-open-source/postgresql/installer/images/the_installation_directory_dialog.png b/advocacy_docs/supported-open-source/postgresql/installer/images/the_installation_directory_dialog.png new file mode 100755 index 00000000000..90fa33415ab Binary files /dev/null and b/advocacy_docs/supported-open-source/postgresql/installer/images/the_installation_directory_dialog.png differ diff --git a/advocacy_docs/supported-open-source/postgresql/installer/images/the_installing_dialog.png b/advocacy_docs/supported-open-source/postgresql/installer/images/the_installing_dialog.png new file mode 100755 index 00000000000..a8215fe2040 Binary files /dev/null and b/advocacy_docs/supported-open-source/postgresql/installer/images/the_installing_dialog.png differ diff --git a/advocacy_docs/supported-open-source/postgresql/installer/images/the_password_dialog.png b/advocacy_docs/supported-open-source/postgresql/installer/images/the_password_dialog.png new file mode 100755 index 00000000000..b602edb622b Binary files /dev/null and b/advocacy_docs/supported-open-source/postgresql/installer/images/the_password_dialog.png differ diff --git a/advocacy_docs/supported-open-source/postgresql/installer/images/the_preinstallation_summary_dialog.png b/advocacy_docs/supported-open-source/postgresql/installer/images/the_preinstallation_summary_dialog.png new file mode 100755 index 00000000000..5365065634e Binary files /dev/null and b/advocacy_docs/supported-open-source/postgresql/installer/images/the_preinstallation_summary_dialog.png differ diff --git a/advocacy_docs/supported-open-source/postgresql/installer/images/the_proxy_servers_dialog.png b/advocacy_docs/supported-open-source/postgresql/installer/images/the_proxy_servers_dialog.png new file mode 100644 index 00000000000..0c7d751d2d4 Binary files /dev/null and b/advocacy_docs/supported-open-source/postgresql/installer/images/the_proxy_servers_dialog.png differ diff --git a/advocacy_docs/supported-open-source/postgresql/installer/images/the_ready_to_install_dialog.png b/advocacy_docs/supported-open-source/postgresql/installer/images/the_ready_to_install_dialog.png new file mode 100755 index 00000000000..e0966deef45 Binary files /dev/null and b/advocacy_docs/supported-open-source/postgresql/installer/images/the_ready_to_install_dialog.png differ diff --git a/advocacy_docs/supported-open-source/postgresql/installer/images/the_select_components_dialog.png b/advocacy_docs/supported-open-source/postgresql/installer/images/the_select_components_dialog.png new file mode 100755 index 00000000000..2a2a480b006 Binary files /dev/null and b/advocacy_docs/supported-open-source/postgresql/installer/images/the_select_components_dialog.png differ diff --git a/advocacy_docs/supported-open-source/postgresql/installer/images/the_stack_builder_welcome_window.png b/advocacy_docs/supported-open-source/postgresql/installer/images/the_stack_builder_welcome_window.png new file mode 100755 index 00000000000..9f944832358 Binary files /dev/null and b/advocacy_docs/supported-open-source/postgresql/installer/images/the_stack_builder_welcome_window.png differ diff --git a/advocacy_docs/supported-open-source/postgresql/installer/images/the_uninstall_or_change_a_program_dialog.png b/advocacy_docs/supported-open-source/postgresql/installer/images/the_uninstall_or_change_a_program_dialog.png new file mode 100755 index 00000000000..bb3c7d902c3 Binary files /dev/null and b/advocacy_docs/supported-open-source/postgresql/installer/images/the_uninstall_or_change_a_program_dialog.png differ diff --git a/advocacy_docs/supported-open-source/postgresql/installer/images/uninstallation_completed.png b/advocacy_docs/supported-open-source/postgresql/installer/images/uninstallation_completed.png new file mode 100755 index 00000000000..da653753b85 Binary files /dev/null and b/advocacy_docs/supported-open-source/postgresql/installer/images/uninstallation_completed.png differ diff --git a/advocacy_docs/supported-open-source/postgresql/installer/images/uninstallation_confirmation.png b/advocacy_docs/supported-open-source/postgresql/installer/images/uninstallation_confirmation.png new file mode 100755 index 00000000000..e629e93dc70 Binary files /dev/null and b/advocacy_docs/supported-open-source/postgresql/installer/images/uninstallation_confirmation.png differ diff --git a/advocacy_docs/supported-open-source/postgresql/installer/images/uninstallationcomplete.png b/advocacy_docs/supported-open-source/postgresql/installer/images/uninstallationcomplete.png new file mode 100644 index 00000000000..90a6951c505 Binary files /dev/null and b/advocacy_docs/supported-open-source/postgresql/installer/images/uninstallationcomplete.png differ diff --git a/advocacy_docs/supported-open-source/postgresql/installer/images/uninstalling_postgreSQL.png b/advocacy_docs/supported-open-source/postgresql/installer/images/uninstalling_postgreSQL.png new file mode 100755 index 00000000000..654956f45d2 Binary files /dev/null and b/advocacy_docs/supported-open-source/postgresql/installer/images/uninstalling_postgreSQL.png differ diff --git a/advocacy_docs/supported-open-source/postgresql/installer/images/uninstalling_postgreSQL_comfirmation.png b/advocacy_docs/supported-open-source/postgresql/installer/images/uninstalling_postgreSQL_comfirmation.png new file mode 100755 index 00000000000..bafe03f9d94 Binary files /dev/null and b/advocacy_docs/supported-open-source/postgresql/installer/images/uninstalling_postgreSQL_comfirmation.png differ diff --git a/advocacy_docs/supported-open-source/postgresql/installer/images/uninstallingpostgres1.png b/advocacy_docs/supported-open-source/postgresql/installer/images/uninstallingpostgres1.png new file mode 100644 index 00000000000..badac839aab Binary files /dev/null and b/advocacy_docs/supported-open-source/postgresql/installer/images/uninstallingpostgres1.png differ diff --git a/advocacy_docs/supported-open-source/postgresql/installer/images/welcome.png b/advocacy_docs/supported-open-source/postgresql/installer/images/welcome.png new file mode 100644 index 00000000000..f1121cb74b3 Binary files /dev/null and b/advocacy_docs/supported-open-source/postgresql/installer/images/welcome.png differ diff --git a/advocacy_docs/supported-open-source/postgresql/installer/index.mdx b/advocacy_docs/supported-open-source/postgresql/installer/index.mdx new file mode 100644 index 00000000000..c7fc835c4eb --- /dev/null +++ b/advocacy_docs/supported-open-source/postgresql/installer/index.mdx @@ -0,0 +1,23 @@ +--- +title: "EDB Installers" +description: "The PostgreSQL installers created by EnterpriseDB are designed to make it quick and simple to install PostgreSQL on your computer." +legacyRedirects: + - "/edb-docs/d/postgresql/installation-getting-started/installation-guide/13.0/index.html" +--- + +The PostgreSQL installers created by EnterpriseDB are designed to make it quick and simple to install PostgreSQL on your computer. The installer provides: + +- A distribution-independent PostgreSQL installation. +- The popular open-source PostgreSQL administration tool, pgAdmin. +- The Stack Builder package manager (used to download and install drivers, tools and applications to complement your PostgreSQL installation). + +The sections that follow provide information about using the PostgreSQL 13.0 installer. It also provides information about: + +- Hardware requirements and software prerequisites before installing PostgreSQL +- Step-by-step instructions explaining the installation options available with the setup wizard +- How to use Stack Builder to install modules that provide enhanced functionality for PostgreSQL 13.0 +- Uninstalling PostgreSQL + +## EDB Language Pack Installer + +The EDB Language Pack Installer can be used with both PostgreSQL installations and Advanced Server installations. [Details are in the documentation](/epas/latest/language_pack/). diff --git a/app.json b/app.json new file mode 100644 index 00000000000..b97b86d85c8 --- /dev/null +++ b/app.json @@ -0,0 +1,37 @@ +{ + "name": "edb_docs", + "env": { + "DOMAIN": { + "required": false + }, + "IS_STAGING": { + "required": true, + "value": false + }, + "HOST": { + "required": true, + "value": "0.0.0.0" + }, + "YARN_PRODUCTION": { + "required": true, + "value": "false" + } + }, + "formation": { + "web": { + "quantity": 1 + } + }, + "addons": [], + "buildpacks": [ + { + "url": "https://github.com/dmathieu/heroku-buildpack-submodules" + }, + { + "url": "heroku/nodejs" + }, + { + "url": "https://github.com/heroku/heroku-buildpack-static" + } + ] +} diff --git a/build-sources.json b/build-sources.json new file mode 100644 index 00000000000..59d7e261d15 --- /dev/null +++ b/build-sources.json @@ -0,0 +1,23 @@ +{ + "ark": false, + "bdr": true, + "bart": true, + "efm": true, + "epas": true, + "eprs": true, + "hadoop_data_adapter": true, + "jdbc_connector": true, + "migration_portal": true, + "migration_toolkit": true, + "mysql_data_adapter": true, + "mongo_data_adapter": true, + "net_connector": true, + "ocl_connector": true, + "odbc_connector": true, + "pem": true, + "pgbouncer": true, + "pgpool": true, + "postgis": true, + "repmgr": true, + "slony": true +} diff --git a/dev-sources.sample b/dev-sources.sample new file mode 100644 index 00000000000..0d0a992d7e2 --- /dev/null +++ b/dev-sources.sample @@ -0,0 +1,21 @@ +{ + "ark": true, + "bart": true, + "efm": true, + "epas": true, + "eprs": true, + "hadoop_data_adapter": true, + "jdbc_connector": true, + "migration_portal": true, + "migration_toolkit": true, + "mongo_data_adapter": true, + "mysql_data_adapter": true, + "net_connector": true, + "ocl_connector": true, + "odbc_connector": true, + "pem": true, + "pgbouncer": true, + "pgpool": true, + "postgis": true, + "slony": true +} diff --git a/docker/docker-compose.build-pdf.yaml b/docker/docker-compose.build-pdf.yaml new file mode 100644 index 00000000000..99f7040d3c6 --- /dev/null +++ b/docker/docker-compose.build-pdf.yaml @@ -0,0 +1,13 @@ +version: '3.8' + +services: + pdf-builder: + build: + context: ../ + dockerfile: docker/images/Dockerfile.pdf-builder + image: edb/x-docs-pdf-builder + container_name: pdf-builder + hostname: pdf-builder + working_dir: /app + volumes: + - ../:/app diff --git a/docker/images/Dockerfile.pdf-builder b/docker/images/Dockerfile.pdf-builder new file mode 100644 index 00000000000..2153b725871 --- /dev/null +++ b/docker/images/Dockerfile.pdf-builder @@ -0,0 +1,27 @@ +FROM ubuntu:focal + +ARG PANDOC_VERSION=2.12 +ARG PANDOC_DEB=pandoc-2.12-1-amd64.deb +ARG WKHTML_TO_PDF_VERSION=0.12.6-1 +ARG WKHTML_TO_PDF_DEB=wkhtmltox_${WKHTML_TO_PDF_VERSION}.focal_amd64.deb + +RUN apt-get update && apt-get install --no-install-recommends -y \ + python3 \ + wget \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +# Install Pandoc +RUN wget --no-check-certificate -P /tmp https://github.com/jgm/pandoc/releases/download/${PANDOC_VERSION}/${PANDOC_DEB} \ + && apt-get install --no-install-recommends -y /tmp/${PANDOC_DEB} \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* \ + && rm -rf /tmp/* + +# Install wkhtmltopdf +RUN wget --no-check-certificate -P /tmp https://github.com/wkhtmltopdf/packaging/releases/download/${WKHTML_TO_PDF_VERSION}/${WKHTML_TO_PDF_DEB} \ + && apt-get update \ + && apt-get install --no-install-recommends -y /tmp/${WKHTML_TO_PDF_DEB} \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* \ + && rm -rf /tmp/* diff --git a/docs/agreements/branch-and-release.md b/docs/agreements/branch-and-release.md new file mode 100644 index 00000000000..16f29234ec7 --- /dev/null +++ b/docs/agreements/branch-and-release.md @@ -0,0 +1,169 @@ +# Docs Repository Branch and Release Strategies + +- [Evergreen Branches](#evergreen-branches) + - [main](#main) + - [develop](#develop) +- [Release Process](#release-process) + - [Preparation](#preparation) + - [Release](#release) +- [Branching Strategies](#branching-strategies) + - [Short-lived](#short-lived) + - [Long-lived](#long-lived) +- [Pull Request Strategies](#pull-request-strategies) + - [Normal PR](#normal-pr) + - [Draft PR](#draft-pr) +- [Use Cases](#use-cases) + - [Hot Fix](#hot-fix) + - [Bug Fix](#bug-fix) + - [Feature](#feature) + - [Add Documentation for Currently Released Product (Or Product + Version)](#add-documentation-for-currently-released-product-or-product-version) + - [Future Release Documentation](#future-release-documentation) + +## Evergreen Branches + +### main + +The `main` branch tracks what's currently deployed at +. + +### develop + +For the most part, `develop` tracks the next release of the `docs` repo. +`develop` is deployed automatically at +. + +The `develop` branch should always be in a deployable state. + +## Release Process + +### Preparation + +1. Make a release branch from `develop`: `release/${today's date}`. E.g. + `release/2021-02-09`. +1. Create a pull request ("PR") to merge the release branch into `main`. +1. Smoke test the release branch and make adjustments as needed. Ideally you + shouldn't need to make any new commits to the release branch. + +### Release + +1. Merge the release PR. +1. Ensure the release is successful. +1. Delete the release branch. +1. Tag `main` with the release date: e.g. `2021-02-09`. + + If there are multiple releases per day, suffix with letters. For example, + the second release of the day would be `2021-02-09-a`, third release would + be `2021-02-09-b`, and so on. + +1. Merge `main` into `develop`. + +## Branching Strategies + +Example: Create a `bug/epas/fix-typo` branch from `develop` ("base"). + +See [Use Cases](#use-cases) for when to use which strategy. + +### Short-lived + +Ideally, most branches are short-lived from creation to merging into its base +branch. This minimizes potential conflicts and typically allows the branch to +be merged without any fuss. + +### Long-lived + +In the case of long-lived branches (e.g. future product release branches), it's +up to the person responsible for the branch to keep it up to date with its base +branch. There are couple ways to periodically keep your branch up-to-date (once +a day, or less frequently if the base branch is stable): + +- Rebase your branch onto the base branch (preferred). +- Merge the base branch into your branch. + +This will ensure that conflicts and surprises are resolved as early in the +branch lifecycle as possible. + +## Pull Request Strategies + +Each branch that's intended to be deployed at some point needs to be associated +with a PR. If there's a ticket associated with the PR, provide a link to the +ticket at the top of the PR description. + +See [Use Cases](#use-cases) for when to use which strategy. + +### Normal PR + +A normal PR is one that's ready to be reviewed and merged to the base branch. +It requires at least one approval in order to be merged. + +Once a PR is approved, anyone can merge it to the base branch. + +### Draft PR + +A [draft PR][pr-draft] is _not_ ready to be merged to the base branch. However, +it may still be a good idea to solicit work-in-progress reviews. + +1. [Convert a PR to draft state][draft state]. +1. Once the PR is ready, [remove the "Draft" status and convert it to a normal + PR][review state]. + +## Use Cases + +### Hot Fix + +Stop the presses, something is seriously wrong with +. + +- **Base branch**: `main` +- **Branching strategy**: [short-lived][] +- **Branch name**: `hotfix/${my-name}/${issue#}-${short-description}`. +- **PR strategy**: [normal pr][] + +#### Steps + +1. Create a hot fix branch from `main`. +1. Create a PR to merge into `main`. +1. Review, QA, and approve PR. +1. [Follow the release portion](#release) of the release process, using the hot + fix branch as the release branch. + +### Bug Fix + +- **Base branch**: `develop` +- **Branching strategy**: [short-lived][] +- **Branch name**: `bugfix/${my-name}/${issue#}-${short-description}`. +- **PR strategy**: [normal pr][] + +### Feature + +- **Base branch**: `develop` +- **Branching strategy**: [short-lived][] or [long-lived][] +- **Branch name**: `feature/${my-name}/${issue#}-${short-description}`. +- **PR strategy**: [normal pr][] or [draft pr][] + +### Add Documentation for Currently Released Product (Or Product Version) + +- **Base branch**: `develop` +- **Branching strategy**: [short-lived][] or [long-lived][] +- **Branch name**: + `docs/${product-name}/${issue#}-${version-number-or-short-description}`. +- **PR strategy**: [normal pr][] or [draft pr][] + +### Future Release Documentation + +- **Base branch**: `develop` +- **Branching strategy**: [long-lived][] +- **Branch name**: + `future/${product-name}/${issue#}-${version-number-or-short-description}`. +- **PR strategy**: [draft pr][] + +ℹ️ At the top of your PR description, please note when the expected release date +is and keep it up-to-date as the release date changes. + +[draft pr]: #draft-pr +[draft state]: https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/changing-the-stage-of-a-pull-request#converting-a-pull-request-to-a-draft +[long-lived]: #long-lived +[normal pr]: #normal-pr +[pr-draft]: https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests#draft-pull-requests +[review state]: https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/changing-the-stage-of-a-pull-request#marking-a-pull-request-as-ready-for-review +[short-lived]: #short-lived diff --git a/docs/how-tos/sync-cnp-docs.md b/docs/how-tos/sync-cnp-docs.md new file mode 100644 index 00000000000..8bb0f00aea5 --- /dev/null +++ b/docs/how-tos/sync-cnp-docs.md @@ -0,0 +1,22 @@ +# Sync Cloud-Native-PostgreSQL Docs + +Currently we need to manually sync over [cloud-native-postgresql][cnp]("CNP") +docs whenever there's a new release. The long term goal is to automate this via +GitHub action dispatch and automated event handling. + +1. The CNP team informs us that there's a new version. +1. Check out the appropriate version from the [CNP][] repo. +1. Replace `docs:temp_kubernetes/docs/` with `cloud-native-postgresql:docs/`. + + `temp_kubernetes/docs/` is not tracked via Git, so if it's not present + already, you'll need to create the directory yourself. +1. Transpile original source documentation into MDX format: + + ```sh + python scripts/source/source_cloud_native_operator.py + ``` + +1. Replace `advocacy_docs/kubernetes/cloud-native-postgresql/` with + `temp_kubernetes/build/`. + +[cnp]: https://github.com/EnterpriseDB/cloud-native-postgresql diff --git a/docs/overviews/legacy-redirects/README.md b/docs/overviews/legacy-redirects/README.md new file mode 100644 index 00000000000..5d0bd399c0f --- /dev/null +++ b/docs/overviews/legacy-redirects/README.md @@ -0,0 +1,36 @@ +# Legacy Redirects Overview + +"Legacy redirects" are the redirects set up from the Docs 1.0 site (/edb-docs), to the Docs 2.0 site (/docs). While our system handles creating the redirect mapping, the actual redirects ultimately get served by the nginx server that hosts Docs 1.0. + +Our legacy redirects system consists of three different pieces. + +## The Spider + +Within `scripts/legacy_redirects`, we have a Scrapy project. Scrapy is a python program for creating web scrapers, spiders, etc. Our Scrapy project is called `legacy`, and only consists of a single spider. This will spider the legacy Docs 1.0 website, and extract url, title, path, and some navigation data. + +Since we have already launched some legacy redirects, and new content shouldn't be going up to the Docs 1.0 site, I don't expect we'll need to scrape the site again. But if we need to add more data to the scraped output to support older docs (more on that later), we might need to modify the spider, and scrape the site again. + +To run the spider, you need to install Scrapy. With Scrapy installed, from within the `scripts/legacy_redirects/scrapy_spider/legacy` directory, run `scrapy crawl legacy_docs -o output.json`. This will boot up the spider and start dumping JSON output into `output.json`. + +If you want to use this new output for redirects, you need to move it to `scripts/legacy_redirects/legacy_docs_scrape.json`. + +## `add_legacy_redirects.py` + +This script looks at `legacy_docs_scrape.json` and the files in the `product_docs` directory, and attempts to write a list of redirects into `legacyRedirectsGenerated` frontmatter for each document. To help do this work, it will also use the `legacy_redirects_metadata.json` file to help map legacy urls to folders in `product_docs`. + +When you run this script, the `legacyRedirectsGenerated` frontmatter for every file will be recalculated. Any manual legacy redirects you want to add should be added under `legacyRedirects`, which are untouched by this script. + +### Url Style ("new" vs "old") +Currently, the script only handles "new" style urls. I have done some initial work on mapping "old" style urls (which are used for older product version), but they are trickier. + +Example of a "new" style url (EPAS 13) - `/edb-docs/d/edb-postgres-advanced-server/user-guides/ecpgplus-guide/13/using_embedded_sql.html` + +Example of an "old" style url (EPAS 12) - `/edb-docs/d/edb-postgres-advanced-server/installation-getting-started/installation-guide-for-linux/12/EDB_Postgres_Advanced_Server_Installation_Guide_Linux.1.07.html#pID0E0KN0HA` + +The biggest difference is most urls in the "old" style do not contain the name of the file in the url, making them much more challenging to map. My initial work uses headers to attempt to make matches. + +## `yarn build-legacy-redirects-nginx` + +The final piece is actually generating the nginx configuration to handle these redirects. This is done with the `yarn build-legacy-redirects-nginx` script. All this is doing is a clean build of the site, then running `scripts/legacy_redirects/clean_up_output.py` to remove non-legacy redirects from the output file. The file generation is handled by the `gatsby-plugin-nginx-redirect` plugin, which you can see in `gatsby-config.js`. + +Once this process completes, the new nginx configuration file should be at `static/nginx_redirects.generated`. This file should be inspected, and then handed to Mark Yeatman on the IT team to add to the server configuration. diff --git a/docs/overviews/search/README.md b/docs/overviews/search/README.md new file mode 100644 index 00000000000..bc4cca02ed9 --- /dev/null +++ b/docs/overviews/search/README.md @@ -0,0 +1,60 @@ +# Algolia Search Overview + +This document is a straightforward overview of our search implementation, along with some examples of how I test new search changes. + +## How Search is Integrated + +### Indexing + +The indexing of the docs site happens as the final step in the gatsby build process, and is managed by the `gatsby-plugin-algolia` plugin. This plugin is listed near the bottom of `gatsby-config.js`. The way the plugin works is pretty straightforward - you hand it a GraphQL query (`indexQuery`) and a transformation function, and it will completely rebuild your search index at the end of each gatsby build (if indexing is turned on). + +Most of the magic happens in the tranformation function, which is in `constants/algolia-indexing.js`. Essentially the process is as follows... + +1. Turn the graphql data into a tree data structure, in order to calculate the inherited frontmatter. +1. Compute the list of "latest" product versions, which is used to determine which page path to give to Algolia. +1. Create the list of algolia search nodes. For each mdx node... + 1. Create an initial search node (`mdxNodeToAlgoliaNode`). This is where most attributes of the search node are set (product, version, paths, etc). + 1. Process the MDX abstract syntax tree in order to create a list of natural excerpts. We aim to create a separate search node for each "section" of the document, broken up by headers. + 1. For each "section", clone the search node, and add the appropriate excerpt to it. +1. Return the final list of search nodes. This will become the new search index. + +Each time we index, the old index data is completely replaced by the new index data. + +### Client-Side (Actually searching) + +The actual search queries are handled by the `algoliasearch` and `react-instantsearch-dom` packages. See the [react-instantsearch docs](https://www.algolia.com/doc/api-reference/widgets/instantsearch/react/) for more info on this client side library. + +We have three separate search experiences - the quick search (`components/search`), the advanced search (`pages/search.js`), and the 404 page search (`pages/404.js`). The components for each are mostly separated, and each search experience is a little bit different. + +## Making Changes to the Search Index + +### Using the Test Index Locally + +There is an algolia index setup specificially for testing index changes called `edb-docs-test`. If you want to use this index locally, you can set the environment variable `ALGOLIA_INDEX_NAME` to `edb-docs-test`. I strongly recommend testing any index changes locally using this index. + +The `edb-docs-test.netlify.app` environment also uses this index. This environment can be handy to show others the changes you've made. + +To enable indexing locally, set `INDEX_ON_BUILD=true` when you run `yarn build`. + +### Example: Add a New Field + +Say for example we have a new frontmatter field `downloadable`, and we want to have that be a filterable attribute in advanced search. To add this data to the search nodes we need to... + +1. Update the `indexQuery` in `gatsby-config.js` to pull in `downloadable` as part of the frontmatter. +1. Update `mdxNodeToAlgoliaNode` in `algolia-indexing.js` to set `newNode.downloadble` to this value. + +...and that should give Algolia the data it needs. To have Algolia make `downloadable` facetable, we need to update the "Attributes for faceting" in the "Facets" section of the index settings in the Algolia UI. + +Once this is done, we then need to update the advanced search page to display the facet. I won't get too into the details, but you would want to update `components/advanced-search/filtering.js` to show a refinement component that controls the facet. We have a custom component called `RadioRefinement` for our existing facets, but if a new component is needed, it can be created using the appropriate [react-instantsearch's connector API](https://www.algolia.com/doc/api-reference/widgets/refinement-list/react/#connector). + +### Configuring Algolia + +Lots of options can be configured in Algolia to influence the search behavior. Here are the options we've changed from defaults at the time of writing... + +- **Searchable attributes:** Choose which attributes are searched, and the order that they're prioritized/considered in. +- **Facets:** Set which attributes are filterable. This powers the filters for the advanced search page. +- **Snippeting:** Creates the excerpt snippet that is displayed in search results. +- **Deduplication:** We're dedupping all search results by `pagePath`. +- **Advanced Syntax:** This enables search queries to use quotes for exact matching, and `-` to exclude terms. + +I expect in the future we will want to tune the results more using the settings under **Relevance Essentials/Optimizations**. diff --git a/gatsby-browser.js b/gatsby-browser.js new file mode 100644 index 00000000000..5112622f858 --- /dev/null +++ b/gatsby-browser.js @@ -0,0 +1,30 @@ +require('prismjs/themes/prism-okaidia.css'); + +exports.onRouteUpdate = ({ location }) => scrollToAnchor(location); + +/** + * + * @desc - a function to jump to the correct scroll position + * @param {Object} location - + * @param {Number} [mainNavHeight] - the height of any persistent nav -> document.querySelector(`nav`) + */ +function scrollToAnchor(location, mainNavHeight = 0) { + // Check for location so build does not fail + if (location && location.hash) { + try { + const item = document.querySelector(`${location.hash}`); + + if (item) { + window.scrollTo({ + top: item.offsetTop - mainNavHeight, + behavior: 'smooth', + }); + } + } catch (error) { + // if hash is bad exception will be raised + console.error(error); + } + } + + return true; +} diff --git a/gatsby-config.js b/gatsby-config.js new file mode 100644 index 00000000000..b3245b1838b --- /dev/null +++ b/gatsby-config.js @@ -0,0 +1,292 @@ +require('dotenv').config({ + path: `.env.${process.env.NODE_ENV}`, +}); +const gracefulFs = require('graceful-fs'); + +const algoliaTransformer = require('./src/constants/algolia-indexing.js'); + +const ANSI_BLUE = '\033[34m'; +const ANSI_GREEN = '\033[32m'; +const ANSI_STOP = '\033[0m'; + +const isBuild = process.env.NODE_ENV === 'production'; +const isProduction = process.env.APP_ENV === 'production'; +const algoliaIndex = process.env.ALGOLIA_INDEX_NAME || 'edb-docs-staging'; + +/******** Sourcing *********/ +const sourceFilename = isBuild ? 'build-sources.json' : 'dev-sources.json'; +const sourceToPluginConfig = { + ark: { name: 'ark', path: 'product_docs/docs/ark' }, + bart: { name: 'bart', path: 'product_docs/docs/bart' }, + bdr: { name: 'bdr', path: 'product_docs/docs/bdr' }, + efm: { name: 'efm', path: 'product_docs/docs/efm' }, + epas: { name: 'epas', path: 'product_docs/docs/epas' }, + eprs: { name: 'eprs', path: 'product_docs/docs/eprs' }, + hadoop_data_adapter: { + name: 'hadoop_data_adapter', + path: 'product_docs/docs/hadoop_data_adapter', + }, + jdbc_connector: { + name: 'jdbc_connector', + path: 'product_docs/docs/jdbc_connector', + }, + migration_portal: { + name: 'migration_portal', + path: 'product_docs/docs/migration_portal', + }, + migration_toolkit: { + name: 'migration_toolkit', + path: 'product_docs/docs/migration_toolkit', + }, + mysql_data_adapter: { + name: 'mysql_data_adapter', + path: 'product_docs/docs/mysql_data_adapter', + }, + mongo_data_adapter: { + name: 'mongo_data_adapter', + path: 'product_docs/docs/mongo_data_adapter', + }, + net_connector: { + name: 'net_connector', + path: 'product_docs/docs/net_connector', + }, + ocl_connector: { + name: 'ocl_connector', + path: 'product_docs/docs/ocl_connector', + }, + odbc_connector: { + name: 'odbc_connector', + path: 'product_docs/docs/odbc_connector', + }, + pem: { name: 'pem', path: 'product_docs/docs/pem' }, + pgbouncer: { name: 'pgbouncer', path: 'product_docs/docs/pgbouncer' }, + pgpool: { name: 'pgpool', path: 'product_docs/docs/pgpool' }, + postgis: { name: 'postgis', path: 'product_docs/docs/postgis' }, + repmgr: { name: 'repmgr', path: 'product_docs/docs/repmgr' }, + slony: { name: 'slony', path: 'product_docs/docs/slony' }, +}; + +const externalSourcePlugins = () => { + const sourcePlugins = []; + + if (!process.env.SKIP_SOURCING) { + // default to full set of sources + let sources = Object.keys(sourceToPluginConfig).reduce((result, source) => { + result[source] = true; + return result; + }, {}); + + if (gracefulFs.existsSync(sourceFilename)) { + console.log( + `${ANSI_BLUE}###### Sourcing from ${sourceFilename} #######${ANSI_STOP}`, + ); + console.log( + `${ANSI_GREEN}Note: ${sourceFilename} is no longer required; delete it to load the full set of docs.${ANSI_STOP}`, + ); + sources = JSON.parse(gracefulFs.readFileSync(sourceFilename)); + } + + for (const [source, enabled] of Object.entries(sources)) { + const config = sourceToPluginConfig[source]; + if (enabled && config) { + sourcePlugins.push({ + resolve: 'gatsby-source-filesystem', + options: { + name: config.name, + path: config.path, + }, + }); + } + } + } + + return sourcePlugins; +}; + +/******** Algolia Index ********/ +const indexQuery = ` +{ + allMdx { + nodes { + frontmatter { + title + product + platform + tags + directoryDefaults { + product + platform + } + } + id + fields { + docType + product + path + version + } + mdxAST + } + } +} +`; + +/********** Gatsby config *********/ +module.exports = { + pathPrefix: '/docs', + siteMetadata: { + title: 'EDB Docs', + baseUrl: 'https://enterprisedb.com/docs', + imageUrl: 'https://enterprisedb.com/docs/images/social.jpg', + siteUrl: 'https://enterprisedb.com/docs', + algoliaIndex: algoliaIndex, + isDevelopment: !isBuild, + cacheBuster: 2, // for busting gh actions cache if needed + }, + plugins: [ + 'gatsby-plugin-sass', + 'gatsby-plugin-react-helmet', + 'gatsby-transformer-sharp', + 'gatsby-transformer-json', + 'gatsby-plugin-catch-links', + 'gatsby-plugin-sharp', + { + resolve: 'gatsby-plugin-netlify', + options: { + headers: { + '/*': isProduction ? [] : ['X-Robots-Tag: noindex'], + }, + }, + }, + 'gatsby-plugin-sitemap', + { + resolve: `gatsby-plugin-manifest`, + options: { + name: 'EDB Documentation', + short_name: 'EDB Docs', + start_url: '/', + background_color: '#EBEFF2', + theme_color: '#EBEFF2', + // Enables "Add to Homescreen" prompt and disables browser UI (including back button) + // see https://developers.google.com/web/fundamentals/web-app-manifest/#display + display: 'standalone', + icon: 'static/images/favicon.png', // This path is relative to the root of the site. + // An optional attribute which provides support for CORS check. + // If you do not provide a crossOrigin option, it will skip CORS for manifest. + // Any invalid keyword or empty string defaults to `anonymous` + crossOrigin: `use-credentials`, + }, + }, + { + resolve: 'gatsby-source-filesystem', + options: { + name: 'advocacy_docs', + path: 'advocacy_docs', + }, + }, + { + resolve: 'gatsby-source-filesystem', + options: { + name: 'images', + path: 'static/images', + }, + }, + ...externalSourcePlugins(), + { + resolve: 'gatsby-plugin-mdx', + options: { + defaultLayouts: { + default: require.resolve('./src/components/layout.js'), + }, + lessBabel: true, + gatsbyRemarkPlugins: [ + { + resolve: 'gatsby-remark-images', + options: { + linkImagesToOriginal: false, + showCaptions: false, + }, + }, + { + resolve: `gatsby-remark-autolink-headers`, + options: { + isIconAfterHeader: true, + className: 'ml-1', + }, + }, + { + resolve: 'gatsby-remark-prismjs', + options: { + noInlineHighlight: true, + }, + }, + ], + remarkPlugins: [ + [require('./src/plugins/code-in-tables')], + [ + require('remark-admonitions'), + { + tag: '!!!', + icons: 'none', + infima: true, + customTypes: { + seealso: 'note', + hint: 'tip', + interactive: 'interactive', + }, + }, + ], + ], + }, + }, + { + resolve: 'gatsby-plugin-react-svg', + options: { + rule: { + include: /static/, + }, + }, + }, + { + resolve: `gatsby-plugin-google-fonts`, + options: { + fonts: [ + `source code pro\:400`, // you can also specify font weights and styles + ], + }, + }, + { + resolve: 'gatsby-plugin-google-tagmanager', + options: { + id: process.env.GTM_ID, + }, + }, + { + resolve: 'gatsby-plugin-nginx-redirect', + options: { + inputConfigFile: `${__dirname}/static/nginx_redirects.template`, + outputConfigFile: `${__dirname}/static/nginx_redirects.generated`, + whereToIncludeRedirects: '', // defaults to: "server" + }, + }, + { + // This plugin must be placed last in your list of plugins to ensure that it can query all the GraphQL data + resolve: `gatsby-plugin-algolia`, + options: { + appId: process.env.ALGOLIA_APP_ID, + apiKey: process.env.ALGOLIA_API_KEY, + indexName: algoliaIndex, + queries: [ + { + query: indexQuery, + transformer: algoliaTransformer, + indexName: algoliaIndex, + }, + ], + chunkSize: 1000, + enablePartialUpdates: false, + skipIndexing: process.env.INDEX_ON_BUILD !== 'true', + }, + }, + ], +}; diff --git a/gatsby-node.js b/gatsby-node.js new file mode 100644 index 00000000000..a769df86bb0 --- /dev/null +++ b/gatsby-node.js @@ -0,0 +1,452 @@ +// this patch is required to consistently load all the doc files +const realFs = require('fs'); +const gracefulFs = require('graceful-fs'); +gracefulFs.gracefulify(realFs); + +const { createFilePath } = require(`gatsby-source-filesystem`); +const { exec, execSync } = require('child_process'); + +const { + replacePathVersion, + filePathToDocType, + removeTrailingSlash, + isPathAnIndexPage, + pathToDepth, + mdxNodesToTree, + computeFrontmatterForTreeNode, + buildProductVersions, + reportMissingIndex, + treeToNavigation, + treeNodeToNavNode, + findPrevNextNavNodes, + configureRedirects, + configureLegacyRedirects, + readFile, + writeFile, +} = require('./src/constants/gatsby-utils.js'); + +const isBuild = process.env.NODE_ENV === 'production'; +const isProduction = process.env.APP_ENV === 'production'; + +exports.onCreateNode = async ({ node, getNode, actions, loadNodeContent }) => { + const { createNodeField } = actions; + + if (node.internal.mediaType === 'text/yaml') loadNodeContent(node); + if (node.internal.type !== 'Mdx') return; + + const fileNode = getNode(node.parent); + const nodeFields = { + docType: filePathToDocType(node.fileAbsolutePath), + mtime: fileNode.mtime, + }; + + let relativeFilePath = createFilePath({ node, getNode }); + if (nodeFields.docType === 'doc') { + relativeFilePath = `/${fileNode.sourceInstanceName}${relativeFilePath}`; + } + + Object.assign(nodeFields, { + path: relativeFilePath, + depth: pathToDepth(relativeFilePath), + }); + + if (nodeFields.docType === 'doc') { + Object.assign(nodeFields, { + product: relativeFilePath.split('/')[1], + version: relativeFilePath.split('/')[2], + topic: 'null', + }); + } else if (nodeFields.docType === 'advocacy') { + Object.assign(nodeFields, { + product: 'null', + version: '0', + topic: relativeFilePath.split('/')[2], + }); + } + + for (const [name, value] of Object.entries(nodeFields)) { + createNodeField({ node, name: name, value: value }); + } +}; + +exports.createPages = async ({ actions, graphql, reporter }) => { + const result = await graphql(` + query { + allMdx { + nodes { + id + frontmatter { + title + navTitle + description + redirects + iconName + originalFilePath + productStub + indexCards + navigation + legacyRedirects + legacyRedirectsGenerated + navigation + showInteractiveBadge + katacodaPages { + scenario + account + } + katacodaPanel { + scenario + account + initializeCommand + codelanguages + } + directoryDefaults { + description + prevNext + iconName + product + platform + } + } + fields { + docType + path + depth + product + version + topic + } + fileAbsolutePath + } + } + allFile(filter: { extension: { eq: "yaml" } }) { + nodes { + id + relativePath + } + } + } + `); + + if (result.errors) { + reporter.panic('createPages graphql query has errors!', result.errors); + } + + processFileNodes(result.data.allFile.nodes, actions); + + const { nodes } = result.data.allMdx; + + const productVersions = buildProductVersions(nodes); + + // it should be possible to remove these in the future, + // they are only used for navLinks generation + const learn = nodes.filter((file) => file.fields.docType === 'advocacy'); + + // perform depth first preorder traversal + const treeRoot = mdxNodesToTree(nodes); + const navStack = [treeRoot]; + let curr = null; + + while (navStack.length > 0) { + curr = navStack.pop(); + curr.children.forEach((child) => navStack.push(child)); + + // build ordered navigation for immediate children + // treeToNavigation will use this data + const addedChildPaths = {}; + curr.navigationNodes = []; + (curr.mdxNode?.frontmatter?.navigation || []).forEach((navEntry) => { + if (navEntry.startsWith('#')) { + curr.navigationNodes.push({ + path: null, + title: navEntry.replace('#', '').trim(), + }); + return; + } + + const navChild = curr.children.find((child) => { + if (addedChildPaths[child.path]) return false; + const navName = child.path.split('/').slice(-2)[0]; + return navName.toLowerCase() === navEntry.toLowerCase(); + }); + if (!navChild?.mdxNode) return; + + addedChildPaths[navChild.path] = true; + curr.navigationNodes.push(treeNodeToNavNode(navChild)); + }); + + curr.children + .filter((child) => !addedChildPaths[child.path]) + .map((child) => treeNodeToNavNode(child)) + .sort((a, b) => a.path.localeCompare(b.path)) + .forEach((child) => curr.navigationNodes.push(child)); + + // exit here if we're not dealing with an actual page + if (!curr.mdxNode) { + reportMissingIndex(reporter, curr); + continue; + } + + const node = curr.mdxNode; + + // set computed frontmatter + node.frontmatter = computeFrontmatterForTreeNode(curr); + + configureRedirects(node.fields.path, node.frontmatter.redirects, actions); + + // build navigation tree + const navigationDepth = 2; + let navRoot = curr; + while (navRoot.depth > navigationDepth) navRoot = navRoot.parent; + const navTree = treeToNavigation(navRoot, node); + + // determine next and previous nodes + const prevNext = findPrevNextNavNodes(navTree, curr); + + const { docType } = node.fields; + if (docType === 'doc') { + createDoc(navTree, prevNext, node, productVersions, actions); + } else if (docType === 'advocacy') { + createAdvocacy(navTree, prevNext, node, learn, actions); + } + } +}; + +const createDoc = (navTree, prevNext, doc, productVersions, actions) => { + const isLatest = + productVersions[doc.fields.product][0] === doc.fields.version; + if (isLatest) { + actions.createRedirect({ + fromPath: doc.fields.path, + toPath: replacePathVersion(doc.fields.path), + redirectInBrowser: true, + isPermanent: false, + force: true, + }); + } + + // configure legacy redirects + if (!doc.frontmatter.productStub) { + configureLegacyRedirects({ + toPath: doc.fields.path, + toLatestPath: replacePathVersion(doc.fields.path), + redirects: (doc.frontmatter.legacyRedirects || []).concat( + doc.frontmatter.legacyRedirectsGenerated || [], + ), + actions, + }); + } + + const isIndexPage = isPathAnIndexPage(doc.fileAbsolutePath); + const docsRepoUrl = 'https://github.com/EnterpriseDB/docs'; + const branch = isProduction ? 'main' : 'develop'; + const fileUrlSegment = + removeTrailingSlash(doc.fields.path) + + (isIndexPage ? '/index.mdx' : '.mdx'); + const githubFileLink = `${docsRepoUrl}/commits/${branch}/product_docs/docs${fileUrlSegment}`; + const githubEditLink = `${docsRepoUrl}/edit/${branch}/product_docs/docs${fileUrlSegment}`; + const githubIssuesLink = `${docsRepoUrl}/issues/new?title=Feedback%20on%20${encodeURIComponent( + fileUrlSegment, + )}`; + + const template = doc.frontmatter.productStub ? 'doc-stub.js' : 'doc.js'; + const path = isLatest ? replacePathVersion(doc.fields.path) : doc.fields.path; + + // workaround for https://github.com/gatsbyjs/gatsby/issues/26520 + actions.createPage({ + path: path, + component: require.resolve(`./src/templates/${template}`), + context: {}, + }); + + actions.createPage({ + path: path, + component: require.resolve(`./src/templates/${template}`), + context: { + frontmatter: doc.frontmatter, + pagePath: path, + navTree, + prevNext, + versions: productVersions[doc.fields.product], + nodeId: doc.id, + githubFileLink: githubFileLink, + githubEditLink: githubEditLink, + githubIssuesLink: githubIssuesLink, + isIndexPage: isIndexPage, + potentialLatestPath: replacePathVersion(doc.fields.path), // the latest url for this path (may not exist!) + potentialLatestNodePath: replacePathVersion( + doc.fields.path, + productVersions[doc.fields.product][0], + ), // the latest version number path (may not exist!), needed for query + }, + }); +}; + +const createAdvocacy = (navTree, prevNext, doc, learn, actions) => { + // configure legacy redirects + configureLegacyRedirects({ + toPath: doc.fields.path, + toLatestPath: doc.fields.path, + redirects: (doc.frontmatter.legacyRedirects || []).concat( + doc.frontmatter.legacyRedirectsGenerated || [], + ), + actions, + }); + + const navLinks = learn.filter( + (node) => node.fields.topic === doc.fields.topic, + ); + + const advocacyDocsRepoUrl = 'https://github.com/EnterpriseDB/docs'; + const branch = isProduction ? 'main' : 'develop'; + const isIndexPage = isPathAnIndexPage(doc.fileAbsolutePath); + const fileUrlSegment = + removeTrailingSlash(doc.fields.path) + + (isIndexPage ? '/index.mdx' : '.mdx'); + const githubFileLink = `${advocacyDocsRepoUrl}/commits/${branch}/advocacy_docs${fileUrlSegment}`; + const githubEditLink = `${advocacyDocsRepoUrl}/edit/${branch}/advocacy_docs${fileUrlSegment}`; + const githubIssuesLink = `${advocacyDocsRepoUrl}/issues/new?title=Regarding%20${encodeURIComponent( + fileUrlSegment, + )}`; + + // workaround for https://github.com/gatsbyjs/gatsby/issues/26520 + actions.createPage({ + path: doc.fields.path, + component: require.resolve('./src/templates/learn-doc.js'), + context: {}, + }); + + actions.createPage({ + path: doc.fields.path, + component: require.resolve('./src/templates/learn-doc.js'), + context: { + nodeId: doc.id, + frontmatter: doc.frontmatter, + pagePath: doc.fields.path, + navLinks: navLinks, + prevNext, + navTree, + githubFileLink: githubFileLink, + githubEditLink: githubEditLink, + githubIssuesLink: githubIssuesLink, + isIndexPage: isIndexPage, + }, + }); + + (doc.frontmatter.katacodaPages || []).forEach((katacodaPage) => { + if (!katacodaPage.scenario || !katacodaPage.account) { + throw new Error( + `katacoda scenario or account missing for ${doc.fields.path}`, + ); + } + + const path = `${doc.fields.path}${katacodaPage.scenario}`; + actions.createPage({ + path: path, + component: require.resolve('./src/templates/katacoda-page.js'), + context: { + ...katacodaPage, + pagePath: path, + learn: { + title: doc.frontmatter.title, + description: doc.frontmatter.description, + }, + }, + }); + }); +}; + +const processFileNodes = (fileNodes, actions) => { + fileNodes.forEach((node) => { + actions.createPage({ + path: node.relativePath, + component: require.resolve('./src/templates/file.js'), + context: { + nodeId: node.id, + }, + }); + }); +}; + +exports.sourceNodes = async ({ + actions: { createNode }, + createNodeId, + createContentDigest, +}) => { + // create edb-git node + const sha = ( + await new Promise((resolve, reject) => { + exec('git rev-parse HEAD', (error, stdout, stderr) => resolve(stdout)); + }) + ).trim(); + + const branch = ( + await new Promise((resolve, reject) => { + exec('git branch --show-current', (error, stdout, stderr) => + resolve(stdout), + ); + }) + ).trim(); + + const gitData = { sha, branch }; + createNode({ + ...gitData, + id: createNodeId('edb-git'), + internal: { + type: 'edbGit', + contentDigest: createContentDigest(gitData), + }, + }); +}; + +exports.createSchemaCustomization = ({ actions }) => { + const { createTypes } = actions; + const typeDefs = ` + type Mdx implements Node { + frontmatter: Frontmatter + } + + type Frontmatter { + originalFilePath: String + indexCards: TileModes + legacyRedirects: [String] + legacyRedirectsGenerated: [String] + showInteractiveBadge: Boolean + } + + enum TileModes { + none + simple + full + } + `; + createTypes(typeDefs); +}; + +exports.onPreBootstrap = () => { + console.log(` + _____ ____ _____ ____ +| __|| \\ | __ | | \\ ___ ___ ___ +| __|| | || __ -| | | || . || _||_ -| +|_____||____/ |_____| |____/ |___||___||___| + + `); +}; + +exports.onPostBuild = async ({ reporter, pathPrefix }) => { + const originalRedirects = await readFile('public/_redirects'); + + // filter out legacyRedirects that are loaded via nginx, not netlify + let filteredRedirects = originalRedirects + .split('\n') + .filter((line) => !line.startsWith(`${pathPrefix}/edb-docs/`)) + .join('\n'); + + if (filteredRedirects.length === originalRedirects.length) { + reporter.warn('no redirects were filtered out, did something change?'); + } + + await writeFile( + 'public/_redirects', + `${filteredRedirects}\n\n# Netlify pathPrefix path rewrite\n${pathPrefix}/* /:splat 200`, + ); +}; diff --git a/gatsby-ssr.js b/gatsby-ssr.js new file mode 100644 index 00000000000..e0331b20c2a --- /dev/null +++ b/gatsby-ssr.js @@ -0,0 +1,18 @@ +const React = require('react'); + +exports.onRenderBody = ({ setPreBodyComponents }) => { + setPreBodyComponents( + React.createElement('script', { + key: 'injectedDarkModeScript', + dangerouslySetInnerHTML: { + __html: ` + const storedDark = window.localStorage.getItem('dark'); + const inferredDark = window.matchMedia('(prefers-color-scheme: dark)').matches; + if (storedDark === 'true' || (storedDark === null && inferredDark)) { + document.documentElement.classList.add('dark'); + } + `, + }, + }), + ); +}; diff --git a/merge_sources/README.md b/merge_sources/README.md new file mode 100644 index 00000000000..9a21227e172 --- /dev/null +++ b/merge_sources/README.md @@ -0,0 +1,3 @@ +# Purpose + +This subtree contains content intended to be merged with external sources during import / postprocessing. See scripts/source/* for usage. diff --git a/merge_sources/kubernetes/cloud_native_postgresql/interactive_demo.mdx b/merge_sources/kubernetes/cloud_native_postgresql/interactive_demo.mdx new file mode 100644 index 00000000000..1256c5d2db7 --- /dev/null +++ b/merge_sources/kubernetes/cloud_native_postgresql/interactive_demo.mdx @@ -0,0 +1,343 @@ +--- +title: "Installation, Configuration and Deployment Demo" +description: "Walk through the process of installing, configuring and deploying the Cloud Native PostgreSQL Operator via a browser-hosted Minikube console" +navTitle: Install, Configure, Deploy +product: 'Cloud Native PostgreSQL Operator' +platform: ubuntu +tags: + - postgresql + - cloud-native-postgresql-operator + - kubernetes + - minikube + - live-demo +katacodaPanel: + scenario: minikube + codelanguages: shell, yaml +showInteractiveBadge: true +--- + +Want to see what it takes to get the Cloud Native PostgreSQL Operator up and running? This section will demonstrate the following: + +1. Installing the Cloud Native PostgreSQL Operator +2. Deploying a three-node PostgreSQL cluster +3. Installing and using the kubectl-cnp plugin +4. Testing failover to verify the resilience of the cluster + +It will take roughly 5-10 minutes to work through. + +!!!interactive This demo is interactive + You can follow along right in your browser by clicking the button below. Once the environment initializes, you'll see a terminal open at the bottom of the screen. + + + +[Minikube](https://kubernetes.io/docs/setup/learning-environment/minikube/) is already installed in this environment; we just need to start the cluster: + +```shell +minikube start +__OUTPUT__ +* minikube v1.8.1 on Ubuntu 18.04 +* Using the none driver based on user configuration +* Running on localhost (CPUs=2, Memory=2460MB, Disk=145651MB) ... +* OS release is Ubuntu 18.04.4 LTS +* Preparing Kubernetes v1.17.3 on Docker 19.03.6 ... + - kubelet.resolv-conf=/run/systemd/resolve/resolv.conf +* Launching Kubernetes ... +* Enabling addons: default-storageclass, storage-provisioner +* Configuring local host environment ... +* Waiting for cluster to come online ... +* Done! kubectl is now configured to use "minikube" +``` + +This will create the Kubernetes cluster, and you will be ready to use it. +Verify that it works with the following command: + +```shell +kubectl get nodes +__OUTPUT__ +NAME STATUS ROLES AGE VERSION +minikube Ready master 66s v1.17.3 +``` + +You will see one node called `minikube`. If the status isn't yet "Ready", wait for a few seconds and run the command above again. + +## Install Cloud Native PostgreSQL + +Now that the Minikube cluster is running, you can proceed with Cloud Native PostgreSQL installation as described in the ["Installation"](installation.md) section: + +```shell +kubectl apply -f https://get.enterprisedb.io/cnp/postgresql-operator-1.3.0.yaml +__OUTPUT__ +namespace/postgresql-operator-system created +customresourcedefinition.apiextensions.k8s.io/backups.postgresql.k8s.enterprisedb.io created +customresourcedefinition.apiextensions.k8s.io/clusters.postgresql.k8s.enterprisedb.io created +customresourcedefinition.apiextensions.k8s.io/scheduledbackups.postgresql.k8s.enterprisedb.io created +mutatingwebhookconfiguration.admissionregistration.k8s.io/postgresql-operator-mutating-webhook-configuration created +serviceaccount/postgresql-operator-manager created +clusterrole.rbac.authorization.k8s.io/postgresql-operator-manager created +clusterrolebinding.rbac.authorization.k8s.io/postgresql-operator-manager-rolebinding created +service/postgresql-operator-webhook-service created +deployment.apps/postgresql-operator-controller-manager created +validatingwebhookconfiguration.admissionregistration.k8s.io/postgresql-operator-validating-webhook-configuration created +``` + +And then verify that it was successfully installed: + +```shell +kubectl get deploy -n postgresql-operator-system postgresql-operator-controller-manager +__OUTPUT__ +NAME READY UP-TO-DATE AVAILABLE AGE +postgresql-operator-controller-manager 1/1 1 1 52s +``` + +## Deploy a PostgreSQL cluster + +As with any other deployment in Kubernetes, to deploy a PostgreSQL cluster +you need to apply a configuration file that defines your desired `Cluster`. + +The [`cluster-example.yaml`](../samples/cluster-example.yaml) sample file +defines a simple `Cluster` using the default storage class to allocate +disk space: + +```yaml +cat < cluster-example.yaml +# Example of PostgreSQL cluster +apiVersion: postgresql.k8s.enterprisedb.io/v1 +kind: Cluster +metadata: + name: cluster-example +spec: + instances: 3 + + # Example of rolling update strategy: + # - unsupervised: automated update of the primary once all + # replicas have been upgraded (default) + # - supervised: requires manual supervision to perform + # the switchover of the primary + primaryUpdateStrategy: unsupervised + + # Require 1Gi of space + storage: + size: 1Gi +EOF +``` + +!!! Note "There's more" + For more detailed information about the available options, please refer + to the ["API Reference" section](api_reference.md). + +In order to create the 3-node PostgreSQL cluster, you need to run the following command: + +```shell +kubectl apply -f cluster-example.yaml +__OUTPUT__ +cluster.postgresql.k8s.enterprisedb.io/cluster-example created +``` + +You can check that the pods are being created with the `get pods` command. It'll take a bit to initialize, so if you run that +immediately after applying the cluster configuration you'll see the status as `Init:` or `PodInitializing`: + +```shell +kubectl get pods +__OUTPUT__ +NAME READY STATUS RESTARTS AGE +cluster-example-1-initdb-kq2vw 0/1 PodInitializing 0 18s +``` + +...give it a minute, and then check on it again: + +```shell +kubectl get pods +__OUTPUT__ +NAME READY STATUS RESTARTS AGE +cluster-example-1 1/1 Running 0 56s +cluster-example-2 1/1 Running 0 35s +cluster-example-3 1/1 Running 0 19s +``` + +Now we can check the status of the cluster: + +```shell +kubectl get cluster cluster-example -o yaml +__OUTPUT__ +apiVersion: postgresql.k8s.enterprisedb.io/v1 +kind: Cluster +metadata: + annotations: + kubectl.kubernetes.io/last-applied-configuration: | + {"apiVersion":"postgresql.k8s.enterprisedb.io/v1","kind":"Cluster","metadata":{"annotations":{},"name":"cluster-example","namespace":"default"},"spec":{"instances":3,"primaryUpdateStrategy":"unsupervised","storage":{"size":"1Gi"}}} + creationTimestamp: "2021-04-27T15:11:21Z" + generation: 1 + name: cluster-example + namespace: default + resourceVersion: "2572" + selfLink: /apis/postgresql.k8s.enterprisedb.io/v1/namespaces/default/clusters/cluster-example + uid: 6a693046-a9d0-41b0-ac68-7a96d7e2ff07 +spec: + affinity: + topologyKey: "" + bootstrap: + initdb: + database: app + owner: app + imageName: quay.io/enterprisedb/postgresql:13.2 + instances: 3 + postgresql: + parameters: + logging_collector: "off" + max_parallel_workers: "32" + max_replication_slots: "32" + max_worker_processes: "32" + wal_keep_size: 512MB + primaryUpdateStrategy: unsupervised + resources: {} + storage: + size: 1Gi +status: + currentPrimary: cluster-example-1 + instances: 3 + instancesStatus: + healthy: + - cluster-example-1 + - cluster-example-2 + - cluster-example-3 + latestGeneratedNode: 3 + licenseStatus: + isImplicit: true + isTrial: true + licenseExpiration: "2021-05-27T15:11:21Z" + licenseStatus: Implicit trial license + repositoryAccess: false + valid: true + phase: Cluster in healthy state + pvcCount: 3 + readService: cluster-example-r + readyInstances: 3 + secretsResourceVersion: + applicationSecretVersion: "1479" + caSecretVersion: "1475" + replicationSecretVersion: "1477" + serverSecretVersion: "1476" + superuserSecretVersion: "1478" + targetPrimary: cluster-example-1 + writeService: cluster-example-rw +``` + +!!! Note + By default, the operator will install the latest available minor version + of the latest major version of PostgreSQL when the operator was released. + You can override this by setting [the `imageName` key in the `spec` section of + the `Cluster` definition](api_reference/#clusterspec). + +!!! Important + The immutable infrastructure paradigm requires that you always + point to a specific version of the container image. + Never use tags like `latest` or `13` in a production environment + as it might lead to unpredictable scenarios in terms of update + policies and version consistency in the cluster. + +## Install the kubectl-cnp plugin + +Cloud Native PostgreSQL provides a plugin for kubectl to manage a cluster in Kubernetes, along with a script to install it: + +```shell +curl -sSfL \ + https://github.com/EnterpriseDB/kubectl-cnp/raw/main/install.sh | \ + sudo sh -s -- -b /usr/local/bin +__OUTPUT__ +EnterpriseDB/kubectl-cnp info checking GitHub for latest tag +EnterpriseDB/kubectl-cnp info found version: 1.3.0 for v1.3.0/linux/x86_64 +EnterpriseDB/kubectl-cnp info installed /usr/local/bin/kubectl-cnp +``` + +The `cnp` command is now available in kubectl: + +```shell +kubectl cnp status cluster-example +__OUTPUT__ +Cluster in healthy state +Name: cluster-example +Namespace: default +PostgreSQL Image: quay.io/enterprisedb/postgresql:13.2 +Primary instance: cluster-example-1 +Instances: 3 +Ready instances: 3 + +Instances status +Pod name Current LSN Received LSN Replay LSN System ID Primary Replicating Replay paused Pending restart Status +-------- ----------- ------------ ---------- --------- ------- ----------- ------------- --------------- ------ +cluster-example-1 0/5000060 6955855494195015697 ✓ ✗ ✗ ✗ OK +cluster-example-2 0/5000060 0/5000060 6955855494195015697 ✗ ✓ ✗ ✗ OK +cluster-example-3 0/5000060 0/5000060 6955855494195015697 ✗ ✓ ✗ ✗ OK +``` + +!!! Note "There's more" + See [the Cloud Native PostgreSQL Plugin page](cnp-plugin/) for more commands and options. + +## Testing failover + +As our status checks show, we're running two replicas - if something happens to the primary instance of PostgreSQL, the cluster will fail over to one of them. Let's demonstrate this by killing the primary pod: + +```shell +kubectl delete pod --wait=false cluster-example-1 +__OUTPUT__ +pod "cluster-example-1" deleted +``` + +This simulates a hard shutdown of the server - a scenario where something has gone wrong. + +Now if we check the status... +```shell +kubectl cnp status cluster-example +__OUTPUT__ +Failing over Failing over to cluster-example-2 +Name: cluster-example +Namespace: default +PostgreSQL Image: quay.io/enterprisedb/postgresql:13.2 +Primary instance: cluster-example-2 +Instances: 3 +Ready instances: 2 + +Instances status +Pod name Current LSN Received LSN Replay LSN System ID Primary Replicating Replay paused Pending restart Status +-------- ----------- ------------ ---------- --------- ------- ----------- ------------- --------------- ------ +cluster-example-1 - - - - - - - - unable to upgrade connection: container not found ("postgres") - +cluster-example-2 0/7000230 6955855494195015697 ✓ ✗ ✗ ✗ OK +cluster-example-3 0/70000A0 0/70000A0 6955855494195015697 ✗ ✓ ✗ ✗ OK +``` + +...the failover process has begun, with the second pod promoted to primary. Once the failed pod has restarted, it will become a replica of the new primary: + +```shell +kubectl cnp status cluster-example +__OUTPUT__ +Cluster in healthy state +Name: cluster-example +Namespace: default +PostgreSQL Image: quay.io/enterprisedb/postgresql:13.2 +Primary instance: cluster-example-2 +Instances: 3 +Ready instances: 3 + +Instances status +Pod name Current LSN Received LSN Replay LSN System ID Primary Replicating Replay paused Pending restart Status +-------- ----------- ------------ ---------- --------- ------- ----------- ------------- --------------- ------ +cluster-example-1 0/7004268 0/7004268 6955855494195015697 ✗ ✓ ✗ ✗ OK +cluster-example-2 0/7004268 6955855494195015697 ✓ ✗ ✗ ✗ OK +cluster-example-3 0/7004268 0/7004268 6955855494195015697 ✗ ✓ ✗ ✗ OK +``` + + +### Further reading + +This is all it takes to get a PostgreSQL cluster up and running, but of course there's a lot more possible - and certainly much more that is prudent before you should ever deploy in a production environment! + +- Deploying on public cloud platforms: see the [Cloud Setup](cloud_setup/) section. + +- Design goals and possibilities offered by the Cloud Native PostgreSQL Operator: check out the [Architecture](architecture/) and [Use cases](use_cases/) sections. + +- Configuring a secure and reliable system: read through the [Security](security/), [Failure Modes](failure_modes/) and [Backup and Recovery](backup_recovery/) sections. + +- Webinar: [Watch Gabriele Bartolini discuss and demonstrate Cloud Native PostgreSQL lifecycle management](https://www.youtube.com/watch?v=S-I9y-HnAnI) + +- Development: [Leonardo Cecchi writes about setting up a local environment using Cloud Native PostgreSQL for application development](https://www.enterprisedb.com/blog/cloud-native-postgresql-application-developers) + diff --git a/package.json b/package.json new file mode 100644 index 00000000000..f374662a139 --- /dev/null +++ b/package.json @@ -0,0 +1,94 @@ +{ + "name": "docs", + "private": true, + "description": "EDB Docs", + "version": "0.1.0", + "license": "Apache-2.0", + "engines": { + "node": "14.x" + }, + "scripts": { + "clean": "gatsby clean", + "clean-develop": "gatsby clean && gatsby develop", + "develop": "gatsby develop", + "config-sources": "python3 scripts/source/config_sources.py", + "format": "prettier --write src/**/*.js gatsby-*.js", + "build": "gatsby build --prefix-paths", + "serve-build": "gatsby serve --prefix-paths", + "prepare": "husky install", + "update-icons": "git submodule update --init --remote && node scripts/createIconTypes.js && node scripts/createIconNames.js", + "build-pdf": "docker-compose -f docker/docker-compose.build-pdf.yaml run --rm --entrypoint scripts/pdf/generate_pdf.py pdf-builder", + "build-all-pdfs": "for i in product_docs/docs/**/*/ ; do echo \"$i\"; yarn build-pdf ${i%} || exit 1; done", + "build-all-pdfs-ci": "for i in product_docs/docs/**/*/ ; do echo \"$i\"; python3 scripts/pdf/generate_pdf.py ${i%} || exit 1; done", + "fix-mtimes": "python3 scripts/source/git-restore-mtime.py", + "count": "find product_docs/docs/ advocacy_docs/ external_sources/ -name '*.mdx' | wc -l", + "heroku-postbuild": "gatsby build", + "build-legacy-redirects-nginx": "gatsby clean && gatsby build --prefix-paths && python3 scripts/legacy_redirects/clean_up_output.py" + }, + "dependencies": { + "@mdx-js/mdx": "^1.6.1", + "@mdx-js/react": "^1.6.1", + "algoliasearch": "^4.2.0", + "balance-text": "^3.3.0", + "bl": "5.0.0", + "bootstrap": "4.6.0", + "gatsby": "^3.2.1", + "gatsby-cli": "^3.2.0", + "gatsby-plugin-algolia": "^0.18.0", + "gatsby-plugin-catch-links": "^3.2.0", + "gatsby-plugin-google-fonts": "^1.0.1", + "gatsby-plugin-google-tagmanager": "^3.2.0", + "gatsby-plugin-manifest": "^3.2.0", + "gatsby-plugin-mdx": "^2.2.0", + "gatsby-plugin-meta-redirect": "^1.1.1", + "gatsby-plugin-netlify": "^3.2.0", + "gatsby-plugin-nginx-redirect": "^0.0.11", + "gatsby-plugin-react-helmet": "^4.2.0", + "gatsby-plugin-react-svg": "^3.0.0", + "gatsby-plugin-sass": "^4.2.0", + "gatsby-plugin-sharp": "^3.2.0", + "gatsby-plugin-sitemap": "^3.2.0", + "gatsby-remark-autolink-headers": "^3.2.0", + "gatsby-remark-images": "4.2.0", + "gatsby-remark-prismjs": "^4.2.0", + "gatsby-source-filesystem": "^3.2.0", + "gatsby-transformer-json": "^3.2.0", + "gatsby-transformer-remark": "^3.2.0", + "gatsby-transformer-sharp": "^3.2.0", + "graceful-fs": "^4.2.4", + "is-absolute-url": "^3.0.3", + "markdown-to-jsx": "^7.0.0", + "prismjs": "^1.21.0", + "react": "^17.0.2", + "react-bootstrap": "^1.0.1", + "react-dom": "^17.0.2", + "react-helmet": "^6.0.0", + "react-instantsearch-dom": "^6.9.0", + "remark-admonitions": "https://github.com/josh-heyer/remark-admonitions", + "sass": "^1.32.5", + "truncate-utf8-bytes": "^1.0.2" + }, + "devDependencies": { + "fast-glob": "^3.2.5", + "hast-util-is-element": "^1.1.0", + "hast-util-to-text": "^2.0.1", + "husky": "^6.0.0", + "prettier": "^2.2.1", + "pretty-quick": "^3.1.0", + "react-refresh": "^0.10.0", + "rehype-format": "^3.1.0", + "rehype-parse": "^7.0.1", + "rehype-remark": "^8.0.0", + "rehype-stringify": "^8.0.0", + "remark-frontmatter": "^2.0.0", + "remark-mdx": "^1.6.22", + "remark-stringify": "^8.1.1", + "semver-compare": "^1.0.0", + "to-vfile": "^6.1.0", + "typescript": "^4.1.3" + }, + "repository": { + "type": "git", + "url": "https://github.com/EnterpriseDB/docs" + } +} diff --git a/product_docs/content/.keep b/product_docs/content/.keep new file mode 100644 index 00000000000..e69de29bb2d diff --git a/product_docs/content_build/.keep b/product_docs/content_build/.keep new file mode 100644 index 00000000000..e69de29bb2d diff --git a/product_docs/convert.sh b/product_docs/convert.sh new file mode 100755 index 00000000000..1e9d951e14e --- /dev/null +++ b/product_docs/convert.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +for i in content/**/*.rst ; do python3 scripts/pre_pandoc_script.py ${i%}; echo \"$i\" && pandoc --wrap=none $i -f rst -t gfm --atx-headers -o ${i%.*}.mdx ; done ; python3 scripts/post_pandoc_script.py diff --git a/product_docs/docs/ark/3.5/ark_admin/01_ark_whats_new.mdx b/product_docs/docs/ark/3.5/ark_admin/01_ark_whats_new.mdx new file mode 100644 index 00000000000..edf629ecf72 --- /dev/null +++ b/product_docs/docs/ark/3.5/ark_admin/01_ark_whats_new.mdx @@ -0,0 +1,39 @@ +--- +title: "What's New" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-ark-platform/user-guides/administrative-users-guide/3.5/ark_whats_new.html" +--- + + + +The following features have been added to the EDB Ark user console for this release. + +- Ark now supports EDB Postgres Advanced Server and PostgreSQL version 12 database clusters. +- You can use the `Promote` option (located on a cluster's context menu in the `Details` panel) to replace the master node with a standby node. For more information, see the EDB Postgres Ark Getting Started Guide. +- The `/templates` and `/templates/id` resources now support the `region` property. + +## Limitations + +**Cloning, Recovering, or Scaling Encrypted Clusters from Previous Versions** + +Encrypted clusters created with Ark 3.3 or prior may not be used to clone, recover, or scale to a machine type that is not supported by that earlier version. If you will be moving encrypted clusters created with Ark version 3.3 or prior to a new machine type (as supported by Ark 3.4), you will need to: + +1. Clone the encrypted cluster to a new, unencrypted cluster. +2. Upgrade the Ark console on which the cluster resides to Ark 3.4. +3. Clone the unencrypted cluster to a new encrypted cluster of the new machine type. + +For detailed information about cloning a cluster, see the *EDB Postgres Ark Getting Started Guide*. + +**Cloning with a Template from a Foreign Region** + +You cannot use a template when cloning from a foreign region. + +**Monitoring a Federated Console with PEM** + +Ark does not support federated consoles configured in local PEM server mode. + +**Federating Consoles that host clusters with the Same Name** + +If you are upgrading to version 3.4, and plan to federate existing Ark version 3.3 consoles that host clusters with the same name, you must first create a clone of one of the clusters specifying an alternate name; federated consoles cannot be used to host clusters with the same name. For example, if you plan to federate two consoles that both contain a cluster named `acctg`, you should clone one of the clusters specifying an alternate name for the cluster (i.e. `acctg-west`). Then, you can federate the consoles; both consoles will have access to `acctg` and `acctg-west`. diff --git a/product_docs/docs/ark/3.5/ark_admin/02_ark_supported_platforms.mdx b/product_docs/docs/ark/3.5/ark_admin/02_ark_supported_platforms.mdx new file mode 100644 index 00000000000..c4f02431d48 --- /dev/null +++ b/product_docs/docs/ark/3.5/ark_admin/02_ark_supported_platforms.mdx @@ -0,0 +1,23 @@ +--- +title: "Supported Platforms" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-ark-platform/user-guides/administrative-users-guide/3.5/ark_supported_platforms.html" +--- + + + +The EDB Ark management console runs on the following browser versions (or newer): + +- Mozilla Firefox 18 +- Mozilla Firefox 17 ESR, 24 ESR, 31 ESR +- Internet Explorer 8 +- Safari 6 +- Opera 16 +- Google Chrome 23 + +EDB Ark provisions cluster instances on the following 64-bit Linux systems: + +- RHEL 7.x +- CentOS 7.x diff --git a/product_docs/docs/ark/3.5/ark_admin/03_ark_architecture_overview.mdx b/product_docs/docs/ark/3.5/ark_admin/03_ark_architecture_overview.mdx new file mode 100644 index 00000000000..6fc1878cdea --- /dev/null +++ b/product_docs/docs/ark/3.5/ark_admin/03_ark_architecture_overview.mdx @@ -0,0 +1,60 @@ +--- +title: "Ark Architecture Overview" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-ark-platform/user-guides/administrative-users-guide/3.5/ark_architecture_overview.html" +--- + + + +The Ark console and API are designed to help you easily create and manage high-availability database clusters. + +!!! Note + Traditionally, the expression *cluster* refers to a single instance of Postgres managing multiple databases; an EDB Ark database server cluster is a collection of high-availability Postgres server instances that reside in a cloud or on a traditional network. + +When you create a new cluster (a group of replicated database servers), EDB Ark initializes one or more Postgres instances (virtual machines) according to your specifications. EDB Ark uses Postgres streaming replication to synchronize replicas in the cluster, and pgpool-II to implement load balancing and connection pooling among all active instances. + +![EDB Postgres Ark Architecture](images/ark_architecture_overview.png) + +The master node of the cluster contains a host operating system with a running instance of Postgres, along with the load balancer. Database modifications are automatically routed to the master node; any modifications to the master node are subsequently propagated to each replica using Postgres streaming replication. + +EDB Ark installs Postgres on each replica node in a read-only hot-standby role that automatically duplicates all data found on the master node, and all changes made to that data. In hot-standby mode, the data is available to service user queries providing read scalability to the cluster. In addition, any schema changes made to the master are also replicated to the replica nodes, making development and deployment of application changes easy and seamless without interruption to normal operations. + +![EDB Postgres Ark Architecture](images/ark_architecture_load_balancing.png) + +Replicas provide balanced user support as needed - if any instance in the cluster goes offline, the cluster's load is re-balanced among the remaining servers while the instance is automatically replaced. + +When used in the default healing configuration, in the event of a failure of the master node, an existing replica is used to replace the failed master node. While the replica nodes are standing by, they are read-only resources, load balancing client queries without a risk of compromising data integrity. + +EDB Ark automatically archives data at regular intervals; you can specify a convenient backup window and how many backups to retain when creating a database cluster. EDB Ark also offers backup on demand - simply click the Backup icon to save a copy of the instance. Automatic backups are retained according to your specifications; while on-demand backups are retained until you delete them. Each backup is a complete copy of the cluster; you can use a backup to restore a cluster. + +EDB Ark makes it easy to scale a database cluster: + +- To increase read performance, you can add read replicas to the cluster (manually or automatically). +- To handle expanding data requirements you can increase the amount of storage available (manually or automatically). +- To increase the RAM or CPU processing power of the cluster's underlying virtual machine, you can manually scale a cluster into a more appropriate server class. + +## Using Ark on an AWS Virtual Private Cloud + +EDB Ark can create and manage clusters that reside on Amazon-hosted virtual private clouds (VPCs). A VPC is similar in structure to a traditional network, but provides the scalability and ease of maintenance offered by cloud computing. + +A VPC is an isolated network with a unique IP address range and subnet addresses. When deploying a cluster, you can use the Ark console to select the VPC on which the new cluster will reside, or choose to have Ark create a new VPC. + +![EDB Postgres Ark Architecture](images/ark_architecture_overview_create_new_cluster.png) + +To create a new cluster that resides on a private subnet, log into the Ark console and click the `Launch DB Cluster` button. Use the `Create a new Server Cluster` dialog to provide details about the cluster configuration. Check the box to the left of `Use Private IP addresses` to display only those VPCs which have a NAT gateway configured to support private subnets in the VPC field. Then, use the `VPC` drop-down menu to select a VPC. + +After completing the `Step 1` tab, use the `Next` key to continue. Provide information in the fields on each additional tab before selecting the `Launch` button and deploying your cluster into your private subnet. For detailed information about the additional options available when defining a cluster, please see the EDB Ark Getting Started Guide, available via the Ark console dashboard. + +Please note: if you use private IP addresses, the master instance is not assigned an elastic IP address. Should a failover occur, the IP address of the master instance will change. + +### Using a NAT Gateway + +You can deploy the Ark console on a VPC, and use a [network address translation (NAT)](https://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/vpc-nat-gateway.html) gateway to provide access to services outside of the VPC. The NAT gateway allows an instance without a public IP address to securely access services and resources such as yum repositories. + +When the Ark console is deployed in a private subnet (or without a public IP address), the console can only communicate with private networks in its own VPC or peered VPCs. Clusters are restricted to deploying into VPCs that have a peering connection to the VPC in which the console is deployed, and the console's VPC. + +A [peering connection](https://docs.aws.amazon.com/AmazonVPC/latest/PeeringGuide/Welcome.html) allows you to route traffic between two virtual private clouds without exposing the clouds to outside connections. + +Please note: when the Ark console is deployed in a private subnet, the `Use Private IP addresses` option is always `true`. diff --git a/product_docs/docs/ark/3.5/ark_admin/04_ark_registering_with_pem.mdx b/product_docs/docs/ark/3.5/ark_admin/04_ark_registering_with_pem.mdx new file mode 100644 index 00000000000..5c395011ebb --- /dev/null +++ b/product_docs/docs/ark/3.5/ark_admin/04_ark_registering_with_pem.mdx @@ -0,0 +1,222 @@ +--- +title: "Registering an Ark Cluster with PEM" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-ark-platform/user-guides/administrative-users-guide/3.5/ark_registering_with_pem.html" +--- + + + +Postgres Enterprise Manager (PEM) is an enterprise management tool designed to assist database administrators, system architects, and performance analysts in administering, monitoring, and tuning PostgreSQL and EnterpriseDB Advanced Server database servers. PEM can manage and monitor a handful of servers or hundreds of servers from a single console, allowing complete control over all aspects of your databases. + +A PEM installation consists of a PEM server, one or more PEM agents, and the backing database server (named `pem`). The PEM server includes a web interface that allows you to monitor and manage the database instances that are registered with a PEM agent. A PEM agent is responsible for returning metric information to the PEM server, and performing tasks on the database instances that are registered with that agent. + +The Ark console installation includes a pre-configured PEM server, a PEM agent, and the pem backing database. You also have the option of using a remote PEM server to monitor your Ark console. A remote server is a PEM server that has been installed and configured on another host. + +![*Specifying Deployment Details*](images/ark_registering_with_pem.png) + +Fig. 4.1: Specifying Deployment Details + +During deployment, you will be prompted to use the `PEM Server Mode` drop-down listbox to select a deployment mode: + +- Select `DISABLE` to indicate that clusters deployed on the host should not be registered with the PEM server. +- Select `LOCAL` to indicate that you would like to use the PEM server that resides on your local host. If you select LOCAL, the PEM deployment will use default values assigned by the installer. + - The IP address of the PEM server host will be the IP address of the Ark host. + - The PEM Server DB Port will monitor port `5432`. + - The PEM server database user will be named `postgres`. + - The password associated with the PEM server will be the same password as the Ark console. +- Select `REMOTE` to indicate that you would like to use a PEM server that resides on another host, and provide connection information on the Ark console deployment dialog. + - Provide the IP address of the PEM server host in the `PEM Server IP Address` field. + - Specify the port monitored for connections by the PEM server in the `PEM Server DB Port` field. + - Specify the port monitored for API connections in the `PEM Server API Port` field. + - Provide the name that should be used when authenticating with the PEM server in the `PEM Server Username` field. + - Provide the password associated with the PEM server user in the `PEM Server Password` field. + +If you select `REMOTE`, whenever a new cluster node is created on this console, it will be registered for monitoring by the PEM server. Please note that you must modify the [pg_hba.conf](https://www.postgresql.org/docs/10/static/auth-pg-hba-conf.html) file of the pem database on the remote PEM server to accept connections from the host of the Ark console. + +## Syncing with the PEM Server + +When you register with PEM during console deployment, the *PEM Sync Mode* field will be enabled. Use the drop-down listbox in the PEM Sync Mode field to specify your preference for synchronizing with the PEM server. + +If you select `DISABLED`: + +- Any object that Ark registers with PEM will be owned by the PEM user specified in the PEM Server *Username* field (if the PEM server is a REMOTE server), or by `postgres` (if the PEM server resides on the host of the LOCAL Ark server). +- Any Ark user that registers with a console instance will not be added as a PEM user. + +If you select `ENABLED`: + +- Any Amazon Role or Azure Group that is accessible by the Ark user that is deploying the console is added to the PEM server as a group role. The PEM role created for the project, role, or group is not a login role. To simplify management, each role that represents a project, role, or group is also a member of the PEM `ark-team` group role. + +![*The PEM Group Role dialog*](images/ark_registering_with_pem_group_role_dialog.png) + +Fig. 4.2: The PEM Group Role dialog + +- Each user that registers with a monitored Ark instance is also created as a PEM login user. The user account will be displayed in the `Login/Group Roles` node of the PEM client tree control. To access the properties dialog for the user, right click on the user name, and select `Properties` from the context menu. + + Each PEM user account that corresponds with a registered Ark user will belong to the `ark-user` role. The PEM user account will also have membership in any `ark-team` roles that have been created to correspond to the project, role, or groups that the Ark user has permission to access. + +![*The PEM Login Role dialog*](images/ark_registering_with_pem_login_role_dialog.png) + +Fig. 4.3: The PEM Login Role dialog + +The PEM user account is not password enabled. To set a password for the account, an administrative user must navigate to the PEM role's `Definition` tab, and provide a password in the `Password` field. + +If you use the Ark console to delete an Ark user, the synchronization service will disable the corresponding user on the PEM server. The service will ensure that membership in ark-user is revoked, and the role will no longer be a `LOGIN` role. Please note that the sync service will only modify those roles that are a member of the ark-user team. + +The sync service will also ensure that the corresponding pem-team role is deleted if a tenant, group, or role is deleted on an Ark host. + +![*Registering as a login role*](images/ark_registering_with_pem_login_role_dialog_password.png) + +Fig. 4.4: Registering as a login role + +Ark will sync with PEM on the schedule specified by the `PEM Synchronization Interval` field. The field accepts interval values in minutes; by default, Ark will attempt to syncronize every 10 minutes. + + + +## Monitoring an Ark Cluster + +After deployment, you can access the PEM web interface in your choice of browser: + +- If the PEM server resides on a local host, navigate to: `https:///pem` +- If the PEM server resides on a remote host, navigate to: `https://:/pem` + +When prompted, provide the PEM credentials to connect. + +![*Logging on to the PEM Server*](images/ark_registering_with_pem_logon.png) + +Fig. 4.5: Logging on to the PEM Server + +If you have registered the Ark console with a remote PEM server during deployment, use the PEM server credentials to connect. + +If you have deployed the PEM server locally (on the Ark host), the password associated with the Ark backing database will be used for the PEM server. Unless you have modified the password (either during deployment in the DB User New Password field, or after deployment in the console backing database), the Ark database superuser has the following connection credentials at deployment: + +name: `postgres` + +password: `0f42d1934a1a19f3d25d6288f2a3272c6143fc5d` + +You should [change the password](10_ark_console_management/#ark_console_management) after deployment to a unique password (known only to trusted users). + +After authenticating with the server, the PEM web interface allows you to manage your monitored nodes. + +![*The PEM Global Overview*](images/ark_registering_with_pem_global_overview.png) + +Fig. 4.6: The PEM Global Overview + +When you launch an Ark cluster on a console that is registered with PEM, Ark will register each node of the cluster with the PEM server for monitoring. Each node of an Ark cluster, and the agent that resides on the node is displayed in a Group-level heading in the PEM web interface `Browser` tree control. The node name is: + +`Ark-Cluster` + +Where `` is the name assigned to the cluster. + +Right click on the IP address of a cluster node, and provide the password specified when the cluster was provisioned to authenticate with the database and view the database objects that reside on the cluster in the tree control. + +PEM documentation is available via the PEM web interface Help menu, or at [the EnterpriseDB website](https://www.enterprisedb.com/products/edb-postgres-platform/edb-postgres-enterprise-managerpem/). + +**Known Limitations** + +If your Ark clusters are provisioned with private IP addresses, they may not be reachable from the PEM server. If this is the case, you will not be able to use PEM to remotely browse the database server. PEM agents running on the Ark cluster nodes will be able to report status to the PEM Server. + +Please note that the user identifier associated with an Ark cluster (the cluster owner) must be unique across all Ark consoles supported by a given PEM server. + + + +## Registering a PEM Agent + +The PEM agent is responsible for executing tasks and reporting statistics from a monitored Postgres instance to the PEM server. The PEM agent is installed by the pem-agent RPM. By default, all engine configurations shipped with the Ark console include the PEM agent. + +![*PEM Architecture*](images/ark_registering_with_pem_architecture.png) + +Fig. 4.7: PEM Architecture + +After installing the PEM agent, the agent must be registered on each node that will be monitored by the PEM server. The steps that follow detail registering the PEM agent with the server, and configuring the server to monitor the agent. + +Please note that before registering a node for monitoring, you must: + +- modify the `pg_hba.conf` file on the node hosting the PEM server to allow connections from any monitored node. +- modify the `pg_hba.conf` file on any monitored node, allowing connections from the PEM server. +- configure the agent on each monitored node. + +The steps that follow provide detailed information about each configuration step. The steps assume that you have installed and configured a PEM server; for information about installing and configuring PEM, please visit the EnterpriseDB website at [www.enterprisedb.com](http://www.enterprisedb.com). + +**Please note:** when a cluster node is stopped (for example, when scaling down), or if a cluster is deleted, the `Monitoring` tab of the PEM web interface will alert you that the agent on that node is down. + +If the cluster has been deleted (and the agent will not resume monitoring), you can use the PEM `Browser` tree control to remove the agent definition from the PEM server. Expand the PEM Agents node of the tree control, and right-click on the name of the deleted agent; then, select `Delete/Drop` from the context menu. + +**1. Create an EDB Ark Cluster** + +Navigate to the Clusters tab, and create a new cluster that is provisioned using an engine definition that includes the pem-agent RPM package in the list of required RPM packages. For detailed information about creating a new server cluster, please see the `EDB Ark Getting Started Guide`, available through the Ark console's `Dashboard` tab. + +**2. Modify the pg_hba.conf file to allow connections to the PEM Server** + +The PEM server consists of an instance of PostgreSQL, an associated PostgreSQL database for storage of monitoring data, and a server that provides web services for the PEM web interface. The PEM server may reside on a host outside of a monitored EDB Ark cluster, or on the master node of an Ark cluster. + +Before a PEM agent that resides on an Ark cluster can communicate with the PEM server, you must modify the `pg_hba.conf` file of the PostgreSQL database that stores PEM statistics to allow connections from any monitored servers as well as the PEM client. + +With your choice of editor, modify the `pg_hba.conf` file of the PEM Server backing database, adding entries for the IP address of the EDB Ark cluster. The connection properties should allow connections that use `cert` and `md5` authentication. + +![*Modifying the pg_hba.conf file*](images/ark_registering_with_pem_pg_hba.png) + +Fig. 4.8: Modifying the pg_hba.conf file + +**3. Restart the PEM Server Database** + +After modifying the pg_hba.conf file for the PostgreSQL installation that stores statistical information for PEM, you must restart the PEM backing database server to apply the changes. The name of the PEM service is: + +`postgresql-` + +Where `` specifies the version. For example, the following command restarts a PostgreSQL 10 service: + +`service postgresql-10 restart` + +Use your platform and version-specific command to restart the PEM server. + +**4. Establish an SSH Session with the Monitored Node of the Ark Cluster** + +Use the `Download SSH Key` icon on the `Clusters` tab to download the SSH key for your cluster. When you download the key, a popup will open, informing you of the steps required to connect to the master node of your cluster. + +![*Connecting with SSH*](images/ark_registering_with_pem_ssh_session.png) + +Fig. 4.9: Connecting with SSH + +Open a terminal window, modify the permissions on the downloaded file, and use the command shown on the popup to establish a connection with the server. + +**5. Modify the pg_hba.conf file to Allow Connections from the PEM Server** + +Use your choice of editor to modify the pg_hba.conf file on the Ark node. By default, the pg_hba.conf file is located in `/var/lib/ppas//data`, where `` specifies the Ark server version. + +Add entries to the `pg_hba.conf` file that allow connections from the PEM server. + +**6. Restart the Database Server on the Ark Cluster** + +After modifying the `pg_hba.conf` file, you must restart the server to apply the changes. The name of the service is `Arkdb`. Use the platform and version specific command for your cluster to restart the `Arkdb` service. + +**7. Configuring the PEM Agent** + +You must register each PEM agent that resides in an Ark cluster with the PEM server. Using the SSH connection to the cluster node on which the agent resides, navigate into the directory that contains the PEM agent installation: + +`cd /usr/pem-7.0/bin` + +Then, invoke the PEM agent registration program: + +`PGPASSWORD=password ./pemagent --register-agent --pem-server --pem-port --pem-user ` + +Where: + +`` specifies the IP address of the PEM server. + +`` specifies the port on which the server is listening for connections + +`` specifies the name of the PEM user. + +The program will confirm that the agent was registered successfully. + +![*The agent is registered successfully*](images/ark_registering_with_pem_registered_successfully.png) + +Fig. 4.10: The agent is registered successfully + +After registering the agent, use the following command to ensure that the service is configured to restart when if the node restarts, and that the pemagent service is running: + +`chkconfig pemagent on && service pemagent start` + +For more information about Postgres Enterprise Manager, and to download PEM documentation, please visit the [EnterpriseDB website](https://www.enterprisedb.com/products/edb-postgres-platform/edb-postgres-enterprise-managerpem) . diff --git a/product_docs/docs/ark/3.5/ark_admin/05_ark_authentication_models.mdx b/product_docs/docs/ark/3.5/ark_admin/05_ark_authentication_models.mdx new file mode 100644 index 00000000000..b8bf673ab19 --- /dev/null +++ b/product_docs/docs/ark/3.5/ark_admin/05_ark_authentication_models.mdx @@ -0,0 +1,99 @@ +--- +title: "Ark Authentication Models" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-ark-platform/user-guides/administrative-users-guide/3.5/ark_authentication_models.html" +--- + + + +When deploying the console, you can specify the type of authentication used by the Ark console. Authentication can be native password (provided by the service provider), or performed by the PostgreSQL backing database that resides on the host of the Ark console. + +**Using Native Password Authentication** + +When using native password authentication, an Administrative user must: + +- On AWS: use the `User Administration` section of the Ark `Admin` tab to register Ark users. +- On Azure: use the Azure console to create user accounts and manage user access. + +**Using PostgreSQL Authentication** + +Ark supports using the following PostgreSQL authentication types: + +- PASSWORD +- LDAP +- RADIUS +- PAM +- BSD + +For information about configuring authentication on a Postgres server, please consult the [Postgres documentation](https://www.enterprisedb.com/docs/en/10/pg/client-authentication.html) available at the EnterpriseDB website. + +If you choose to use PostgreSQL authentication when deploying the Ark console, an Administrative user must: + +- On AWS: add each user to the Ark backing database, and then use the `User Administration` section of the Ark `Admin` tab to register Ark users. On an Amazon host, the user name and associated password specified in the Ark backing database must match the credentials specified when registering the user in the Ark console. +- On Azure: add each user to the Ark backing database. Registration will be complete when the user logs in to the Ark console. + +You can use the psql client to add a user to the postgres database. To use the psql client, SSH to the host of the Ark console; navigate into the `bin` directory, and connect to the psql client with the command: + +`./psql –d postgres –U postgres` + +When prompted, supply the password of the postgres database user. After connecting to the database, you can use the `CREATE ROLE` command to add a user to the database: + +`ADD USER WITH PASSWORD ;` + +Where: + +`` specifies the name of the Ark user. `` specifies the password associated with the user name. + +For detailed information about using the [psql client](https://www.enterprisedb.com/docs/en/10/pg/app-psql.html) please see the Postgres documentation. + +After the administrative user adds the end-user, the end-user will complete the registration process by navigating to the URL of the console, and logging in. + + + +## Using Provider Authentication on AWS + +If you use authentication provided by Amazon, an Ark Administrative user can use the Ark Administrator's console to add, modify, or delete user accounts. + +![*Using Provider Authentication on AWS*](images/ark_authentication_models_aws_provider_auth.png) + +Fig. 5.1: Using Provider Authentication on AWS + +When the user provides credentials to the Ark console, the credentials are passed to Amazon for verification. If the credentials are successfully verified, the role is evaluated to determine if the user should have access to the Administrator console or the end-user console. + + + +## Using PostgreSQL Authentication on AWS + +When Postgres authentication is enabled, the first user to log in becomes the service user. + +![*Using PostgreSQL Authentication on AWS*](images/ark_authentication_models_aws_pg_auth.png) + +Fig. 5.2: Using PostgreSQL Authentication on AWS + +An Ark Administrative user must use a client application (such as psql or PEM) to add each user to the Ark backing database, and then use the User Administration table to register Ark users. The user name and associated password specified in the Ark backing database must match the credentials specified when registering the user in the Ark console. If Ark successfully verifies the credentials, the credentials are passed to Amazon for evaluation to determine console access. + + + +## Using Provider Authentication on Azure + +If you use native password authentication provided by Azure you must use the Azure Active Directory console to create and manage user accounts. + +![*Using Provider Authentication on Azure*](images/ark_authentication_models_azure_provider_auth.png) + +Fig. 5.3: Using Provider Authentication on Azure + +When the user provides credentials to the Ark console, the credentials are passed to the provider for verification. If the credentials are successfully verified, the role is evaluated to determine if the user should have access to the Administrator console or the end-user console. + + + +## Using PostgreSQL Authentication on Azure + +When Postgres authentication is enabled on Azure, the first user to log in to the Ark console becomes the service user. An administrator will be required to use either the PEM web interface or psql to add each successive user to the Ark backing database. User registration will be completed when the end user logs in to the Ark console. + +![*Using PostgreSQL Authentication on Azure*](images/ark_authentication_models_azure_pg_auth.png) + +Fig. 5.4: Using PostgreSQL Authentication on Azur + +The credentials of the Ark service user are verified by the provider; all other credentials are verified by the Postgres server on the Ark console host. If Ark successfully verifies the credentials, the credentials are then evaluated to determine console access. diff --git a/product_docs/docs/ark/3.5/ark_admin/06_ark_installing_console/01_ark_installing_console_aws.mdx b/product_docs/docs/ark/3.5/ark_admin/06_ark_installing_console/01_ark_installing_console_aws.mdx new file mode 100644 index 00000000000..8ac052b2a3d --- /dev/null +++ b/product_docs/docs/ark/3.5/ark_admin/06_ark_installing_console/01_ark_installing_console_aws.mdx @@ -0,0 +1,467 @@ +--- +title: "Installing the Ark Console on AWS" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-ark-platform/user-guides/administrative-users-guide/3.5/ark_installing_console_aws.html" +--- + + + +The EDB Ark console is distributed through the Amazon AWS Marketplace in an Amazon machine instance. To install the Ark console on your Amazon instance, you will need to: + +- Launch an [Ark instance](#launch_ark_aws) with an Amazon AWS Marketplace AMI. +- Create an [Amazon role](#creating_aws_service_user) and [register an administrative user](#creating_aws_service_role) . +- Configure the [Ark console](#config_ark_console) . +- Create an Amazon role and [register an Ark console user](#create_aws_role_register_ark_user) . + + + +## Launching the Ark Console Instance on AWS + +Before launching an AMI into an Amazon VPC, you must ensure that the VPC has access to an [Internet Gateway](http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_Internet_Gateway.html). If your VPC does not have access to an Internet Gateway, you can use the Amazon management console to create an Internet Gateway and associate it with your VPC. + +Please note: if you are using EC2-Classic networking, you do not need to provide an Internet Gateway. + +To launch an Amazon EC2 instance that contains a running copy of the Ark console and the Ark console's backing database, connect to your Amazon AWS Marketplace account and locate the AMI that contains the Ark console. Navigate through the introductory page for the AMI, selecting AWS service options that are appropriate to your application, and agreeing to the `Terms and Conditions`. When you agree to the `Terms and Conditions`, Amazon will process the subscription. + +After you subscribe, Amazon will forward an email to the address associated with your user account that includes [launch instructions](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/launching-instance.html) for the AMI. + +Then, use the Amazon launch wizard to launch your instance, noting the requirements that follow on `Step 3` and `Step 6` of the wizard. + +![*Step 3 - Enabling the startup script*](../images/ark_installing_console_aws_step_3_details.png) + +Fig. 6.1: Step 3 - Enabling the startup script + +When configuring your instance, you should include the following selections on the `Step 3: Configure Instance Details` dialog of the Amazon launch wizard: + +- Use the `Auto-assign Public IP` drop-down to specify Enable to automatically assign an IP address to the new instance. +- Use the `Advanced Details` section to provide the text of the script that will start the Ark console setup or recovery dialog. + + + +```text +#!/bin/sh +rm -f /usr/share/tomcat/startup-password.txt +echo "" > /usr/share/tomcat/startup-password.txt +chown tomcat:tomcat /usr/share/tomcat/startup-password.txt +chmod 600 /usr/share/tomcat/startup-password.txt +``` + +Replace the `` variable in the script with a password for the console. When the user first connects to the AWS Ark console, they will be required to provide the console password provided in the script. + +Continue through the launch wizard; please note that when configuring your security group, the group must allow communication between the nodes of the cluster. When defining the security group, include the rules listed in the table below. + +| Rule Type | Direction | Port or Range | Remote | CIDR Address | +| ---------- | --------- | ------------- | ------ | ------------ | +| All ICMP | Ingress | | CIDR | 0.0.0.0/0 | +| SSH | | | CIDR | 0.0.0.0/0 | +| HTTP | | | CIDR | 0.0.0.0/0 | +| HTTPS | | | CIDR | 0.0.0.0/0 | +| Custom TCP | Ingress | 6666 | CIDR | 0.0.0.0/0 | +| Custom TCP | Ingress | 7800 to 7999 | CIDR | 0.0.0.0/0 | +| Custom TCP | Ingress | 5432 | CIDR | 0.0.0.0/0 | + +**Please Note:** + +- The CIDR addresses specified in the rules for SSH, HTTP, HTTPS, and 5432 can be customized to restrict access to a limited set of users. +- The CIDR addresses specified for port 6666 and ports 7800 through 7999 must specify a value of `0.0.0.0/0`. +- The Custom TCP rule that opens ports 7800 through 7999 provides enough ports for 200 cluster connections; the upper limit of the port range can be extended if more than 200 clusters are required. + + + +## Creating the Amazon AWS Service User and Service Role + +Before configuring the Ark console on an Amazon host and creating users, you must create an Amazon service user and service role. Ark uses the service role when performing Ark management functions (such as console backups). The Ark console uses the service role credentials (the cross account keys) to assume the IAM roles assigned to Ark users. This enables Ark to securely manage AWS resources. When configuring the Ark console, you are required to provide the setup dialog with details about the AWS service user and the service role. Specify: + +- the Amazon Role ARN (resource name) that will be used by the Ark service in the `Service Account Role ARN` field. +- the Amazon external ID that will be used by the Ark service user in the `Service Account External ID` field. +- the AWS_ACCESS_KEY_ID associated with the AWS role used for account administration in `AWS Access Key` field. +- the AWS_SECRET_ACCESS_KEY associated with the AWS role used for account administration in `AWS Secret Key` field. + + + +### Creating the AWS Service User + +To create the Ark console's service user account, connect to the Amazon AWS management console, and navigate through the *IAM* menu (Identity and Access Management) to the *Users* dashboard; select the *Add user* button to open the *Add user* dialog. + +![*The AWS Add user dialog*](../images/ark_installing_console_aws_add_user_dialog.png) + +Fig. 6.2: The AWS Add user dialog + +On the `Add user` dialog: + +- Provide a name for the service user account in the `User name` field. +- Check the box to the left of `Programmatic access`. + +Click `Next: Permissions` to continue. Click the `Attach existing policies directly` button, and then the `Create policy` button to open the `Create policy` dialog in a new tab. + +When the `Create policy` dialog opens, select the `JSON` tab, and provide the policy definition. + +![*Adding a policy definition*](../images/ark_installing_console_aws_create_policy.png) + +Fig. 6.3: Adding a policy definition + +After copying in a policy, click the `Review policy` button to continue. + +![*Completing the policy definition*](../images/ark_installing_console_aws_complete_policy.png) + +Fig. 6.4: Completing the policy definition + +Provide a name and a description for the service policy definition, and click the `Create policy` button to continue. + +![*Attaching the policy*](../images/ark_installing_console_aws_attach_policy.png) + +Fig. 6.5: Attaching the policy + +Return to the `Add user` tab, and click the `Refresh` button. Check the box to the left of the new policy, and click `Next:Tags`. + +IAM user tags are optional; you can click `Next: Review` to continue. + +![*Creating the user*](../images/ark_installing_console_aws_review_user.png) + +Fig. 6.6: Creating the user + +Review the account details, and click the `Create user` button to create the user. The AWS console will confirm that the user has been added successfully. + +![*The user is created successfully*](../images/ark_installing_console_aws_add_user_success.png) + +Fig. 6.7: The user is created successfully + +Keep a copy of the access key values displayed on the console; you must provide the values when configuring your Ark console: + +- Provide the Access key id in the `AWS Access Key` field on the Ark console setup dialog. +- Use the `Show` button to display the Secret access key. You must provide the Secret access key in the AWS `Secret Key` field on the Ark console setup dialog. + + + +### Creating the AWS Service Role + +After creating the service user, you must create a service role. Connect to the Amazon management console, and navigate through the Identity and Access Management dashboard to the Roles dashboard. Then, click the `Create role` button to open the `Create role` dialog. + +![*Creating a role*](../images/ark_installing_console_aws_create_svc_role.png) + +Fig. 6.8: Creating a role + +Select the `AWS service` button, and the `EC2 service` type; click `Next: Permissions` to continue. + +![*The AWS Attach permissions policies dialog*](../images/ark_installing_console_aws_attach_perm_policy.png) + +Fig. 6.9: The AWS Attach permissions policies dialog + +When the `Attach permissions policies` dialog opens, do not select a policy; instead, click `Next:Tags`, then `Next: Review` to continue. + +![*Provide a role name and description*](../images/ark_installing_console_aws_review_role.png) + +Fig. 6.10: Provide a role name and description + +When the `Review` dialog opens, specify a name and description for the new role and click the `Create role` button. The new role will be displayed in the role list on the Amazon IAM Roles page. Click the role name to display detailed information about the role on the `Summary` dialog. + +![*The AWS Summary dialog*](../images/ark_installing_console_aws_role_permissions.png) + +Fig. 6.11: The AWS Summary dialog + +The `Summary` dialog will display a Role ARN, but the ARN will not be enabled until the security policy and trust policy are updated. To modify the inline security policy, click the `Add inline policy` button; the button is located on the `Permissions` tab. + +![*Provide the policy name and contents*](../images/ark_installing_console_aws_role_provide_policy.png) + +Fig. 6.12: Provide the policy name and contents + +Copy the [provided security policy](../17_ark_aws_service_user_security_policy/#ark_aws_service_user_security_policy) into the `JSON` tab on the `Create policy` dialog. After providing security policy information, click `Review Policy` to provide a name for the policy, and return to the role information page. + +![*The policy document*](../images/ark_installing_console_aws_role_edit_trust.png) + +Fig. 6.13: The policy document + +Navigate to the `Trust relationships` tab, and select the `Edit Trust Relationship` button to display the `Policy Document`. Replace the displayed content of the policy document with the provided [Amazon IAM Role Trust Relationship](../16_ark_aws_iam_role_trust_relationship/#ark_aws_iam_role_trust_relationship). + +Click the `Update Trust Policy` button to finish. + +![*The role detail summary*](../images/ark_installing_console_aws_role_summary.png) + +Fig. 6.14: The role detail summary + +The role detail `Summary` will display values that you must provide when configuring your Ark console: + +- The `Role ARN` associated with the service role must be provided in the `Service Account Role ARN` field. +- The external ID associated with the service role must be provided in the `Service Account External ID` field. You can find this value under the `Conditions` section of the `Trust Relationships` tab. + + + +## Configuring the Ark Console + +After launching the instance in the Amazon console, navigate to the public IP address of the cluster. + +![*Deploying the console*](../images/ark_installing_console_aws_conf_ark_console.png) + +Fig. 6.15: Deploying the console + +When prompted, provide the password specified when launching the console, and click `Deploy Console`. + +![*The provider specific console properties*](../images/ark_installing_console_aws_spec_props.png) + +Fig. 6.16: The provider specific console properties + +Use fields in the first section of the dialog to provide values that are specific to your Amazon account: + +- Use the `AWS Access Key` field to specify the Amazon access key ID associated with the AWS role that will be used for account administration. +- Use the `AWS Secret Key` field to specify the Amazon secret key associated with the AWS role that will be used for account administration. +- Use the `Service Account Role ARN` field to specify the Amazon Role ARN (resource name) that should be used by the Ark service user when performing management functions on behalf of Ark. +- Use the `Service Account External ID` field to specify the Amazon external ID that should be used by the Ark service user. +- Use the `Service Account ID` field to specify the identity of the service account. +- Use the `Service Account Password` field to provide the password associated with the service account. +- Use the `Enable Self Registration` field to specify if the Ark console should allow self-registration for Ark users; specify `true` to allow self-registration, or `false` to disable self-registration. + +![*Provide general server properties*](../images/ark_installing_console_aws_general_props.png) + +Fig. 6.17: Provide general server properties + +Use fields in the next section to provide general server properties: + +- Use the `Console DNS Name` field to specify a custom DNS name for the console. The property does not assign the DNS name to the console, but any notification emails that refer to the console will refer to the console by the specified name. If you do not provide a custom DNS name, the IP address of the console will be used in notifications. +- Use the `Contact Email Address` field to specify the email address that will be included in the body of cluster status notification emails. +- Use the `Email From Address` field to specify the return email address used on cluster status notification emails. +- Use the `Notification Email` field to specify the email address to which email notifications about the status of the Ark console will be sent. +- Set the `CC From Address` field to true to instruct Ark to send a copy of the email to the Email From Address anytime a notification email is sent. +- Use the `API Timeout field` to specify the number of minutes that an authorization token will be valid for use with the API. +- Use the `WAL Archive Container` field to specify the name of the object storage container where WAL archives (used for point-in-time recovery) are stored. You must provide a value for this field; once set, this property must not be changed. + - The bucket name must be at least 3 and no more than 63 characters long. + - The name can contain lowercase letters, numbers, and hyphens; the name must start with and end with a lowercase letter or number. + - A series of one or more labels; adjacent labels are separated by a single period (.). A name may not be formatted as an IP address. + +For more information, please visit: + +- Use the `Dashboard Docs URL` field to specify the location of the content that will be displayed on the Dashboard tab of the Ark console. If your cluster resides on a network with Internet access, set the parameter to `DEFAULT` to display content (documentation) from EnterpriseDB; to display alternate content, provide the URL of the content. To display no content in the lower half of the `Dashboard` tab, leave the field blank. +- Use the `Dashboard Hot Topics URL` field to specify the location of the content that will be displayed on the Dashboard tab of the Ark console. If your cluster resides on a network with Internet access, set the parameter to `DEFAULT` to display content (alerts) from EnterpriseDB; to display alternate content, provide the URL of the content. Leave the field blank to omit content. +- Use the `Enable Console Switcher` field to indicate if the console should display [console switcher](../08_ark_admin_tab/#ark_using_admin_tab) functionality. +- Set `Enable Postgres Authentication` to `true` to instruct Ark to enforce the authentication method configured on the backing Postgres server. Supported authentication methods include password, LDAP, RADIUS, PAM, and BSD. If `false`, Ark will use the default authentication method (password). +- Use the `Template Restrict New Users` field to configure the Ark console to make any new user a `Template Only` user by default. You can later modify the user definition in the `User Administration` table to specify that a user is not a template only user. +- Use the `Cluster Event Retention Limit` field to specify how long the console will keep events for deleted clusters. The default value is 14 days. + +![*Provide connection details for PEM*](../images/ark_installing_console_aws_pem_props.png) + +Fig. 6.18: Provide connection details for PEM + +Use fields in the next section to provide connection details for a PEM server host; this will allow Ark to register and unregister PEM agents and clusters: + +- Use the `PEM Server Mode` drop-down listbox to select a deployment mode: + +Select `DISABLE` to indicate that clusters deployed on the host should not be registered with the PEM server. + +Select `LOCAL` to indicate that you would like to use the PEM server that resides on your local host. If you select LOCAL, the PEM deployment will use default values assigned by the installer. + +- The IP address of the PEM server host will be the IP address of the Ark host. +- The PEM Server Port will monitor port `5432`. +- The PEM server database user will be named `postgres`. +- The password associated with the PEM server will be the same password as the Ark console. + +Select `REMOTE` to indicate that you would like to use a PEM server that resides on another host, and provide connection information on the Ark console deployment dialog. If you select REMOTE, whenever a new cluster node is created on this console, it will be registered for monitoring by the PEM server. + +- Provide the IP address of the PEM server host in the `PEM Server IP Address` field. +- Specify the port monitored for connections by the PEM server in the `PEM Server DB Port` field. +- Specify the port on the PEM server host used for PEM API connection attempts by the Ark server in the `PEM Server API Port` field. Not valid if the PEM server mode is `DISABLED` or `LOCAL`. +- Provide the name that should be used when authenticating with the PEM server in the `PEM Server Username` field. +- Provide the password associated with the PEM server user in the `PEM Server Password` field. +- Use the `PEM Sync Mode` drop-down listbox to `ENABLE` or `DISABLE` synchronization between the Ark server and the PEM server. +- Use the `PEM Synchronization Interval` field to specify the number of minutes between attempts to synchronize the Ark console with the PEM server. + + + +![*Provide information about the service provider*](../images/ark_installing_console_aws_sp_props.png) + +Fig. 6.19: Provide information about the service provider + +If you specify `true` in the `SAML auth enabled` field, the Ark console will display the properties required to use SAML authentication when connecting to the Ark console. Use fields on the deployment dialog to specify SAML authentication properties. Use fields in the next section to provide information about the service provider: + +- Use the `SP Entity ID` field to provide a URI that specifies the identifier of the service provider. +- Use the `SP Consumer Service URL` field to specify the URL from which the response from the identity provider will be returned. +- Use the `SP Consumer Service Binding` field to specify the SAML protocol binding to be used when returning the response message from the identity provider. +- Use the `SP Logout Service URL` field to specify the URL to which the service provider will specify information about where and how the `Logout Response` message MUST be returned to the requester, in this case our service provider. +- Use the `SP Logout Service Binding` field to specify the SAML protocol binding to be used when returning the `LogoutResponse` or sending the `LogoutRequest` message. +- Use the `SP Name ID Format` field to specify the constraints on the name identifier that will be used to represent the requested subject. +- Use the `SP Certificate` field to specify certificate information; this is usually `x509cert`. The private key of the service files are provided by files placed in the `certs` folder. +- Use the `SP Private Key` field to specify the location of the service providers private key; this must be in `PKCS#8` format. + +![*Provide information about the identity provider*](../images/ark_installing_console_aws_idp_props.png) + +Fig. 6.20: Provide information about the identity provider + +Use fields in the next section to provide information about the identity provider: + +- Use the `IDP Entity ID` field to specify the identifier of the identity provider (this must be a URI). +- Use the `IDP Sign On URL` field to specify the URL target of the identity provider (where the service provider will send the Authentication Request Message). +- Use the `IDP Sign On Service Binding` field to specify the SAML protocol binding to be used when returning the response message. This version of Ark only supports the HTTP-Redirect binding. +- Use the `IDP Logout Service URL` field to specify the URL Location of the identity provider to which the service provider will send a single logout Request. +- Use the `IDP Logout Service Response URL` field to specify the URL Location of the identity provider to which the service provider will send a single logout response. +- Use the `IDP Single Logout Service Binding` field to specify the SAML protocol binding to be used when returning the response message. +- Use the `IDP Certificate` field to specify the Public x509 certificate of the identity provider. + +![*Provide information about your SAML preferences*](../images/ark_installing_console_aws_saml_props.png) + +Fig. 6.21: Provide information about your SAML preferences + +Use fields in the next section to provide your SAML preferences: + +- Use the `Encrypted Name ID` field to indicate that the name identifier of the `samlp:logoutRequest` sent by this service provider will be encrypted; specify `true` or `false`. +- Use the `Auth Request Signed` field to indicate if the `samlp:AuthnRequest` messages sent by this service provider will be signed; specify `true` or `false`. +- Use the `Logout Request` field to indicate if the `samlp:logoutRequest` messages sent by the service provider will be signed; specify `true` or `false`. +- Use the `Logout Response Signed` field to indicate if the `samlp:logoutResponse` messages sent by the service provider will be signed; specify `true` or `false`. +- Use the `Sign messages` field to sign the metadata. If you leave the field empty, the metadata will not be signed. If you wish to provide a signature, provide a comma separated `keyFileName`, `certFileName` pair. +- Use the `Sign assertions` field to indicate a requirement for the `samlp:Response`, `samlp:LogoutRequest`, and `samlp:LogoutResponse` elements received by the service provider to be signed; specify `true` or `false`. +- Use the `Sign Metadata` field to indicate that the metadata of this service provider must be signed; specify `true` or `false`. +- Use the `Encrypt Assertions` field to indicate that the assertions received by this service provider must be encrypted; specify `true` or `false`. +- Use the `Encrypt Name ID` field to indicate that the name identifier received by this service provider must be encrypted; specify `true` or `false`. +- Use the `Authentication Context` field to specify that `Set Empty` and `no AuthContext` will be sent in the `AuthNRequest`. You can set multiple values in a comma-delimited list. +- Use the `Auth Comparison Parameters` field to specify that the `authn` comparison parameter to be set; this field defaults to `exact`. +- Use the `XML validation` field to indicate if the service provider will validate all received xmls; specify `true` or `false`. +- Use the `Signature Algorithm` field to specify the algorithm that the toolkit will use for the signing process. Specify one of the following: + - `http://www.w3.org/2000/09/xmldsig#rsa-sha1` + - `http://www.w3.org/2000/09/xmldsig#dsa-sha1` + - `http://www.w3.org/2001/04/xmldsig-more#rsa-sha256` + - `http://www.w3.org/2001/04/xmldsig-more#rsa-sha384` + - `http://www.w3.org/2001/04/xmldsig-more#rsa-sha512` + +![*Provide information about your organization*](../images/ark_installing_console_aws_org_props.png) + +Fig. 6.22: Provide information about your organization + +Use fields in the next section to provide information about your organization: + +- Use the `Organization Name` field to specify the name of the organization for which authentication is being provided. +- Use the `Display Name` field to specify the display name of the organization. +- Use the `Organization URL` field to specify the URL of the organization. +- Use the `Organization Language` field to specify the primary language used by the organization. +- Use the `Technical Contact Name` field to specify the name of a technical contact. +- Use the `Technical Email Address` field to specify a contact email address for the technical contact. +- Use the `Support Contact Name` field to specify the name of a support contact. +- Use the `SAML Support Email Address` field to specify the email address of the SAML support contact. + +![*Provide console backup information*](../images/ark_installing_console_aws_backup_props.png) + +Fig. 6.23: Provide console backup information + +Use fields in the next section to specify your console backup storage preferences: + +- Use the `Storage Bucket` field to specify the name of the bucket in which backups will be stored. +- Use the `Console Backup Folder` field to specify the name of the backup folder within the storage bucket. + +![*Specify console password preferences*](../images/ark_installing_console_aws_pwd_props.png) + +Fig. 6.24: Specify console password preferences + +Use fields in the next section to specify database password preferences for the database superuser (`postgres`) on the backing PostgreSQL database (`postgres`): + +- Use the `DB User New Password` field to set the password for the postgres user on the console's backing database (`postgres`). +- Use the `DB User Confirm Password` field to set the password for the postgres user on the console's backing database (`postgres`). + +![*Select a timezone for the server*](../images/ark_installing_console_aws_timezone_props.png) + +Fig. 6.25: Select a timezone for the server + +Use the last field to specify a timezone for the server: + +- Use the drop-down listbox in the `Timezone` field to select the timezone that will be displayed by the Ark console. + +When you've completed the setup dialog, click the `Save` button to validate your changes. The Ark console will prompt you to confirm that you wish to restart the server; when prompted, click the `Restart` button to restart the server and start the Ark console. + + + +## Creating an Amazon Role and Registering an Ark Console User + +After deploying the console, you must create an Amazon role with an associated security policy that will be applied to the Ark console user. You can use the same security policy for multiple users, or create additional Amazon roles with custom security policies for additional users. Each time you register a user, you will be prompted for a Role ARN. The Role ARN determines which security policy will be applied to that user. + +To define an Amazon role, connect to the Amazon management console, and navigate through the `Identity and Access Management` dashboard to the `Roles` dashboard, and click the `Create role` button. + +![*The Create role dialog*](../images/ark_installing_console_aws_create_iam_role.png) + +Fig. 6.26: The Create role dialog + +When the `Create role` dialog opens, select the `AWS service button` and highlight the `EC2` bar, and click `Next: Permissions` to continue. + +![*The Attach permissions policies dialog*](../images/ark_installing_console_aws_iam_role_perm.png) + +Fig. 6.27: The Attach permissions policies dialog + +When the `Attach permissions policies` dialog opens, do not specify a policy; instead, click `Next: Review` to continue. + +![*The Review dialog*](../images/ark_installing_console_aws_iam_role_review.png) + +Fig. 6.28: The Review dialog + +Use the `Review` dialog to provide a name and a description; then, click `Create role`. The role will be displayed in the role list on the Amazon `IAM Roles` page. Highlight the role name to review account details. + +![*The Summary dialog*](../images/ark_installing_console_aws_iam_role_summary.png) + +Fig. 6.29: The Summary dialog + +The *Summary* dialog will display a Role ARN, but the ARN will not be enabled until the security policy and trust policy are updated. + +After completing the `Create Role` wizard, you must modify the inline policy and trust relationship (defined by the security policy) to allow Ark to use the role. Click the `Add inline policy` link to add a security policy. Then, copy the [permission policy text](../15_ark_aws_iam_role_permission_policy/#ark_aws_iam_role_permission_policy) into the `JSON` tab. + +![*Adding a security policy*](../images/ark_installing_console_aws_iam_role_sec_policy.png) + +Fig. 6.30: Adding a security policy + +Then, click `Review Policy` to return to continue to the `Review policy` page and provide a name for the policy. Then, click the `Create policy` button to return to the role summary page. + +Select the `Trust relationships` tab, and click the `Edit trust relationship` button to update the trust relationship assigned to the role. + +![*Editing the trust relationship*](../images/ark_installing_console_aws_iam_role_edit_trust_rel.png) + +Fig. 6.31: Editing the trust relationship + +Replace the displayed content with the [provided policy document](../16_ark_aws_iam_role_trust_relationship/#ark_aws_iam_role_trust_relationship). + +!!! Note + `EDB-ARK-SERVICE` is a placeholder within the trust policy. You must replace the placeholder with the `External ID` provided on the `Step 2` tab of the Ark console `New User Registration` dialog. + +To retrieve the `External ID`, open another browser window and navigate to the `Log In` page of your Ark console. + +![*Accessing the New User Registration dialog*](../images/ark_installing_console_aws_user_reg.png) + +Fig. 6.32: Accessing the New User Registration dialog + +Click the `Register` button to open the `New User Registration` dialog. + +![*The New User Registration dialog*](../images/ark_installing_console_aws_reg_step_1.png) + +Fig. 6.33: The New User Registration dialog + +Enter user information in the `User Details` box located on the `Step 1` tab: + +- Enter your first and last names in the `First Name` and `Last Name` fields. +- Enter a password that will be associated with the user account, and confirm the password in the `Password` and `Verify Password` fields. +- Provide an email address in the `Email` field; please note that the email address is used as the Login identity for the user. +- Use the drop-down listbox in the `Cloud Provider` field to select the host on which the cloud will reside. +- Enter the name of the company with which you are associated in the `Company Name` field. + +When you've completed `Step 1`, click `Next` to open the `Step 2` tab. The `Step 2` tab of the `New User Registration` dialog will display a random `External ID` number. Copy the `External ID` from the `Step 2` dialog into the trust policy, replacing `EDB-ARK-SERVICE`. Please note that you must enclose the External ID in double-quotes ("). Click the `Update Trust Policy` button to save your edits and exit the dialog. + +![*The Summary tab of the Role detail panel*](../images/ark_installing_console_aws_role_detail.png) + +Fig. 6.34: The Summary tab of the Role detail panel + +Your Amazon IAM role ARN is displayed on the Amazon role detail panel. + +![*Registering a user on an Amazon EC2 cloud*](../images/ark_installing_console_aws_reg_step_2.png) + +Fig. 6.35: Registering a user on an Amazon EC2 cloud + +Enter your Amazon IAM role ARN in the `Role Arn` field on the `Step 2` dialog, and click `Finish` to complete the registration. Select `Cancel` to exit without completing the registration. + +After registering your user identity and connection information, you are ready to log in to the Ark console. + +![*The Login/Register dialog*](../images/ark_installing_console_aws_ark_login.png) + +Fig. 6.36: The Login/Register dialog + +Provide the email address in the `Email` field, and the associated password in the `Password` field, and click `Log In` to connect to the Ark management console. + +![*The Ark dashboard tab*](../images/ark_installing_console_aws_ark_dashboard.png) + +Fig. 6.37: The Ark dashboard tab + +In preparation for non-administrative user to connect, an Administrator should: + +1. Use the Ark console to define a server image for each server that will host a database cluster. For detailed information about using the Ark console to create server images, see [Creating a Server Image](../08_ark_admin_tab/#ark_using_admin_tab). +2. Use the Ark console to create database engine definitions. For detailed information about defining a database engine, see [Creating a Database Engine](../08_ark_admin_tab/#ark_using_admin_tab) diff --git a/product_docs/docs/ark/3.5/ark_admin/06_ark_installing_console/02_ark_installing_console_azure.mdx b/product_docs/docs/ark/3.5/ark_admin/06_ark_installing_console/02_ark_installing_console_azure.mdx new file mode 100644 index 00000000000..5ba082bea7b --- /dev/null +++ b/product_docs/docs/ark/3.5/ark_admin/06_ark_installing_console/02_ark_installing_console_azure.mdx @@ -0,0 +1,432 @@ +--- +title: "Installing the Ark Console on Azure" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-ark-platform/user-guides/administrative-users-guide/3.5/ark_installing_console_azure.html" +--- + + + +The EDB Postgres Ark image is available on Azure Marketplace; installation and configuration is a simple process. To enable the Ark console on Azure, you must: + +Create an [Azure user account with sufficient privileges](#provide_access_azure) to access the Ark Administrator's console.\` Create an [Azure network security group](#azure_security_group) . + +Create an [Azure storage account](#azure_storage_account). Launch a [VM Image](#azure_launch_ark_console) that contains the Ark console. + +Configure the [Ark console](#azure_configure_ark_console). Register an [Ark Administrative user](#azure_register_user). + + + +## Providing Administrative Access to an Azure User + +To provide sufficient privileges for an Azure user account to access the Ark administrative console, navigate to the `Azure Resource groups` panel, highlight the name of the resource group in which your instance will reside, and select `Access control (IAM)` from the `Resources` panel; then, click the `+Add` button to access the `Add permissions` panel. + +On the `Add permissions` panel, use the drop-down listbox in the `Role` field to select `Owner`; use the drop-down listbox in the `Select` field to select the user(s) that should have administrative access to the Ark console. When you've made your selections, click `Save`. + +To limit the scale of the access to the resource group in which the image resides, use the `Resources – Access control (IAM)` panel to specify a value of `This resource` in the `scale` field for the specified user(s). + +For more information about delegating Azure permissions, please [see the Azure documentation](https://docs.microsoft.com/en-us/azure/active-directory/role-based-access-control-configure). + + + +## Creating a Security Group + +Before connecting to the Ark console, you must create a security group that will allow connections from your web browser, and between the Ark console and your instance. To create a security group, navigate to the Microsoft Azure `Network security groups` page, and click the `Add` button. When the `Create network security group` panel opens: + +- Use the `Name` field to provide a name for the security group. +- Use the drop-down listbox in the `Subscription` field to select a subscription plan. +- Use the `Resource` group field to provide a name for the associated resource group, or highlight the Use existing radio button and use the drop-down listbox in the Resource group field to select an existing resource group. +- Use the `Location` drop-down listbox to specify a location. + +When you've finished, click `Create` to create a network security group. + +After creating the network security group, you must provide the inbound rules that will allow the Ark console to manage your instance. On the Network security groups page, click the name of the security group that you wish to modify; click `Inbound security rules` (in the `SETTINGS` section of the details panel) to modify the inbound rules for the group. + +To add a new rule, click the `Add` button, and provide details about the rule; after providing rule details, click `OK`. The Azure console will notify you that it is creating the new rule. When defining the security group, include the rules listed below: + +| Rule Type | Direction | Port | Remote | CIDR Address | +| ----------------------- | --------- | ---------------------------- | ------------------- | --------------------------------------- | +| All ICMP SSH HTTP HTTPS | Ingress | | CIDR CIDR CIDR CIDR | 0.0.0.0/0 0.0.0.0/0 0.0.0.0/0 0.0.0.0/0 | +| Custom TCP | Ingress | 6666 | CIDR | 0.0.0.0/0 | +| Custom TCP | Ingress | port range from 7800 to 7999 | CIDR | 0.0.0.0/0 | +| Custom TCP | Ingress | 5432 | CIDR | 0.0.0.0/0 | + +The CIDR addresses specified in the rules for SSH, HTTP, and HTTPS can be customized to restrict access to a limited set of users. The CIDR addresses specified for port `6666` and ports `7800 through 7999` must specify a value of `0.0.0.0/0`. + +The rule that opens ports `7800` through `7999` provides enough ports for 200 cluster connections; you can extend the upper limit of the port range if more than 200 clusters are required. + + + +## Creating a Storage Account + +Before launching the Ark console, you should create an Azure storage account in which the Ark console will store console backups. You should not modify the storage account after the console is launched. + +To add an Azure storage account, navigate to the Azure `All resources` page, and click the `Add` button. In the `MARKETPLACE` edit box enter `Storage account`, and hit return. Highlight the `Storage account – blob, file, table, queue` entry. + +![*Defining a storage account*](../images/ark_installing_console_azure_create_storage.png) + +Fig. 6.38: Defining a storage account + +Click the `Create` button located on the bottom of the `Storage account-blob, file, table, queue` panel to open the `Create storage account` panel. Use fields on the `Create storage account` panel to define the storage account. + +When you've defined your storage account, click `Create`; the Azure dashboard will keep you informed as the storage account is deployed, and send you a notification when the account creation is finished. + +For detailed information about defining a storage account, please consult the [Azure documentation](https://docs.microsoft.com/en-us/azure/storage/). + + + +## Launching the Ark Console Instance + +The EDB Postgres Ark image is available on the Microsoft Azure Marketplace. To create an Ark virtual machine, log in to the Microsoft Azure management console, and click the green plus sign in the upper-left hand corner to navigate to the Azure Marketplace. + +![*Selecting an image*](../images/ark_installing_console_azure_select_image.png) + +Fig. 6.39: Selecting an image + +When the Azure Marketplace opens, enter EDB Postgres Ark in the search box. Select the EDB Postgres Ark (published by EnterpriseDB Corp.) icon from the search results, and click Create to continue. + +The Azure console will open to a dialog that allows you to configure the virtual machine that will host your console deployment. Please note that your virtual machine requirements may vary from the description that follows; the description is intended to provide guidelines about the minimum requirements for a console host for an Ark deployment. Please consult the Azure documentation for detailed information about additional configuration options for your virtual environment. + +![*Creating a virtual machine*](../images/ark_installing_console_azure_create_vm.png) + +Fig. 6.40: Creating a virtual machine + +Use fields on the `Basics` panel to provide general information about the new virtual machine: + +- If applicable, use the `Subscription` drop-down listbox to select the name of an Azure subscription. +- Use the `Resource group` drop-down listbox to select the resource group in which the VM will be created. +- Provide a name for the VM in the `Virtual Machine Name` field. +- If applicable, use the `Region` drop-down listbox to select the region in which the VM will reside. +- Use the `Image` drop-down listbox to select the image that will be used for the VM. +- Use the `Change size` link (in the `Size` field) to open the Select a VM size panel and select the machine configuration. + +![*Selecting a machine size*](../images/ark_installing_console_azure_select_vm_size.png) + +Fig. 6.41: Selecting a machine size + +Highlight a configuration type, and click the `Select` button (in the lower-left corner of the panel) to continue. + +- Select the radio button next to the `Authentication type` you wish to use for the Administrator account; we highly recommend using SSH authentication. +- Provide an operating system user name in the `User name` field; the default operating system user name for Ark images is centos. +- If you have elected to enable SSH public key authentication, provide the key in the `SSH public key` field. + +Use fields on the `Networking` panel to specify your network configuration preferences. When configuring an Azure virtual machine to use the Ark console, you should: + +- Select the `Advanced` radio button in the `Network security group` field. +- Use the `Network security group` drop-down listbox to select the security group that you wish to use for the virtual machine. + +Use fields on the `Guest config` panel to provide an extension that sets the Ark console deployment password. Create a file on your local system named `startup-password.sh` that contains the following text: + +``` +| #!/bin/sh +| rm -f /usr/share/tomcat/startup-password.txt +| echo "console_password" > /usr/share/tomcat/startup-password.txt +| chown tomcat:tomcat /usr/share/tomcat/startup-password.txt +| chmod 600 /usr/share/tomcat/startup-password.txt + +Where `console_password` is replaced with the password you will provide when prompted for a password by the Ark setup dialog. +``` + +To provide the location of the script to the virtual machine, click the `Select an Extension to install` link, then `Custom Script for Linux`. Then, click the `Create` button; use the fields on the `Install extension` panel to identify the script: + +- Use the `Script files` browser to locate and upload the script file. +- Enter the command that will invoke your script in the `Command` field; for example, `sh startup-password.sh`. + +![*Installing an extension*](../images/ark_installing_console_azure_install_extension.png) + +Fig. 6.42: Installing an extension + +Click `OK` to continue and return to the Settings panel; when you've finished updating the settings with your preferences, click OK to continue. Then, click the Review + Create button to validate your virtual machine definition. + +![*Validating the machine definition*](../images/ark_installing_console_azure_validation_passed.png) + +Fig. 6.43: Validating the machine definition + +Azure will confirm that your machine definition is valid; then, you can click the `Create` button to create your virtual machine. + +You can monitor the virtual machine's deployment from the `Azure Operations` page, the `Resource group activity log`, or the `Virtual machine Overview` page. + +![*The virtual machine details page*](../images/ark_installing_console_azure_vm_details.png) + +Fig. 6.44: The virtual machine details page + +While the deployment finishes, you can register your application in the Azure Active Directory. You will need the Public IP address or DNS name of your server for the registration. To copy the IP address, click the copy icon to the right of the public IP address on the `VM details` panel. + +![*The New application registration page*](../images/ark_installing_console_azure_new_app_reg.png) + +Fig. 6.45: The New application registration page + +After copying the public IP address of your server, select `App registrations` from the Azure Active Directory page. Click the New application registration button located on the App registrations detail panel. + +![*The Create panel*](../images/ark_installing_console_azure_create_panel.png) + +Fig. 6.46: The Create panel + +Use fields on the `Create` panel to provide information about your application: + +- Provide the application name in the `Name` field. +- Use the drop-down listbox in the `Application type` field to select the Application type; select `Native` for the Ark console application. +- Provide the public IP address of the virtual machine that is hosting the console in the `Redirect URI` field. + +Click `Create` to register your application. + +![*Accessing the Required permissions page*](../images/ark_installing_console_azure_required_permissions.png) + +Fig. 6.47: Accessing the Required permissions page + +After creating the virtual machine and registering the application, you must adjust the required permissions, allowing the `Windows Azure Service Management API` to connect to your application. This will give the Ark server permission to control Azure services via the Service Management API. + +Please note that you must be an Azure Global Administrator to grant permissions required by Ark. Click the `Settings` icon, and then navigate to the `Required permissions` page for the application, and select `+Add`. + +![*Selecting an API*](../images/ark_installing_console_azure_select_api.png) + +Fig. 6.48: Selecting an API + +Click `Select an API`, and then highlight Windows Azure Service Management API. + +![*Specifying API permissions*](../images/ark_installing_console_azure_set_api_permissions.png) + +Fig. 6.49: Specifying API permissions + +Click `Select permissions`, and then `Access Azure Service Management`; then, click `Select`. + +![*Confirming that the permissions are added*](../images/ark_installing_console_azure_api_perm_conf.png) + +Fig. 6.50: Confirming that the permissions are added + +Then, click `Grant Permissions`. + +![*Granting permissions for the applications*](../images/ark_installing_console_azure_api_perm_grant.png) + +Fig. 6.51: Granting permissions for the applications + +When prompted, click `Yes` to confirm that you wish to grant access permissions. + +Repeat the process, adding permissions for `Microsoft Graph`. When adding permissions for Microsoft Graph, select a scale of `Read all users` full profiles. + +![*Sufficient resource permissions*](../images/ark_installing_console_azure_required_perm.png) + +Fig. 6.52: Sufficient resource permissions + +When you're finished granting permissions, the `Required permissions` list should include: + +- Wizard Azure Active Directory +- Windows Azure Service Management API +- Microsoft Graph + + + +## Configuring the Ark Console + +To access the Ark setup dialog and configure the console, open a browser window and navigate to the IP address assigned to the console. + +![*Logging in to the instance*](../images/ark_installing_console_azure_deploy.png) + +Fig. 6.53: Logging in to the instance + +When prompted, provide the console password. If you did not assign a password in a script identified as an extension (when creating the Azure virtual machine), a password will be created randomly, and stored in: + +`/usr/share/tomcat/startup-password.txt` + +To retrieve a system assigned password, ssh into the console host and invoke the following command: + +`$ more /usr/share/tomcat/startup-password.txt h020zdigm95xxqmjonrs` + +The Ark console setup dialog opens. + +![*The platform specific property fields*](../images/ark_installing_console_azure_props.png) + +Fig. 6.54: The platform specific property fields + +Use fields in the first portion of the setup dialog to provide platform specific information and configuration details for the Ark console. + +- Use the `Azure Subscription ID` field to specify the subscription ID for the Azure account that hosts the Ark console. You can locate the subscription ID on the Azure Subscriptions page. +- Use the `Azure Active Directory ID` field to specify the directory ID associated with the Azure account that hosts the Ark console. To locate the directory ID, navigate to the Azure Active Directory and select Properties. +- Use the `Azure Application Registration ID` field to specify the application ID associated with the Azure account that hosts the Ark console. To locate the application ID, select Enterprise applications or App registrations from the Azure Active Directory menu; use the application ID associated with the registration created for the Ark console. +- Use the `Service Account ID` field to specify the name of the Azure service account. The service account must be an owner of the resource group in which the Ark server is deployed. +- Use the `Service Account Password` field to specify the password associated with the service account. +- Use the `Azure Storage Account` field to specify the name of the Azure block storage account you wish to use with this Ark server. + +![*The general server property fields*](../images/ark_installing_console_azure_general_props.png) + +Fig. 6.55: The general server property fields + +The fields in the `General` properties section set values that control Ark behaviors: + +- Use the `Console DNS Name` field to specify a custom DNS name for the console. The property does not assign the DNS name to the console, but any notification emails that refer to the console will refer to the console by the specified name. If you do not provide a custom DNS name, the IP address of the console will be used in notifications. +- Use the `Contact Email Address` field to specify the address that will be included in the body of cluster status notification emails. +- Use the `Email From Address` field to specify the return email address specified on cluster status notification emails. +- Use the `Notification Email` field to specify the email address to which email notifications about the status of the Ark console will be sent. +- Set the `CC From Address` field to true to instruct Ark to send a copy of the email to the `Email From Address` anytime a notification email is sent. +- Use the `API Timeout` field to specify the number of minutes that an authorization token will be valid for use within the API. +- Use the `WAL Archive Container` field to specify the name of the storage container where WAL archives (used for point-in-time recovery) are stored. You must provide a value for this property; once set, this property must not be modified. +- Use the `Dashboard Docs URL` field to specify the location of the content that will be displayed on the Dashboard tab of the Ark console. If your cluster resides on a network with Internet access, set the parameter to DEFAULT to display content (documentation) from EnterpriseDB; to display alternate content, provide the URL of the content. To display no content in the lower half of the `Dashboard` tab, leave the field blank. +- Use the `Dashboard Hot Topics URL` field to specify the location of the content that will be displayed on the Dashboard tab of the Ark console. If your cluster resides on a network with Internet access, set the parameter to DEFAULT to display content (alerts) from EnterpriseDB; to display alternate content, provide the URL of the content. To display no content across the middle section of the `Dashboard` tab, leave the field blank. +- Use the `Enable Console Manager` field to indicate if the console should display console manager functionality. When set to `true`, the console will display the manager; when `false`, the manager will not be displayed. +- Set `Enable Postgres Authentication` to `true` to instruct Ark to enforce the authentication method configured on the backing Postgres server. Supported authentication methods include password, LDAP, RADIUS, PAM, and BSD. If set to `false`, Ark will use the default authentication method (`password`). +- Use the `Template Restrict New Users` field to configure the Ark console to make any new user a Template Only user by default. You can later modify the user definition in the User Administration table to specify that a user is not a template only user. +- Use the `Cluster Event Retention Limit` field to specify how long the console will keep events for deleted clusters. The default value is `14` days. + +![*The PEM server property fields*](../images/ark_installing_console_azure_pem_server_props.png) + +Fig. 6.56: The PEM server property fields + +Use fields in the next section to provide connection details for a PEM server host; this will allow Ark to register and unregister PEM agents and clusters. + +- Use the `PEM Server Mode` drop-down listbox to select a deployment mode: + + Select `DISABLE` to indicate that clusters deployed on the host should not be registered with the PEM server. + + Select `LOCAL` to indicate that you would like to use the PEM server that resides on your local host. If you select `LOCAL`, the PEM deployment will use default values assigned by the installer. + +- The IP address of the PEM server host will be the IP address of the Ark host. + +- The PEM Server Port will monitor port `5432`. + +- The PEM server database user will be named `postgres`. + +- The password associated with the PEM server will be the same password as the Ark console. + + Select `REMOTE` to indicate that you would like to use a PEM server that resides on another host, and provide connection information on the Ark console deployment dialog. If you select `REMOTE`, whenever a new cluster node is created on this console, it will be registered for monitoring by the PEM server. + +- Provide the IP address of the PEM server host in the `PEM Server IP Address` field. + +- Specify the port monitored for connections by the PEM server in the `PEM Server DB Port` field. + +- Specify the port on the PEM server host used for PEM API connection attempts by the Ark server in the `PEM Server API Port` field. Not valid if the PEM server mode is `DISABLED` or `LOCAL`. + +- Provide the name that should be used when authenticating with the PEM server in the `PEM Server Username` field. + +- Provide the password associated with the PEM server user in the `PEM Server Password` field. + +- Use the `PEM Sync Mode` drop-down listbox to `ENABLE` or `DISABLE` synchronization between the Ark server and the PEM server. + +- Use the `PEM Synchronization Interval` field to specify the number of minutes between attempts to synchronize the Ark console with the PEM server. + + + +![*Provide information about the service provider*](../images/ark_installing_console_azure_sp_props.png) + +Fig. 6.57: Provide information about the service provider + +If you specify `true` in the `SAML auth enabled` field, the Ark console will display the properties required to use SAML authentication when connecting to the Ark console. Use fields on the deployment dialog to specify SAML authentication properties. Use fields in the next section to provide information about the service provider: + +- Use the `SP Entity ID` field to provide a URI that specifies the identifier of the service provider. +- Use the `SP Consumer Service URL` field to specify the URL from which the response from the identity provider will be returned. +- Use the `SP Consumer Service Binding` field to specify the SAML protocol binding to be used when returning the response message from the identity provider. +- Use the `SP Logout Service URL` field to specify the URL to which the service provider will specify information about where and how the `Logout Response` message MUST be returned to the requester, in this case our service provider. +- Use the `SP Logout Service Binding` field to specify the SAML protocol binding to be used when returning the `LogoutResponse` or sending the `LogoutRequest` message. +- Use the `SP Name ID Format` field to specify the constraints on the name identifier that will be used to represent the requested subject. +- Use the `SP Certificate` field to specify certificate information; this is usually `x509cert`. The private key of the service files are provided by files placed in the `certs` folder. +- Use the `SP Private Key` field to specify the location of the service providers private key; this must be in `PKCS#8` format. + +![*Provide information about the identity provider*](../images/ark_installing_console_azure_idp_props.png) + +Fig. 6.58: Provide information about the identity provider + +Use fields in the next section to provide information about the identity provider: + +- Use the `IDP Entity ID` field to specify the identifier of the identity provider (this must be a URI). +- Use the `IDP Sign On URL` field to specify the URL target of the identity provider (where the service provider will send the Authentication Request Message). +- Use the `IDP Sign On Service Binding` field to specify the SAML protocol binding to be used when returning the response message. This version of Ark only supports the HTTP-Redirect binding. +- Use the `IDP Logout Service URL` field to specify the URL Location of the identity provider to which the service provider will send a single logout Request. +- Use the `IDP Logout Service Response URL` field to specify the URL Location of the identity provider to which the service provider will send a single logout response. +- Use the `IDP Single Logout Service Binding` field to specify the SAML protocol binding to be used when returning the response message. +- Use the `IDP Certificate` field to specify the Public x509 certificate of the identity provider. + +![*Provide information about your SAML preferences*](../images/ark_installing_console_azure_saml_props.png) + +Fig. 6.59: Provide information about your SAML preferences + +Use fields in the next section to provide your SAML preferences: + +- Use the `Encrypted Name ID` field to indicate that the name identifier of the `samlp:logoutRequest` sent by this service provider will be encrypted; specify `true` or `false`. +- Use the `Auth Request Signed` field to indicate if the `samlp:AuthnRequest` messages sent by this service provider will be signed; specify `true` or `false`. +- Use the `Logout Request` field to indicate if the `samlp:logoutRequest` messages sent by the service provider will be signed; specify `true` or `false`. +- Use the `Logout Response Signed` field to indicate if the `samlp:logoutResponse` messages sent by the service provider will be signed; specify `true` or `false`. +- Use the `Sign messages` field to sign the metadata. If you leave the field empty, the metadata will not be signed. If you wish to provide a signature, provide a comma separated `keyFileName`, `certFileName` pair. +- Use the `Sign assertions` field to indicate a requirement for the `samlp:Response`, `samlp:LogoutRequest`, and `samlp:LogoutResponse` elements received by the service provider to be signed; specify `true` or `false`. +- Use the `Sign Metadata` field to indicate that the metadata of this service provider must be signed; specify `true` or `false`. +- Use the `Encrypt Assertions` field to indicate that the assertions received by this service provider must be encrypted; specify `true` or `false`. +- Use the `Encrypt Name ID` field to indicate that the name identifier received by this service provider must be encrypted; specify `true` or `false`. +- Use the `Authentication Context` field to specify that `Set Empty` and `no AuthContext` will be sent in the `AuthNRequest`. You can set multiple values in a comma-delimited list. +- Use the `Auth Comparison Parameters` field to specify that the `authn` comparison parameter to be set; this field defaults to `exact`. +- Use the `XML validation` field to indicate if the service provider will validate all received xmls; specify `true` or `false`. +- Use the `Signature Algorithm` field to specify the algorithm that the toolkit will use for the signing process. Specify one of the following: + - `http://www.w3.org/2000/09/xmldsig#rsa-sha1` + - `http://www.w3.org/2000/09/xmldsig#dsa-sha1` + - `http://www.w3.org/2001/04/xmldsig-more#rsa-sha256` + - `http://www.w3.org/2001/04/xmldsig-more#rsa-sha384` + - `http://www.w3.org/2001/04/xmldsig-more#rsa-sha512` + +![*Provide information about your organization*](../images/ark_installing_console_azure_org_props.png) + +Fig. 6.60: Provide information about your organization + +Use fields in the next section to provide information about your organization: + +- Use the `Organization Name` field to specify the name of the organization for which authentication is being provided. +- Use the `Display Name` field to specify the display name of the organization. +- Use the `Organization URL` field to specify the URL of the organization. +- Use the `Organization Language` field to specify the primary language used by the organization. +- Use the `Technical Contact Name` field to specify the name of a technical contact. +- Use the `Technical Email Address` field to specify a contact email address for the technical contact. +- Use the `Support Contact Name` field to specify the name of a support contact. +- Use the `SAML Support Email Address` field to specify the email address of the SAML support contact. + +![*The console backup storage fields*](../images/ark_installing_console_azure_backup_props.png) + +Fig. 6.61: The console backup storage fields + +Use fields in the next section to provide information about the location of the console backup storage in the next section of the setup dialog; please note that you must provide values in these fields to use the Ark console recovery functionality: + +- Use the `Storage Bucket` field to specify the name of the container that will be used to store files for point-in-time recovery. This location may not change after the initial deployment of the Ark console. + + - A container name must be at least 3 and no more than 63 characters in length. + - A container name may contain lowercase letters, numbers, and the dash character (-). + - A container name must start with a lowercase letter or number. + + For more information, please [consult the Azure documentation](https://docs.microsoft.com/en-us/rest/api/storageservices/naming-and-referencing-containers--blobs--and-metadata). + +- Use the `Console Backup Folder` field to specify a folder in which the backups will be stored. + +![*The password fields*](../images/ark_installing_console_azure_password_props.png) + +Fig. 6.62: The password fields + +Use the password properties fields to modify the password for the database user: + +- Use the `DB User New Password` field to modify the database password. +- Use the `DB User Confirm Password` field to confirm the new password. + +![*The timezone field*](../images/ark_installing_console_azure_timezone_props.png) + +Fig. 6.63: The timezone field + +Use the last field to specify a timezone for the server: + +- Use the drop-down listbox in the `Timezone` field to select the timezone that will be displayed by the Ark console. + +When you've completed the dialog, click the `Save` button to validate and save your preferences; when prompted, click the `Restart` button to restart the console. + + + +## Connecting to the Administrative Console on an Azure Host + +When you navigate to the URL of the installed Ark console that uses Azure to host clusters, the console will display a login dialog. + +![*The Login dialog*](../images/ark_installing_console_azure_login.png) + +Fig. 6.64: The Login dialog + +Enter the name of an administrative user in the User Name field, and the associated password in the `Password` field, and click `Login` to connect to the Ark console. If the user name and password provided are members of a role with administrative privileges, the Ark console will include the `DBA` tab and the `Admin` tab. + +![*The Dashboard of the EDB Ark Administrator’s console*](../images/ark_installing_console_azure_admin_console.png) + +Fig. 6.65: The Dashboard of the EDB Ark Administrator’s console + +After connecting to the Ark console, you should: + +- Update the `User` tab, providing a `Notification Email`. For more information about the User tab, see the `EDB Ark Getting Started Guide`, available on the Ark `Dashboard`. +- Use the [Admin tab](../08_ark_admin_tab/#ark_using_admin_tab) to create the server images and database engines that will be used by non-administrative users. diff --git a/product_docs/docs/ark/3.5/ark_admin/06_ark_installing_console/index.mdx b/product_docs/docs/ark/3.5/ark_admin/06_ark_installing_console/index.mdx new file mode 100644 index 00000000000..caddd3399e7 --- /dev/null +++ b/product_docs/docs/ark/3.5/ark_admin/06_ark_installing_console/index.mdx @@ -0,0 +1,20 @@ +--- +title: "Installing the Ark Console" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-ark-platform/user-guides/administrative-users-guide/3.5/ark_installing_console.html" +--- + + + +Some features of the Ark Administrative console will not work properly when pop-up blocker (or Ad blocker) software is enabled. To take full advantage of console features, you should disable pop-up blocker software from restricting pop-ups from the URL/s used by the Ark console or Ark clusters. After disabling pop-up blocker software for your console, follow the platform specific steps to deploy an Ark console: + +- If your cluster resides on an Amazon public cloud, see [Installing the Ark Console on AWS](01_ark_installing_console_aws/#ark_installing_console_aws) for more information. +- If your cluster uses an Azure host, see [Installing the Ark Console on Azure](02_ark_installing_console_azure/#ark_installing_console_azure) for more information. + +
+ +ark_installing_console_aws ark_installing_console_azure + +
diff --git a/product_docs/docs/ark/3.5/ark_admin/07_ark_admin_features.mdx b/product_docs/docs/ark/3.5/ark_admin/07_ark_admin_features.mdx new file mode 100644 index 00000000000..a8396246fc2 --- /dev/null +++ b/product_docs/docs/ark/3.5/ark_admin/07_ark_admin_features.mdx @@ -0,0 +1,25 @@ +--- +title: "Administrative Features of the EDB Ark Console" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-ark-platform/user-guides/administrative-users-guide/3.5/ark_admin_features.html" +--- + + + +Administrative users have access through the Ark console to features that allow them to register server images and create database engine definitions that will be available for use by the non-administrative EDB Ark user. An administrator also has access to statistical information and console log files that are not available to the non-administrative user. + +For information about functionality that is exposed to both administrators and non-administrative users, please see the *EDB Ark Getting Started Guide*. + +When you navigate to the URL of the Ark console, the console will display a login dialog. + +![*The Login dialog*](images/ark_admin_features_login.png) + +Fig. 7.1: The Login dialog + +Enter the name of an administrative user in the *User Name* field, and the associated password in the *Password* field, and click Login to connect to the Ark console. The console opens as shown below. + +![*The EDB Ark Administrator’s console*](images/ark_admin_features_console.png) + +Fig. 7.2: The EDB Ark Administrator’s console diff --git a/product_docs/docs/ark/3.5/ark_admin/08_ark_admin_tab.mdx b/product_docs/docs/ark/3.5/ark_admin/08_ark_admin_tab.mdx new file mode 100644 index 00000000000..3777cb355a9 --- /dev/null +++ b/product_docs/docs/ark/3.5/ark_admin/08_ark_admin_tab.mdx @@ -0,0 +1,1077 @@ +--- +title: "Using the Admin Tab" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-ark-platform/user-guides/administrative-users-guide/3.5/ark_admin_tab.html" +--- + + + +Use options on the `Admin` tab to perform administrative tasks such as creating federations of consoles, managing servers and database engines, and defining templates. You can also use the `Admin` tab to manage users and deployment properties. + +![*The Admin tab.*](images/ark_admin_features_admin_tab.png) + +Fig. 8.1: The Admin tab. + +**Console Manager** + +Use the fields in the `Console Manager` panel to: + +- Make a console available through the `Consoles` drop-down navigation listbox on the Ark console. +- Generate a token that can be used to configure the current console as part of a *federation* of Ark consoles. A federated console can deploy resources (such as standby servers) on another console that resides in another region. +- Register other consoles with the current console as part of a *federation* of consoles. + +For more information, see [Using the Console Manager](#using-the-console-manager). + +**Server Type Administration** + +A fresh installation of EDB Ark will include default database engine configurations for: + +- EDB Postgres Advanced Server 9.4, 9.5, 9.6, 10.0, and 11 (64-bit) +- PostgreSQL 9.4, 9.5, 9.6, 10.0, and 11 (64-bit) + +For information about adding additional servers, see [Managing Server Images](#managing-server-images). + +**DB Engine Administration** + +The databases made available through the `DB Engine Administration` panel will be disabled and will not have an associated server type or valid repository information. To make a database available for end users, you must: + +- Create one or more server images that correspond to a server that resides on your system. For more information about defining a server type, see [Managing Server Images](#managing-server-images). +- Use the `Edit Engine Details` button to modify existing engine definitions to specify a server image associated with the engine and repository information (if applicable), and enable the engine for use by end-users. + +For more information, see [Managing Database Engines](#managing-database-engines). + +**Template Administration** + +Use the `Template Administration` panel to create and manage database cluster templates. A template contains a predefined set of server options that determine the configuration of a cluster. + +An administrator can use a template to: + +- simplify creation of clusters that use a common configuration. +- predefine supported cluster configurations. +- limit access to server resources for a *Template Only* user. A Template Only user must use a template when deploying a new cluster. + +For more information about creating and using a template, see [Template Administration](#template-administration). + +**RHEL Subscription Management** + +Options in the `RHEL Subscription Management` panel allow you to: + +- Add, modify, or delete RHEL subscription information. + +For more information, see [Red Hat Subscription Management](#red-hat-subscription-management). + +**IAM Roles Administration (AWS only)** + +Options in the `IAM Roles Administration` panel allow you to: + +- Make Amazon ARNs available for use in Ark user accounts (AWS). + +For information about user administration options, see [Managing Amazon Roles](#managing-amazon-roles). + +**User Administration** + +Options in the `User Administration` panel allow you to: + +- If applicable, manage user accounts. +- Access a list of currently connected users. +- Display a banner message to connected users. +- Specify that a user must use a template when deploying a cluster. + +For information about user administration options, see [User Administration](#user-administration). + +**Download Console Logs** + +Click the `Download` button in the `Download Console Logs` panel to download a zip file that contains the server logs for the underlying application server. You can use the log file to confirm changes to server status or verify server activity. + +For more information, see [Accessing the Console Logs](#accessing-the-console-logs). + +**Download Core Usage Logs** + +Click the `Download` button in the `Download Core Usage Logs` panel to download a zip file that contains the usage logs for the underlying server. + +For more information, see [Accessing the Core Usage Logs](#accessing-the-core-usage-logs). + +**Backup Ark Console** + +Click the `Backup Now` button to start a console backup. A popup will confirm that you have requested a manual backup of the console. + +For more information, see [Taking a Manual Backup of the Console](#taking-a-manual-backup-of-the-console). + +**Edit Installation Properties** + +Click the `Edit installation properties` button to open a dialog that allows you to modify the Ark console configuration. For more information, see [Editing Installation Properties](#editing-installation-properties). + +## Using the Console Manager + +Use fields in the `Console Manager` panel to manage the names and links displayed by the `Consoles` drop-down listbox on the Ark console. You can also use the Console Manager to manage federated consoles and provide access to cross-region resources. The console manager provides access to optional functionality; if you are not federating consoles or do not wish to use the `Consoles` drop-down, you are not required to complete the fields in the panel. + +For more information about creating and using federated consoles, see [Using the Console Manager to Create a Federated Console](#register_federated_console). + +![*The Consoles drop-down.*](images/ark_admin_tab_console_switcher.png) + +Fig. 8.2: The Consoles drop-down. + +The `Consoles` drop-down listbox (in the upper-right corner of the Ark console) provides quick access to other consoles. When you select a name from the `Consoles` drop-down listbox, the Ark console opens a browser tab and navigates to the address associated with the name. Use the `Console Manager` section of the `Admin` tab to manage the console names and addresses that are displayed in the `Consoles` drop-down. + +![*The Console Manager panel*](images/ark_admin_tab_console_switcher_pane.png) + +Fig. 8.3: The Console Manager panel + +To enable the `Consoles` drop-down, you must first provide a name for the console to which you are currently connected in the `Name for this Console` field. + +![*Provide a name for the console.*](images/ark_admin_tab_console_switcher_enable.png) + +Fig. 8.4: Provide a name for the console + +After providing the console name, click the `Save Name` button to display the name of the console in the upper-left corner of the Ark console, and in the `Consoles` drop-down. To add a shortcut to another console, click the `Add URL` button; the `Add URL` dialog opens. + +![*Saving the console name.*](images/ark_admin_tab_console_switcher_add_url.png) + +Fig. 8.5: Saving the console name. + +Then, use the `Add Console` dialog to provide information about the console for which you are creating a `Consoles` entry: + +- Provide a user-friendly name in the `Name` field. +- Provide the URL of the console in the `Url` field; please note that the URL must be prefixed with the http protocol identifier. +- Optionally, provide the API token associated with the console in the `API Token` field. This field is only required when you are federating consoles. + +When you're finished, click the `Save` button to add the console to the list displayed on the `Consoles` drop-down. + +To modify an entry in the `Consoles` drop-down, highlight the name of the console in the `NAME` column and click the `Edit URL` button. After modifying the console details on the `Edit URL` dialog, click the `Apply` button to preserve the changes. Click `Cancel` to exit the dialog without saving your changes. + +To remove a URL, highlight the name of the URL in the `NAME` column and click the `Delete URL` button. A dialog will open, asking you to confirm that you wish to delete the URL. + +![*Deleting a console.*](images/ark_admin_tab_console_switcher_delete_url.png) + +Fig. 8.6: Deleting a console. + +Click the `Delete` button to confirm that you want to remove the entry from the `Consoles` drop-down and delete the entry from the `Console Manager` table, or click `Cancel` to exit the dialog without deleting the entry. + + + +### Using the Console Manager to Create a Federated Console + +You can use fields in the `Console Manager` panel to generate and share access tokens between consoles to create a *federation* of consoles. After creating a federation, you can create or clone cluster members in any region in which one of the federated consoles resides. A federated console may have resources that reside in more than one region; standby nodes that reside in other regions will reflect the state of the master node. + +!!! Note + Each federation may only contain one console from a specific region; if you try to add more than one console from a given region to a federation, Ark will return an error. + +When creating a federation, please note: + +- All of the federated consoles must be configured with the same set of database engines and server images: + + - Each database engine must have the same configuration across all federated consoles (including the engine id and name). + - Each server image must have the same configuration across all federated consoles; the image id will vary by region. + +For example, you might have two consoles; one that resides in Region `us-east-1` and one that resides in Region `us-east-2`. You can create a federation of those consoles by *registering* the consoles with each other. After registering the consoles (sharing the URL and token of each console within the federation with the other console), you will be allowed to select the `Region` in which replica nodes are created or cloned. + +![*Selecting a region.*](images/ark_admin_tab_create_cross_region.png) + +!!! Note + Standby nodes that reside in a different region than the master console will be used for load balancing. Failover to nodes that reside on a different region than the master node is not supported. If a master node fails and you do not have a standby node in the same region as the master node, Ark will create a replacement node in the same region as the original master. + +All of the resources that reside on federated consoles will be visible on the `Clusters` tab of all of the consoles within the federation. To federate consoles you must: + +1. Use the `Name for this Console` field to create a name for each console that will be federated. Click within the field and provide a console name; when finished, click the `Save Name` button. The console name will be displayed on the title bar of the Ark console. + +![*Providing a console name.*](images/ark_admin_tab_name_console.png) + +Fig. 8.8: Providing a console name. + +2. Click the `Generate API Token` button to create a token for the console. The API token is displayed in the `API Token for this Console` field. + +![*Generating an API token.*](images/ark_admin_tab_generate_token.png) + +Fig. 8.9: Generating an API token. + +3. Use the `Add Console` dialog on each console within the federation to register the other consoles with which they will be federated. + +![*Registering a console.*](images/ark_admin_tab_register_console.png) + +Fig. 8.10: Registering a console. + +After registering each with all of the other consoles within the federation, you will be allowed to create resources in any region in which the federated consoles reside. + +**Revoking a Token** + +Select the `Revoke API Token` button to revoke the token assigned to the console. + +![*Confirm you wish to revoke the token.*](images/ark_admin_tab_token_revoke.png) + +Fig. 8.11: Confirm you wish to revoke the token. + +If the console is a member of a federation, the other members of the federation will no longer be able to create resources in the area in which the console resides. To restore membership in a federation, you must generate a new token for the console and edit the console definitions of the other federation members, updating the token associated with the console. + +After creating a federation, you can: + +- Log in to any federated console and initiate a cluster backup. +- Log in to any federated console and delete a cluster. +- Initiate a clone operation regardless of the region in which the node resides. +- Log in to any federated console and initiate a yum update on a cluster. +- Scale a federated cluster in multiple regions. +- Perform machine scaling on a cluster that resides on a federated console. + + + +## Managing Server Images + +A server definition describes the virtual machine that will host an instance of Advanced Server or PostgreSQL. Use the `Server Type Administration` panel to manage server images. + +![*The Server Type Administration section of the Admin tab*](images/ark_admin_tab_manage_server_pane.png) + +Fig. 8.12: The Server Type Administration section of the Admin tab + +**Creating a Server Image** + +To create a new server image, connect to the Ark console as a user with administrative privileges, navigate to the Admin tab, and select `Add Server`. The `Add Server` dialog opens. + +![*The Add Server dialog*](images/ark_admin_tab_create_server.png) + +Fig. 8.13: The Add Server dialog + +Use the fields on the `Add Server` dialog to define a new server: + +- Use the `Server ID` field to provide an identifier for the server image. The `Server ID` must be unique, and may not be modified after saving the server image. +- Use the `Server Description` field to provide a description of the server image. +- Use the `Image ID` field to provide the Image ID of the server image. + +**On Amazon** + +If you are using Ark with Amazon, provide the `AMI ID` in the `Image ID` field. Please note: you should use a server from a trusted source, with a virtualization type of hvm. We recommend using the official Amazon images from the Amazon AWS Marketplace. + +**On Azure** + +If you are using an Ark with Azure, you can use the Azure CLI interface to retrieve a list of the machine images that are available in the Azure Marketplace. Review the Azure documentation for information about [downloading and installing the Azure CLI](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli). After installing the Azure CLI, you can use one of the following commands to retrieve a list of the available images for a specific platform and version: + +| Version | Command | +| --------- | ------------------------------------------------------------- | +| RHEL 7: | az vm image list --offer RHEL --sku 7. --output table --all | +| CentOS 7: | az vm image list --offer CentOS --sku 7. --output table --all | + +Select an image from a trusted publisher; when configuring the Ark console, provide the first three elements of the Urn column in the `Server Image ID` field. For example, if the Urn returned by the CLI is `RedHat:RHEL:7.2:7.2.20160921 7.2.20160921`, the Image ID is `RedHat:RHEL:7.2`. + +Some recommended images and providers are: + +- RedHat:RHEL:7-RAW +- OpenLogic:CentOS:7.5 + +Use the `Initial User` field to provide the name of the default operating system user. This user must have `sudo root` privileges to perform the initial provisioning of software on the node. + +If you are using an Amazon AWS Marketplace image, the default user name is associated with the backing image; for more information about image user identities, review [the AWS documentation](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AccessingInstancesLinux.html). + +- Use the `System Type` field drop-down listbox to select the operating system type of the server; select CentOS or RHEL. +- Check the box next to `Statically Provisioned` to indicate that the server is statically provisioned. A statically provisioned server is a pre-installed image that contains the software required to create a database cluster. + +For detailed information about creating a statically provisioned image, please see Section 11. + +When you have completed the dialog, click Save to create the server image, or Cancel to exit without saving. + +**Modifying a Server** + +Click the `Edit Server Details` button to open the `Edit Server Details` dialog and modify the properties of a server. + +![*The Edit Server dialog*](images/ark_admin_tab_modify_server.png) + +Fig. 8.14: The Edit Server dialog + +After modifying the server definition, click `Save` to make the changes persistent and exit the dialog, or `Cancel` to exit without saving. + +**Deleting a Server** + +To delete a server definition, highlight a server name, and select the `Delete Server` button. If no engines are dependent on the server, a dialog will open, asking you to confirm that you wish to delete the selected server type. + +![*The Delete Server Type dialog*](images/ark_admin_tab_delete_server.png) + +Fig. 8.15: The Delete Server Type dialog + +Select the `Delete` key to remove the server, or `Cancel` to exit without removing the server. + +![*You cannot remove a server with dependencies*](images/ark_admin_tab_delete_server_error.png) + +Fig. 8.16: You cannot remove a server with dependencies + +Please note: If the server is currently used by an engine, the Ark console will advise you that the server cannot be removed; before removing the server, you must delete any dependent engines. + + + +## Managing Database Engines + +An engine definition pairs a Postgres server type with the server image on which it will reside. Only an EDB Ark administrative user can define an engine. Once defined, all of the engines that reside within a specific role or group will be made available to all users with access to that group. You can use the `DB Engine Administration` section of the Admin tab to create and manage database engines. + +![*The DB Engine Administration section of the Admin tab*](images/ark_admin_tab_manage_db_engine_pane.png) + +Fig. 8.17: The DB Engine Administration section of the Admin tab + +**Please note:** The EnterpriseDB repository structure has changed; after upgrading your Ark console to v3.5, you will have a combination of old and new DB engine configurations in the Ark Admin panel. You should migrate to the new DB engines for all new clusters since these contain the proper EDB YUM repository configuration. + +The Ark console ships with a number of default engine definitions. Before using an engine, you must create a server (see [Managing Server Images](#managing-server-images)) and edit the engine details, associating a server with the engine you wish to use and enabling the engine. + +The following engines are shipped with Ark. Engine definitions may include multiple repositories to provide access to all of the packages required to complete the installation. Advanced Server repositories require you to provide a USERNAME and associated PASSWORD; for credentials, visit the [EnterpriseDB website](https://info.enterprisedb.com/rs/069-ALB-339/images/Repository%20Access%2004-09-2019.pdf). + +**PostgreSQL 9.4 64bit on CentOS / RHEL 7** + +```text +https://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm +https://USERNAME:PASSWORD@yum.enterprisedb.com/edb-repo-rpms/edb-repo-latest.noarch.rpm + +Required Packages: postgresql94-server pgpool-II-94 edb-pem-agent +``` + +**EDB Postgres Advanced Server 9.4 64bit on CentOS / RHEL 7** + +```text +https://USERNAME:PASSWORD@yum.enterprisedb.com/edb-repo-rpms/edb-repo-latest.noarch.rpm + +Required Packages: ppas94-server ppas-pgpool34 ppas94-pgpool34-extensions edb-pem-agent +``` + +**PostgreSQL 9.5 64bit on CentOS / RHEL 7** + +```text +https://yum.postgresql.org/9.5/redhat/rhel-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm +https://USERNAME:PASSWORD@yum.enterprisedb.com/edb-repo-rpms/edb-repo-latest.noarch.rpm + +postgresql95-server pgpool-II-95 edb-pem-agent +``` + +**EDB Postgres Advanced Server 9.5 64bit on CentOS / RHEL 7** + +```text +https://USERNAME:PASSWORD@yum.enterprisedb.com/edb-repo-rpms/edb-repo-latest.noarch.rpm + +Required Packages: ppas95-server ppas-pgpool34 ppas95-pgpool34-extensions edb-pem-agent +``` + +**PostgreSQL 9.6 64bit on CentOS / RHEL 7** + +```text +https://yum.postgresql.org/9.6/redhat/rhel-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm +https://USERNAME:PASSWORD@yum.enterprisedb.com/edb-repo-rpms/edb-repo-latest.noarch.rpm + +Required Packages: postgresql96-server pgpool-II-96 edb-pem-agent +``` + +**EDB Postgres Advanced Server 9.6 64bit on CentOS / RHEL 7** + +```text +https://USERNAME:PASSWORD@yum.enterprisedb.com/edb-repo-rpms/edb-repo-latest.noarch.rpm + +Required Packages: pkgs: edb-as96-server edb-pgpool35 edb-as96-pgpool35-extensions edb-pem-agent +``` + +**PostgreSQL 10 64bit on CentOS / RHEL 7** + +```text +https://yum.postgresql.org/10/redhat/rhel-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm +https://USERNAME:PASSWORD@yum.enterprisedb.com/edb-repo-rpms/edb-repo-latest.noarch.rpm + +Required Packages: postgresql10-server pgpool-II-10 pgpool-II-10-extensions edb-pem-agent +``` + +**EDB Postgres Advanced Server 10 64bit on CentOS / RHEL 7** + +```text +https://USERNAME:PASSWORD@yum.enterprisedb.com/edb-repo-rpms/edb-repo-latest.noarch.rpm + +Required Packages: edb-as10-server edb-pgpool36 edb-as10-pgpool36-extensions edb-pem-agent +``` + +**PostgreSQL 11 64bit on CentOS / RHEL 7** + +```text +https://yum.postgresql.org/11/redhat/rhel-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm +https://USERNAME:PASSWORD@yum.enterprisedb.com/edb-repo-rpms/edb-repo-latest.noarch.rpm + +Required Packages: postgresql11-server pgpool-II-11 pgpool-II-11-extensions edb-pem-agent +``` + +**EDB Postgres Advanced Server 11 64bit on CentOS / RHEL 7** + +```text +https://USERNAME:PASSWORD@yum.enterprisedb.com/edb-repo-rpms/edb-repo-latest.noarch.rpm + +Required Packages: pkgs: edb-as11-server edb-pgpool37 edb-as11-pgpool37-extensions edb-pem-agent +``` + +**PostgreSQL 12 64bit on CentOS / RHEL 7** + +```text +https://yum.postgresql.org/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm +https://USERNAME:PASSWORD@yum.enterprisedb.com/edb-repo-rpms/edb-repo-latest.noarch.rpm + +Required Packages: postgresql12-server pgpool-II-12 pgpool-II-12-extensions edb-pem-agent +``` + +**EDB Postgres Advanced Server 12 64bit on CentOS / RHEL 7** + +```text +https://USERNAME:PASSWORD@yum.enterprisedb.com/edb-repo-rpms/edb-repo-latest.noarch.rpm + +Required Packages: edb-as12-server edb-pgpool40 edb-as12-pgpool40-extensions edb-pem-agent +``` + + + +## Adding, Modifying, or Deleting Engine Definitions + +Use the `Add Engine` dialog to define an engine. To access the `Add Engine` dialog, connect to the Ark console as a user with administrative privileges, navigate to the `Admin` tab, and select `Add Engine`. + +![*The Add Engine dialog*](images/ark_admin_tab_add_db_engine.png) + +Fig. 8.18: The Add Engine dialog + +Use the fields on the `Add Engine` dialog to define a new server image/database pairing; please note that some fields are disabled if the server is statically provisioned: + +- Use the `ID` field to provide an identifier for the engine. Please note that the identifier must be unique, and may not be modified after saving the engine. + +- Use the drop-down listbox in the `DB Type` field to select the type of database used in the pairing. + +- Use the drop-down listbox in the `Version` field to specify the server version. + +- Use the `Name` field to provide a name for the pairing. When the engine is enabled, the specified name will be included for use on the `Create Cluster` dialog. + +- Use the drop-down listbox in the `Server Type` field to specify the server image on which the database will reside. The drop-down listbox displays those images previously defined on the Add Server dialog. + +- Use the drop-down listbox in the `RHEL Subscription` field to select the Red Hat Subscription Manager service that will be used by the engine. To populate the RHEL Subscription drop-down, describe your subscription services in the RHEL Subscription Management section of the Admin tab. RHEL Subscription Manager services are only applicable for RHEL 7 clusters. + + Please note that you must delete any instances that use an engine that is associated with a RHEL subscription before you can delete the RHEL subscription. + +- Use the `Yum repo URL` field to provide the URL of the yum repository that will be used to initially provision database packages and to later update the database packages during cluster upgrade operations. When specifying multiple repositories in the Yum repo URL field, specify one repository per line. When you perform an update, any available updates in all of the specified repositories will be applied. The repository URL should take the form: + + `http://:@` + + Where: + + `user_name` specifies the name of a user with sufficient privileges to access the repository. + + `password` specifies the password associated with the repository user. Please note that if your password contains special characters (such as a $), you may need to percent-encode the characters. + + `repository_url` specifies the URL of the repository. + + Please contact your EnterpriseDB account manager if you need connection credentials for the EnterpriseDB repositories, or visit [the EnterpriseDB website](https://www.enterprisedb.com/advanced-downloads). + +- Use the `Required DB Packages` field to provide a space-delimited list of packages that have been tested by EDB as the required minimum set to build a functional cluster instance. + +When defining a database engine, you must specify the required package list for the installation in the Required DB packages field on the `Edit Engine Details` dialog. + +For an Advanced Server 9.4 database, the package list must include: + +```text +ppas94-server +ppas-pgpool34 +ppas95-pgpool34-extensions +pem-agent +``` + +For an Advanced Server 9.5 database, the package list must include: + +```text +ppas95-server +ppas-pgpool34 +ppas95-pgpool34-extensions +pem-agent +``` + +For an Advanced Server 9.6 database, the package list must include: + +```text +edb-as96-server +edb-pgpool35 +edb-as96-pgpool35-extensions +pem-agent +``` + +For an Advanced Server 10 database, the package list must include: + +```text +edb-as10-server +edb-pgpool36 +edb-as10-pgpool36-extensions +pem-agent +``` + +For an Advanced Server 11 database, the package list must include: + +```text +edb-as11-server +edb-pgpool37 +edb-as11-pgpool37-extensions +edb-pem-agent +``` + +For an Advanced Server 12 database, the package list must include: + +```text +edb-as12-server +edb-pgpool40 +edb-as12-pgpool40-extensions +edb-pem-agent +``` + +For a PostgreSQL 9.4 database, the package list must include: + +```text +postgresql94-server +pgpool-II-94 +pem-agent +``` + +For a PostgreSQL 9.5 database, the package list must include: + +```text +postgresql95-server +pgpool-II-95 +pem-agent +``` + +For a PostgreSQL 9.6 database, the package list must include: + +```text +postgresql96-server +pgpool-II-96 +pem-agent +``` + +For a PostgreSQL 10 database, the package list must include: + +```text +postgresql10-server +pgpool-II-10 +pgpool-II-10-extensions +pem-agent +``` + +For a PostgreSQL 11 database, the package list must include: + +```text +postgresql11-server +pgpool-II-11 +pgpool-II-11-extensions +edb-pem-agent +``` + +For a PostgreSQL 12 database, the package list must include: + +```text +postgresql12-server +pgpool-II-12 +pgpool-II-12-extensions +edb-pem-agent +``` + +- Use the `Optional Node Packages` field to provide the names of any packages that should be installed (from the specified repository) on every cluster node during provisioning. + +Please note: packages added via the `Optional Node Packages` field on the master node of the cluster will also be provisioned on any standby nodes that are subsequently created. If the package requires manual configuration steps, you will be required to repeat those steps on each node of the cluster; package configurations will not be propagated to standby nodes. If you add a node through cluster operations (such as failover, scaling, or restoring a node from backup), any packages on the new node will require manual configuration. + +When you have completed the dialog, click `Save` to create the engine definition, or `Cancel` to exit without saving. + +For information about using the EnterpriseDB repository, and the Advanced Server packages available, please see the [EDB Postgres Advanced Server Installation Guide](http://www.enterprisedb.com/products-services-training/products/documentation/enterpriseedition). + +**Modifying an Engine** + +To modify an engine, use the `Edit Engine Details` button to open the `Edit Engine Details` dialog. + +![*The Edit Engine Details dialog*](images/ark_admin_tab_modify_db_engine.png) + +Fig. 8.19: The Edit Engine Details dialog + +Use fields on the Edit Engine dialog to specify property changes to an engine. When you’re finished, click the `Save` button to make the changes persistent and exit, or `Cancel` to exit without saving. + +**Disabling an Engine** + +You can use the disabled box to specify that an engine is (or is not) available for use in new clusters without removing the engine definition: + +- If the box next to disabled is checked, the engine will not be available for use. +- If the box next to disabled is unchecked, the engine will be available for use. + +Click the `Save` button to make any changes to the `Edit Engine Details` dialog persistent, or select `Cancel` to exit without modifying the engine definition. + +Please note that disabling an engine has no impact on any running clusters; it simple prevents users from creating new clusters with the engine. You can use this feature to phase out the use of older engines. + +**Deleting an Engine** + +To delete an engine, highlight an engine name in the `DB Engine Administration` list, and select the `Delete Engine` button. A dialog will open, asking you to confirm that you wish to delete the selected engine. + +![*The Delete DB Engine dialog*](images/ark_admin_tab_delete_db_engine.png) + +Fig. 8.20: The Delete DB Engine dialog + +Click the `Delete` button to remove the engine definition, or select `Cancel` to exit without removing the engine definition. + +Please note that you cannot remove an engine that is referenced by one or more clusters and/or backups; if you attempt to remove an engine that is in use, EDB Ark will display a warning message. + + + +## Adding Supporting Components to a Database Engine Definition + +When you create a cluster, you specify the engine that EDB Ark will use when provisioning that cluster. If you modify the engine description, adding the list of RPM packages that will be installed when that engine is provisioned, each node of any cluster provisioned with that engine will include the functionality of the supporting component. + +**Adding PostGIS to a Database Engine** + +To simplify PostGIS installation, add a list of the required RPM packages to the `Optional Node Packages` field of the `Edit Engine Details` dialog. To provision replicas that contain the PostGIS functions, perform the installation and create the extensions on the master node of the cluster before adding replica nodes to your cluster. + +To modify an engine description, use Administrative credentials to connect to the Ark console, and navigate to the `Admin` tab. Select an engine ID from the list of engines in the `DB Engine Administration` list, and click `Edit Engine Details`. + +![*Modifying the Engine Details dialog*](images/ark_admin_tab_add_postgis_db_engine.png) + +Fig. 8.21: Modifying the Engine Details dialog + +When the `Edit Engine Details` dialog opens, use the fields on the dialog to specify the repository information and the names of optional RPM packages that the installer should provision on each node of the cluster. + +- The PostGIS RPM packages are distributed from the `enterprisedb tools` repository; by default, the `enterprisedb tools` repository is included in the `Yum Repo URL` field. +- Add the names of the PostGIS RPM packages to the `Optional Node Packages` field on the `Edit Engine Details` dialog. + +The PostGIS installation packages for Advanced Server 9.4 are: + +`ppas94-postgis` + +`ppas94-postgis-core` + +`ppas94-postgis-docs` + +`ppas94-postgis-utils` + +The PostGIS installation packages for Advanced Server 9.5 are: + +`ppas95-postgis` + +`ppas95-postgis-core` + +`ppas95-postgis-docs` + +`ppas95-postgis-utils` + +The PostGIS installation packages for Advanced Server 9.6 are: + +`edb-as-96-postgis` + +`edb-as-96-postgis-core` + +`edb-as-96-postgis-docs` + +`edb-as-96-postgis-utils` + +The PostGIS installation packages for Advanced Server 10 are: + +`edb-as-10-postgis` + +`edb-as-10-postgis-core` + +`edb-as-10-postgis-docs` + +`edb-as-10-postgis-utils` + +The PostGIS installation packages for Advanced Server 11 are: + +`edb-as-11-postgis` + +`edb-as-11-postgis-core` + +`edb-as-11-postgis-docs` + +`edb-as-11-postgis-jdbc` + +`edb-as-11-postgis-utils` + +Any EDB Ark clusters that are subsequently provisioned with that engine will automatically include an installation of the PostGIS on all nodes of the cluster. + +**Creating the PostGIS Extensions** + +After adding the packages to the master node of a cluster, you can use the psql client or the EDB Postgres Enterprise Manager (PEM) client to create the extensions. Before connecting with a client, an Administrator must open the listener port (by default, `5444` on an Advanced Server instance) of the node for connections. + +Use a client to connect to the database in which you wish to create the extensions, and enter the following commands: + +```text +CREATE EXTENSION postgis; +CREATE EXTENSION fuzzystrmatch; +CREATE EXTENSION postgis_topology; +CREATE EXTENSION postgis_tiger_geocoder; +``` + +The client will confirm that the extensions have been created successfully. The PostGIS functions are created in the public schema of the database. + +Visit the PostGIS project site for detailed information about using [PostGIS](http://postgis.net/documentation/). + + + +## Template Administration + +A template contains a predefined set of server options that determine the configuration of a database cluster. A template can simplify creation of clusters that use a common configuration, or limit user access to costly resources such as large server classes. Use functionality offered in the `Template Administration` panel to create and manage templates. + +![*The Template Administration section of the Admin dashboard*](images/ark_admin_tab_template_pane.png) + +Fig. 8.22: The Template Administration section of the Admin dashboard + +Use the `TEMPLATES ONLY` column of the `User Administration` table to specify that a user must use a template. A `Template Only` user will have access to only those templates that specify a role or tenant in which they have membership in the `Select Roles` section of the `Add Template` dialog. + +If a user is specified as a `Template Only` user: + +- They must use a template when deploying a cluster. +- They will be restricted to the scaling policies defined in the template. +- They cannot modify a manually-defined cluster created by another user. +- They can only create clusters in a server class that exists in an available template. +- They must use a template when cloning or restoring from backup. +- They may only delete backups of template created clusters. +- They may not delete last backup of a template created cluster if the cluster had been deleted (removing the last artifact of any cluster). + +To create a template, click the `Add Template` button; the `Add Template` dialog opens. + +![*The Template Administration section of the Admin dashboard*](images/ark_admin_tab_add_template.png) + +Fig. 8.23: The Template Administration section of the Admin dashboard + +Use fields on the `Add Template` dialog to define a new template: + +- Provide a user-friendly name for the template in the `Template Name` field. +- Use the `Description` field to provide a description of the template. +- Use the drop-down listbox in the `Engine Version` field to select the version of the Postgres engine that you wish to use on clusters configured by the template. +- Use the drop-down listbox in the `Server Class` field to specify the size of each cluster node. The server class determines the size and type (compute power and RAM) of any cluster configured by the template. +- If your cluster resides on an Amazon AMI, use the drop-down listbox in the `VPC` field to specify the identity of the network in which clusters configured by the template should reside. +- Use the drop-down listbox in the `Number of nodes` field to specify the number of nodes that should be created in each cluster. +- Use the `Storage GB` field to specify the initial size of the data space (in Gigabytes). +- Check the box next to `Encrypted` to indicate that the cluster should be encrypted. EDB Ark uses the aes-xts-plain (512-bit) cipher suite to provide an encryption environment that is both secure and transparent to connecting clients. When encryption is enabled, everything residing on the cluster is encrypted except for the root filesystem. +- If the cluster will reside on an AWS host, check the box next to `EBS Optimized` to specify that the cluster should use an Amazon EBS-optimized instance and provisioned IOPS to guarantee a level of I/O performance. +- The `IOPS` field is enabled for those clusters that will reside on an EBS-optimized instance. If applicable, specify the level of I/O performance that will be maintained for the cluster by automatic scaling. The maximum value is 30 times the size of your cluster; for example, if you have a 4 Gigabyte cluster, you can specify a maximum value of 120. +- Check the box next to `Perform OS and Software` update to specify that a software update should be performed whenever the cluster is provisioned. Please note: this option is disabled if the cluster uses a statically provisioned server. +- Use the `Number of backups` field to specify the number of backups that will be retained for the cluster. When the specified number of server backups is reached, EDB Ark will delete the oldest backup to make room for a new backup. +- Use the `Backup Window` field to specify a time that it is convenient to perform a cluster backup. +- Check the box next to `Continuous Archiving (Point-in-Time Recovery)` to enable point-in-time recovery for the cluster. When enabled, a base backup is automatically performed that can to be used to restore to a specific point in time. All subsequent automatic scheduled backups will also support point-in-time recovery. +- Check the boxes next to the options in the `Select Scaling Options` box to indicate which options will be available to template users. Check the box next to: + - `Manually Scale Replicas` to specify that users of this template will be allowed to manually scale replica nodes configured by this template. + - `Manually Scale Storage` to specify that users of this template will be allowed to manually scale storage on clusters configured by this template. + - `Auto Scale Replicas` to specify that users of this template will be able to configure automatic node scaling for clusters configured by this template. + - `Auto Scale Storage` to specify that users of this template will be able to configure automatic storage scaling for clusters configured by this template. +- Check the box to the left of a role name in the `Select Roles` box to indicate that members of the selected role can use the template. + +When you've completed the `Add Template` dialog, click `Save` to create the defined template; click `Cancel` to close the dialog and exit without saving your work. + +If you select `Launch From Template` on the `Create a New Server Cluster` dialog, you will be prompted to select the template you wish to use from the `Template Name` drop-down listbox. After selecting a template, you can use the `Full Template Details` link to open a popup that displays detailed information about the configuration of clusters deployed with the template. + +![*The template details popup*](images/ark_admin_tab_template_details.png) + +Fig. 8.24: The template details popup + + + +## Red Hat Subscription Management + +You can use the Ark Administrative console to attach Red Hat Subscription Manager information to engines hosted on Red Hat consoles. The Red Hat Subscription Manager tracks installed products and subscriptions to implement content management with tools like yum. Visit the Red Hat website for information about [Red Hat Subscription Manager](https://access.redhat.com/documentation/en/red-hat-subscription-management/). + +When you create a new cluster that uses an engine that is associated with a Red Hat subscription, Ark registers the cluster nodes with Red Hat; when you terminate the node, the system's subcription is unregistered. + +Use the `RHEL Subscription Management` section of the Admin tab to define and manage Red Hat Subscription Manager access for your Ark consoles that reside on Red Hat Linux instances. + +![*The RHEL Subscription Management section.*](images/ark_admin_tab_rhel_sub_mgmt_pane.png) + +Fig. 8.25: The RHEL Subscription Management section. + +After creating a subscription definition, use options in the `DB Engine Administration` panel to associate the definition with database engines. + +![*The Add RHEL Subscription dialog*](images/ark_admin_tab_add_rhel_sub.png) + +Fig. 8.26: The Add RHEL Subscription dialog + +Use fields on the `Add RHEL Subscription` dialog to describe a Red Hat subscription service: + +- Use the `Subscription ID` field to provide a user-friendly name for the subscription. The name will identify the subscription in the RHEL Subscription drop-down on the Add Engine Details dialog. +- Use the `Username` field to provide the name of the user account registered with the Red Hat content server. +- Use the `Password` field to provide the password associated with the user account. +- Use the `Server URL` field to provide the host name of the subscription server used by the service; if left blank, the default value of subscription.rhn.redhat.com will be used. +- Use the `Base URL` field to provide the host name of the content delivery server used by the service; if left blank, the default value of will be used. +- Use the `Org` field to provide the organization that will be registered with the Red Hat subscription system. +- Use the `Environment` field to provide the name of the environment (within the organization that will be registered). +- Use the `Name` field to provide the name of the system that will be registered. +- Use the `Activation Key` field to provide the activation key of the Red Hat subscription. +- If enabled, use the `Auto-attach` checkbox to instruct any node associated with the subscription to automatically attach to the service. +- If applicable, use the `Pool` field to provide the pool identifier for the Red Hat subscription service. +- If applicable, check the `Auto` checkbox to indicate that nodes provisioned with engines associated with the pool will automatically attach to the subscription service. +- If applicable, use the `Quantity` field to provide the number of subscriptions in the subscription pool. +- Use the `Service Level` field to provide the service level of the subscription. +- Use the `Release` field to provide the operating system minor release that will be used when identifying updates to any nodes provisioned with the subscription. +- Check the `Force` checkbox to indicate that the node should be registered, even if it is already registered. +- Use the `Type` field to specify the type of consumer that is being registered; the default is system. +- The `Required Repos` list is populated by the Ark console, and displays a list of the repositories required by the subscription definition. +- Use the `Additional Repos` field to provide the names of any additional repositories that should be enabled on the cluster node(s). +- Use the `Disabled Repos` field to provide the names of any repositories that should be disabled on the cluster node(s). + +When you've completed the dialog, click the `Save` button to add the repository to the table in the RHEL Subscription Management section, or `Cancel` to exit without saving. If you choose to save the definition, the Ark console will display a popup that lists the subscription manager commands that were generated as a result of your selections. + +![*RHEL Subscription details*](images/ark_admin_tab_rhel_sub_details.png) + +Fig. 8.27: RHEL Subscription details + +After creating a subscription definition, use options in the `DB Engine Administration` section of the `Admin` tab to associate the definition with database engines; see [Managing Database Engines](#managing-database-engines) for detailed information. + +**Modifying a RHEL Subscription Definition** + +To modify the description of a Red Hat Subscription Manager service, highlight the name of a subscription in the `RHEL Subscription Management` table, and click the `Edit RHEL Subscription` button. The `Edit RHEL Subscription Details` dialog opens, allowing you to modify the subscription definition. + +After modifying the subscription definition, click `Save` to preserve your changes and exit the dialog; to exit without saving, click the `Cancel` button. Please note that changes made to a definition are applied only to those instances that are created after the changes are saved; changes are not propagated to existing instances. + +**Deleting a Red Hat Subscription Definition** + +Before deleting a Red Hat subscription service definition, you must: + +- Modify any database engines that are associated with the subscription, disassociating the engine definition from the Red Hat subscription. +- Delete any instances that were created using an engine that is associated with the Red Hat subscription service. + +Then, to delete a Red Hat Subscription Manager service from the list in the Ark console, highlight the name of a service and click the `Delete RHEL Subscription` button. + +![*Confirming that you wish to delete a subscription description*](images/ark_admin_tab_delete_rhel_sub.png) + +Fig. 8.28: Confirming that you wish to delete a subscription description + +Click the `Delete` button to confirm that you wish to delete the subscription definition, or `Cancel` to exit without deleting the definition. + + + +## Managing Amazon Roles + +Amazon Role ARNs that are listed in the `IAM Roles Administration` table will be available on the `Role` drop-down listbox of the `Add User` dialog. Please note that before adding a Role ARN to the table you must define the role in the AWS management console, and the trust policy of the role must include the External Id of the Ark console. + +![*The Roles Administration dialog*](images/ark_admin_tab_aws_role_pane.png) + +Fig. 8.29: The Roles Administration dialog + +You can use the `Add Role` dialog to add an entry to the table. To locate the information required by the Add Role dialog, connect to the Amazon Management dashboard, and navigate to the `Roles` page. Select the role you wish to add from the list to open the `Summary` dialog; then, select the `Trust relationships` tab to display the information required. + +![*The Roles Administration dialog*](images/ark_admin_tab_aws_role_arn.png) + +Fig. 8.30: The Roles Administration dialog + +To add a Role ARN to the table, click the `Add Role` button; the `Add Role` dialog opens. + +![*The Roles Administration dialog*](images/ark_admin_tab_aws_add_role.png) + +Fig. 8.31: The Roles Administration dialog + +Use fields on the dialog to provide details from the Amazon management console: + +- Provide the `Role ARN` from the `Summary dialog` header in the `Role Arn` field. +- Provide the `Value` from the `Trust relationships` tab in the `External Id` field. + +Click the `Apply` button to verify the information, and add the entry to the table. + + + +## User Administration + +Options in the `User Administration` panel provide extended management functionality for an administrative user. The functionality offered is host and configuration specific. + +![*User administration features of the Amazon console*](images/ark_admin_tab_user_pane.png) + +Fig. 8.32: User administration features of the Amazon console + +Depending on your host type and configuration, you can use `User Administration` options to: + +- add, modify, or delete a user account. +- delete clusters or snapshots that belong to a user account. +- display a list of logged in users. +- add, modify, or remove a wall message. +- specify that a user must use a template when deploying a cluster. + +**Adding a User** + +If available for your configuration, you can click the `Add User` button to access the `Add User` dialog and register a new user account for the Ark console. + +![*The Add User dialog on an Amazon host*](images/ark_admin_tab_add_user.png) + +Fig. 8.33: The Add User dialog on an Amazon host + +Provide information about the user account: + +- Use the `Login` field to provide the identifier that the user will provide when logging in to the console; each identifier must be unique. +- Provide the user's first name in the `First Name` field. +- Provide the user's last name in the `Last Name` field. +- To allow the user administrative access to the Ark console, check the box next to `Admin`. +- Check the box next to `Enabled` if the user should be allowed to log in to the console. +- Check the box next to `Templates Only` to specify that a user must use a template when deploying a cluster. +- If applicable, provide a password associated with the user account in the `Password` field. +- If applicable, confirm the password in the `Verify Password` field. +- If applicable, select a previously defined Amazon role ARN from the drop-down list in the `Role` field, or copy a different role ARN into the field. The role ARN must be defined on the AWS console by an Amazon administrator. Each role will be able to access all clusters that are created by users that share the common role ARN. To create an isolated user environment, a user must have a unique Amazon role ARN. + +If you copy an Amazon role ARN into the `Role` field, a popup will open, prompting you for the AWS ExternalId associated with the user. To locate the ExternalId, connect to the Amazon management console, and navigate to the `IAM Roles` page. Select the role name from the list, and then click the `Trust Relationships` tab. The ExternalId associated with the Role ARN is displayed in the `Conditions` section of the `Summary` page. + +**Modifying User Properties and Reviewing User Activity** + +If the `Edit User` button is displayed, you can use the `Edit User` dialog to modify user properties. Highlight a user name, and click the `Edit User` button to open the `Edit User` dialog. Enabled fields on the `Details` tab may be modified; use the `Info` tab to review information about the user account and account activities. + +After making changes to modifiable fields, click the `Save` button to make the changes persistent. Click `Cancel` to exit without saving any changes. + +**Deleting User Objects** + +If enabled, you can use buttons below the `User Administration` table to manage user objects. Highlight a user name, and click: + +- The `Delete Clusters` button to delete all clusters that belong to the selected user. +- The `Delete Snapshots` button to delete any cluster backups that belong to the selected user. + +After deleting the objects owned by a user, you can use the `Delete User` button to remove the user account. To delete a user, highlight the name of a user in the user table, and click the `Delete User` button. The Ark console will ask you to confirm that you wish to delete the selected user before removing the account. Click `Delete` to remove the user account, or `Cancel` to exit the popup without deleting the account. + + + +## User Administration on an Amazon Host + +You can use the `User Administration` table to register new users for the Ark console, edit user properties, or delete a user account. Please note that you must use a client application to connect to the Ark console and add the user to the postgres database before the user is allowed to connect. + +![*The user table of an AWS console*](images/ark_admin_tab_user_admin_aws_host.png) + +Fig. 8.34: The user table of an AWS console + +Columns within the `User Administration` table provide information about the current AWS console users: + +- The user's login name is displayed in the `ID` column. +- The user's first name is displayed in the `FIRST NAME` column. +- The user's last name is displayed in the `LAST` NAME column. +- Check the box next to a user name in the `ADMIN` column to indicate that the user should have administrative access to the Ark console. +- Check the box next to a user name in the `ENABLED` column to indicate that the account is active. +- Check the box in the `TEMPLATES ONLY` column to indicate that the user must use templates when deploying clusters. +- The number of clusters currently owned by the user is displayed in the `CLUSTERS` column. +- The number of cluster snapshots owned by the user is displayed in the `SNAPSHOTS` column. +- The date and time of the last login is displayed in the `LAST LOGIN` column. The time zone displayed is based on the time zone used by the operating system. +- The `LOGINS` column displays a cumulative total of the number of times that the user has logged in. + +After adding the user to the Ark console, use the psql client application to add the user to the backing `postgres` database. To use the psql client, SSH to the host of the Ark console. Then, navigate into the `bin` directory, and connect to the psql client with the command: + +`./psql –d postgres –U postgres` + +When prompted, supply the password of the postgres database user. After connecting to the database, you can use the `CREATE ROLE` command to add a user to the database: + +`ADD USER user_name WITH PASSWORD 'password';` + +Where: + +`user_name` specifies the name of the Ark user. + +`password` specifies the password associated with the user name. + +Please note: The user name and associated password specified in the Ark backing database must match the credentials specified when registering the user in the Ark console. + +For detailed information about using the psql client please see the [Postgres core documentation](https://www.enterprisedb.com/docs/en/10/pg/app-psql.html). + +After the administrative user adds the end-user, the end-user will complete the registration process by navigating to the URL of the console, and logging in. + +Use the buttons below the AWS user table to manage user accounts for the AWS console and user-owned objects. + + + +## User Administration on an Azure Host + +You can use the `User Administration` table to register new users for the Ark console, edit user properties, or delete a user account. Please note that you must use a client application to connect to the Ark console and add the user to the postgres database before the user is added to the table or allowed to connect. + +![*User administration table on the Azure console*](images/ark_admin_tab_user_admin_azure_host.png) + +Fig. 8.35: User administration table on the Azure console + +Use the check boxes to modify user access privileges: + +- Check the box next to a user name in the `ADMIN` column to indicate that the user should have administrative access to the Ark console. +- Check the box next to a user name in the `ENABLED` column to indicate that the account is active. +- Check the box in the `TEMPLATES ONLY` column to indicate that the user must use templates when deploying clusters. + +Use the `Refresh` button to update the table. + + + +## Displaying Connected Users + +Click the `Show logged in users` button to display the `Logged in users` popup. + +![*The Logged in users list*](images/ark_admin_tab_display_connected.png) + +Fig. 8.36: The Logged in users list + +The dialog displays: + +- The current number of empty sessions; an empty session is an http session with the server that is not associated with a logged-in user. +- The current number of sessions with a logged-in user. +- A list of the currently logged-in users. + +When you’re finished reviewing the list, use the `X` in the upper-right corner of the popup to close the dialog. + + + +## Managing the Wall Message + +Provide a message in the `Message` field and click the `Display Message` button to add an announcement to the top of the user console. A message may include HTML tags to control the displayed format, and will wrap if the message exceeds the width of the screen. + +![*Modifying the Wall Message*](images/ark_admin_tab_wall_message_pane.png) + +Fig. 8.37: Modifying the Wall Message + +The console may take a few seconds to refresh. Once processed by the server, the message will be displayed to console users when their screens refresh. + +![*Displaying a wall message*](images/ark_admin_tab_wall_message.png) + +Fig. 8.38: Displaying a wall message + +Use the `Remove Message` button to remove the wall banner. + + + +## Accessing the Console Logs + +Use the `Download Console Logs` panel to download a zip file that contains the server logs for the underlying application server. You can confirm changes to server status or verify server activity by reviewing the application server log file. + +![*The Download Console Logs section of the Admin tab*](images/ark_admin_tab_access_console_logs.png) + +Fig. 8.39: The Download Console Logs section of the Admin tab + +You can also review the console logs via an ssh session. Log files are stored in `/var/log/edb-ark`. The current log file is `/var/log/edb-ark/ark.log`. + +You can use the Linux tail utility to display the most recent entries in any of the server logs. For example, to review the last 10 lines in the server log file, connect to the console host with ssh and enter: + +`tail file_name` + +Where `file_name` specifies the complete path to the log file. + +You can include the `-F` option to instruct the `tail` utility to display only the last 10 lines of the log file, and new log file entries as they are added to the file: + +`tail -F file_name` + + + +## Accessing the Core Usage Logs + +Use the `Download Core Usage Logs` panel to download a zip file that contains the core usage by managed clusters on an hourly basis. + +![*The Download Core Usage Logs section of the Admin tab*](images/ark_admin_tab_access_core_usage_logs.png) + +Fig. 8.40: The Download Core Usage Logs section of the Admin tab + +The zip file contains a report with four columns; the columns contain: + +- The date and time that the entry was written. +- The database type; either `ppas` for Advanced Server, or `postgres` for PostgreSQL. +- The database version. +- The total number of cores running in that region. + + + +## Taking a Manual Backup of the Console + +Use the `Backup Ark Console` panel to request a manual backup of the Ark console begin. + +![*The Backup Ark Console section of the Admin tab*](images/ark_admin_tab_take_manual_backup.png) + +Fig. 8.41: The Backup Ark Console section of the Admin tab + +Click the `Backup Now` button to start a console backup; the backup will be uploaded to the currently configured object storage service. + + + +## Editing Installation Properties + +Use the option displayed in the `Edit Installation Properties` panel to review or modify Ark console properties. + +![*The Edit Installation Properties section*](images/ark_admin_tab_edit_inst_prop_pane.png) + +Fig. 8.42: The Edit Installation Properties section + +Click the `Edit installation properties` button to open the `Edit Installation Properties` dialog. Use fields on the dialog to modify the properties of the Ark console. When you've finished, click `Save` to preserve your changes and restart the console server, or `Cancel` to exit the dialog without saving the changes. + +For detailed descriptions of each field: + +- For an Amazon-hosted console, review the AWS [deployment instructions](06_ark_installing_console/01_ark_installing_console_aws/#ark_installing_console_aws). +- For an Azure-hosted console, review the Azure console [deployment instructions](06_ark_installing_console/02_ark_installing_console_azure/#ark_installing_console_azure). diff --git a/product_docs/docs/ark/3.5/ark_admin/09_ark_dba_tab.mdx b/product_docs/docs/ark/3.5/ark_admin/09_ark_dba_tab.mdx new file mode 100644 index 00000000000..d7389bf6800 --- /dev/null +++ b/product_docs/docs/ark/3.5/ark_admin/09_ark_dba_tab.mdx @@ -0,0 +1,51 @@ +--- +title: "Using the Ark DBA Tab" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-ark-platform/user-guides/administrative-users-guide/3.5/ark_dba_tab.html" +--- + + + +The DBA tab displays views that contain information about current clusters and cluster creation history. The tab is accessible only to administrative users. + +![*The Ark DBA tab*](images/ark_dba_tab.png) + +Fig. 9.1: The Ark DBA tab + +Use the `Choose table/view` drop down listbox to select a view. + +![*The table/view listbox*](images/ark_dba_tab_drop_down.png) + +Fig. 9.2: The table/view listbox + +When the view opens, click a column heading to sort the view by the contents of the column; click a second time to reverse the sort order. Use the `Refresh` button to update the contents of the view. + +## Accessing User Information + +Use the user information links in the lower-left corner of the DBA tab to download a comma-delimited list of users and user information. + +![*The Contact information links*](images/ark_dba_tab_user_info.png) + +Fig. 9.3: The Contact information links + +The file contains the information provided on the `User` tab of the Ark console by each user: + +- The user identifier. +- The default email address of the user. +- The first name of the user. +- The last name of the user. +- The status of the user account (`TRUE` if enabled, `FALSE` if disabled). +- The company name with which the user is associated. + +Select a link to download user information: + +- Click `Contact information` for enabled users to download a file that contains only those users that are currently enabled. +- Click `Contact information` for all users to download a file that contains user information of all users (enabled and disabled). + +
+ +ark_dba_tables + +
diff --git a/product_docs/docs/ark/3.5/ark_admin/10_ark_console_management.mdx b/product_docs/docs/ark/3.5/ark_admin/10_ark_console_management.mdx new file mode 100644 index 00000000000..fdad9b796f8 --- /dev/null +++ b/product_docs/docs/ark/3.5/ark_admin/10_ark_console_management.mdx @@ -0,0 +1,303 @@ +--- +title: "Console Management" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-ark-platform/user-guides/administrative-users-guide/3.5/ark_console_management.html" +--- + + + +The sections that follow provide information about managing the EDB Ark application server. + +## Starting, Stopping or Restarting the Ark Console + +Apache Tomcat is an opensource project that deploys Java servlets on behalf of the Ark console. To start, stop, or restart the application server, use ssh to connect to the host of the Ark console database. Then, use sudo to assume sufficient privileges to restart the console: + +`sudo su -` + +Then, use systemctl to start, stop, or restart the server. + +To start the server: + +`systemctl start tomcat` + +To stop the server: + +`systemctl stop tomcat` + +To restart the server (if it is already running): + +`systemctl restart tomcat` + +## Changing Console Passwords + +A fresh installation of the Ark console includes a PostgreSQL installation that is used to manage the console; the management database is named postgres. By default, the database superuser has the following connection credentials: + +name: `postgres` password: `0f42d1934a1a19f3d25d6288f2a3272c6143fc5d` + +You should change the password on the PostgreSQL server to a unique password (known only to trusted users). You can set the password when you deploy the console or modify the password later on the `Edit Installation Properties` dialog. To open the `Edit Installation Properties` dialog, navigate to the `Admin` tab of the Ark console and click the `Edit Installation Properties` button. + +![*Changing console passwords*](images/changing_console_passwords.png) + +Fig. 10.1: Changing console passwords + +Fields near the bottom of the dialog allow you to modify the password: + +- Use the `DB User New Password` field to modify the database password. +- Use the `DB User Confirm Password` field to confirm the new password. + +After providing a new password and confirming the password, click the `Save` button. The console will inform you that it needs to restart the server to complete the password change. When prompted, click the `Restart` button. When the restart is complete, you will be required to log in to the server again. + +**Please note:** if you modify the password of the Ark console, the password of the PEM server that resides on the Ark console will change as well. When using the PEM web interface to connect to the PEM server, use the password assigned to the Ark console. + +## Customizing the Console + +The majority of the console layout is defined in source files and cannot be changed without compilation, but you can modify several aspects of the user interface, including: + +- Background images +- Background colors +- Fonts +- Font colors + +To change the colors, fonts, or images displayed by the console, you can use ssh to connect to the console host; once connected, use your choice of editor to modify the files that control the onscreen display. + +**Modifying the Console Display** + +To modify the console display, use ssh to connect to the host of the Ark console: After connecting to the console host, you can use your choice of editor to modify the files that control the look and feel of the console host. + +**Please Note: We recommend that you make a backup of any file that you plan to modify before changing the file.** + +**The css File** + +The css rules for the EDB Ark user console are stored in the `styles.css` file. The file is located at: + +`/usr/share/tomcat/webapps/PPCDConsole/WEB‑INF/classes/VAADIN/themes/pcsconsole/styles.css` + +Please refer to comments within the file for detailed information about modifying individual components within the console display. + +Some modifications to the styles.css file will be visible when you reload the page in your browser; if a change is not immediately visible, restart the server to apply the changes. If a change is not visible after restarting the server, you may need to clear your browser cache. + +**The images Directory** + +To modify the images that are displayed by the console user interface, replace the `.png` files in the `images` directory with the images you wish to display. The `images` directory is located at: + +`/usr/share/tomcat/webapps/PPCDConsole/VAADIN/themes/pcsconsole/images` + +Please note that the logo displayed on the login screen is defined in the `i18n.properties` file; for more information about modifying the logo image, please refer to comments in that file. + +**The html Template File** + +The `loginscreen.html` template file defines the page layout for the login screen and the terms of use URL (referenced on the login screen). The file is located at: + +`/usr/share/tomcat/webapps/PPCDConsole/WEB-INF/classes/com/enterprisedb/pcs/ui/loginscreen.html` + +**The properties File** + +Use the `i18n.properties` file to modify text and external URLs displayed in the Ark console. The `i18n.properties` file is located at: + +`/usr/share/tomcat/webapps/PPCDConsole/WEB-INF/classes/i18n.properties` + +Comments within the `i18n.properties` files identify the onscreen information controlled by each entry in the file. You must restart the server to apply any modifications to the properties file. + +## Managing Console Logs + +By default, Ark console log files are written to `/var/log/edb-ark/ark.log`. Log files are rotated on a daily basis, and stored for 30 days. + +You can use the `ark.server.level` property to manage the level of detail saved in the Ark console log files. The `ark.server.level` property resides in: + +`/usr/share/tomcat/webapps/PPCDConsole/WEB-INF/classes` + +To modify the value, connect to the Ark console, and use your choice of editor to modify the property value. The valid values are: + +| Property Value | Information Logged | +| -------------- | ------------------------------------------------------------------------------------------------ | +| SEVERE | Includes the least amount of information in the log files (i.e., exceptions and ERROR messages). | +| WARNING | Includes WARNING messages. | +| INFO | Includes informational messages about server activity. | +| CONFIG | Includes messages about configuration changes. | +| FINE | This is the default; provides detailed information about server activity. | +| FINER | Includes a higher level of detail about server activity. | +| FINEST | Provides the highest level of detail about server activity. | + +After modifying the properties file, restart the server to make the changes take effect: + +`sudo systemctl restart tomcat` + +## Upgrading the Console + +The steps that follow provide detailed instructions about upgrading the Ark console. Before upgrading the console, you must ensure that no users are connected to the console, and that there are no cluster operations (backup, cloning, etc) in progress; you may wish to alert users to the pending upgrade with a wall message. + +Use the `Show logged in users` button on the Admin tab to confirm that no users are connected to the console, and check the server log (located in `/var/log/edb-ark/ark.log`) to confirm that all server activities have completed. Then: + +1. Use ssh to connect to the node on which the Ark console resides, and assume root privileges: + + `sudo su -` + +2. With your choice of editor, modify the repository configuration file (located in `/etc/yum.repos.d`), enabling the `edb-ark` repository URL. + + + +```text +[edb-ark] +name=EnterpriseDB EDB Ark +baseurl=http://:@yum.enterprisedb.com/edb-ark/redhat/rhel-\\$releasever-\\$basearch +enabled=0 +gpgcheck=0 +gpgkey=file:///etc/pki/rpm-gpg/ENTERPRISEDB-GPG-KEY +``` + +To enable the repository, replace the `` and `` placeholders with your user name and password, and set enabled to `1`. + +3. Use the `yum list edb-ark` command to review a list of available updates. + + `yum list edb-ark` + +4. If any updates are available, use yum to install the updates: + + `yum update package_ name` + + Where `package_name` specifies the name of the package that you wish to update. + +5. When the downloads complete, navigate into the `/usr/share/tomcat/` directory: + + `cd /usr/share/tomcat` + +6. Invoke the EDB Ark post-installation script to upgrade the console: + + `./postInstall.sh` + + The installation script will prompt you to confirm that the console is not in use, and that you wish to continue with the installation. + + + +```text +[root@ip-172-31-15-135 yum.repos.d]# /usr/share/tomcat/postInstall.sh +Script will upgrade the application! Is the EDB-ARK console in a steady state (no logged in users, no activity in the console)? +Are you sure you want to continue? y +Updating EDB-ARK Application... +Stopping httpd and tomcat services... +Deploying the latest application in tomcat +Starting httpd and tomcat services... +Done! +``` + +When the `yum update` completes, navigate to the Ark URL in your browser, and enter the account password. You will be taken to the Ark deployment dialog where you will be required to provide the `Service Account ID` and `Service Account Password`; provide any missing values, select a `Time Zone`, and restart the Ark server. Ark will open to the `Login` dialog. + +## Updating a PEM Installation + +If you are using a local installation of PEM to monitor an Ark console, you may want to update your version of PEM to a more recent version. To update your PEM installation: + +1. Ensure that the `edb-ark.repo` file is enabled and contains your connection credentials: + + Use ssh to connect to the Ark console host, and navigate to the `/etc/yum.repos.d` directory. Then, use your choice of editor to update the `edb-ark.repo` file. + + + +```bash +[edb-ark] +name=EnterpriseDB EDB-ARK $releasever - $basearch +baseurl=https://:@yum.enterprisedb.com/edb-ark/redhat/rhel-$releasever-$basearch +enabled=0 +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/ENTERPRISEDB-GPG-KEY +[edb-tools] +name=EnterpriseDB Tools $releasever - $basearch +baseurl=https://:@yum.enterprisedb.com/tools/redhat/rhel-$releasever-$basearch +enabled=0 +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/ENTERPRISEDB-GPG-KEY +[edb-dependencies] +name=EnterpriseDB Dependencies $releasever-$basearchbaseurl=https://:@yum.enterprisedb.com/dependencies/redhat/rhel-$releasever-$basearch +enabled=0 +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/ENTERPRISEDB-GPG-KEY +``` + +Modify the repository details, replacing each `` and `` placeholder with your credentials for the EnterpriseDB repository, and setting enabled to `1`. To request credentials for the repository, please visit the [EnterpriseDB website](https://www.enterprisedb.com/advanced-downloads). + +2. Assume superuser privileges. + + `sudo su` + +3. Use yum to update the PEM agent and PEM server version installed on your Ark console host: + + `yum install edb-pem-python-idna.noarch` + + `yum update edb-pem edb-pem-server` + +4. When the installation completes, configure the updated PEM server: + + `/usr/edb/pem/bin/configure-pem-server.sh -dbi /usr/pgsql-10 -d /var/lib/pgsql/10/data/ -ho 127.0.0.1 -p 5432 -su postgres -sp -t 1 -ci 0.0.0.0/0 -ds postgresql-10 -acp ~/.pem/` + + Where `` is the password of the Ark console. + + For more information about using PEM, please see the [PEM user guides](/pem/latest/). + +## Recovering From a Console Failure + +User and instance information used by the Ark console is stored in tables in a Postgres database. If the console application should fail, the information will persist in the console database, and will be available when the console application restarts. + +If the system hosting the application database fails, then all information about the console database and registered users will be lost unless you have retained a backup. + +The Ark console is configured to take automatic backups of the console database hourly, and after the registration of each new user. If you do not wish to use the Ark backup script to implement backups, you should maintain regular backups of your console database. + +Please note: the Ark recovery utility only supports recovering the console from a backup that is the same version as the current console version. + +## Modifying Backup Properties with the EDB Ark Console + +You can use the `Installation Properties` dialog to modify console backup properties; to modify the properties, navigate to the Admin tab, and click the Edit Installation Properties button. + +![Console management](images/ark_console_mgmt_modify_backup_props.png) + +When the `Edit Installation Properties` dialog opens, you can modify details about the console backup storage: + +- Use the `Backup Script` field to specify the name and location of the backup script provided with EDB Ark. If you choose to provide your own backup script, use the parameter to specify the name and location. + +- Use the `DB Name` field to specify the name of the console database; the default is `postgres`. + +- Use the `Directory to Store Backups` field to specify a directory to which backups will be written. Please note that you must create the directory specified. + + The backup directory specified should not reside on the console VM's root disk; your backup would be lost in the event of a VM failure. You should consider mounting an external volume to the console VM, and writing console database backups to that volume. + +- Use the `DB User Name` field to specify the name of the console database user; the default is postgres. + +- Use the `DB User Password` field to specify the password associated with the console database user; the default password is: + + `0f42d1934a1a19f3d25d6288f2a3272c6143fc5d` + +- Use the `Storage Bucket` field to specify the name of the swift storage container that will be used to store files for point-in-time recovery. This location should not change after the initial deployment of the Ark console. + +- Use the `Console Backup Folder` field to specify a folder in which the backups will be stored. + +- Use the `Storage Tenant` field to provide the name of the tenant in which the backup will be stored. + +## Using the Recover Option + +If the console cannot locate a registered user, and your console is configured to support console backups, the Ark console login dialog will request the password specified during setup and display the `Deploy Console` or `Recover from Backup` options when you navigate to the console address. + +![*The connection dialog*](images/ark_console_mgmt_recover.png) + +Fig. 10.2: The connection dialog + +To initiate a console recovery, provide the console password specified when you deployed the console instance (in the Amazon management console), and click the Recover from Backup button. The console properties dialog opens, prompting you for information about console backups. + +Use the dialog to provide details about the console, and the location of a backup to recover. When you're finished, click the Recover button to start the recovery process. A popup will open, prompting you for the name of the backup folder that you wish to use for the recovery. + +Use the `Folder name` drop-down listbox to select the backup you wish to use for the recovery, and click `Finish` to start the recovery process. If your system is monitored by a local PEM server, the backup will attempt to restore both the Ark and PEM servers. + +## Manually Recovering from Console Backups + +If you wish to manually save backups, you can use the Postgres [pg_dump](http://www.enterprisedb.com/docs/en/9.6/pg/app-pgdump.html) or [pg_dumpall](http://www.enterprisedb.com/docs/en/9.6/pg/app-pg-dumpall.html) command to archive the console database. Then, you can then use the [pg_restore](http://www.enterprisedb.com/docs/en/9.6/pg/app-pgrestore.html) command to restore the console database if necessary. + +**Recovering the Console with a Backup Script** + +The backup script provided with the Ark console uses pg_dump to create a plain-text SQL script file that contains the commands required to rebuild the console database to the state in which the backup was taken. After using ssh to connect to the host of the console, you can use the following command to invoke the psql command line tool and restore the console: + +``` +/usr/bin/psql –h localhost –p 5432 –d postgres –U postgres -f <(echo truncate sequence\\;; cat ``recovery_file`` +``` + +Where `recovery_file` specifies the path and name of the backup file you wish to restore. + +While restoring a console instance, you should shut down the application server so that the console application isn't actively using the database. When the restoration is complete, restart the application server. diff --git a/product_docs/docs/ark/3.5/ark_admin/11_ark_securing_ark.mdx b/product_docs/docs/ark/3.5/ark_admin/11_ark_securing_ark.mdx new file mode 100644 index 00000000000..9ad60e02f21 --- /dev/null +++ b/product_docs/docs/ark/3.5/ark_admin/11_ark_securing_ark.mdx @@ -0,0 +1,122 @@ +--- +title: "Securing EDB Postgres Ark" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-ark-platform/user-guides/administrative-users-guide/3.5/ark_securing_ark.html" +--- + + + +Each cluster has an associated security group that specifies the addresses from which the cluster will accept connections. By default, the security group exposes only port `9999` (the load balancing port) to the outside world, while allowing inter-cluster communication, and console-to-cluster communication between the servers in the cluster. + +You can modify the security group, strategically exposing other ports for client connection. For example, you may wish to open port `22` to allow ssh connections to a server, or port `5444` to allow connections to the listener port of the Advanced Server database server that resides on a replica node. + +EDB Ark assigns the same security group to every member of a cluster. By default, the security group contains rules that specify that any cluster member may connect to any other member's ICMP port, TCP port or UDP port. These rules do not permit connections from hosts on the public Internet. You *must not* alter these security rules. + +Additional rules open TCP ports `7800-7802` to the cluster manager, allowing the cluster manager to perform maintenance and administrative tasks. Please note that the rules governing connections from the cluster manager *must* remain open to allow: + +- intra-cluster communications +- communication with the console or cluster manager +- maintenance and administrative functionality + +The rule for TCP port `9999` uses a CIDR mask (`0.0.0.0/0`) to specify that port `9999` is open for connections from any IP address. You can customize this rule, selectively restricting the IP addresses from which computers are allowed to connect to a given port within the cluster. + +Please note that EDB Ark provides a secure environment for all communications within the cluster, and between the cluster and the the console or cluster manager by employing SSH authentication and SSL encryption. + +## Modifying a Security Group for an Amazon AWS Hosted Console + +Security groups for Ark clusters that reside on an AWS host are managed through the Amazon management console; Amazon administrative privileges are required to review or modify the security group entries. + +To manage a security group for a cluster, connect to the AWS management console, and locate the cluster on the Instances dashboard. Highlight the cluster name, and scroll through the columns to the right. Click the name of the security group (in the Security Groups column) to review detailed information about the rules that are currently defined for the cluster. + +To modify a security group and add a rule that allows connections from an outside client (such as ssh), navigate to the Inbound tab, and click the Edit button. When the Edit inbound rules dialog opens, click the Add Rule button to add a new line to the list of rules. + +![Editing the inbound rules](images/ark_securing_ark_editing_inbound_rules.png) + +Fig. 11.1: Editing the Inbound Rules + +Specify the rule type, the protocol type, the port (or port range) on which inbound connections will be accepted, and the CIDR-formatted address from which you will be connecting. + +Consult the core documentation for more information about specifying a [CIDR address](http://www.postgresql.org/docs/10/static/datatype-net-types.html). + +When you've defined the rule, click Save to add the entry to the inbound rules list. + +Please consult the [Amazon documentation](http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_SecurityGroups.html) for detailed information about managing the security group for a virtual private cloud. + +## Using ssh to Access a Server + +EDB Ark creates an ssh key when you create a new cluster; each cluster has a unique key. Before connecting to a Postgres instance that resides on the cloud via an ssh encrypted connection, you must download the ssh key, and adjust the privileges on the key file. + +To download your private key, navigate to the Clusters tab, and click the Download SSH Key icon. The Accessing Your Cluster Instance popup opens. + +![Using SSH](images/ark_securing_ark_using_ssl.png) + +Fig. 11.2: Accessing your Cluster Instance + +The popup displays the tenant name, the cluster name, the name that you should use when connecting to the cluster, and the IP address to which you should connect. + +Before using the private key, you must modify the permissions on the keyfile. Use the following command to restrict file permissions: + +`chmod 0600 .pem` + +Where \\<ssh_key_file>.pem specifies the complete path and name of the EDB Ark ssh private key file. + +After modifying the key file permissions, you can use ssh to connect to the cluster. Include the complete path to the key file when invoking the command provided on the Accessing Your Cluster Instance popup. + +Please note: Postgres Server applications must be invoked by the Postgres cluster owner (identified when creating an EDB Ark cluster as the Master User). If you are using a PostgreSQL server, the default user name is postgres; if you are using Advanced Server, the default user name is enterprisedb. To change your identity after connecting via ssh, use the su command: + +`# sudo su database_user_name` + +## Using iptables Rules + +If you are using iptables rules to manage security on the host of the Ark console, please note that you must not modify the iptables rules provided by EDB Ark. + +If you are using iptables on the host of the Ark console, do not modify the following rules: + +`iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 –j REDIRECT --to-port 8080` + +`iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 443 –j REDIRECT --to-port 8181` + +`iptables -I INPUT 1 -p tcp --dport 8181 -j ACCEPT` + +`iptables -I INPUT 1 -p tcp --dport 8080 -j ACCEPT` + +These rules: + +- redirect http and https traffic on ports `80` and `443` to the default ports (`8080` and `8181`). +- allow inbound traffic on `8080` and `8181`. +- save the configuration (to preserve the behaviors when the system reboots). + +If you are using iptables on an Advanced Server cluster, do not modify the following rules: + +`iptables -I INPUT 1 -p tcp --dport 7800:7802 -j ACCEPT` + +`iptables -I INPUT 1 -p tcp --dport 5444 -j ACCEPT` + +`iptables –I INPUT 1 –p tcp --dport 9999 –j ACCEPT` + +If you are using iptables on a PostgreSQL cluster, do not modify the following rules: + +`iptables -I INPUT 1 -p tcp --dport 7800:7802 -j ACCEPT` + +`iptables -I INPUT 1 -p tcp --dport 5432 -j ACCEPT` + +`iptables –I INPUT 1 –p tcp --dport 9999 –j ACCEPT` + +The rules: + +- allow inbound traffic from the Ark console on ports `7800` and `7802`. +- allow inbound traffic on the database listener ports. +- save the configuration (to preserve the behaviors when the system reboots). +- allow inbound traffic on the load balancer port. + +## Post-Installation Recommendations + +**SE Linux** + +During the installation process, SE Linux is disabled on the console host. Please note that SE Linux must remain disabled for the Ark console and clusters to function properly. + +**Create a Secondary User Account** + +The Ark console installation process creates an administrative user (named `centos` on CentOS hosts, or `cloud-user` on RHEL hosts) with ssh access to the console host. After installing the Ark console, you should use ssh to connect to the console host, and create a secondary user account that can be used to login and gain `root` privileges in the event that the installer-created user should lose ssh access for any reason. diff --git a/product_docs/docs/ark/3.5/ark_admin/12_ark_statically_provisioned.mdx b/product_docs/docs/ark/3.5/ark_admin/12_ark_statically_provisioned.mdx new file mode 100644 index 00000000000..6689e8b57c3 --- /dev/null +++ b/product_docs/docs/ark/3.5/ark_admin/12_ark_statically_provisioned.mdx @@ -0,0 +1,49 @@ +--- +title: "Creating a Statically Provisioned Image" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-ark-platform/user-guides/administrative-users-guide/3.5/ark_statically_provisioned.html" +--- + + + +An `install.sh` script is distributed with Ark; use the script when creating a statically provisioned image. If you are creating a statically provisioned image on a RHEL host, you must register the host before configuring the cluster. + +1. Create an instance that contains the backing operating system for your image. + +2. Use `scp` to copy the `install.sh` file to the instance. + +3. Use the following command to modify the permissions associated with the `install.sh` file: + + ``` + chmod a+x install.sh + ``` + +4. Then, assume superuser privileges and invoke the install.sh script, including command options and values that specify details about the image: + +| Option | Value | +| ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| -n | The database server type | +| -v | The database server version | +| -u | If true, Ark will invoke the yum update command and update the currently installed software packages. | +| -c | When set to true, the script will configure and enable required RHEL repositories. | +| -r | The repository address (and if applicable, credentials) for provisioning. Include the -r flag once for each repository required by packages specified with the -p or -o options. | +| -p | A list of the packages that will be installed in the image. | +| -o | A list of additional packages that should be installed in the image. | + +5. Take a snapshot of the instance, and make the image public to make it accessible to the Ark console. + +**Examples** + +For example, the following command creates a static image that contains the EDB Postgres Advanced Server 10 database on a RHEL host: + +`$ sudo ./install.sh -n ppas -v 10 -u true -c true -r http://USERNAME:PASSWORD@yum.enterprisedb.com/10/redhat/rhel-\$releasever-\$basearch -r http://USERNAME:PASSWORD@yum.enterprisedb.com/tools/redhat/rhel-\$releasever-\$basearch -r http://USERNAME:PASSWORD@yum.enterprisedb.com/dependencies/redhat/rhel-\$releasever-\$basearch -p edb-as10-server edb-pgpool35 edb-as10-pgpool35-extensions` + +The following command creates a static image that contains PostgreSQL 10 on a CentOS host: + +`$ sudo ./install.sh -n postgres -v 10 -u true -c false -r http://yum.postgresql.org/10/redhat/rhel-7-x86_64/pgdg-redhat96-10-3.noarch.rpm -p postgresql10-server pgpool-II-10` + +The script returns `Script execution complete` when the command finishes executing successfully. + +When creating a new server with the Ark console that references the image, check the box next to `Statically Provisioned` on the console properties dialog. diff --git a/product_docs/docs/ark/3.5/ark_admin/13_ark_notifications.mdx b/product_docs/docs/ark/3.5/ark_admin/13_ark_notifications.mdx new file mode 100644 index 00000000000..5645e83b2bb --- /dev/null +++ b/product_docs/docs/ark/3.5/ark_admin/13_ark_notifications.mdx @@ -0,0 +1,47 @@ +--- +title: "Ark Notifications" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-ark-platform/user-guides/administrative-users-guide/3.5/ark_notifications.html" +--- + + + +EDB Ark will send e-mail notifications when: + +- The state of a monitored database cluster changes. +- An administrative action is performed on a cluster +- User information changes. + +Please note: For EDB Ark notifications to function properly, you must have an SMTP server running on each node, and provide contact email addresses for the Ark administrator and Ark user. + +| Subject | Body | +| ------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Console DB Backup Failed | The Console DB Backup failed. A problem was encountered trying to run the backup script: *script_output*. | +| Database State Changed to *db_state* | The MASTER /REPLICA database server *dns_name* in cluster *cluster_name* is now STOPPED /STARTING /RUNNING /WARNING /UNKNOWN in location *availability_zone*. | +| Load Balancer Port Error | The MASTER /REPLICA database server *dns_name* in cluster *cluster_name* in location *availability_zone* is reporting an error determining the load balancer port. | +| Load Balancer Port Notification | The MASTER /REPLICA database server *dns_name* in cluster *cluster_name* is now RUNNING /STARTING /STOPPED /WARNING /UNKNOWN in location *availability_zone* using port *port_number*. | +| Continuous Archiving State Changed to *db_state* | Continuous Archiving on the master/replica database server *dns_name* in cluster *cluster_name* is operating normally. | +| Continuous Archiving State Changed to *db_state* | A problem was detected with continuous archiving on the master/replica database server *dns_name* in cluster *cluster_name*. | +| Data Storage Scaling *cluster_name* | Data storage is being added to cluster *cluster_name* because the auto-scaling threshold was reached. | +| Data storage scaling for cluster *cluster_name* has been suspended | Data storage scaling for cluster *cluster_name* has been suspended. Instance *instance_id* no assignable device names left | +| Rebuild of primary node in cluster *cluster_name* | The primary server, node id *instance_id* in cluster *cluster_name* is being rebuilt. | +| Replacement of primary node in cluster *cluster_name* | The primary server, node id *instance_id* in cluster *cluster_name* is being replaced with node id *instance_id*. | +| Rebuild of replica node in cluster *cluster_name* | The replica server, node id *instance_id* in cluster *cluster_name* is being rebuilt. | +| Replica promotion failed in cluster *cluster_name* | Replica promotion failed. Performing rebuild of primary DB node; id: *instance_id* | +| Replica promotion failed in cluster *cluster_name* | Replica promotion failed. Node id: *instance_id* | +| WARNING: Connectivity Issue with instance *region/instance_id* | WARNING: The EDB Ark cluster manager was unable to connect to the node manager for instance ID *region/instance_id*. This may be due to a temporary connectivity issue or the instance may require manual intervention. | +| (PITR) Base Backup of cluster *cluster_name* failed | The automatic\|manual backup of cluster *cluster_name* in location *availability_zone* failed. | +| Backup of cluster *cluster_name* failed | The automatic\|manual backup of cluster *cluster_name* in location *availability_zone* failed. | +| WAL Archive Storage Container Created | A storage container (bucket) named *bucket_name* has been created. All EDB Ark clusters configured for Continuous Archiving (Point-in-Time Recovery) will use this location to store archived WAL files. This container should not be deleted once created as it will cause WAL archiving to stop functioning. | +| Termination of cluster *cluster_name* completed. | The termination of cluster *cluster_name* has completed. | +| WARNING: Termination Protection *instance_id*. | The system was not able to terminate instance {0} in cluster *cluster_name* because termination protection is enabled. You must disable termination protection before this instance can be terminated. | +| OS/SW update PASSED on node *instance_id.* | Yum update results for node: *dns_name* Yum exit status: *exit_status* You may also consult the yum log on the node (usually in /var/log/yum.log) If there were any errors, you will have to log into the node and manually correct them and/or consult with your EDB Ark Admin. | +| OS/SW update FAILED on node *instance_id.* | Yum update results for node: *dns_name* Yum exit status: *exit_status* You may also consult the yum log on the node (usually in /var/log/yum.log) If there were any errors, you will have to log into the node and manually correct them and/or consult with your EDB Ark Admin. | +| OS/SW Status is now: *status* | The OS/SW status on node *dns_name* of cluster *cluster_name* is now CRITICAL. This indicates that the node has at least one outstanding security update and possibly other non-critical updates available. Please log into the EDB Ark console and perform a cluster upgrade. | +| OS/SW Status is now: *status* | The OS/SW status on node *dns_name* of cluster *cluster_name* is now UNKNOWN. This indicates that the node is having difficulty determining the OS/SW status. This may be a temporary issue that will resolve itself. Please log into the EDB Ark console and check your clusters status. If it is still showing status UNKNOWN then you will need to log into node *dns_name* and run "yum --security check-update" to diagnose the issue manually. | +| Unable to delete Security Group *group_name* | The system was not able to delete the Security Group named *group_name* in cluster *cluster_name*. This could be because one or more instances in the cluster could not be terminated. This Security Group will need to be manually deleted from the provider's management console. | +| Volume attachment failed in cluster *cluster_name* | The message body contains error text directly from the server. | +| Ark Synchronization Error With PEM Server | The Ark console has encountered an error while attempting to synchronize with the PEM server: *exception_information* Ark console: *https: console_address* PEM dashboard: Full Error Details: *details* | +| Reboot of cluster *cluster_name* in progress | OS/SW update completed successfully, rebooting all cluster nodes. | diff --git a/product_docs/docs/ark/3.5/ark_admin/14_ark_resources.mdx b/product_docs/docs/ark/3.5/ark_admin/14_ark_resources.mdx new file mode 100644 index 00000000000..f07f92a5ce1 --- /dev/null +++ b/product_docs/docs/ark/3.5/ark_admin/14_ark_resources.mdx @@ -0,0 +1,21 @@ +--- +title: "Ark Resources" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-ark-platform/user-guides/administrative-users-guide/3.5/ark_resources.html" +--- + + + +You can find solutions to administrative problems through EnterpriseDB. If you have purchased support, you can log a support ticket: + +- in the Customer Portal: +- via email: [support@enterprisedb.com](mailto:support@enterprisedb.com) +- or by phone: +1-732-331-1320 or 1-800-235-5891 (US Only) + +If you have not purchased support, and would like to, view your support options at: + + + +You are always welcome to log an issue via email; when time permits, our customer support experts will respond to inquiries from customers that have not purchased support. Postgres documentation and helpful tutorials is always available from the `Dashboard` tab of the Ark console. diff --git a/product_docs/docs/ark/3.5/ark_admin/15_ark_aws_iam_role_permission_policy.mdx b/product_docs/docs/ark/3.5/ark_admin/15_ark_aws_iam_role_permission_policy.mdx new file mode 100644 index 00000000000..9dcd9875f53 --- /dev/null +++ b/product_docs/docs/ark/3.5/ark_admin/15_ark_aws_iam_role_permission_policy.mdx @@ -0,0 +1,17 @@ +--- +title: "AWS IAM Role Permission Policy" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-ark-platform/user-guides/administrative-users-guide/3.5/ark_aws_iam_role_permission_policy.html" +--- + + + +When you define an Amazon user, you are required to provide a security policy. The following text is an example of a security policy. + +```json + +``` + +{ "Version": "2012-10-17", "Statement": \[ { "Action": \[ "ec2:AllocateAddress", "ec2:AssignPrivateIpAddresses", "ec2:Associate*", "ec2:Attach*", "ec2:AuthorizeSecurityGroup*", "ec2:Copy*", "ec2:Create*", "ec2 DeleteInternetGateway", "ec2 DeleteNetworkAcl", "ec2 DeleteNetworkAclEntry", "ec2 DeleteNetworkInterface", "ec2 DeletePlacementGroup", "ec2 DeleteRoute", "ec2 DeleteRouteTable", "ec2 DeleteSecurityGroup", "ec2 DeleteSnapshot", "ec2 DeleteSubnet", "ec2 DeleteTags", "ec2 DeleteVolume", "ec2 DeleteVpc", "ec2 DeleteKeypair", "ec2 Describe*", "ec2 Detach*", "ec2 DisassociateAddress", "ec2 DisassociateRouteTable", "ec2:EnableVolumeIO", "ec2:GetConsoleOutput", "ec2:ModifyImageAttribute", "ec2:ModifyInstanceAttribute", "ec2:ModifyNetworkInterfaceAttribute", "ec2:ModifySnapshotAttribute", "ec2:ModifyVolumeAttribute", "ec2:ModifyVpcAttribute", "ec2:MonitorInstances", "ec2:ReleaseAddress", "ec2:ReplaceNetworkAclAssociation", "ec2:ReplaceNetworkAclEntry", "ec2:ReplaceRoute", "ec2:ReplaceRouteTableAssociation", "ec2:ReportInstanceStatus", "ec2:ResetImageAttribute", "ec2:ResetInstanceAttribute", "ec2:ResetNetworkInterfaceAttribute", "ec2:ResetSnapshotAttribute", "ec2:RevokeSecurityGroup*", "ec2:RunInstances", "ec2:StartInstances", "ec2:UnassignPrivateIpAddresses", "ec2:UnmonitorInstances", "ec2:ImportKeyPair" ], "Resource": "", "Effect": "Allow", "Sid": "Stmt1407961327680" }, { "Action": \[ "iam PassRole" ], "Resource": "", "Effect": "Allow", "Sid": "Stmt1407961362664" }, { "Action": \[ "s3:CreateBucket", "s3:Get*", "s3:List*" ], "Resource": "", "Effect": "Allow", "Sid": "Stmt1407961630932" }, { "Action": \[ "s3 Put", "s3:Get*", "s3 DeleteObject*", "s3 DeleteBucket\*" ], "Resource": "arn:aws:s3:::", "Effect": "Allow", "Sid": "Stmt1407961734627" }, { "Condition": { "StringEquals": { "ec2:ResourceTag/CreatedBy": "EnterpriseDB" } }, "Action": \[ "ec2:RebootInstances", "ec2:StopInstances", "ec2:TerminateInstances" ], "Resource": "", "Effect": "Allow", "Sid": "Stmt1407961927870" } ] } diff --git a/product_docs/docs/ark/3.5/ark_admin/16_ark_aws_iam_role_trust_relationship.mdx b/product_docs/docs/ark/3.5/ark_admin/16_ark_aws_iam_role_trust_relationship.mdx new file mode 100644 index 00000000000..5f92e71426c --- /dev/null +++ b/product_docs/docs/ark/3.5/ark_admin/16_ark_aws_iam_role_trust_relationship.mdx @@ -0,0 +1,40 @@ +--- +title: "Amazon IAM Role Trust Relationship" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-ark-platform/user-guides/administrative-users-guide/3.5/ark_aws_iam_role_trust_relationship.html" +--- + + + +When you define an Amazon IAM role, you are required to provide a security policy and an updated trust relationship policy document. You can use the following trust relationship document: + +```bash +{ + "Version": "2012-10-17", + "Statement": [ + { + "Sid": "", + "Effect": "Allow", + "Principal": { + "Service": "ec2.amazonaws.com" + }, + "Action": "sts:AssumeRole" + }, + { + "Sid": "", + "Effect": "Allow", + "Principal": { + "AWS": "arn:aws:iam::your_account_number:root" + }, + "Action": "sts:AssumeRole", + "Condition": { + "StringEquals": { + "sts:ExternalId": "EDB-ARK-SERVICE" + } + } + } + ] +} +``` diff --git a/product_docs/docs/ark/3.5/ark_admin/17_ark_aws_service_user_security_policy.mdx b/product_docs/docs/ark/3.5/ark_admin/17_ark_aws_service_user_security_policy.mdx new file mode 100644 index 00000000000..144eec29167 --- /dev/null +++ b/product_docs/docs/ark/3.5/ark_admin/17_ark_aws_service_user_security_policy.mdx @@ -0,0 +1,30 @@ +--- +title: "Amazon Service User Security Policy" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-ark-platform/user-guides/administrative-users-guide/3.5/ark_aws_service_user_security_policy.html" +--- + + + +When you define an Amazon service user, you are required to provide an inline security policy. You can use the following security policy when registering a service user: + +```json +{ + "Version": "2012-10-17", + "Statement": [ + { + "Sid": "Stmt1389628412000", + "Effect": "Allow", + "Action": [ + "sts:GetFederationToken", + "sts:AssumeRole" + ], + "Resource": [ + "*" + ] + } + ] +} +``` diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_features_admin_tab.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_features_admin_tab.png new file mode 100755 index 00000000000..fb1429ffa08 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_features_admin_tab.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_features_console.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_features_console.png new file mode 100755 index 00000000000..ced1d166b70 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_features_console.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_features_login.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_features_login.png new file mode 100755 index 00000000000..b738fb38e36 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_features_login.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_access_console_logs.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_access_console_logs.png new file mode 100755 index 00000000000..bbc942316d4 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_access_console_logs.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_access_core_usage_logs.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_access_core_usage_logs.png new file mode 100755 index 00000000000..fa0dd6c604f Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_access_core_usage_logs.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_add_db_engine.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_add_db_engine.png new file mode 100755 index 00000000000..28c9cb60b4c Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_add_db_engine.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_add_postgis_db_engine.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_add_postgis_db_engine.png new file mode 100755 index 00000000000..cb53b1be745 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_add_postgis_db_engine.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_add_rhel_sub.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_add_rhel_sub.png new file mode 100755 index 00000000000..332ab7f5d70 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_add_rhel_sub.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_add_template.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_add_template.png new file mode 100755 index 00000000000..a67d05136e7 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_add_template.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_add_user.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_add_user.png new file mode 100755 index 00000000000..a1b4470525f Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_add_user.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_aws_add_role.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_aws_add_role.png new file mode 100755 index 00000000000..a87d412d9af Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_aws_add_role.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_aws_role_arn.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_aws_role_arn.png new file mode 100755 index 00000000000..432433bdb86 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_aws_role_arn.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_aws_role_pane.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_aws_role_pane.png new file mode 100755 index 00000000000..a3cc8133858 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_aws_role_pane.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_console_switcher.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_console_switcher.png new file mode 100755 index 00000000000..2c7542e0e21 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_console_switcher.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_console_switcher_add_url.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_console_switcher_add_url.png new file mode 100755 index 00000000000..7a16c1a357f Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_console_switcher_add_url.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_console_switcher_delete_url.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_console_switcher_delete_url.png new file mode 100755 index 00000000000..c2790763aef Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_console_switcher_delete_url.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_console_switcher_enable.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_console_switcher_enable.png new file mode 100755 index 00000000000..bc1c75d554c Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_console_switcher_enable.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_console_switcher_pane.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_console_switcher_pane.png new file mode 100755 index 00000000000..8e94ab955b3 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_console_switcher_pane.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_create_cross_region.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_create_cross_region.png new file mode 100755 index 00000000000..f82ba226c96 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_create_cross_region.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_create_server.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_create_server.png new file mode 100755 index 00000000000..3f41c28a780 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_create_server.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_delete_db_engine.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_delete_db_engine.png new file mode 100755 index 00000000000..a3127d35904 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_delete_db_engine.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_delete_rhel_sub.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_delete_rhel_sub.png new file mode 100755 index 00000000000..4226d19e001 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_delete_rhel_sub.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_delete_server.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_delete_server.png new file mode 100755 index 00000000000..0a6b3dc2bf9 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_delete_server.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_delete_server_error.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_delete_server_error.png new file mode 100755 index 00000000000..6f2a877347d Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_delete_server_error.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_display_connected.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_display_connected.png new file mode 100755 index 00000000000..b87a97d21e1 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_display_connected.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_edit_inst_prop_pane.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_edit_inst_prop_pane.png new file mode 100755 index 00000000000..48210f4fc3b Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_edit_inst_prop_pane.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_generate_token.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_generate_token.png new file mode 100755 index 00000000000..31f55dba94c Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_generate_token.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_manage_db_engine_pane.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_manage_db_engine_pane.png new file mode 100755 index 00000000000..d75a813881f Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_manage_db_engine_pane.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_manage_server_pane.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_manage_server_pane.png new file mode 100755 index 00000000000..9685e43e171 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_manage_server_pane.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_modify_db_engine.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_modify_db_engine.png new file mode 100755 index 00000000000..3cf0a7c8556 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_modify_db_engine.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_modify_server.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_modify_server.png new file mode 100755 index 00000000000..1cea49ddc7d Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_modify_server.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_name_console.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_name_console.png new file mode 100755 index 00000000000..88b0363209b Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_name_console.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_register_console.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_register_console.png new file mode 100755 index 00000000000..9cfd2edeee5 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_register_console.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_rhel_sub_details.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_rhel_sub_details.png new file mode 100755 index 00000000000..5a4f0600393 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_rhel_sub_details.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_rhel_sub_mgmt_pane.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_rhel_sub_mgmt_pane.png new file mode 100755 index 00000000000..2efb47fd703 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_rhel_sub_mgmt_pane.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_take_manual_backup.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_take_manual_backup.png new file mode 100755 index 00000000000..7229a2fca84 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_take_manual_backup.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_template_details.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_template_details.png new file mode 100755 index 00000000000..9c30bd8aa2f Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_template_details.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_template_pane.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_template_pane.png new file mode 100755 index 00000000000..6a5bdc6bf69 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_template_pane.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_token_revoke.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_token_revoke.png new file mode 100755 index 00000000000..a84a8c8b148 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_token_revoke.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_user_admin_aws_host.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_user_admin_aws_host.png new file mode 100755 index 00000000000..8e7b54eec71 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_user_admin_aws_host.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_user_admin_azure_host.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_user_admin_azure_host.png new file mode 100755 index 00000000000..9ecb1b06193 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_user_admin_azure_host.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_user_pane.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_user_pane.png new file mode 100755 index 00000000000..53e6f5ba682 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_user_pane.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_wall_message.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_wall_message.png new file mode 100755 index 00000000000..6176d64064f Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_wall_message.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_wall_message_pane.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_wall_message_pane.png new file mode 100755 index 00000000000..1bb2fc6c656 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_admin_tab_wall_message_pane.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_architecture_load_balancing.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_architecture_load_balancing.png new file mode 100755 index 00000000000..b0b622e2206 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_architecture_load_balancing.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_architecture_overview.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_architecture_overview.png new file mode 100755 index 00000000000..2bb498533c8 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_architecture_overview.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_architecture_overview_create_new_cluster.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_architecture_overview_create_new_cluster.png new file mode 100755 index 00000000000..566d2b5efaf Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_architecture_overview_create_new_cluster.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_authentication_models_aws_pg_auth.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_authentication_models_aws_pg_auth.png new file mode 100755 index 00000000000..4969ba7ef6b Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_authentication_models_aws_pg_auth.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_authentication_models_aws_provider_auth.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_authentication_models_aws_provider_auth.png new file mode 100755 index 00000000000..4064562987c Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_authentication_models_aws_provider_auth.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_authentication_models_azure_pg_auth.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_authentication_models_azure_pg_auth.png new file mode 100755 index 00000000000..8ef026e3592 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_authentication_models_azure_pg_auth.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_authentication_models_azure_provider_auth.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_authentication_models_azure_provider_auth.png new file mode 100755 index 00000000000..c573a3cfa2a Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_authentication_models_azure_provider_auth.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_console_mgmt_modify_backup_props.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_console_mgmt_modify_backup_props.png new file mode 100755 index 00000000000..b0232063cae Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_console_mgmt_modify_backup_props.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_console_mgmt_recover.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_console_mgmt_recover.png new file mode 100755 index 00000000000..8cc6b08dc14 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_console_mgmt_recover.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_dba_tab.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_dba_tab.png new file mode 100755 index 00000000000..5759b4317ba Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_dba_tab.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_dba_tab_drop_down.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_dba_tab_drop_down.png new file mode 100755 index 00000000000..1f4b971f6cb Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_dba_tab_drop_down.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_dba_tab_user_info.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_dba_tab_user_info.png new file mode 100755 index 00000000000..5ec35d67489 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_dba_tab_user_info.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_add_user_dialog.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_add_user_dialog.png new file mode 100755 index 00000000000..61674dd5467 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_add_user_dialog.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_add_user_success.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_add_user_success.png new file mode 100755 index 00000000000..5037dccf655 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_add_user_success.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_ark_dashboard.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_ark_dashboard.png new file mode 100755 index 00000000000..576494fd0d1 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_ark_dashboard.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_ark_login.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_ark_login.png new file mode 100755 index 00000000000..7733626ee51 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_ark_login.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_attach_perm_policy.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_attach_perm_policy.png new file mode 100755 index 00000000000..919730404ab Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_attach_perm_policy.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_attach_policy.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_attach_policy.png new file mode 100755 index 00000000000..b29e4e557a7 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_attach_policy.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_backup_props.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_backup_props.png new file mode 100755 index 00000000000..258846282b0 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_backup_props.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_complete_policy.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_complete_policy.png new file mode 100755 index 00000000000..464d14ec49d Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_complete_policy.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_conf_ark_console.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_conf_ark_console.png new file mode 100755 index 00000000000..f6a61de718b Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_conf_ark_console.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_create_iam_role.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_create_iam_role.png new file mode 100755 index 00000000000..d86c4ffe034 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_create_iam_role.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_create_policy.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_create_policy.png new file mode 100755 index 00000000000..ad9862ea4b1 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_create_policy.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_create_svc_role.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_create_svc_role.png new file mode 100755 index 00000000000..796b4a8e6c3 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_create_svc_role.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_general_props.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_general_props.png new file mode 100755 index 00000000000..c364525c452 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_general_props.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_iam_role_edit_trust_rel.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_iam_role_edit_trust_rel.png new file mode 100755 index 00000000000..b0f2748d246 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_iam_role_edit_trust_rel.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_iam_role_perm.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_iam_role_perm.png new file mode 100755 index 00000000000..02c26802ac6 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_iam_role_perm.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_iam_role_review.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_iam_role_review.png new file mode 100755 index 00000000000..5d78b04bd08 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_iam_role_review.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_iam_role_sec_policy.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_iam_role_sec_policy.png new file mode 100755 index 00000000000..f7d8be1cb62 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_iam_role_sec_policy.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_iam_role_summary.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_iam_role_summary.png new file mode 100755 index 00000000000..fff2ac7020b Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_iam_role_summary.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_idp_props.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_idp_props.png new file mode 100755 index 00000000000..2ebcd4b50d8 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_idp_props.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_org_props.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_org_props.png new file mode 100755 index 00000000000..242070f325d Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_org_props.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_pem_props.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_pem_props.png new file mode 100755 index 00000000000..98b48855d20 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_pem_props.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_pwd_props.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_pwd_props.png new file mode 100755 index 00000000000..ba619bb703c Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_pwd_props.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_reg_step_1.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_reg_step_1.png new file mode 100755 index 00000000000..ccf9a332d11 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_reg_step_1.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_reg_step_2.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_reg_step_2.png new file mode 100755 index 00000000000..3f21f766e5e Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_reg_step_2.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_review_role.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_review_role.png new file mode 100755 index 00000000000..626b090fdc0 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_review_role.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_review_user.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_review_user.png new file mode 100755 index 00000000000..84e68c652c5 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_review_user.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_role_detail.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_role_detail.png new file mode 100755 index 00000000000..a700b7587e5 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_role_detail.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_role_edit_trust.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_role_edit_trust.png new file mode 100755 index 00000000000..6c8d10cf62d Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_role_edit_trust.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_role_permissions.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_role_permissions.png new file mode 100755 index 00000000000..e89fc7285d9 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_role_permissions.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_role_provide_policy.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_role_provide_policy.png new file mode 100755 index 00000000000..1826efd7da8 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_role_provide_policy.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_role_summary.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_role_summary.png new file mode 100755 index 00000000000..7ecbafb0e80 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_role_summary.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_saml_props.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_saml_props.png new file mode 100755 index 00000000000..398107e1381 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_saml_props.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_sp_props.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_sp_props.png new file mode 100755 index 00000000000..7be310c3dd7 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_sp_props.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_spec_props.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_spec_props.png new file mode 100755 index 00000000000..6047014d3fb Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_spec_props.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_step_3_details.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_step_3_details.png new file mode 100755 index 00000000000..55de5dd9d43 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_step_3_details.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_timezone_props.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_timezone_props.png new file mode 100755 index 00000000000..766cdfe9018 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_timezone_props.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_user_reg.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_user_reg.png new file mode 100755 index 00000000000..fd95cc07932 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_aws_user_reg.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_admin_console.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_admin_console.png new file mode 100755 index 00000000000..ced1d166b70 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_admin_console.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_api_perm_conf.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_api_perm_conf.png new file mode 100755 index 00000000000..8e44525a9c2 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_api_perm_conf.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_api_perm_grant.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_api_perm_grant.png new file mode 100755 index 00000000000..0a324200a6a Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_api_perm_grant.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_backup_props.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_backup_props.png new file mode 100755 index 00000000000..76933ff2892 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_backup_props.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_create_panel.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_create_panel.png new file mode 100755 index 00000000000..e08d6816077 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_create_panel.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_create_storage.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_create_storage.png new file mode 100755 index 00000000000..8066ae0b609 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_create_storage.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_create_vm.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_create_vm.png new file mode 100755 index 00000000000..3fd3034ff9b Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_create_vm.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_deploy.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_deploy.png new file mode 100755 index 00000000000..cc5b3b7f072 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_deploy.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_general_props.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_general_props.png new file mode 100755 index 00000000000..1f1134e5f75 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_general_props.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_idp_props.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_idp_props.png new file mode 100755 index 00000000000..8b2f4a2f921 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_idp_props.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_install_extension.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_install_extension.png new file mode 100755 index 00000000000..46e9044ceb8 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_install_extension.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_login.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_login.png new file mode 100755 index 00000000000..11ecf0baf94 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_login.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_new_app_reg.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_new_app_reg.png new file mode 100755 index 00000000000..18c31e84eb1 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_new_app_reg.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_org_props.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_org_props.png new file mode 100755 index 00000000000..89327f8fa29 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_org_props.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_password_props.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_password_props.png new file mode 100755 index 00000000000..53378cb43e2 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_password_props.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_pem_server_props.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_pem_server_props.png new file mode 100755 index 00000000000..998b49dec46 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_pem_server_props.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_props.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_props.png new file mode 100755 index 00000000000..671678f8a21 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_props.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_required_perm.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_required_perm.png new file mode 100755 index 00000000000..1ecfb05ea56 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_required_perm.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_required_permissions.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_required_permissions.png new file mode 100755 index 00000000000..fab1dc86cbe Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_required_permissions.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_saml_props.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_saml_props.png new file mode 100755 index 00000000000..b52af03db2f Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_saml_props.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_select_api.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_select_api.png new file mode 100755 index 00000000000..6613fbcd7b5 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_select_api.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_select_image.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_select_image.png new file mode 100755 index 00000000000..05f200f27ee Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_select_image.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_select_vm_size.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_select_vm_size.png new file mode 100755 index 00000000000..444cfabf616 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_select_vm_size.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_set_api_permissions.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_set_api_permissions.png new file mode 100755 index 00000000000..ecf89377044 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_set_api_permissions.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_sp_props.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_sp_props.png new file mode 100755 index 00000000000..7be310c3dd7 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_sp_props.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_timezone_props.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_timezone_props.png new file mode 100755 index 00000000000..52b7850e608 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_timezone_props.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_validation_passed.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_validation_passed.png new file mode 100755 index 00000000000..44cf3d6cbb1 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_validation_passed.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_vm_details.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_vm_details.png new file mode 100755 index 00000000000..07e39d5a87d Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_installing_console_azure_vm_details.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_registering_with_pem.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_registering_with_pem.png new file mode 100755 index 00000000000..d893898ae32 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_registering_with_pem.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_registering_with_pem_architecture.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_registering_with_pem_architecture.png new file mode 100755 index 00000000000..73632578d1b Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_registering_with_pem_architecture.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_registering_with_pem_global_overview.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_registering_with_pem_global_overview.png new file mode 100755 index 00000000000..93119a97640 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_registering_with_pem_global_overview.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_registering_with_pem_group_role_dialog.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_registering_with_pem_group_role_dialog.png new file mode 100755 index 00000000000..952e36753d7 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_registering_with_pem_group_role_dialog.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_registering_with_pem_login_role_dialog.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_registering_with_pem_login_role_dialog.png new file mode 100755 index 00000000000..e666f4466f5 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_registering_with_pem_login_role_dialog.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_registering_with_pem_login_role_dialog_password.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_registering_with_pem_login_role_dialog_password.png new file mode 100755 index 00000000000..6d50e7fc98d Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_registering_with_pem_login_role_dialog_password.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_registering_with_pem_logon.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_registering_with_pem_logon.png new file mode 100755 index 00000000000..849daa264c6 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_registering_with_pem_logon.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_registering_with_pem_pg_hba.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_registering_with_pem_pg_hba.png new file mode 100755 index 00000000000..d396af2d927 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_registering_with_pem_pg_hba.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_registering_with_pem_registered_successfully.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_registering_with_pem_registered_successfully.png new file mode 100755 index 00000000000..04a9be9a934 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_registering_with_pem_registered_successfully.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_registering_with_pem_ssh_session.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_registering_with_pem_ssh_session.png new file mode 100755 index 00000000000..26917adfc41 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_registering_with_pem_ssh_session.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_securing_ark_editing_inbound_rules.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_securing_ark_editing_inbound_rules.png new file mode 100755 index 00000000000..9d3b2fd27cc Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_securing_ark_editing_inbound_rules.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/ark_securing_ark_using_ssl.png b/product_docs/docs/ark/3.5/ark_admin/images/ark_securing_ark_using_ssl.png new file mode 100755 index 00000000000..75f9f957f3e Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/ark_securing_ark_using_ssl.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/images/changing_console_passwords.png b/product_docs/docs/ark/3.5/ark_admin/images/changing_console_passwords.png new file mode 100755 index 00000000000..d810b0412f0 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_admin/images/changing_console_passwords.png differ diff --git a/product_docs/docs/ark/3.5/ark_admin/index.mdx b/product_docs/docs/ark/3.5/ark_admin/index.mdx new file mode 100644 index 00000000000..78d1fb4e0b2 --- /dev/null +++ b/product_docs/docs/ark/3.5/ark_admin/index.mdx @@ -0,0 +1,35 @@ +--- +navTitle: Administrative User Guide +title: "Ark" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-ark-platform/user-guides/administrative-users-guide/3.5/index.html" + - "/edb-docs/d/edb-postgres-ark-platform/user-guides/administrative-users-guide/3.5/conclusion.html" + - "/edb-docs/d/edb-postgres-ark-platform/user-guides/administrative-users-guide/3.5/genindex.html" +--- + +**EDB Postgres Ark** + +EDB Ark automatically provisions EDB Postgres Advanced Server or PostgreSQL databases in single instances, high-availability clusters, or application development sandboxes. EDB Ark allows service providers and organizations to offer elastic and highly scalable database-as-a-service (DBaaS) environments while freeing DBAs and application developers from the rigors of setting up and administering modern and robust database environments. + +In minutes, EDB Ark configures a cluster of database machines with: + +- Monitoring +- Streaming replication +- Connection pooling +- Load balancing +- Automatic failover (transaction or recovery time preferred) +- Secure data encryption +- Rotating user-scheduled backups +- Point-in-time recovery +- Elastic storage +- Elastic scale out + +EDB Ark's automatic scaling of storage resources and scale out of read replicas when a database cluster reaches user-defined thresholds provides unattended, around-the-clock responsiveness to unpredictable load demands on your database infrastructure. + +
+ +ark_whats_new ark_supported_platforms ark_architecture_overview ark_registering_with_pem ark_authentication_models ark_installing_console ark_admin_features ark_admin_tab ark_dba_tab ark_console_management ark_securing_ark ark_statically_provisioned ark_notifications ark_resources ark_statically_provisioned ark_aws_iam_role_permission_policy ark_aws_iam_role_trust_relationship ark_aws_service_user_security_policy conclusion + +
diff --git a/product_docs/docs/ark/3.5/ark_gsg/01_whats_new.mdx b/product_docs/docs/ark/3.5/ark_gsg/01_whats_new.mdx new file mode 100644 index 00000000000..90508aa4326 --- /dev/null +++ b/product_docs/docs/ark/3.5/ark_gsg/01_whats_new.mdx @@ -0,0 +1,42 @@ +--- +title: "What's New" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-ark-platform/installation-getting-started/getting-started-guide/3.5/whats_new.html" +--- + + + +The following features have been added to the EDB Ark user console for this release. + +- Ark now supports EDB Postgres Advanced Server and PostgreSQL version 12 database clusters. +- EnterpriseDB has introduced a new RPM repository structure that combines the contents of the previous three repositories into a single repository. The new structure is supported by Ark. For information about connecting to the repository, visit . +- Ark now provides extended support for multi-region features (including manual promotion and API support). +- You can use the `Promote` option (located on a cluster's context menu in the `Details` panel) to replace the master node with a standby node. For more information, see the EDB Postgres Ark Getting Started Guide. +- The `/templates` and `/templates/id` resources now support the `region` property. +- Support for Amazon `r4.*` and `r5.8x` instance types has been reinstated. + +## Limitations + +**Cloning, Recovering, or Scaling Encrypted Clusters from Previous Versions** + +Encrypted clusters created with Ark 3.3 or prior may not be used to clone, recover, or scale to a machine type that is not supported by that earlier version. If you will be moving encrypted clusters created with Ark version 3.3 or prior to a new machine type (as supported by Ark 3.4 or 3.5), you will need to: + +1. Clone the encrypted cluster to a new, unencrypted cluster. +2. Upgrade the Ark console on which the cluster resides. +3. Clone the unencrypted cluster to a new encrypted cluster of the new machine type. + +For detailed information about cloning a cluster, see the *EDB Postgres Ark Getting Started Guide*. + +**Cloning with a Template from a Foreign Region** + +You cannot use a template when cloning from a foreign region. + +**Monitoring a Federated Console with PEM** + +Ark does not support federated consoles configured in local PEM server mode. + +**Federating Consoles that host clusters with the Same Name** + +If you are upgrading to version 3.4 or 3.5, and plan to federate existing Ark version 3.3 consoles that host clusters with the same name, you must first create a clone of one of the clusters specifying an alternate name; federated consoles cannot be used to host clusters with the same name. For example, if you plan to federate two consoles that both contain a cluster named `acctg`, you should clone one of the clusters specifying an alternate name for the cluster (i.e. `acctg-west`). Then, you can federate the consoles; both consoles will have access to `acctg` and `acctg-west`. diff --git a/product_docs/docs/ark/3.5/ark_gsg/02_ark_overview.mdx b/product_docs/docs/ark/3.5/ark_gsg/02_ark_overview.mdx new file mode 100644 index 00000000000..5e670523441 --- /dev/null +++ b/product_docs/docs/ark/3.5/ark_gsg/02_ark_overview.mdx @@ -0,0 +1,128 @@ +--- +title: "EDB Ark - Overview" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-ark-platform/installation-getting-started/getting-started-guide/3.5/ark_overview.html" +--- + + + +EDB Ark simplifies the process of provisioning robust Postgres deployments, while taking advantage of the benefits of cloud computing. When used with Advanced Server, EDB Ark also provides a platform with compatibility with the Oracle database, offering dramatic cost savings and competitive advantages. + +A cloud is a collection of virtual machines; each virtual machine runs a separate copy of an operating system and an installation of Postgres. + +![*Using EDB Ark in a Private Cloud.*](images/ark_overview_private_cloud.png) + +Fig. 2.1: Using EDB Ark in a Private Cloud. + +You can specify different combinations of CPU speed, RAM, and disk space to suit your needs when provisioning an EDB Ark cluster. EDB Ark makes it easy to scale up to a more capable cluster, or scale down as your requirements change. + +EDB Ark solves common challenges faced by businesses that need more agility, velocity, and thrift in deploying and using relational, ACID-compliant databases: + +- **Develop / Test / Deploy.** Quickly create and delete Postgres databases with standard configurations to support software development and testing activities, then deploy applications to the database or cluster – all at a pace dramatically quicker than physical provisioning. +- **Workload Portability.** The same Postgres database trusted in the datacenter also runs in a cloud cluster with scalability and high-availability. +- **Enterprise-class power.** Postgres was designed to solve critical business challenges requiring reliable, high-performance, ACID-compliant database processing. As the only open source database meeting those requirements, it offers an extremely attractive alternative to more expensive options. + +EDB Ark includes the following functionality: + +- **Scale computing resources up and out.** EDB Ark automatically scales up storage capacity, and provides a simple button to scale your server class up when data processing loads and usage characteristics require a change in the underlying virtual machine resources. +- **Automatic Connection Pooling and Load Balancing.** EDB Ark maintains a cluster of database nodes, automatically scaling out replicas based on increasing user demand. The integrated connection pooling manager increases database read performance by distributing requests across all cluster members. +- **Self-Healing Failover.** EDB Ark automatically replaces downed database nodes, preserving the continuity and performance of the cluster. Users can choose to replace the master with a new master (preserving all committed transactions) or with a promoted replica (for faster recovery time). +- **Automatic Online backup.** EDB Ark uses user-directed rotating backups to protect your data from loss due to mishaps +- **Supports data encryption.** EDB Ark offers SSL data encryption that protects data at rest, and is transparent to connecting clients. +- **Cost-saving Compatibility with the Oracle Database.** Using a database that is compatible with Oracle is a reliable, fast and cost-effective way to support Oracle applications in public and private clouds. +- **Web-based interface.** EDB Ark provides easy to use point-and-click cluster lifecycle management from start to finish from your favorite web browser. +- **Database Cloning.** EDB Ark allows you to quickly and easily create developer 'sandboxes' based on real production data, saving System Administrators setup, configuration and data load time. +- **Professional Postgres Support.** EnterpriseDB provides support from Postgres experts who work with top Postgres open source developers. +- **JSON Compatible API Support.** EDB Ark supports a JSON-compatible API. + +## Architecture Overview + +The Ark console is designed to help you easily create and manage high-availability database clusters from a web browser. + +!!! Note + Traditionally, the expression *cluster* refers to a single instance of Postgres managing multiple databases; an EDB Ark database server cluster is a collection of high-availability Postgres server instances that reside in a cloud or on a traditional network. + +When you create a new cluster (a group of replicated database servers), EDB Ark initializes one or more Postgres instances (virtual machines) according to your specifications. EDB Ark uses Postgres streaming replication to synchronize replicas in the cluster, and pgpool-II to implement load balancing and connection pooling among all active instances. The following figure provides a general overview of the EDB Ark architecture. + +![*An overview of the EDB Ark architecture.*](images/ark_architecture_overview.png) + +Fig. 2.2: An overview of the EDB Ark architecture + +The master node of the cluster contains a host operating system with a running instance of Postgres, along with the load balancer. Database modifications are automatically routed to the master node; any modifications to the master node are subsequently propagated to each replica using Postgres streaming replication. + +EDB Ark installs Postgres on each replica node in a read-only hot-standby role that automatically duplicates all data found on the master node, and all changes made to that data. In hot-standby mode, the data is available to service user queries providing read scalability to the cluster. In addition, any schema changes made to the master are also replicated to the replica nodes, making development and deployment of application changes easy and seamless without interruption to normal operations. + +![*EDB Ark performs automatic load balancing.*](images/ark_overview_load_balance.png) + +Fig. 2.3: EDB Ark performs automatic load balancing + +Replicas provide balanced user support as needed - if any instance in the cluster goes offline, the cluster's load is re-balanced among the remaining servers while the instance is automatically replaced. + +When used in the default healing configuration, in the event of a failure of the master node, an existing replica is used to replace the failed master node. While the replica nodes are standing by, they are read-only resources, load balancing client queries without a risk of compromising data integrity. + +EDB Ark automatically archives data at regular intervals; you can specify a convenient backup window and how many backups to retain when creating a database cluster. EDB Ark also offers backup on demand -simply click the Backup icon to save a copy of the instance. Automatic backups are retained according to your specifications; on-demand backups are retained until you delete them. Each backup is a complete copy of the cluster; you can use a backup to restore a cluster. + +EDB Ark makes it easy to scale a database cluster: + +- To increase read performance, you can add read replicas to the cluster (manually or automatically). +- To handle expanding data requirements you can increase the amount of storage available (manually or automatically). +- To increase the RAM or CPU processing power of the cluster's underlying virtual machine, you can manually scale a cluster into a more appropriate server class. + + + +## Using Ark as a Template Only User + +Some features of the Ark console are not available to a *Template* *Only* user. A Template Only user: + +- must specify a template when deploying, scaling, or restoring a cluster. +- is restricted to the scaling policies defined in the template. +- cannot modify a manually-defined cluster created by another user. +- can only scale clusters to a server class that exists in a template that is available to the current tenant. +- may only delete backups of template created clusters. +- may not delete last backup of a template created cluster if the cluster had been deleted. + +If you are a Template Only user, the Ark console displays a note in the upper-left header when you log in. + +![*Template Only User.*](images/using_ark_template_only.png) + +Fig. 2.4: Template Only User + +For Template Only users, the Ark dialogs used to create a cluster, clone a cluster, or to restore a backup offer a subset of the fields presented on the dialogs viewed by a user that is not a Template Only user. + +For detailed information about using a template to: + +- create a cluster, see [Using a Template to Create a Cluster](05_creating_a_cluster/#template_create_cluster) . +- restore from backup, see [Using a Template to Restore from Backup](07_manage_backup_recovery/#template_restore) . +- clone a cluster, see [Using a Template to Clone a Cluster](05_creating_a_cluster/#template_clone_cluster) . + +Please note: a user that is not restricted to template usage may override template policy when modifying a cluster created with a template. + + + +## Using a Federated Console + +An Administrative user can create a federation of consoles; once federated, a user can create or clone clusters or add resources in any region in which one of the federated consoles resides. Standby nodes that reside in other regions will reflect the state of the master node. + +Standby nodes that reside in a different region than the master console will be used for load balancing. Failover to nodes that reside on a different region than the master node is not supported. If a master node fails and you do not have a standby node in the same region as the master node, Ark will create a replacement node in the same region as the original master. + +If a console is a member of a federation, any other member of the federation will be able to create resources in the region in which the console resides. All of the resources that reside on federated consoles will be visible on the `Clusters` tab of all of the consoles within the federation. + +When connected to a federated console, you can: + +- Create a cluster with nodes that reside in multiple regions; the console from which you create the cluster will be responsible for managing the master node. +- Initiate a cluster backup on any cluster within the federation. If the cluster master is managed by the console where the backup was initiated, then the backup will run locally; if the cluster is not managed by the console where the backup was requested, then a backup request will be made to the managing console and the backup will run remotely. +- Delete a node or cluster regardless of the region in which the node or cluster resides. +- Initiate a clone operation regardless of the region in which the node resides; the clone operation will be able to create one or more nodes in any region of the federation. +- Initiate a yum update on any node or cluster of the federation (remote or local). +- Add resources and replicas in any region of a federated console during a manual scaling operation. +- Perform multi-region machine scaling. If the cluster contains nodes running in different regions, then the console that manages the master node will coordinate machine scaling in the foreign regions. A new master node is created first on the new machine type, the old master is removed, and then each replica node is replaced. + +On a federated console, dialogs that allow you to create and manage clusters or nodes (create, scale, clone, or delete) will make the regions, VPCs, availability zones, and subnets of other federation members available for selection. + +![*Selecting a region.*](images/ark_create_cross_region.png) + +Fig. 2.5: Selecting a region + +For example, you might have two federated consoles; one that resides in `us-east-1` and one that resides in `us-east-2`. After federating the consoles (sharing the URL and token of each console within the federation with the other console), you will be allowed to select the `Region` in which replica nodes are created or cloned. diff --git a/product_docs/docs/ark/3.5/ark_gsg/03_accessing_ark_console.mdx b/product_docs/docs/ark/3.5/ark_gsg/03_accessing_ark_console.mdx new file mode 100644 index 00000000000..7439d1ecbd2 --- /dev/null +++ b/product_docs/docs/ark/3.5/ark_gsg/03_accessing_ark_console.mdx @@ -0,0 +1,141 @@ +--- +title: "Accessing the Ark Console" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-ark-platform/installation-getting-started/getting-started-guide/3.5/accessing_ark_console.html" +--- + + + +If your Ark console resides on an Amazon host, the console configuration will determine the user registration process. An administrative user can enable or disable self-registration. If you are an administrative user and need information about enabling or disabling self-registration, please refer to the EDB Ark Administrative User's Guide. If you are a non-administrative user connecting to the Ark console on an Amazon host with self-registration enabled, see Using Self-Registration on an Amazon Hosted Console. + +When you navigate to the URL of an installed Ark console, the console will display a login dialog. + +![*The Login dialog.*](images/accessing_ark_console.png) + +Fig. 3.1: The Login dialog. + +Enter your user name in the `Email` field, and the associated password in the `Password` field, and click `Log In` to connect to the Ark console. + +![*The Ark console.*](images/accessing_ark_console_dashboard.png) + +Fig. 3.2: The Ark console. + + + +## Using Self-Registration on an Amazon Hosted Console + +If self-registration is enabled, on your first visit to the Ark console, you should create an Amazon role and register an Ark console user. + +As part of the registration process for the Ark console, you must create an Amazon IAM role and perform a *handshake* between the Ark console and the Amazon management console. The handshake associates the external ID provided by the Ark console with the Amazon role, and the `Role Arn` provided by the Amazon console with the Ark user. + +Please note that each time you refresh the Ark `New User` dialog, the external ID displayed on the registration dialog will change; you must have access to both the Ark console and the Amazon management console while registering an Ark user. + +To start the registration process, connect to the Amazon management console, and navigate to the `Identity and Access Management` dashboard. + +![*The Amazon IAM Dashboard.*](images/self_reg_welcome.png) + +Fig. 3.3: The Amazon IAM Dashboard. + +Navigate to the `Roles` dashboard, and click the `Create New Role` button. + +![*Provide a role name.*](images/self_reg_set_role_name.png) + +Fig. 3.4: Provide a role name + +When the `Set Role Name` dialog opens, specify a name for the new role and click `Next Step` to specify a role type. + +![*Specify that the role allows EC2 instances to call AWS services.*](images/self_reg_role_type.png) + +Fig. 3.5: Specify that the role allows EC2 instances to call AWS services + +On the `Select Role Type` dialog, select the `AWS Service Roles` radio button, and then the `Select` button to the right of `Amazon EC2` to continue to the `Attach Policy` dialog. + +![*The Attach Policy dialog.*](images/self_reg_attach_policy.png) + +Fig. 3.6: The Attach Policy dialog + +When the `Attach Policy` dialog opens, do not specify a policy; instead, click `Next Step` to continue to the `Review` dialog. + +![*Review the role information.*](images/self_reg_review.png) + +Fig. 3.7: Review the role information + +When the `Review` dialog opens, review the information displayed, and then click `Create Role` to instruct the AWS management console to create the described role. + +![*The new role is displayed on the Roles page.*](images/self_reg_create_role.png) + +Fig. 3.8: The new role is displayed on the Roles page. + +The role will be displayed in the role list on the `Amazon IAM Roles` page. The `Summary` tab will display a `Role ARN`, but the ARN will not be enabled until the security policy and trust policy are updated. + +After completing the `Create Role` wizard, you must modify the inline policy and trust relationship (defined by the security policy) to allow Ark to use the role. Highlight the role name; then navigate to the `Permissions` tab and open the `Inline Policies` menu. Select `Click here` to add a new policy. + +![*The Inline Policies menu.*](images/self_reg_inline_policy.png) + +Fig. 3.9: The Inline Policies menu + +When the `Set Permissions` dialog opens, select the `Custom Policy` radio button, and then click the `Select` button. + +![*Add a Custom Policy.*](images/self_reg_set_permissions.png) + +Fig. 3.10: Add a Custom Policy. + +![*Provide the policy name and contents.*](images/self_reg_custom_policy.png) + +Fig. 3.11: Provide the policy name and contents + +Use the fields on the `Set Permissions` dialog to define the security policy: + +- Provide a name for the security policy in the `Policy Name` field. +- Copy the security policy text into the `Policy Document` field. The security policy required by Ark is available in [AWS + Resources](15_aws_policies/#aws_policies) . + +After providing security policy information, click `Apply Policy` to return to the `Role` information page. Then, select the `Edit Trust Relationship` button (located in the `Trust Relationships` section) to display the `Policy Document`. + +![*The Policy Document.*](images/self_reg_edit_trust_rel.png) + +Fig. 3.12: The Policy Document + +Replace the displayed content of the policy document with the content of the file available in [AWS Resources](15_aws_policies/#aws_policies) . + +`EDB-PPCD-CONSOLE` is a placeholder within the trust policy. You must replace the placeholder with the `External ID` provided on the `Step 2` tab of the Ark console `New User Registration` dialog. + +To retrieve the `External ID`, open another browser window and navigate to the `Log In` page of your Ark console. Click the `Register` button to open the `New User Registration` dialog. + +![*The New User Registration dialog.*](images/self_reg_reg_dialog.png) + +Fig. 3.13: The New User Registration dialog. + +Enter user information in the `User Details` box located on the `Step 1` tab: + +- Enter your first and last names in the `First Name` and `Last Name` fields. +- Enter a password that will be associated with the user account, and confirm the password in the `Password` and `Verify Password` fields. +- Provide an email address in the `Email` field; please note that the email address is used as the Login identity for the user. +- Use the drop-down listbox in the `Cloud Provider` field to select the host on which the cloud will reside. +- Enter the name of the company with which you are associated in the `Company Name` field. + +When you've completed `Step 1`, click `Next` to access the `Step 2` tab. + +![*The Summary tab of the Role detail panel.*](images/self_reg_role_detail.png) + +Fig. 3.14: The Summary tab of the Role detail panel. + +The `Step 2` tab of the `New User Registration` dialog will display a random `External ID` number. Copy the `External ID` from the `Step 2` dialog into the trust policy, replacing `EDB-PPCD-CONSOLE`. Please note that you must enclose the `External ID` in double-quotes ("). Click the `Update Trust Policy` button to save your edits and exit the dialog. + +Your Amazon IAM role ARN is displayed on the `IAM Roles` detail panel of the Amazon management console. Highlight a role name to display the assigned value on the `Summary` page. + +![*Registering a user on an Amazon EC2 cloud.*](images/self_reg_step_two.png) + +Fig. 3.15: Registering a user on an Amazon EC2 cloud. + +Enter your Amazon IAM role ARN in the `Role Arn` field on the `Step 2` dialog, and click `Finish` to complete the registration. Select `Cancel` to exit without completing the registration. + +After completing the registration, you can use the `Login/Register` dialog to access the Ark console. + +![*The Login/Register dialog.*](images/accessing_ark_console.png) + +Fig. 3.16: The Login/Register dialog. + +Enter the registered email address in the `Username` field, and the associated password in the `Password` field, and click `Log In` to connect to the Ark console. diff --git a/product_docs/docs/ark/3.5/ark_gsg/04_using_ark_console/01_ark_dashboard_tab.mdx b/product_docs/docs/ark/3.5/ark_gsg/04_using_ark_console/01_ark_dashboard_tab.mdx new file mode 100644 index 00000000000..6d346500690 --- /dev/null +++ b/product_docs/docs/ark/3.5/ark_gsg/04_using_ark_console/01_ark_dashboard_tab.mdx @@ -0,0 +1,35 @@ +--- +title: "The Dashboard Tab" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-ark-platform/installation-getting-started/getting-started-guide/3.5/ark_dashboard_tab.html" +--- + + + +The `Dashboard` tab provides an overview of the EDB Ark service status, resources, useful information links and a quick-start `Launch DB Cluster` button. + +![*The Dashboard tab.*](../images/accessing_ark_console_dashboard.png) + +Fig. 4.1: The Dashboard tab. + +To launch a cluster from the `Dashboard` tab, use the `Tenant` drop-down listbox to select the tenant in which the cluster will be created. Then, use the `Launch DB Cluster` button located in the `Getting Started` panel to open the `Create New Cluster` dialog and define the cluster attributes. For more information about defining a cluster, see [Creating a Server Cluster](../05_creating_a_cluster/#creating_a_cluster) . + +The `Resources` panel contains a table that displays the resource usage (instances, snapshots, and volumes) for each role. + +The `Hot Topics` panel provides a link to the EDB Ark website. + +Use the links in the `EDB Ark Tutorials and Documentation` section to access EDB Ark and Postgres documentation. + + + +## Using the Console Switcher Feature + +The console switcher provides convenient access to a list of user-defined console names and their associated addresses. When you select a name from the `Consoles` drop-down listbox, the Ark console opens a browser tab and navigates to the address associated with the shortcut name. + +![*The Consoles drop-down.*](../images/console_switcher.png) + +Fig. 4.2: The Consoles drop-down + +An Ark administrative user can use management features located on the Admin tab of the administrative console to add consoles to the list, or remove consoles from the list. For more information about populating the console switcher, please see the *EDB Ark Administrative User's Guide*. diff --git a/product_docs/docs/ark/3.5/ark_gsg/04_using_ark_console/02_ark_clusters_tab.mdx b/product_docs/docs/ark/3.5/ark_gsg/04_using_ark_console/02_ark_clusters_tab.mdx new file mode 100644 index 00000000000..c1e15f38ec1 --- /dev/null +++ b/product_docs/docs/ark/3.5/ark_gsg/04_using_ark_console/02_ark_clusters_tab.mdx @@ -0,0 +1,229 @@ +--- +title: "The Clusters Tab" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-ark-platform/installation-getting-started/getting-started-guide/3.5/ark_clusters_tab.html" +--- + + + +Use the `Clusters` tab to create, monitor and manage active clusters that reside in the cluster. + +![*The Clusters tab.*](../images/ark_clusters_tab.png) + +Fig. 4.3: The Clusters tab + +Indicators in the columns to the right of a cluster name display the current health of the cluster. Click on a column name to sort the contents of the column; click a second time to reverse the sort-order. + +- The `VM` column displays the state of the virtual machine on which the cluster resides. +- The `HA` column displays the state of the high-availability cluster. +- The `DB` column displays the state of the database server. +- The `UP` column displays the current status of the packages installed on the cluster. Periodically, the cluster manager performs a check to see if the packages are up to date. + +Status indicators provide quick visual feedback about each feature: + +| | | +| ------------------------------------------------ | --------------------------------------------------------------------------- | +| ![icon1](../images/cds_user_green_checkmark.png) | A green checkmark indicates that an object is healthy. | +| ![icon2](../images/cds_user_yellow_alert.png) | A yellow alert symbol calls attention to an object that requires attention. | +| ![icon3](../images/cds_user_red_error.png) | A red error symbol signifies that an object is not available. | +| ![icon4](../images/cds_user_orange_busy.png) | A busy-indicator signals that the cluster is processing a request. | +| ![icon5](../images/cds_user_grey_question.png) | A question mark indicates that the state of the resource is unknown. | + +Management options are on the node's context menu; right-click the node name to access the menu. The menu is context-sensitive; when applicable, select from: + +- `Download DB Logs` to download database server logs. +- `Download pgPool Logs` to download pgPool (load balancing) logs. +- `Promote` to [promote](../08_automatic_failover/#manual_promotion) the selected standby node to master. + +![](../images/ark_cluster_download_logs.png) + +If you choose to download a log file archive, the archive name is in the following form: + +`
--.tar.gz` + +Where: + +*address* is the address of the selected node. + +*log_type* is the type of log file (server type or pgPool). + +*date* is the date that the archive was generated. + +Use the icons along the left side of the `Clusters` tab to create new clusters or manage existing clusters: + +Status indicators provide quick visual feedback about each feature: + +| | | +| ---------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| ![icon6](../images/create_cluster_icon.png) | Use the `Add Cluster` icon to create a new Postgres cluster. | +| ![icon7](../images/scale_cluster_icon.png) | Select the `Scale Up` icon to manually add one or more replicas to the current cluster, or add additional storage to the current cluster servers. | +| ![icon8](../images/scale_down_icon.png) | Use the `Scale Down` icon to remove one or more specified replicas from the cluster. | +| ![icon9](../images/backup_icon.png) | Select the `Backup` icon to take a backup of the highlighted cluster (a single backup of the cluster data, and a backup of the cluster configuration files). | +| ![icon10](../images/clone_icon.png) | Select the `Clone` icon to create an exact duplicate of the master node of the selected database. When you clone a database, only the master node is recreated in the new cluster. | +| ![icon11](../images/upgrade_icon.png) | Use the `Upgrade` icon to perform a yum update (keeping the same server version) or perform an upgrade to a later server version. After the update, the cluster nodes will be rebooted (initiating any kernel updates required). Please note that a software update can take some time to complete. | +| ![icon12](../images/scale_machine_icon.png) | Use the `Scale Machine Type` icon to change the size of the virtual machine for the selected cluster. EDB Ark will copy the cluster into a new cluster of a different server class (RAM and CPU), and optionally re-assign the IP address of the existing cluster to the new cluster. | +| ![icon13](../images/restart_icon.png) | Use the `Download SSH Key` icon to download the SSH key associated with the selected cluster. Each cluster has a unique key that you can use to access nodes in that cluster. Before downloading the SSH key, you should disable pop-up blocker software from restricting pop-ups from the URL/s used by the Ark console or Ark clusters. | +| ![icon14](../images/download_ssh_key_icon.png) | Use the `Restart/Reload DB Servers` icon to reload one or more nodes of a selected cluster. Select the instance you wish to restart or reload on the `Restart/Reload DB Servers` dialog and specify if you would like to `Restart` or `Reload` the server before clicking `Confirm` to initiate the action. | +| ![icon15](../images/admin_settings_icon.png) | Use the `Cluster Administrative Settings` icon to access a popup dialog that allows you to view or modify the ownership and notification email address of a cluster. | +| ![icon16](../images/delete_icon.png) | Use the `Delete Cluster` icon to delete the currently selected cluster. A popup dialog will ask you to confirm you wish to terminate the cluster; once terminated, a cluster may only be restored from a backup. By default, the box next to `Release elastic IP address` is checked. Deselect this option if you wish to retain the IP address for re-use with other clusters. If you release the IP address, it will be made available for use by other clusters. When you terminate an active cluster, backups are not deleted. Backups (including user data) are retained until they are selected and deleted from the Backups tab. | + +- Select the [Details bar](#details_panel) to view information about the state of the selected cluster. +- Select the [Monitoring bar](#monitoring_panel) to view usage statistics for the selected cluster. +- Select the [Events bar](#events_panel) to review event logs describing activities on the selected cluster. + + + +## The Details Panel + +Click the `Details` navigation bar to open the `Details` panel. + +![*The Details panel on the Clusters tab.*](../images/clusters_tab_details_panel.png) + +Fig. 4.4: The Details panel on the Clusters tab. + +The left pane of the `Details` panel displays information about the currently selected cluster: + +- The name of the cluster +- The date and time that the cluster was created +- The name of the database superuser for the cluster +- The name of the cluster owner +- The email address to which notifications about the cluster will be sent +- The elastic IP address of the master node of the cluster +- The cluster size +- If the cluster is encrypted +- If applicable, the IOPS value for the cluster +- The region in which the cluster resides +- The virtual network or VPC ID in which the cluster resides +- The cluster's hardware type or Server Class +- The engine type and version that resides on the server +- If a template was used, the template name +- If the cluster is configured to update when provisioned + +You can use controls on the `Details` panel to specify: + +- If load balancer health should be monitored +- If database health should be monitored +- Failover preferences for the cluster +- Auto-scaling thresholds for the cluster +- Backup preferences for the cluster +- If continuous archiving should be enabled for the cluster + +When you modify the settings on the `Details` panel, EDB Ark displays a `New value saved` notice, confirming that the change has been saved. + +Please note: If a template was used to specify the configuration details for the cluster, the template may prohibit access to auto-scaling or manual scaling functionality. + +**Monitoring Load Balancer Health** + +By default, EDB Ark monitors the health of the load balancer to ensure that service is not interrupted. If the load balancer (pgpool) should fail while monitoring is enabled, PgPool will be automatically restarted. If the load balancer cannot be automatically restarted, EDB Ark will display a warning sign in the DB column next to the cluster name, and send a notification email to the cluster user. + +Deselect the `Monitor Load Balancer Health` checkbox to indicate that you do not wish for load balancer health to be monitored and automatically restarted if an interruption in service is detected. + +**Monitoring Database Health** + +By default, the `Monitor Database Health` checkbox is checked, indicating that EDB Ark is monitoring the health of the database to ensure that service is not interrupted. If the state of the database server changes to any state other than running while Monitor Database Health is checked, Ark will attempt to restart the database. + +If the database restart fails, Ark will restore the configuration files to their original settings and attempt a restart. If the server fails to restart after restoring the configuration, Ark will failover to a new instance. + +Uncheck the `Monitor Database Health` checkbox to instruct Ark to not automatically restart the database if the database stops. + +**Selecting a Cluster Healing Mode** + +Use the `Cluster healing mode` radio buttons to specify the type of failover that should be employed: + +- Select the `Replace failed master` with a new master radio button to specify that the cluster manager should create a new master to replace a failed master node. + + When replacing a failed master node with a new master node, the data volumes from the failed instance are attached to the new master node, preserving data integrity, while the replicas continue serving client queries. + +- Select the `Replace failed master with existing replica` radio button to specify that the cluster manager should promote a replica node to be the new master node for the cluster. + + When replacing a failed master node with an existing replica, a replica node is marked for promotion to master node, while the other replica nodes are re-configured to replicate data from the new master node. Since replica nodes use asynchronous replication, any data that was committed to the old master node, but not pushed to the replica prior to the node failure will be lost. + +Please note that replacing a failed master node with a new master node can take a bit longer than promoting a replica node to the role of master, but it does have the advantage of guaranteeing that no committed data will be lost. If recovery time for your cluster is more important than preserving any non-replicated transactions, then select Replace failed master with existing replica as the healing mode. + +**Adjusting Auto-Scaling Thresholds** + +Use the `Auto-Scaling Thresholds` controls on the `Details` panel to adjust the threshold at which EDB Ark automatically scales up cluster resources. For more information about using the controls, see [Adjusting the Automatic Scaling Thresholds](../10_automatic_scaling/#automatic_scaling) . + +**Modifying Backup Settings** + +Use the fields in the `Backup Settings` box to change your backup preferences for the selected cluster: + +- Use the `Backup Window` drop-down listbox to select an optimal time to process cluster backups; specify a time when the number of clients accessing the database is minimal. + +- Use the `Backup Retention` field to specify the number of backups that should be stored for the selected cluster. + +- Select the checkbox next to `Continuous Archiving (Point-in-Time Recovery)` to enable point-in-time recovery for a cluster. When enabled, a base backup is automatically performed that can to be used to restore to a specific point in time. All subsequent automatic scheduled backups will also support point-in-time recovery. Note that if you deselect this option, the cluster (and subsequent automatic backups) will be re-configured to not include support for point-in-time recovery. + + When point-in-time recovery is enabled, the value specified in the `Backup Retention` field determines the duration of the point-in-time recovery backup window. For example, if you specify a value of 7, the backup window will be `7` calendar days long. When the backup retention threshold is reached, the oldest base backup is removed, as well as any WAL files required to perform a recovery with that backup. + +**Reviewing Cluster Connection and Status Information** + +The `DNSNAME` table (located on the right side of the `Details` panel) contains a status overview and connection information for the selected cluster. If you have created replicas, the secondary server nodes are listed below the master node in the tree control; expand the tree control to view the status of the replication nodes. + +Status indicators provide quick visual feedback about each feature: + +| | | +| ------------------------------------------------- | --------------------------------------------------------------------------- | +| ![icon17](../images/cds_user_green_checkmark.png) | A green checkmark indicates that an object is healthy. | +| ![icon18](../images/cds_user_yellow_alert.png) | A yellow alert symbol calls attention to an object that requires attention. | +| ![icon19](../images/cds_user_red_error.png) | A red error symbol signifies that an object is not available. | +| ![icon20](../images/cds_user_orange_busy.png) | A busy-indicator signals that the cluster is processing a request. | +| ![icon21](../images/cds_user_grey_question.png) | A question mark indicates that the state of the resource is unknown. | + +Use the drop-down tab in the upper-right corner of the `DNSNAME` pane to select the columns that will be displayed in the panel: + +- The `AZ` column displays the Availability Zone in which the cluster resides. + +- The `VPC ID` column displays the identifier of the VPC on which the cluster resides. + +- The `LBPORT` column displays the port number to which a client application should connect to utilize load balancing. + +- The `DBPORT` column displays the default listener port for the Advanced Server or PostgreSQL server. + +- The `CXN` column displays the current number of connections to the node. + +- The `VM` column displays the state of the virtual machine on which the cluster resides. + +- The `HA` column displays the state of the high-availability cluster. + +- The `DB` column displays the state of the database server. + +- The `UP` column displays the current status of the packages installed on the cluster. Periodically, the cluster manager performs a check to see if the packages are up to date. If an update becomes available, the `UP` column will display a yellow alert symbol if the update is non-critical, or a red error symbol if the update is a critical (security) alert. + + If alerted to an out-of-date package, you can use the `Upgrade` icon to invoke a yum update to update the package on all of the nodes on your cluster. + + + +### The Monitoring Panel + +The `Monitoring` panel displays graphs that allow you to review statistical usage information about the amount of storage and the CPU load for the selected cluster. + +![*The Monitoring panel displays usage information.*](../images/clusters_tab_monitoring_panel.png) + +Fig. 4.5: The Monitoring panel displays usage information + +Use the `Time Range` drop-down listbox to modify the time period that the charted information on the Monitoring panel spans. + +The graphs on the `Monitoring` panel display resource usage information: + +- The `Data Space` chart displays the amount of allocated data space used by the selected cluster. The red line denotes the threshold specified by the `Data Space Threshold` slider on the `Details` panel (the threshold at which the cluster will be scaled-up). The blue line indicates the amount of the data space that is currently in use. +- The `Connections` chart displays a graph of the number of connections to the cluster during the selected time range. The red line denotes the threshold specified by the Connections slider on the Details panel. +- The `Load` chart displays the processing load placed on the CPU by connecting clients. The value displayed is the actual load average as read from the program, `/proc/loadavg`. The chart shows the number of jobs in the run queue or waiting for disk I/O, averaged over 15 minute periods. +- The `Replication Lag` chart displays the replication lag (in seconds) for the cluster. Each replica node is displayed as a separate colored line on the chart; the key at the bottom of the chart identifies the IP address of the node. + + + +## The Events Panel + +The `Events` panel displays an event log containing a history of selected events for the connected user. + +![*The Events panel displays server activity.*](../images/clusters_tab_events_panel.png) + +Fig. 4.6: The Events panel displays server activity. + +Highlight a cluster name to display only events for that cluster; if you do not select a cluster, the `Events` panel will display the collected events for the connected user. + +- Click a column heading to sort the logged activity by the selected column; click again to reverse the sort order. +- Use a mouse to select multiple rows from the event log for copy and paste operations. diff --git a/product_docs/docs/ark/3.5/ark_gsg/04_using_ark_console/03_ark_backups_tab.mdx b/product_docs/docs/ark/3.5/ark_gsg/04_using_ark_console/03_ark_backups_tab.mdx new file mode 100644 index 00000000000..69043721e98 --- /dev/null +++ b/product_docs/docs/ark/3.5/ark_gsg/04_using_ark_console/03_ark_backups_tab.mdx @@ -0,0 +1,26 @@ +--- +title: "The Backups Tab" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-ark-platform/installation-getting-started/getting-started-guide/3.5/ark_backups_tab.html" +--- + + + +Use the `Backups` tab to manage cluster backups; the tab displays a list of the available backups. + +![*The Backups tab of the Ark console.*](../images/backups_tab.png) + +Fig. 4.7: The Backups tab of the Ark console + +A backup captures and stores the status and condition of a cluster at a specific point-in-time. Click a column heading to sort the column contents; click again to reverse the sort order. + +If the comment in the `NOTES` column for a specific cluster includes `PITR`, point in time recovery is enabled on the cluster. When point in time recovery is enabled, the backup can be used to restore your cluster to a state at any given time since the backup was taken. + +Use the icons on the left side of the `Backups` tab to restore or delete backups: + +| | | +| ------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| ![icon1](../images/recover_backup_icon.png) | Highlight a backup in the list, and click the `Recover Backup` icon to open a dialog that allows you to restore a cluster from the selected backup. Specify a name for the cluster, and click the `Recover` button to continue. A popup confirms that the cluster is being restored; navigate to the Clusters tab to monitor the restoration process. | +| ![icon2](../images/delete_backup_icon.png) | Highlight one or more backups in the list and click the `Delete Backup` icon to delete the selected backups. A popup will ask you to confirm that you wish to delete the selected backups before the backups are actually deleted. | diff --git a/product_docs/docs/ark/3.5/ark_gsg/04_using_ark_console/04_ark_user_tab.mdx b/product_docs/docs/ark/3.5/ark_gsg/04_using_ark_console/04_ark_user_tab.mdx new file mode 100644 index 00000000000..2e85ad52cf4 --- /dev/null +++ b/product_docs/docs/ark/3.5/ark_gsg/04_using_ark_console/04_ark_user_tab.mdx @@ -0,0 +1,44 @@ +--- +title: "The User Tab" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-ark-platform/installation-getting-started/getting-started-guide/3.5/ark_user_tab.html" +--- + + + +Fields on the `User` tab allow you to view or modify information about the current user. + +![*The User tab of the Ark console.*](../images/ark_user_tab.png) + +Fig. 4.8: The User tab of the Ark console. + +To change the `First Name`, `Last Name`, or `Company Name` of the registered user, modify the corresponding fields and click the `Apply Changes` button. A popup will confirm that the changes have been applied. + +The `Notification Email` field on the `User` tab displays the default email address that will be used for cluster notifications unless an alternate address is provided. You can optionally: + +- provide an alternate email address when a cluster is created (on the `Create a new Server Cluster` dialog). +- modify a cluster’s notification email address on the `Administrative Settings` dialog. + +To change the default notification email address, enter a new address in the `Notification Email` field, and click the `Apply Changes` button. A popup dialog will open, prompting you to enter your password to confirm the change of address. Enter your password, and click `Confirm` to modify the address, or click `Cancel` to exit the popup without applying the change. + +If you elect to change the notification email address, EDB Ark will send a confirmation email to both the old notification address and the new notification address. + +## Updating a Password on Amazon AWS + +If your Ark console is deployed on Amazon AWS, the `User` tab displays the Amazon Role ARN associated with your Ark user account, and provides an option that allows you to modify your password. To modify your password, click the `Change Password` button. + +![*The Change Password dialog.*](../images/user_tab_change_password.png) + +Fig. 4.9: The Change Password dialog. + +To modify your password: + +- Provide your current password in the `Current Password` field. +- Enter the new password in the `New Password` field. +- Confirm the new password in the `Confirm New Password` field. + +Click the `Confirm` button to change the password to the new value; click `Cancel` to exit the dialog without modifying the password. + +When you change your password, a popup will confirm that the password has been changed and Ark will send an email to the notification email address associated with the account. diff --git a/product_docs/docs/ark/3.5/ark_gsg/04_using_ark_console/index.mdx b/product_docs/docs/ark/3.5/ark_gsg/04_using_ark_console/index.mdx new file mode 100644 index 00000000000..8d6bdd4e8fa --- /dev/null +++ b/product_docs/docs/ark/3.5/ark_gsg/04_using_ark_console/index.mdx @@ -0,0 +1,24 @@ +--- +title: "Using the Ark Console" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-ark-platform/installation-getting-started/getting-started-guide/3.5/using_ark_console.html" +--- + + + +The Ark console has four browser tabs that help you to manage clusters that reside in an AWS or Azure cloud: + +- The `Dashboard` tab provides an overview of the current resources in use, a quick-start Launch DB Cluster button, and (optionally), links to documentation and tutorials. +- The `Clusters` tab provides a management and information resources for your clusters. +- The `Backups` tab provides a list of the existing snapshots of your Ark clusters and buttons that allow you to create or delete a snapshot. +- The `User` tab provides a graphical management interface that you can use to review and manage your user account information. + +Please note that some features of the Ark console are not available to a [Template Only](../02_ark_overview/#template_only_user) user. + +
+ +ark_dashboard_tab ark_clusters_tab ark_backups_tab ark_user_tab + +
diff --git a/product_docs/docs/ark/3.5/ark_gsg/05_creating_a_cluster.mdx b/product_docs/docs/ark/3.5/ark_gsg/05_creating_a_cluster.mdx new file mode 100644 index 00000000000..ea33a290308 --- /dev/null +++ b/product_docs/docs/ark/3.5/ark_gsg/05_creating_a_cluster.mdx @@ -0,0 +1,339 @@ +--- +title: "Creating a Server Cluster" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-ark-platform/installation-getting-started/getting-started-guide/3.5/creating_a_cluster.html" +--- + + + +To create a server cluster, you can: + +- Use the `Launch DB Cluster` button (located on the `Dashboard` tab) to open the `Create a new Server Cluster` dialog and define a new cluster. +- Click the `New Server` button (located on the `Clusters` tab) to open the `Create a new Server Cluster` dialog and define a new cluster. + +If you are not a *Template Only* user (a user required to use a template when defining a cluster), the `Create a New Server Cluster` dialog will prompt you to select a deployment option. + +![*Specify your server launch preferences.*](images/create_cluster_launch_option.png) + +Fig. 5.1: Specify your server launch preferences. + +If you are a Template Only user or select the `Launch From Template` option on the deployment method selection dialog, a dialog opens that allows you to use a pre-defined template for the cluster configuration; for detailed information about using a template to create a cluster, see [Using a Template to Create a Cluster](#template_create_cluster) . + +If you select `Manually Define A Cluster`, a dialog opens that allows you to specify detailed information about the cluster configuration. For information about manually defining a cluster, see [Manually Creating a Cluster](#manually_create_cluster) . + +You can also use an existing cluster or a backup as a starting point for a new cluster: + +- For information about cloning a new server cluster from an existing cluster, see [Cloning a Server Cluster](#clone_server_cluster) . +- For information about restoring a backup to create a new cluster, see [Restoring a Cluster from Backup](07_manage_backup_recovery/#restore_create_cluster) . + + + +## Manually Creating a Cluster + +Before you can connect to Postgres from a client application, you must create a server cluster. Use the `Launch DB Instance` button (located in the upper left panel of the `Dashboard` tab) or click the `Add Server` button on the `Clusters` tab to open the `Create a New Server Cluster` dialog. + +Please note: not all fields and tabs documented in the following sections are applicable for all console host types. + +![*Specify information about the new cluster on the Step 1 tab.*](images/create_cluster_step_one.png) + +Fig. 5.2: Specify information about the new cluster on the Step 1 tab. + +Use fields on the `Create a New Server Cluster` dialog to specify information about the new cluster: + +- Specify a name for the new server cluster in the `Cluster Name` field. Ark uses the name specified in the `Cluster Name` field to identify the cluster when performing management functions. + +- Use the drop-down listbox in the `Engine Version` field to select the version of the Postgres engine that you wish to use. + +- Use the drop-down listbox in the `Server Class` field to specify the size of each cluster node. The server class determines the size and type (compute power and RAM) of each node within the cluster. When you select a server class, the attributes of the selected class are displayed below the server class field. + + You can adjust the amount of storage used by the cluster, or number of replicas in the cluster as your resource demands change. For example, you can start with a m1.small instance, and later, easily upgrade to a more capable c1.medium instance as your performance requirements dictate. + +- If your cluster resides on an Amazon host, you can check the box to the left of Use `Private IP` addresses to display addresses that are in your private network in the `VPC` field. + +- If your cluster resides on an Amazon host, use the drop-down listbox in the `VPC` field to specify the identity of the network in which the cluster should reside. + +- Use the drop-down listbox in the Number of nodes field to specify the number of server nodes that you wish to create. The name specified in the `Cluster Name` field will apply to the master node; each additional node will act as a replication server for the master node. + +- Use the `Storage GB` field to specify the initial size of the data space (in Gigabytes). + +- Check the box next to `Encrypted` to indicate that the cluster should be encrypted. EDB Ark uses the aes-xts-plain (512-bit) cipher suite to provide an encryption environment that is both secure and transparent to connecting clients. When encryption is enabled, everything residing on the cluster is encrypted except for the root filesystem. + +- If your cluster resides on an AWS host, check the box next to `EBS Optimized` to specify that your cluster should use an Amazon EBS-optimized instance and provisioned IOPS to guarantee a level of I/O performance. + + The `IOPS` field is enabled for those clusters that will reside on an EBS-optimized instance. If applicable, use the field to specify the level of I/O performance that will be maintained for the cluster by automatic scaling. The maximum value is 30 times the size of your cluster; for example, if you have a 4 Gigabyte cluster, you can specify a maximum value of 120. + +- Check the box next to `Perform OS and Software update?` to instruct EDB Ark to perform a yum update whenever the cluster is provisioned; this option is disabled for clusters that use statically provisioned servers. The yum update command updates all of the outdated packages that reside on the cluster. The update will occur when a cluster is scaled up, scaled down, or during a failover. + + When you check the box next to `Perform OS and Software update ?`, EDB Ark will warn you that enabling this functionality can significantly slow down cluster operations. Updating packages may slow down cluster maintenance operations; an update can easily take 10 minutes or more, and will initiate a reboot of the node. This setting is persistent; if you enable software updates for a cluster, you cannot directly disable software updates for that cluster at a later time. + +- Enter the name of the database superuser in the `Master User` field. + +- Enter the password associated with the database superuser in the `Master Password` field. + +- Use the `Notification Email` field to provide the email address that will receive notices about changes to the cluster status. + +If applicable on your host system, click the `Next` button to continue to the `Step 2` tab. + +![*The Step 2 tab.*](images/create_cluster_step_two.png) + +Fig. 5.3: The Step 2 tab. + +Use the fields on the `Step 2` tab to specify additional database information for each node of the cluster; the `Type` column identifies if a node is a `Master` or `Replica` node: + +- Use the `Region` drop-down listbox to the right of each node to select the region in which the node will reside. +- Use the `VPC` drop-down listbox to select the VPC in which the node will be created. +- Use the `AZ` drop-down listbox to select the Availability Zone in which the node will be created. +- Use the `Subnet` drop-down listbox to the right of each node to select the subnet that the node will use. Please note that if you manually specify a subnet, you must select a subnet that resides on your private network. + +Click the `Next` button to continue to the `Step 3` tab. + +![*Specify cluster security rules on the Step 3 tab.*](images/create_cluster_step_three.png) + +Fig. 5.4: Specify cluster security rules on the Step 3 tab. + +Use the fields on the `Step 3` tab to define security rules that allow access to the cluster. By default, the load balancer port is open to any IP address for client connections; you may choose to delete the rule, and specify a more restrictive IP range. + +To delete a rule from the list, highlight the entry and click the `Delete Rule` button; you will be prompted to confirm that you wish to delete the entry before the server removes the rule. + +Click the `Add Rule` button to open the `Add Rule` dialog and provide access to a port. + +![*Adding a security rule.*](images/create_cluster_security_rule.png) + +Fig. 5.5: Adding a security rule. + +On the `Add Rule` dialog: + +- Use the `Port` drop-down listbox to select the port that can be accessed from the specified CIDR. A non-administrative user can allow access to ports: + + `9999` - for client connections and load balancing. + + `5432` or `5444` - the cluster specific database listener port. + + An administrative user can use the `Add Rule` dialog to add a rule that allows SSH access to Port `22`. + +- Use the `CIDR` field to specify the address (or address range) that will be allowed access to the server through the selected port. + +When you're finished, click `Apply` to create the security rule. + +Then, click `Next` to continue to the `Step 4` tab. + +![*Specify backup information on the Step 4 tab.*](images/create_cluster_step_four.png) + +Fig. 5.6: Specify backup information on the Step 4 tab. + +Use the fields on the `Step 4` tab to specify additional database information: + +- Use the `# of automatic backups to retain` field to specify the number of server backups stored. When the specified number of server backups is reached, EDB Ark will delete the oldest backup to make room for a new backup. + + When point-in-time recovery (PITR) is enabled, the value specified in the # of automatic backups to retain setting determines the duration of the PITR backup window. For example, if you specify a value of 7, the PITR backup window will be 7 calendar days long. + +- Use the `Backup Window` field to specify a time that it is convenient to backup the server (you may wish to schedule backups to occur when the CPU load is the lightest). + +- Check the box next to `Continuous Archiving (Point-in-Time Recovery)` to enable point-in-time recovery for the cluster. When enabled, a base backup is automatically performed that can to be used to restore to a specific point in time. All subsequent automatic scheduled backups will also support point-in-time recovery. Note that if you deselect this option, the cluster (and subsequent automatic backups) will be re-configured to not include support for point-in-time recovery. + + **Please Note:** + + If your cluster resides on an Amazon host that is running CentOS 6.x, point-in-time recovery support is limited to the following regions: + + `ap-northeast-1` + + `ap-southeast-1` + + `ap-southeast-2` + + `eu-west-1` + + `sa-east-1` + + `us-standard (us-east-1)` + + `us-west-1` + + `us-west-2` + +Use the `Previous` button or select a tab to return to a tab to review or update information; when you have completed the `Create a New Server` dialog, click Launch to create the database cluster. + +A popup dialog confirms that EDB Ark is creating a new cluster; click the `X` in the upper-right corner of the popup to close the popup. + +![*A popup confirms that the new cluster is being created.*](images/create_cluster_complete.png) + +Fig. 5.7: A popup confirms that the new cluster is being created. + +Navigate to the `Clusters` tab of the Ark console to monitor the creation of the cluster. + + + +### Using a Template to Create a Cluster + +If you select the `Launch From Template` option when deploying a cluster or are a *Template only* user, a dialog that offers limited options will open when you deploy a cluster. + +![*Creating a cluster from a template.*](images/create_cluster_from_template.png) + +Fig. 5.8: Creating a cluster from a template. + +Use fields on the `Create a New Server Cluster` dialog to define your cluster: + +- Use the `Template Filter` panel to filter the list of templates that will be made available in the `Template Name` drop-down listbox. Select: + - The database or databases from which you would like to choose. + - The version or versions from which you would like to choose. +- Use the `Template Name` drop-down listbox to select the template that you wish to use to configure your cluster. To review template configuration details, select the `Full Template Details` link; the `Template Details` dialog opens. + +![*Reviewing Template details*](images/create_cluster_template_details.png) + +Fig. 5.9: Reviewing Template details + +After selecting the template that you wish to use, use the fields on the dialog to finish defining your cluster: + +- Use the `Cluster Name` field to specify a name for the new cluster. +- Use the `DB Master User` field to specify the name of the database superuser. +- Use the `DB Master Password` field to specify the password associated with the database superuser. +- Use the `Notification Email` field to provide the email address that will receive notices about changes to the cluster status. +- Use fields in the `Availability Zone and Subnet Details` section to specify the regions in which the cluster nodes will be deployed: + - Use the `Region` drop-down listbox to select the region in which the node will be deployed. + - Use the `VPC` drop-down listbox to select the vpc on which the node will be deployed. + - Use the `AZ` drop-down listbox to select the availability zone in which the node will reside. + - Use the `Subnet` drop-down listbox to select the subnet that the node will use. +- If applicable, highlight a rule, and use the `Add Rule` or `Delete Rule` button to define security rules that allow access to the cluster. By default, the load balancer port is open to any IP address for client connections; you may choose to delete the rule, and specify a more restrictive IP range. + - To delete a rule from the list, highlight the entry and click the `Delete Rule` button; you will be prompted to confirm that you wish to delete the entry before the server removes the rule. + - Click the `Add Rule` button to open the `Add Rule` dialog and provide access to a port. On the `Add Rule` dialog: + - Use the `Port` drop-down listbox to select the port that can be accessed from the specified CIDR. + - Use the `CIDR` field to specify the address (or address range) that will be allowed access to the server through the selected port. + +After completing the `Launch From Template` dialog, click the `Launch` button to provision a cluster that conforms to the cluster configuration. + + + +## Cloning a Server Cluster + +With a few simple steps, you can create a developer sandbox that contains a duplicate of the original master node. To clone a cluster, + +navigate to the `Clusters` tab and highlight the name of the cluster you wish to clone; then, click the `Clone` icon from the left margin. If you are not a Template Only user, a dialog will open that allows you to select your deployment method. + +![*Selecting a Cloning option.*](images/create_cluster_clone.png) + +Fig. 5.10: Selecting a Cloning option + +If you are a Template Only user or select the `Clone From Template` option on the deployment method selection dialog, a dialog opens that allows you to use a pre-defined template for the cluster configuration; for detailed information about using a template to clone a cluster, see [Using a Template to Create a Cluster](#template_create_cluster) . + +If you select `Manually Clone A Backup`, the dialog shown below opens. + +![*Creating a clone of a database.*](images/create_cluster_clone_manual.png) + +Fig. 5.11: Creating a clone of a database. + +When the `Create clone...` dialog opens, provide values in the requested fields: + +- Provide a name for the new cluster in the `Cluster Name` field. +- The clone will be created in the `Clone Region` listed below the cluster name. +- Check the box next to `Encryption` if you would like the clone to be created in an encrypted cluster. +- Check the box next to `Perform OS and Software update?` if you would like the server to perform a software update each time the clone is provisioned. Please note: this option is disabled if the database engine is statically provisioned. +- If applicable, check the box next to `Use Private IP addresses` to create the clone your private network. +- If your cluster resides on an Amazon host, use the `VPC` drop-down list box to specify a network name. +- Use the `Availability Zone` drop-down listbox to specify the availability zone in which the new cluster will be created. +- Use the `Subnet` drop-down listbox to select a subnet that will be used by the new cluster. +- Use the `Server Class` drop-down listbox to specify the initial size of the new cluster. The attributes of the selected server class will be listed below the `Server Class` field. +- If your cluster resides on an AWS host, check the box next to `EBS Optimized` to specify that your cluster should use an Amazon EBS-optimized instance and provisioned IOPS to guarantee a level of I/O performance. +- The `IOPS` field is enabled for those clusters that will reside on an EBS-optimized instance. If applicable, use the field to specify the level of I/O performance that will be maintained for the cluster by automatic scaling. +- Check the box next to `Continuous Archiving (Point-in-Time Recovery)` to enable point-in-time recovery on the clone. +- Use the buttons in the `Configure Network Security Rules` section to define security rules for the clone. + - To delete a rule from the list, highlight the entry and click the `Delete Rule` button; you will be prompted to confirm that you wish to delete the entry before the server removes the rule. + - Click the `Add Rule` button to open the `Add Rule` dialog and provide access to a port. On the `Add Rule` dialog: + - Use the `Port` drop-down listbox to select the port that can be accessed from the specified CIDR. + - Use the `CIDR` field to specify the address (or address range) that will be allowed access to the server through the selected port. + +When you've completed the dialog, click the `Clone` button to create the sandbox. + +When you clone a database, only the master node is recreated in the new cluster; for information about manually adding replica servers to the new cluster, see [Manual Scaling](09_manual_scaling/#manual_scaling). + + + +### Using a Template to Clone a Cluster + +A clone deployed with a template will be an exact duplicate of the original master node, but will adhere to the cluster deployment rules described in the template by the system administrator. If you are a Template Only user, you will be required to use a template when cloning a cluster. A non-Template Only user may find it easier (especially when cloning a number of clusters) to use a template to define the properties that are common to multiple deployments. + +![*Creating a clone of a database.*](images/create_cluster_clone_template.png) + +Fig. 5.12: Creating a clone of a database. + +When the `Create clone...` dialog opens, provide values in the requested fields: + +- Use the `Template Name` drop-down listbox to select a template that will be used for the new cluster; to review the cluster details associated with the template, click the Full Template Details link. +- Provide a name for the clone in the `Cluster Name` field. +- If applicable, use the `Availability Zone` drop-down listbox to specify the availability zone in which the new cluster will be created. +- If applicable, use the `Subnet` drop-down listbox to select a subnet that will be used by the new cluster. + +Use the fields in the `Configure Network Security Rules` section to define security rules that allow access to the cluster. By default, the load balancer port is open to any IP address for client connections; you may choose to delete the rule, and specify a more restrictive IP range. + +To delete a rule from the list, highlight the rule and click the `Delete Rule` button; you will be prompted to confirm that you wish to delete the entry before the server removes the rule. + +Click the `Add Rule` button to open the `Add Rule` dialog and provide access to a port. + +![*Adding a security rule.*](images/create_cluster_security_rule.png) + +Fig. 5.13: Adding a security rule. + +On the `Add Rule` dialog: + +- Use the `Port` drop-down listbox to select the port that can be accessed from the specified CIDR. A non-administrative user can allow access to ports: + + `9999` - for client connections and load balancing. + + `5432` or `5444` - the cluster specific database listener port. + + An administrative user can use the `Add Rule` dialog to add a rule that allows SSH access to Port `22`. + +- Use the `CIDR` field to specify the address (or address range) that will be allowed access to the server through the selected port. + +When you're finished, click `Apply` to create the security rule. + +After providing the details for the cluster, click the `Clone` button to create the clone of the cluster; select `Cancel` to exit the dialog without creating a cluster. + + + +## Modifying a Cluster’s Administrative Settings + +Fields on the `Administrative Settings` dialog display the current owner and the email address to which notification emails about the state of the cluster are sent. To modify the owner of a cluster or the email address associated with a cluster, highlight the name of a cluster on the `Clusters` tab, and click the `Administrative Settings` icon. The dialog shown below opens. + +![*The Administrative Settings dialog.*](images/create_cluster_admin_settings.png) + +Fig. 5.14: The Administrative Settings dialog + +Use the fields on the dialog to modify the administrative settings for the cluster: + +- Use the drop-down listbox in the `Owner` field to select a new cluster owner. Please note that only those users with permissions to access the tenant on which the cluster resides are included in the list. +- Use the `Notification Email` field to specify the address to which you wish notices about the state of the cluster to be sent. +- Check the box next to `Allow non-SSL DB connections` to specify that the database can accept connections from a source that is not authenticated via SSL; this will adjust the settings in the `pg_hba.conf` file. + +Use the fields in the `Configure Network Security Rules` section to define security rules that allow access to the cluster. By default, the load balancer port is open to any IP address for client connections; you may choose to delete the rule, and specify a more restrictive IP range. + +To delete a rule from the list, highlight the rule and click the `Delete Rule` button; you will be prompted to confirm that you wish to delete the entry before the server removes the rule. + +Click the `Add Rule` button to open the `Add Rule` dialog and provide access to a port. + +![*Adding a security rule.*](images/create_cluster_security_rule.png) + +Fig. 5.15: Adding a security rule. + +On the `Add Rule` dialog: + +- Use the `Port` drop-down listbox to select the port that can be accessed from the specified CIDR. A non-administrative user can allow access to ports: + + `9999` - for client connections and load balancing. + + `5432` or `5444` - the cluster specific database listener port. + + An administrative user can use the `Add Rule` dialog to add a rule that allows SSH access to Port `22`. + +- Use the CIDR field to specify the address (or address range) that will be allowed access to the server through the selected port. + + When you're finished, click `Apply` to create the security rule. + +After modifying the configuration details for the cluster, click the `Confirm` button; a dialog will open, prompting you to provide the password associated with the connected session. + +![*Provide a password to confirm changes.*](images/create_cluster_admin_settings_confirm.png) + +Fig. 5.16: Provide a password to confirm changes. + +Provide a password in the `Password` field and click `Confirm` to save your changes and exit, or `Cancel` to exit without saving the changes. diff --git a/product_docs/docs/ark/3.5/ark_gsg/06_connecting_to_cluster.mdx b/product_docs/docs/ark/3.5/ark_gsg/06_connecting_to_cluster.mdx new file mode 100644 index 00000000000..d69f3646e71 --- /dev/null +++ b/product_docs/docs/ark/3.5/ark_gsg/06_connecting_to_cluster.mdx @@ -0,0 +1,189 @@ +--- +title: "Connecting to an EDB Ark Cluster" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-ark-platform/installation-getting-started/getting-started-guide/3.5/connecting_to_cluster.html" +--- + + + +To connect to an Ark cluster, provide the IP address and port of the server, and the credentials associated with the role defined when the server cluster was created. + +![*The Details panel on the Clusters tab.*](images/clusters_tab_details_panel.png) + +Fig. 6.1: The Details panel on the Clusters tab. + +If you have defined a cluster with two or more servers, client applications should always connect to the load balancing port of the master server (the first DNS name listed on the `Details` panel). This will ensure that read requests are distributed efficiently across the cluster replicas to maximize performance, while write requests are directed only to the cluster master. Replica server nodes are listed below the master node in the tree view. + +- The `DNSNAME` column displays the address of the node; a connecting client should use this address when connecting to a specific server. + +- The `LB PORT` column displays the port number to which a client application should connect to utilize load balancing. + + Since only the master node of a multi-server cluster operates in read/write mode, all write queries will be directed to the master node, while any read-only queries may be directed to a replica node. + +- The `DB PORT` column displays the default listener port for the Advanced Server or PostgreSQL server. To connect directly to the database listener port, modify the cluster's security group to allow connections from your client. + +Use the authentication information (`Master User` and `Master Password`) provided on the `Create a New Server Cluster` dialog to establish the initial connection to the cluster as the database superuser. Please note that connecting with this identity grants you superuser privileges on the server; you should not share this connection information with un-trusted users. + +After connecting as the database superuser, you should create lesser-privileged user roles with which non-administrative users will connect. + + + +## Using ssh to Access a Server + +Before you can connect to a cluster node with ssh, an administrator must modify the security group of the cluster node to which you are connecting to permit ssh connections. If the console is federated (and the node resides in a remote region), you must modify the security group on the remote console to allow ssh connections. You can modify the security group via the Administrative Settings dialog on the Ark console or at the AWS console. + +EDB Ark creates an ssh key when you create a new cluster; each cluster has a unique key. Before connecting to an Ark instance, you must download the ssh key, and adjust the privileges on the key file. + +To download your private key, navigate to the `Clusters` tab, and click the `Download SSH Key` icon. The `Accessing Your Cluster Instance` popup opens as shown below. + +![*Accessing Your Cluster Instance.*](images/ark_clusters_ssh_popup.png) + +Fig. 6.2: Accessing Your Cluster Instance. + +The popup displays the tenant name, the cluster name, the name that you should use when connecting to the cluster, and the IP address to which you should connect. + +Before using the private key, you must modify the permissions on the keyfile. Use the following command to restrict file permissions: + +`chmod 0600 ` + +Where `ssh_key_file.pem` specifies the complete path and name of the EDB Ark ssh private key file. + +After modifying the key file permissions, you can use ssh to connect to the cluster. Include the complete path to the key file when invoking the command provided on the `Accessing Your Cluster Instance` popup. + +After connecting via ssh, you can: + +- Stop, start, or restart the Postgres server. +- Download and install Postgres extensions. +- Use the PostgreSQL Client Applications. +- Invoke PostgreSQL Server Applications. + +Please note: Postgres Server applications must be invoked by the Postgres cluster owner (identified when creating an EDB Ark cluster as the Master User). If you are using a PostgreSQL server, the default user name is `postgres`; if you are using Advanced Server, the default user name is `enterprisedb`. To change your identity after connecting via ssh, use the `su` command: + +`# sudo su ` + + + +## Connecting to EDB Ark with the psql Client + +After connecting to a server hosted on EDB Ark with the psql client, you can invoke SQL commands or use meta-commands to: + +- Execute queries +- Insert, update, and delete data +- Create and manage database objects (tables, indexes, views, etc.) +- Create user roles and manage privileges +- Review object and role attributes +- Invoke scripts containing complex (or simple) commands + +By default, an EDB Ark cluster is only open to connections via port `9999` on the master node. Port `9999` is a good choice if you are connecting for the purpose of querying the database, but if you are modifying database objects, or performing administrative functions, you should connect directly to the server's listener port. + +Please note: some administrative functions, if executed over port `9999`, may be directed to the incorrect node of a multi-node cluster where they may not have the intended effect, or may return an invalid value. + +The listener port number is displayed in the `DBPORT` column of the `Details` panel of the `Clusters` tab. + +Before connecting to the server's listener port, an Ark administrator must modify the security group to allow connections from the host of your client application. + +**Connecting with psql From a Local Workstation** + +After installing Advanced Server or PostgreSQL on a local workstation, you can use psql to perform administrative tasks on an EDB Ark cluster. + +To open the psql client on an Advanced Server Windows workstation, navigate through the operating system menu to the `EDB Postgres` menu and select `EDB-PSQL`. + +To open a psql client on a PostgreSQL workstation, navigate through the operating system menu to the `PostgreSQL` menu, and select `SQL Shell (psql)`. + +If you have used a package to install Advanced Server or PostgreSQL, you will find the executable in the `bin` directory under your installation. You can invoke the executable at the command line; for example, to start the client on an Advanced Server host, use the command: + +`/usr/edb/as11/bin/psql -d edb -U enterprisedb` + +![*The psql command line utility.*](images/connecting_psql_login.png) + +Fig. 6.3: The psql command line utility. + +Provide connection information for the server to which you are connecting: + +- When prompted for a Server, enter the IP address or DNS name of the EDB Ark server. The IP address is displayed in the `DNSNAME` column on the `Details` panel of the `Clusters` tab of the Ark console. +- When prompted for a Database, enter the name of the database to which you wish to connect. By default, an Advanced Server cluster is created with a database named edb; a PostgreSQL cluster is created with a database named postgres. +- When prompted for a `Port`, enter the port on which the server is listening. For database queries, you can use port `9999`; if you are modifying database objects or performing administrative functions, you should use the server's listener port (5444 for an Advanced Server cluster, 5432 for a PostgreSQL cluster). +- When prompted for a `Username`, enter the role you wish to use when connecting to the server. The name of the database superuser is specified in the Master User field when defining an EDB Ark server cluster. By default, the Advanced Server database superuser is `enterprisedb`. The default superuser of a PostgreSQL database is `postgres`. +- When prompted for a `Password`, enter the password associated with that role. The database superuser's password is specified in the Master Password field when defining an EDB Ark server cluster. + +After connecting, the prompt will display the name of the database to which you are connected. + +**Invoking psql on an EDB Ark Server** + +To use a copy of the psql client that resides on the EDB Ark host, first connect to the cluster using ssh: + +`ssh -i path ` + +After connecting to the host, assume the identity of the database superuser (or a user with sufficient privileges to invoke the client). On an Advanced Server host, use the command: + +`sudo su enterprisedb` + +On a PostgreSQL host, use the command: + +`sudo su postgres` + +Then, invoke the psql client. On an Advanced Server host, use the command: + +`/usr/bin/edb-psql -d edb` + +On a PostgreSQL host, use the command: + +`/usr/bin/psql -d postgres` + +Include the `-d` option to specify the name of the database to which you wish to connect. The session opens as shown below. + +![*A psql session on the EDB Ark host.*](images/connecting_psql_on_ark.png) + +Fig. 6.4: A psql session on the EDB Ark host. + +To exit the psql client, enter `\q`. + +For information about using psql and the psql meta-commands, please see the Postgres documentation at: + + + + + +## Using iptables Rules + +EDB Ark uses iptables rules to manage security on the console and cluster nodes. Please note that you must *not* modify the iptables rules provided by EDB Ark. + +If you are using iptables on the host of the Ark console, do not modify the following rules: + +```text +iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 –j REDIRECT --to-port 8080 +iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 443 –j REDIRECT --to-port 8181 +iptables -I INPUT 1 -p tcp --dport 8181 -j ACCEPT +iptables -I INPUT 1 -p tcp --dport 8080 -j ACCEPT +``` + +These rules: + +- redirect http and https traffic on ports `80` and `443` to the default ports (`8080` and `8181`). +- allow inbound traffic to the default administration port. +- allow inbound traffic on `8080` and `8181`. +- save the configuration (to preserve the behaviors when the system reboots). + +If you are using iptables on an Advanced Server cluster, do not modify the following rules: + +```text +iptables -I INPUT 1 -p tcp --dport 7800:7802 -j ACCEPT +iptables -I INPUT 1 -p tcp --dport 5444 -j ACCEPT +iptables -I INPUT 1 -p tcp --dport 9999 -j ACCEPT +``` + +If you are using iptables on a PostgreSQL cluster, do not modify the following rules: + +```text +iptables -I INPUT 1 -p tcp --dport 7800:7802 -j ACCEPT +iptables -I INPUT 1 -p tcp --dport 5432 -j ACCEPT +iptables -I INPUT 1 -p tcp --dport 9999 -j ACCEPT +``` + +The rules: + +- allow inbound traffic from the Ark console on ports `7800` and `7802`. +- allow inbound traffic on the database listener ports. +- save the configuration (to preserve the behaviors when the system reboots). diff --git a/product_docs/docs/ark/3.5/ark_gsg/07_manage_backup_recovery.mdx b/product_docs/docs/ark/3.5/ark_gsg/07_manage_backup_recovery.mdx new file mode 100644 index 00000000000..0f191432056 --- /dev/null +++ b/product_docs/docs/ark/3.5/ark_gsg/07_manage_backup_recovery.mdx @@ -0,0 +1,156 @@ +--- +title: "Managing Backups and Recovery" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-ark-platform/installation-getting-started/getting-started-guide/3.5/manage_backup_recovery.html" +--- + + + +When you use the Ark console to take a backup, EDB Ark makes a copy of the contents of the PostgreSQL `PGDATA` directory. The `PGDATA` directory contains the data and the meta-data required to construct an exact copy of the Postgres data cluster (the data and the database objects that reside within that Postgres instance). + +To capture a backup of a cluster, navigate to the `Clusters` tab, highlight a name in the cluster list, and click the `Backup` icon. The `Backup Data?` dialog opens as shown below: + +![*The Backup Data? dialog.*](images/backup_data_dialog.png) + +Fig. 7.1: The Backup Data? dialog. + +You can include a reference note about the backup that can be viewed on the Backups tab by adding a message to the `Optional notes` field on the `Backup Data?` dialog before clicking the `Backup` button. + +When you click the `Backup` button, EDB Ark will perform the backup. While EDB Ark performs the backup, the `PENDING` column of the selected cluster on the `Clusters` tab will display the message: `Backup in progress`. + + + +## Performing a Base Backup for Point-In-Time Recovery + +When point-in-time recovery is enabled, a base backup is automatically performed that can to be used to restore to a specific point in time. All subsequent automatic scheduled backups will also support point-in-time recovery. Note that if you deselect this option, the cluster (and subsequent automatic backups) will be re-configured to not include support for point-in-time recovery. + +When point-in-time recovery is enabled, the value specified in the `Backup Retention` field of the `Create cluster` dialog determines the duration of the point-in-time recovery backup window. For example, if you specify a value of `7`, the backup window will be 7 calendar days long. When the backup retention threshold is reached, the oldest base backup is removed, as well as any WAL files required to perform a recovery with that backup. + +Please note that you cannot perform a base backup on a cluster while the database is in recovery and not accepting connections. If you attempt to perform a base backup during recovery, the backup will fail (the failure will be noted on the `Events` panel of the `Clusters` tab). You should instead wait until the database recovery is complete to enable point-in-time recovery for the cluster. + +Point-in-time recovery is enabled on the [Details panel](04_using_ark_console/02_ark_clusters_tab/#details_panel) of the [Clusters tab](04_using_ark_console/02_ark_clusters_tab/#ark_clusters_tab) . If a base backup fails, you can trigger EDB Ark to perform a base backup by disabling point-in-time recovery, and then (after waiting a few minutes) re-enable point-in-time recovery. + + + +## Reviewing Stored Backups + +Navigate to the [Backups tab](04_using_ark_console/03_ark_backups_tab/#ark_backups_tab) to review a list of stored cluster backups. + +![*The Backups tab of the Ark console.*](images/backups_list.png) + +Fig. 7.2: The Backups tab of the Ark console. + +A backup captures and stores the status and condition of a cluster at a specific point-in-time. + +- The `ID` column contains a unique backup identifier. +- The `CLUSTER` column displays the name of the cluster that was the target of the backup. +- The `NOTES` column displays an informational note (provided by either the user or the system at the time of backup). Those messages that include (PITR) can be restored to a specific point-in-time within the backup window. +- The `ENGINE VERSION` column contains a description of the Postgres version that the saved cluster is using. +- The `CAPACITY` column contains the storage capacity of the cluster at the time that the backup was taken. +- The `STARTED` column displays the date and time that the backup was initiated. +- The `ENDED` column displays the data and time that the backup completed. + +You can use the icons on the left side of the Backups tab to restore or delete the selected backup: + +Status indicators provide quick visual feedback about each feature: + +| | | +| ---------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| ![icon1](images/recover_backup_icon.png) | Highlight a backup in the list, and click the Recover Backup icon to open a dialog that allows you to restore a cluster from the selected backup. | +| ![icon2](images/delete_backup_icon.png) | Highlight one or more backups in the list and click the Delete Backup icon to delete the selected backups. A popup will ask you to confirm that you wish to delete the selected backups before the backups are actually deleted. | + + + +## Restoring a Cluster from Backup + +You can use a template or manually provide cluster properties when restoring a cluster from a backup. To restore a backup into a new cluster, navigate to the [Backups tab](04_using_ark_console/03_ark_backups_tab/#ark_backups_tab) and highlight the name of a backup. Then, click the `Recover Backup` icon (located in the left margin). + +If you are not a Template Only user, a dialog will open that allows you to select the method by which you will specify cluster preferences. + +![*Selecting a Restore option.*](images/select_restore_backup.png) + +Fig. 7.3: Selecting a Restore option. + +If you are a Template Only user or select the `Restore From Template` option on the recovery method dialog, a dialog opens that allows you to use a pre-defined template for the cluster configuration; for detailed information about using a template to clone a cluster, see [Using a Template to Restore from Backup](#template_restore) . + +If you select `Manually Restore A Backup`, the following dialog opens: + +![*The Recover Data from a Backup dialog.*](images/manually_recover_backup.png) + +Fig. 7.4: The Recover Data from a Backup dialog. + +When the `Recover Data from a Backup` dialog opens: + +- If applicable, use the calendar selector in the `Recovery Point` field to specify the recovery target (the date and time that the database was in the state in which you wish the new cluster to start). The Recovery Point field is only displayed for backups that were taken with point-in-time recovery implemented; you cannot perform a point-in-time recovery with a backup unless point-in-time recovery is enabled for the cluster when the backup was taken. + +- Specify a name for the new cluster in the `Cluster Name` field. + +- Check the box next to `Encryption` to specify that the new cluster should reside in an encrypted cluster. Please note that you can restore a non-encrypted backup into an encrypted cluster. + +- Check the box next to `Perform OS and Software` update to instruct EDB Ark to perform a yum update whenever the cluster is provisioned. Please note: this option is disabled if the database engine is statically provisioned. + +- If applicable, check the box to the left of `Use Private IP addresses` to restore the backup into a private IP address. + +- If your cluster resides on an Amazon host, use the `VPC` drop-down listbox to select a VPC on which the cluster will reside. + +- Use the `Availability Zone` drop-down listbox to the right of each node to select the availability zone in which the node will reside. + +- Use the `Subnet` drop-down listbox to the right of each node to select the subnet that the node will use. + +- Use the `Server Class` drop-down listbox to specify the server class of the new cluster. + +- If your cluster resides on an AWS host, check the box next to `EBS Optimized` to specify that your cluster should use an Amazon EBS-optimized instance and provisioned IOPS to guarantee a level of I/O performance; + + The `IOPS` field is enabled for those clusters that will reside on an EBS-optimized instance. If applicable, use the field to specify the level of I/O performance that will be maintained for the cluster by automatic scaling. The maximum value is 30 times the size of your cluster; for example, if you have a 4 Gigabyte cluster, you can specify a maximum value of 120. + + Note that you can increase the IOPS value of your cluster by recovering the cluster from a snapshot into a cluster with a higher value or cloning your database into a cluster with a higher IOPS value. + +- Check the box next to `Continuous Archiving (Point-In-Time Recovery)` to indicate that the new cluster should implement point-in-time recovery. Please note that to restore into a cluster with point-in-time recovery enabled, the backup from which you are restoring must have had point-in-time recovery implemented when the backup was taken. The checkbox will not be available if point-in-time recovery was not implemented when the backup was taken. + +- Use the `Add Rule` button to open a dialog that allows you to open a port for connections from a specified CIDR formatted address.On the Add Rule dialog: + + Use the `Port` drop-down listbox to select the port that can be accessed from the specified CIDR. A non-administrative user can allow access to ports: + + 9999 - for client connections and load balancing. + + 5432 or 5444 - the cluster specific database listener port. + + An administrative user can use the `Add Rule` dialog to add a rule that allows SSH access to Port `22`. + + Use the CIDR field to specify the address (or address range) that will be allowed access to the server through the selected port. + + When you're finished, click Apply to create the security rule and continue. + +- Highlight a rule and click the `Delete Rule` button to remove a security rule. + +Click the `Recover` button to continue, or the `Cancel` button to exit without starting the recovery process. A popup confirms that the cluster is being restored; close the popup and navigate to the `Clusters` tab to monitor the restoration process. + +![*The recovery is in progress.*](images/recovery_in_progress.png) + +Fig. 7.5: The recovery is in progress. + +Please note: when you restore a backup, the server configuration will match the original configuration, but the server addresses will change. + +Please note: when restoring a cluster from backup, you may need to modify parameters in the postgresql.conf file on the restored cluster to reflect the available memory of the new instance if the server class has changed from the original setting (the default value in the `Server Class` field). After modifying the server configuration, restart the server for the changes to take effect. + + + +### Using a Template to Restore from Backup + +If you are a Template Only user, you will be required to use a template when restoring a backup into a new cluster. A non-Template Only user may find it easier (especially when restoring a number of clusters) to use a template to define the properties that are common to multiple deployments. + +![*Using a template to restore from a backup.*](images/template_recover_from_backup.png) + +Fig. 7.6: Using a template to restore from a backup. + +If you are using a template when restoring a cluster from backup, use the dialog shown to provide the non-template details: + +- Use the `Template Name` drop-down listbox to select a template that will be used for the new cluster; to review the cluster details associated with the template, click the Full Template Details link. +- If applicable, use the calendar selector to specify a point-in-time to which to recover. +- Specify a name for the new cluster in the `Cluster Name` field. +- Use the `AZ` drop-down listbox to the right of each node to select the availability zone in which the node will reside. +- Use the `Subnet` drop-down listbox to the right of each node to select the subnet that the node will use. +- Use the `Add Rule` button to open a dialog that allows you to open a port for connections from a specified CIDR formatted address. +- Highlight a rule and click the `Delete Rule` button to remove a security rule. diff --git a/product_docs/docs/ark/3.5/ark_gsg/08_automatic_failover.mdx b/product_docs/docs/ark/3.5/ark_gsg/08_automatic_failover.mdx new file mode 100644 index 00000000000..a589f3dd098 --- /dev/null +++ b/product_docs/docs/ark/3.5/ark_gsg/08_automatic_failover.mdx @@ -0,0 +1,61 @@ +--- +title: "Automatic Failover" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-ark-platform/installation-getting-started/getting-started-guide/3.5/automatic_failover.html" +--- + + + +The EDB Ark cluster manager constantly monitors the state of each cluster. Each cluster is composed of a single master Postgres instance that operates in read-write mode (performing all writes to the database) and one or more replica Postgres instances. Replica nodes are read-only, automatically duplicating all data found on the master node, and all changes made to that data. + +If a replica fails, EDB Ark automatically spins up a new replica instance and attaches it to the master database. The cluster continues operating during the replacement process, with the master servicing writes and reads, and the remaining replicas servicing reads. Overall read performance may degrade for a short period of time until the cluster is returned to full strength. + +If a master failover occurs, the server will enforce one of two behaviors, specified by the Cluster healing mode radio buttons, located on the Details panel of the Clusters tab: + +- Select the `Replace failed master with a new master` radio button to specify that the cluster manager should create a new master to replace a failed master node. + + When replacing a failed master node with a new master node, the data volumes from the failed instance are attached to the new master node, preserving all transactions that were committed on the master. + +- Select the `Replace failed master with existing replica` radio button to specify that the cluster manager should promote a replica node to be the new master node for the cluster. Choose this option when speed of recovery is important, and your application can tolerate the loss of some transactions. This is the default behavior. + + When replacing a failed master node with an existing replica, a replica node is marked for promotion to master node, while the other replica nodes are re-configured to replicate data from the new master node. Since replica nodes use asynchronous replication, any data that was committed to the old master node, but not yet pushed to the replica prior to the node failure will be lost. + + If you opt to promote a replica to replace the master node, a replacement replica will also be added to the cluster during the failover process, returning the cluster to full strength. This self-healing property is at the heart of providing high availability to cluster users. + +Please note that replacing a failed master node with a new master node can take a bit longer than promoting a replica node to the role of master, but it does have the advantage of guaranteeing that no committed data will be lost. + +**Triggering a Failover** + +By design, EDB Ark *does not* perform a failover when the Postgres server is stopped, because the server stop or restart may be intentional: + +- A user may intentionally restart the server when performing maintenance or tuning. For example, a server restart is required when updating server configuration parameters; this restart will not invoke failover. +- If a user intentionally kills the postmaster process, the server will not failover; the postmaster process is responsible for restarting the server. +- The Postgres server may intentionally perform a server restart. For example, when a backend server process crashes (or is intentionally killed by a user), the Postgres server automatically invokes a restart. + +When a failover is complete, EDB Ark does not delete the original master instance of the database; you can use the preserved master instance to perform any post-mortem activities that may be required. If you do not wish to utilize the preserved instance, you should use the management console to delete the instance. + + + +## Manually Promoting a Standby Node + +You can use the `Promote` option on a cluster's context menu to manually promote a standby node to master node. When you promote the standby, the master node is deleted. You must initiate the promotion from a console that resides in the same region as the standby that is being promoted. + +To promote a node to master, right-click on the cluster name in the `Details` panel, and select `Promote` from the context menu. + +![*The Promote option on a context menu*](images/manual_promote_context.png) + +Fig. 8.1: The Promote option on a context menu + +When you select the `Promote` option, the console will ask you to confirm that you wish to promote the standby to master and delete the original master node. + +![*Confirming that you wish to promote a standby*](images/manual_promote_confirmation.png) + +Fig. 8.2: Confirming that you wish to promote a standby + +Click `Continue` to instruct Ark to perform the promotion. During the promotion, status messages will inform you of the state of the cluster. + +![*Status messages display the state of the cluster*](images/manual_promote_status.png) + +Fig. 8.3: Status messages display the state of the cluster diff --git a/product_docs/docs/ark/3.5/ark_gsg/09_manual_scaling.mdx b/product_docs/docs/ark/3.5/ark_gsg/09_manual_scaling.mdx new file mode 100644 index 00000000000..9d414a2892b --- /dev/null +++ b/product_docs/docs/ark/3.5/ark_gsg/09_manual_scaling.mdx @@ -0,0 +1,108 @@ +--- +title: "Manual Scaling" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-ark-platform/installation-getting-started/getting-started-guide/3.5/manual_scaling.html" +--- + + + +The Ark console makes it simple to add replicas and storage to an existing cluster, or to upgrade to a larger server class (i.e. vertical scaling). + +- Adding additional replicas to your database cluster increases the CPU power available to handle additional client requests or applications, increasing the number of client connections that can be serviced. When the scale up is complete, each additional replica automatically assumes a share of the read-only workload from incoming queries. +- Adding additional storage to the cluster increases the amount of data that can be stored by the database servers. When you add additional storage to the cluster, each member of the cluster gets the additional storage amount. +- Vertically scaling to a larger server class increases the processing capabilities of your cluster, allowing the server to process customer requests with greater speed. + +You can also downsize a cluster by selectively removing a replica. You can machine scale to a smaller machine type to reduce resource usage (cpu/memory) and/or cost. + +Please note: if you are a Template Only user, access to automatic scaling behaviors is determined by the configuration specified on the template used to deploy your cluster. + + + +## Manually Adding Replicas and Storage + +EDB Ark's `Scale Up` dialog makes it simple to manually add additional replicas to a cluster if you find that server resources are strained. The dialog also allows you to increase the amount of storage available to a cluster. + +If you specify that EDB Ark should add both storage and replicas, EDB Ark will process the request for additional storage *before* adding replicas to the cluster. All of the nodes on the cluster will be of the newly specified storage size. + +To add a replica or storage space to a cluster, navigate to the [Clusters tab](04_using_ark_console/02_ark_clusters_tab/#ark_clusters_tab) , highlight a cluster name, and select the `Scale Up` icon. The `Scale Up` dialog opens as shown below: + +![*The Scale Up dialog.*](images/manually_scale_up_step_one.png) + +Fig. 9.1: The Scale Up dialog. + +Use the drop-down listboxes on the `Step 1` tab to specify: + +- The number of replicas to add to the cluster. +- The region in which each node of the cluster will be provisioned. +- The VPC in which the node will be provisioned. +- The AZ (availability zone) in which the node will be provisioned. +- The subnet that will be used by each node of the cluster. +- The amount of storage memory (in Gigabytes) that will be added to each server in the cluster. + +When you've completed the dialog, click `Next` to continue to the `Step 2` tab: + +![*The Step 2 tab.*](images/manually_scale_up_step_two.png) + +Fig. 9.2: The Step 2 tab. + +Use the `Previous` button to return to the `Step 1` tab to modify specified values. Use the `Scale Up` button to confirm that you wish to add the specified number of replication servers or the specified amount of memory to the cluster. Use the `Cancel button`, or simply close the dialog to exit without modifying the cluster. + +When scaling begins, EDB Ark will confirm that replicas or memory are being added to the cluster. + + + +## Manually Removing a Replica + +EDB Ark's `Scale Down` dialog makes it simple to manually remove one or more unneeded replicas from a cluster. + +To delete a replica, navigate to the [Clusters tab](04_using_ark_console/02_ark_clusters_tab/#ark_clusters_tab) , and click the `Scale Down` icon. The `Scale Down` dialog opens as shown below: + +![*The Scale Down dialog.*](images/manually_scale_down_step_one.png) + +Fig. 9.3: The Scale Down dialog. + +Check the box to the left of the name of a replica, and click `Next` to proceed to the `Step 2` tab of the dialog. + +![*The Step 2 tab*](images/manually_scale_down_step_two.png) + +Fig. 9.4: The Step 2 tab + +Click `Scale Down` to confirm that you wish to remove the replica, or Previous to return to the `Step 1` tab. Use the `Cancel` button, or simply close the dialog to exit without modifying the cluster. + + + +## Manually Changing the Server Class + +When your RAM processing needs, CPU power, or other circumstances warrant a larger virtual machine for your application, you can vertically scale to a larger server class. You can either: + +- Use the `Scale Machine Type` dialog to copy the cluster into a larger server class. + + When you use the `Scale Machine Type` dialog to move your cluster into a larger server class, you must provide a new name for the upgraded cluster. You can also use the dialog to specify that EDB Ark should re-assign the IP address of the cluster, so the upgrade will be transparent to connecting clients. + + Please note: you may wish to postpone the IP address reassignment to perform configuration tasks or test the new server size. + +- Use the `pg_dump` and `pg_restore` utilities to move the cluster into a larger server class. + + To move to a larger server class, use the pg_dump utility to make a backup of the cluster. After backing up the cluster, create a new instance with the larger server class, and use pg_restore to restore the cluster on the new instance. For information about using pg_dump and pg_restore, see [Moving an Existing Database into a New Cluster](13_database_management/#move_existing_database) . + +You can also downsize a cluster by selectively removing a replica. You can machine scale to a smaller machine type to reduce resource usage (cpu/memory) and/or cost. + +When you vertically scale your cluster with the `Scale Machine Type` dialog, EDB Ark will copy the existing cluster into a new cluster of a different server class, and optionally re-assign the IP address of the existing cluster to the new cluster. To open the `Scale Machine Type` dialog, navigate to the [Clusters tab](04_using_ark_console/02_ark_clusters_tab/#ark_clusters_tab) and select the `Scale Machine Type` icon. + +![*The Scale Machine Type dialog.*](images/scale_machine_type.png) + +Fig. 9.5: The Scale Machine Type dialog. + +Use the fields on the `Scale Machine Type` dialog to specify details about the new cluster: + +- Check the box next to `Perform OS and Software update` to instruct EDB Ark to perform a yum update whenever the cluster is provisioned. Please note: this option is disabled if the database engine used to provision the cluster is statically provisioned. + +- Use the `Server Class` drop-down listbox to specify the size of the new cluster. + + Please note that if you are a Template Only user, the types listed in the `Server Class` drop-down listbox will be limited to those types that are included in template definitions for the current tenant. + + When you click the `Scale` button to start scaling the cluster, EDB Ark will confirm that the scaling is in progress. + + Before creating the new cluster, EDB Ark will perform a backup of the original cluster. During the process, status indicators in the `PENDING` column of the `Clusters` tab will keep you informed as EDB Ark backs up the original cluster, and initializes the new cluster. diff --git a/product_docs/docs/ark/3.5/ark_gsg/10_automatic_scaling.mdx b/product_docs/docs/ark/3.5/ark_gsg/10_automatic_scaling.mdx new file mode 100644 index 00000000000..8c904536358 --- /dev/null +++ b/product_docs/docs/ark/3.5/ark_gsg/10_automatic_scaling.mdx @@ -0,0 +1,30 @@ +--- +title: "Automatic Scaling" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-ark-platform/installation-getting-started/getting-started-guide/3.5/automatic_scaling.html" +--- + + + +Adding additional replicas to your database cluster increases the number of client connections and queries that each cluster can handle, while maintaining a high-level of overall performance. Each additional replica automatically assumes a share of the read-only workload from incoming queries. + +When auto-scaling in enabled, EDB Ark monitors the server storage and connection resources in use, and automatically adds additional resources when usage exceeds a user specified percent. + +- When the `% of Storage Size used` is reached, EDB Ark will automatically increase your data space by 50%. +- When the `# of Server Connections` is reached, EDB Ark adds replica nodes. + +Please note: if you are a Template Only user, access to automatic scaling behaviors is determined by the configuration specified on the template used to deploy your cluster. + + + +## Adjusting the Automatic Scaling Thresholds + +Use the `Auto Scale Options` controls to adjust the threshold at which EDB Ark automatically scales up cluster resources. The `Auto Scale Options` controls are located on the `Details` panel; to access the `Details` panel, navigate to the [Clusters tab](04_using_ark_console/02_ark_clusters_tab/#ark_clusters_tab), and highlight the name of a cluster. + +![*The Auto Scale Options controls.*](images/auto_scale_options_dialog.png) + +Fig. 10.1: The Auto Scale Options controls. + +Adjust the `Auto Scale Options` sliders to increase or decrease the thresholds at which automatic scaling is invoked. When you modify the values, EDB Ark will display a `New Value Saved` notice, alerting you that your changes have been saved. diff --git a/product_docs/docs/ark/3.5/ark_gsg/11_load_balancing.mdx b/product_docs/docs/ark/3.5/ark_gsg/11_load_balancing.mdx new file mode 100644 index 00000000000..9ba45ccb176 --- /dev/null +++ b/product_docs/docs/ark/3.5/ark_gsg/11_load_balancing.mdx @@ -0,0 +1,80 @@ +--- +title: "Load Balancing" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-ark-platform/installation-getting-started/getting-started-guide/3.5/load_balancing.html" +--- + + + +EDB Ark uses pgPool functionality to implement automatic load balancing. Load balancing increases system performance by distributing client queries to replica nodes, while routing database modifications to the master node. Any modifications to the master node are subsequently propagated to each replica using Postgres streaming replication. + +**Utilizing Load Balancing** + +By default, load balancing is enabled on an EDB Ark cluster. To utilize load balancing, you should direct client applications to connect to the load balancing port (by default, 9999). A cluster's load balancing port number is displayed in the LBPORT column on the Details pane of the Clusters tab of the Ark console. + +pgPool may direct the following statement types to *either* a primary or a standby node: + +- SELECT statements (not listed below) +- COPY TO +- DECLARE +- FETCH +- CLOSE +- SHOW +- SET +- DISCARD +- DEALLOCATE ALL + +When deciding which node a query should be routed to, pgPool checks the transaction log number; if the transaction log number on the standby server is lower than the log number on the master, pgPool routes the statement to the master node. This helps to ensure that the data returned by the query is the most recent available. + +In some cases, specific clauses within a query statement will signal pgPool to direct a statement to the master node. In other cases, the transaction type, or order of commands within a transaction can direct a statement to the master node. By default, the following transaction types will always be executed on the master node: + +- SELECT INTO, SELECT FOR UPDATE or SELECT FOR SHARE statements +- SELECT statements within SERIALIZABLE transactions +- SELECT statements that follow an INSERT statement +- SET SESSION CHARACTERISTICS AS TRANSACTION… READ WRITE statements +- SET transaction_read_only = off statements +- EXPLAIN and EXPLAIN ANALYZE SELECT statements +- START TRANSACTION… READ WRITE statements +- LOCK commands that are stricter than ROW EXCLUSIVE MODE +- Transactions that start with a BEGIN statement +- The nextval() and setval() sequence functions +- Large objects creation commands + +Please Note: If your application uses JDBC, and the autocommit option is set to false, the JDBC driver will include a BEGIN and COMMIT statement with each SELECT statement. To enable load balancing when using the JDBC driver, your application must include a call to setAutoCommit(true). + +pgPool directs the following non-query statement types to the master node only: + +- INSERT +- UPDATE +- DELETE +- COPY FROM +- TRUNCATE +- CREATE +- DROP +- ALTER +- COMMENT +- PREPARE TRANSACTION +- COMMIT PREPARED +- ROLLBACK PREPARED +- LISTEN +- UNLISTEN +- NOTIFY +- VACUUM + +**Selectively Enforcing Load Balancing** + +pgPool does not enforce load balancing for `SELECT` statements with a leading white space or leading comment. For example, the following statement would be directed to the master node: + +`/*Ignore load balancing*/ SELECT * FROM emp;` + +To enforce load balancing of `SELECT` statements with leading white space or comments, modify the `pgpool.conf` file, and set the `ignore_leading_white_space` parameter to `true`. + +You can also use the `black_list` and `white_list` parameters (located in the `pgpool.conf` file) to instruct pgPool to direct specific statements or functions to the master node. This is useful for cases where a `SELECT` statement (normally directed to a replica) calls a function that in turn might modify the database, and so should be directed to the master. + +**Monitoring Load Balancer Health** + +By default, EDB Ark monitors the health of the load balancer to ensure that service is not interrupted. If the load balancer (pgpool) should fail while monitoring is enabled, PgPool will be automatically restarted. If the load balancer cannot be automatically restarted, EDB Ark will display a warning sign next to the cluster name on the Details panel and send a notification email to the cluster user. + +Deselect the Monitor Load Balancer Health checkbox (located on the Details panel of the Clusters tab) to indicate that you do not wish for load balancer health to be monitored and automatically restarted if an interruption in service is detected. diff --git a/product_docs/docs/ark/3.5/ark_gsg/12_customizing_cluster.mdx b/product_docs/docs/ark/3.5/ark_gsg/12_customizing_cluster.mdx new file mode 100644 index 00000000000..b6e8ed5af8c --- /dev/null +++ b/product_docs/docs/ark/3.5/ark_gsg/12_customizing_cluster.mdx @@ -0,0 +1,30 @@ +--- +title: "Customizing Your Cluster" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-ark-platform/installation-getting-started/getting-started-guide/3.5/customizing_cluster.html" +--- + + + +EDB Ark creates fully-functioning, high-availability database clusters of various sizes complete with replication, load balancing, connection pooling, backup and failover capabilities. An EDB Ark cluster can be defined in minutes without any special database knowledge or skills. This characteristic is greatly appreciated by application developers who want to create robust, data-intensive applications quickly, and who may not have the time, inclination, or skills to otherwise achieve the same results. This type of black box setup was designed to dramatically increase the productivity of developers, DBAs, and system administrators alike. + +However, there are many users who, while enjoying the black box benefits described above, prefer to take a more hands-on approach to managing their databases. EDB Ark was also designed with these users in mind. + +You can also use supporting components to extend the functionality of your EDB Ark cluster; the following sections provide an overview of how to add an extension to a new or existing cluster. + +!!! Note + The EDB Ark Administrator’s console provides an easy way to install and maintain the latest server-related packages. Talk to your system administrator about automatically including supporting components for your cluster when provisioning the database engine. + + + +## Adding an Extension to a New Cluster + +Supporting components and utilities can extend the functionality of your Postgres cluster. For example, you may want to consider adding EDB Postgres Enterprise Manager for management, monitoring, and statistical analysis functionality, or PostGIS, to provide support for spatial data types and functions. + +An administrative user can use the `Optional Node Packages` field on the `Add Engine` or `Edit Engine` dialog to modify a database engine definition, providing the names of optional rpm packages that will be installed (from the specified repository) during provisioning. All engines created with that definition will contain the new component; the component will be provisioned on each replica as well as on the master node. As each rpm is installed, yum will satisfy the dependencies for the new component. + +Packages added via the `Optional Node Packages` field on the master node of the cluster will be provisioned on any standby nodes that are subsequently created. If the package requires manual configuration steps, you will be required to repeat those steps on each node of the cluster; package configurations will not be propagated to standby nodes. If you add a node through cluster operations (such as failover, scaling, or restoring a node from backup), any packages on the new node will also require manual configuration. + +For information about modifying a database engine to add a supporting component, see the *EDB Ark Administrative User's Guide*. diff --git a/product_docs/docs/ark/3.5/ark_gsg/13_database_management.mdx b/product_docs/docs/ark/3.5/ark_gsg/13_database_management.mdx new file mode 100644 index 00000000000..cedf8a9237c --- /dev/null +++ b/product_docs/docs/ark/3.5/ark_gsg/13_database_management.mdx @@ -0,0 +1,291 @@ +--- +title: "Database Management" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-ark-platform/installation-getting-started/getting-started-guide/3.5/database_management.html" +--- + + + +This section details some of the tasks that are performed outside of the Ark console's graphical interface: + +- Moving an existing database into an EDB Ark cluster +- Manually modifying configuration parameters on a cluster +- Stopping and starting the server + + + +## Moving an Existing Database into a New Cluster + +You can use the Postgres `pg_dump` utility to migrate an existing Postgres database (schema, data, and associated database objects) into an EDB Ark cluster. + +`pg_dump` creates an archive that contains the commands needed to re-create and populate your existing database. After moving the archive to the master node of the Ark cluster, use pg_restore to uncompress and play the SQL commands contained in the archive. The following section will walk you through the process of moving a database to EDB Ark using pg_dump. + +You can also use the `pg_dumpall` utility to move an entire *Postgres* cluster (data, schema information, and roles) to EDB Ark; for detailed information about using pg_dumpall, please see the Postgres documentation at: + + + +The following example assumes that you have provisioned an EDB Ark cluster and opened a port for SSH connections. + +**Step One – Navigate into the directory that contains pg_dump** + +Open a terminal window on the system that contains your Postgres source database, assume the identity of the Postgres superuser, and navigate into the bin directory that resides under your Postgres installation directory. + +On Advanced Server the path to the `bin` directory is: + +`/usr/ppas-9.x/bin` + +On PostgreSQL, the path to the directory is: + +`/usr/pgsql-9.x/bin` + +**Step Two - Create the pg_dump Archive** + +Use the `pg_dump` utility to create an archive that contains the commands required to recreate a database. When invoking pg_dump, include the -Ft flag to instruct pg_dump to format the output as a tar file, and the -U flag to specify the name of the database superuser: + +`pg_dump -Ft -U > ` + +Where: + +`db_superuser` is the name of a Postgres database superuser. + +`db_name` is the name of the database that you wish to move to EDB Ark. + +`archive_name.tar` is the complete path and name of the archive. Please note that you must have permission to write a file to the location specified. + +If prompted, enter the password associated with the database superuser. + +**Step Three - Move the Archive to EDB Ark** + +Use the scp command to copy the archive to the master server in the EDB Ark cluster; include the `-i` option to specify the location of your ssh key: + +`scp -i ` + +Where: + +`ssh_key_file` specifies the pathname of the EDB Ark ssh private key file. + +`file_name` specifies the archive name. + +`user_name` specifies the name used to connect to the master node of the EDB Ark cluster. + +`host_name` specifies the host name of the master node of the EDB Ark cluster; the host name is located on the Details panel of the Clusters tab in the Ark console. + +`target` specifies the name of the target directory on the EDB Ark host. Including `:/tmp/` at the end of this command directs `scp` to copy the file to the `tmp` directory + +**Step Four - Connect to EDB Ark with ssh** + +Use ssh to connect to your EDB Ark cluster master node. Provide the user identity of the operating system superuser, and the location of the ssh key (on your local host) in the command: + +`ssh -i//` + +Where: + +`path` specifies the location of your EDB Ark ssh certificate on the system from which you are connecting. + +`ssh_key.pem` specifies the name of the EDB Ark ssh private key file. + +`host_name` specifies the host name of the master node of the EDB Ark cluster; the host name is located on the Details panel of the Clusters tab in the Ark console. + +**Step Five – Navigate into the bin directory on the Ark Host** + +After connecting, assume the identity of the database superuser and navigate into the directory on the Ark host that contains the pg_restore utility. On an Advanced Server host: + +`cd /opt/PostgresPlus/CloudDB/bin` + +On a PostgreSQL host: + +`cd /opt/PostgreSQL/CloudDB/bin` + +**Step Six - Invoke pg_restore on the master server in the EDB Ark cluster** + +Before invoking the `pg_restore` utility, you must create the target database in the master server; you can use the createdb client utility at the command line to create the target: + +`createdb -U ` + +Where: + +`db_superuser` specifies the name of the database superuser. On an Advanced Server cluster, the default is `enterprisedb`; on a PostgreSQL cluster, the default is `postgres`. + +`database_name` specifies the name of the database on EDB Ark. + +Then, invoke the `pg_restore` utility: + +`pg_restore -Ft -U // -d ` + +Where: + +`db_superuser specifies` the name of the database superuser. On an Advanced Server cluster, the default is enterprisedb; on a PostgreSQL cluster, the default is `postgres`. + +`path` is the pathname to the archive on the Ark. + +`archive_name.tar` is the name of the archived database. + +`target_db_name` is the name of the target database on the Ark. + +Include: + +the `-Ft` flag to specify that the file is an archive + +the `-U` flag to specify the name of a database superuser. + +the `-d target_db_name` flag to specify the name of the target database + +**Step Seven - Confirm that the Move was Successful** + +After performing the restore, you can use the psql client to connect to the EDB Ark and confirm that the database has been transferred: + +`psql -U -d ` + +Where: + +`db_superuser specifies` the name of the database superuser. On an Advanced Server cluster, the default is `enterprisedb`; on a PostgreSQL cluster, the default is `postgres`. + +`target_db_name` is the name of the target database. + +Use the `\dt` command to view a list of database objects in the current database. + +To exit the psql client, enter `\q`; to exit the ssh session, type `exit` and `Return`. + +For more information about using the psql client, please see the [PostgreSQL core documentation](https://www.postgresql.org/docs/current/app-psql.html) . + +For more information about using PostgreSQL utilities to move an existing database into EDB Ark, please see the [PostgreSQL core documentation](https://www.postgresql.org/docs/11/static/backup-dump.html) . + + + +## Manually Modifying Configuration Files + +Many of the features of a Postgres server may be influenced by settings specified in configuration files: + +- The `postgresql.conf` file determines Postgres server behavior as it pertains to auditing, authentication, file locations, resource usage, query planning, statistic gathering, error handling and more. +- The `pg_hba.conf` file controls the type of authentication that should be used when a client application connects to an EDB Ark service. By default, the pg_hba.conf file is configured to require clients to provide a valid md5-encrypted password. +- The `pg_ident.conf` file contains user mappings for external authentication methods (like LDAP or GSSAPI). Each entry within the pg_ident.conf file maps an external user name to his corresponding Postgres user name. +- The `pgpool.conf` file determines the behavior of EDB Ark as it pertains to load balancing. + +To modify a configuration file: + +1. ssh to the node of the cluster that contains the file you wish to modify. +2. Use your choice of editor to modify the files. +3. Reload or restart the server. + +When you add or remove nodes from a cluster, EDB Ark takes a backup of your `pg_hba.conf` and `pgpool.conf` configuration files. Configuration file backups are appended with the date that the backup was taken and a unique identifier; for example, `pg_hba.conf.20140319-140903` identifies a backup of the `pg_hba.conf` file. + +When modifying a configuration file, you should make changes only to those files that *are not* appended with a timestamp and identifier. + + + +### Best Practices for Modifying Configuration Files + +Please note that changing parameter settings can have unintended consequences, ranging from degraded performance to system crashes. Consequently, we recommend that only an advanced user who accepts these risks, and has experience with both Postgres and cloud environments modify parameter settings. + +There are several ways that you can minimize the risks involved when making parameter changes: + +- Always make a snapshot backup of your data before making parameter changes. +- Always use a test cluster to test parameter changes, to ensure they have the intended effect before deploying them to your production environment. Create a test environment that mirrors the final target environment as much as possible - this is easy to accomplish by restoring a production backup into a similar size cluster as the original. +- Only change one parameter at a time (or as few as possible when dealing with interdependent settings) and monitor its effect until you are comfortable with the result. +- Make parameter changes on a *copy* of the existing configuration that is in use for the master or replicas. That way, if the parameter change proves detrimental, it will be easy for you to re-apply the original settings. Keep a backup of the original configuration, so they can be easily restored if necessary. + +When adjusting parameters, be mindful of that fact that the master node in the cluster processes both read and write requests, while the replica nodes in the cluster accept only read requests. You can tune the master node and the replica nodes independently to quickly have an impact (either positive or negative) on your write or read performance. + +For more information about modifying Postgres server parameters, please see the [PostgreSQL core documentation](https://www.postgresql.org/docs/11/static/runtime-config.html) . + + + +## Controlling the Database Server + +You can use your platform-specific service controller to control a Postgres database. The service name of the database server in an Ark cluster is clouddb. + +**Controlling a Service on CentOS 7.x** + +If your cluster resides on CentOS version 7.x, you can use the systemctl command to control the service. The systemctl command must be in your search path and must be invoked with superuser privileges. To use the command, open a command line, and enter: + +`systemctl clouddb` + +Where `action` specifies the action taken by the service command. Specify: + +- `status` to discover the current status of the service. +- `start` to start the service. +- `stop` to stop the service. +- `restart` to stop and then start the service. + +**Controlling a Service on CentOS 6.x** + +On CentOS version 6.x, you can control a service at the command line with the service command. The Linux service controller mechanism allows you to start and stop the server gracefully. The command must be in your search path and must be invoked with superuser privileges. Open a command line, and issue the command: + +`service clouddb ` + +Where `action` specifies the action taken by the service command. Specify: + +- `status` to discover the current status of the service. +- `start` to start the service. +- `stop` to stop the service. +- `condstop` to stop the service without displaying a notice if the server is already stopped. +- `restart` to stop and then start the service. +- `condrestart` to restart the service without displaying a notice if the server is already stopped. +- `try-restart` to restart the service without displaying a notice if the server is already stopped. + + + +## Updating the Server Version on the EDB Ark Cluster + +When an update becomes available for a package installed on your cluster, the Ark console will display an alert symbol in the `UP` column of the `Details` panel for the cluster, and in the `UP` column of the DNSNAME table adjacent to the node that requires an update: + +![*The DNSNAME table.*](images/db_mgmt_dnsname_table_upgrade.png) + +Fig. 13.1: The DNSNAME table. + +The overall cluster status (displayed in the top section of the `Clusters` tab) is based on the values of the nodes within the cluster. + +- If all of the nodes within the cluster are up-to-date, the `UP` column displays a green checkmark. +- If one or more nodes require a non-critical update, the `UP` column displays a yellow alert symbol. +- If one or more nodes require a critical update, the `UP` column for the cluster displays a red error symbol. +- If one or more nodes have an unknown package status, the `UP` column for the cluster displays a grey checkmark. + +You can use the `Upgrade` icon (located on the [Clusters tab](04_using_ark_console/02_ark_clusters_tab/#ark_clusters_tab) ) to access a dialog that allows you to update the server version on each node within the cluster. + +![*The cluster upgrade dialog.*](images/db_mgmt_cluster_upgrade.png) + +Fig. 13.2: The cluster upgrade dialog. + +Select the radio button next to an option to: + +- Select `OS and DB Minor Version Upgrade` to invoke a `yum update` command and update any outdated packages and perform a minor database version upgrade on each node of the cluster. +- Select `DB Major Version Upgrade` to select a version and perform a major version upgrade of the server. Please note that this functionality is restricted to users that are not required to use a template when deploying a cluster. + +After making a selection, click `Upgrade` to continue. + + + +### Performing a Minor Version Upgrade + +If you select the radio button next to `OS and DB Minor Version Upgrade` and click the `Upgrade` button, the Ark console will invoke the yum update command on each node of the cluster. The `yum update` command will update all installed packages to the most recent version available of the same release (i.e., if you are running a 9.6 database server, yum will update your database server to the most recent version of 9.6). + +![*The Upgrade Cluster dialog.*](images/db_mgmt_cluster_upgrade.png) + +Fig. 13.3: The Upgrade Cluster dialog + +Before performing the update, EDB Ark will perform a backup. During the upgrade process, all clients will be disconnected from the server. The updated server will retain the IP address used by the original server. When the update has completed, clients may once again connect. + +After performing a yum update, the node will be rebooted, initiating any kernel updates required. When the update completes, EDB Ark will send an email notification that contains a list of the updated packages. + +If one or more nodes in your cluster are currently displaying an unknown status, EDB Ark will display an error message. You must correct the problem that is causing the unknown status before EDB Ark can perform an update. + +Please note that if the yum update command fails during the upgrade process, EDB Ark will terminate the process and yum update will not be run on any remaining nodes, leaving the cluster partially upgraded. + + + +### Performing a Major Version Upgrade + +You can use the `Upgrade Cluster` dialog to upgrade the Postgres server installed on your Ark cluster; the upgrade must be to a more recent version of the same server type and must use the same server image as the current database engine. For example, you may upgrade an Advanced Server version 9.6 database server that resides on a CentOS 6.x host to Advanced Server 11, but you cannot move the server onto a CentOS 7.x host. Similarly, you may not upgrade a PostgreSQL 9.6 database server that resides on a CentOS 7.x host to use an Advanced Server 11 server on a CentOS 7.x host. The server type and host operating system version must remain the same. Please note: + +- a major version upgrade may not be performed by a template-only user. +- if over half of the data space allocated to a cluster is used, you must add storage to the cluster before performing the upgrade. + +To upgrade a running cluster, select the radio button next to `Major Version Upgrade`, and then use the drop-down listbox to select a server version. Click `Upgrade` to continue. + +![*The Upgrade Cluster dialog.*](images/db_mgmt_cluster_major_upgrade.png) + +Fig. 13.4: The Upgrade Cluster dialog. + +A popup will open, asking you to confirm that you wish to upgrade the server; click the `Upgrade` button to perform an upgrade. The server will be briefly unavailable during the upgrade process. The upgrade does not change the IP address and listening port of the server. diff --git a/product_docs/docs/ark/3.5/ark_gsg/14_troubleshooting.mdx b/product_docs/docs/ark/3.5/ark_gsg/14_troubleshooting.mdx new file mode 100644 index 00000000000..219af9d9311 --- /dev/null +++ b/product_docs/docs/ark/3.5/ark_gsg/14_troubleshooting.mdx @@ -0,0 +1,101 @@ +--- +title: "Troubleshooting" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-ark-platform/installation-getting-started/getting-started-guide/3.5/troubleshooting.html" +--- + + + +This section provides helpful troubleshooting information; if you still have unanswered questions after reviewing this section, you can also find solutions through EnterpriseDB: + +If you have purchased support, you can log a support ticket: + +in the Customer Portal: + +via email: [support@enterprisedb.com](mailto:support@enterprisedb.com) + +or by phone: +1-732-331-1320 or 1-800-235-5891 (US Only) + +If you have not purchased support, and would like to, you can view your support options at: + + + +You are always welcome to log an issue via email; when time permits, our customer support experts will respond to inquiries from customers that have not purchased support. + +You can also find free help on a wide variety of topics in the EnterpriseDB User Forums, at: + + + +Postgres documentation and helpful tutorials are available from the EDB Ark bookshelf, located on the Dashboard tab of the management console. + +## Frequently Asked Questions + +**Problem: Logging into the Console sometimes takes a long time.** + +This can be attributed to delays in the connection time to the cloud provider. When you log in, the Console Manager must pass your credentials to the provider to log in; any delays at the service provider may slow your connection time. + +**Problem: I am attempting to connect to my cluster, but don't know my default database name.** + +- The name of the default database in an Advanced Server cluster is `edb`. +- The name of the default database in a PostgreSQL cluster is `postgres`. + +**Problem: unable to connect to the load balancing port (9999).** + +If you are having difficulty connecting to the load balancing port, you should: + +- Make sure you are connecting to the master server's DNS name, rather than a replica's DNS name; the load balancer resides on the master node of an EDB Ark cluster. +- Make sure that your client application is providing an MD-5 encrypted password when attempting to connect to the load balancing port. The username:password-md5 combination is stored in `pgpool_passwd.conf`, and is automatically updated when a user changes password, or when a new user is created. + +**Problem: pgpool keeps issuing the following error: make_persistent_db_connection: s_do_auth failed.** + +pgpool attempts to connect to each node to perform replication lag checking. This happens unconditionally if pgpool is configured in a master-slave mode and streaming replication is being used (which is the case for EDB Ark). The pgpool community has been alerted to this behavior; please ignore these messages. + +**Question: How do I stop the Postgres server on a cluster node without triggering a failover process?** + +To safely stop a Postgres server without triggering failover, you can use either the `service` command or the pg_ctl utility. For more information, see [Controlling the Database Server](13_database_management/#controlling_server) . + +**Problem: I am attempting to connect to my Advanced Server database with the psql client, and am getting an error** + +```text +(03/23/2012 13:36:53)-> psql --host=192.0.43.10 -p 9999 -U enterprisedb +Password for user enterprisedb: psql: FATAL: database "postgres" does +not exist +``` + +The psql client expects the default database to be named `postgres`; the edb-psql client expects the default database to be named `edb`. If you attempt to connect to an Advanced Server cluster with the psql client without specifying the name of the database to which it should connect, the client will fail to connect. + +You can include the `-d` or `--dbname` flag, followed by the database name when invoking either client to specify the database to which the client should connect. + +**Question: I'm trying to drop a database from a cluster, but I am getting an error that there are open sessions. There are no clients connected. How can I terminate any leftover backend sessions?** + +It may be that pgpool is retaining a connection to the database. You can use the `pg_cancel_backend()` or `pg_terminate_backend()` functions to selectively close connections to the database you wish to drop. + +**Question: Why do I have to restart pgPool before it will recognize new users that I've added to the database server?** + +pgPool does not check for new Postgres users. EDB Ark has a periodic update process that updates the user list every 20 seconds; if the update process identifies a new user, it sends a reload signal to the pgPool process. After the reload, pgPool will allow new users to login. + +Instead of reloading, simply waiting for 20 seconds between the CREATE USER statement and the CREATEDB statement should solve the problem. + +**Question: Why are scheduled backups not working?** + +If you invoke the `pg_start_backup()` function before performing a manual backup your database, you must remember to invoke the `pg_stop_backup()` function when the backup has completed, or EDB Ark scheduled backups will fail. + + + +## The EDB Ark Email Notification System + +EDB Ark invokes an email notification system that will alert you if your cluster changes or encounters a problem. Email notifications are sent to the address used to log in to the management console. + +EDB Ark will send an email: + +- When a new cluster is created. +- If a server stops (or is terminated). +- When a replica is added to a cluster. +- When memory is scaled up. +- When failover is invoked on a master or a replica. +- If a backup fails. +- If the password associated with your user account changes. + +The `Notification Email` field (on the `User` tab) allows you to change the notification email associated with your user account; for more information, see [The User Tab](04_using_ark_console/04_ark_user_tab/#ark_user_tab) . diff --git a/product_docs/docs/ark/3.5/ark_gsg/15_aws_policies.mdx b/product_docs/docs/ark/3.5/ark_gsg/15_aws_policies.mdx new file mode 100644 index 00000000000..c61099a7049 --- /dev/null +++ b/product_docs/docs/ark/3.5/ark_gsg/15_aws_policies.mdx @@ -0,0 +1,144 @@ +--- +title: "AWS Policies" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-ark-platform/installation-getting-started/getting-started-guide/3.5/aws_policies.html" +--- + + + +**AWS Security Policy** + +When you define a new Amazon role, you are required to provide a security policy. The following text is an example of a security policy: + +{ +"Version": "2012-10-17", +"Statement": \[ { +"Action": \[ +"ec2:AllocateAddress", +"ec2:AssignPrivateIpAddresses", +"ec2:Associate*", +"ec2:Attach*", +"ec2:AuthorizeSecurityGroup*", +"ec2:Copy*", +"ec2:Create*", +"ec2:DeleteInternetGateway", +"ec2:DeleteNetworkAcl", +"ec2:DeleteNetworkAclEntry", +"ec2:DeleteNetworkInterface", +"ec2:DeletePlacementGroup", +"ec2:DeleteRoute", +"ec2:DeleteRouteTable", +"ec2:DeleteSecurityGroup", +"ec2:DeleteSnapshot", +"ec2:DeleteSubnet", +"ec2:DeleteTags", +"ec2:DeleteVolume", +"ec2:DeleteVpc", +"ec2:DeleteKeypair", +"ec2:Describe*", +"ec2:Detach*", +"ec2:DisassociateAddress", +"ec2:DisassociateRouteTable", +"ec2:EnableVolumeIO", +"ec2:GetConsoleOutput", +"ec2:ModifyImageAttribute", +"ec2:ModifyInstanceAttribute", +"ec2:ModifyNetworkInterfaceAttribute", +"ec2:ModifySnapshotAttribute", +"ec2:ModifyVolumeAttribute", +"ec2:ModifyVpcAttribute", +"ec2:MonitorInstances", +"ec2:ReleaseAddress", +"ec2:ReplaceNetworkAclAssociation", +"ec2:ReplaceNetworkAclEntry", +"ec2:ReplaceRoute", +"ec2:ReplaceRouteTableAssociation", +"ec2:ReportInstanceStatus", +"ec2:ResetImageAttribute", +"ec2:ResetInstanceAttribute", +"ec2:ResetNetworkInterfaceAttribute", +"ec2:ResetSnapshotAttribute", +"ec2:RevokeSecurityGroup*", +"ec2:RunInstances", +"ec2:StartInstances", +"ec2:UnassignPrivateIpAddresses", +"ec2:UnmonitorInstances" +], +"Resource": "*", +"Effect": "Allow", +"Sid": "Stmt1407961327680" +}, { +"Action": \[ +"iam:PassRole" +], +"Resource": "*", +"Effect": "Allow", +"Sid": "Stmt1407961362664" +}, { +"Action": \[ +"s3:CreateBucket", +"s3:Get*", +"s3:List*" +], +"Resource": "*", +"Effect": "Allow", +"Sid": "Stmt1407961630932" +}, { +"Action": \[ +"s3:Put*", +"s3:Get*", +"s3:DeleteObject*" +], +"Resource": "arn:aws:s3:::*", +"Effect": "Allow", +"Sid": "Stmt1407961734627" +}, { +"Condition": { +"StringEquals": { +"ec2:ResourceTag/CreatedBy": "EnterpriseDB" +} +}, +"Action": \[ +"ec2:RebootInstances", +"ec2:StopInstances", +"ec2:TerminateInstances" +], +"Resource": "*", +"Effect": "Allow", +"Sid": "Stmt1407961927870" +} +] +} + +**AWS User Trust Policy** + +When you define an Amazon role, you are required to provide a security policy. The following text is an example of a trust policy: + +{ +"Version": "2012-10-17", +"Statement": \[ +{ +"Sid": "", +"Effect": "Allow", +"Principal": { +"Service": "ec2.amazonaws.com" +}, +"Action": "sts:AssumeRole" +}, +{ +"Sid": "", +"Effect": "Allow", +"Principal": { +"AWS": "arn:aws:iam::747919436152:root" +}, +"Action": "sts:AssumeRole", +"Condition": { +"StringEquals": { +"sts:ExternalId": "EDB-PPCD-CONSOLE" +} +} +} +] +} diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/accessing_ark_console.png b/product_docs/docs/ark/3.5/ark_gsg/images/accessing_ark_console.png new file mode 100755 index 00000000000..354d31e74f9 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/accessing_ark_console.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/accessing_ark_console_dashboard.png b/product_docs/docs/ark/3.5/ark_gsg/images/accessing_ark_console_dashboard.png new file mode 100755 index 00000000000..92803d6192f Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/accessing_ark_console_dashboard.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/admin_settings_icon.png b/product_docs/docs/ark/3.5/ark_gsg/images/admin_settings_icon.png new file mode 100755 index 00000000000..9aeabd176a4 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/admin_settings_icon.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/ark_architecture_overview.png b/product_docs/docs/ark/3.5/ark_gsg/images/ark_architecture_overview.png new file mode 100755 index 00000000000..004b963c0e5 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/ark_architecture_overview.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/ark_cluster_download_logs.png b/product_docs/docs/ark/3.5/ark_gsg/images/ark_cluster_download_logs.png new file mode 100755 index 00000000000..6adad8bf951 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/ark_cluster_download_logs.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/ark_clusters_ssh_popup.png b/product_docs/docs/ark/3.5/ark_gsg/images/ark_clusters_ssh_popup.png new file mode 100755 index 00000000000..2585c663614 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/ark_clusters_ssh_popup.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/ark_clusters_tab.png b/product_docs/docs/ark/3.5/ark_gsg/images/ark_clusters_tab.png new file mode 100755 index 00000000000..9b06ed670d6 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/ark_clusters_tab.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/ark_create_cross_region.png b/product_docs/docs/ark/3.5/ark_gsg/images/ark_create_cross_region.png new file mode 100755 index 00000000000..f82ba226c96 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/ark_create_cross_region.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/ark_overview_load_balance.png b/product_docs/docs/ark/3.5/ark_gsg/images/ark_overview_load_balance.png new file mode 100755 index 00000000000..bc426cbc78a Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/ark_overview_load_balance.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/ark_overview_private_cloud.png b/product_docs/docs/ark/3.5/ark_gsg/images/ark_overview_private_cloud.png new file mode 100755 index 00000000000..112900cf0f6 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/ark_overview_private_cloud.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/ark_user_tab.png b/product_docs/docs/ark/3.5/ark_gsg/images/ark_user_tab.png new file mode 100755 index 00000000000..9f8f6c622fd Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/ark_user_tab.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/auto_scale_options_dialog.png b/product_docs/docs/ark/3.5/ark_gsg/images/auto_scale_options_dialog.png new file mode 100755 index 00000000000..91f63005a5e Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/auto_scale_options_dialog.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/backup_data_dialog.png b/product_docs/docs/ark/3.5/ark_gsg/images/backup_data_dialog.png new file mode 100755 index 00000000000..8e1b0d0e5f5 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/backup_data_dialog.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/backup_icon.png b/product_docs/docs/ark/3.5/ark_gsg/images/backup_icon.png new file mode 100755 index 00000000000..988d4ec717b Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/backup_icon.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/backups_list.png b/product_docs/docs/ark/3.5/ark_gsg/images/backups_list.png new file mode 100755 index 00000000000..9a8de06d69e Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/backups_list.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/backups_tab.png b/product_docs/docs/ark/3.5/ark_gsg/images/backups_tab.png new file mode 100755 index 00000000000..56dff60d775 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/backups_tab.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/cds_user_green_checkmark.png b/product_docs/docs/ark/3.5/ark_gsg/images/cds_user_green_checkmark.png new file mode 100755 index 00000000000..84da251c996 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/cds_user_green_checkmark.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/cds_user_grey_question.png b/product_docs/docs/ark/3.5/ark_gsg/images/cds_user_grey_question.png new file mode 100755 index 00000000000..dae343899b7 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/cds_user_grey_question.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/cds_user_orange_busy.png b/product_docs/docs/ark/3.5/ark_gsg/images/cds_user_orange_busy.png new file mode 100755 index 00000000000..b6787f808cd Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/cds_user_orange_busy.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/cds_user_red_error.png b/product_docs/docs/ark/3.5/ark_gsg/images/cds_user_red_error.png new file mode 100755 index 00000000000..82271be6104 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/cds_user_red_error.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/cds_user_yellow_alert.png b/product_docs/docs/ark/3.5/ark_gsg/images/cds_user_yellow_alert.png new file mode 100755 index 00000000000..4974f01c0a0 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/cds_user_yellow_alert.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/clone_icon.png b/product_docs/docs/ark/3.5/ark_gsg/images/clone_icon.png new file mode 100755 index 00000000000..28f68a51720 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/clone_icon.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/clusters_tab_details_panel.png b/product_docs/docs/ark/3.5/ark_gsg/images/clusters_tab_details_panel.png new file mode 100755 index 00000000000..32436bea162 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/clusters_tab_details_panel.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/clusters_tab_events_panel.png b/product_docs/docs/ark/3.5/ark_gsg/images/clusters_tab_events_panel.png new file mode 100755 index 00000000000..d38e721bc8c Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/clusters_tab_events_panel.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/clusters_tab_monitoring_panel.png b/product_docs/docs/ark/3.5/ark_gsg/images/clusters_tab_monitoring_panel.png new file mode 100755 index 00000000000..9f0cffd304d Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/clusters_tab_monitoring_panel.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/connecting_psql_login.png b/product_docs/docs/ark/3.5/ark_gsg/images/connecting_psql_login.png new file mode 100755 index 00000000000..a17de9267ba Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/connecting_psql_login.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/connecting_psql_on_ark.png b/product_docs/docs/ark/3.5/ark_gsg/images/connecting_psql_on_ark.png new file mode 100755 index 00000000000..375c29dd724 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/connecting_psql_on_ark.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/console_switcher.png b/product_docs/docs/ark/3.5/ark_gsg/images/console_switcher.png new file mode 100755 index 00000000000..31c505427c7 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/console_switcher.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/create_cluster_admin_settings.png b/product_docs/docs/ark/3.5/ark_gsg/images/create_cluster_admin_settings.png new file mode 100755 index 00000000000..d9ee35893de Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/create_cluster_admin_settings.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/create_cluster_admin_settings_confirm.png b/product_docs/docs/ark/3.5/ark_gsg/images/create_cluster_admin_settings_confirm.png new file mode 100755 index 00000000000..17542a46473 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/create_cluster_admin_settings_confirm.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/create_cluster_clone.png b/product_docs/docs/ark/3.5/ark_gsg/images/create_cluster_clone.png new file mode 100755 index 00000000000..77060f3205a Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/create_cluster_clone.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/create_cluster_clone_manual.png b/product_docs/docs/ark/3.5/ark_gsg/images/create_cluster_clone_manual.png new file mode 100755 index 00000000000..28ddfb6e778 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/create_cluster_clone_manual.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/create_cluster_clone_template.png b/product_docs/docs/ark/3.5/ark_gsg/images/create_cluster_clone_template.png new file mode 100755 index 00000000000..5167db8a6d5 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/create_cluster_clone_template.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/create_cluster_complete.png b/product_docs/docs/ark/3.5/ark_gsg/images/create_cluster_complete.png new file mode 100755 index 00000000000..b16865a4205 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/create_cluster_complete.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/create_cluster_from_template.png b/product_docs/docs/ark/3.5/ark_gsg/images/create_cluster_from_template.png new file mode 100755 index 00000000000..103ed5e2830 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/create_cluster_from_template.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/create_cluster_icon.png b/product_docs/docs/ark/3.5/ark_gsg/images/create_cluster_icon.png new file mode 100755 index 00000000000..d4e7330e910 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/create_cluster_icon.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/create_cluster_launch_option.png b/product_docs/docs/ark/3.5/ark_gsg/images/create_cluster_launch_option.png new file mode 100755 index 00000000000..43c18ef54f8 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/create_cluster_launch_option.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/create_cluster_security_rule.png b/product_docs/docs/ark/3.5/ark_gsg/images/create_cluster_security_rule.png new file mode 100755 index 00000000000..33de5596250 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/create_cluster_security_rule.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/create_cluster_step_four.png b/product_docs/docs/ark/3.5/ark_gsg/images/create_cluster_step_four.png new file mode 100755 index 00000000000..41622c7fdcc Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/create_cluster_step_four.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/create_cluster_step_one.png b/product_docs/docs/ark/3.5/ark_gsg/images/create_cluster_step_one.png new file mode 100755 index 00000000000..43945210555 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/create_cluster_step_one.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/create_cluster_step_three.png b/product_docs/docs/ark/3.5/ark_gsg/images/create_cluster_step_three.png new file mode 100755 index 00000000000..50050572adc Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/create_cluster_step_three.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/create_cluster_step_two.png b/product_docs/docs/ark/3.5/ark_gsg/images/create_cluster_step_two.png new file mode 100755 index 00000000000..1f578f45bfe Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/create_cluster_step_two.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/create_cluster_template_details.png b/product_docs/docs/ark/3.5/ark_gsg/images/create_cluster_template_details.png new file mode 100755 index 00000000000..f3b8f30deed Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/create_cluster_template_details.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/db_mgmt_cluster_major_upgrade.png b/product_docs/docs/ark/3.5/ark_gsg/images/db_mgmt_cluster_major_upgrade.png new file mode 100755 index 00000000000..2d1e37f60d4 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/db_mgmt_cluster_major_upgrade.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/db_mgmt_cluster_upgrade.png b/product_docs/docs/ark/3.5/ark_gsg/images/db_mgmt_cluster_upgrade.png new file mode 100755 index 00000000000..6ac2cbc3c8a Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/db_mgmt_cluster_upgrade.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/db_mgmt_dnsname_table_upgrade.png b/product_docs/docs/ark/3.5/ark_gsg/images/db_mgmt_dnsname_table_upgrade.png new file mode 100755 index 00000000000..caa5eed3b24 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/db_mgmt_dnsname_table_upgrade.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/delete_backup_icon.png b/product_docs/docs/ark/3.5/ark_gsg/images/delete_backup_icon.png new file mode 100755 index 00000000000..fa4a1c68c44 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/delete_backup_icon.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/delete_icon.png b/product_docs/docs/ark/3.5/ark_gsg/images/delete_icon.png new file mode 100755 index 00000000000..d461c88b277 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/delete_icon.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/download_ssh_key_icon.png b/product_docs/docs/ark/3.5/ark_gsg/images/download_ssh_key_icon.png new file mode 100755 index 00000000000..9cb033d5548 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/download_ssh_key_icon.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/manual_promote_confirmation.png b/product_docs/docs/ark/3.5/ark_gsg/images/manual_promote_confirmation.png new file mode 100755 index 00000000000..a1a7161fdd4 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/manual_promote_confirmation.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/manual_promote_context.png b/product_docs/docs/ark/3.5/ark_gsg/images/manual_promote_context.png new file mode 100755 index 00000000000..b1e6a6b98c8 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/manual_promote_context.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/manual_promote_status.png b/product_docs/docs/ark/3.5/ark_gsg/images/manual_promote_status.png new file mode 100755 index 00000000000..5e33560fa13 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/manual_promote_status.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/manually_recover_backup.png b/product_docs/docs/ark/3.5/ark_gsg/images/manually_recover_backup.png new file mode 100755 index 00000000000..ed2d517064b Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/manually_recover_backup.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/manually_scale_down_step_one.png b/product_docs/docs/ark/3.5/ark_gsg/images/manually_scale_down_step_one.png new file mode 100755 index 00000000000..8223a76b658 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/manually_scale_down_step_one.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/manually_scale_down_step_two.png b/product_docs/docs/ark/3.5/ark_gsg/images/manually_scale_down_step_two.png new file mode 100755 index 00000000000..b42204eedf2 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/manually_scale_down_step_two.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/manually_scale_up_step_one.png b/product_docs/docs/ark/3.5/ark_gsg/images/manually_scale_up_step_one.png new file mode 100755 index 00000000000..35ccdb99390 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/manually_scale_up_step_one.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/manually_scale_up_step_two.png b/product_docs/docs/ark/3.5/ark_gsg/images/manually_scale_up_step_two.png new file mode 100755 index 00000000000..dc44921a1ad Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/manually_scale_up_step_two.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/recover_backup_icon.png b/product_docs/docs/ark/3.5/ark_gsg/images/recover_backup_icon.png new file mode 100755 index 00000000000..16b7e99d840 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/recover_backup_icon.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/recovery_in_progress.png b/product_docs/docs/ark/3.5/ark_gsg/images/recovery_in_progress.png new file mode 100755 index 00000000000..ddaa6fdd276 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/recovery_in_progress.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/restart_icon.png b/product_docs/docs/ark/3.5/ark_gsg/images/restart_icon.png new file mode 100755 index 00000000000..4507602f40f Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/restart_icon.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/scale_cluster_icon.png b/product_docs/docs/ark/3.5/ark_gsg/images/scale_cluster_icon.png new file mode 100755 index 00000000000..39216cf028f Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/scale_cluster_icon.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/scale_down_icon.png b/product_docs/docs/ark/3.5/ark_gsg/images/scale_down_icon.png new file mode 100755 index 00000000000..75170217926 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/scale_down_icon.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/scale_machine_icon.png b/product_docs/docs/ark/3.5/ark_gsg/images/scale_machine_icon.png new file mode 100755 index 00000000000..2634ea7b889 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/scale_machine_icon.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/scale_machine_type.png b/product_docs/docs/ark/3.5/ark_gsg/images/scale_machine_type.png new file mode 100755 index 00000000000..6876e8ac20d Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/scale_machine_type.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/select_restore_backup.png b/product_docs/docs/ark/3.5/ark_gsg/images/select_restore_backup.png new file mode 100755 index 00000000000..91625b1695f Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/select_restore_backup.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/self_reg_attach_policy.png b/product_docs/docs/ark/3.5/ark_gsg/images/self_reg_attach_policy.png new file mode 100755 index 00000000000..0ed82dd4a2d Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/self_reg_attach_policy.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/self_reg_create_role.png b/product_docs/docs/ark/3.5/ark_gsg/images/self_reg_create_role.png new file mode 100755 index 00000000000..8e014e54734 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/self_reg_create_role.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/self_reg_custom_policy.png b/product_docs/docs/ark/3.5/ark_gsg/images/self_reg_custom_policy.png new file mode 100755 index 00000000000..00cba97c84d Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/self_reg_custom_policy.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/self_reg_edit_trust_rel.png b/product_docs/docs/ark/3.5/ark_gsg/images/self_reg_edit_trust_rel.png new file mode 100755 index 00000000000..c300d0eb211 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/self_reg_edit_trust_rel.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/self_reg_inline_policy.png b/product_docs/docs/ark/3.5/ark_gsg/images/self_reg_inline_policy.png new file mode 100755 index 00000000000..af71681d47d Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/self_reg_inline_policy.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/self_reg_reg_dialog.png b/product_docs/docs/ark/3.5/ark_gsg/images/self_reg_reg_dialog.png new file mode 100755 index 00000000000..dfdcee10fd2 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/self_reg_reg_dialog.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/self_reg_review.png b/product_docs/docs/ark/3.5/ark_gsg/images/self_reg_review.png new file mode 100755 index 00000000000..579c28172ae Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/self_reg_review.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/self_reg_role_detail.png b/product_docs/docs/ark/3.5/ark_gsg/images/self_reg_role_detail.png new file mode 100755 index 00000000000..22f2742b7f7 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/self_reg_role_detail.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/self_reg_role_type.png b/product_docs/docs/ark/3.5/ark_gsg/images/self_reg_role_type.png new file mode 100755 index 00000000000..98283131e8f Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/self_reg_role_type.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/self_reg_set_permissions.png b/product_docs/docs/ark/3.5/ark_gsg/images/self_reg_set_permissions.png new file mode 100755 index 00000000000..5769f2cda9c Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/self_reg_set_permissions.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/self_reg_set_role_name.png b/product_docs/docs/ark/3.5/ark_gsg/images/self_reg_set_role_name.png new file mode 100755 index 00000000000..b8891243b36 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/self_reg_set_role_name.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/self_reg_step_two.png b/product_docs/docs/ark/3.5/ark_gsg/images/self_reg_step_two.png new file mode 100755 index 00000000000..1bac32bb3f2 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/self_reg_step_two.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/self_reg_welcome.png b/product_docs/docs/ark/3.5/ark_gsg/images/self_reg_welcome.png new file mode 100755 index 00000000000..dd3c89e386c Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/self_reg_welcome.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/template_recover_from_backup.png b/product_docs/docs/ark/3.5/ark_gsg/images/template_recover_from_backup.png new file mode 100755 index 00000000000..e0018ed2ee8 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/template_recover_from_backup.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/upgrade_icon.png b/product_docs/docs/ark/3.5/ark_gsg/images/upgrade_icon.png new file mode 100755 index 00000000000..a4953e95c98 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/upgrade_icon.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/user_tab_change_password.png b/product_docs/docs/ark/3.5/ark_gsg/images/user_tab_change_password.png new file mode 100755 index 00000000000..257418618c9 Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/user_tab_change_password.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/images/using_ark_template_only.png b/product_docs/docs/ark/3.5/ark_gsg/images/using_ark_template_only.png new file mode 100755 index 00000000000..5f7c568439c Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_gsg/images/using_ark_template_only.png differ diff --git a/product_docs/docs/ark/3.5/ark_gsg/index.mdx b/product_docs/docs/ark/3.5/ark_gsg/index.mdx new file mode 100644 index 00000000000..59035db36f6 --- /dev/null +++ b/product_docs/docs/ark/3.5/ark_gsg/index.mdx @@ -0,0 +1,35 @@ +--- +navTitle: Getting Started Guide +title: "Ark" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-ark-platform/installation-getting-started/getting-started-guide/3.5/index.html" + - "/edb-docs/d/edb-postgres-ark-platform/installation-getting-started/getting-started-guide/3.5/conclusion.html" + - "/edb-docs/d/edb-postgres-ark-platform/installation-getting-started/getting-started-guide/3.5/genindex.html" + - "/edb-docs/d/edb-postgres-ark-platform/installation-getting-started/getting-started-guide/3.5/whats_new.html" +--- + +**EDB Postgres Ark** + +EDB Ark automatically provisions PostgreSQL or EDB Postgres Advanced Server databases in single instances, high-availability clusters, or application development sandboxes. EDB Ark frees DBAs and application developers from the rigors of setting up and administering robust database environments. In minutes, EDB Ark configures a cluster of database machines with: + +- Streaming replication +- Connection pooling +- Load balancing +- Automatic failover (transaction or recovery time preferred) +- Secure data encryption +- Rotating user-scheduled backups +- Point-in-time recovery +- Elastic storage +- Elastic scale out + +EDB Ark's automatic scaling of storage resources and scale out of read replicas when a database cluster reaches user-defined thresholds provides unattended, around-the-clock responsiveness to unpredictable load demands on your database infrastructure. + +This document will demonstrate how to use the EDB Ark console successfully in your cloud-based database management activities. + +
+ +whats_new ark_overview accessing_ark_console using_ark_console creating_a_cluster connecting_to_cluster manage_backup_recovery automatic_failover manual_scaling automatic_scaling load_balancing customizing_cluster database_management troubleshooting aws_policies conclusion + +
diff --git a/product_docs/docs/ark/3.5/ark_v3.5_documentation.pdf b/product_docs/docs/ark/3.5/ark_v3.5_documentation.pdf new file mode 100644 index 00000000000..f28c55c1fbd Binary files /dev/null and b/product_docs/docs/ark/3.5/ark_v3.5_documentation.pdf differ diff --git a/product_docs/docs/ark/3.5/index.mdx b/product_docs/docs/ark/3.5/index.mdx new file mode 100644 index 00000000000..ef38d30e6b2 --- /dev/null +++ b/product_docs/docs/ark/3.5/index.mdx @@ -0,0 +1,13 @@ +--- +title: Ark Platform +directoryDefaults: + description: "EDB Postgres Ark Platform Version 3.5 Documentation and release notes." +navigation: + - "#Getting Started" + - ark_gsg + - "#User Guides" + - ark_admin +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/p/edb-postgres-ark-platform/3.5" +--- diff --git a/product_docs/docs/bart/2.4/bart_v2.4_documentation.pdf b/product_docs/docs/bart/2.4/bart_v2.4_documentation.pdf new file mode 100644 index 00000000000..56f594cedae Binary files /dev/null and b/product_docs/docs/bart/2.4/bart_v2.4_documentation.pdf differ diff --git a/product_docs/docs/bart/2.4/index.mdx b/product_docs/docs/bart/2.4/index.mdx new file mode 100644 index 00000000000..2d2cd428e4c --- /dev/null +++ b/product_docs/docs/bart/2.4/index.mdx @@ -0,0 +1,12 @@ +--- +title: Backup and Recovery Tool +productStub: true +directoryDefaults: + description: "EDB Backup and Recovery Tool Version 2.4 Documentation and release notes. A tool to manage and configure PostgreSQL backups and disaster recovery." + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/p/edb-backup-and-recovery-tool/2.4" +--- + + diff --git a/product_docs/docs/bart/2.5.1/bart_v2.5.1_documentation.pdf b/product_docs/docs/bart/2.5.1/bart_v2.5.1_documentation.pdf new file mode 100644 index 00000000000..f66b600974c Binary files /dev/null and b/product_docs/docs/bart/2.5.1/bart_v2.5.1_documentation.pdf differ diff --git a/product_docs/docs/bart/2.5.1/index.mdx b/product_docs/docs/bart/2.5.1/index.mdx new file mode 100644 index 00000000000..20e2e3f9be3 --- /dev/null +++ b/product_docs/docs/bart/2.5.1/index.mdx @@ -0,0 +1,12 @@ +--- +title: Backup and Recovery Tool +productStub: true +directoryDefaults: + description: "EDB Backup and Recovery Tool Version 2.5.1 Documentation and release notes. A tool to manage and configure PostgreSQL backups and disaster recovery." + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/p/edb-backup-and-recovery-tool/2.5.1" +--- + + diff --git a/product_docs/docs/bart/2.5.2/bart_v2.5.2_documentation.pdf b/product_docs/docs/bart/2.5.2/bart_v2.5.2_documentation.pdf new file mode 100644 index 00000000000..8c7c1c7ea95 Binary files /dev/null and b/product_docs/docs/bart/2.5.2/bart_v2.5.2_documentation.pdf differ diff --git a/product_docs/docs/bart/2.5.2/index.mdx b/product_docs/docs/bart/2.5.2/index.mdx new file mode 100644 index 00000000000..10def0c9765 --- /dev/null +++ b/product_docs/docs/bart/2.5.2/index.mdx @@ -0,0 +1,12 @@ +--- +title: Backup and Recovery Tool +productStub: true +directoryDefaults: + description: "EDB Backup and Recovery Tool Version 2.5.2 Documentation and release notes. A tool to manage and configure PostgreSQL backups and disaster recovery." + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/p/edb-backup-and-recovery-tool/2.5.2" +--- + + diff --git a/product_docs/docs/bart/2.5.3/bart_v2.5.3_documentation.pdf b/product_docs/docs/bart/2.5.3/bart_v2.5.3_documentation.pdf new file mode 100644 index 00000000000..1a9be0092dd Binary files /dev/null and b/product_docs/docs/bart/2.5.3/bart_v2.5.3_documentation.pdf differ diff --git a/product_docs/docs/bart/2.5.3/index.mdx b/product_docs/docs/bart/2.5.3/index.mdx new file mode 100644 index 00000000000..cfb4eda4619 --- /dev/null +++ b/product_docs/docs/bart/2.5.3/index.mdx @@ -0,0 +1,12 @@ +--- +title: Backup and Recovery Tool +productStub: true +directoryDefaults: + description: "EDB Backup and Recovery Tool Version 2.5.3 Documentation and release notes. A tool to manage and configure PostgreSQL backups and disaster recovery." + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/p/edb-backup-and-recovery-tool/2.5.3" +--- + + diff --git a/product_docs/docs/bart/2.5.4/bart_v2.5.4_documentation.pdf b/product_docs/docs/bart/2.5.4/bart_v2.5.4_documentation.pdf new file mode 100644 index 00000000000..8fabb600403 Binary files /dev/null and b/product_docs/docs/bart/2.5.4/bart_v2.5.4_documentation.pdf differ diff --git a/product_docs/docs/bart/2.5.4/index.mdx b/product_docs/docs/bart/2.5.4/index.mdx new file mode 100644 index 00000000000..fbfb7811dea --- /dev/null +++ b/product_docs/docs/bart/2.5.4/index.mdx @@ -0,0 +1,12 @@ +--- +title: Backup and Recovery Tool +productStub: true +directoryDefaults: + description: "EDB Backup and Recovery Tool Version 2.5.4 Documentation and release notes. A tool to manage and configure PostgreSQL backups and disaster recovery." + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/p/edb-backup-and-recovery-tool/2.5.4" +--- + + diff --git a/product_docs/docs/bart/2.5.5/bart_v2.5.5_documentation.pdf b/product_docs/docs/bart/2.5.5/bart_v2.5.5_documentation.pdf new file mode 100644 index 00000000000..c04f37b8e13 Binary files /dev/null and b/product_docs/docs/bart/2.5.5/bart_v2.5.5_documentation.pdf differ diff --git a/product_docs/docs/bart/2.5.5/index.mdx b/product_docs/docs/bart/2.5.5/index.mdx new file mode 100644 index 00000000000..025b8a807ac --- /dev/null +++ b/product_docs/docs/bart/2.5.5/index.mdx @@ -0,0 +1,12 @@ +--- +title: Backup and Recovery Tool +productStub: true +directoryDefaults: + description: "EDB Backup and Recovery Tool Version 2.5.5 Documentation and release notes. A tool to manage and configure PostgreSQL backups and disaster recovery." + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/p/edb-backup-and-recovery-tool/2.5.5" +--- + + diff --git a/product_docs/docs/bart/2.5.7/bart_v2.5.7_documentation.pdf b/product_docs/docs/bart/2.5.7/bart_v2.5.7_documentation.pdf new file mode 100644 index 00000000000..ce109bf5465 Binary files /dev/null and b/product_docs/docs/bart/2.5.7/bart_v2.5.7_documentation.pdf differ diff --git a/product_docs/docs/bart/2.5.7/index.mdx b/product_docs/docs/bart/2.5.7/index.mdx new file mode 100644 index 00000000000..c7628a2a3ec --- /dev/null +++ b/product_docs/docs/bart/2.5.7/index.mdx @@ -0,0 +1,12 @@ +--- +title: Backup and Recovery Tool +directoryDefaults: + description: "EDB Backup and Recovery Tool Version 2.5.7 Documentation and release notes. A tool to manage and configure PostgreSQL backups and disaster recovery." +productStub: true + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/p/edb-backup-and-recovery-tool/2.5.7" +--- + + diff --git a/product_docs/docs/bart/2.5.9/bart_inst/02_installing_bart.mdx b/product_docs/docs/bart/2.5.9/bart_inst/02_installing_bart.mdx new file mode 100644 index 00000000000..f4e2ef84cbd --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_inst/02_installing_bart.mdx @@ -0,0 +1,433 @@ +--- +title: 'Installing BART' + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/installation-getting-started/installation-upgrade-guide/2.6.1/installing_bart.html" +--- + +This section will walk you through performing a fresh installation of BART on a host. Installation instructions are organized into the following platform/installer specific sections: + +- [Installing BART on a CentOS Host](#installing-bart-on-a-centos-host) +- [Installing BART on a RHEL Host](#installing-bart-on-a-rhel-host) +- [Installing BART on a RHEL/CentOS 7 PPCLE Host](#installing-bart-on-a-rhelcentos-7-ppcle-host) +- [Installing BART on a Debian or Ubuntu Host](#installing-bart-on-a-debian-or-ubuntu-host) +- [Installing BART on an SLES 12 Host](#installing-bart-on-an-sles-12-host) + +!!! Note + If you are using the pdf version of this document, using the cut/paste command to copy may result in extra spaces or carriage returns in the pasted command. If a command fails, check the command carefully for additional characters. + +## Installing BART on a CentOS Host + +The following section demonstrates installing BART on a CentOS host using an RPM package.  This section assumes that the user has some knowledge of installation and system administration procedures, and has administrative privileges on the host. + +1. To install the repository configuration, assume superuser privileges and invoke one of the following platform-specific commands: + + On CentOS 7: + + ```text + yum -y install https://yum.enterprisedb.com/edbrepos/edb-repo-latest.noarch.rpm + ``` + + On CentOS 8: + + ```text + dnf -y install https://yum.enterprisedb.com/edbrepos/edb-repo-latest.noarch.rpm + ``` + +2. Replace the `USERNAME:PASSWORD` in the following command with the username and password of a registered EnterpriseDB user: + + ```text + sed -i "s@:@USERNAME:PASSWORD@" /etc/yum.repos.d/edb.repo + ``` + + To request credentials for the repository, visit the [EDB website](https://www.enterprisedb.com/user). + +3. Before installing BART, execute the following command to install the Extra Packages for Enterprise Linux (EPEL) release package: + + On CentOS 7: + + ```text + yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm + ``` + + On CentOS 8: + + ```text + dnf -y install epel-release + ``` + +4. For CentOS 8, enable the PowerTools repository to satisfy EPEL package dependencies: + + ```text + dnf config-manager --set-enabled PowerTools + ``` + +5. For CentOS 8, disable the built-in PostgreSQL module: + + ```text + dnf -qy module disable postgresql + ``` + +6. Optionally, install the `pg_basebackup` utility program using the server client package. If you do not already have the `pg_basebackup` program installed on the BART host, you can install a limited number of files that include the `pg_basebackup` program by invoking the following command: + + On CentOS 7: + + ```text + yum install edb-as-server-client + ``` + + On CentOS 8: + + ```text + dnf install edb-as-server-client + ``` + + In the above command, replace `` with the required Advanced Server version. The `pg_basebackup` version must be the same or more recent than the database server to be backed up. For example, `pg_basebackup` version 10 can be used to back up database server version 10, but cannot be used to back up database server version 11. + +7. Use the following command to install BART: + + On CentOS 7: + + ```text + yum -y install edb-bart-2.5.9 + ``` + + On CentOS 8: + + ```text + dnf -y install edb-bart-2.5.9 + ``` + + Repeat the installation process described in this section to install BART on each remote host on which an incremental backup is to be restored. + + To verify the BART installation, navigate to the `/usr/edb/bart/bin` directory and execute the following command: + + ```text + bart --version + ``` + + The `bart --version` command should return the current BART version. If the `bart --version` command returns an error stating the PATH is not available after switching from the root user to another BART user account, adjust the setting of the `PATH` environment variable to include the directory location of the BART `bin` subdirectory in the `~/.bashrc` or `~/.bash_profile` files of the following user accounts: + + - The BART user account on the BART host. See [Configuring BART](03_configuring_bart/#path) for details. + - The remote user account on the remote host to which incremental backups are to be restored. For details, see the *EDB Backup and Recovery User Guide* available at the [EDB website](/bart/latest/bart_user/). + + Upon successful installation, BART is installed in the `BART_HOME` directory: + + `/usr/edb/bart` + + The installation includes the following files: + +| File Name | Location | Description | +| ------------------- | ----------------- | ------------------------------------- | +| bart | ``/bin | BART command line, executable program | +| bart-scanner | ``/bin | BART WAL scanner program | +| bart.cfg.sample | ``/etc | Sample BART configuration file | +| xlogreader_ident.so | ``/lib | Libraries supporting WAL versions | +| bart_license.txt | `` | License agreement | + +After BART is installed successfully, you need to [configure the installation](03_configuring_bart/#configuration). + +## Installing BART on a RHEL Host + +The following section demonstrates installing BART on a RHEL host using an RPM package.  This section assumes that the user has some knowledge of installation and system administration procedures, and has administrative privileges on the host. + +1. To install the repository configuration, assume superuser privileges and invoke one of the following platform-specific commands: + + On RHEL 7: + + ```text + yum -y install https://yum.enterprisedb.com/edbrepos/edb-repo-latest.noarch.rpm + ``` + + On RHEL 8: + + ```text + dnf -y install https://yum.enterprisedb.com/edbrepos/edb-repo-latest.noarch.rpm + ``` + +2. Replace the `USERNAME:PASSWORD` in the following command with the username and password of a registered EnterpriseDB user: + + ```text + sed -i "s@:@USERNAME:PASSWORD@" /etc/yum.repos.d/edb.repo + ``` + + To request credentials for the repository, visit the [EDB website](https://www.enterprisedb.com/user). + +3. Before installing BART, execute the following command to install the Extra Packages for Enterprise Linux (EPEL) release package: + + On RHEL 7: + + ```text + yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm + ``` + + On RHEL 8: + + ```text + dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm + ``` + +4. Enable the repository: + + On RHEL 7, enable the `optional, extras`, and `HA` repositories to satisfy EPEL package dependencies: + + ```text + subscription-manager repos --enable "rhel-*-optional-rpms" --enable "rhel-*-extras-rpms" --enable "rhel-ha-for-rhel-*-server-rpms" + ``` + + On RHEL 8, enable the `codeready-builder-for-rhel-8-*-rpms` repository to satisfy EPEL packages dependency: + + ```text + ARCH=$( /bin/arch ) + + subscription-manager repos --enable "codeready-builder-for-rhel-8-${ARCH}-rpms" + ``` + +5. For RHEL 8, disable the built-in PostgreSQL module: + + ```text + dnf -qy module disable postgresql + ``` + +6. Optionally, install the `pg_basebackup` utility program using the server client package. If you do not already have the `pg_basebackup` program installed on the BART host, you can install a limited number of files that include the `pg_basebackup` program by invoking the following command: + + On RHEL 7: + + ```text + yum install edb-as-server-client + ``` + + On RHEL 8: + + ```text + dnf install edb-as-server-client + ``` + + In the above command, replace `` with the required Advanced Server version. The `pg_basebackup` version must be the same or more recent than the database server to be backed up. For example, `pg_basebackup` version 10 can be used to back up database server version 10, but cannot be used to back up database server version 11. + +7. Use the following command to install the BART: + + On RHEL 7: + + ```text + yum -y install edb-bart-2.5.9 + ``` + + On RHEL 8: + + ```text + dnf -y install edb-bart-2.5.9 + ``` + + Repeat the installation process described in this section to install BART on each remote host on which an incremental backup is to be restored. + + To verify the BART installation, navigate to the `/usr/edb/bart/bin` directory and execute the following command: + + ```text + bart --version + ``` + + The `bart --version` command should return the current BART version. If the `bart --version` command returns an error stating the PATH is not available after switching from the root user to another BART user account, adjust the setting of the `PATH` environment variable to include the directory location of the BART `bin` subdirectory in the `~/.bashrc` or `~/.bash_profile` files of the following user accounts: + + - The BART user account on the BART host. See [Configuring BART](03_configuring_bart/#path) for details. + - The remote user account on the remote host to which incremental backups are to be restored. For details, see the *EDB Backup and Recovery User Guide* available at the [EDB website](/bart/latest/bart_user/). + + Upon successful installation, BART is installed in the `BART_HOME` directory: + + `/usr/edb/bart` + + The installation includes the following files: + +| File Name | Location | Description | +| ------------------- | ----------------- | ------------------------------------- | +| bart | ``/bin | BART command line, executable program | +| bart-scanner | ``/bin | BART WAL scanner program | +| bart.cfg.sample | ``/etc | Sample BART configuration file | +| xlogreader_ident.so | ``/lib | Libraries supporting WAL versions | +| bart_license.txt | `` | License agreement | + +After BART is installed successfully, you need to [configure the installation](03_configuring_bart/#configuration). + + + +## Installing BART on a RHEL/CentOS 7 PPCLE Host + +The following section demonstrates installing BART on a RHEL host using an RPM package.  This section assumes that the user has some knowledge of installation and system administration procedures, and has administrative privileges on the host. + +1. Install Advance Toolchain: + + ```text + rpm --import https://public.dhe.ibm.com/software/server/POWER/Linux/toolchain/at/redhat/RHEL7/gpg-pubkey-6976a827-5164221b + + cat > /etc/yum.repos.d/advance-toolchain.repo <:@USERNAME:PASSWORD@" /etc/yum.repos.d/edb.repo + ``` + + To request credentials for the repository, visit the [EDB website](https://www.enterprisedb.com/user). + +4. Before installing BART, execute the following command to install the Extra Packages for Enterprise Linux (EPEL) release package: + + ```text + yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm + ``` + +5. On RHEL 7, enable the `optional, extras`, and `HA` repositories to satisfy EPEL package dependencies: + + ```text + subscription-manager repos --enable "rhel-*-optional-rpms" --enable "rhel-*-extras-rpms" --enable "rhel-ha-for-rhel-*-server-rpms" + ``` + +6. Invoke the following command to install BART: + + ```text + yum -y install edb-bart-2.5.9 + ``` + + + +## Installing BART on a Debian or Ubuntu Host + +Perform the following steps to install a Debian package using the EnterpriseDB apt repository. + +To request credentials for the repository, visit the [EDB website](https://www.enterprisedb.com/repository-access-request). + +1. Assume the superuser privileges. + + ```text + sudo su - + ``` + +2. To configure the EnterpriseDB repository on Debian 9 and Ubuntu 18: + + ```text + sh -c 'echo "deb https://username:password@apt.enterprisedb.com/$(lsb_release -cs)-edb/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/edb-$(lsb_release -cs).list' + ``` + + On Debian 10: + + a. Set up the EnterpriseDB repository: + + ```text + sh -c 'echo "deb [arch=amd64] https://apt.enterprisedb.com/$(lsb_release -cs)-edb/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/edb-$(lsb_release -cs).list' + ``` + + b. Substitute your EnterpriseDB credentials for the `username` and `password` placeholders in the following command: + + ```text + sh -c 'echo "machine apt.enterprisedb.com login password " > /etc/apt/auth.conf.d/edb.conf' + ``` + +3. Add support to your system for secure APT repositories. + + ```text + apt-get install apt-transport-https + ``` + +4. Add the EDB signing key; When invoking the command, replace the `username` and `password` with the credentials provided by EnterpriseDB. + + ```text + wget -q -O - https://apt.enterprisedb.com/edb-deb.gpg.key | apt-key add – + ``` + +5. Update the repository metadata. + + ```text + apt-get update + ``` + +6. Install the Debian package: + + a. Contact [EDB Support](https://support.enterprisedb.com) for information about how to install the BART 2.5.9 package. + + b. Navigate to the download directory and execute the following command: + + ```text + apt-get install ./edb-bart_2.5.9-1-deb10_amd64.deb + ``` + + + +## Installing BART on an SLES 12 Host + +This section provides instructions for installing BART on an SLES 12 SP4 host using the zypper package manager. BART is supported on SLES SP4 and SP5 versions. + +1. Assume superuser privileges. + + ```text + sudo su - + ``` + +2. Use the following command to add the EDB repository to your SLES host: + + ```text + zypper addrepo https://zypp.enterprisedb.com/suse/edb-sles.repo + ``` + +3. Invoke the following command to refresh the metadata: + + ```text + zypper refresh + ``` + +4. Install `SUSEConnect` to register the host with SUSE to allow access to SUSE repositories: + + ```text + zypper install SUSEConnect + ``` + +5. Register the host with SUSE to allow access to SUSE repositories and replace `'REGISTRATION_CODE'` and `'EMAIL'` with your SUSE registration information: + + ```text + SUSEConnect -r 'REGISTRATION_CODE' -e 'EMAIL' + ``` + + ```text + SUSEConnect -p PackageHub/12.4/x86_64 + ``` + + ```text + SUSEConnect -p sle-sdk/12.4/x86_64 + ``` + +6. Install the following repository for PEM dependencies: + + ```text + zypper addrepo https://download.opensuse.org/repositories/Apache:/Modules/SLE_12_SP4/Apache:Modules.repo + ``` + +7. Refresh the metadata: + + ```text + zypper refresh + ``` + +8. Then, use the zypper utility to install BART: + + ```text + zypper install edb-bart-2.5.9 + ``` diff --git a/product_docs/docs/bart/2.5.9/bart_inst/03_configuring_bart.mdx b/product_docs/docs/bart/2.5.9/bart_inst/03_configuring_bart.mdx new file mode 100644 index 00000000000..0201f230692 --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_inst/03_configuring_bart.mdx @@ -0,0 +1,643 @@ +--- +title: "Configuring BART" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/installation-getting-started/installation-upgrade-guide/2.6.1/configuring_bart.html" +--- + + + +To configure BART, you must establish the BART user account, [configure the BART host](#configuring-the-bart-host), and [configure the database server](#configuring_database_server) that will be backed up. + + + +## Establishing the BART User Account + +The BART user account is an operating system user that will run the BART command line program. The BART user account must: + +- own the BART backup catalog. +- be able to run the `bart` program and the `bart-scanner` program. +- be able to establish a SSH/SCP connection to and from each database server managed by BART. + +You can optionally use the `enterprisedb` database user as the BART user account for an Advanced Server database and `postgres` database user as the BART user account for a PostgreSQL server. If you do not wish to use an existing database user as the BART user account, you must create an operating system user to assume the role. + + + +## Configuring BART and Database Server + +As stated earlier, to configure BART, you must [configure the BART host](#configuring-the-bart-host) as well as the [database server](#configuring_database_server). The following table acts as a configuration parameter reference listing the mandatory and optional parameters with default values for `[SERVER]` as well as `[BART]` sections. + +- Parameters set in the `[BART]` section are applicable to all BART managed database servers. +- Parameters set in the `Server` section are applicable only to the specific server; the `Server` parameter setting overrides the `[BART]` section setting. + +For information about configuring BART host parameters, see the [BART Host Parameter Reference](#bart) and for information about configuring the database server parameters, see the [Database Server Parameter Reference](#server). + +| **Parameter** | **Type** | **Default** | **\[SERVER]** | **\[BART]** | +| -------------------------- | --------- | ------------------------------------------------------------ | ------------- | ----------- | +| `[BART]` | Mandatory | N/A | N/A | Yes | +| `` | Mandatory | N/A | N/A | Yes | +| `` | Mandatory | N/A | N/A | Yes | +| `` | Mandatory | N/A | N/A | Yes | +| `retention_policy` | Optional | `BACKUPS` | Yes | Yes | +| `wal_compression` | Optional | `Disabled` | Yes | Yes | +| `copy_wals_during_restore` | Optional | `Disabled` | Yes | Yes | +| `xlog_method` | Optional | `fetch` | Yes | Yes | +| `logfile` | Optional | `/tmp/bart.log` | N/A | Yes | +| `scanner_logfile` | Optional | `/tmp/bart_scanner.log` | N/A | Yes | +| `` | Optional | `/tmp` | N/A | Yes | +| `` | Optional | `` | N/A | Yes | +| `` | Optional | `1` | Yes | Yes | +| `` | Optional | `49152` | Yes | Yes | +| `` | Optional | `0` | Yes | Yes | +| `` | Optional | `20 seconds` | Yes | Yes | +| `` | Optional | `1` | Yes | Yes | +| `[Server Name]` | Mandatory | N/A | Yes | N/A | +| `` | Optional | N/A | Yes | N/A | +| `host` | Mandatory | N/A | Yes | N/A | +| `port` | Mandatory | `5444` for EPAS; `5432` for Postgres | Yes | N/A | +| `user` | Mandatory | N/A | Yes | N/A | +| `` | Optional | `BART backup catalog` | Yes | N/A | +| `` | Optional | N/A | Yes | N/A | +| `` | Mandatory | `enterprisedb` for EPAS

`postgres` for PostgreSQL | Yes | N/A | +| `` | Optional | N/A | Yes | N/A | +| `` | Optional | N/A | Yes | N/A | +| `allow_incremental_backup` | Optional | `Disabled` | Yes | N/A | +| `description` | Optional | N/A | Yes | N/A | + + + +### Configuring the BART Host + +To configure the BART host, perform the following steps on the BART host as a root user: + +**Step 1.** Navigate to the `usr/edb/bart/etc` directory and make a copy of the `bart.cfg.sample` file to create the `bart.cfg` file that will contain the parameter settings. + +**Step 2.** Confirm that the Postgres `pg_basebackup` utility program is installed on the BART host. The `pg_basebackup` utility resides in the `bin` directory under your Postgres installation. + + + +**Step 3.** Ensure the `LD_LIBRARY_PATH` environment variable includes the location of the `libpq` library. If your `libpq` library does not reside in the default location (`POSTGRES_INSTALL_HOME/lib`), you must add the library path to the `LD_LIBRARY_PATH` environment variable in the BART user account’s profile (`bash_profile`) located in `/home/`: + +```text +# .bash_profile +# Get the aliases and functions +if [ -f ~/.bashrc ]; then +. ~/.bashrc +fi +# User specific environment and startup programs +export LD_LIBRARY_PATH=/usr/edb/as11/lib:$LD_LIBRARY_PATH +``` + +**Step 4.** Create the BART backup catalog and ensure the BART user account holds privileges on the BART backup catalog. In the following example, the BART configuration file specifies `/opt/backup` as the parent directory for the BART backup catalog in the `` parameter: + +```text +[BART] + +bart_host = bartuser@192.168.2.22 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log +``` + +In the following example, `bartuser` is the BART user account. The example creates and sets the ownership and permissions on the BART backup catalog: + +```text +su root +mkdir /opt/backup +chown bartuser /opt/backup +chgrp bartuser /opt/backup +chmod 700 /opt/backup +``` + +If the subdirectory does not exist, BART creates a subdirectory for each database server listed in the configuration file when you invoke the `bart` command line program. + +**Step 5.** Use your choice of editor to open the BART configuration file (located in the `usr/edb/bart/etc` directory) and edit the configuration as required. You must add the mandatory parameters to the `[BART]` section. Default values may be used for optional parameters. + +The following table describes the `[BART]` host parameters. + + + +| **Parameters/Placeholder** | **Type** | **Description** | +| -------------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `[BART}` | Mandatory | Identifies the global section of the configuration file. It must be named BART. | +| `bart_host` | Mandatory | Specify the bart user name and the IP address of the bart host on which the BART utility resides. You must specify it in the form of <bart_user>@<bart_host_address>. | +| `backup_path` | Mandatory | Specify the path to the file system parent directory where all BART backups are stored. | +| `pg_basebackup_path` | Mandatory | Specify the path to the `pg_basebackup` program that you installed on the BART host. For information about `pg_basebackup` version-specific restrictions, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/latest/bart_user/). | +| `wal_compression` | Optional | Set this parameter to `enabled` to compress the archived WAL files in gzip format in the BART backup catalog when the `MANAGE` subcommand is invoked. By default it is set to `disabled`. The gzip compression program must be in the BART user account’s `PATH` and the WAL compression setting must not be enabled for those database servers where you need to take incremental backups. | +| `copy_wals_during_restore` | Optional | Set this parameter to `enabled` to copy the archived WAL files from the BART backup catalog to the `restore_path/archived_wals` directory prior to the database server archive recovery. Enabling this option helps you save time during the restore operation. Set this parameter to `disabled` (default) to retrieve the archived WAL files directly from the BART backup catalog during the database server archive recovery. During the restore operation, recovery settings will be saved in the `postgresql.auto.conf` file. The `restore_command` in the `postgresql.auto.conf` file will be determined by the value specified in the `copy_wals_during_restore` parameter. If the `RESTORE` subcommand is invoked with the `-c` option, the archived WAL files are copied from the BART backup catalog to the `restore_path/archived_wals` directory, thus overriding any setting of the `copy_wals_during_restore` parameter. If the `RESTORE` subcommand is invoked without the `-c` option, the value specified by the `copy_wals_during_restore` parameter is used. | +| `xlog_method` | Optional | Specify how the transaction log is collected during the execution of `pg_basebackup` through the `BACKUP` subcommand. Set `xlog_method` to `fetch` (default) to collect the transaction log files after the backup is completed. Set to `stream` to stream the transaction log in parallel with the full backup creation. | +| `retention_policy` | Optional | Set this parameter to determine when an active backup should be marked as `obsolete` when the `MANAGE` subcommand is used. You can specify the retention policy either in terms of number of backups or duration (days, weeks, or months). ` BACKUPS` (default), ` DAYS`, ` WEEKS`, or ` MONTHS` where `` is a positive integer. For information about managing backups using a retention policy, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/latest/bart_user/). | +| `logfile` | Optional | Use this parameter to specify the path to the BART log file. The default log file location is `/tmp/bart.log`. The log file will be created the first time you invoke the `bart` command line program using the sample configuration file value. To change the default setting, you must delete the `bart.log` file from the `/tmp` directory and create a new log file in another directory so that a new log file will be created and owned by the new BART user account. If no path to a log file is specified, BART does not create a log file. | +| `scanner_logfile` | Optional | Use this parameter to specify the path to the XLOG/WAL scanner log file. The default location is `/tmp/bart_scanner.log`. The scanner log file will be created the first time you invoke the `bart_scanner` program using the sample configuration file value. To change the default setting, you must delete the `bart_scanner.log` file from the `/tmp` directory and create a new log file in another directory so that a new log file will be created and owned by the new BART user account. If no path to a log file is specified, BART does not create a WAL scanner log file. | +| `` | Optional | Specify the socket directory path where all BART sockets will be stored. The default directory is `/tmp`. While specifying the `bart_socket_directory` path, you must ensure that the directory exists and the BART user has the required access permissions to the directory. | +| `` | Optional | Specify a user-friendly BART socket file name. Using this option overrides the default BART socket name generated using MD5 checksum. You must shut down the bart-scanner before setting this option. You can view the `` in the `sockPath` field after starting the bart-scanner in the debug mode. This option helps in preventing the use of MD5 during the bart-scanner startup, thus making BART more compliant in FIPS mode. | +| `` | Optional | Specify the number of worker threads for copying blocks (for incremental backups) or data files (for full backup) from the database server to the `archive_path` when the `BACKUP` subcommand is invoked. The default value is `1`. The same set of worker threads are used for the compression operation when taking full backups in order to provide parallel, compressed backups when the `BACKUP` subcommand is specified with the `-z` or `-c` options. The compression operation does not apply to incremental backups. See [thread count](#thread_count) for more information. | +| `` | Optional | Specify the number of blocks of memory used for copying modified blocks from the database server to the `archive_path` when the `BACKUP` subcommand is invoked for incremental backups. The default value is 49152 blocks; each block is 8192 bytes. The maximum permitted value is 131072 blocks and the minimum permitted value is 1 block. Reduce the `` setting if the server runs out of memory while executing the `pg_read_binary_file()`. | +| `` | Optional | Specify the number of seconds after which the WAL scanner should initiate force scanning of the new WAL files. The default value is 0, which means no brute-force scanning will be started. After upgrading to the latest version of BART, users who have set this parameter to a non-default value may see increased CPU consumption on the part of bart-scanner. If this is an issue, consider increasing the configured value of `scan_interval` parameter, or removing the setting if it is not required. | +| `` | Optional | Specify the number of seconds to wait for MBM files before timing out; this parameter is applicable only for incremental backup. You must set the `scan_interval` to a value significantly less than the MBM scan timeout. The default value is 20 seconds. The `mbm_scan_timeout` parameter value must be greater than 0. If the value is 0 or negative, then an error will be displayed during an incremental backup. | +| `` | Optional | Specify the number of parallel worker processes required to stream the modified blocks of an incremental backup to the restore host. The default value is 1. | + + + +**Thread Count** + +If the `BACKUP` subcommand is invoked with the `--thread-count` option, then the number of worker threads specified by this option overrides any setting of the `thread_count` parameter in the BART configuration file. If the `BACKUP` subcommand is invoked without the `--thread-count` option, then the following determines the number of worker threads used: + +- The setting of the `thread_count` parameter in the server section of the BART configuration file overrides the setting of `thread_count` in the global section for that particular database server. +- If omitted in the server section, the setting of `thread_count` in the global section is used. +- If the `thread_count` parameter is not specified in either section, the default is 1. +- When taking a full backup, if the `thread count` in effect is only 1, then the `pg_basebackup` utility is used to take the full backup unless the `--no-pg_basebackup` option is specified with the `BACKUP` subcommand. + +`` will not be effective if the backup is taken on a standby server. + +If parallel backup is run with `N` number of worker threads, then it will initiate `N + 1` concurrent connections with the server. + +**Step 6** Invoke the `CHECK-CONFIG` subcommand, omitting the `-s` option to check the parameter settings in the BART configuration file. It should return the current BART version. + +```text +bart CHECK-CONFIG +``` + +The `CHECK-CONFIG` subcommand displays an error message if the required configuration is not properly set. You need to check the logfile to fix this. + + + +### Configuring the Database Server + +To configure the database server, you must: + +1. [Authorize SSH/SCP access without a password prompt](#authorizing_ssh_scp_access). +2. [Create and configure a replication database user](#setting_up_a_replication_database_user). +3. [Adding the database server to the configuration file (server section)](#adding_a_database_server). +4. [Enable WAL archiving of the server](#enabling_wal_archiving). +5. [Verify the server configuration settings](#verifying_configuration_settings). + +The following section will walk you through the configuration process. + +!!! Note + You must authorize SSH/SCP access and set up a replication database user before restarting the database server with WAL archiving enabled. + + + +**Authorizing SSH/SCP Access** + +BART uses the Secure Shell (`ssh`) and Secure Copy (`scp`) Linux utility programs to copy the backup and WAL files from the BART managed database servers to the BART host as well as to restore backups. + +- The client/server `ssh` and `scp` commands must not prompt for a password when establishing a connection with the target server (the server to which a passwordless connection is being made). +- A passwordless connection uses *authorized public keys* (public key of a client user account) to authenticate with the target server. +- You must add the public key of each client user account to the target user account’s authorized public keys list on the target server. + +For BART usage, there are two scenarios that require a passwordless SSH/SCP connection: + +- When connecting from each BART managed database server (SSH/SCP client) to the BART host (target SSH/SCP server) to support WAL archiving as implemented by the `archive_command` parameter. + - In this case, the database server user account should generate the public key file (`id_rsa.pub`) with the `ssh-keygen –t rsa` command on the database server host. + - The public key file name should be appended to the `~/.ssh/authorized_keys` file on the BART host. The `authorized_keys` file is in the BART user account’s home directory. +- When connecting from the BART host (SSH/SCP client) to each BART managed database server (target SSH/SCP server) for taking incremental backups and for supporting restoration of the full backup, the archived WAL files, and the modified blocks, which occurs when the BART `RESTORE` subcommand is given. + - In this case, the BART user account should generate the public key file (`id_rsa.pub`) with the `ssh-keygen –t rsa` command on the BART host. + - The public key file name should be appended to the `~/.ssh/authorized_keys` file on the database server host. The `authorized_keys` file is in the home directory of the user account that owns the directory where the database backup is to be restored. +- If backups are to be taken from a given database server host, but restored to a different database server host, the passwordless SSH/SCP connections must be configured from the BART host to the database server host from which the backup is to be taken as well as from the BART host to the database server host to which the backup is to be restored. + +See the EDB Backup and Recovery Reference Guide available at the [EDB website](/bart/latest/bart_ref/) to view examples of creating a passwordless connection. + +**Enabling Public Key Authentication** + +The following example enables SSH/SCP access on a CentOS 7.x host; similar (platform-specific) steps will apply to other platforms/versions. + +1. In the SSH server daemon configuration file (`sshd_config`) located in the `/etc/ssh`, set the `PubkeyAuthentication` parameter to `yes`. +2. Reload the configuration file: + +```text +service sshd reload +``` + +If you get any SSH or SCP errors, examine the `/var/log/secure` log file. + +**Creating a Passwordless Connection** + +The following general instructions will walk you through generating a client’s public key file, creating the target server’s authorized public keys file, and creating a passwordless connection. + +**Step 1.** On the client system, log in as the user account that will be initiating the SSH or SCP connection. + +**Step 2.** Navigate to the user account’s home directory and check for an existing `.ssh` subdirectory. If the `.ssh` directory does not exist, create one and assign the required privileges to the user. + +**Step 3.** Generate the public key file with the following command. Accept all prompted defaults and do not specify a passphrase when prompted for one. + +```text +ssh-keygen –t rsa +``` + +The public key file named `id_rsa.pub` is created in the `.ssh` subdirectory. + +**Step 4.** While logged into the client where you just generated the public key file, use `SCP` to make a temporary copy of it on the target server: + +```text +scp ~/.ssh/id_rsa.pub @:tmp.pub +``` + +**Step 5.** Navigate into the target user account’s home directory and check for an existing `.ssh` subdirectory. If it does not exist, create one and assign the required privileges to the user. + +**Step 6.** Append the temporary, client’s public key file, `tmp.pub`, to the `authorized_keys` file. If an `authorized keys` file does not exist, create a new file, but do not completely replace any existing `authorized keys` file. + +```text +cat tmp.pub >> ~/.ssh/authorized_keys +``` + +Make sure the `authorized_keys` file is only accessible by the file owner and not by groups or other users. If the `authorized_keys` file does not have the required permission setting or it was newly created, change the file permissions as follows: + +```text +chmod 600 ~/.ssh/authorized_keys +``` + +**Step 7.** Delete the temporary public key file: + +```text +rm tmp.pub +``` + +Now, when logged into the client system as `user` there should be no prompt for a password when commands such as the following is given: + +```text +ssh target_user@host_address +``` + + + +**Setting up a Replication Database User** + +For each database server that is to be managed by BART, a database user must be chosen to serve as the *replication database user*. The replication database user sets the Postgres `archive_command` configuration parameter when the `INIT` subcommand in invoked and creates backups when the `BACKUP` subcommand is invoked. The replication database user must be a `superuser`. + +When executed with the PSQL client, the following PostgreSQL command creates a superuser to be the replication database user: + +`CREATE ROLE repuser WITH LOGIN SUPERUSER PASSWORD 'password';` + +The `pg_hba.conf` file must minimally permit the replication database user to have access to the database. + +In the following example, the `pg_hba.conf` file permits the `repuser` (replication database user) to have access to the `template1` database. The IP address from which `repuser` has access to `template1` database is the location of the BART host: + +**For pg_basebackup only:** If `pg_basebackup` is to be used for taking any backups (such as for standby servers), the replication database user must also be included in the `pg_hba.conf` file as a `replication` database connection as shown by the last entry in the following example. + +```text +# TYPE DATABASE USER ADDRESS METHOD +# "local" is for Unix domain socket connections only +local all all md5 +# IPv4 local connections: +host template1 repuser 192.168.2.22/32 md5 +host all enterprisedb 127.0.0.1/32 md5 +# IPv6 local connections: +host all all ::1/128 md5 +# Allow replication connections from localhost, by a user with the +# replication privilege. +host replication repuser 192.168.2.22/32 md5 +``` + +The replication database user must be specified for the `user` parameter in the BART configuration file for the database server as shown in the following example: + +```text +[ACCTG] +host = 192.168.2.24 +port = 5444 +user = repuser +cluster_owner = enterprisedb +remote_host = enterprisedb@192.168.2.24 +description = "Accounting" +``` + +There must be no password prompt when connecting to the database server with the replication database user. There are several ways to permit this; one recommended method is to use a `.pgpass` file located in the BART user account’s home directory. + +For example, if `bartuser` is the BART user account, then the `.pgpass` file located in the `/home/bartuser` directory must contain the following entry: + +`192.168.2.24:5444::repuser:password` + +When `bartuser` invokes a BART backup, the password for the replication database user, `repuser`, is obtained from the `.pgpass` file of `bartuser` to connect to the database server running at `192.168.2.24` on `port 5444`. + +The `.pgpass` file must contain an entry for each BART managed database server and its corresponding replication database user and password. + + + +**Adding a Database Server to the BART Configuration File** + +To manage the backup and recovery of a database server, you must add entries to the `[SERVER]` section of the BART configuration file, which is located in `/etc` directory. + + + +*Database Server Parameter Reference* + +Set the following parameters in the \[`SERVER`] section of the BART configuration file. The parameter setting in the \[`SERVER`] section overrides the setting in the global \[`BART`] section for that particular database server. If omitted, the default value will be used. + +For each cluster serviced by BART, the following parameters are mandatory: + +```text +[HR] + +host = 192.168.2.24 +port = 5432 +user = postgres +cluster_owner = postgres +``` + +!!! Note + The port parameter setting is required only if the database server listens on a port other than the default (for example if Postgres listens on a port other than 5432). + +The following table describes the database server parameters. + + + + + + + + + +| **Parameters/Placeholder** | Type | **Description** | +| --------------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `[ServerName]` | Mandatory | Specify the server name that you want to backup using BART. It is not case-sensitive when referenced with BART subcommand options. A lowercase conversion of this name is used to create a subdirectory in the BART backup catalog for storing the backups and WAL files for this database server (for eg., epas12). | +| `` | Optional | Specify a [template](#backup_name_template) for user-defined, friendly names that will be assigned to the backups of the database server. The maximum permitted length of backup name is 49 characters. The `` parameter can be overridden by the `--backup-name` option of the `BACKUP` subcommand. If this parameter is omitted from the BART configuration file, and the `--backup-name` option with a user-defined name is not specified with the `BACKUP` subcommand, then the backup can only be referenced in BART subcommands by the BART assigned, integer backup identifier. | +| `host` | Mandatory | Specify the IP address of the database server to be configured for backup. | +| `port` | Mandatory | Specify the port number identifying the database server instance (that is, the relevant database cluster) to be backed up. The default port number for EPAS is `5444` and for Postgres it is `5432`. The port parameter setting is only required if the database server listens on a port other than the default value. | +| `User` | Mandatory | Specify the replication database user name used by BART to establish the connection to the database server for full backups. See [Setting up a Replication Database User](#setting_up_a_replication_database_user) for more information. | +| `` | Optional | Specify the path where archived WAL files will be stored. The default location is the BART backup catalog (`//archived_wals`). | +| `` | Optional | When the `INIT` subcommand is used, the content and variables specified in the BART `` result in the archive command string to be generated into the `Postgres archive_command` parameter in the `postgresql.auto.conf` file. To configure the BART `` parameter, enclose the command string within single quotes ('). If you do not specify the `` parameter in the configuration file, the default setting is taken as `'scp %p %h:%a/%f'`. See [Archive Command Auto Configuration](#archive_command_auto_configuration) for information about variables. The BART `` parameter in the BART configuration file, and the Postgres `` parameter in the `postgresql.conf` file (or the `postgresql.auto.conf` file) refer to two different parameters that are to be set in different manner. | +| `` | Mandatory | Specify the Linux operating system user account that owns the database cluster. This is typically `enterprisedb` for Advanced Server database clusters installed in the Oracle compatible mode, or `postgres` for Advanced Server database clusters installed in the PostgreSQL compatible mode and PostgreSQL database clusters. | +| `` | Optional | Specify the IP address of the remote server to which a backup is to be restored. Specify this parameter in the form of `@`. `` is the user account on the target database server host that accepts a passwordless SSH/SCP login connection and owns the directory where the backup is to be restored. `` is the IP address of the remote host. For restoring a backup to a remote host or for restoring any backup where `` and the BART user account are not the same users, either this parameter must be set or it may be specified with the `-r` option with the BART `RESTORE` subcommand. | +| `` | Optional | Specify path to which tablespaces are to be restored in the format `OID = `; If the backup is to be restored to a remote host specified by the `` parameter, then the tablespace paths must exist on the remote host. | +| `allow_incremental_backups` | Optional | Set this parameter to `enabled` to enable use of the WAL scanner and permit taking incremental backups when the `BACKUP` subcommand is invoked with the `--parent` option. Set it to `disabled` (default) to disallow incremental backups and thus permit only full backups. For information about using the `BACKUP` subcommand and running the WAL scanner, please see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/latest/bart_user/). | +| `Description` | Optional | Specify the description that will be used to identify the database server. | + +For information regarding the following parameters, see [configuring the BART host](#configuring-the-bart-host). + +- `retention_policy` +- `xlog_method` +- `wal_compression` +- `copy_wals_during_restore`. +- `thread_count`. +- `batch_size`. +- `scan_interval`. +- `mbm_scan_timeout`. +- `workers` + + + +**Backup Name Template** + +- The template is an alphanumeric string that may include the following variables that will be replaced with the timestamp values when the backup is taken: + + - `%year` to be replaced by 4-digit year + - `%month` to be replaced by 2-digit month + - `%day` to be replaced by 2-digit day + - `%hour` to be replaced by 2-digit hour + - `%minute` to be replaced by 2-digit minute + - `%second` to be replaced by 2-digit second + +- To include a percent sign (`%`) as a character in the backup name, specify `%%` in the template. + +- Do not enclose the template string in quotes even if you want the template to include space characters, otherwise the enclosing quotes are stored as part of the backup name. However, when referenced with the `-i` option by BART subcommands use of space characters in the backup name requires enclosing the backup name in quotes. + +The following example shows the configuration settings of three database servers: + +```text +[ACCTG] + +host = 127.0.0.1 +port = 5444 +user = enterprisedb +cluster_owner = enterprisedb +backup_name = acctg_%year-%month-%dayT%hour:%minute:%second +archive_command = 'cp %p %a/%f' +allow_incremental_backups = enabled +retention_policy = 8 BACKUPS +description = "Accounting" + +[MKTG] + +host = 192.168.2.24 +port = 5444 +user = repuser +cluster_owner = enterprisedb +remote_host = enterprisedb@192.168.2.24 +allow_incremental_backups = enabled +description = "Marketing" + +[HR] + +host = 127.0.0.1 +port = 5432 +user = postgres +cluster_owner = postgres +retention_policy = 4 DAYS +description = "Human Resources" +``` + + + +**Enabling WAL Archiving** + +WAL archiving must be enabled for the database server for which BART is to perform backup and recovery management. + +- The WAL Archiving Configuration section describes the manual WAL archiving configuration process. +- The Archive Command Auto Configuration section describes an automated WAL archiving process. + +*WAL Archiving Configuration* + +Set the following configuration parameters in the `postgresql.conf` file to enable WAL archiving + +- Set `wal_level` to `replica` or higher. +- Set `archive_mode` to `on`. +- Set the PostgreSQL `archive_command` parameter to copy the WAL files to the `archive_path`. The `archive_command` configuration parameter mentioned here is located in the `postgresql.conf` file; the PostgreSQL `archive_command` parameter is used in a different manner than the BART [archive_command](#archive_command). +- Set `max_wal_senders` to a value high enough to leave at least one session available for the backup. If the `xlog_method=stream` parameter setting is to be used by this database server, the `max_wal_senders` setting must account for an additional session for the transaction log streaming (the setting must be a minimum of 2). See [Configuring the BART host](#configuring-the-bart-host) for information about the `xlog_method` parameter. + +For detailed information about WAL archiving, see the [PostgreSQL Core Documentation](https://www.postgresql.org/docs/current/static/continuous-archiving.html). + +The `ARCHIVE PATH` field displayed by the BART `SHOW-SERVERS` subcommand displays the full directory path where the WAL files should be copied as specified in the `archive_command` configuration parameter in the `postgresql.conf` file: + +```text +-bash-4.1$ bart SHOW-SERVERS -s acctg +SERVER NAME : acctg +HOST NAME : 192.168.2.24 +USER NAME : repuser +PORT : 5444 +REMOTE HOST : +RETENTION POLICY : none +DISK UTILIZATION : 0.00 bytes +NUMBER OF ARCHIVES : 0 +ARCHIVE PATH : /opt/backup/acctg/archived_wals +ARCHIVE COMMAND : (disabled) +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +INCREMENTAL BACKUP : DISABLED +DESCRIPTION : "Accounting" +``` + +The parameter settings in the following example will copy the WAL files to a directory named `/opt/backup/acctg/archived_wals` on the BART host located at `192.168.2.22` as the `bartuser` user account. Using the `bartuser` account ensures that the operation will have sufficient permissions to copy to the BART backup catalog owned by `bartuser`. + +```text +archive_mode = on # allows archiving to be done + # (change requires restart) +archive_command = 'scp %p bartuser@192.168.2.22:/opt/backup/acctg/archived_wals/%f' + # command to use to archive a logfile segment + # placeholders: %p = path of file to archive + # %f = file name only +... + +max_wal_senders = 1 # max number of walsender processes + # (change requires restart) +``` + +The database server must be restarted in order to initiate WAL archiving, but do not do so until you have verified that the full path of the BART backup catalog has been created by a prior BART subcommand or the archive operation will fail. + +Start the WAL scanner by executing the following command: + +```text +./bart-scanner +``` + + + +*Archive Command Auto Configuration* + +To enable WAL archiving: + +- In the `postgresql.conf` file, set the `wal_level` to `replica` or higher, `archive_mode` to `on`, and `max_wal_senders` to a value high enough to leave at least one session available for the backup. If the `xlog_method=stream` parameter setting is to be used by this database server as determined in the BART configuration file, the `max_wal_senders` setting must account for an additional session for the transaction log streaming (that is, the setting must be a minimum of `2`). See [Configuring the BART host](#configuring-the-bart-host) for information on the `xlog_method` parameter. + +- Configure the Postgres `archive_command` parameter automatically with the `INIT` subcommand and restart the database server when you are ready to initiate WAL archiving. The `INIT` subcommand invokes the Postgres `ALTER SYSTEM` command to set the Postgres `archive_command` configuration parameter in the `postgresql.auto.conf` file located in the managed database server’s `POSTGRES_INSTALL_HOME data directory`. For additional information about the `INIT` subcommand, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/latest/bart_user/). + + The archive command string that the `INIT` subcommand generates into the `postgresql.auto.conf` file is determined by the parameter setting of the BART `archive_command` parameter in the server section of the BART configuration file. If the BART `archive_command` parameter is not set in the server section for a given database server, the command string that is configured uses the following default format: + + `'scp %p %h:%a/%f'` + + The following table describes these variables: + +| **Variable** | **Description** | +| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `%p` | The path of the file to archive used by the Postgres archiving process. | +| `%h` | Will be replaced by the `@` as specified in the <bart_host> parameter setting. | +| `%a` | Will be replaced by the BART `archived_wals` directory as specified in the [archive path](#archive_path) parameter setting. If the `` is not specified, then the default directory is `//archived_wals`. `` is the lowercase conversion of the database server name. | +| `%f` | The archived file name used by the Postgres archiving process. | + +The placeholders `%h` and `%a` are replaced by the `INIT` subcommand when creating the archive command string. The placeholders `%p` and `%f` are not replaced by the `INIT` subcommand, but are kept as given to be used by the Postgres archiving process. + +For example, to use the default archive command format, the BART configuration file contains the following settings where the BART `archive_command` parameter is omitted from the server section for `ACCTG`: + +```text +[BART] + +bart_host= bartuser@192.168.2.22 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log + +[ACCTG] + +host = 127.0.0.1 +port = 5444 +user = repuser +cluster_owner = enterprisedb +description = "Accounting" +``` + +The `INIT` subcommand is invoked by BART user account `bartuser` as follows: + +```text +[bartuser@localhost ~]$ bart INIT -s acctg -o +INFO: setting archive_command for server 'acctg' +WARNING: archive_command is set. server restart is required +``` + +If the BART backup catalog directory is not already complete, it will be completed. + +The resulting archive command string in the `postgresql.auto.conf` file located in the managed database server’s `POSTGRES_INSTALL_HOME/data directory` appears as follows: + +```text +# Do not edit this file manually! +# It will be overwritten by ALTER SYSTEM command. +archive_command = 'scp %p +bartuser@192.168.2.22:/opt/backup/acctg/archived_wals/%f' +``` + +Run the `INIT` subcommand with the `-o` option to override any existing `archive_command` setting in the `postgresql.conf` or the `postgresql.auto.conf` file. In addition, the `-o` option must be used to generate the command string if the `archive_mode` is set to off even if there are no existing settings of the `archive_command` in the `postgresql.conf` or `postgresql.auto.conf` files. + +In this example, the following BART configuration file is used with an explicit setting of the BART `archive_command` parameter: + +```text +[BART] + +bart_host= enterprisedb@192.168.2.22 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log + +[ACCTG] + +host = 127.0.0.1 +port = 5444 +user = repuser +cluster_owner = enterprisedb +archive_command = 'cp %p %a/%f' +description = "Accounting" +``` + +The `INIT` subcommand is invoked by BART user account `enterprisedb` as follows: + +```text +-bash-4.1$ bart INIT -s acctg -o +INFO: setting archive_command for server 'acctg' +WARNING: archive_command is set. server restart is required +``` + +The resulting Postgres `archive_command` parameter in the `postgresql.auto.conf` file appears as follows: + +```text +# Do not edit this file manually! +# It will be overwritten by ALTER SYSTEM command. +archive_command = 'cp %p /opt/backup/acctg/archived_wals/%f' +``` + +When the database server has been restarted, the `ARCHIVE COMMAND` field of the `SHOW-SERVERS` subcommand displays the active Postgres archive command as shown by the following example: + +```text +-bash-4.1$ bart SHOW-SERVERS -s acctg +SERVER NAME : acctg +HOST NAME : 127.0.0.1 +USER NAME : repuser +PORT : 5444 +REMOTE HOST : +RETENTION POLICY : none +DISK UTILIZATION : 48.00 MB +NUMBER OF ARCHIVES : 0 +ARCHIVE PATH : /opt/backup/acctg/archived_wals +ARCHIVE SCOMMAND : `cp %p /opt/backup/acctg/archived_wals/%f` +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +INCREMENTAL BACKUP : DISABLED +DESCRIPTION : "Accounting" +``` + + + +**Verifying Configuration Settings** + +To verify the parameter settings of the database server specified, execute tthe `CHECK-CONFIG` subcommand with the `–s` option: + +```text +bart CHECK-CONFIG [ –s server_name ] +``` + +The `CHECK-CONFIG` subcommand confirms the following: + +- The `cluster_owner` parameter is set to the user account owning the database cluster directory. +- A passwordless SSH/SCP connection is set between the BART user and the user account specified by the `cluster_owner` parameter. +- The BART `user` parameter specifies a database superuser. +- The BART `user` has access to the backup directory catalog. +- The `pg_hba.conf` file contains a replication entry for the database superuser specified by the BART `user` parameter. +- The `archive_mode` parameter in the `postgresql.conf` file is enabled. +- The `archive_command` parameter in the `postgresql.auto.conf` or the `postgresql.conf` file is set. +- The `allow_incremental_backups` parameter in the BART configuration file is enabled for database servers for which incremental backups are to be taken. +- Archiving of WAL files to the `archive_path` is in process. +- The WAL scanner program is running. + +After configuring the BART host and the database server(s), you can start using BART. For information about using BART, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/latest/bart_user/). diff --git a/product_docs/docs/bart/2.5.9/bart_inst/04_upgrading_bart.mdx b/product_docs/docs/bart/2.5.9/bart_inst/04_upgrading_bart.mdx new file mode 100644 index 00000000000..4ea97b87ab6 --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_inst/04_upgrading_bart.mdx @@ -0,0 +1,77 @@ +--- +title: "Upgrading BART" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/installation-getting-started/installation-upgrade-guide/2.6.1/upgrading_bart.html" +--- + + + +This section outlines the process of upgrading BART from an existing version to the latest version. + +**Upgrade Restrictions** + +The following restrictions apply with regard to previous BART versions. + +- You can take incremental backups using the latest version only when the parent backup (full or incremental backup) has also been taken with the latest version. +- Using the latest version, you can restore incremental backups that are taken only with the latest version of BART. However, using the latest version you can restore full backups that were taken with older versions. + + + +## Upgrading from Older Versions of BART + +Perform the following steps to upgrade from older versions of BART to the latest version: + +**Step 1:** Assume the identity of the BART user account and invoke the following command to stop the BART WAL scanner program (`bart-scanner`): + +```text +bart-scanner STOP +``` + +**Step 2:** As the `root` user, upgrade to the latest BART version with the `yum upgrade` command. + +- To upgrade the BART RPM package directly from the *EDB Yum Repository* website, specify only the package name: + + On CentOS 7: + + ```text + yum upgrade edb-bart + ``` + + You can also use a downloaded RPM package file to upgrade. To use a downloaded BART RPM package file to upgrade, use the `yum` command, specifying the complete RPM package file name: + + ```text + yum upgrade edb-bart-x.y.z rhel7.x86_64.rpm + ``` + + Where x denotes the major version of BART, and y and z denotes the minor version. + + On a Debian or Ubuntu Host: + On a Debian or Ubuntu Host: + + ```text + apt-get upgrade edb-bart + ``` + + On a SLES Host: + + ```text + zypper update edb-bart + ``` + +**Step 3:** Repeat the process described in this section to upgrade to the latest BART version on each remote hosts where an incremental backup will be restored. + +For additional information about restoration of incremental backups on remote hosts, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/latest/bart_user/). + +**Step 4:** If the `bart --version` command returns an error stating the `PATH` is not available after switching from `root` user to another BART user account, adjust the setting of the `PATH` environment variable to include the location of the BART x.y.z executable (the `bin` subdirectory) in the `~/.bashrc` or `~/.bash_profile` files of the following user accounts: + +- The BART user account on the BART host. +- The remote user account on the remote host to which incremental backups are to be restored. For details, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/latest/bart_user/). + +The `PATH` setting should be the same as set for BART x.y.z since all versions use `/usr/edb/bart/bin`. + +!!! Note + After upgrading to the latest BART version, you must take a new full backup of your system before performing an incremental backup. + + \ No newline at end of file diff --git a/product_docs/docs/bart/2.5.9/bart_inst/05_uninstalling_bart.mdx b/product_docs/docs/bart/2.5.9/bart_inst/05_uninstalling_bart.mdx new file mode 100644 index 00000000000..8374221ef88 --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_inst/05_uninstalling_bart.mdx @@ -0,0 +1,50 @@ +--- +title: "Uninstalling BART" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/installation-getting-started/installation-upgrade-guide/2.6.1/uninstalling_bart.html" +--- + + + +This section walks you through uninstalling BART. + +## Uninstalling BART on a RHEL/CentOS Host + +To uninstall BART on a RHEL/CentOS host, assume the identity of the `root` user and invoke the following command: + +On RHEL/CentOS 7: + +```text +yum remove edb-bart +``` + +On RHEL/CentOS 8: + +```text +dnf remove edb-bart +``` + +Uninstalling BART does not delete the backup files and archived WAL files that reside in the BART backup catalog. To permanently delete the backup files and archived WAL files in the BART backup catalog (`/opt/backup`), use one of the following commands: + +- `rm –rf /opt/backup` +- BART `DELETE` subcommand + +For information about the BART `DELETE` subcommand, see the *EDB Backup and Recovery User Guide* available at the [EDB website](/bart/latest/bart_user/). + +## Uninstalling BART on an SLES 12 Host + +To uninstall BART on an SLES 12 host, assume the identity of the `root` user and invoke the following command: + +```text +zypper remove edb-bart +``` + +## Uninstalling BART on a Debian/Ubuntu Host + +To uninstall BART on a Debian or Ubuntu host, invoke the following command: + +```text +apt-get remove edb-bart +``` diff --git a/product_docs/docs/bart/2.5.9/bart_inst/images/EDB_logo.png b/product_docs/docs/bart/2.5.9/bart_inst/images/EDB_logo.png new file mode 100644 index 00000000000..39a54822d85 Binary files /dev/null and b/product_docs/docs/bart/2.5.9/bart_inst/images/EDB_logo.png differ diff --git a/product_docs/docs/bart/2.5.9/bart_inst/images/edb.png b/product_docs/docs/bart/2.5.9/bart_inst/images/edb.png new file mode 100644 index 00000000000..71e5bdde787 Binary files /dev/null and b/product_docs/docs/bart/2.5.9/bart_inst/images/edb.png differ diff --git a/product_docs/docs/bart/2.5.9/bart_inst/images/edb_logo.svg b/product_docs/docs/bart/2.5.9/bart_inst/images/edb_logo.svg new file mode 100644 index 00000000000..f24d1dfefee --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_inst/images/edb_logo.svg @@ -0,0 +1,19 @@ + + + edb-logo-disc-dark + + + + \ No newline at end of file diff --git a/product_docs/docs/bart/2.5.9/bart_inst/images/edblogo.png b/product_docs/docs/bart/2.5.9/bart_inst/images/edblogo.png new file mode 100644 index 00000000000..71e5bdde787 Binary files /dev/null and b/product_docs/docs/bart/2.5.9/bart_inst/images/edblogo.png differ diff --git a/product_docs/docs/bart/2.5.9/bart_inst/index.mdx b/product_docs/docs/bart/2.5.9/bart_inst/index.mdx new file mode 100644 index 00000000000..dd182be18aa --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_inst/index.mdx @@ -0,0 +1,45 @@ +--- +navTitle: Installation Guide +title: "EDB Postgres Backup and Recovery Installation Guide" +legacyRedirects: + - "/edb-docs/d/edb-backup-and-recovery-tool/installation-getting-started/installation-upgrade-guide/2.6.1/requirements_overview.html" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/installation-getting-started/installation-upgrade-guide/2.6.1/conclusion.html" + - "/edb-docs/d/edb-backup-and-recovery-tool/installation-getting-started/installation-upgrade-guide/2.6.1/genindex.html" + - "/edb-docs/d/edb-backup-and-recovery-tool/installation-getting-started/installation-upgrade-guide/2.6.1/index.html" +--- + +This guide provides information about how to install and configure the EDB Backup and Recovery Tool (BART) 2.5. + + + +## Requirements Overview + +### Supported Platforms and Database Versions + +- To view a complete list of platforms that EDB supports, visit the [EDB website.](https://www.enterprisedb.com/services-support/edb-supported-products-and-platforms) + +!!! Note + BART 2.5 does not support CentOS/RHEL/OEL 6.x platforms. EDB recommends migrating the EDB products running on these platforms to a supported platform. + +- BART supports the following database versions: + + - Advanced Server versions 9.6, 10, 11, and 12. + - PostgreSQL versions 9.6, 10, 11, and 12. + +### Software Requirements + +You require the following components to install BART. + +- BART Host Components - Use EDB packages to add BART host components; see [Installing BART](02_installing_bart/#installing-bart) for information about how to install these components. + +- Additional Components - In addition to the BART host components, the following components are required: + + - The [Secure Shell (SSH) server daemon and Secure Copy (SCP) client programs](03_configuring_bart/#authorizing_ssh_scp_access) must be enabled and activated on the BART host as well as on the remote database server hosts on which BART will be managing backup and recovery. + - BART uses the `pg_basebackup` utility program when taking full backups. + +### Limitation + +BART supports taking only a full backup of standby servers; it does not support taking incremental or parallel backups of standby servers. diff --git a/product_docs/docs/bart/2.5.9/bart_qs_7/images/EDB_logo.png b/product_docs/docs/bart/2.5.9/bart_qs_7/images/EDB_logo.png new file mode 100644 index 00000000000..39a54822d85 Binary files /dev/null and b/product_docs/docs/bart/2.5.9/bart_qs_7/images/EDB_logo.png differ diff --git a/product_docs/docs/bart/2.5.9/bart_qs_7/images/edb.png b/product_docs/docs/bart/2.5.9/bart_qs_7/images/edb.png new file mode 100644 index 00000000000..71e5bdde787 Binary files /dev/null and b/product_docs/docs/bart/2.5.9/bart_qs_7/images/edb.png differ diff --git a/product_docs/docs/bart/2.5.9/bart_qs_7/images/edb_logo.svg b/product_docs/docs/bart/2.5.9/bart_qs_7/images/edb_logo.svg new file mode 100644 index 00000000000..f24d1dfefee --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_qs_7/images/edb_logo.svg @@ -0,0 +1,19 @@ + + + edb-logo-disc-dark + + + + \ No newline at end of file diff --git a/product_docs/docs/bart/2.5.9/bart_qs_7/images/image2.png b/product_docs/docs/bart/2.5.9/bart_qs_7/images/image2.png new file mode 100644 index 00000000000..4eba2e7efa7 Binary files /dev/null and b/product_docs/docs/bart/2.5.9/bart_qs_7/images/image2.png differ diff --git a/product_docs/docs/bart/2.5.9/bart_qs_7/index.mdx b/product_docs/docs/bart/2.5.9/bart_qs_7/index.mdx new file mode 100644 index 00000000000..1d54bf90879 --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_qs_7/index.mdx @@ -0,0 +1,321 @@ +--- +title: "Quick Start Guide for RHEL/CentOS 7" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/quick-start/quick-start-guide-for-rhelcentos-7/2.6.1/genindex.html" + - "/edb-docs/d/edb-backup-and-recovery-tool/quick-start/quick-start-guide-for-rhelcentos-7/2.6.1/index.html" +--- + +This tutorial demonstrates using `yum` to [install](#installing) and [configure](../bart_qs_8/#configuring) Backup and Recovery Tool (BART) 2.5 on a CentOS 7 host with minimal configuration settings.  The tutorial assumes that the user has some knowledge of installation and system administration procedures, and has administrative privileges on the host. + +For detailed information about BART installation and configuration, see the *BART Installation and Upgrade Guide*, available at the [EDB website](/bart/latest/bart_inst/). + +- BART is tested with the following database versions: + + - Advanced Server - 9.6, 10, 11, and 12. + - PostgreSQL - 9.6, 10, 11, and 12. + + + +**Installing BART** + +The following steps describe installing BART on CentOS 7.x OS using `yum`. + +1. Assume superuser privileges and use `yum` to create the repository configuration file: + + ```text + yum install -y https://yum.enterprisedb.com/edbrepos/edb-repo-latest.noarch.rpm + ``` + +2. Create an EDB user account to request credentials to the EDB repository; for a user account visit the [EnterpriseDB website](https://www.enterprisedb.com/repository-access-request). + +3. Use your choice of editor to open the repository configuration file (named `edb.repo`, located in `/etc/yum.repos.d`), and set the `enabled` parameter value to `1`, and replace the `username` and `password` placeholders in the `baseurl` specification with the username and password of a registered EnterpriseDB user. + +4. Update the cache: + + ```text + yum makecache + ``` + +5. Install an Advanced Server or PostgreSQL database server. + + To install Advanced Server, execute the following command: + + ```text + yum -y install edb-as12-server + ``` + + Use sudo to assume the identity of the `enterprisedb` database superuser + + ```text + sudo su - enterprisedb + ``` + + Create an Advanced Server cluster named `acctg` on listener port `5444`: + + ```text + /usr/edb/as12/bin/initdb -D /var/lib/edb/as12/acctg + ``` + + As the `enterprisedb` user, start the cluster: + + ```text + /usr/edb/as12/bin/pg_ctl start -D /var/lib/edb/as12/acctg + ``` + + You can check the status of the cluster with the following command: + + ```text + /usr/edb/as12/bin/pg_ctl status -D /var/lib/edb/as12/acctg + ``` + + !!! Note + The BART host server is not required to have an Advanced Server or PostgreSQL installation, but must include a copy of the Postgres `libpq` library, the `pg_basebackup` utility program, and Boost Libraries 1.53 version for CentOS 7. + +6. If you do not already have the `pg_basebackup` program installed on the BART host, you can use the following command to install a limited number of files that include the `pg_basebackup` program: + + ```text + yum install edb-as-server-client + ``` + + Where <xx> is the Advanced Server version. + +7. As a root user, execute the following command to install BART: + + ```text + yum install edb-bart + ``` + +BART (the bart program and bart-scanner) is installed in the `/usr/edb/bart/bin` directory, referred to as ``. Repeat the installation process described in this section to install BART on all remote hosts where incremental backups are to be restored. + + + +**Configuring BART** + +Before configuring BART, establish the BART user account (the operating system user) that will run the BART command line program. Then, to configure the BART host and each database server that is to be managed by BART, perform the following steps: + +1. Assume superuser privileges, create the directory that will hold the BART backup catalog, and assign its ownership (with restrictive privileges) to the BART user account: + + In this example, `bartuser` is the BART user account and `/opt/backup` is the BART backup catalog. + + ```text + su root + mkdir /opt/backup + chown bartuser /opt/backup + chgrp bartuser /opt/backup + chmod 700 /opt/backup + ``` + +2. Navigate to the `/usr/edb/bart/etc` directory and copy the `bart.cfg.sample` file to create the BART configuration file (`bart.cfg`): + + ```text + cp bart.cfg.sample bart.cfg + ``` + +3. Open the BART configuration file (`bart.cfg`) using an editor of your choice and scroll through the BART configuration file to edit the file as required; sample settings are included for your reference. You must add the mandatory parameters to the `[BART]` and `[ServerName]` sections. Default values may be used for optional parameters. For detailed information about parameter settings, see the *BART Installation and Upgrade Guide*, available at the [EDB website](/bart/latest/bart_inst/). + + Parameters set in the `[BART]` section are applicable to all BART managed database servers, while parameters set in the `[ServerName]` section are applicable only to the specific server; `[ServerName]` settings override `[BART]` section settings. + + In the following example, only mandatory parameters are set: + + ```text + [BART] + bart_host= bartuser@192.168.169.199 + backup_path = /opt/backup + pg_basebackup_path = /usr/edb/as12/bin/pg_basebackup + + [EPAS12] + host = 127.0.0.1 + user = repuser + cluster_owner = enterprisedb + ``` + +The following table describes only mandatory parameters: + +| **Parameters/Placeholder** | **Section** | **Description** | +| -------------------------- | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `bart_host` | `[BART]` | Use this field to specify the BART user and the IP address of the host on which the BART utility is installed. Specify the value in the form of `@`. | +| `backup_path` | `[BART]` | Use this field to specify the path where all BART backups and archived WAL files will be stored. Ensure the BART user account holds privileges to create subdirectories and files within the location specified in the `backup_path` parameter. The default `backup_path` is BART backup catalog (`/opt/backup`). | +| `pg_basebackup_path` | `[BART]` | Use this field to specify the path to the pg_basebackup utility (`/usr/edb/as/bin/pg_basebackup`). | +| `[ServerName]` | `[ServerName]` | Specify the name of the database server to be backed up (for example, \[EPAS12]). | +| `host` | `[ServerName]` | Specify the IP address of the database server to be configured for backup. | +| `user` | `[ServerName]` | Specify the replication database user name used by BART to establish the connection to the database server for full backups. | +| `cluster_owner` | `[ServerName]` | Specify the Linux operating system user account that owns the database cluster. | + +4. As a BART user, navigate to `/usr/edb/bart/bin` and invoke the following subcommand (omitting the `-s` option) to verify the \[BART] section parameter settings: + + ```text + bart CHECK-CONFIG + ``` + +5. Authorize [SSH/SCP access](../bart_qs_8/#passwordless) between the server and the BART host without a password prompt. + +6. Create a [replication database user](../bart_qs_8/#replication) for each database server that BART manages. + +7. To enable continuous WAL archiving for any database server for which BART is to perform a backup, modify the `postgresql.conf` file, setting: + + - `wal_level` to `replica` or higher (for Postgres 9.6 or later) + - `archive_mode` to `on` + - `archive_command` (if it is not set in the `bart.cfg` file) + - `max_wal_senders` to a value high enough to leave at least one session available for the backup. + + After setting the parameters, restart the database server. + +8. To start the WAL scanner, navigate to `/usr/edb/bart/bin` as a BART user and execute the following command: + + ```text + ./bart-scanner + ``` + +9. If you are using the default `archive_command`, then navigate to `/usr/edb/bart/bin` as a BART user, run the `INIT` subcommand without the `-o` option, and restart the database server: + + ```text + bart INIT [ -s { | all } ] + ``` + + Where `` is the name of the database server to be backed up. + + If you have customized the `archive_command` setting in the `bart.cfg` file, run the `INIT` subcommand with the `-o` option to override any existing Postgresql `archive_command` setting in the `postgresql.conf` or the `postgresql.auto.conf` file, and restart the database server. + + ```text + bart INIT [ -s { | all } ] [ -o ] + ``` + +10. To verify the database server parameter settings, as a BART user navigate to `/usr/edb/bart/bin` and invoke the `CHECK-CONFIG` subcommand with the -s option: + + ```text + bart CHECK-CONFIG [ -s ] + ``` + + BART is now configured successfully. For detailed information about using BART, see the *EDB Backup and Recovery Tool User Guide*, available at the [EDB website](/bart/latest/bart_user/). + + + +**Creating a Passwordless Connection** + +The following example enables SSH/SCP access on a CentOS 7.x host; similar (platform-specific) steps will apply to other platforms/versions. You must create a passwordless connection between the BART host (SSH/SCP client) and the database server (target SSH/SCP server), as well as a passwordless connection between the database server (SSH/SCP client) and the BART host (target SSH/SCP server). + +1. Log in as the user account on the BART host that will be initiating the SSH or SCP connection and navigate to the user account’s home directory and check for an existing `.ssh` subdirectory. If the `.ssh` directory does not exist, create one with the required privileges. + +2. As a root user navigate to `/usr/edb/bart`, open the `/etc/ssh/sshd_config` file and set the `PubkeyAuthentication` parameter to `yes`. + +3. Reload the configuration file: + + ```text + service sshd reload + ``` + + If you get any SSH or SCP errors, examine the log file (`/var/log/secure`). + +4. As a BART user, use the following command to generate the public key file; you can accept the default responses: + + ```text + ssh-keygen -t rsa + ``` + + The public key file named `id_rsa.pub` is created in the `.ssh` subdirectory. + +5. Use `SCP` to make a temporary copy of the public key file on the target server: + + ```text + scp ~/.ssh/id_rsa.pub target_user@host_address:tmp.pub + ``` + +6. As a `target_user`, log into the target server using `ssh target_user@host_address` command and navigate to the user account’s home directory to check if there is an existing `.ssh` subdirectory. If it does not exist, create one with the required privileges. + +7. Append the client’s temporary public key file, `tmp.pub`, to the `authorized_keys` file: + + ```text + cat tmp.pub >> ~/.ssh/authorized_keys + ``` + + If an `authorized_keys` file does not exist, create a new file, but be careful not to completely replace any existing `authorized_keys` file. + +8. Ensure only the file owner (and not other groups or users) has access to `authorized_keys` file: + + ```text + chmod 600 ~/.ssh/authorized_keys + ``` + +9. Delete the temporary public key file: + + ```text + rm tmp.pub + ``` + + Now, when logged into the BART host as a user, there should be no prompt for a password when you are connecting to the target database server: + + ```text + ssh target_user@database_server_address + ``` + +**Creating a Passwordless Connection Between the Database Server and the BART Host** + +If backups are to be taken from a given database server host, but restored to a different database server host, the passwordless SSH/SCP connections must be configured from the BART host to the database server host from which the backup is to be taken as well as from the BART host to the database server host to which the backup is to be restored. + +An example of how to create a passwordless connection is documented in the *EDB Backup and Recovery Reference Guide*, available at the [EDB website](/bart/latest/bart_ref/). + +Even when the Advanced Server database is on the same host as BART, and the Advanced Server database cluster owner is also the BART user account, a passwordless SSH/SCP connection must be established from the same user account to itself. + +1. On the database server, navigate into the target user account’s home directory to check for an existing `.ssh` subdirectory. If it does does not exist, create one in the user account’s home directory with the required privileges. + +2. As a database server user, generate the public key file: + + ```text + ssh-keygen -t rsa + ``` + +3. Create a temporary copy of the public key file: + + ```text + scp ~/.ssh/id_rsa.pub target_user@host_address:tmp.pub + ``` + +4. As a target user, log into the BART host and navigate to the user account’s home directory to check if there is an existing `.ssh` subdirectory. If it does not exist, create one with the required privileges: + + ```text + ssh target_user@host_address + ``` + +5. Append the temporary, client’s public key file to the `authorized_keys` file: + + ```text + cat tmp.pub >> ~/.ssh/authorized_keys + ``` + +If an `authorized_keys` file does not exist, create a new file, but do not completely replace any existing `authorized_keys` file. + +6. Ensure only the file owner (and not other groups or users) has access to `authorized_keys` file: + + ```text + chmod 600 ~/.ssh/authorized_keys + ``` + +7. Delete the temporary public key file: + + ```text + rm tmp.pub + ``` + + Now, when logged into the database server as a user, there should be no prompt for a password when you are connecting to the BART host: + + ```text + ssh bart_user@bartip_address + ``` + + + +**Creating a Replication Database User** + +1. To create a replication database user (a superuser), connect to the database server with the psql client, and invoke the following PostgreSQL command: + + ```text + CREATE ROLE WITH LOGIN SUPERUSER PASSWORD ''; + ``` + +2. Specify this replication database user in the `user` parameter of the `bart.cfg` file. + +3. The [pg_hba.conf](https://www.postgresql.org/docs/current/auth-pg-hba-conf.html) file must minimally permit the replication database user to have access to the database. The IP address from which the replication database user has access to the database is the BART host location. The replication database user must also be included in the `pg_hba.conf` file as a replication database connection if `pg_basebackup` is to be used for taking any backups. + +4. To ensure there is no password prompt when connecting to the database server with the replication database user, a recommended method is to use the `.pgpass` file located in the BART user account’s home directory (if it does not exist, you need to create the `.pgpass` file with the required privileges). The `.pgpass` file must contain an entry for each BART managed database server, and its corresponding replication database user and password. diff --git a/product_docs/docs/bart/2.5.9/bart_qs_8/images/EDB_logo.png b/product_docs/docs/bart/2.5.9/bart_qs_8/images/EDB_logo.png new file mode 100644 index 00000000000..39a54822d85 Binary files /dev/null and b/product_docs/docs/bart/2.5.9/bart_qs_8/images/EDB_logo.png differ diff --git a/product_docs/docs/bart/2.5.9/bart_qs_8/images/edb.png b/product_docs/docs/bart/2.5.9/bart_qs_8/images/edb.png new file mode 100644 index 00000000000..71e5bdde787 Binary files /dev/null and b/product_docs/docs/bart/2.5.9/bart_qs_8/images/edb.png differ diff --git a/product_docs/docs/bart/2.5.9/bart_qs_8/images/edb_logo.svg b/product_docs/docs/bart/2.5.9/bart_qs_8/images/edb_logo.svg new file mode 100644 index 00000000000..f24d1dfefee --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_qs_8/images/edb_logo.svg @@ -0,0 +1,19 @@ + + + edb-logo-disc-dark + + + + \ No newline at end of file diff --git a/product_docs/docs/bart/2.5.9/bart_qs_8/images/image2.png b/product_docs/docs/bart/2.5.9/bart_qs_8/images/image2.png new file mode 100644 index 00000000000..4eba2e7efa7 Binary files /dev/null and b/product_docs/docs/bart/2.5.9/bart_qs_8/images/image2.png differ diff --git a/product_docs/docs/bart/2.5.9/bart_qs_8/index.mdx b/product_docs/docs/bart/2.5.9/bart_qs_8/index.mdx new file mode 100644 index 00000000000..7dc447abfb2 --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_qs_8/index.mdx @@ -0,0 +1,317 @@ +--- +title: "Quick Start Guide for RHEL/CentOS 8" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/quick-start/quick-start-guide-for-rhelcentos-8/2.6.1/genindex.html" + - "/edb-docs/d/edb-backup-and-recovery-tool/quick-start/quick-start-guide-for-rhelcentos-8/2.6.1/index.html" +--- + +This tutorial demonstrates using the `dnf` command to install and configure the EDB Backup and Recovery Tool (BART) 2.5 on a CentOS 8 host with minimal configuration settings.  The tutorial assumes that the user has some knowledge of installation and system administration procedures and has administrative privileges on the host. + +For detailed information about BART installation and configuration, see the *BART Installation and Upgrade Guide* available at the [EDB website](/bart/latest/bart_inst/). + +- BART is tested with the following database versions: + + - Advanced Server - 9.6, 10, 11, and 12. + - PostgreSQL - 9.6, 10, 11, and 12. + +**Installing BART** + +The following steps describe installing BART on CentOS 8.x OS. + +1. Assume superuser privileges and use `dnf` to create the repository configuration file: + + ```text + dnf install -y https://yum.enterprisedb.com/edbrepos/edb-repo-latest.noarch.rpm + ``` + +2. Create an EDB user account to request credentials to the EDB repository; for a user account visit the [EnterpriseDB website](https://www.enterprisedb.com/repository-access-request). + +3. Use your choice of editor to open the repository configuration file (named `edb.repo`, located in `/etc/yum.repos.d`), set the `enabled` parameter value to `1`, and replace the `username` and `password` placeholders in the `baseurl` specification with the username and password of a registered EnterpriseDB user. + +4. Update the cache: + + ```text + dnf makecache + ``` + +5. Install an Advanced Server or PostgreSQL database server. + + To install Advanced Server, execute the following command: + + ```text + dnf -y install edb-as12-server + ``` + + Use sudo to assume the identity of the `enterprisedb` database superuser: + + ```text + sudo su - enterprisedb + ``` + + Create an Advanced Server cluster named `acctg` on listener port `5444`: + + ```text + /usr/edb/as12/bin/initdb -D /var/lib/edb/as12/acctg + ``` + + As the `enterprisedb` user, start the cluster: + + ```text + /usr/edb/as12/bin/pg_ctl start -D /var/lib/edb/as12/acctg + ``` + + You can check the status of the cluster with the following command: + + ```text + /usr/edb/as12/bin/pg_ctl status -D /var/lib/edb/as12/acctg + ``` + + !!! Note + The BART host server is not required to have an Advanced Server or PostgreSQL installation, but must include a copy of the Postgres `libpq` library, the `pg_basebackup` utility program, and Boost Libraries 1.66 version for CentOS 8. + +6. If you do not already have the `pg_basebackup` program installed on the BART host, you can use the following command to install a limited number of files that include the `pg_basebackup` program: + + ```text + dnf install edb-asxx-server-client + ``` + +7. As a root user, use the following command to install the BART RPM package: + + ```text + dnf install edb-bart + ``` + +BART (the `bart` program and `bart-scanner`) is installed in the `/usr/edb/bart/bin` directory, referred to as ``. Repeat the installation process described in this section to install BART on all remote hosts where incremental backups are to be restored. + + + +**Configuring BART** + +Before configuring BART, establish the BART user account (the operating system user) to run the BART command line program. Then, to configure the BART host and each database server that is to be managed by BART, perform the following steps: + +1. Assume superuser privileges, create the directory that will hold the BART backup catalog, and assign its ownership (with restrictive privileges) to the BART user account: + + In this example, `bartuser` is the BART user account and `/opt/backup` is the BART backup catalog. + + ```text + su root + mkdir /opt/backup + chown bartuser /opt/backup + chgrp bartuser /opt/backup + chmod 700 /opt/backup + ``` + +2. Navigate to the `/usr/edb/bart/etc` directory and copy the `bart.cfg.sample` file to create the BART configuration file (`bart.cfg`): + + ```text + cp bart.cfg.sample bart.cfg + ``` + +3. Open the BART configuration file (`bart.cfg`) using an editor of your choice and scroll through the BART configuration file to edit the file as required; sample settings are included for your reference. You must add the mandatory parameters to the `[BART]` and `[ServerName]` sections. Default values may be used for optional parameters. For detailed information about parameter settings, see the *BART Installation and Upgrade Guide*, available at the [EDB website](/bart/latest/bart_inst/). + + Parameters set in the `[BART]` section are applicable to all BART managed database servers, while parameters set in the `[ServerName]` section are applicable only to the specific server; `[ServerName]` settings override `[BART]` section settings. + + In the following example, only mandatory parameters are set: + + ```text + [BART] + bart_host= bartuser@192.168.169.199 + backup_path = /opt/backup + pg_basebackup_path = /usr/edb/as12/bin/pg_basebackup + + [EPAS12] + host = 127.0.0.1 + user = repuser + cluster_owner = enterprisedb + ``` + +The following table describes only mandatory parameters: + +| **Parameters/Placeholder** | **Section** | **Description** | +| -------------------------- | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `bart_host` | `[BART]` | Use this field to specify the BART user and the IP address of the host on which the BART utility is installed. Specify the value in the form of `@`. | +| `backup_path` | `[BART]` | Use this field to specify the path where all BART backups and archived WAL files will be stored. Ensure the BART user account holds privileges to create subdirectories and files within the location specified in the `backup_path` parameter. The default `backup_path` is BART backup catalog (`/opt/backup`). | +| `pg_basebackup_path` | `[BART]` | Use this field to specify the path to the pg_basebackup utility (`/usr/edb/as/bin/pg_basebackup`). | +| `[ServerName]` | `[ServerName]` | Specify the name of the database server to be backed up (for example, \[EPAS12]). | +| `host` | `[ServerName]` | Specify the IP address of the database server to be configured for backup. | +| `user` | `[ServerName]` | Specify the replication database user name used by BART to establish the connection to the database server for full backups. | +| `cluster_owner` | `[ServerName]` | Specify the Linux operating system user account that owns the database cluster. | + +4. As a BART user, navigate to `/usr/edb/bart/bin` and invoke the following subcommand (omitting the `-s` option) to verify the \[BART] section parameter settings: + + ```text + bart CHECK-CONFIG + ``` + +5. Authorize [SSH/SCP access](#passwordless) between the server and the BART host without a password prompt. + +6. Create a [replication database user](#replication) for each database server that BART manages. + +7. To enable continuous WAL archiving for any database server for which BART is to perform a backup, modify the `postgresql.conf` fil and set it to: + + - `wal_level` to `replica` or higher (for Postgres 9.6 or later) + - `archive_mode` to `on` + - `archive_command` (if it is not set in the `bart.cfg` file) + - `max_wal_senders` to a value high enough to leave at least one session available for the backup. + + After setting the parameters, restart the database server. + +8. To start the WAL scanner, navigate to `/usr/edb/bart/bin` as a BART user and execute the following command: + + ```text + ./bart-scanner + ``` + +9. If you are using the default `archive_command`, then navigate to `/usr/edb/bart/bin` as a BART user, run the `INIT` subcommand without the `-o` option, and restart the database server: + + ```text + bart INIT [ -s { | all } ] + ``` + + Where `` is the name of the database server to be backed up. + + If you have customized the `archive_command` setting in the `bart.cfg` file, run the `INIT` subcommand with the `-o` option to override any existing Postgresql `archive_command` setting in the `postgresql.conf` or the `postgresql.auto.conf` file, and restart the database server. + + ```text + bart INIT [ -s { | all } ] [ -o ] + ``` + +10. To verify the database server parameter settings, as a BART user navigate to `/usr/edb/bart/bin` and invoke the `CHECK-CONFIG` subcommand with the -s option: + + ```text + bart CHECK-CONFIG [ -s ] + ``` + + BART is now configured successfully. For detailed information about using BART, see the *EDB Backup and Recovery Tool User Guide* available at the [EDB website](/bart/latest/bart_user/). + + + +**Creating a Passwordless Connection** + +The following example enables SSH/SCP access on a CentOS 8.x host; similar (platform-specific) steps will apply to other platforms/versions. You must create a passwordless connection between the BART host (SSH/SCP client) and the database server (target SSH/SCP server), as well as a passwordless connection between the database server (SSH/SCP client) and the BART host (target SSH/SCP server). + +1. Log in as the user account on the BART host that will be initiating the SSH or SCP connection and navigate to the user account’s home directory and check for an existing `.ssh` subdirectory. If the `.ssh` directory does not exist, create one with the required privileges. + +2. As a root user navigate to `/usr/edb/bart`, open the `/etc/ssh/sshd_config` file and set the `PubkeyAuthentication` parameter to `yes`. + +3. Reload the configuration file: + + ```text + service sshd reload + ``` + + If you get any SSH or SCP errors, examine the log file (`/var/log/secure`). + +4. As a BART user, use the following command to generate the public key file; you can accept the default responses: + + ```text + ssh-keygen -t rsa + ``` + + The public key file named `id_rsa.pub` is created in the `.ssh` subdirectory. + +5. Use `SCP` to make a temporary copy of the public key file on the target server: + + ```text + scp ~/.ssh/id_rsa.pub target_user@host_address:tmp.pub + ``` + +6. As a `target_user`, log into the target server using `ssh target_user@host_address` command and navigate to the user account’s home directory to check if there is an existing `.ssh` subdirectory. If it does not exist, create one with the required privileges. + +7. Append the temporary client’s public key file, `tmp.pub`, to the `authorized_keys` file: + + ```text + cat tmp.pub >> ~/.ssh/authorized_keys + ``` + + If an `authorized_keys` file does not exist, create a new file, but be careful not to completely replace any existing `authorized_keys` file. + +8. Ensure only the file owner (and not other groups or users) has access to `authorized_keys` file: + + ```text + chmod 600 ~/.ssh/authorized_keys + ``` + +9. Delete the temporary public key file: + + ```text + rm tmp.pub + ``` + + Now, when logged into the BART host as a user, there should be no prompt for a password when you are connecting to the target database server: + + ```text + ssh target_user@database_server_address + ``` + +**Creating a Passwordless Connection Between the Database Server and the BART Host** + +If backups are to be taken from a given database server host, but restored to a different database server host, the passwordless SSH/SCP connections must be configured from the BART host to the database server host from which the backup is to be taken as well as from the BART host to the database server host to which the backup is to be restored. + +An example of how to create a passwordless connection is documented in the *EDB Backup and Recovery Reference Guide*, available at the [EDB website](/bart/latest/bart_ref/). + +Even when the Advanced Server database is on the same host as BART, and the Advanced Server database cluster owner is also the BART user account, a passwordless SSH/SCP connection must be established from the same user account to itself. + +1. On the database server, navigate into the target user account’s home directory to check for an existing `.ssh` subdirectory. If it does does not exist, create one in the user account’s home directory with the required privileges. + +2. As a database server user, generate the public key file: + + ```text + ssh-keygen -t rsa + ``` + +3. Create a temporary copy of the public key file: + + ```text + scp ~/.ssh/id_rsa.pub target_user@host_address:tmp.pub + ``` + +4. As a target user, log into the BART host and navigate to the user account’s home directory to check if there is an existing `.ssh` subdirectory. If it does not exist, create one with the required privileges: + + ```text + ssh target_user@host_address + ``` + +5. Append the client’s temporary public key file to the `authorized_keys` file: + + ```text + cat tmp.pub >> ~/.ssh/authorized_keys + ``` + +If the `authorized_keys file` does not exist, create a new file, but do not completely replace any existing `authorized_keys` file. + +6. Ensure that only the file owner (and not other groups or users) has access to `authorized_keys` file: + + ```text + chmod 600 ~/.ssh/authorized_keys + ``` + +7. Delete the temporary public key file: + + ```text + rm tmp.pub + ``` + + Now, when logged into the database server as a user, there should be no prompt for a password when you are connecting to the BART host: + + ```text + ssh bart_user@bartip_address + ``` + + + +**Creating a Replication Database User** + +1. To create a replication database user (a superuser), connect to the database server with the psql client, and invoke the following PostgreSQL command: + + ```text + CREATE ROLE WITH LOGIN SUPERUSER PASSWORD ''; + ``` + +2. Specify this replication database user in the `user` parameter of the `bart.cfg` file. + +3. The [pg_hba.conf](https://www.postgresql.org/docs/current/auth-pg-hba-conf.html) file must minimally permit the replication database user to have access to the database. The IP address from which the replication database user has access to the database is the BART host location. The replication database user must also be included in the `pg_hba.conf` file as a replication database connection if `pg_basebackup` is to be used for taking any backups. + +4. To ensure there is no password prompt when connecting to the database server with the replication database user, a recommended method is to use the `.pgpass` file located in the BART user account’s home directory (if it does not exist, you need to create the `.pgpass` file with the required privileges). The `.pgpass` file must contain an entry for each BART managed database server, and its corresponding replication database user and password. diff --git a/product_docs/docs/bart/2.5.9/bart_ref/01_bart_subcommands_examples/01_backup.mdx b/product_docs/docs/bart/2.5.9/bart_ref/01_bart_subcommands_examples/01_backup.mdx new file mode 100644 index 00000000000..2649c676929 --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_ref/01_bart_subcommands_examples/01_backup.mdx @@ -0,0 +1,218 @@ +--- +title: "BACKUP" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/backup.html" +--- + +Use the `BACKUP` subcommand to create a full or incremental backup. + +**Syntax for a Full Backup:** + +```text +bart BACKUP –s { | all } [ -F { p | t } ] + +[ -z ] [ –c ] + +[ --backup-name ] + +[ --thread-count ] + +[ { --with-pg_basebackup | --no-pg_basebackup } ] +``` + +**Syntax for an Incremental Backup:** + +```text +bart BACKUP –s [-Fp] + +[ --parent { | } ] + +[ --backup-name ] + +[ --thread-count ] + +``` + +Before performing an incremental backup, you must take a full backup. For more details about incremental backup, refer to *Block-Level Incremental Backup* in the *EDB Backup and Recovery User Guide* available at the [EDB website](/bart/latest/bart_user/). + +The following table describes the `BACKUP` options: + +| Options | Description | +| ---------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { \| all }`
`--server { \| all }` | Use this option to specify the database server to be backed up.
Specify `` to take a backup of the database server (as specified in the BART configuration file).
Specify `all` to take a backup of all servers. | +| `-F { p \| t }`
`--format { p \| t }` | Use this option to specify the backup file format.
Specify `p` option to take backup in plain text format and specify `t` option to take backup in tar format. If the `p` or `t` option is omitted, the default is tar format.
Use `p` option with the `BACKUP` subcommand when streaming is used as a backup method.
An incremental backup can only be taken in plain text format (`p`). | +| `-z`
`(--gzip)` | This option is applicable only for full backup and `tar` format. Use this option to enable gzip compression of tar files using the default compression level (typically 6). | +| `-c `
`--compress-level ` | This is applicable only for full backup and tar format. Use this option to specify the gzip compression level on the tar file output. `` is a digit from 1 through 9, with 9 being the best compression. | +| `--backup-name ` | Use this option to assign a user-defined, alphanumeric friendly name to the backup. The maximum permitted length of backup name is 49 characters.
For detailed information about this parameter, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/latest/bart_user/).
If the option `--backup-name` is not specified and the `backup_name` parameter is not set for this database server in the BART configuration file, then the backup can only be referenced in other BART subcommands by the BART assigned backup identifier. | +| `--thread-count ` | Use this option to specify the number of worker threads to run in parallel to copy blocks for a backup.
For detailed information about the `--thread-count` parameter, see the EDB Backup and Recovery Installation and Upgrade Guide available at the [EDB website](/bart/latest/bart_inst/). | +| `--with-pg_basebackup` | This is applicable only for full backup. Use this option to specify the use of `pg_basebackup` to take a full backup. The number of thread counts in effect is ignored as given by the `thread_count` parameter in the BART configuration file.
When taking a full backup, if the thread count in effect is greater than `1`, then the `pg_basebackup` utility is not used to take the full backup (parallel worker threads are used) unless the `--with-pg_basebackup` option is specified with the `BACKUP` subcommand. | +| `--no-pg_basebackup` | This is applicable only for full backup. Use this option to specify that `pg_basebackup` is not to be used to take a full backup.
When taking a full backup, if the thread count in effect is only `1`, then the `pg_basebackup` utility is used to take the full backup unless the `--no-pg_basebackup` option is specified with the `BACKUP` subcommand. | +| `--parent { \| }` | Use this option to take an incremental backup. The parent backup is a backup taken prior to the incremental backup; it can be either a full backup or an incremental backup. `` is the backup identifier of a parent backup and `` is the user-defined alphanumeric name of a parent backup. | +| `--check` | This is applicable only for incremental backup. Use this option to verify if the required MBM files are present in the BART backup catalog before taking an incremental backup. However, an actual incremental backup is not taken when the `--check` option is specified.
The `--parent` option must be used along with the `--check` option. | + +**Examples** + +The following code sample demonstrates using variables with the `BACKUP` subcommand: + +```text +./bart backup -s ppas12 -Ft --backup-name "YEAR = %year MONTH = +%month DAY = %day" +``` + +```text +./bart backup -s ppas12 -Ft --backup-name "YEAR = %year MONTH = +%month DAY = %day %%" +``` + +```text +./bart show-backups -s ppas12 -i "test backup" +``` + +The following code sample displays the result of creating a full backup in the default tar format with gzip compression when the `BACKUP` subcommand was invoked. Note that checksums are generated for the full backup and user-defined tablespaces for the tar format backup: + +```text +[edb@localhost bin]$ ./bart BACKUP -s hr -z +INFO: DebugTarget - getVar(checkDiskSpace.bytesAvailable) +INFO: new backup identifier generated 1567591909098 +INFO: creating 5 harvester threads +NOTICE: all required WAL segments have been archived +INFO: backup completed successfully +INFO: +BART VERSION: 2.5 +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1567591909098 +BACKUP NAME: none +BACKUP PARENT: none +BACKUP LOCATION: /home/edb/bkup_new/hr/1567591909098 +BACKUP SIZE: 13.91 MB +BACKUP FORMAT: tar.gz +BACKUP TIMEZONE: America/New_York +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 0 +TABLESPACE(s): 3 +Oid Name Location +16387 test1 /home/edb/tbl1 +16388 test2 /home/edb/tbl2 +16389 test3 /home/edb/tbl3 + +START WAL LOCATION: 000000010000000000000025 +STOP WAL LOCATION: 000000010000000000000026 +BACKUP METHOD: streamed +BACKUP FROM: master +START TIME: 2019-09-04 06:11:49 EDT +STOP TIME: 2019-09-04 06:11:53 EDT +TOTAL DURATION: 4 sec(s) +``` + +The following code sample displays information about the directory containing the full backup: + +```text +[edb@localhost bin]$number_of_threads> +[edb@localhost bin]$ ls -l /home/edb/bkup_new/hr/ +total 8 +drwxrwxr-x. 3 edb edb 34 Aug 27 05:57 1566899819709 +drwxrwxr-x. 3 edb edb 58 Aug 27 05:57 1566899827751 +drwxrwxr-x. 3 edb edb 4096 Sep 4 06:11 1567591909098 +drwxrwxr-x. 2 edb edb 4096 Sep 4 06:11 archived_wals +[edb@localhost bin]$ +``` + +The following code sample displays information about the creation of a full backup while streaming the transaction log. Note that the `-Fp` option must be specified with the `BACKUP` subcommand when streaming is used as a backup method. + +```text +[edb@localhost bin]$ ./bart BACKUP -s ACCTG -Fp +INFO: DebugTarget - getVar(checkDiskSpace.bytesAvailable) +INFO: new backup identifier generated 1566898964200 +INFO: creating 5 harvester threads +NOTICE: pg_stop_backup complete, all required WAL segments have been archived +INFO: backup completed successfully +INFO: +BART VERSION: 2.5 +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1566898964200 +BACKUP NAME: none +BACKUP PARENT: none +BACKUP LOCATION: /home/edb/bkup_new/acctg/1566898964200 +BACKUP SIZE: 46.03 MB +BACKUP FORMAT: plain +BACKUP TIMEZONE: US/Eastern +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 0 +TABLESPACE(s): 0 +START WAL LOCATION: 000000010000000000000017 +BACKUP METHOD: streamed +BACKUP FROM: master +START TIME: 2019-08-27 05:42:44 EDT +STOP TIME: 2019-08-27 05:42:46 EDT +TOTAL DURATION: 2 sec(s) +``` + +The following code sample displays the assignment of a user-defined backup name with the `--backup-name` option: + +```text +[edb@localhost bin]$ ./bart BACKUP -s acctg --backup-name acctg_%year-%month-%day +INFO: DebugTarget - getVar(checkDiskSpace.bytesAvailable) +INFO: new backup identifier generated 1566899004804 +INFO: creating 5 harvester threads +NOTICE: pg_stop_backup complete, all required WAL segments have been archived +INFO: backup completed successfully +INFO: +BART VERSION: 2.5 +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1566899004804 +BACKUP NAME: acctg_2019-08-27 +BACKUP PARENT: none +BACKUP LOCATION: /home/edb/bkup_new/acctg/1566899004804 +BACKUP SIZE: 46.86 MB +BACKUP FORMAT: tar +BACKUP TIMEZONE: US/Eastern +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 0 +TABLESPACE(s): 0 +START WAL LOCATION: 00000001000000000000001A +BACKUP METHOD: streamed +BACKUP FROM: master +START TIME: 2019-08-27 05:43:24 EDT +STOP TIME: 2019-08-27 05:43:24 EDT +TOTAL DURATION: 0 sec(s) +``` + +The following code sample displays an incremental backup taken by specifying the `--parent` option. The option `-Fp` must be specified while taking an incremental backup as incremental backup can be taken only in plain text format. + +```text +[edb@localhost bin]$ ./bart BACKUP -s hr -Fp --parent hr_full_1 --backup-name +hr_incr_1 +INFO: DebugTarget - getVar(checkDiskSpace.bytesAvailable) +INFO: checking /home/edb/bkup_new/hr/archived_wals for MBM files from 0/20000028 to +0/22000000 +INFO: new backup identifier generated 1566899827751 +INFO: creating 5 harvester threads +NOTICE: all required WAL segments have been archived +INFO: backup completed successfully +INFO: +BART VERSION: 2.5 +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1566899827751 +BACKUP NAME: hr_incr_1 +BACKUP PARENT: 1566899819709 +BACKUP LOCATION: /home/edb/bkup_new/hr/1566899827751 +BACKUP SIZE: 7.19 MB +BACKUP FORMAT: plain +BACKUP TIMEZONE: America/New_York +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 0 +TABLESPACE(s): 0 +START WAL LOCATION: 000000010000000000000022 +STOP WAL LOCATION: 000000010000000000000023 +BACKUP METHOD: streamed +BACKUP FROM: master +START TIME: 2019-08-27 05:57:07 EDT +STOP TIME: 2019-08-27 05:57:08 EDT +TOTAL DURATION: 1 sec(s) +``` \ No newline at end of file diff --git a/product_docs/docs/bart/2.5.9/bart_ref/01_bart_subcommands_examples/02_check_config.mdx b/product_docs/docs/bart/2.5.9/bart_ref/01_bart_subcommands_examples/02_check_config.mdx new file mode 100644 index 00000000000..69c51d5249e --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_ref/01_bart_subcommands_examples/02_check_config.mdx @@ -0,0 +1,65 @@ +--- +title: "CHECK-CONFIG" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/check_config.html" +--- + +The `CHECK-CONFIG` subcommand checks the global parameter settings as well as the database server configuration in the BART configuration file. + +The following syntax is used to check the BART configuration file global section settings. + +```text +bart CHECK-CONFIG +``` + +The following syntax is used to check the database server configuration settings. + +```text +bart CHECK-CONFIG [ –s ] +``` + +The following table describes the `CHECK-CONFIG` option: + +| Option | Description | +| ------------------------------------------- | ------------------------------------------------------------------------------------------------------------ | +| `-s ` `--server ` | `` is the name of the database server whose configuration parameter settings are to be checked. | + +**Example** + +The following code sample demonstrates successfully checking the BART configuration file global parameters with the `bart CHECK-CONFIG` command: + +```text +bash-4.1$ bart CHECK-CONFIG +INFO: Verifying that pg_basebackup is executable +INFO: success - +INFO: success - pg_basebackup(/usr/edb/as11/bin/pg_basebackup) returns +version 11.400000 +``` + +The following code sample demonstrates successfully checking the BART configuration file database server parameters with the `bart CHECK-CONFIG` command with the `–s` option: + +```text +[edb@localhost bin]$ ./bart check-config -s hr +INFO: Checking server hr +INFO: Verifying cluster_owner and ssh/scp connectivity +INFO: success +INFO: Verifying user, host, and replication connectivity +INFO: success +INFO: Verifying that user is a database superuser +INFO: success +INFO: Verifying that cluster_owner can read cluster data files +INFO: success +INFO: Verifying that you have permission to write to vault +INFO: success +INFO: /home/edb/bkup_new/hr +INFO: Verifying database server configuration +INFO: success +INFO: Verifying that WAL archiving is working +INFO: waiting 30 seconds for +/home/edb/bkup_new/hr/archived_wals/00000001000000000000001E +INFO: success +INFO: Verifying that bart-scanner is configured and running +INFO: success +``` diff --git a/product_docs/docs/bart/2.5.9/bart_ref/01_bart_subcommands_examples/03_delete.mdx b/product_docs/docs/bart/2.5.9/bart_ref/01_bart_subcommands_examples/03_delete.mdx new file mode 100644 index 00000000000..a148c571880 --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_ref/01_bart_subcommands_examples/03_delete.mdx @@ -0,0 +1,141 @@ +--- +title: "DELETE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/delete.html" +--- + +The `DELETE` subcommand removes the subdirectory and data files from the BART backup catalog for the specified backups along with archived WAL files. + +**Syntax:** + +```text +bart DELETE –s +-i { all | [']{ | },... }['] } +[ -n ] +``` + +Note that when invoking the `DELETE` subcommand, you must specify a database server. + +For database servers under a retention policy, there are conditions where certain backups may not be deleted. For more information, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/latest/bart_user/). + +The following table describes the `DELETE` options: + +| Options | Description | +| -------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s `
`--server ` | `` is the name of the database server whose backups are to be deleted. | +| ``-i { all \| [']{ \| }',... }[`] }``

``--backupid { all \| [']{ \| }',... }[`] }`` | `` is the backup identifier of the backup to be deleted. `` is the user-defined alphanumeric name for the backup.
Multiple backup identifiers and backup names may be specified in a comma-separated list. The list must be enclosed within single quotes if there is any white space appearing before or after each comma (see [Example](#deleting_multiple_backups_with_space_characters)).
If `all` is specified, all backups and their archived WAL files for the specified database server are deleted. | +| `-n`
`--dry-run` | Performs the test run and displays the results prior to physically removing files; no files are actually deleted. | + +**Example** + +The following code sample demonstrates deleting a backup from the specified database server: + +```text +[edb@localhost bin]$ ./bart DELETE -s acctg -i acctg_2019-08-27 +INFO: deleting backup 'acctg_2019-08-27' of server 'acctg' +INFO: deleting backup '1566900093665' +INFO: WALs of deleted backup(s) will belong to prior backup(if any), or will +be marked unused +WARNING: not marking any WALs as unused WALs, the WAL file +'/home/edb/bkup_new/acctg/archived_wals/000000010000000000000025' +is required, yet not available in archived_wals directory +INFO: backup(s) deleted +[edb@localhost bin]$ +``` + +After the deletion, the BART backup catalog for the database server no longer contains the corresponding directory for the deleted `backup ID`. The following code sample displays information about `archived_wals` subdirectory that no longer contains the backup WAL files: + +```text +[edb@localhost acctg]$ ls -l +total 16 +drwxrwxr-x. 3 edb edb 4096 Aug 27 06:03 1566900199604 +drwxrwxr-x. 3 edb edb 4096 Aug 27 06:03 1566900204377 +drwxrwxr-x. 3 edb edb 4096 Aug 27 06:03 1566900209087 +drwxrwxr-x. 3 edb edb 4096 Aug 27 06:05 1566900321228 +drwxrwxr-x. 2 edb edb 6 Aug 27 06:01 archived_wals +``` + +The following code sample demonstrates deleting multiple backups from the database server. + +```text +[edb@localhost bin]$ ./bart DELETE -s acctg -i `1566988095633,1566988100760, +acctg_2019-08-28` +INFO: deleting backup `1566988095633` of server `acctg` +INFO: deleting backup `1566988095633` +INFO: WALs of deleted backup(s) will belong to prior backup(if any), or will +be marked unused +WARNING: not marking any WALs as unused WALs, the WAL file +`/home/edb/bkup_new/acctg/archived_wals/000000010000000000000037` is required, +yet not available in archived_wals directory +INFO: backup(s) deleted +INFO: deleting backup `1566988100760` of server `acctg` +INFO: deleting backup `1566988100760` +INFO: WALs of deleted backup(s) will belong to prior backup(if any), or will +be marked unused +WARNING: not marking any WALs as unused WALs, the WAL file +`/home/edb/bkup_new/acctg/archived_wals/000000010000000000000039` is +required, yet not available in archived_wals directory +INFO: backup(s) deleted +INFO: deleting backup `acctg_2019-08-28` of server `acctg` +INFO: deleting backup `1566988115512` +INFO: WALs of deleted backup(s) will belong to prior backup(if any), or will +be marked unused +WARNING: not marking any WALs as unused WALs, the WAL file +`/home/edb/bkup_new/acctg/archived_wals/00000001000000000000003C` is required, +yet not available in archived_wals directory +INFO: backup(s) deleted +[edb@localhost bin]$ +[edb@localhost bin]$ +[edb@localhost bin]$ +[edb@localhost acctg]$ +[edb@localhost acctg]$ ls -l +total 8 +drwxrwxr-x. 3 edb edb 4096 Aug 28 06:28 1566988105086 +drwxrwxr-x. 3 edb edb 4096 Aug 28 06:28 1566988109477 +drwxrwxr-x. 2 edb edb 6 Aug 28 06:09 archived_wals +[edb@localhost acctg]$ +``` + + + +**Deleting Multiple Backups with Space Characters** + +The following code sample demonstrates deleting multiple backups; since there are space characters in the comma-separated list, the entire list must be enclosed within single quotes: + +```text +[edb@localhost bin]$ ./bart DELETE -s acctg -i +`1566900199604,1566900204377,1566900209087`; +INFO: deleting backup `1566900199604` of server `acctg` +INFO: deleting backup `1566900199604` +INFO: WALs of deleted backup(s) will belong to prior backup(if any), or will +be marked unused +WARNING: not marking any WALs as unused WALs, the WAL file +`/home/edb/bkup_new/acctg/archived_wals/000000010000000000000028` is required, +yet not available in archived_wals directory +INFO: backup(s) deleted +INFO: deleting backup `1566900204377` of server `acctg` +INFO: deleting backup `1566900204377` +INFO: WALs of deleted backup(s) will belong to prior backup(if any), or will +be marked unused +WARNING: not marking any WALs as unused WALs, the WAL file +`/home/edb/bkup_new/acctg/archived_wals/00000001000000000000002A` is required, +yet not available in archived_wals directory +INFO: backup(s) deleted +INFO: deleting backup `1566900209087` of server `acctg` +INFO: deleting backup `1566900209087` +INFO: WALs of deleted backup(s) will belong to prior backup(if any), or will +be marked unused +WARNING: not marking any WALs as unused WALs, the WAL file +`/home/edb/bkup_new/acctg/archived_wals/00000001000000000000002C` is required, +yet not available in archived_wals directory +INFO: backup(s) deleted +[edb@localhost bin]$ +[edb@localhost bin]$ +[edb@localhost acctg]$ ls -l +total 4 +drwxrwxr-x. 3 edb edb 4096 Aug 27 06:05 1566900321228 +drwxrwxr-x. 2 edb edb 6 Aug 27 06:01 archived_wals +[edb@localhost acctg]$ +``` diff --git a/product_docs/docs/bart/2.5.9/bart_ref/01_bart_subcommands_examples/04_init.mdx b/product_docs/docs/bart/2.5.9/bart_ref/01_bart_subcommands_examples/04_init.mdx new file mode 100644 index 00000000000..9f8b020ac03 --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_ref/01_bart_subcommands_examples/04_init.mdx @@ -0,0 +1,276 @@ +--- +title: "INIT" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/init.html" +--- + + + +The `INIT` subcommand is used to create the BART backup catalog directory, rebuild the BART `backupinfo` file, and set the `archive_command` in the server based on the `archive_command` setting in the `bart.cfg` file. + +**Syntax:** + +```text +bart INIT [ –s { | all } ] [ -o ] + +[ -r [ -i { | | all } ] ] + +[--no-configure] +``` + +The following table describes the `INIT` options: + +| Options | Description | +| ------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { \| all }`
`--server { \| all }` | `` is the name of the database server to which the `INIT` actions are to be applied. If `all` is specified or if the option is omitted, actions are applied to all servers. | +| `-o`
`--override` | Overrides the existing Postgres `archive_command` configuration parameter setting in the `postgresql.conf` file or the `postgresql.auto.conf` file using the BART `archive_command` parameter in the BART configuration file. The `INIT` generated `archive command` string is written to the `postgresql.auto.conf` file. | +| `-r`
`--rebuild` | Rebuilds the `backupinfo` file located in each backup subdirectory. If `all` is specified or if the option is omitted, the `backupinfo` files of all backups for the database servers specified by the `-s` option are recreated. This option is only intended for recovering from a situation where the backupinfo file has become corrupt.
If the backup was initially created with a user-defined backup name, and then the `INIT -r` option is invoked to rebuild that `backupinfo` file, the user-defined backup name is no longer available. Thus, future references to the backup must use the backup identifier. | +| `-i { \| \| all }`
`--backupid { \| \| all }` | `` is an integer, backup identifier and `` is the user-defined alphanumeric name for the backup. The `-i` option can only be used with the `-r` option. | +| `--no-configure` | Prevents the `archive_command` from being set in the PostgreSQL server. | + +**Examples** + +In the following code sample, you can see that `archive_mode = off` and `archive_command` is not set. After invoking the BART `INIT` subcommand, `archive_mode` is set to `on` and `archive_command` is set: + +```text +archive_mode = off # enables archiving; off, on, or always +# (change requires restart) +archive_command = '' +# command to use to archive a logfile segment +[edb@localhost bin]$ ./bart init -s ppas11 +INFO: setting archive_mode/archive_command for server 'ppas11' +WARNING: archive_mode/archive_command is set. Restart the PostgreSQL +server using 'pg_ctl restart' +[edb@localhost bin]$ +# Do not edit this file manually! +# It will be overwritten by the ALTER SYSTEM command. +archive_mode = 'on' +archive_command = 'scp %p +edb@127.0.0.1:/home/edb/bkup/ppas11/archived_wals/%f' +``` + +In the following code sample, you can see that `archive_mode = on`, and `archive_command` is not set. After invoking the `INIT` subcommand, `archive_command` is set: + +```text +archive_mode = on # enables archiving; off, on, or always +# (change requires restart) +archive_command = '' # command to use to archive a logfile segment +[edb@localhost bin]$ ./bart init -s ppas11 +INFO: setting archive_mode/archive_command for server 'ppas11' +WARNING: archive_command is set. Reload the configuration in the +PostgreSQL server using pg_reload_conf() or 'pg_ctl reload' +[edb@localhost bin]$ +# Do not edit this file manually! +# It will be overwritten by the ALTER SYSTEM command. +archive_command = 'scp %p +edb@127.0.0.1:/home/edb/bkup/ppas11/archived_wals/%f' +``` + +In the following code sample, you can see that `archive_mode = on` and `archive_command` are already set. After invoking the `INIT` subcommand, there is no change in their settings. Note that to override the existing `archive_command`, you must include the `-o` option. + +```text +archive_mode = on # enables archiving; off, on, or always +# (change requires restart) +archive_command = 'scp %p +edb@127.0.0.1:/home/edb/bkup/ppas11/archived_wals/%f' # command to use +to archive a logfile segment +# placeholders: %p = path of file to archive +[edb@localhost bin]$ ./bart init -s ppas11 +INFO: setting archive_mode/archive_command for server 'ppas11' +WARNING: archive_command is not set for server 'ppas11' +[edb@localhost bin]$ +# Do not edit this file manually! +# It will be overwritten by the ALTER SYSTEM command. +``` + +In the following code sample, you can see that `archive_mode = off` and `archive_command` is already set. After invoking the `INIT` subcommand `archive_mode` is set to `on`: + +```text +archive_mode = off # enables archiving; off, on, or always +# (change requires restart) +archive_command = 'scp %p +edb@127.0.0.1:/home/edb/bkup/ppas11/archived_wals/%f' # command to use +to archive a log file segment +[edb@localhost bin]$ ./bart init -s ppas11 +INFO: setting archive_mode/archive_command for server 'ppas11' +WARNING: archive_mode/archive_command is set. Restart the PostgreSQL +server using 'pg_ctl restart' +# Do not edit this file manually! +# It will be overwritten by the ALTER SYSTEM command. +archive_mode = 'on' +archive_command = 'scp %p +edb@127.0.0.1:/home/edb/bkup/ppas11/archived_wals/%f' +``` + +In the following code sample an existing `archive command` setting is overridden by resetting the `archive_command` in the PostgreSQL server with the `archive_command = 'cp %p %a/%f'` parameter from the `bart.cfg` file: + +```text +[BART] + +bart_host= enterprisedb@192.168.2.22 +backup_path = /opt/backup_edb +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log + +[ACCTG] + +host = 127.0.0.1 +port = 5444 +user = repuser +cluster_owner = enterprisedb +archive_command = 'cp %p %a/%f' +description = "Accounting" +``` + +The `archive_mode` and `archive_command` parameters in the database server are set as follows: + +```text +edb=# SHOW archive_mode; +archive_mode +-------------- +on +(1 row) +edb=# SHOW archive_command; +archive_command +------------------------------------------------------------------ +scp %p bartuser@192.168.2.22:/opt/backup/acctg/archived_wals/%f + +(1 row) +``` + +Invoke the `INIT` subcommand with the `-o` option to override the current `archive_command` setting in the PostgreSQL server: + +```text +-bash-4.1$ bart INIT -s acctg -o +INFO: setting archive_mode/archive_command for server 'acctg' +WARNING: archive_command is set. Reload the configuration in the +PostgreSQL server using pg_reload_conf() or 'pg_ctl reload' +``` + +Reload the database server configuration; a restart of the database server is not necessary to reset only the `archive_command` parameter: + +```text +[root@localhost tmp]# service ppas11 reload +``` + +The `archive_command` in the PostgreSQL server is now set as follows: + +```text +edb=# SHOW archive_command; + archive_command +----------------------------------------------- +cp %p /opt/backup_edb/acctg/archived_wals/%f +(1 row) +``` + +The new command string is written to the `postgresql.auto.conf` file: + +```text +# Do not edit this file manually! +# It will be overwritten by ALTER SYSTEM command. +archive_command = 'cp %p /opt/backup_edb/acctg/archived_wals/%f' +``` + +When you invoke the BART `INIT` command with the `-r` option, BART rebuilds the `backupinfo` file using the content of the backup directory for the server specified or for all servers. The BART `backupinfo` file is initially created by the `BACKUP` subcommand and contains the backup information used by BART. + +!!! Note + If the backup was initially created with a user-defined backup name, and then the `INIT -r` option is invoked to rebuild the `backupinfo` file, the user-defined backup name is no longer available. Thus, future references to the backup must use the backup identifier. + +The following code sample shows the `backupinfo` file location in a backup subdirectory: + +```text +[root@localhost acctg]# pwd +/opt/backup/acctg +[root@localhost acctg]# ls -l +total 4 +drwx------ 2 enterprisedb enterprisedb 38 Oct 26 10:21 1477491569966 +drwxrwxr-x 2 enterprisedb enterprisedb 4096 Oct 26 10:19 archived_wals +[root@localhost acctg]# ls -l 1477491569966 +total 61144 +-rw-rw-r-- 1 enterprisedb enterprisedb 703 Oct 26 10:19 backupinfo +-rw-rw-r-- 1 enterprisedb enterprisedb 62603776 Oct 26 10:19 base.tar +``` + +The following code sample displays the `backupinfo` file content: + +```text +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1477491569966 +BACKUP NAME: none +BACKUP PARENT: none +BACKUP LOCATION: /opt/backup/acctg/1477491569966 +BACKUP SIZE: 59.70 MB +BACKUP FORMAT: tar +BACKUP TIMEZONE: +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 1 +ChkSum File +84b3eeb1e3f7b3e75c2f689570d04f10 base.tar +TABLESPACE(s): 0 +START WAL LOCATION: 2/A5000028 (file 0000000100000002000000A5) +STOP WAL LOCATION: 2/A50000C0 (file 0000000100000002000000A5) +CHECKPOINT LOCATION: 2/A5000028 +BACKUP METHOD: streamed +BACKUP FROM: master +START TIME: 2016-10-26 10:19:30 EDT +LABEL: pg_basebackup base backup +STOP TIME: 2016-10-26 10:19:30 EDT +TOTAL DURATION: 0 sec(s) +``` + +The following code sample displays an error message if the `backupinfo` file is missing when invoking a BART subcommand: + +```text +-bash-4.2$ bart SHOW-BACKUPS +ERROR: 'backupinfo' file does not exist for backup '1477491569966' +please use 'INIT -r' to generate the file +``` + +The `backupinfo` file may be missing if the `BACKUP` subcommand did not complete successfully. + +The following code sample displays information about rebuilding the `backupinfo` file of the specified backup for database server `acctg`: + +```text +-bash-4.1$ bart INIT -s acctg -r -i 1428346620427 +INFO: rebuilding BACKUPINFO for backup '1428346620427' of server 'acctg' +INFO: backup checksum: ced59b72a7846ff8fb8afb6922c70649 of base.tar +``` + +The following code sample displays information about how the `backupinfo` files of all backups are rebuilt for all database servers: + +```text +-bash-4.1$ bart INIT -r + +INFO: rebuilding BACKUPINFO for backup '1428347191544' of server 'acctg' +INFO: backup checksum: 1ac5c61f055c910db314783212f2544f of base.tar +INFO: rebuilding BACKUPINFO for backup '1428346620427' of server 'acctg' +INFO: backup checksum: ced59b72a7846ff8fb8afb6922c70649 of base.tar +INFO: rebuilding BACKUPINFO for backup '1428347198335' of server 'dev' +INFO: backup checksum: a8890dd8ab7e6be5d5bc0f38028a237b of base.tar +INFO: rebuilding BACKUPINFO for backup '1428346957515' of server 'dev' +INFO: backup checksum: ea62549cf090573625d4adeb7d919700 of base.tar +``` + +The following code sample displays information about invoking `BART INIT` with the `-r - i` option: + +```text +edb@localhost bin]$ ./bart init -s ppas11 -i 1551778898392 -r +INFO: rebuilding BACKUPINFO for backup '1551778898392' of server +'ppas11' +[edb@localhost bin]$ ls /home/edb/bkup/ppas11/1551778898392/ +backupinfo backup_label base base-1.tar base-2.tar base-3.tar +base-4.tar base-5.tar base.tar +``` + +The following code sample displays information about invoking the `BART INIT` command with the `--no-configure` option. You can use the `--no-configure` option with the `INIT` subcommand to prevent the `archive_command` option from being set in the PostgreSQL server. + +```text +[edb@localhost bin]$ ./bart init -s ppas11 -o --no-configure +[edb@localhost bin]$ +# Do not edit this file manually! +# It will be overwritten by the ALTER SYSTEM command. +``` diff --git a/product_docs/docs/bart/2.5.9/bart_ref/01_bart_subcommands_examples/05_manage.mdx b/product_docs/docs/bart/2.5.9/bart_ref/01_bart_subcommands_examples/05_manage.mdx new file mode 100644 index 00000000000..75e63130a8e --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_ref/01_bart_subcommands_examples/05_manage.mdx @@ -0,0 +1,228 @@ +--- +title: "MANAGE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/manage.html" +--- + +The `MANAGE` subcommand can be invoked to: + +- Evaluate backups, mark their status, and delete obsolete backups based on the `retention_policy` parameter in the BART configuration file. +- Compress the archived WAL files based on the `wal_compression` parameter in the BART configuration file. + +**Syntax:** + +```text +bart MANAGE [ –s { | all} ] +[ -l ] [ -d ] +[ -c { keep | nokeep } +-i { | | all } ] +[ -n ] +``` + +To view detailed information about the `MANAGE` subcommand and retention policy management, see *the EDB Backup and Recovery User Guide*. For information about setting the `wal_compression` parameter, see the *EDB Backup and Recovery Installation and Upgrade Guide*. These guides are available at the [EDB website](/bart/latest/bart_user/). + +The following table describes the `MANAGE` options: + +| Options | Description | +| ---------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `-s [ \| all ]`
`--server [ \| all ]` | `` is the name of the database server to which the `MANAGE` actions are to be applied.
If `all` is specified or if the `-s` option is omitted, actions are applied to all database servers. | +| `-l`
`--list-obsolete` | Lists the backups marked as obsolete. | +| `-d`
`--delete-obsolete` | Deletes the backups marked as obsolete. This action physically deletes the backup along with its archived WAL files and any MBM files for incremental backups. | +| `-c { keep \| nokeep }`
`--change-status { keep \| nokeep }` | Specify `keep` to change the backup status to `keep` to retain the backup indefinitely.

Specify `nokeep` to change the backup status back to `active`. You can then re-evaluate and possibly mark the backup as `obsolete` (according to the retention policy) using the `MANAGE` subcommand.

The `-c` option can only be used with the `-i` option. | +| `-i { \| \| all` }

`--backupid { \| \| all` } | `` is a backup identifier and `` is the user-defined alphanumeric name for the backup.
If `all` is specified, actions are applied to all backups.
The `-i` option can only be used with the `-c` option. | +| `-n`
`--dry-run` | Performs the test run and displays the results prior to actually implementing the actions as if the operation was performed, however, no changes are actually made.
If you specify `-n` with the `-d` option, it displays which backups would be deleted, but does not actually delete the backups.
If you specify `-n` with the `-c` option, it displays the keep or nokeep action, but does not actually change the backup status.
If you specify `-n` alone with no other options or if you specify `-n` with only the `-s` option, it displays which active backups would be marked as obsolete, but does not actually change the backup status. In addition, no compression is performed on uncompressed, archived WAL files even if WAL compression is enabled for the database server. | + +**Example** + +The following code sample performs a dry run for the specified database server displaying which active backups are evaluated as obsolete according to the retention policy, but does not actually change the backup status: + +```text +-bash-4.2$ bart MANAGE -s acctg -n +INFO: processing server 'acctg', backup '1482770807519' +INFO: processing server 'acctg', backup '1482770803000' +INFO: marking backup '1482770803000' as obsolete +INFO: 1 WAL file(s) marked obsolete +INFO: processing server 'acctg', backup '1482770735155' +INFO: marking backup '1482770735155' as obsolete +INFO: 2 incremental(s) of backup '1482770735155' will be marked obsolete +INFO: marking incremental backup '1482770780423' as obsolete +INFO: marking incremental backup '1482770763227' as obsolete +INFO: 3 WAL file(s) marked obsolete +INFO: 1 Unused WAL file(s) present +INFO: 2 Unused file(s) (WALs included) present, use 'MANAGE -l' for the +list +``` + +The following code sample marks active backups as obsolete according to the retention policy for the specified database server: + +```text +-bash-4.2$ bart MANAGE -s acctg +INFO: processing server 'acctg', backup '1482770807519' +INFO: processing server 'acctg', backup '1482770803000' +INFO: marking backup '1482770803000' as obsolete +INFO: 1 WAL file(s) marked obsolete +INFO: processing server 'acctg', backup '1482770735155' +INFO: marking backup '1482770735155' as obsolete +INFO: 2 incremental(s) of backup '1482770735155' will be marked obsolete +INFO: marking incremental backup '1482770780423' as obsolete +INFO: marking incremental backup '1482770763227' as obsolete +INFO: 3 WAL file(s) marked obsolete +INFO: 1 Unused WAL file(s) present +INFO: 2 Unused file(s) (WALs included) present, use 'MANAGE -l' for the +list +``` + +The following code sample lists backups marked as obsolete for the specified database server: + +```text +-bash-4.2$ bart MANAGE -s acctg -l +SERVER NAME: acctg +BACKUP ID: 1482770803000 +BACKUP STATUS: obsolete +BACKUP TIME: 2016-12-26 11:46:43 EST +BACKUP SIZE: 59.52 MB +WAL FILE(s): 1 +WAL FILE: 000000010000000100000055 +SERVER NAME: acctg +BACKUP ID: 1482770735155 +BACKUP STATUS: obsolete +BACKUP TIME: 2016-12-26 11:45:35 EST +BACKUP SIZE: 59.52 MB +INCREMENTAL BACKUP(s): 2 +BACKUP ID: 1482770780423 +BACKUP PARENT: 1482770735155 +BACKUP STATUS: obsolete +BACKUP TIME: 2016-12-26 11:45:35 EST +BACKUP SIZE: 59.52 MB +BACKUP ID: 1482770763227 +BACKUP PARENT: 1482770735155 +BACKUP STATUS: obsolete +BACKUP TIME: 2016-12-26 11:45:35 EST +BACKUP SIZE: 59.52 MB +WAL FILE(s): 3 +WAL FILE: 000000010000000100000054 +WAL FILE: 000000010000000100000053 +WAL FILE: 000000010000000100000052 +UNUSED FILE(s): 2 +UNUSED FILE: 000000010000000100000051 +UNUSED FILE: 0000000100000001510000280000000152000000.mbm +``` + +The following code sample deletes the obsolete backups for the specified database server: + +```text +-bash-4.2$ bart MANAGE -s acctg -d +INFO: removing all obsolete backups of server 'acctg' +INFO: removing obsolete backup '1482770803000' +INFO: 1 WAL file(s) will be removed +INFO: removing WAL file '000000010000000100000055' +INFO: removing obsolete backup '1482770735155' +INFO: 3 WAL file(s) will be removed +INFO: 2 incremental(s) of backup '1482770735155' will be removed +INFO: removing obsolete incremental backup '1482770780423' +INFO: removing obsolete incremental backup '1482770763227' +INFO: removing WAL file '000000010000000100000054' +INFO: removing WAL file '000000010000000100000053' +INFO: removing WAL file '000000010000000100000052' +INFO: 8 Unused file(s) will be removed +INFO: removing (unused) file '000000010000000100000056.00000028.backup' +INFO: removing (unused) file '000000010000000100000056' +INFO: removing (unused) file '000000010000000100000055.00000028.backup' +INFO: removing (unused) file '000000010000000100000054.00000028.backup' +INFO: removing (unused) file '000000010000000100000053.00000028.backup' +INFO: removing (unused) file '000000010000000100000052.00000028.backup' +INFO: removing (unused) file '000000010000000100000051' +INFO: removing (unused) file +'0000000100000001510000280000000152000000.mbm' +``` + +The following code sample changes the specified backup to keep status to retain it indefinitely: + +```text +-bash-4.2$ bart MANAGE -s acctg -c keep -i 1482770807519 +INFO: changing status of backup '1482770807519' of server 'acctg' from +'active' to 'keep' +INFO: 1 WAL file(s) changed +-bash-4.2$ bart SHOW-BACKUPS -s acctg -i 1482770807519 -t +SERVER NAME : acctg +BACKUP ID : 1482770807519 +BACKUP NAME : none +BACKUP PARENT : none +BACKUP STATUS : keep +BACKUP TIME : 2016-12-26 11:46:47 EST +BACKUP SIZE : 59.52 MB +WAL(S) SIZE : 16.00 MB +NO. OF WALS : 1 +FIRST WAL FILE : 000000010000000100000057 +CREATION TIME : 2016-12-26 11:52:47 EST +LAST WAL FILE : 000000010000000100000057 +CREATION TIME : 2016-12-26 11:52:47 EST +``` + +The following code sample resets the specified backup to active status: + +```text +-bash-4.2$ bart MANAGE -s acctg -c nokeep -i 1482770807519 +INFO: changing status of backup '1482770807519' of server 'acctg' from +'keep' to 'active' +INFO: 1 WAL file(s) changed +-bash-4.2$ bart SHOW-BACKUPS -s acctg -i 1482770807519 -t +SERVER NAME : acctg +BACKUP ID : 1482770807519 +BACKUP NAME : none +BACKUP PARENT : none +BACKUP STATUS : active +BACKUP TIME : 2016-12-26 11:46:47 EST +BACKUP SIZE : 59.52 MB +WAL(S) SIZE : 16.00 MB +NO. OF WALS : 1 +FIRST WAL FILE : 000000010000000100000057 +CREATION TIME : 2016-12-26 11:52:47 EST +LAST WAL FILE : 000000010000000100000057 +CREATION TIME : 2016-12-26 11:52:47 EST +``` + +The following code sample uses the enabled `wal_compression` parameter in the BART configuration file as shown by the following: + +```text +[ACCTG] + +host = 127.0.0.1 +port = 5445 +user = enterprisedb +cluster_owner = enterprisedb +allow_incremental_backups = disabled +wal_compression = enabled +description = "Accounting" +``` + +When the `MANAGE` subcommand is invoked, the following message is displayed indicating that WAL file compression is performed: + +```text +-bash-4.2$ bart MANAGE -s acctg +INFO: 4 WAL file(s) compressed +WARNING: 'retention_policy' is not set for server 'acctg' +``` + +The following code sample shows the archived WAL files in compressed format: + +```text +-bash-4.2$ pwd +/opt/backup/acctg +-bash-4.2$ ls -l archived_wals +total 160 +-rw------- 1 enterprisedb enterprisedb 27089 Dec 26 12:16 +00000001000000010000005B.gz +-rw------- 1 enterprisedb enterprisedb 305 Dec 26 12:17 +00000001000000010000005C.00000028.backup +-rw------- 1 enterprisedb enterprisedb 27112 Dec 26 12:17 +00000001000000010000005C.gz +-rw------- 1 enterprisedb enterprisedb 65995 Dec 26 12:18 +00000001000000010000005D.gz +-rw------- 1 enterprisedb enterprisedb 305 Dec 26 12:18 +00000001000000010000005E.00000028.backup +-rw------- 1 enterprisedb enterprisedb 27117 Dec 26 12:18 +00000001000000010000005E.gz +``` diff --git a/product_docs/docs/bart/2.5.9/bart_ref/01_bart_subcommands_examples/06_restore.mdx b/product_docs/docs/bart/2.5.9/bart_ref/01_bart_subcommands_examples/06_restore.mdx new file mode 100644 index 00000000000..b0399e9d3e4 --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_ref/01_bart_subcommands_examples/06_restore.mdx @@ -0,0 +1,158 @@ +--- +title: "RESTORE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/restore.html" +--- + +The `RESTORE` subcommand restores a backup and its archived WAL files for the designated database server to the specified directory location. + +**Syntax for Restore**: + +```text +bart RESTORE –s -p +[ –i { | } ] +[ -r @ ] +[ -w ] +[ -t ] +[ { -x | -g } ] +[ -c ] +``` + +To view detailed information about the `RESTORE` subcommand, see the *EDB Backup and Recovery User Guide* available at the [EDB website](/bart/latest/bart_user/). + +If the backup is restored to a different database cluster directory than where the original database cluster resided, then some operations dependent upon the database cluster location may fail. This happens if the supporting service scripts are not updated to reflect the new directory location of restored backup. + +For information about the use and modification of service scripts, see the EDB Advanced Server Installation Guide available at the [EDB website](/epas/latest/). + +The following table describes the `RESTORE` options: + +| Options | Description | +| --------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s `
`--server ` | `` is the name of the database server to be restored. | +| `-p --restore-path `
`--restore-path ` | `` is the directory path where the backup of the database server is to be restored. The directory must be empty and have the proper ownership and privileges assigned to it. | +| `-i { \| }`

`--backupid { \| }` | `backup_id` is the backup identifier of the backup to be used for the restoration and `` is the user-defined alphanumeric name for the backup.
If the option is omitted, the latest backup is restored by default. | +| `-r `

`--remote-host ` | `` is the user account on the remote database server host that accepts a passwordless SSH/SCP login connection and is the owner of the directory where the backup is to be restored.
`` is the IP address of the remote host to which the backup is to be restored. This option must be specified if the `remote_host` parameter for this database server is not set in the BART configuration file.
For information about the `remote_host` parameter, see the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/latest/bart_inst/). | +| `-w `
`--workers ` | `` is the number of worker processes to run in parallel to stream the modified blocks of an incremental backup to the restore location. If the `-w` option is omitted, the default is `1` worker process.
For example, if four worker processes are specified, four receiver processes on the restore host and four streamer processes on the BART host are used. The output of each streamer process is connected to the input of a receiver process.
When the receiver gets to the point where it needs a modified block file, it obtains those modified blocks from its input. With this method, the modified block files are never written to the restore host disk. | +| `-t `
`--target-tli ` | `` is the integer identifier of the timeline to be used for replaying the archived WAL files for point-in-time recovery. | +| `-x `
`--target-xid ` | `` is the integer identifier of the transaction ID that determines the transaction up to and including, which point-in-time recovery encompasses. | +| `-g `

`--target-timestamp ` | `` is the timestamp that determines the point in time up to and including, which point-in-time recovery encompasses. | +| `-c`

`--copy-wals` | Specify this option to copy archived WAL files from the BART backup catalog to `/archived_wals` directory.
The `restore_command` retrieves the WAL files from `/archived_wals` for the database server archive recovery.
If the `-c` option is omitted and the `copy_wals_during_restore` parameter in the BART configuration file is not enabled in a manner applicable to this database server, then the `restore_command` in the `postgresql.conf` retrieves the archived WAL files directly from the BART backup catalog.
For information about the `copy_wals_during_restore` parameter, see the EDB Backup and Recovery Installation and Upgrade Guide available at the [EDB website](/bart/latest/bart_inst/). | + +**Examples** + +The following code sample restores a database server(named `mktg`) to the `/opt/restore` directory up to timestamp `2015-12-15 10:47:00`: + +```text +-bash-4.1$ bart RESTORE -s mktg -i 1450194208824 -p /opt/restore -t 1 -g +'2015-12-15 10:47:00' +INFO: restoring backup '1450194208824' of server 'mktg' +INFO: restoring backup to enterprisedb@192.168.2.24:/opt/restore +INFO: base backup restored +INFO: WAL file(s) will be streamed from the BART host +INFO: writing recovery settings to postgresql.auto.conf file +INFO: archiving is disabled +INFO: tablespace(s) restored +``` + +The following parameters are set in the `postgresql.auto.conf` file: + +```text +restore_command = 'scp -o BatchMode=yes -o PasswordAuthentication=no +enterprisedb@192.168.2.22:/opt/backup/mktg/archived_wals/%f %p' +recovery_target_time = '2015-12-15 10:47:00' +recovery_target_timeline = 1 +``` + +The following is a list of the restored files and subdirectories: + +```text +[root@localhost restore]# pwd +/opt/restore +[root@localhost restore]# ls -l +total 108 +-rw------- 1 enterprisedb enterprisedb 208 Dec 15 10:43 backup_label +drwx------ 6 enterprisedb enterprisedb 4096 Dec 2 10:38 base +drwx------ 2 enterprisedb enterprisedb 4096 Dec 15 10:42 dbms_pipe +drwx------ 2 enterprisedb enterprisedb 4096 Dec 15 11:00 global +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_clog\ +-rw------- 1 enterprisedb enterprisedb 4438 Dec 2 10:38 pg_hba.conf +-rw------- 1 enterprisedb enterprisedb 1636 Nov 10 15:38 pg_ident.conf +drwxr-xr-x 2 enterprisedb enterprisedb 4096 Dec 15 10:42 pg_log +drwx------ 4 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_multixact +drwx------ 2 enterprisedb enterprisedb 4096 Dec 15 10:42 pg_notify +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_serial +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_snapshots +drwx------ 2 enterprisedb enterprisedb 4096 Dec 15 10:42 pg_stat +drwx------ 2 enterprisedb enterprisedb 4096 Dec 15 10:43 pg_stat_tmp +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_subtrans +drwx------ 2 enterprisedb enterprisedb 4096 Dec 15 11:00 pg_tblspc +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_twophase +-rw------- 1 enterprisedb enterprisedb 4 Nov 10 15:38 PG_VERSION +drwx------ 2 enterprisedb enterprisedb 4096 Dec 15 11:00 pg_xlog +-rw------- 1 enterprisedb enterprisedb 23906 Dec 15 11:00 +postgresql.conf +-rw-r--r-- 1 enterprisedb enterprisedb 217 Dec 15 11:00 +postgresql.auto.conf +``` + +**Example** + +The following code sample performs a `RESTORE` operation with the `copy_wals_during_restore` parameter enabled to copy the archived WAL files to the local `/archived_wals` directory: + +```text +-bash-4.1$ bart RESTORE -s hr -i hr_2017-03-29T13:50 -p +/opt/restore_pg96 -t 1 -g '2017-03-29 14:01:00' +INFO: restoring backup 'hr_2017-03-29T13:50' of server 'hr' +INFO: base backup restored +INFO: copying WAL file(s) to +postgres@192.168.2.24:/opt/restore_pg96/archived_wals +INFO: writing recovery settings to postgresql.auto.conf file +INFO: archiving is disabled +INFO: permissions set on $PGDATA +INFO: restore completed successfully +``` + +The following parameters are set in the `postgresql.auto.conf` file: + +```text +restore_command = 'cp archived_wals/%f %p' +recovery_target_time = '2017-03-29 14:01:00' +recovery_target_timeline = 1 +``` + +The following is a list of the restored files and subdirectories: + +```text +-bash-4.1$ pwd +/opt/restore_pg96 +-bash-4.1$ ls -l +total 128 +drwxr-xr-x 2 postgres postgres 4096 Mar 29 14:27 archived_wals +-rw------- 1 postgres postgres 206 Mar 29 13:50 backup_label +drwx------ 5 postgres postgres 4096 Mar 29 12:25 base +drwx------ 2 postgres postgres 4096 Mar 29 14:27 global +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_clog +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_commit_ts +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_dynshmem +-rw------- 1 postgres postgres 4212 Mar 29 13:18 pg_hba.conf +-rw------- 1 postgres postgres 1636 Mar 29 12:25 pg_ident.conf +drwxr-xr-x 2 postgres postgres 4096 Mar 29 13:45 pg_log +drwx------ 4 postgres postgres 4096 Mar 29 12:25 pg_logical +drwx------ 4 postgres postgres 4096 Mar 29 12:25 pg_multixact +drwx------ 2 postgres postgres 4096 Mar 29 13:43 pg_notify +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_replslot +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_serial +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_snapshots +drwx------ 2 postgres postgres 4096 Mar 29 13:43 pg_stat +drwx------ 2 postgres postgres 4096 Mar 29 13:50 pg_stat_tmp +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_subtrans +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_tblspc +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_twophase +-rw------- 1 postgres postgres 4 Mar 29 12:25 PG_VERSION +drwx------ 3 postgres postgres 4096 Mar 29 14:27 pg_xlog +-rw------- 1 postgres postgres 169 Mar 29 13:24 postgresql.auto.conf +-rw-r--r-- 1 postgres postgres 21458 Mar 29 14:27 postgresql.conf +-rw-r--r-- 1 postgres postgres 118 Mar 29 14:27 postgresql.auto.conf +``` \ No newline at end of file diff --git a/product_docs/docs/bart/2.5.9/bart_ref/01_bart_subcommands_examples/07_show_servers.mdx b/product_docs/docs/bart/2.5.9/bart_ref/01_bart_subcommands_examples/07_show_servers.mdx new file mode 100644 index 00000000000..8ada69b5622 --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_ref/01_bart_subcommands_examples/07_show_servers.mdx @@ -0,0 +1,77 @@ +--- +title: "SHOW-SERVERS" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/show_servers.html" +--- + +The `SHOW-SERVERS` subcommand displays information for the managed database servers listed in the BART configuration file. + +**Syntax:** + +```text +bart SHOW-SERVERS [ –s { | all } ] +``` + +The following table describes the `SHOW-SERVERS` option: + +| Option | Description | +| ---------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { \| all` }
`--server { \| all` } | `` is the name of the database server to which the `SHOW-SERVERS` actions are to be applied.
If `all` is specified or if the `-s` option is omitted, the actions are applied to all database servers. | + +**Example** + +The following code sample shows all the database servers managed by BART as returned by the `SHOW-SERVERS` subcommand: + +```text +-bash-4.2$ bart SHOW-SERVERS +SERVER NAME : acctg +BACKUP FRIENDLY NAME: acctg_%year-%month-%dayT%hour:%minute +HOST NAME : 127.0.0.1 +USER NAME : enterprisedb +PORT : 5444 +REMOTE HOST : +RETENTION POLICY : 6 Backups +DISK UTILIZATION : 0.00 bytes +NUMBER OF ARCHIVES : 0 +ARCHIVE PATH : /opt/backup/acctg/archived_wals +ARCHIVE COMMAND : (disabled) +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +INCREMENTAL BACKUP : DISABLED +DESCRIPTION : "Accounting" +SERVER NAME : hr +BACKUP FRIENDLY NAME: hr_%year-%month-%dayT%hour:%minute +HOST NAME : 192.168.2.24 +USER NAME : postgres +PORT : 5432 +REMOTE HOST : postgres@192.168.2.24 +RETENTION POLICY : 6 Backups +DISK UTILIZATION : 0.00 bytes +NUMBER OF ARCHIVES : 0 +ARCHIVE PATH : /opt/backup/hr/archived_wals +ARCHIVE COMMAND : (disabled) +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +INCREMENTAL BACKUP : DISABLED +DESCRIPTION : "Human Resources" +SERVER NAME : mktg +BACKUP FRIENDLY NAME: mktg_%year-%month-%dayT%hour:%minute +HOST NAME : 192.168.2.24 +USER NAME : repuser +PORT : 5444 +REMOTE HOST : enterprisedb@192.168.2.24 +RETENTION POLICY : 6 Backups +DISK UTILIZATION : 0.00 bytes +NUMBER OF ARCHIVES : 0 +ARCHIVE PATH : /opt/backup/mktg/archived_wals +ARCHIVE COMMAND : (disabled) +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +INCREMENTAL BACKUP : DISABLED\ +DESCRIPTION : "Marketing" +``` diff --git a/product_docs/docs/bart/2.5.9/bart_ref/01_bart_subcommands_examples/08_show_backups.mdx b/product_docs/docs/bart/2.5.9/bart_ref/01_bart_subcommands_examples/08_show_backups.mdx new file mode 100644 index 00000000000..03b7727add3 --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_ref/01_bart_subcommands_examples/08_show_backups.mdx @@ -0,0 +1,100 @@ +--- +title: "SHOW-BACKUPS" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/show_backups.html" +--- + +The `SHOW-BACKUPS` subcommand displays the backup information for the managed database servers. + +**Syntax:** + +```text +bart SHOW-BACKUPS [ –s { | all } ] +[ -i { | | all } ] +[ -t ] +``` + +The following table describes the `SHOW-BACKUPS` options: + +| Options | Description | +| ------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { \| all` }

`--server { \| all` } | `` is the name of the database server whose backup information is to be displayed.
If `all` is specified or if the option is omitted, the backup information for all database servers is displayed. | +| `-i { \| \| all }`

`--backupid { \| \| all }` | `` is a backup identifier and `` is the user-defined alphanumeric name for the backup.
If `all` is specified or if the option is omitted, all backup information for the relevant database server is displayed. | +| `-t`
`--toggle` | Displays detailed backup information in list format. If the option is omitted, the default is a tabular format. | + +**Example** + +The following code sample shows the backup from database server `dev`: + +```text +-bash-4.2$ bart SHOW-BACKUPS -s dev +SERVER NAME BACKUP ID BACKUP NAME BACKUP PARENT +BACKUP TIME BACKUP SIZE WAL(s) SIZE WAL FILES STATUS +dev 1477579596637 dev_2016-10-27T10:46:36 none +2016-10-27 10:46:37 EDT 54.50 MB 96.00 MB 6 active +``` + +The following code sample shows detailed information using the `-t` option: + +```text +-bash-4.2$ bart SHOW-BACKUPS -s dev -i 1477579596637 -t +SERVER NAME : dev +BACKUP ID : 1477579596637 +BACKUP NAME : dev_2016-10-27T10:46:36 +BACKUP PARENT : none +BACKUP STATUS : active +BACKUP TIME : 2016-10-27 10:46:37 EDT +BACKUP SIZE : 54.50 MB +WAL(S) SIZE : 80.00 MB +NO. OF WALS : 5 +FIRST WAL FILE : 0000000100000001000000EC +CREATION TIME : 2016-10-27 10:46:37 EDT +LAST WAL FILE : 0000000100000001000000F0 +CREATION TIME : 2016-10-27 11:22:01 EDT +``` + +The following code sample shows a listing of an incremental backup along with its parent backup: + +```text +-bash-4.2$ bart SHOW-BACKUPS +SERVER NAME BACKUP ID BACKUP NAME BACKUP PARENT +BACKUP TIME BACKUP SIZE WAL(s) SIZE WAL FILES STATUS +acctg 1477580293193 acctg_2016-10-27 none +2016-10-27 10:58:13 EDT 16.45 MB 16.00 MB 1 active +acctg 1477580111358 acctg_2016-10-27 none 2016-10-27 10:55:11 EDT 59.71 +MB 16.00 MB 1 active +``` + +The following code sample shows the complete, detailed information of the incremental backup and the parent backup: + +```text +-bash-4.2$ bart SHOW-BACKUPS -t +SERVER NAME : acctg +BACKUP ID : 1477580293193 +BACKUP NAME : none +BACKUP PARENT : acctg_2016-10-27 +BACKUP STATUS : active +BACKUP TIME : 2016-10-27 10:58:13 EDT +BACKUP SIZE : 16.45 MB +WAL(S) SIZE : 16.00 MB +NO. OF WALS : 1 +FIRST WAL FILE : 0000000100000002000000D9 +CREATION TIME : 2016-10-27 10:58:13 EDT +LAST WAL FILE : 0000000100000002000000D9 +CREATION TIME : 2016-10-27 10:58:13 EDT +SERVER NAME : acctg +BACKUP ID : 1477580111358 +BACKUP NAME : acctg_2016-10-27 +BACKUP PARENT : none +BACKUP STATUS : active +BACKUP TIME : 2016-10-27 10:55:11 EDT +BACKUP SIZE : 59.71 MB +WAL(S) SIZE : 16.00 MB +NO. OF WALS : 1 +FIRST WAL FILE : 0000000100000002000000D8 +CREATION TIME : 2016-10-27 10:55:12 EDT +LAST WAL FILE : 0000000100000002000000D8 +CREATION TIME : 2016-10-27 10:55:12 EDT +``` diff --git a/product_docs/docs/bart/2.5.9/bart_ref/01_bart_subcommands_examples/09_verify_chksum.mdx b/product_docs/docs/bart/2.5.9/bart_ref/01_bart_subcommands_examples/09_verify_chksum.mdx new file mode 100644 index 00000000000..973ae05dc7d --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_ref/01_bart_subcommands_examples/09_verify_chksum.mdx @@ -0,0 +1,41 @@ +--- +title: "VERIFY-CHKSUM" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/verify_chksum.html" +--- + +The `VERIFY-CHKSUM` subcommand verifies the MD5 checksums of the full backups and any user-defined tablespaces for the specified database server or for all database servers. The checksum is verified by comparing the current checksum of the backup against the checksum when the backup was taken. + +!!! Note + The `VERIFY-CHKSUM` subcommand is only used for tar format backups. + +**Syntax:** + +```text +bart VERIFY-CHKSUM +[ –s { | all } ] +[ -i { | | all } ] +``` + +The following table describes the `VERIFY-CHKSUM` options: + +| Options | Description | +| ---------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { \| all }`
`--server { \| all` } | `` is the name of the database server whose tar backup checksums are to be verified.
If `all` is specified or if the `-s` option is omitted, the checksums of all tar backups are verified for all database servers. | +| `-i { \| \| all` }

`--backupid { \| \| all` } | `` is the backup identifier of a tar format full backup whose checksum is to be verified along with any user-defined tablespaces. `` is the user-defined alphanumeric name for the full backup.
If `all` is specified or if the `-i` option is omitted, the checksums of all tar backups for the relevant database server are verified. | + +**Example** + +The following code sample verifies the checksum of all tar format backups of the specified database server: + +```text +-bash-4.1$ bart VERIFY-CHKSUM -s acctg -i all +SERVER NAME BACKUP ID VERIFY +acctg 1430239348243 OK +acctg 1430232284202 OK +acctg 1430232016284 OK +acctg 1430231949065 OK +acctg 1429821844271 OK +``` diff --git a/product_docs/docs/bart/2.5.9/bart_ref/01_bart_subcommands_examples/10_running_the_bart_wal_scanner.mdx b/product_docs/docs/bart/2.5.9/bart_ref/01_bart_subcommands_examples/10_running_the_bart_wal_scanner.mdx new file mode 100644 index 00000000000..e28e5954347 --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_ref/01_bart_subcommands_examples/10_running_the_bart_wal_scanner.mdx @@ -0,0 +1,166 @@ +--- +title: "Running the BART WAL Scanner" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/running_the_bart_wal_scanner.html" +--- + +The BART WAL scanner is used to process each WAL file to find and record modified blocks in a corresponding MBM file. As a BART account user, use the BART WAL scanner to invoke the `bart-scanner` program located in the `/bin` directory. + +For detailed information about the WAL scanner and its usage, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/latest/bart_user/). + +**Syntax:** + +```text +bart-scanner +[ -d ] +[ -c ] +{ –h | +-v | +--daemon | +-p | + | +RELOAD | +STOP +``` + +When the `bart-scanner` program is invoked, it forks a separate process for each database server enabled with the `allow_incremental_backups` parameter. + +The WAL scanner processes can run in either the foreground or background depending upon usage of the `--daemon` option: + +- If the `--daemon` option is specified, the WAL scanner process runs in the background. All output messages can be viewed in the BART log file. +- If the `--daemon` option is omitted, the WAL scanner process runs in the foreground. All output messages can be viewed from the terminal running the program as well as in the BART log file. + +The following table describes the `VERIFY-CHKSUM` options. + +| Options | Description | +| ---------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-h` `--help` | Displays general syntax and information on WAL scanner usage. | +| `-v` `--version` | Displays the WAL scanner version information. | +| `-d` `--debug` | Displays debugging output while executing the WAL scanner with any of its options. | +| `-c ` `--config-path ` | Specifies `` as the full directory path to a BART configuration file. Use this option if you do not want to use the default BART configuration file `/etc/bart.cfg` | +| `--daemon` | Runs the WAL scanner as a background process. | +| `-p ` `--print ` | Specifies the full directory path to an MBM file whose content is to be printed. The `archived_wals` directory as specified in the the `archive_path` parameter in the `bart.cfg` file contains the MBM files. | +| `` | Specifies the full directory path to a WAL file to be scanned. The archive path directory contains the WAL files. Use it if a WAL file in the archive path is missing its MBM file. This option is to be used for assisting the EnterpriseDB support team for debugging problems that may have been encountered. | +| `RELOAD` | Reloads the BART configuration file. The keyword `RELOAD` is case-insensitive. The `RELOAD` option is useful if you make changes to the configuration file after the WAL scanner has been started. It will reload the configuration file and adjust the WAL scanners accordingly. For example, if a server section allowing incremental backups is removed from the BART configuration file, then the process attached to that server will stop. Similarly, if a server allowing incremental backups is added, a new WAL scanner process will be launched to scan the WAL files of that server. | +| `STOP` | Stops the WAL scanner. The keyword `STOP` is not case-sensitive. | + +**Example** + +The following code sample demonstrates starting the WAL scanner to run interactively. The WAL scanner begins scanning existing WAL files in the archive path that have not yet been scanned (that is, there is no corresponding MBM file for the WAL file): + +```text +-bash-4.2$ bart-scanner +INFO: process created for server 'acctg', pid = 5287 +INFO: going to parse backlog of WALs, if any. +INFO: WAL file to be processed: 0000000100000000000000ED +INFO: WAL file to be processed: 0000000100000000000000EE +INFO: WAL file to be processed: 0000000100000000000000EF +INFO: WAL file to be processed: 0000000100000000000000F0 +INFO: WAL file to be processed: 0000000100000000000000F1 +``` + +The following code sample is the content of the archive path showing the MBM files created for the WAL files. (The user name and group name of the files have been removed from the example to list the WAL files and MBM files in a more readable manner): + +```text +[root@localhost archived_wals]# pwd +/opt/backup/acctg/archived_wals +[root@localhost archived_wals]# ls -l +total 81944 +-rw------- 1 ... ... 16777216 Dec 20 09:10 0000000100000000000000ED +-rw------- 1 ... ... 16777216 Dec 20 09:06 0000000100000000000000EE +-rw------- 1 ... ... 16777216 Dec 20 09:11 0000000100000000000000EF +-rw------- 1 ... ... 16777216 Dec 20 09:15 0000000100000000000000F0 +-rw------- 1 ... ... 16777216 Dec 20 09:16 0000000100000000000000F1 +-rw------- 1 ... ... 305 Dec 20 09:16 0000000100000000000000F1.00000028.backup +-rw-rw-r-- 1 ... ... 161 Dec 20 09:18 +0000000100000000ED00002800000000EE000000.mbm +-rw-rw-r-- 1 ... ... 161 Dec 20 09:18 +0000000100000000EE00002800000000EF000000.mbm +-rw-rw-r-- 1 ... ... 161 Dec 20 09:18 +0000000100000000EF00002800000000F0000000.mbm +-rw-rw-r-- 1 ... ... 161 Dec 20 09:18 +0000000100000000F000002800000000F1000000.mbm +-rw-rw-r-- 1 ... ... 161 Dec 20 09:18 +0000000100000000F100002800000000F2000000.mbm +``` + +To stop the interactively running WAL scanner, either enter `ctrl-C` at the terminal running the WAL scanner or invoke the `bart-scanner` program from another terminal with the `STOP` option: + +```text +-bash-4.2$ bart-scanner STOP +-bash-4.2$ +``` + +The terminal on which the WAL scanner was running interactively appears as follows after it has been stopped: + +```text +-bash-4.2$ bart-scanner +INFO: process created for server 'acctg', pid = 5287 +INFO: going to parse backlog of WALs, if any. +INFO: WAL file to be processed: 0000000100000000000000ED +INFO: WAL file to be processed: 0000000100000000000000EE +INFO: WAL file to be processed: 0000000100000000000000EF +INFO: WAL file to be processed: 0000000100000000000000F0 +INFO: WAL file to be processed: 0000000100000000000000F1 +INFO: bart-scanner stopped +-bash-4.2$ +``` + +The following code sample demonstrates invoking the WAL scanner to run as a background process with the `--daemon` option: + +```text +-bash-4.2$ bart-scanner --daemon +-bash-4.2$ +``` + +The WAL scanner runs as a background process. There is also a separate background process for each database server that has been enabled for WAL scanning with the `allow_incremental_backups` parameter in the BART configuration file: + +```text +-bash-4.2$ ps -ef | grep bart + enterpr+ 4340 1 0 09:48 ? 00:00:00 bart-scanner --daemon + enterpr+ 4341 4340 0 09:48 ? 00:00:00 bart-scanner --daemon + enterpr+ 4415 3673 0 09:50 pts/0 00:00:00 grep --color=auto bart +``` + +To stop the WAL scanner processes, invoke the WAL scanner with the `STOP` option: + +```text +-bash-4.2$ bart-scanner STOP +-bash-4.2$ +``` + +The following command demonstrates scanning an individual WAL file: + +```text +-bash-4.2$ bart-scanner /opt/backup/acctg/archived_wals/0000000100000000000000FF +-bash-4.2$ +``` + +To print the content of an MBM file for assisting the EnterpriseDB support team for debugging problems that may have been encountered, use the `-p` option to specify the file as shown in the following code sample: + +```text +-bash-4.2$ bart-scanner -p +/opt/backup/acctg/archived_wals/0000000100000000FF0000280000000100000000.mbm + +Header: +Version: 1.0:90500:1.2.0 +Scan Start: 2016-12-20 10:02:11 EST, Scan End: 2016-12-20 10:02:11 EST, Diff: 0 sec(s) +Start LSN: ff000028, End LSN: 100000000, TLI: 1 +flags: 0, Check Sum: f9cfe66ae2569894d6746b61503a767d + +Path: base/14845/16384 +NodeTag: BLOCK_CHANGE +Relation: relPath base/14845/16384, isTSNode 0, Blocks +*............................................................................. +First modified block: 0 +Total modified blocks: 1 + +Path: base/14845/16391 +NodeTag: BLOCK_CHANGE +Relation: relPath base/14845/16391, isTSNode 0, Blocks +*.............................................................................. +First modified block: 0 +Total modified blocks: 1 +``` diff --git a/product_docs/docs/bart/2.5.9/bart_ref/01_bart_subcommands_examples/index.mdx b/product_docs/docs/bart/2.5.9/bart_ref/01_bart_subcommands_examples/index.mdx new file mode 100644 index 00000000000..20c71192ef2 --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_ref/01_bart_subcommands_examples/index.mdx @@ -0,0 +1,115 @@ +--- +title: "BART Subcommand Syntax and Examples" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/bart_subcommands_examples.html" +--- + + + +This section briefly describes each BART subcommand and provides an example. + +**Invoking BART** + +BART subcommands are invoked at the Linux command line as a BART user. You can invoke the `bart` program (located in the `/bin` directory) with the desired options to manage your BART installation. + +The following examples demonstrate ways of invoking BART. In these examples, the BART user account is named `bartuser`. + +```text +$ su bartuser +Password: +$ export +LD_LIBRARY_PATH=/opt/PostgresPlus/9.6AS/lib/:$LD_LIBRARY_PATH +$ ./bart SHOW-SERVERS +``` + +To run BART from any current working directory: + +```text +$ su bartuser +Password: +$ export +LD_LIBRARY_PATH=/opt/PostgresPlus/9.6AS/lib/:$LD_LIBRARY_PATH +$ bart SHOW-SERVERS +``` + +**Syntax for invoking BART** + +```text +bart [ ]... [ ] []... +``` + +You can use either abbreviated or long option forms on the command line (for example `-h` or `--help`). + +**General Options** + +You can specify the following general options with `bart`. + +`-h` or (`--help`) + +- Displays general syntax and information about BART usage. +- All subcommands support a help option (`-h, --help`). If the help option is specified, information is displayed regarding that particular subcommand. The subcommand, itself, is not executed. + +The following code sample displays the result of invoking the `--help` option for the `BACKUP` subcommand: + +```text +-bash-4.2$ bart BACKUP --help +bart: backup and recovery tool + +Usage: +bart BACKUP [OPTION]... + +Options: +-h, --help Show this help message and exit +-s, --server Name of the server or 'all' (full backups only) to specify all servers +-F, --format=p|t Backup output format (tar (default) or plain) +-z, --gzip Enables gzip compression of tar files +-c, --compress-level Specifies the compression level (1 through 9, 9 being + best compression) +--backup-name Specify a friendly name for the current backup +--parent Specify parent backup for incremental backup +--check Verify checksum of required mbm files +``` + +`-v` (or `--version`) + +The following code sample displays information returned by the `bart --version` subcommand: + +```text +[edb@localhost bin]$ bart --version +bart (EnterpriseDB) 2.5.2 +[edb@localhost bin]$ +``` + +`-d` (or `--debug`) + +The following code sample displays debugging output returned by the `bart MANAGE` subcommand: + +```text +-bash-4.1$ bart -d MANAGE -n +DEBUG: Server: acctg, Now: 2015-04-17 16:34:03 EDT, RetentionWindow: +259200 (secs) ==> 72 hour(s) +DEBUG: Server: dev, Now: 2015-04-17 16:34:03 EDT, RetentionWindow: +1814400 (secs) ==> 504 hour(s) +DEBUG: Server: hr, Now: 2015-04-17 16:34:03 EDT, RetentionWindow: +7776000 (secs) ==> 2160 hour(s) +``` + +`-c` (or `--config-path) ` + +The following code sample demonstrates using the `-c` option to specify a non-default configuration file name and installation location: + +```text +$ su bartuser +Password: +$ export +LD_LIBRARY_PATH=/opt/PostgresPlus/9.6AS/lib/:$LD_LIBRARY_PATH +$ bart -c /home/bartuser/bart.cfg SHOW-SERVERS +``` + +
+ +backup check_config delete init manage restore show_servers show_backups verify_chksum running_the_bart_wal_scanner + +
diff --git a/product_docs/docs/bart/2.5.9/bart_ref/02_additional_examples.mdx b/product_docs/docs/bart/2.5.9/bart_ref/02_additional_examples.mdx new file mode 100644 index 00000000000..38a519f727d --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_ref/02_additional_examples.mdx @@ -0,0 +1,1473 @@ +--- +title: "Additional Examples" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/additional_examples.html" +--- + + + +This section lists examples of the following BART operations. + +- Restoring a database cluster with tablespaces. +- Restoring an incremental backup. +- Managing backups. +- Managing incremental backups. + +## Restoring a Database Cluster with Tablespaces + +The following code sample illustrates taking a backup and restoring a database cluster on a remote host containing tablespaces. For detailed information regarding using tablespaces, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/latest/bart_user/). + +On an Advanced Server database running on a remote host, the following tablespaces are created for use by two tables: + +```text +edb=# CREATE TABLESPACE tblspc_1 LOCATION '/mnt/tablespace_1'; +CREATE TABLESPACE +edb=# CREATE TABLESPACE tblspc_2 LOCATION '/mnt/tablespace_2'; +CREATE TABLESPACE +edb=# \db + List of tablespaces +Name | Owner | Location +------------+-----------------+------------------- +pg_default | enterprisedb | +pg_global | enterprisedb | +tblspc_1 | enterprisedb | /mnt/tablespace_1 +tblspc_2 | enterprisedb | /mnt/tablespace_2 +(4 rows) + +edb=# CREATE TABLE tbl_tblspc_1 (c1 TEXT) TABLESPACE tblspc_1; +CREATE TABLE +edb=# CREATE TABLE tbl_tblspc_2 (c1 TEXT) TABLESPACE tblspc_2; +CREATE TABLE +edb=# \d tbl_tblspc_1 +Table "enterprisedb.tbl_tblspc_1" +Column | Type | Modifiers +-------+------+----------- +c1 | text | +Tablespace: "tblspc_1" + +edb=# \d tbl_tblspc_2 +Table "enterprisedb.tbl_tblspc_2" +Column | Type | Modifiers +-------+------+----------- +c1 | text | +Tablespace: "tblspc_2" +``` + +The following code sample shows the OIDs assigned to the tablespaces and the symbolic links to the tablespace directories: + +```text +-bash-4.1$ pwd +/opt/PostgresPlus/9.6AS/data/pg_tblspc +-bash-4.1$ ls -l +total 0 +lrwxrwxrwx 1 enterprisedb enterprisedb 17 Nov 16 16:17 16587 ->/mnt/tablespace_1 +lrwxrwxrwx 1 enterprisedb enterprisedb 17 Nov 16 16:17 16588 ->/mnt/tablespace_2 +``` + +The BART configuration file contains the following settings. Note that the `tablespace_path` parameter does not have to be set at this point. + +```text +[BART] +bart_host= enterprisedb@192.168.2.22 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log + +[ACCTG] +host = 192.168.2.24 +port = 5444 +user = repuser +cluster_owner = enterprisedb +remote_host = enterprisedb@192.168.2.24 +tablespace_path = +description = "Accounting" +``` + +After the necessary configuration steps are performed to ensure BART manages the remote database server, a full backup is taken as shown in the following code sample: + +```text +-bash-4.1$ bart BACKUP -s acctg + +INFO: creating backup for server 'acctg' +INFO: backup identifier: '1447709811516' +54521/54521 kB (100%), 3/3 tablespaces + +INFO: backup completed successfully +INFO: backup checksum: 594f69fe7d26af991d4173d3823e174f of 16587.tar +INFO: backup checksum: 7a5507567729a21c98a15c948ff6c015 of base.tar +INFO: backup checksum: ae8c62604c409635c9d9e82b29cc0399 of 16588.tar +INFO: +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1447709811516 +BACKUP NAME: none +BACKUP LOCATION: /opt/backup/acctg/1447709811516 +BACKUP SIZE: 53.25 MB +BACKUP FORMAT: tar +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 3 +ChkSum File +594f69fe7d26af991d4173d3823e174f 16587.tar +7a5507567729a21c98a15c948ff6c015 base.tar +ae8c62604c409635c9d9e82b29cc0399 16588.tar + +TABLESPACE(s): 2 +Oid Name Location +16587 tblspc_1 /mnt/tablespace_1 +16588 tblspc_2 /mnt/tablespace_2 +START WAL LOCATION: 00000001000000000000000F +BACKUP METHOD: streamed +BACKUP FROM: master +START TIME: 2015-11-16 16:36:51 EST +STOP TIME: 2015-11-16 16:36:52 EST +TOTAL DURATION: 1 sec(s) +``` + +Note that in the output from the preceding example, checksums are generated for the tablespaces as well as the full backup. + +Within the backup subdirectory `1447709811516` of the BART backup catalog, the tablespace data is stored with file names `16587.tar.gz` and `16588.tar.gz` as shown below: + +```text +-bash-4.1$ pwd +/opt/backup/acctg +-bash-4.1$ ls -l +total 8 +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 16:36 1447709811516 +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 16:43 archived_wals +-bash-4.1$ ls -l 1447709811516 +total 54536 +-rw-rw-r-- 1 enterprisedb enterprisedb 19968 Nov 16 16:36 16587.tar +-rw-rw-r-- 1 enterprisedb enterprisedb 19968 Nov 16 16:36 16588.tar +-rw-rw-r-- 1 enterprisedb enterprisedb 949 Nov 16 17:05 backupinfo +-rw-rw-r-- 1 enterprisedb enterprisedb 55792640 Nov 16 16:36 base.tar +``` + +When you are ready to restore the backup, in addition to creating the directory to which the main database cluster is to be restored, you must prepare the directories to which the tablespaces are to be restored. + +On the remote host, directories `/opt/restore_tblspc_1` and `/opt/restore_tblspc_2` are created and assigned the proper ownership and permissions as shown by the following example. The main database cluster is to be restored to `/opt/restore`. + +```text +[root@localhost opt]# mkdir restore_tblspc_1 +[root@localhost opt]# chown enterprisedb restore_tblspc_1 +[root@localhost opt]# chgrp enterprisedb restore_tblspc_1 +[root@localhost opt]# chmod 700 restore_tblspc_1 + +[root@localhost opt]# mkdir restore_tblspc_2 +[root@localhost opt]# chown enterprisedb restore_tblspc_2 +[root@localhost opt]# chgrp enterprisedb restore_tblspc_2 +[root@localhost opt]# chmod 700 restore_tblspc_2 +[root@localhost opt]# ls -l +total 20 +drwxr-xr-x 3 root daemon 4096 Nov 10 15:38 PostgresPlus +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 17:40 restore +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 17:40 +restore_tblspc_1 +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 17:41 +restore_tblspc_2 +drwxr-xr-x. 2 root root 4096 Nov 22 2013 rh +``` + +Set the `tablespace_path` parameter in the BART configuration file to specify the tablespace directories. The remote host user and IP address are specified by the `remote_host` configuration parameter. + +```text +[ACCTG] + +host = 192.168.2.24 +port = 5444 +user = repuser +cluster_owner = enterprisedb +remote_host = enterprisedb@192.168.2.24 +tablespace_path = +16587=/opt/restore_tblspc_1;16588=/opt/restore_tblspc_2 + +description = "Accounting" +``` + +The following code sample demonstrates invoking the `RESTORE` subcommand: + +```text +-bash-4.1$ bart RESTORE -s acctg -i 1447709811516 -p /opt/restore +INFO: restoring backup '1447709811516' of server 'acctg' +INFO: restoring backup to enterprisedb@192.168.2.24:/opt/restore +INFO: base backup restored +INFO: archiving is disabled +INFO: tablespace(s) restored +``` + +The following code sample shows the restored full backup (including the restored tablespaces): + +```text +bash-4.1$ pwd +/opt +-bash-4.1$ ls -l restore +total 104 +-rw------- 1 enterprisedb enterprisedb 206 Nov 16 16:36 backup_label.old +drwx------ 6 enterprisedb enterprisedb 4096 Nov 10 15:38 base +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 17:46 global +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_clog +-rw------- 1 enterprisedb enterprisedb 4438 Nov 10 16:23 pg_hba.conf +-rw------- 1 enterprisedb enterprisedb 1636 Nov 10 15:38 pg_ident.conf +drwxr-xr-x 2 enterprisedb enterprisedb 4096 Nov 16 17:45 pg_log +drwx------ 4 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_multixact +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 17:45 pg_notify +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_serial +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_snapshots +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 17:47 pg_stat +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 17:47 pg_stat_tmp +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_subtrans +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 17:42 pg_tblspc +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_twophase +-rw------- 1 enterprisedb enterprisedb 4 Nov 10 15:38 PG_VERSION +drwx------ 3 enterprisedb enterprisedb 4096 Nov 16 17:47 pg_xlog +-rw------- 1 enterprisedb enterprisedb 23906 Nov 16 17:42 postgresql.conf +-rw------- 1 enterprisedb enterprisedb 61 Nov 16 17:45 postmaster.opts +-bash-4.1$ +-bash-4.1$ ls -l restore_tblspc_1 +total 4 +drwx------ 3 enterprisedb enterprisedb 4096 Nov 16 16:18 +PG_9.6_201306121 +-bash-4.1$ ls -l restore_tblspc_2 +total 4 +drwx------ 3 enterprisedb enterprisedb 4096 Nov 16 16:18 +PG_9.6_201306121 +``` + +The symbolic links in the `pg_tblspc` subdirectory point to the restored directory location: + +```text +bash-4.1$ pwd +/opt/restore/pg_tblspc +-bash-4.1$ ls -l +total 0 +lrwxrwxrwx 1 enterprisedb enterprisedb 21 Nov 16 17:42 16587 -> +/opt/restore_tblspc_1 +lrwxrwxrwx 1 enterprisedb enterprisedb 21 Nov 16 17:42 16588 -> +/opt/restore_tblspc_2 +``` + +`psql` queries also show the restored tablespaces: + +```text +edb=# \db + + List of tablespaces +Name | Owner | Location +------------+--------------+----------------------- +pg_default | enterprisedb | +pg_global | enterprisedb | +tblspc_1 | enterprisedb | /opt/restore_tblspc_1 +tblspc_2 | enterprisedb | /opt/restore_tblspc_2 +``` + +## Restoring an Incremental Backup + +Restoring an incremental backup may require additional setup steps depending upon the host on which the incremental backup is to be restored. For more information, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/latest/bart_user/). + +This section provides an example of creating backup chains and then restoring an incremental backup. + +**Creating a Backup Chain** + +A *backup chain* is the set of backups consisting of a full backup and all of its successive incremental backups. Tracing back on the parent backups of all incremental backups in the chain eventually leads back to that single, full backup. + +In the following example, the `allow_incremental_backups` parameter is set to `enabled` in the BART configuration file to permit incremental backups on the listed database server: + +```text +[BART] + +bart_host= enterprisedb@192.168.2.27 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log + +[ACCTG] + +host = 127.0.0.1 +port = 5445 +user = enterprisedb +cluster_owner = enterprisedb +allow_incremental_backups = enabled +description = "Accounting" +``` + +After the database server has been started with WAL archiving enabled to the BART backup catalog, the WAL scanner is started: + +```text +-bash-4.2$ bart-scanner --daemon +``` + +First, a full backup is taken. + +```text +-bash-4.2$ bart BACKUP -s acctg --backup-name full_1 +INFO: creating backup for server 'acctg' +INFO: backup identifier: '1490649204327'\ +63364/63364 kB (100%), 1/1 tablespace +INFO: backup completed successfully +INFO: backup checksum: aae27d4a7c09dffc82f423221154db7e of base.tar +INFO: +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1490649204327 +BACKUP NAME: full_1 +BACKUP PARENT: none +BACKUP LOCATION: /opt/backup/acctg/1490649204327 +BACKUP SIZE: 61.88 MB +BACKUP FORMAT: tar +BACKUP TIMEZONE: US/Eastern +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 1 +ChkSum File +aae27d4a7c09dffc82f423221154db7e base.tar +TABLESPACE(s): 0 +START WAL LOCATION: 00000001000000000000000E +BACKUP METHOD: streamed +BACKUP FROM: master +START TIME: 2017-03-27 17:13:24 EDT +STOP TIME: 2017-03-27 17:13:25 EDT +TOTAL DURATION: 1 sec(s) +``` + +A series of incremental backups are taken. The first incremental backup specifies the full backup as the parent. Each successive incremental backup then uses the preceding incremental backup as its parent. + +```text +-bash-4.2$ bart BACKUP -s acctg -F p --parent full_1 --backup-name +incr_1-a +INFO: creating incremental backup for server 'acctg' +INFO: checking mbm files /opt/backup/acctg/archived_wals +INFO: new backup identifier generated 1490649255649 +INFO: reading directory /opt/backup/acctg/archived_wals +INFO: all files processed +NOTICE: pg_stop_backup complete, all required WAL segments have been +archived +INFO: incremental backup completed successfully +INFO: +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1490649255649 +BACKUP NAME: incr_1-a +BACKUP PARENT: 1490649204327 +BACKUP LOCATION: /opt/backup/acctg/1490649255649 +BACKUP SIZE: 16.56 MB +BACKUP FORMAT: plain +BACKUP TIMEZONE: US/Eastern +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 0 +TABLESPACE(s): 0 +START WAL LOCATION: 000000010000000000000010 +STOP WAL LOCATION: 000000010000000000000010 +BACKUP METHOD: pg_start_backup +BACKUP FROM: master +START TIME: 2017-03-27 17:14:15 EDT +STOP TIME: 2017-03-27 17:14:16 EDT +TOTAL DURATION: 1 sec(s) +-bash-4.2$ bart BACKUP -s acctg -F p --parent incr_1-a --backup-name +incr_1-b +INFO: creating incremental backup for server 'acctg' +INFO: checking mbm files /opt/backup/acctg/archived_wals +INFO: new backup identifier generated 1490649336845 +INFO: reading directory /opt/backup/acctg/archived_wals +INFO: all files processed +NOTICE: pg_stop_backup complete, all required WAL segments have been +archived +INFO: incremental backup completed successfully +. +. +. +-bash-4.2$ bart BACKUP -s acctg -F p --parent incr_1-b --backup-name +incr_1-c +INFO: creating incremental backup for server 'acctg' +INFO: checking mbm files /opt/backup/acctg/archived_wals +INFO: new backup identifier generated 1490649414316 +INFO: reading directory /opt/backup/acctg/archived_wals +INFO: all files processed +NOTICE: pg_stop_backup complete, all required WAL segments have been +archived +INFO: incremental backup completed successfully +. +. +. +``` + +The following output of the `SHOW-BACKUPS` subcommand lists the backup chain, which are backups `full_1, incr_1-a, incr_1-b, and incr_1-c`. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID BACKUP NAME BACKUP PARENT BACKUP TIME ... +acctg 1490649414316 incr_1-c incr_1-b 2017-03-27 17:16:55 ... +acctg 1490649336845 incr_1-b incr_1-a 2017-03-27 17:15:37 ... +acctg 1490649255649 incr_1-a full_1 2017-03-27 17:14:16 ... +acctg 1490649204327 full_1 none 2017-03-27 17:13:25 ... +``` + +For the `full backup full_1`, the `BACKUP PARENT` field contains `none`. For each incremental backup, the `BACKUP PARENT` field contains the backup identifier or name of its parent backup. + +A second backup chain is created in the same manner with the `BACKUP` subcommand. The following example shows the addition of the resulting, second backup chain consisting of full backup `full_2` and incremental backups `incr_2-a` and `incr_2-b`. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID BACKUP NAME BACKUP PARENT BACKUP TIME ... +acctg 1490649605607 incr_2-b incr_2-a 2017-03-27 17:20:06 ... +acctg 1490649587702 incr_2-a full_2 2017-03-27 17:19:48 ... +acctg 1490649528633 full_2 none 2017-03-27 17:18:49 ... +acctg 1490649414316 incr_1-c incr_1-b 2017-03-27 17:16:55 ... +acctg 1490649336845 incr_1-b incr_1-a 2017-03-27 17:15:37 ... +acctg 1490649255649 incr_1-a full_1 2017-03-27 17:14:16 ... +acctg 1490649204327 full_1 none 2017-03-27 17:13:25 ... +``` + +The following additional incremental backups starting with `incr_1-b-1`, which designates `incr_1-b` as the parent, results in the forking from that backup into a second line of backups in the chain consisting of `full_1, incr_1-a, incr_1-b, incr_1-b-1, incr_1-b-2`, and `incr_1-b-3` as shown in the following list: + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID BACKUP NAME BACKUP PARENT BACKUP TIME ... +acctg 1490649791430 incr_1-b-3 incr_1-b-2 2017-03-27 17:23:12 ... +acctg 1490649763929 incr_1-b-2 incr_1-b-1 2017-03-27 17:22:44 ... +acctg 1490649731672 incr_1-b-1 incr_1-b 2017-03-27 17:22:12 ... +acctg 1490649605607 incr_2-b incr_2-a 2017-03-27 17:20:06 ... +acctg 1490649587702 incr_2-a full_2 2017-03-27 17:19:48 ... +acctg 1490649528633 full_2 none 2017-03-27 17:18:49 ... +acctg 1490649414316 incr_1-c incr_1-b 2017-03-27 17:16:55 ... +acctg 1490649336845 incr_1-b incr_1-a 2017-03-27 17:15:37 ... +acctg 1490649255649 incr_1-a full_1 2017-03-27 17:14:16 ... +acctg 1490649204327 full_1 none 2017-03-27 17:13:25 ... +``` + +**Restoring an Incremental Backup** + +Restoring an incremental backup is done with the `RESTORE` subcommand in the same manner as for restoring a full backup. Specify the backup identifier or backup name of the incremental backup to be restored as shown in the following example. + +```text +-bash-4.2$ bart RESTORE -s acctg -p /opt/restore -i incr_1-b +INFO: restoring incremental backup 'incr_1-b' of server 'acctg' +INFO: base backup restored +INFO: archiving is disabled +INFO: permissions set on $PGDATA +INFO: incremental restore completed successfully +``` + +Restoring incremental backup `incr_1-b` as shown by the preceding example results in the restoration of full backup `full_1`, then incremental backups `incr_1-a` and finally, `incr_1-b`. + +## Managing Backups + +This section illustrates evaluating, marking, and deleting backups using the `MANAGE` subcommand using a redundancy retention policy and a recovery window retention policy. For detailed information about the `MANAGE` subcommand, see the *EDB Backup and Recovery User Guide* available at the [EDB website](/bart/latest/bart_user/). + + + +### Using a Redundancy Retention Policy + +The following code sample uses a redundancy retention policy to evaluate, mark, and delete backups as shown by the following server configuration: + +```text +[ACCTG] +host = 127.0.0.1 +port = 5444 +user = enterprisedb +archive_command = 'cp %p %a/%f' +retention_policy = 3 BACKUPS +description = "Accounting" +``` + +The following list is the set of backups. Note that the last backup in the list has been marked as `keep`. + +```text +-bash-4.1$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID BACKUP TIME BACKUP SIZE WAL(s) SIZE +WAL FILES STATUS +acctg 1428768344061 2015-04-11 12:05:46 EDT 5.72 MB 48.00 MB +3 active +acctg 1428684537299 2015-04-10 12:49:00 EDT 5.72 MB 272.00 MB +17 active +acctg 1428589759899 2015-04-09 10:29:27 EDT 5.65 MB 96.00 MB +6 active +acctg 1428502049836 2015-04-08 10:07:30 EDT 55.25 MB 96.00 MB +6 active +acctg 1428422324880 2015-04-07 11:58:45 EDT 54.53 MB 32.00 MB +2 active +acctg 1428355371389 2015-04-06 17:22:53 EDT 5.71 MB 16.00 MB +1 keep +``` + +Invoke the `MANAGE` subcommand with the `-n` option to perform a dry run to observe which active backups would be changed to obsolete according to the retention policy as shown in the following code sample: + +```text +-bash-4.1$ bart MANAGE -s acctg -n +INFO: processing server 'acctg', backup '1428768344061' +INFO: processing server 'acctg', backup '1428684537299' +INFO: processing server 'acctg', backup '1428589759899' +INFO: processing server 'acctg', backup '1428502049836' +INFO: marking backup '1428502049836' as obsolete +INFO: 6 WAL file(s) marked obsolete +INFO: processing server 'acctg', backup '1428422324880' +INFO: marking backup '1428422324880' as obsolete +INFO: 2 WAL file(s) marked obsolete +INFO: processing server 'acctg', backup '1428355371389' +``` + +The dry run shows that backups `1428502049836` and `1428422324880` would be marked as `obsolete`. + +!!! Note + A dry run does not change the backup status. The two backups that would be considered obsolete are still marked as `active`: + +```text +-bash-4.1$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID BACKUP TIME BACKUP SIZE WAL(s) SIZE +WAL FILES STATUS +acctg 1428768344061 2015-04-11 12:05:46 EDT 5.72 MB 48.00 MB +3 active +acctg 1428684537299 2015-04-10 12:49:00 EDT 5.72 MB 272.00 MB +17 active +acctg 1428589759899 2015-04-09 10:29:27 EDT 5.65 MB 96.00 MB +6 active +acctg 1428502049836 2015-04-08 10:07:30 EDT 55.25 MB 96.00 MB +6 active +acctg 1428422324880 2015-04-07 11:58:45 EDT 54.53 MB 32.00 MB +2 active +acctg 1428355371389 2015-04-06 17:22:53 EDT 5.71 MB 16.00 MB +1 keep +``` + +Invoke the `MANAGE` subcommand omitting the `-n` option to change and mark the status of the backups as `obsolete`: + +```text +-bash-4.1$ bart MANAGE -s acctg +INFO: processing server 'acctg', backup '1428768344061' +INFO: processing server 'acctg', backup '1428684537299' +INFO: processing server 'acctg', backup '1428589759899' +INFO: processing server 'acctg', backup '1428502049836' +INFO: marking backup '1428502049836' as obsolete +INFO: 6 WAL file(s) marked obsolete +INFO: processing server 'acctg', backup '1428422324880' +INFO: marking backup '1428422324880' as obsolete +INFO: 2 WAL file(s) marked obsolete +INFO: processing server 'acctg', backup '1428355371389' +``` + +The obsolete backups can be observed in a number of ways. Use the `MANAGE` subcommand with the `-l` option to list the `obsolete` backups: + +```text +-bash-4.1$ bart MANAGE -s acctg -l +INFO: 6 WAL file(s) will be removed +SERVER NAME: acctg +BACKUP ID: 1428502049836 +BACKUP STATUS: obsolete +BACKUP TIME: 2015-04-08 10:07:30 EDT +BACKUP SIZE: 55.25 MB +WAL FILE(s): 6 +WAL FILE: 000000010000000100000003 +WAL FILE: 000000010000000100000002 +WAL FILE: 000000010000000100000001 +WAL FILE: 000000010000000100000000 +WAL FILE: 0000000100000000000000E3 +WAL FILE: 0000000100000000000000E2 +INFO: 2 WAL file(s) will be removed +SERVER NAME: acctg +BACKUP ID: 1428422324880 +BACKUP STATUS: obsolete +BACKUP TIME: 2015-04-07 11:58:45 EDT +BACKUP SIZE: 54.53 MB +WAL FILE(s): 2 +WAL FILE: 0000000100000000000000E1 +WAL FILE: 0000000100000000000000E0 +``` + +The `STATUS` field of the `SHOW-BACKUPS` subcommand displays the current status: + +```text +-bash-4.1$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID BACKUP TIME BACKUP SIZE WAL(s) SIZE +WAL FILES STATUS +acctg 1428768344061 2015-04-11 12:05:46 EDT 5.72 MB 48.00 MB +3 active +acctg 1428684537299 2015-04-10 12:49:00 EDT 5.72 MB 272.00 MB +17 active +acctg 1428589759899 2015-04-09 10:29:27 EDT 5.65 MB 96.00 MB +6 active +acctg 1428502049836 2015-04-08 10:07:30 EDT 55.25 MB 96.00 MB +6 obsolete +acctg 1428422324880 2015-04-07 11:58:45 EDT 54.53 MB 32.00 MB +2 obsolete +acctg 1428355371389 2015-04-06 17:22:53 EDT 5.71 MB 16.00 MB +1 keep +``` + +The details of an individual backup can be displayed using the `SHOW-BACKUPS` subcommand with the `-t` option. Note the status in the `BACKUP STATUS` field. + +```text +-bash-4.1$ bart SHOW-BACKUPS -s acctg -i 1428502049836 -t +SERVER NAME : acctg +BACKUP ID : 1428502049836 +BACKUP NAME : none +BACKUP STATUS : obsolete +BACKUP TIME : 2015-04-08 10:07:30 EDT +BACKUP SIZE : 55.25 MB +WAL(S) SIZE : 96.00 MB +NO. OF WALS : 6 +FIRST WAL FILE : 0000000100000000000000E2 +CREATION TIME : 2015-04-08 10:07:30 EDT +LAST WAL FILE : 000000010000000100000003 +CREATION TIME : 2015-04-09 10:25:46 EDT +``` + +Use the `MANAGE` subcommand with the `-d` option to physically delete the `obsolete` backups including the unneeded WAL files. + +```text +-bash-4.1$ bart MANAGE -s acctg -d +INFO: removing all obsolete backups of server 'acctg' +INFO: removing obsolete backup '1428502049836' +INFO: 6 WAL file(s) will be removed +INFO: removing WAL file '000000010000000100000003' +INFO: removing WAL file '000000010000000100000002' +INFO: removing WAL file '000000010000000100000001' +INFO: removing WAL file '000000010000000100000000' +INFO: removing WAL file '0000000100000000000000E3' +INFO: removing WAL file '0000000100000000000000E2' +INFO: removing obsolete backup '1428422324880' +INFO: 2 WAL file(s) will be removed +INFO: removing WAL file '0000000100000000000000E1' +INFO: removing WAL file '0000000100000000000000E0' +``` + +The `SHOW-BACKUPS` subcommand now displays the remaining backups marked as `active` or `keep`: + +```text +-bash-4.1$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID BACKUP TIME BACKUP SIZE WAL(s) SIZE +WAL FILES STATUS +acctg 1428768344061 2015-04-11 12:05:46 EDT 5.72 MB 48.00 MB +3 active +acctg 1428684537299 2015-04-10 12:49:00 EDT 5.72 MB 272.00 MB +17 active +acctg 1428589759899 2015-04-09 10:29:27 EDT 5.65 MB 96.00 MB +6 active +acctg 1428355371389 2015-04-06 17:22:53 EDT 5.71 MB 16.00 MB +1 keep +``` + + + +### Using a Recovery Window Retention Policy + +This section illustrates the evaluation, marking, and deletion of backup using a recovery window retention policy. To use the recovery window retention policy, set the `retention_policy` parameter to the desired length of time for the recovery window. + +This section provides examples of the following: + +- How to view the calculated recovery window. +- How to evaluate, mark, and delete backup using a recovery window retention policy. + +#### Viewing the Recovery Window + +You can view the actual, calculated recovery window by invoking any of the following subcommands: + +- `MANAGE` subcommand in debug mode (along with the `-n` option). +- `SHOW-SERVERS` subcommand. + +##### Viewing the Recovery Window Using the Manage Subcommand + +When invoking BART in debug mode with the `MANAGE` subcommand and the `-n` option, the length of the recovery window is calculated based on the `retention_policy` setting and the current date/time. + +For example, using the following `retention_policy` settings: + +```text +[ACCTG] + +host = 127.0.0.1 +port = 5444 +user = enterprisedb +archive_command = 'cp %p %a/%f' +retention_policy = 3 DAYS +backup-name = acctg_%year-%month-%dayT%hour:%minute:%second +description = "Accounting" + +[DEV] + +host = 127.0.0.1 +port = 5445 +user = enterprisedb +archive_command = 'cp %p %a/%f' +retention_policy = 3 WEEKS +description = "Development" + +[HR] + +host = 127.0.0.1 +port = 5432 +user = postgres +retention_policy = 3 MONTHS +description = "Human Resources" +``` + +If the `MANAGE` subcommand is invoked in debug mode along with the `-n` option on 2015-04-17, the following results are displayed: + +```text +-bash-4.1$ bart -d MANAGE -n +DEBUG: Server: acctg, Now: 2015-04-17 16:34:03 EDT, RetentionWindow: +259200 (secs) ==> 72 hour(s) +DEBUG: Server: dev, Now: 2015-04-17 16:34:03 EDT, RetentionWindow: +1814400 (secs) ==> 504 hour(s) +DEBUG: Server: hr, Now: 2015-04-17 16:34:03 EDT, RetentionWindow: +7776000 (secs) ==> 2160 hour(s) +``` + +For server `acctg`, 72 hours translates to a recovery window of 3 days. + +For server `dev`, 504 hours translates to a recovery window of 21 days (3 weeks). + +For server `hr`, 2160 hours translates to a recovery window of 90 days (3 months). + +For a setting of ` MONTHS`, the calculated total number of days for the recovery window is dependent upon the actual number of days in the preceding months from the current date/time. Thus, ` MONTHS` is not always exactly equivalent to ` x 30 DAYS`. For example, if the current date/time is in the month of March, a 1-month recovery window would be equivalent to only 28 days because the preceding month is February. Thus, for a current date of March 31, a 1-month recovery window would start on March 3. However, the typical result is that the day of the month of the starting recovery window boundary will be the same day of the month of when the `MANAGE` subcommand is invoked. + +##### Viewing the Recovery Window Using the Show-Servers Subcommand + +This section provides an example of viewing the recovery window using the `SHOW-SERVERS` subcommand; the `RETENTION POLICY` field displays the start of the recovery window. + +In the following code sample, the recovery window retention policy setting considers the backups taken within a 3-day recovery window as the active backups. + +```text +[ACCTG] +host = 127.0.0.1 +port = 5444 +user = enterprisedb +archive_command = 'cp %p %a/%f' +retention_policy = 3 DAYS +description = "Accounting" +``` + +The start of the 3-day recovery window displayed in the `RETENTION POLICY` field is `2015-04-07 14:57:36 EDT` when the `SHOW-SERVERS` subcommand is invoked on `2015-04-10`. + +At this current point in time, backups taken on or after `2015-04-07 14:57:36 EDT` would be considered active. Backups taken prior to `2015-04-07 14:57:36 EDT` would be considered obsolete except for backups marked as `keep`. + +```text +-bash-4.1$ date +Fri Apr 10 14:57:33 EDT 2015 +-bash-4.1$ +-bash-4.1$ bart SHOW-SERVERS -s acctg +SERVER NAME : acctg +HOST NAME : 127.0.0.1 +USER NAME : enterprisedb +PORT : 5444 +REMOTE HOST : +RETENTION POLICY : 2015-04-07 14:57:36 EDT +DISK UTILIZATION : 824.77 MB +NUMBER OF ARCHIVES : 37 +ARCHIVE PATH : /opt/backup/acctg/archived_wals +ARCHIVE COMMAND : cp %p /opt/backup/acctg/archived_wals/%f +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +DESCRIPTION : "Accounting" +``` + +In the following code sample, the recovery window retention policy setting considers the backups taken within a 3-week recovery window as the `active` backups. + +```text +[DEV] +host = 127.0.0.1 +port = 5445 +user = enterprisedb +archive_command = 'cp %p %a/%f' +retention_policy = 3 WEEKS +description = "Development" +``` + +The start of the 3-week recovery window displayed in the `RETENTION POLICY` field is `2015-03-20 14:59:42 EDT` when the `SHOW-SERVERS` subcommand is invoked on `2015-04-10`. + +At this current point in time, backups taken on or after `2015-03-20 14:59:42 EDT` would be considered `active`. Backups taken prior to `2015-03-20 14:59:42 EDT` would be considered `obsolete` except for backups marked as `keep`. + +```text +-bash-4.1$ date +Fri Apr 10 14:59:39 EDT 2015 +-bash-4.1$ +-bash-4.1$ bart SHOW-SERVERS -s dev +SERVER NAME : dev +HOST NAME : 127.0.0.1 +USER NAME : enterprisedb +PORT : 5445 +REMOTE HOST : +RETENTION POLICY : 2015-03-20 14:59:42 EDT +DISK UTILIZATION : 434.53 MB +NUMBER OF ARCHIVES : 22 +ARCHIVE PATH : /opt/backup/dev/archived_wals +ARCHIVE COMMAND : cp %p /opt/backup/dev/archived_wals/%f +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +DESCRIPTION : "Development" +``` + +In the following code sample, the recovery window retention policy setting considers the backups taken within a 3-month recovery window as the `active` backups. + +```text +[HR] +host = 127.0.0.1 +port = 5432 +user = postgres +retention_policy = 3 MONTHS +description = "Human Resources" +``` + +The start of the 3-month recovery window displayed in the `RETENTION POLICY` field is `2015-01-10 14:04:23 EST` when the `SHOW-SERVERS` subcommand is invoked on `2015-04-10`. + +At this current point in time, backups taken on or after `2015-01-10 14:04:23 EST` would be considered `active`. Backups taken prior to `2015-01-10 14:04:23 EST` would be considered `obsolete`, except for backups marked as `keep`. + +```text +-bash-4.1$ date +Fri Apr 10 15:04:19 EDT 2015 +-bash-4.1$ +-bash-4.1$ bart SHOW-SERVERS -s hr +SERVER NAME : hr +HOST NAME : 127.0.0.1 +USER NAME : postgres +PORT : 5432 +REMOTE HOST : +RETENTION POLICY : 2015-01-10 14:04:23 EST +DISK UTILIZATION : 480.76 MB +NUMBER OF ARCHIVES : 26 +ARCHIVE PATH : /opt/backup/hr/archived_wals +ARCHIVE COMMAND : scp %p +enterprisedb@192.168.2.22:/opt/backup/hr/archived_wals/%f +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +DESCRIPTION : "Human Resources" +``` + +#### Evaluating, Marking, and Deleting Backup Using a Recovery Window Retention Policy + +The following code sample uses a recovery window retention policy to evaluate, mark, and delete backups as shown by the following server configuration: + +```text +[DEV] +host = 127.0.0.1 +port = 5445 +user = enterprisedb +archive_command = 'cp %p %a/%f' +retention_policy = 3 DAYS +description = "Development" +``` + +The following is the current set of backups. Note that the last backup in the list has been marked as `keep`. + +```text +-bash-4.1$ bart SHOW-BACKUPS -s dev +SERVER NAME BACKUP ID BACKUP TIME BACKUP SIZE WAL(s) SIZE +WAL FILES STATUS +dev 1428933278236 2015-04-13 09:54:40 EDT 5.65 MB 16.00 MB +1 active +dev 1428862187757 2015-04-12 14:09:50 EDT 5.65 MB 32.00 MB +2 active +dev 1428768351638 2015-04-11 12:05:54 EDT 5.65 MB 32.00 MB +2 active +dev 1428684544008 2015-04-10 12:49:06 EDT 5.65 MB 224.00 MB +14 active +dev 1428590536488 2015-04-09 10:42:18 EDT 5.65 MB 48.00 MB +3 active +dev 1428502171990 2015-04-08 10:09:34 EDT 5.65 MB 80.00 MB +5 keep +``` + +The current date and time is `2015-04-13 16:46:35 EDT` as shown below: + +```text +-bash-4.1$ date +Mon Apr 13 16:46:35 EDT 2015 +``` + +Thus, a 3-day recovery window would evaluate backups prior to `2015-04-10 16:46:35 EDT` as `obsolete` except for those marked as `keep`. + +Invoke the `MANAGE` subcommand with the `-n` option to perform a dry run to observe which active backups would be changed to `obsolete` according to the retention policy. + +```text +-bash-4.1$ bart MANAGE -s dev -n +INFO: processing server 'dev', backup '1428933278236' +INFO: processing server 'dev', backup '1428862187757' +INFO: processing server 'dev', backup '1428768351638' +INFO: processing server 'dev', backup '1428684544008' +INFO: marking backup '1428684544008' as obsolete +INFO: 14 WAL file(s) marked obsolete +INFO: 1 Unused WAL file(s) present +INFO: processing server 'dev', backup '1428590536488' +INFO: marking backup '1428590536488' as obsolete +INFO: 3 WAL file(s) marked obsolete +INFO: 1 Unused WAL file(s) present +INFO: processing server 'dev', backup '1428502171990' +``` + +The dry run shows that backups `1428684544008` and `1428590536488` would be marked as `obsolete`. + +Also note that a dry run does not change the backup status. The two backups that would be considered obsolete are still marked as `active`: + +```text +-bash-4.1$ bart SHOW-BACKUPS -s dev\ + SERVER NAME BACKUP ID BACKUP TIME BACKUP SIZE WAL(s) SIZE + WAL FILES STATUS + dev 1428933278236 2015-04-13 09:54:40 EDT 5.65 MB 16.00 MB + 1 active + dev 1428862187757 2015-04-12 14:09:50 EDT 5.65 MB 32.00 MB + 2 active + dev 1428768351638 2015-04-11 12:05:54 EDT 5.65 MB 32.00 MB + 2 active + dev 1428684544008 2015-04-10 12:49:06 EDT 5.65 MB 224.00 MB + 14 active + dev 1428590536488 2015-04-09 10:42:18 EDT 5.65 MB 48.00 MB + 3 active + dev 1428502171990 2015-04-08 10:09:34 EDT 5.65 MB 80.00 MB + 5 keep +``` + +Invoke the `MANAGE` subcommand omitting the `-n` option to change and mark the status of the backups as `obsolete`: + +```text +-bash-4.1$ bart MANAGE -s dev +INFO: processing server 'dev', backup '1428933278236' +INFO: processing server 'dev', backup '1428862187757' +INFO: processing server 'dev', backup '1428768351638' +INFO: processing server 'dev', backup '1428684544008' +INFO: marking backup '1428684544008' as obsolete +INFO: 14 WAL file(s) marked obsolete +INFO: 1 Unused WAL file(s) present +INFO: processing server 'dev', backup '1428590536488' +INFO: marking backup '1428590536488' as obsolete +INFO: 3 WAL file(s) marked obsolete +INFO: 1 Unused WAL file(s) present +INFO: processing server 'dev', backup '1428502171990' +``` + +The obsolete backups can be observed in a number of ways. Use the `MANAGE` subcommand with the `-l` option to list the `obsolete` backups: + +```text +-bash-4.1$ bart MANAGE -s dev -l +INFO: 14 WAL file(s) will be removed +INFO: 1 Unused WAL file(s) will be removed +SERVER NAME: dev +BACKUP ID: 1428684544008 +BACKUP STATUS: obsolete +BACKUP TIME: 2015-04-10 12:49:06 EDT +BACKUP SIZE: 5.65 MB +WAL FILE(s): 14 +UNUSED WAL FILE(s): 1 +WAL FILE: 00000001000000000000002E +WAL FILE: 00000001000000000000002D +WAL FILE: 00000001000000000000002C +WAL FILE: 00000001000000000000002B +WAL FILE: 00000001000000000000002A +WAL FILE: 000000010000000000000029 +WAL FILE: 000000010000000000000028 +WAL FILE: 000000010000000000000027 +WAL FILE: 000000010000000000000026 +WAL FILE: 000000010000000000000025 +WAL FILE: 000000010000000000000024 +WAL FILE: 000000010000000000000023 +WAL FILE: 000000010000000000000022 +WAL FILE: 000000010000000000000021 +UNUSED WAL FILE: 00000001000000000000000F.00000028 +INFO: 3 WAL file(s) will be removed +INFO: 1 Unused WAL file(s) will be removed +SERVER NAME: dev +BACKUP ID: 1428590536488 +BACKUP STATUS: obsolete +BACKUP TIME: 2015-04-09 10:42:18 EDT\ +BACKUP SIZE: 5.65 MB +WAL FILE(s): 3 +UNUSED WAL FILE(s): 1 +WAL FILE: 000000010000000000000020 +WAL FILE: 00000001000000000000001F +WAL FILE: 00000001000000000000001E +UNUSED WAL FILE: 00000001000000000000000F.00000028 +``` + +The `STATUS` field of the `SHOW-BACKUPS` subcommand displays the current status: + +```text +-bash-4.1$ bart SHOW-BACKUPS -s dev +SERVER NAME BACKUP ID BACKUP TIME BACKUP SIZE WAL(s) SIZE +WAL FILES STATUS +dev 1428933278236 2015-04-13 09:54:40 EDT 5.65 MB 16.00 MB +1 active +dev 1428862187757 2015-04-12 14:09:50 EDT 5.65 MB 32.00 MB +2 active +dev 1428768351638 2015-04-11 12:05:54 EDT 5.65 MB 32.00 MB +2 active +dev 1428684544008 2015-04-10 12:49:06 EDT 5.65 MB 224.00 MB +14 obsolete +dev 1428590536488 2015-04-09 10:42:18 EDT 5.65 MB 48.00 MB +3 obsolete +dev 1428502171990 2015-04-08 10:09:34 EDT 5.65 MB 80.00 MB +5 keep +``` + +The details of an individual backup can be displayed using the `SHOW-BACKUPS` subcommand with the `-t` option. Note the status in the `BACKUP STATUS` field. + +```text +-bash-4.1$ bart SHOW-BACKUPS -s dev -i 1428684544008 -t +SERVER NAME : dev +BACKUP ID : 1428684544008 +BACKUP NAME : none +BACKUP STATUS : obsolete +BACKUP TIME : 2015-04-10 12:49:06 EDT +BACKUP SIZE : 5.65 MB +WAL(S) SIZE : 224.00 MB +NO. OF WALS : 14 +FIRST WAL FILE : 000000010000000000000021 +CREATION TIME : 2015-04-10 12:49:06 EDT +LAST WAL FILE : 00000001000000000000002E +CREATION TIME : 2015-04-11 12:02:15 EDT +``` + +Use the `MANAGE` subcommand with the `-d` option to physically delete the obsolete backups including the unneeded WAL files. + +```text +-bash-4.1$ bart MANAGE -s dev -d +INFO: removing all obsolete backups of server 'dev' +INFO: removing obsolete backup '1428684544008' +INFO: 14 WAL file(s) will be removed +INFO: 1 Unused WAL file(s) will be removed +INFO: removing WAL file '00000001000000000000002E' +INFO: removing WAL file '00000001000000000000002D' +INFO: removing WAL file '00000001000000000000002C' +INFO: removing WAL file '00000001000000000000002B' +INFO: removing WAL file '00000001000000000000002A' +INFO: removing WAL file '000000010000000000000029' +INFO: removing WAL file '000000010000000000000028' +INFO: removing WAL file '000000010000000000000027' +INFO: removing WAL file '000000010000000000000026' +INFO: removing WAL file '000000010000000000000025' +INFO: removing WAL file '000000010000000000000024' +INFO: removing WAL file '000000010000000000000023' +INFO: removing WAL file '000000010000000000000022' +INFO: removing WAL file '000000010000000000000021' +INFO: removing (unused) WAL file '00000001000000000000000F.00000028' +INFO: removing obsolete backup '1428590536488' +INFO: 3 WAL file(s) will be removed +INFO: removing WAL file '000000010000000000000020' +INFO: removing WAL file '00000001000000000000001F' +INFO: removing WAL file '00000001000000000000001E' +``` + +The `SHOW-BACKUPS` subcommand now displays the remaining backups marked as `active` or `keep`: + +```text +-bash-4.1$ bart SHOW-BACKUPS -s dev +SERVER NAME BACKUP ID BACKUP TIME BACKUP SIZE WAL(s) SIZE +WAL FILES STATUS +dev 1428933278236 2015-04-13 09:54:40 EDT 5.65 MB 16.00 MB +1 active +dev 1428862187757 2015-04-12 14:09:50 EDT 5.65 MB 32.00 MB +2 active +dev 1428768351638 2015-04-11 12:05:54 EDT 5.65 MB 32.00 MB +2 active +dev 1428502171990 2015-04-08 10:09:34 EDT 5.65 MB 80.00 MB +5 keep +``` + +## Managing Incremental Backups + +This section illustrates evaluating, marking, and deleting incremental backups using the `MANAGE` and `DELETE` subcommands utilizing redundancy retention policy and recovery window retention policy. For detailed information about the `MANAGE` and `DELETE` subcommands, as well as the redundancy retention and recovery window retention policy, see the *EDB Backup and Recovery User Guide* available at the [EDB website](/bart/latest/bart_user/). + +- [Using a Redundancy Retention Policy](#redundancy_retention_policy) provides an example of using the `MANAGE` and `DELETE` subcommands when a 3 backup redundancy retention policy is in effect. +- [Using a Recovery Window Retention Policy](#recovery_window_retention_policy) provides an example of using the `MANAGE` and `DELETE` subcommands when a 1-day recovery window retention policy is in effect. + + + +### Using a Redundancy Retention Policy + +The following code sample uses the `MANAGE` and `DELETE` subcommands to evaluate, mark, and delete incremental backups when a 3 backup redundancy retention policy is in effect. The example uses the following server configuration: + +```text +[ACCTG] + +host = 192.168.2.24 +port = 5445 +user = enterprisedb +cluster_owner = enterprisedb +remote_host = enterprisedb@192.168.2.24 +allow_incremental_backups = enabled +retention_policy = 3 BACKUPS +description = "Accounting" +``` + +The example uses the following set of backups. In these code samples, some columns have been omitted from the `SHOW-BACKUPS` output to display the relevant information in a more observable manner. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME ... STATUS +acctg 1481749696905 ... 1481749673603 2016-12-14 16:08:17 EST ... active +acctg 1481749673603 ... 1481749651927 2016-12-14 16:07:53 EST ... active +acctg 1481749651927 ... 1481749619582 2016-12-14 16:07:32 EST ... active +acctg 1481749619582 ... none 2016-12-14 16:07:00 EST ... active +``` + +There is one backup chain. The first backup is the initial full backup. + +Backup chain: `1481749619582 => 1481749651927 => 1481749673603 => 1481749696905` + +The `MANAGE` subcommand is invoked as shown by the following: + +```text +-bash-4.2$ bart MANAGE -s acctg +INFO: processing server 'acctg', backup '1481749619582' +INFO: 2 Unused WAL file(s) present +INFO: 4 Unused file(s) (WALs included) present, use 'MANAGE -l' for the +list +``` + +The following code sample shows the resulting status of the backups: + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME ... STATUS +acctg 1481749696905 ... 1481749673603 2016-12-14 16:08:17 EST ... active +acctg 1481749673603 ... 1481749651927 2016-12-14 16:07:53 EST ... active +acctg 1481749651927 ... 1481749619582 2016-12-14 16:07:32 EST ... active +acctg 1481749619582 ... none 2016-12-14 16:07:00 EST ... active +``` + +The status remains active for all backups. Even though the total number of backups exceeds the 3 backup redundancy retention policy, it is only the total number of full backups that is used to determine if the redundancy retention policy has been exceeded. Additional full backups are added including a second backup chain. The following example shows the resulting list of backups: + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME ... STATUS +acctg 1481750365397 ... none 2016-12-14 16:19:26 EST ... active +acctg 1481750098924 ... 1481749997807 2016-12-14 16:14:59 EST ... active +acctg 1481749997807 ... none 2016-12-14 16:13:18 EST ... active +acctg 1481749992003 ... none 2016-12-14 16:13:12 EST ... active +acctg 1481749696905 ... 1481749673603 2016-12-14 16:08:17 EST ... active +acctg 1481749673603 ... 1481749651927 2016-12-14 16:07:53 EST ... active +acctg 1481749651927 ... 1481749619582 2016-12-14 16:07:32 EST ... active +acctg 1481749619582 ... none 2016-12-14 16:07:00 EST ... active +``` + +Second backup chain: `1481749997807 => 1481750098924` + +The `MANAGE` subcommand is invoked, but now with a total of four active full backups. + +```text +-bash-4.2$ bart MANAGE -s acctg +INFO: processing server 'acctg', backup '1481750365397' +INFO: processing server 'acctg', backup '1481749997807' +INFO: processing server 'acctg', backup '1481749992003' +INFO: processing server 'acctg', backup '1481749619582' +INFO: marking backup '1481749619582' as obsolete +INFO: 3 incremental(s) of backup '1481749619582' will be marked obsolete +INFO: marking incremental backup '1481749696905' as obsolete +INFO: marking incremental backup '1481749673603' as obsolete +INFO: marking incremental backup '1481749651927' as obsolete +INFO: 4 WAL file(s) marked obsolete +INFO: 2 Unused WAL file(s) present +INFO: 4 Unused file(s) (WALs included) present, use 'MANAGE -l' for the +list +``` + +The oldest full backup and its chain of incremental backups are now marked as obsolete. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME ... STATUS +acctg 1481750365397 ... none 2016-12-14 16:19:26 EST ... active +acctg 1481750098924 ... 1481749997807 2016-12-14 16:14:59 EST ... active +acctg 1481749997807 ... none 2016-12-14 16:13:18 EST ... active +acctg 1481749992003 ... none 2016-12-14 16:13:12 EST ... active +acctg 1481749696905 ... 1481749673603 2016-12-14 16:08:17 EST ... obsolete +acctg 1481749673603 ... 1481749651927 2016-12-14 16:07:53 EST ... obsolete +acctg 1481749651927 ... 1481749619582 2016-12-14 16:07:32 EST ... obsolete +acctg 1481749619582 ... none 2016-12-14 16:07:00 EST ... obsolete +``` + +Invoking the `MANAGE` subcommand with the `-d` option deletes the entire obsolete backup chain. + +```text +-bash-4.2$ bart MANAGE -s acctg -d +INFO: removing all obsolete backups of server 'acctg' +INFO: removing obsolete backup '1481749619582' +INFO: 4 WAL file(s) will be removed +INFO: 3 incremental(s) of backup '1481749619582' will be removed +INFO: removing obsolete incremental backup '1481749696905' +INFO: removing obsolete incremental backup '1481749673603' +INFO: removing obsolete incremental backup '1481749651927' +INFO: removing WAL file '000000010000000100000000' +INFO: removing WAL file '0000000100000000000000FF' +INFO: removing WAL file '0000000100000000000000FE' +INFO: removing WAL file '0000000100000000000000FD' +INFO: 16 Unused file(s) will be removed +INFO: removing (unused) file '000000010000000100000004.00000028.backup' +. +. +. +INFO: removing (unused) file +'0000000100000000FB00002800000000FC000000.mbm' +``` + +The following code sample shows the remaining full backups and the second backup chain. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME ... STATUS +acctg 1481750365397 ... none 2016-12-14 16:19:26 EST ... active +acctg 1481750098924 ... 1481749997807 2016-12-14 16:14:59 EST ... active +acctg 1481749997807 ... none 2016-12-14 16:13:18 EST ... active +acctg 1481749992003 ... none 2016-12-14 16:13:12 EST ... active +``` + + + +### Using a Recovery Window Retention Policy + +The following example demonstrates using the `MANAGE` and `DELETE` subcommands to evaluate, mark, and delete incremental backups when a 1-day recovery window retention policy is in effect. The example uses the following server configuration: + +```text +[ACCTG] + +host = 192.168.2.24 +port = 5445 +user = enterprisedb +cluster_owner = enterprisedb +remote_host = enterprisedb@192.168.2.24 +allow_incremental_backups = enabled +retention_policy = 1 DAYS +description = "Accounting" +``` + +The example uses the following set of backups. In the samples, some columns have been omitted from the `SHOW-BACKUPS` output to display the relevant information in a more observable manner. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME ... STATUS +acctg 1481559303348 ... 1481554203288 2016-12-12 11:15:03 EST ... active +acctg 1481559014359 ... 1481554802918 2016-12-12 11:10:14 EST ... active +acctg 1481554802918 ... 1481553914533 2016-12-12 10:00:03 EST ... active +acctg 1481554203288 ... 1481553651165 2016-12-12 09:50:03 EST ... active +acctg 1481553914533 ... 1481553088053 2016-12-12 09:45:14 EST ... active +acctg 1481553651165 ... none 2016-12-12 09:40:51 EST ... active +acctg 1481553088053 ... 1481552078404 2016-12-12 09:31:28 EST ... active +acctg 1481552078404 ... none 2016-12-12 09:14:39 EST ... active +``` + +There are two backup chains. In each of the following chains, the first backup is the initial full backup. + +First backup chain: `1481552078404 => 1481553088053 => 1481553914533 => 1481554802918 => 1481559014359` + +Second backup chain: `1481553651165 => 1481554203288 => 1481559303348` + +The `MANAGE` subcommand is invoked when the first full backup `1481552078404` falls out of the recovery window. When the `MANAGE` subcommand is invoked, it is `2016-12-13 09:20:03 EST`, thus making the start of the 1-day recovery window at `2016-12-12 09:20:03 EST` exactly one day earlier. This backup was taken at `2016-12-12 09:14:39 EST`, which is about 5 ½ minutes before the start of the recovery window, thus making the backup obsolete. + +```text +-bash-4.2$ date +Tue Dec 13 09:20:03 EST 2016 +-bash-4.2$ bart MANAGE -s acctg +INFO: processing server 'acctg', backup '1481553651165' +INFO: processing server 'acctg', backup '1481552078404' +INFO: marking backup '1481552078404' as obsolete +INFO: 4 incremental(s) of backup '1481552078404' will be marked obsolete +INFO: marking incremental backup '1481559014359' as obsolete +INFO: marking incremental backup '1481554802918' as obsolete +INFO: marking incremental backup '1481553914533' as obsolete +INFO: marking incremental backup '1481553088053' as obsolete +INFO: 7 WAL file(s) marked obsolete +INFO: 1 Unused WAL file(s) present +INFO: 2 Unused file(s) (WALs included) present, use 'MANAGE -l' for the list +``` + +The incremental backup date and time are within the recovery window since they were taken after the start of the recovery window of `2016-12-12 09:20:03 EST`, but all backups in the chain are marked as `obsolete`. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg\ +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME +... STATUS +acctg 1481559303348 ... 1481554203288 2016-12-12 11:15:03 EST +... active +acctg 1481559014359 ... 1481554802918 2016-12-12 11:10:14 EST +... obsolete +acctg 1481554802918 ... 1481553914533 2016-12-12 10:00:03 EST +... obsolete +acctg 1481554203288 ... 1481553651165 2016-12-12 09:50:03 EST +... active +acctg 1481553914533 ... 1481553088053 2016-12-12 09:45:14 EST +... obsolete +acctg 1481553651165 ... none 2016-12-12 09:40:51 EST +... active +acctg 1481553088053 ... 1481552078404 2016-12-12 09:31:28 EST +... obsolete +acctg 1481552078404 ... none 2016-12-12 09:14:39 EST +... obsolete +``` + +The following code sample shows how the entire backup chain is changed back to active status by invoking the `MANAGE` subcommand with the `-c nokeep` option on the full backup of the chain. + +```text +-bash-4.2$ bart MANAGE -s acctg -c nokeep -i 1481552078404 +INFO: changing status of backup '1481552078404' of server 'acctg' from +'obsolete' to 'active' +INFO: status of 4 incremental(s) of backup '1481552078404' will be +changed +INFO: changing status of incremental backup '1481559014359' of server +'acctg' from 'obsolete' to 'active' +INFO: changing status of incremental backup '1481554802918' of server +'acctg' from 'obsolete' to 'active' +INFO: changing status of incremental backup '1481553914533' of server +'acctg' from 'obsolete' to 'active' +INFO: changing status of incremental backup '1481553088053' of server +'acctg' from 'obsolete' to 'active' +INFO: 7 WAL file(s) changed +``` + +The backup chain has now been reset to active status. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME ... STATUS +acctg 1481559303348 ... 1481554203288 2016-12-12 11:15:03 EST ... active +acctg 1481559014359 ... 1481554802918 2016-12-12 11:10:14 EST ... active +acctg 1481554802918 ... 1481553914533 2016-12-12 10:00:03 EST ... active +acctg 1481554203288 ... 1481553651165 2016-12-12 09:50:03 EST ... active +acctg 1481553914533 ... 1481553088053 2016-12-12 09:45:14 EST ... active +acctg 1481553651165 ... none 2016-12-12 09:40:51 EST ... active +acctg 1481553088053 ... 1481552078404 2016-12-12 09:31:28 EST ... active +acctg 1481552078404 ... none 2016-12-12 09:14:39 EST ... active +``` + +The following code sample shows usage of the `DELETE` subcommand on an incremental backup. The specified incremental backup `1481554802918` in the first backup chain as well as its successive incremental backup `1481559014359` are deleted. + +```text +-bash-4.2$ bart DELETE -s acctg -i 1481554802918 +INFO: deleting backup '1481554802918' of server 'acctg' +INFO: deleting backup '1481554802918' +INFO: 1 incremental backup(s) will be deleted +INFO: deleting incremental backup '1481559014359' +INFO: WALs of deleted backup(s) will belong to prior backup(if any), or +will be marked unused +INFO: 2 Unused file(s) will be removed +INFO: removing (unused) file '0000000100000000000000BA' +INFO: removing (unused) file +'0000000100000000BA00002800000000BB000000.mbm' +INFO: backup(s) deleted +``` + +The results show that the backups `1481554802918` and `1481559014359` are no longer listed by the `SHOW-BACKUPS` subcommand. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME ... STATUS +acctg 1481559303348 ... 1481554203288 2016-12-12 11:15:03 EST ... active +acctg 1481554203288 ... 1481553651165 2016-12-12 09:50:03 EST ... active +acctg 1481553914533 ... 1481553088053 2016-12-12 09:45:14 EST ... active +acctg 1481553651165 ... none 2016-12-12 09:40:51 EST ... active +acctg 1481553088053 ... 1481552078404 2016-12-12 09:31:28 EST ... active +acctg 1481552078404 ... none 2016-12-12 09:14:39 EST ... active +``` + +The `MANAGE` subcommand is invoked again. This time both backup chains are marked `obsolete` since the full backups of both chains fall out of the start of the recovery window, which is now `2016-12-12 09:55:03 EST`. + +```text +-bash-4.2$ date +Tue Dec 13 09:55:03 EST 2016 +-bash-4.2$ bart MANAGE -s acctg +INFO: processing server 'acctg', backup '1481553651165' +INFO: marking backup '1481553651165' as obsolete +INFO: 2 incremental(s) of backup '1481553651165' will be marked obsolete +INFO: marking incremental backup '1481559303348' as obsolete +INFO: marking incremental backup '1481554203288' as obsolete +INFO: 38 WAL file(s) marked obsolete +INFO: processing server 'acctg', backup '1481552078404' +INFO: marking backup '1481552078404' as obsolete +INFO: 2 incremental(s) of backup '1481552078404' will be marked obsolete +INFO: marking incremental backup '1481553914533' as obsolete +INFO: marking incremental backup '1481553088053' as obsolete +INFO: 7 WAL file(s) marked obsolete +``` + +The following code sample shows both backup chains marked as `obsolete`. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME +... STATUS +acctg 1481559303348 ... 1481554203288 2016-12-12 11:15:03 EST +... obsolete +acctg 1481554203288 ... 1481553651165 2016-12-12 09:50:03 EST +... obsolete +acctg 1481553914533 ... 1481553088053 2016-12-12 09:45:14 EST +... obsolete +acctg 1481553651165 ... none 2016-12-12 09:40:51 EST +... obsolete +acctg 1481553088053 ... 1481552078404 2016-12-12 09:31:28 EST +... obsolete +acctg 1481552078404 ... none 2016-12-12 09:14:39 EST +... obsolete +``` + +The following code sample demonstrates using the `MANAGE` subcommand with the `-c keep` option to keep a backup chain indefinitely. The `MANAGE` subcommand with the `-c keep` option must specify the backup identifier or backup name of the full backup of the chain, and not any incremental backup. + +```text +-bash-4.2$ bart MANAGE -s acctg -c keep -i 1481553651165 +INFO: changing status of backup '1481553651165' of server 'acctg' from +'obsolete' to 'keep' +INFO: status of 2 incremental(s) of backup '1481553651165' will be +changed +INFO: changing status of incremental backup '1481559303348' of server +'acctg' from 'obsolete' to 'keep' +INFO: changing status of incremental backup '1481554203288' of server +'acctg' from 'obsolete' to 'keep' +INFO: 38 WAL file(s) changed +``` + +The full backup `1481553651165` and its successive incremental backups `1481554203288` and `1481559303348` have been changed to `keep` status: + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME +... STATUS +acctg 1481559303348 ... 1481554203288 2016-12-12 11:15:03 EST +... keep +acctg 1481554203288 ... 1481553651165 2016-12-12 09:50:03 EST +... keep +acctg 1481553914533 ... 1481553088053 2016-12-12 09:45:14 EST +... obsolete +acctg 1481553651165 ... none 2016-12-12 09:40:51 EST +... keep +acctg 1481553088053 ... 1481552078404 2016-12-12 09:31:28 EST +... obsolete +acctg 1481552078404 ... none 2016-12-12 09:14:39 EST +... obsolete +``` + +Finally, the `MANAGE` subcommand with the `-d` option is used to delete the `obsolete` backup chain: + +```text +-bash-4.2$ bart MANAGE -s acctg -d +INFO: removing all obsolete backups of server 'acctg' +INFO: removing obsolete backup '1481552078404' +INFO: 7 WAL file(s) will be removed +INFO: 2 incremental(s) of backup '1481552078404' will be removed +INFO: removing obsolete incremental backup '1481553914533' +INFO: removing obsolete incremental backup '1481553088053' +INFO: removing WAL file '0000000100000000000000C1' +INFO: removing WAL file '0000000100000000000000C0' +INFO: removing WAL file '0000000100000000000000BF' +INFO: removing WAL file '0000000100000000000000BE' +INFO: removing WAL file '0000000100000000000000BD' +INFO: removing WAL file '0000000100000000000000BC' +INFO: removing WAL file '0000000100000000000000BB' +INFO: 48 Unused file(s) will be removed +INFO: removing (unused) file '0000000100000000000000FA' +. +. +. +INFO: removing (unused) file '0000000100000000000000BB.00000028.backup' +``` + +Only the backup chain with the `keep` status remains as shown below: + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME +... STATUS +acctg 1481559303348 ... 1481554203288 2016-12-12 11:15:03 EST +... keep +acctg 1481554203288 ... 1481553651165 2016-12-12 09:50:03 EST +... keep +acctg 1481553651165 ... none 2016-12-12 09:40:51 EST +... keep +``` diff --git a/product_docs/docs/bart/2.5.9/bart_ref/03_sample_bart_system_with_local_and_remote_database_servers.mdx b/product_docs/docs/bart/2.5.9/bart_ref/03_sample_bart_system_with_local_and_remote_database_servers.mdx new file mode 100644 index 00000000000..b1527216806 --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_ref/03_sample_bart_system_with_local_and_remote_database_servers.mdx @@ -0,0 +1,1385 @@ +--- +title: "Sample BART System with Local and Remote Database Servers" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/sample_bart_system_with_local_and_remote_database_servers.html" +--- + + + +This section describes a sample BART managed backup and recovery system consisting of both local and remote database servers. The complete steps to configure and operate the system are provided. + +For detailed information about configuring a BART system, see the *EDB Backup and Recovery Installation and Upgrade Guide*. For detailed information about the operational procedures and BART subcommands, see the *EDB Backup and Recovery User Guide*. These guides are available at the [EDB website](/bart/latest/bart_inst/). + +The environment for this sample system is as follows: + +- BART on host `192.168.2.22` running with BART user account `enterprisedb` +- Local Advanced Server on host `192.168.2.22` running with user account `enterprisedb` +- Remote Advanced Server on host `192.168.2.24` running with user account `enterprisedb` +- Remote PostgreSQL server on host `192.168.2.24` running with user account `postgres` + +Passwordless SSH/SCP connections are required between the following: + +- BART on host `192.168.2.22` and the local Advanced Server on the same host `192.168.2.22` +- BART on host `192.168.2.22` and the remote Advanced Server on host `192.168.2.24` +- BART on host `192.168.2.22` and the remote PostgreSQL server on host `192.168.2.24` + +The following sections demonstrate configuring and taking full backups only. To support incremental backups as well, enable the `allow_incremental_backups` parameter for the desired database servers and use the `WAL scanner` program. + +- [The BART Configuration File](#bart_configuration_file) shows the settings used in the BART configuration file. +- [Establishing SSH/SCP Passwordless Connections](#establishing-sshscp-passwordless-connections) provides an example of how to establish an SSH/SCP passwordless connection. +- [Configuring a Replication Database User](#configuring-a-replication-database-user) provides an example of how to configure the replication database user. +- [WAL Archiving Configuration Parameters](#wal-archiving-configuration-parameters) provides an example of how to configure WAL archiving. +- [Creating the BART Backup Catalog](#creating-the-bart-backup-catalog-backup_path) provides information about creating a BART Backup Catalog. +- [Starting the Database Servers with WAL Archiving](#starting-the-database-servers-with-wal-archiving) provides example of starting the database servers with WAL archiving. +- [Taking a Full Backup](#taking-a-full-backup) illustrates taking the first full backup of the database servers. +- [Using Point-In-Time Recovery](#using-point-in-time-recovery) demonstrates the point-in-time recovery operation on the remote PostgreSQL database server. + + + +## The BART Configuration File + +The following code sample shows the settings used in the BART configuration file for the examples that follow: + +```text +[BART] +bart_host= enterprisedb@192.168.2.22 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +retention_policy = 6 BACKUPS +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log + +[ACCTG] +host = 127.0.0.1 +port = 5444 +user = enterprisedb +cluster_owner = enterprisedb +backup_name = acctg_%year-%month-%dayT%hour:%minute +archive_command = 'cp %p %a/%f' +description = "Accounting" + +[MKTG] + +host = 192.168.2.24 +port = 5444 +user = repuser +cluster_owner = enterprisedb +backup_name = mktg_%year-%month-%dayT%hour:%minute +remote_host = enterprisedb@192.168.2.24 +description = "Marketing" + +[HR] + +host = 192.168.2.24 +port = 5432 +user = postgres +cluster_owner = postgres +backup_name = hr_%year-%month-%dayT%hour:%minute +remote_host = postgres@192.168.2.24 +copy_wals_during_restore = enabled +description = "Human Resources" +``` + + + +## Establishing SSH/SCP Passwordless Connections + +This section demonstrates how passwordless SSH/SCP connections are established with the authorized public keys files. + + + +### Generating a Public Key File for the BART User Account + +The BART user account is `enterprisedb` with a home directory of `/opt/PostgresPlus/9.6AS`. + +To generate the public key file, as a root user, first create the `.ssh` subdirectory in the BART user’s home directory and assign ownership of this directory to the `enterprisedb` user, ensuring there are no groups or other users that can access the `.ssh` directory. + +```text +[root@localhost 9.6AS]# pwd +/opt/PostgresPlus/9.6AS +[root@localhost 9.6AS]# mkdir .ssh +[root@localhost 9.6AS]# chown enterprisedb .ssh +[root@localhost 9.6AS]# chgrp enterprisedb .ssh +[root@localhost 9.6AS]# chmod 700 .ssh +[root@localhost 9.6AS]# ls -la | grep ssh +drwx------ 2 enterprisedb enterprisedb 4096 Apr 23 13:02 .ssh +``` + +Generate the public key file: + +```text +[user@localhost ~]$ su - enterprisedb +Password: +-bash-4.1$ pwd +/opt/PostgresPlus/9.6AS +-bash-4.1$ ssh-keygen -t rsa +Generating public/private rsa key pair. +Enter file in which to save the key +(/opt/PostgresPlus/9.6AS/.ssh/id_rsa): +Enter passphrase (empty for no passphrase): +Enter same passphrase again: +Your identification has been saved in +/opt/PostgresPlus/9.6AS/.ssh/id_rsa. +Your public key has been saved in +/opt/PostgresPlus/9.6AS/.ssh/id_rsa.pub. +The key fingerprint is: +de:65:34:d6:b1:d2:32:3c:b0:43:c6:a3:c0:9f:f4:64 +enterprisedb@localhost.localdomain +The key's randomart image is: ++----[ RSA 2048]----+ +| . .+ . | +| o .oE+ o o | +| + * o.X + | +| + .+ * | +| S o | +| . . o | +| . . | +| + | +| | ++-------------------+ +``` + +The following are the resulting files. `id_rsa.pub` is the public key file of BART user account `enterprisedb`. + +```text +-bash-4.1$ ls -l .ssh +total 8 +-rw------- 1 enterprisedb enterprisedb 1675 Apr 23 13:04 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Apr 23 13:04 id_rsa.pub +``` + +### Configuring Access between Local Advanced Server and the BART Host + +Even when the Advanced Server database is on the same host as the BART user account, and the Advanced Server database cluster owner is also the BART user account (`enterprisedb` is this case), a passwordless SSH/SCP connection must be established from the same user account to itself. + +On the BART host where the public key file was just generated (as shown in [Generating a Public Key File for the BART User Account](#generating-a-public-key-file-for-the-bart-user-account)), create the authorized keys file by appending the public key file to any existing authorized keys file. + +Log into the BART host as the BART user account and append the public key file, `id_rsa.pub` onto the `authorized_keys` file in the same `.ssh` directory. + +```text +[user@localhost ~]$ su - enterprisedb +Password: +Last login: Thu Mar 23 10:27:35 EDT 2017 on pts/0 +-bash-4.2$ pwd +/opt/PostgresPlus/9.6AS +-bash-4.2$ ls -l .ssh +total 12 +-rw------- 1 enterprisedb enterprisedb 1675 Mar 23 09:54 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Mar 23 09:54 id_rsa.pub +-rw-r--r-- 1 enterprisedb enterprisedb 345 Mar 23 10:05 known_hosts +-bash-4.2$ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys +-bash-4.2$ ls -l .ssh +total 16 +-rw-rw-r-- 1 enterprisedb enterprisedb 416 Mar 23 10:33 authorized_keys +-rw------- 1 enterprisedb enterprisedb 1675 Mar 23 09:54 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Mar 23 09:54 id_rsa.pub +-rw-r--r-- 1 enterprisedb enterprisedb 345 Mar 23 10:05 known_hosts +``` + +The `authorized_keys` file must have file permission `600` as set by the following `chmod 600` command, or the passwordless connection will fail: + +```text +-bash-4.2$ chmod 600 ~/.ssh/authorized_keys +-bash-4.2$ ls -l .ssh +total 16 +-rw------- 1 enterprisedb enterprisedb 416 Mar 23 10:33 authorized_keys +-rw------- 1 enterprisedb enterprisedb 1675 Mar 23 09:54 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Mar 23 09:54 id_rsa.pub +-rw-r--r-- 1 enterprisedb enterprisedb 345 Mar 23 10:05 known_hosts +``` + +Test the passwordless connection. Use the `ssh` command to verify that you can access the same user account as you are currently logged in as (`enterprisedb`) without being prompted for a password: + +```text +-bash-4.2$ ssh enterprisedb@127.0.0.1 +Last login: Thu Mar 23 10:27:50 2017 +-bash-4.2$ exit +logout +Connection to 127.0.0.1 closed. +``` + +### Configuring Access from Remote Advanced Server to BART Host + +On the remote host `192.168.2.24`, create the public key file for the remote database server user account, `enterprisedb`, for access to the BART user account, `enterprisedb`, on the BART host 192.168.2.22. + +Create the `.ssh` directory for user account `enterprisedb` on the remote host: + +```text +[root@localhost 9.6AS]# pwd +/opt/PostgresPlus/9.6AS +[root@localhost 9.6AS]# mkdir .ssh +[root@localhost 9.6AS]# chown enterprisedb .ssh +[root@localhost 9.6AS]# chgrp enterprisedb .ssh +[root@localhost 9.6AS]# chmod 700 .ssh +[root@localhost 9.6AS]# ls -la | grep ssh +drwx------ 2 enterprisedb enterprisedb 4096 Apr 23 13:08 .ssh +``` + +Generate the public key file on the remote host for user account `enterprisedb`: + +```text +[user@localhost ~]$ su - enterprisedb +Password: +-bash-4.1$ ssh-keygen -t rsa +Generating public/private rsa key pair. +Enter file in which to save the key +(/opt/PostgresPlus/9.6AS/.ssh/id_rsa): +Enter passphrase (empty for no passphrase): +Enter same passphrase again: +Your identification has been saved in +/opt/PostgresPlus/9.6AS/.ssh/id_rsa. +Your public key has been saved in +/opt/PostgresPlus/9.6AS/.ssh/id_rsa.pub. +The key fingerprint is: +15:27:1e:1e:61:4b:48:66:67:0b:b2:be:fc:ea:ea:e6 +enterprisedb@localhost.localdomain +The key's randomart image is: ++--[ RSA 2048]---+ +| ..=.@.. | +| =.O O | +| . * | +| . . | +| . S | +| . . | +| o | +| . . | +| +Eoo.. | ++----------------+ +``` + +Copy the generated public key file, `id_rsa.pub`, to the BART user account, `enterprisedb`, on the BART host, `192.168.2.22`: + +```text +-bash-4.1$ scp ~/.ssh/id_rsa.pub enterprisedb@192.168.2.22:/tmp/tmp.pub +The authenticity of host '192.168.2.22 (192.168.2.22)' can't be +established. +RSA key fingerprint is b8:a9:97:31:79:16:b8:2b:b0:60:5a:91:38:d7:68:22. +Are you sure you want to continue connecting (yes/no)? yes +Warning: Permanently added '192.168.2.22' (RSA) to the list of known hosts. +enterprisedb@192.168.2.22's password: +id_rsa.pub +``` + +Log into the BART host as the BART user account and append the temporary public key file, `/tmp/tmp.pub` onto the `authorized_keys` file owned by the BART user account. + +```text +-bash-4.1$ ssh enterprisedb@192.168.2.22 +enterprisedb@192.168.2.22's password: +Last login: Tue Apr 21 17:03:24 2015 from 192.168.2.22 +-bash-4.1$ pwd +/opt/PostgresPlus/9.6AS +-bash-4.1$ cat /tmp/tmp.pub >> ~/.ssh/authorized_keys +-bash-4.1$ ls -l .ssh +total 12 +-rw-rw-r-- 1 enterprisedb enterprisedb 416 Apr 23 13:15 authorized_keys +-rw------- 1 enterprisedb enterprisedb 1675 Apr 23 13:04 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Apr 23 13:04 id_rsa.pub +``` + +The `authorized_keys` file must have file permission `600` as set by the following `chmod 600` command, otherwise the passwordless connection fails: + +```text +-bash-4.1$ chmod 600 ~/.ssh/authorized_keys +-bash-4.1$ ls -l .ssh +total 12 +-rw------- 1 enterprisedb enterprisedb 416 Apr 23 13:15 authorized_keys +-rw------- 1 enterprisedb enterprisedb 1675 Apr 23 13:04 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Apr 23 13:04 id_rsa.pub +-bash-4.1$ rm /tmp/tmp.pub +-bash-4.1$ exit +logout +Connection to 192.168.2.22 closed. +``` + +Test the passwordless connection. From the remote host, verify that you can log into the BART host with the BART user account without being prompted for a password: + +```text +-bash-4.1$ ssh enterprisedb@192.168.2.22 +Last login: Thu Apr 23 13:14:48 2015 from 192.168.2.24 +-bash-4.1$ exit +logout +Connection to 192.168.2.22 closed. +``` + +### Configuring Access from the BART Host to a Remote Advanced Server + +On the BART host `192.168.2.22`, copy the public key file for the BART user account, `enterprisedb`, for access to the remote database server user account, `enterprisedb`, on the remote host `192.168.2.24`. + +The following lists the current SSH keys files in the BART user’s `.ssh` directory on the BART host: + +```text +[user@localhost ~]$ su - enterprisedb +Password: +-bash-4.1$ pwd +/opt/PostgresPlus/9.6AS +-bash-4.1$ ls -l .ssh +total 12 +-rw------- 1 enterprisedb enterprisedb 416 Apr 23 13:15 authorized_keys +-rw------- 1 enterprisedb enterprisedb 1675 Apr 23 13:04 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Apr 23 13:04 id_rsa.pub +``` + +The public key file, `id_rsa.pub`, for BART user account `enterprisedb` on the BART host that was earlier generated in [Generating a Public Key File for the BART User Account](#generating-a-public-key-file-for-the-bart-user-account), is now copied to the remote Advanced Server host on `192.168.2.24`: + +```text +-bash-4.1$ scp ~/.ssh/id_rsa.pub enterprisedb@192.168.2.24:/tmp/tmp.pub +The authenticity of host '192.168.2.24 (192.168.2.24)' can't be +established. +RSA key fingerprint is 59:41:fb:0c:ae:64:3d:3f:a2:d9:90:95:cf:2c:99:f2. +Are you sure you want to continue connecting (yes/no)? yes +Warning: Permanently added '192.168.2.24' (RSA) to the list of known +hosts. +enterprisedb@192.168.2.24's password: +id_rsa.pub +``` + +Log into the `enterprisedb` user account on the remote host and copy the public key file onto the `authorized_keys` file of the remote `enterprisedb` user account under its `.ssh` directory: + +```text +-bash-4.1$ ssh enterprisedb@192.168.2.24 +enterprisedb@192.168.2.24's password: +Last login: Tue Apr 21 09:53:18 2015 from 192.168.2.22 +-bash-4.1$ pwd +/opt/PostgresPlus/9.6AS +-bash-4.1$ ls -l .ssh +total 12 +-rw------- 1 enterprisedb enterprisedb 1675 Apr 23 13:11 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Apr 23 13:11 id_rsa.pub +-rw-r--r-- 1 enterprisedb enterprisedb 394 Apr 23 13:12 known_hosts +-bash-4.1$ cat /tmp/tmp.pub >> ~/.ssh/authorized_keys +``` + +Adjust the file permission on `authorized_keys`: + +```text +-bash-4.1$ chmod 600 ~/.ssh/authorized_keys +-bash-4.1$ ls -l .ssh +total 16 +-rw------- 1 enterprisedb enterprisedb 416 Apr 23 13:26 authorized_keys +-rw------- 1 enterprisedb enterprisedb 1675 Apr 23 13:11 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Apr 23 13:11 id_rsa.pub +-rw-r--r-- 1 enterprisedb enterprisedb 394 Apr 23 13:12 known_hosts +-bash-4.1$ rm /tmp/tmp.pub +-bash-4.1$ exit +logout +Connection to 192.168.2.24 closed. +``` + +While logged into the BART host, test the passwordless connection from the BART host to the remote Advanced Server host: + +```text +-bash-4.1$ ssh enterprisedb@192.168.2.24 +Last login: Thu Apr 23 13:25:53 2015 from 192.168.2.22 +-bash-4.1$ exit +logout +Connection to 192.168.2.24 closed. +``` + +### Configuring Access from a Remote PostgreSQL Server to a BART Host + +On the remote host (192.168.2.24), create a public key file owned by the database server user account (`postgres`), allowing access to the BART user account (`enterprisedb`) on the BART host (192.168.2.22). + +Create the `.ssh` directory for the `postgres` user account on the remote host: + +```text +[root@localhost 9.6]# cd /opt/PostgreSQL/9.6 +[root@localhost 9.6]# mkdir .ssh +[root@localhost 9.6]# chown postgres .ssh +[root@localhost 9.6]# chgrp postgres .ssh +[root@localhost 9.6]# chmod 700 .ssh +[root@localhost 9.6]# ls -la | grep ssh +drwx------ 2 postgres postgres 4096 Apr 23 13:32 .ssh +``` + +Create and copy the generated public key file, `id_rsa.pub`, to the BART user account (`enterprisedb`), on the BART host (`192.168.2.22`): + +```text +[user@localhost ~]$ su - postgres +Password: +-bash-4.1$ pwd +/opt/PostgreSQL/9.6 +-bash-4.1$ ssh-keygen -t rsa +Generating public/private rsa key pair. +Enter file in which to save the key (/opt/PostgreSQL/9.6/.ssh/id_rsa): +Enter passphrase (empty for no passphrase): +Enter same passphrase again: +Your identification has been saved in /opt/PostgreSQL/9.6/.ssh/id_rsa. +Your public key has been saved in /opt/PostgreSQL/9.6/.ssh/id_rsa.pub. +The key fingerprint is: +1f:f8:76:d6:fc:a5:1a:c5:5a:66:66:01:d0:a0:ca:ba +postgres@localhost.localdomain +The key's randomart image is: ++--[ RSA 2048]----+ +| o+. | +| . .. | +| . . | +| . . . . . | +| o S . O | +| . o . @ | +| . + = o .| +| . . o . o.| +| E ... .| ++-----------------+ +-bash-4.1$ ls -l .ssh +total 8 +-rw------- 1 postgres postgres 1671 Apr 23 13:36 id_rsa +-rw-r--r-- 1 postgres postgres 412 Apr 23 13:36 id_rsa.pub +-bash-4.1$ scp ~/.ssh/id_rsa.pub enterprisedb@192.168.2.22:/tmp/tmp.pub +The authenticity of host '192.168.2.22 (192.168.2.22)' can't be +established. +RSA key fingerprint is b8:a9:97:31:79:16:b8:2b:b0:60:5a:91:38:d7:68:22. +Are you sure you want to continue connecting (yes/no)? yes +Warning: Permanently added '192.168.2.22' (RSA) to the list of known +hosts. +enterprisedb@192.168.2.22's password: +id_rsa.pub +``` + +Log into the BART host as the BART user account and append the temporary public key file, `/tmp/tmp.pub`, onto the `authorized_keys` file owned by the BART user account. + +```text +-bash-4.1$ ssh enterprisedb@192.168.2.22 +enterprisedb@192.168.2.22's password: +Last login: Thu Apr 23 13:19:25 2015 from 192.168.2.24 +-bash-4.1$ pwd +/opt/PostgresPlus/9.6AS +-bash-4.1$ cat /tmp/tmp.pub >> ~/.ssh/authorized_keys +-bash-4.1$ ls -l .ssh +total 16 +-rw------- 1 enterprisedb enterprisedb 828 Apr 23 13:40 authorized_keys +-rw------- 1 enterprisedb enterprisedb 1675 Apr 23 13:04 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Apr 23 13:04 id_rsa.pub +-rw-r--r-- 1 enterprisedb enterprisedb 394 Apr 23 13:24 known_hosts +-bash-4.1$ rm /tmp/tmp.pub +-bash-4.1$ exit +logout +Connection to 192.168.2.22 closed. +``` + +Make sure the `authorized_keys` file has file permission 600 as shown, or the passwordless connection will fail. Test the passwordless connection; from the remote host, while logged in as user account `postgres`, verify that you can log into the BART host with the BART user account without being prompted for a password: + +```text +-bash-4.1$ pwd +/opt/PostgreSQL/9.6 +-bash-4.1$ ssh enterprisedb@192.168.2.22 +Last login: Thu Apr 23 13:40:10 2015 from 192.168.2.24 +-bash-4.1$ exit +logout +Connection to 192.168.2.22 closed. +``` + +### Configuring Access from the BART Host to Remote PostgreSQL + +Copy the public key file on the BART host that is owned by the BART user account (`enterprisedb`) to the remote database server user account (`postgres`), on the remote host (192.168.2.24). + +The following lists the current SSH keys files in the BART user’s `.ssh` directory on the BART host: + +```text +[user@localhost ~]$ su - enterprisedb +Password: +-bash-4.1$ ls -l .ssh +total 16 +-rw------- 1 enterprisedb enterprisedb 828 Apr 23 13:40 authorized_keys +-rw------- 1 enterprisedb enterprisedb 1675 Apr 23 13:04 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Apr 23 13:04 id_rsa.pub +-rw-r--r-- 1 enterprisedb enterprisedb 394 Apr 23 13:24 known_hosts +``` + +The public key file, `id_rsa.pub`, for BART user account `enterprisedb` on the BART host that was earlier generated in [Generating a Public Key File for the BART User Account](#generating-a-public-key-file-for-the-bart-user-account), now resides on the remote PostgreSQL host: + +```text +-bash-4.1$ scp ~/.ssh/id_rsa.pub postgres@192.168.2.24:/tmp/tmp.pub +postgres@192.168.2.24's password: +id_rsa.pub +``` + +Log into the `postgres` user account on the remote host and copy the public key file onto the `authorized_keys` file of `postgres` under its `.ssh` directory: + +```text +-bash-4.1$ ssh postgres@192.168.2.24 +postgres@192.168.2.24's password: +Last login: Mon Jan 26 18:08:36 2015 from 192.168.2.19 +-bash-4.1$ pwd +/opt/PostgreSQL/9.6 +-bash-4.1$ cat /tmp/tmp.pub >> ~/.ssh/authorized_keys +``` + +Adjust the file permissions on `authorized_keys`: + +```text +-bash-4.1$ ls -l .ssh +total 16 +-rw-rw-r-- 1 postgres postgres 416 Apr 23 13:52 authorized_keys +-rw------- 1 postgres postgres 1671 Apr 23 13:36 id_rsa +-rw-r--r-- 1 postgres postgres 412 Apr 23 13:36 id_rsa.pub +-rw-r--r-- 1 postgres postgres 394 Apr 23 13:36 known_hosts +-bash-4.1$ chmod 600 ~/.ssh/authorized_keys +-bash-4.1$ ls -l .ssh +total 16 +-rw------- 1 postgres postgres 416 Apr 23 13:52 authorized_keys +-rw------- 1 postgres postgres 1671 Apr 23 13:36 id_rsa +-rw-r--r-- 1 postgres postgres 412 Apr 23 13:36 id_rsa.pub +-rw-r--r-- 1 postgres postgres 394 Apr 23 13:36 known_hosts +-bash-4.1$ rm /tmp/tmp.pub +-bash-4.1$ exit +logout +Connection to 192.168.2.24 closed. +``` + +Test the passwordless connection from the BART host to the remote PostgreSQL host: + +```text +[user@localhost ~]$ su - enterprisedb +Password: +-bash-4.1$ ssh postgres@192.168.2.24 +Last login: Thu Apr 23 13:52:25 2015 from 192.168.2.22 +-bash-4.1$ exit +logout +Connection to 192.168.2.24 closed. +``` + + + +## Configuring a Replication Database User + +This section demonstrates how a replication database user is established. + +**All database servers must use a superuser as the replication database user.** + +The replication database user for each database server is specified by the `user` parameter in the BART configuration file as shown by the following: + +```text +[ACCTG] + +host = 127.0.0.1 +port = 5444 +user = enterprisedb <=== Replication Database User +cluster_owner = enterprisedb +backup_name = acctg_%year-%month-%dayT%hour:%minute +archive_command = 'cp %p %a/%f' +description = "Accounting" + +[MKTG] +host = 192.168.2.24 +port = 5444 +user = repuser <=== Replication Database User +cluster_owner = enterprisedb +backup_name = mktg_%year-%month-%dayT%hour:%minute +remote_host = enterprisedb@192.168.2.24 +description = "Marketing" + +[HR] + +host = 192.168.2.24 +port = 5432 +user = postgres <=== Replication Database User +cluster_owner = enterprisedb +backup_name = hr_%year-%month-%dayT%hour:%minute +remote_host = postgres@192.168.2.24 +copy_wals_during_restore = enabled +description = "Human Resources" +``` + +Add entries to the `.pgpass` file on each server to allow the BART user account to initiate a backup without being prompted for credentials. The `.pgpass` file is located in `/opt/PostgresPlus/9.6AS/.pgpass`: + +```text +127.0.0.1:5444:*:enterprisedb:password +192.168.2.24:5444:*:repuser:password +192.168.2.24:5432:*:postgres:password +``` + +For more information about using a `.pgpass` file, please see the [PostgreSQL documentation](https://www.postgresql.org/docs/current/libpq-pgpass.html). + +While connected to `MKTG` on 192.168.2.24, execute the following `CREATE ROLE` command to create the replication database superuser: + +```text +CREATE ROLE repuser WITH LOGIN SUPERUSER PASSWORD 'password'; +``` + +Access is granted in the `pg_hba.conf` file for the local Advanced Server: + +```text +# TYPE DATABASE USER ADDRESS METHOD +# "local" is for Unix domain socket connections only +local all all md5 +# IPv4 local connections: +host template1 enterprisedb 127.0.0.1/32 md5 +host edb enterprisedb 127.0.0.1/32 md5 +#host all all 127.0.0.1/32 md5 +# IPv6 local connections: +host all all ::1/128 md5 +# Allow replication connections from localhost, by a user with the +# replication privilege. +#local replication enterprisedb md5 +host replication enterprisedb 127.0.0.1/32 md5 +``` + +Similarly, access is granted in the `pg_hba.conf` file for the remote Advanced Server installation: + +```text +# TYPE DATABASE USER ADDRESS METHOD +# "local" is for Unix domain socket connections only +local all all md5 +# IPv4 local connections: +host template1 repuser 192.168.2.22/32 md5 +host all enterprisedb 127.0.0.1/32 md5 +#host all all 127.0.0.1/32 md5 +# IPv6 local connections: +host all all ::1/128 md5 +# Allow replication connections from localhost, by a user with the +# replication privilege. +#local replication enterprisedb md5 +host replication repuser 192.168.2.22/32 md5 +``` + +Access is also granted in the `pg_hba.conf` file for the remote PostgreSQL server: + +```text +# TYPE DATABASE USER ADDRESS METHOD +# "local" is for Unix domain socket connections only +local all all md5 +# IPv4 local connections: +host template1 postgres 192.168.2.22/32 md5 +host all all 127.0.0.1/32 md5 +# IPv6 local connections: +host all all ::1/128 md5 +# Allow replication connections from localhost, by a user with the +q# replication privilege. +#local replication postgres md5 +host replication postgres 192.168.2.22/32 md5 +``` + + + +## WAL Archiving Configuration Parameters + +Use the following parameters in the `postgresql.conf` file to enable WAL archiving. The `postgresql.conf` file for the local Advanced Server database (`ACCTG`) is set as follows: + +```text +wal_level = archive +archive_mode = on # allows archiving to be done + # (change requires restart) +#archive_command = '' # command to use to archive + a logfile segment + # placeholders: %p = path of + file to archive + # %f = file name only +max_wal_senders = 3 +``` + +When the `INIT` subcommand is invoked, the Postgres `archive_command` configuration parameter in the `postgresql.auto.conf` file will be set based on the BART `archive_command` parameter located in the BART configuration file. + +!!! Note + If the Postgres `archive_command` is already set, invoke the `INIT` subcommand with the `-- no-configure` option to prevent the `archive_command` from being reset. For details, see [INIT](../bart_user/03_using_bart/03_basic_bart_subcommand_usage/02_init/#init). + +```text +[BART] +bart_host= enterprisedb@192.168.2.22 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +retention_policy = 6 BACKUPS +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log + +[ACCTG] +host = 127.0.0.1 +port = 5444 +user = enterprisedb +cluster_owner = enterprisedb +backup_name = acctg_%year-%month-%dayT%hour:%minute +archive_command = 'cp %p %a/%f' +description = "Accounting" +``` + +When the `INIT` subcommand is invoked, the `postgresql.auto.conf` file contains the following: + +```text +# Do not edit this file manually! +# It will be overwritten by ALTER SYSTEM command. +archive_command = 'cp %p /opt/backup/acctg/archived_wals/%f' +``` + +The `archive_command` uses the `cp` command instead of `scp` since the BART backup catalog is local to this database cluster and the BART user account (the account that owns the backup catalog, `enterprisedb`), is the same user account running Advanced Server. The result is that there is no directory permission conflict during the archive operation. + +The `postgresql.conf` file for the remote Advanced Server, `MKTG` is set as follows: + +```text +wal_level = archive +archive_mode = on # allows archiving to be done + # (change requires restart) +archive_command = '' # command to use to archive a + logfile segment + # placeholders: %p = path of + file to archive + # %f = file name only +max_wal_senders = 3 +``` + +When the `INIT` subcommand is invoked, the Postgres `archive_command` configuration parameter in the `postgresql.auto.conf` file will be set by the default BART format of the BART `archive_command` parameter (since it is not explicitly set for this database server in the BART configuration file). + +```text +[BART] +bart_host= enterprisedb@192.168.2.22 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +retention_policy = 6 BACKUPS +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log +. +. +. +[MKTG] + +host = 192.168.2.24 +port = 5444 +user = repuser +cluster_owner = enterprisedb +backup_name = mktg_%year-%month-%dayT%hour:%minute +remote_host = enterprisedb@192.168.2.24 +description = "Marketing" +``` + +The default BART `archive_command` format is: + +```text +archive_command = 'scp %p %h:%a/%f' +``` + +The `postgresql.auto.conf` file contains the following after the `INIT` subcommand is invoked: + +```text +# Do not edit this file manually! +# It will be overwritten by ALTER SYSTEM command. +archive_command = 'scp %p +enterprisedb@192.168.2.22:/opt/backup/hr/archived_wals/%f' +``` + +The `archive_command` uses the `scp` command since the BART backup catalog is remote relative to this database cluster. The BART user account, `enterprisedb`, is specified on the `scp` command since this is the user account owning the BART backup catalog where the archived WAL files are to be copied. The result is that there is no directory permission conflict during the archive operation. + +The `postgresql.conf` file for the remote PostgreSQL server (`HR`) is set as follows: + +```text +wal_level = archive +archive_mode = on # allows archiving to be done + # (change requires restart) +#archive_command = '' # command to use to archive a + logfile segment + # placeholders: %p = path of + file to archive + # %f = file name only +max_wal_senders = 3 +``` + +When the `INIT` subcommand is invoked, the Postgres `archive_command` configuration parameter in the `postgresql.auto.conf` file will be set by the default BART format of the BART `archive_command` parameter (since it is not explicitly set for this database server in the BART configuration file): + +```text +[BART] + +bart_host= enterprisedb@192.168.2.22 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +retention_policy = 6 BACKUPS +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log +. +. +. +[HR] + +host = 192.168.2.24 +port = 5432 +user = postgres +cluster_owner = postgres +backup_name = hr_%year-%month-%dayT%hour:%minute +remote_host = postgres@192.168.2.24 +copy_wals_during_restore = enabled +description = "Human Resources" +``` + +The default BART `archive_command` format is: + +```text +archive_command = 'scp %p %h:%a/%f' +``` + +The `postgresql.auto.conf` file contains the following after the `INIT` subcommand is invoked: + +```text +# Do not edit this file manually! +# It will be overwritten by ALTER SYSTEM command. +archive_command = 'scp %p +enterprisedb@192.168.2.22:/opt/backup/hr/archived_wals/%f' +``` + +The `archive_command` uses the `scp` command since the BART backup catalog is remote relative to this database cluster. The BART user account, `enterprisedb`, is specified on the `scp` command since this is the user account owning the BART backup catalog where the archived WAL files are to be copied. The result is that there is no directory permission conflict during the archive operation. + + + +## Creating the BART Backup Catalog (backup_path) + +Create the directory specified by the `backup_path` configuration parameter. + +```text +[BART] + +bart_host= enterprisedb@192.168.2.22 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +retention_policy = 6 BACKUPS +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log +``` + +Ensure that the directory is owned by the BART user account: + +```text +[root@localhost opt]# pwd +/opt +[root@localhost opt]# mkdir backup +[root@localhost opt]# chown enterprisedb backup +[root@localhost opt]# chgrp enterprisedb backup +[root@localhost opt]# chmod 700 backup +[root@localhost opt]# ls -l | grep backup +drwx------ 2 enterprisedb enterprisedb 4096 Apr 23 15:36 backup +``` + +Use the BART `INIT` subcommand to complete the directory structure and set the Postgres `archive_command` configuration parameter. + +Before invoking any BART subcommands, set up a profile under the BART user account’s home directory to set the `LD_LIBRARY_PATH` and `PATH` environment variables. For more information regarding setting this variable, see the EDB Backup and Recovery Installation and Upgrade Guide available at the [EDB website](/bart/latest/bart_inst/). + +The `-o` option is specified with the `INIT` subcommand to force the setting of the Postgres `archive_command` configuration parameter when `archive_mode` is `off` or if the Postgres `archive_command` parameter is already set and needs to be overridden. + +```text +[user@localhost ~]$ su - enterprisedb +Password: +-bash-4.1$ bart INIT -o +INFO: setting archive_command for server 'acctg' +WARNING: archive_command is set. server restart is required +INFO: setting archive_command for server 'hr' +WARNING: archive_command is set. server restart is required +INFO: setting archive_command for server 'mktg' +WARNING: archive_command is set. server restart is required +``` + +The BART `SHOW-SERVERS` subcommand displays the following: + +```text +-bash-4.1$ bart SHOW-SERVERS +SERVER NAME : acctg +BACKUP FRIENDLY NAME: acctg_%year-%month-%dayT%hour:%minute +HOST NAME : 127.0.0.1 +USER NAME : enterprisedb +PORT : 5444 +REMOTE HOST : +RETENTION POLICY : 6 Backups +DISK UTILIZATION : 0.00 bytes +NUMBER OF ARCHIVES : 0 +ARCHIVE PATH : /opt/backup/acctg/archived_wals +ARCHIVE COMMAND : (disabled) +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +INCREMENTAL BACKUP : DISABLED +DESCRIPTION : "Accounting" +SERVER NAME : hr +BACKUP FRIENDLY NAME: hr_%year-%month-%dayT%hour:%minute +HOST NAME : 192.168.2.24 +USER NAME : postgres +PORT : 5432 +REMOTE HOST : postgres@192.168.2.24 +RETENTION POLICY : 6 Backups +DISK UTILIZATION : 0.00 bytes +NUMBER OF ARCHIVES : 0 +ARCHIVE PATH : /opt/backup/hr/archived_wals +ARCHIVE COMMAND : (disabled) +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +INCREMENTAL BACKUP : DISABLED +DESCRIPTION : "Human Resources" +SERVER NAME : mktg +BACKUP FRIENDLY NAME: mktg_%year-%month-%dayT%hour:%minute +HOST NAME : 192.168.2.24 +USER NAME : repuser +PORT : 5444 +REMOTE HOST : enterprisedb@192.168.2.24 +RETENTION POLICY : 6 Backups +DISK UTILIZATION : 0.00 bytes +NUMBER OF ARCHIVES : 0 +ARCHIVE PATH : /opt/backup/mktg/archived_wals +ARCHIVE COMMAND : (disabled) +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +INCREMENTAL BACKUP : DISABLED +DESCRIPTION : "Marketing" +-bash-4.1$ cd /opt/backup +-bash-4.1$ pwd +/opt/backup +-bash-4.1$ ls -l +total 12 +drwxrwxr-x 3 enterprisedb enterprisedb 4096 Mar 29 13:16 acctg +drwxrwxr-x 3 enterprisedb enterprisedb 4096 Mar 29 13:16 hr +drwxrwxr-x 3 enterprisedb enterprisedb 4096 Mar 29 13:16 mktg +-bash-4.1$ ls -l acctg +total 4 +drwxrwxr-x 2 enterprisedb enterprisedb 4096 Mar 29 13:16 archived_wals +-bash-4.1$ ls -l hr +total 4 +drwxrwxr-x 2 enterprisedb enterprisedb 4096 Mar 29 13:16 archived_wals +-bash-4.1$ ls -l mktg +total 4 +drwxrwxr-x 2 enterprisedb enterprisedb 4096 Mar 29 13:16 archived_wals +``` + +The `ARCHIVE PATH` field displays the full directory path to where the WAL files are copied. This directory path must match the directory path specified in the Postgres `archive_command` parameter of the `postgresql.conf` file or the `postgresql.auto.conf` file of each database server. + + + +### Starting the Database Servers with WAL Archiving + +After the BART backup catalog directory structure has been configured, start the archiving of WAL files from the database servers by restarting each database server. + +On BART host 192.168.2.22: + +```text +[root@localhost data]# service ppas-9.6 restart +``` + +On remote host 192.168.2.24: + +```text +[root@localhost data]# service ppas-9.6 restart + +[root@localhost data]# service postgresql-9.6 restart +``` + +In the BART backup catalog, verify that the WAL files are archiving. + +Archived WAL files may not appear very frequently depending upon how often WAL archiving is set to switch to a new segment file with the `archive_timeout` parameter in your database server configuration settings. + +Verify that there are no archiving-related errors in the database server log files. + +## Taking a Full Backup + +The following code sample shows the first full backup of the database servers. + +```text +-bash-4.1$ bart BACKUP -s acctg -z +INFO: creating backup for server 'acctg' +INFO: backup identifier: '1490809695281' +60776/60776 kB (100%), 1/1 tablespace + +INFO: backup completed successfully +INFO: backup checksum: 37f3defb98ca88dcf05079815555dfc2 of base.tar.gz +INFO: +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1490809695281 +BACKUP NAME: acctg_2017-03-29T13:48 +BACKUP PARENT: none +BACKUP LOCATION: /opt/backup/acctg/1490809695281 +BACKUP SIZE: 6.10 MB +BACKUP FORMAT: tar.gz +BACKUP TIMEZONE: US/Eastern +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 1 +ChkSum File +37f3defb98ca88dcf05079815555dfc2 base.tar.gz + +TABLESPACE(s): 0 +START WAL LOCATION: 000000010000000000000004 +STOP WAL LOCATION: 000000010000000000000004 +BACKUP METHOD: streamed +BACKUP FROM: primary +START TIME: 2017-03-29 13:48:15 EDT +STOP TIME: 2017-03-29 13:48:17 EDT +TOTAL DURATION: 2 sec(s) + +-bash-4.1$ bart BACKUP -s mktg -z +INFO: creating backup for server 'mktg' +INFO: backup identifier: '1490809751193' +61016/61016 kB (100%), 1/1 tablespace + +INFO: backup completed successfully +INFO: backup checksum: 8b010e130a105e76d01346bb56dfcf14 of base.tar.gz +INFO: +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1490809751193 +BACKUP NAME: mktg_2017-03-29T13:49 +BACKUP PARENT: none +BACKUP LOCATION: /opt/backup/mktg/1490809751193 +BACKUP SIZE: 6.13 MB +BACKUP FORMAT: tar.gz +BACKUP TIMEZONE: US/Eastern +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 1 +ChkSum File +8b010e130a105e76d01346bb56dfcf14 base.tar.gz + +TABLESPACE(s): 0 +START WAL LOCATION: 000000010000000100000085 +BACKUP METHOD: streamed +BACKUP FROM: primary +START TIME: 2017-03-29 13:49:11 EDT +STOP TIME: 2017-03-29 13:49:14 EDT +TOTAL DURATION: 3 sec(s) + +-bash-4.1$ bart BACKUP -s hr -z +INFO: creating backup for server 'hr' +INFO: backup identifier: '1490809824946' +38991/38991 kB (100%), 1/1 tablespace +INFO: backup completed successfully +INFO: backup checksum: 277e8a1a80ba3474f541eb316a417c9a of base.tar.gz +INFO: +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1490809824946 +BACKUP NAME: hr_2017-03-29T13:50 +BACKUP PARENT: none +BACKUP LOCATION: /opt/backup/hr/1490809824946 +BACKUP SIZE: 2.59 MB +BACKUP FORMAT: tar.gz +BACKUP TIMEZONE: US/Eastern +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 1 +ChkSum File +277e8a1a80ba3474f541eb316a417c9a base.tar.gz + +TABLESPACE(s): 0 +START WAL LOCATION: 000000010000000000000002 +BACKUP METHOD: streamed +BACKUP FROM: primary +START TIME: 2017-03-29 13:50:25 EDT +STOP TIME: 2017-03-29 13:50:26 EDT +TOTAL DURATION: 1 sec(s) +``` + +The following code sample shows the backup directories created for each backup of each database server. The backup ID is used as the backup directory name. + +```text +-bash-4.1$ cd /opt/backup +-bash-4.1$ ls -l +total 12 +drwxrwxr-x 4 enterprisedb enterprisedb 4096 Mar 29 13:48 acctg +drwxrwxr-x 4 enterprisedb enterprisedb 4096 Mar 29 13:50 hr +drwxrwxr-x 4 enterprisedb enterprisedb 4096 Mar 29 13:49 mktg +-bash-4.1$ ls -l acctg +total 8 +drwx------ 2 enterprisedb enterprisedb 4096 Mar 29 13:48 1490809695281 +drwxrwxr-x 2 enterprisedb enterprisedb 4096 Mar 29 13:48 archived_wals +-bash-4.1$ ls -l hr +total 8 +drwx------ 2 enterprisedb enterprisedb 4096 Mar 29 13:50 1490809824946 +drwxrwxr-x 2 enterprisedb enterprisedb 4096 Mar 29 13:50 archived_wals +-bash-4.1$ ls -l mktg +total 8 +drwx------ 2 enterprisedb enterprisedb 4096 Mar 29 13:49 1490809751193 +drwxrwxr-x 2 enterprisedb enterprisedb 4096 Mar 29 13:49 archived_wals +``` + + + +## Using Point-In-Time Recovery + +This section demonstrates using the point-in-time recovery operation on the remote PostgreSQL database server. + +The following tables were created about two minutes apart with WAL archiving enabled: + +```text +postgres=# \dt + + List of relations +Schema | Name | Type | Owner + +--------+----------------+---------+--------- +public | hr_rmt_t1_1356 | table | postgres +public | hr_rmt_t1_1358 | table | postgres +public | hr_rmt_t1_1400 | table | postgres +public | hr_rmt_t1_1402 | table | postgres +public | hr_rmt_t1_1404 | table | postgres +public | hr_rmt_t1_1406 | table | postgres +(6 rows) +``` + +In the table name `hr_rmt_t_, n` represents the active timeline. `` is the approximate time the table was created. For example, `hr_rmt_t1_1356` was created at approximately 1:56 PM while timeline #1 is active. + +The PostgreSQL database server was then stopped. WAL files that have been created, but not yet archived must be identified, and then saved. The following archived WAL files are in the BART backup catalog: + +```text +-bash-4.1$ ls -l hr/archived_wals +total 49156 +-rw------- 1 enterprisedb enterprisedb 16777216 Mar 29 13:50 +000000010000000000000001 +-rw------- 1 enterprisedb enterprisedb 16777216 Mar 29 13:50 +000000010000000000000002 +-rw------- 1 enterprisedb enterprisedb 302 Mar 29 13:50 +000000010000000000000002.00000028.backup +-rw------- 1 enterprisedb enterprisedb 16777216 Mar 29 14:07 +000000010000000000000003 +``` + +The following sample lists the current PostgreSQL server WAL files. The unarchived WAL files are marked with two stars (\*\*). + +```text +-bash-4.1$ cd /opt/PostgreSQL/9.6/data/pg_xlog +-bash-4.1$ pwd +/opt/PostgreSQL/9.6/data/pg_xlog +-bash-4.1$ ls -l +total 49160 +-rw------- 1 postgres postgres 302 Mar 29 13:50 +000000010000000000000002.00000028.backup +-rw------- 1 postgres postgres 16777216 Mar 29 14:07 +000000010000000000000003 +-rw------- 1 postgres postgres 16777216 Mar 29 14:07 +**000000010000000000000004** +-rw------- 1 postgres postgres 16777216 Mar 29 13:50 +**000000010000000000000005** +drwx------ 2 postgres postgres 4096 Mar 29 14:07 archive_status +``` + +Copies of the unarchived WAL files are saved to a temporary location: + +```text +-bash-4.1$ mkdir /tmp/unarchived_pg96_wals +-bash-4.1$ pwd +/opt/PostgreSQL/9.6/data/pg_xlog +bash-4.1$ cp -p 000000010000000000000004 /tmp/unarchived_pg96_wals +bash-4.1$ cp -p 000000010000000000000005 /tmp/unarchived_pg96_wals +bash-4.1$ ls -l /tmp/unarchived_pg96_wals +total 32768 +-rw------- 1 postgres postgres 16777216 Mar 29 14:07 000000010000000000000004 +-rw------- 1 postgres postgres 16777216 Mar 29 13:50 000000010000000000000005 +``` + +On the remote host, a directory is created to which the PostgreSQL database cluster is to be restored. This restore path is named `/opt/restore_pg96` and is owned by user account `postgres`. + +```text +[user@localhost ~]$ su root +Password: +[root@localhost user]# cd /opt +[root@localhost opt]# mkdir restore_pg96 +[root@localhost opt]# chown postgres restore_pg96 +[root@localhost opt]# chgrp postgres restore_pg96 +[root@localhost opt]# chmod 700 restore_pg96 +[root@localhost opt]# ls -l +total 16 +drwxr-xr-x 4 root daemon 4096 Mar 29 12:10 PostgresPlus +drwxr-xr-x 3 root daemon 4096 Mar 29 12:25 PostgreSQL +drwx------ 2 postgres postgres 4096 Mar 29 14:15 restore_pg96 +drwxr-xr-x. 2 root root 4096 Nov 22 2013 rh +``` + +In the BART configuration file, the remote user and remote host IP address, `postgres@192.168.2.24`, have been set with the `remote_host` parameter. If not given in the BART configuration file, this information must then be specified by the `--remote-host` option when giving the `RESTORE` subcommand (for example, `bart RESTORE --remote-host postgres@192.168.2.24 …`). + +```text +[HR] + +host = 192.168.2.24 +port = 5432 +user = postgres +cluster_owner = postgres +backup_name = hr_%year-%month-%dayT%hour:%minute +remote_host = postgres@192.168.2.24 +copy_wals_during_restore = enabled +description = "Human Resources" +``` + +Use the `SHOW-BACKUPS` subcommand to identify the backup to use with the `RESTORE` subcommand. + +```text +SERVER NAME BACKUP ID BACKUP NAME BACKUP PARENT +BACKUP TIME +BACKUP SIZE WAL(s) SIZE WAL FILES STATUS +acctg 1490809695281 acctg_2017-03-29T13:48 none +2017-03-29 13:48:17 EDT +6.10 MB 32.00 MB 2 active +hr 1490809824946 hr_2017-03-29T13:50 none +2017-03-29 13:50:26 EDT +2.59 MB 32.00 MB 2 active +mktg 1490809751193 mktg_2017-03-29T13:49 none +2017-03-29 13:49:14 EDT +6.13 MB 64.00 MB 4 active +``` + +The `-t` option with the `SHOW-BACKUPS` subcommand displays additional backup information: + +```text +-bash-4.1$ bart SHOW-BACKUPS -s hr -i 1490809824946 -t +SERVER NAME : hr +BACKUP ID : 1490809824946 +BACKUP NAME : hr_2017-03-29T13:50 +BACKUP PARENT : none +BACKUP STATUS : active +BACKUP TIME : 2017-03-29 13:50:26 EDT +BACKUP SIZE : 2.59 MB +WAL(S) SIZE : 32.00 MB +NO. OF WALS : 2 +FIRST WAL FILE : 000000010000000000000002 +CREATION TIME : 2017-03-29 13:50:31 EDT +LAST WAL FILE : 000000010000000000000003 +CREATION TIME : 2017-03-29 14:07:35 EDT +``` + +A recovery is made using timeline `1` to `2017-03-29 14:01:00`. + +```text +-bash-4.1$ bart RESTORE -s hr -i hr_2017-03-29T13:50 -p +/opt/restore_pg96 -t 1 -g '2017-03-29 14:01:00' +INFO: restoring backup 'hr_2017-03-29T13:50' of server 'hr' +INFO: base backup restored +INFO: copying WAL file(s) to +postgres@192.168.2.24:/opt/restore_pg96/archived_wals +INFO: writing recovery settings to postgresql.auto.conf file +INFO: archiving is disabled +INFO: permissions set on $PGDATA +INFO: restore completed successfully +``` + +The following example shows the restored backup files in the restore path directory, `/opt/restore_pg96`: + +```text +-bash-4.1$ pwd +/opt/restore_pg96 +-bash-4.1$ ls -l +total 128 +drwxr-xr-x 2 postgres postgres 4096 Mar 29 14:27 archived_wals +-rw------- 1 postgres postgres 206 Mar 29 13:50 backup_label +drwx------ 5 postgres postgres 4096 Mar 29 12:25 base +drwx------ 2 postgres postgres 4096 Mar 29 14:27 global +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_clog +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_commit_ts +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_dynshmem +-rw------- 1 postgres postgres 4212 Mar 29 13:18 pg_hba.conf +-rw------- 1 postgres postgres 1636 Mar 29 12:25 pg_ident.conf +drwxr-xr-x 2 postgres postgres 4096 Mar 29 13:45 pg_log +drwx------ 4 postgres postgres 4096 Mar 29 12:25 pg_logical +drwx------ 4 postgres postgres 4096 Mar 29 12:25 pg_multixact +drwx------ 2 postgres postgres 4096 Mar 29 13:43 pg_notify +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_replslot +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_serial +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_snapshots +drwx------ 2 postgres postgres 4096 Mar 29 13:43 pg_stat +drwx------ 2 postgres postgres 4096 Mar 29 13:50 pg_stat_tmp +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_subtrans +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_tblspc +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_twophase +-rw------- 1 postgres postgres 4 Mar 29 12:25 PG_VERSION +drwx------ 3 postgres postgres 4096 Mar 29 14:27 pg_xlog +-rw------- 1 postgres postgres 169 Mar 29 13:24 postgresql.auto.conf +-rw-r--r-- 1 postgres postgres 21458 Mar 29 14:27 postgresql.conf +-rw-r--r-- 1 postgres postgres 118 Mar 29 14:27 postgresql.auto.conf +``` + +Copy the saved, unarchived WAL files to the restore path `pg_xlog` subdirectory (`/opt/restore_pg96/pg_xlog`): + +```text +-bash-4.1$ pwd +/opt/restore_pg96/pg_xlog +-bash-4.1$ ls -l +total 16388 +-rw------- 1 postgres postgres 16777216 Mar 29 13:50 +000000010000000000000002 +drwx------ 2 postgres postgres 4096 Mar 29 14:27 archive_status +-bash-4.1$ ls -l /tmp/unarchived_pg96_wals +total 32768 +-rw------- 1 postgres postgres 16777216 Mar 29 14:07 +000000010000000000000004 +-rw------- 1 postgres postgres 16777216 Mar 29 13:50 +000000010000000000000005 +-bash-4.1$ cp -p /tmp/unarchived_pg96_wals/* . +-bash-4.1$ ls -l +total 49156 +-rw------- 1 postgres postgres 16777216 Mar 29 13:50 +000000010000000000000002 +-rw------- 1 postgres postgres 16777216 Mar 29 14:07 +000000010000000000000004 +-rw------- 1 postgres postgres 16777216 Mar 29 13:50 +000000010000000000000005 +drwx------ 2 postgres postgres 4096 Mar 29 14:27 archive_status +``` + +Inspect the `/opt/restore_pg96/postgresql.auto.conf` file to verify that it contains the correct recovery settings: + +```text +restore_command = 'cp archived_wals/%f %p' +recovery_target_time = '2017-03-29 14:01:00' +recovery_target_timeline = 1 +``` + +Note that the command restores from the `archived_wals` subdirectory of `/opt/restore_pg96` since the `copy_wals_during_restore` parameter in the BART configuration file is set to `enabled` for database server `hr`. + +Start the database server to initiate the point-in-time recovery operation: + +```text +[user@localhost ~]$ su postgres +Password: +bash-4.1$ cd /opt/restore_pg96 +bash-4.1$ /opt/PostgreSQL/9.6/bin/pg_ctl start -D /opt/restore_pg96 -l +/opt/restore_pg96/pg_log/logfile +server starting +``` + +Inspect the database server log file to ensure the operation did not result in any errors: + +```text +2017-03-29 14:33:23 EDT LOG: database system was interrupted; last known +up at 2017-03-29 13:50:25 EDT +2017-03-29 14:33:23 EDT LOG: starting point-in-time recovery to +2017-03-29 14:01:00-04 +2017-03-29 14:33:23 EDT LOG: restored log file +"000000010000000000000002" from archive +2017-03-29 14:33:23 EDT LOG: redo starts at 0/2000098 +2017-03-29 14:33:23 EDT LOG: consistent recovery state reached at +0/20000C0 +2017-03-29 14:33:23 EDT LOG: restored log file +"000000010000000000000003" from archive +2017-03-29 14:33:23 EDT LOG: recovery stopping before commit of +transaction 1762, time 2017-03-29 14:02:28.100072-04 +2017-03-29 14:33:23 EDT LOG: redo done at 0/303F390 +2017-03-29 14:33:23 EDT LOG: last completed transaction was at log time +2017-03-29 14:00:43.351333-04 +cp: cannot stat `archived_wals/00000002.history': No such file or +directory +2017-03-29 14:33:23 EDT LOG: selected new timeline ID: 2 +cp: cannot stat `archived_wals/00000001.history': No such file or +directory +2017-03-29 14:33:23 EDT LOG: archive recovery complete +2017-03-29 14:33:23 EDT LOG: MultiXact member wraparound protections are +now enabled +2017-03-29 14:33:23 EDT LOG: database system is ready to accept +connections +2017-03-29 14:33:23 EDT LOG: autovacuum launcher started +``` + +The tables that exist in the recovered database cluster are: + +```text +postgres=# \dt + List of relations +Schema | Name | Type | Owner +--------+----------------+-------+---------- +public | hr_rmt_t1_1356 | table | postgres +public | hr_rmt_t1_1358 | table | postgres +public | hr_rmt_t1_1400 | table | postgres +(3 rows) +``` + +Since recovery was up to and including 2017-03-29 14:01:00, the following tables created after 14:01 are not present: + +```text +public | hr_rmt_t1_1402 | table | postgres +public | hr_rmt_t1_1404 | table | postgres +public | hr_rmt_t1_1406 | table | postgres +``` + +The BART `RESTORE` operation stops WAL archiving by adding an `archive_mode = off` parameter at the very end of the `postgresql.conf` file. This last parameter in the file overrides any other previous setting of the same parameter in the file. Delete the last setting and restart the database server to start WAL archiving. + +```text +# Add settings for extensions here +archive_mode = off +``` diff --git a/product_docs/docs/bart/2.5.9/bart_ref/images/EDB_logo.png b/product_docs/docs/bart/2.5.9/bart_ref/images/EDB_logo.png new file mode 100644 index 00000000000..39a54822d85 Binary files /dev/null and b/product_docs/docs/bart/2.5.9/bart_ref/images/EDB_logo.png differ diff --git a/product_docs/docs/bart/2.5.9/bart_ref/images/edb.png b/product_docs/docs/bart/2.5.9/bart_ref/images/edb.png new file mode 100644 index 00000000000..71e5bdde787 Binary files /dev/null and b/product_docs/docs/bart/2.5.9/bart_ref/images/edb.png differ diff --git a/product_docs/docs/bart/2.5.9/bart_ref/images/edb_logo.svg b/product_docs/docs/bart/2.5.9/bart_ref/images/edb_logo.svg new file mode 100644 index 00000000000..f24d1dfefee --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_ref/images/edb_logo.svg @@ -0,0 +1,19 @@ + + + edb-logo-disc-dark + + + + \ No newline at end of file diff --git a/product_docs/docs/bart/2.5.9/bart_ref/images/image2.png b/product_docs/docs/bart/2.5.9/bart_ref/images/image2.png new file mode 100644 index 00000000000..4eba2e7efa7 Binary files /dev/null and b/product_docs/docs/bart/2.5.9/bart_ref/images/image2.png differ diff --git a/product_docs/docs/bart/2.5.9/bart_ref/index.mdx b/product_docs/docs/bart/2.5.9/bart_ref/index.mdx new file mode 100644 index 00000000000..6a8817bd039 --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_ref/index.mdx @@ -0,0 +1,33 @@ +--- +navTitle: Reference Guide +title: "EDB Postgres Backup and Recovery Reference Guide" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/genindex.html" + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/conclusion.html" + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/index.html" +--- + +This guide acts as a quick reference for BART subcommands and provides comprehensive examples of the following BART operations: + +- Performing a full backup of database servers +- Performing a point-in-time recovery (PITR) on a remote PostgreSQL database server +- Restoring an incremental backup +- Restoring a database cluster with tablespaces +- Evaluating, marking, and deleting backups and incremental backups +- Configuring and operating local and remote database servers + +For detailed information about BART subcommands and operations, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/latest/bart_user/). + +The document is organized as follows: + +- See [Subcommands](01_bart_subcommands_examples/#using_bart_subcommands) to view BART subcommand examples. +- See [Examples](02_additional_examples/#examples) to view BART operations examples. +- See [Sample BART System](03_sample_bart_system_with_local_and_remote_database_servers/#a_sample_bart_system_with_local_and_remote_database_servers) to view examples of both local and remote database server configuration and operation. + +
+ +bart_subcommands_examples additional_examples sample_bart_system_with_local_and_remote_database_servers conclusion + +
diff --git a/product_docs/docs/bart/2.5.9/bart_user/01_introduction.mdx b/product_docs/docs/bart/2.5.9/bart_user/01_introduction.mdx new file mode 100644 index 00000000000..1212b2847bf --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_user/01_introduction.mdx @@ -0,0 +1,55 @@ +--- +title: "Introduction" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/introduction.html" +--- + +The EDB Backup and Recovery Tool (BART) is an administrative utility that provides simplified backup and recovery management for multiple local or remote EDB Advanced Server and PostgreSQL database servers. + +BART provides the following features: + +- Support for complete, hot, physical backups of multiple Advanced Servers and PostgreSQL database servers +- Support for two types of backups – full base backups and block-level incremental backups +- Backup and recovery management of database servers on local or remote hosts +- A single, centralized catalog for backup data +- Retention policy support for defining and managing how long backups should be kept +- The capability to store the backup data in compressed format +- Verified backup data with checksums +- Backup information displayed in an easy-to-read format +- A simplified point-in-time recovery process + +This guide provides the following information about using BART: + +- an [overview](02_overview/#overview) of the BART components and concepts. +- [backup and recovery management process](03_using_bart/#using_bart). +- [using tablespaces](04_using_tablespaces/#using_tablespaces). + +For information about installing BART, see the *EDB Backup and Recovery Installation and Upgrade Guide*; for examples of BART operations and subcommand usage, see the *EDB Backup and Recovery Reference Guide*. These guides are available at the [EDB website](/bart/latest/bart_inst/). + + + +## Conventions Used in this Guide + +The following is a list of conventions used throughout this document. + +- Much of the information in this document applies interchangeably to the PostgreSQL and EDB Advanced Server database systems. The term *Advanced Server* is used to refer to EDB Advanced Server. The term *Postgres* is used to generically refer to both PostgreSQL and Advanced Server. When a distinction needs to be made between these two database systems, the specific names, PostgreSQL or Advanced Server are used. + +- The installation directory of the PostgreSQL or Advanced Server products is referred to as `POSTGRES_INSTALL_HOME`: + + - For PostgreSQL Linux installations, this defaults to `/opt/PostgreSQL/` for version 10 and earlier. For later versions, the installation directory is `/var/lib/pgsql/`. + - For Advanced Server Linux installations performed using the interactive installer for version 10 and earlier, this defaults to `/opt/PostgresPlus/AS` or `/opt/edb/as`. For Advanced Server Linux installations performed with an RPM package, this defaults to `/usr/ppas-` or `/usr/edb/as`. For Advanced Server Linux installations performed with an RPM package for version 11 or later, this defaults to `/usr/edb/as`. + +## Restrictions on pg_basebackup + +BART takes full backups using the `pg_basebackup` utility program under the following conditions: + +- The backup is taken on a standby server. +- The `--with-pg_basebackup` option is specified with the `BACKUP` subcommand (see [Backup](03_using_bart/03_basic_bart_subcommand_usage/03_backup/#backup)). +- The number of thread count in effect is 1, and the `with-pg_basebackup` option is not specified with the `BACKUP` subcommand. +- Database servers can only be backed up using `pg_basebackup` utility program of the same or later version than the database server version. + +In the global section of the BART configuration file, the `pg_basebackup_path` parameter specifies the complete directory path to the `pg_basebackup` program. For information about the `pg_basebackup_path` parameter and the `thread_count`, see the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/latest/bart_inst/). + +For information about `pg_basebackup`, see the [PostgreSQL Core Documentation](https://postgresql.org/docs/current/static/app-pgbasebackup.html). diff --git a/product_docs/docs/bart/2.5.9/bart_user/02_overview/01_block-level_incremental_backup/01_incremental_backup_limitations_and_requirements.mdx b/product_docs/docs/bart/2.5.9/bart_user/02_overview/01_block-level_incremental_backup/01_incremental_backup_limitations_and_requirements.mdx new file mode 100644 index 00000000000..a3fe8894d09 --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_user/02_overview/01_block-level_incremental_backup/01_incremental_backup_limitations_and_requirements.mdx @@ -0,0 +1,42 @@ +--- +title: "Incremental Backup Limitations and Requirements" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/incremental_backup_limitations_and_requirements.html" +--- + + + +The following limitations apply to incremental backup: + +- If you have restored a full or incremental backup, you must take a full backup before enabling incremental backup. +- If a standby node has been promoted to the role of a primary node, you must take a full backup before enabling incremental backup on the cluster. +- On a standby database server, you cannot take an incremental backup. + +You must meet the following requirements before implementing incremental backup: + +- You must create or select an operating system account to be used as the BART user account. + +- You must create or select the replication database user, which must be a superuser. + +- In the BART configuration file: + + - You must set the `cluster_owner` parameter to the Linux operating system user account that owns the database cluster directory from which incremental backups are to be taken. + - You must enable the `allow_incremental_backups` parameter. + +- A passwordless SSH/SCP connection must be established between the BART user account on the BART host and the `cluster_owner` user account on the database server. + + It must be noted that a passwordless SSH/SCP connection must be established even if BART and the database server are running on the same host and the BART user account and the `cluster_owner` user account are the same account. + +- In addition to the BART host (where the BART backup catalog resides), the BART package must also be installed on every remote database server on which incremental backups are to be restored. To restore an incremental backup, the `bart` program must be executable on the remote host by the remote user (the remote user is specified by the `remote_host` parameter in the BART configuration file or by the `-r` option when using the `RESTORE` subcommand to restore the incremental backup). + +- When [restoring incremental backups on a remote database server](05_restoring_an_incremental_backup/#restoring-an-incremental-backup-on-a-remote-host), a passwordless SSH/SCP connection must be established from the BART user account on the BART host to the remote user on the remote host (the remote user is specified by the `remote_host` parameter in the BART configuration file or by the `-r` option when using the `RESTORE` subcommand to restore the incremental backup). + +- Compression of archived WAL files in the BART backup catalog is not permitted for database servers on which incremental backups are to be taken. The `wal_compression` setting in the BART configuration file must be disabled for those database servers. + +- The incremental backup must be on the same timeline as the parent backup. The timeline changes after each recovery operation so an incremental backup cannot use a parent backup from an earlier timeline. + +For information about configuring these requirements, see the EDB Backup and Recovery Installation and Upgrade Guide available at the [EDB website](/bart/latest/bart_inst/). + +The following section provides an overview of the basic incremental backup concepts. diff --git a/product_docs/docs/bart/2.5.9/bart_user/02_overview/01_block-level_incremental_backup/02_concept_overview.mdx b/product_docs/docs/bart/2.5.9/bart_user/02_overview/01_block-level_incremental_backup/02_concept_overview.mdx new file mode 100644 index 00000000000..8183d4802bd --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_user/02_overview/01_block-level_incremental_backup/02_concept_overview.mdx @@ -0,0 +1,33 @@ +--- +title: "Concept Overview" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/concept_overview.html" +--- + + + +Using incremental backups involves the following sequence of steps: + +1. Configure BART, and enable and initiate archiving of WAL files to the `archive_path` in the same manner as done for full backups. + + The default `archive_path` is the BART backup catalog (`//archived_wals`). Using the `` parameter in the server section of the BART configuration file, you can specify the location where WAL files will be archived. + + For more information about the `archive_path` parameter and configuring BART, see the EDB Backup and Recovery Installation and Upgrade Guide available at the [EDB website](/bart/latest/bart_inst/). + +2. Take an initial full backup with the `BACKUP` subcommand. This full backup establishes the parent of the first incremental backup. + +3. Scan all WAL files produced by database servers on which incremental backups are to be taken. These WAL files are scanned once they have been archived to the `archive_path`. + + Each scanned WAL file results in a modified block map (MBM) file that records the location of modified blocks obtained from the corresponding WAL file. The BART WAL scanner program `bart-scanner` performs this process. + +4. Take incremental backups using the `BACKUP` subcommand with the `--parent` option to specify the backup identifier or name of a previous, full backup or an incremental backup. Any previous backup may be chosen as the parent as long as all backups belong to the same timeline. + +5. The incremental backup process identifies which WAL files may contain changes from when the parent backup was taken to the starting point of the incremental backup. The corresponding MBM files are used to locate and copy the modified blocks to the incremental backup directory along with other database cluster directories and files. Instead of backing up all, full relation files, only the modified blocks are copied and saved. In addition, the relevant MBM files are condensed into one consolidated block map (CBM) file that is stored with the incremental backup. + + Multiple block copier threads can be used to copy the modified blocks to the incremental backup directory. See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/latest/bart_inst/) for information about setting the `thread_count` parameter in the BART configuration file. See [Backup](../../03_using_bart/03_basic_bart_subcommand_usage/03_backup/#backup) for information about using the `--thread-count` option with the `BACKUP` subcommand. + +6. Invoke the restore process for an incremental backup using the `RESTORE` subcommand in the same manner as restoring a full backup. The `-i` option specifies the backup identifier or name of the incremental backup to restore. The restore process begins by going back through the chain of past, parent incremental backups until the initial full backup starting the chain is identified. This full backup provides the initial set of directories and files to be restored to the location specified with the `-p` option. Each subsequent incremental backup in the chain is then restored. Restoration of an incremental backup uses its CBM file to restore the modified blocks from the incremental backup. + +The following sections provide some additional information on these procedures. diff --git a/product_docs/docs/bart/2.5.9/bart_user/02_overview/01_block-level_incremental_backup/03_wal_scanning_preparation_for_an_incremental_backup.mdx b/product_docs/docs/bart/2.5.9/bart_user/02_overview/01_block-level_incremental_backup/03_wal_scanning_preparation_for_an_incremental_backup.mdx new file mode 100644 index 00000000000..5264499e13e --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_user/02_overview/01_block-level_incremental_backup/03_wal_scanning_preparation_for_an_incremental_backup.mdx @@ -0,0 +1,54 @@ +--- +title: "WAL Scanning – Preparation for an Incremental Backup" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/wal_scanning_preparation_for_an_incremental_backup.html" +--- + + + +The WAL scanner program (`bart-scanner`) scans the WAL files created from the time of the parent backup up to the start of the incremental backup to determine which blocks have modified since the parent backup, and records the information in a file called the *modified block map (MBM) file*. One MBM file is created for each WAL file. + +The MBM file is stored in the directory where archived_wals will be stored, as specified in the `archive_path` parameter in the `bart.cfg` file. If the `archive_path` is not specified, the default `archived_wals` directory is: + +`//` + +Where: + +`` is the BART backup catalog parent directory specified in the global section of the BART configuration file. + +`` is the lowercase conversion of the database server name specified in the server section of the BART configuration file. + +The following code snippet is the content of the archive path showing the MBM files created for the WAL files. (The user name and group name of the files have been removed from the example to list the WAL files and MBM files in a more comparable manner): + +```text +[root@localhost archived_wals]# pwd +/opt/backup/acctg/archived_wals +[root@localhost archived_wals]# ls -l +total 131104 +-rw------- 1 ... ... 16777216 Oct 12 09:38 000000010000000100000078 +-rw------- 1 ... ... 16777216 Oct 12 09:38 000000010000000100000079 +-rw------- 1 ... ... 16777216 Oct 12 09:38 00000001000000010000007A +-rw------- 1 ... ... 16777216 Oct 12 09:35 00000001000000010000007B +-rw------- 1 ... ... 16777216 Oct 12 09:38 00000001000000010000007C +-rw------- 1 ... ... 16777216 Oct 12 09:39 00000001000000010000007D +-rw------- 1 ... ... 16777216 Oct 12 09:42 00000001000000010000007E +-rw------- 1 ... ... 16777216 Oct 12 09:47 00000001000000010000007F +-rw-rw-r-- 1 ... ... 161 Oct 12 09:49 0000000100000001780000280000000179000000.mbm +-rw-rw-r-- 1 ... ... 684 Oct 12 09:49 000000010000000179000028000000017A000000.mbm +-rw-rw-r-- 1 ... ... 161 Oct 12 09:49 00000001000000017A000028000000017B000000.mbm +-rw-rw-r-- 1 ... ... 161 Oct 12 09:49 00000001000000017B000028000000017C000000.mbm +-rw-rw-r-- 1 ... ...1524 Oct 12 09:49 00000001000000017C000028000000017D000000.mbm +-rw-rw-r-- 1 ... ... 161 Oct 12 09:49 00000001000000017D000028000000017E000000.mbm +-rw-rw-r-- 1 ... ... 161 Oct 12 09:49 00000001000000017E000028000000017F000000.mbm +-rw-rw-r-- 1 ... ... 161 Oct 12 09:49 00000001000000017F0000280000000180000000.mbm +``` + +MBM files have the suffix, `.mbm`. + +In preparation for any incremental backup, the WAL files should be scanned as soon as they are copied to the `archive_path`. Thus, the WAL scanner should be running as soon as the WAL files from the database cluster are archived to the `archive_path`. If the `archive_path` contains WAL files that have not yet been scanned, starting the WAL scanner begins scanning these files. If WAL file fails to be scanned (resulting in a missing MBM file), you can use the WAL scanner to specify an individual WAL file. + +Under certain conditions such as when the Network File System (NFS) is used to copy WAL files to the `archive_path`, the WAL files may have been missed by the WAL scanner program for scanning and creation of MBM files. Use the `scan_interval` parameter in the BART configuration file to initiate force scanning of WAL files in the `archive_path` to ensure MBM files are generated. See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/latest/bart_inst/) for more information about the `scan_interval` parameter. + +See [Running the BART WAL Scanner](../../03_using_bart/04_running_the_bart_wal_scanner/#running_the_bart_wal_scanner) for information about using the WAL scanner. diff --git a/product_docs/docs/bart/2.5.9/bart_user/02_overview/01_block-level_incremental_backup/04_performing_an_incremental_backup.mdx b/product_docs/docs/bart/2.5.9/bart_user/02_overview/01_block-level_incremental_backup/04_performing_an_incremental_backup.mdx new file mode 100644 index 00000000000..7cd01990da6 --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_user/02_overview/01_block-level_incremental_backup/04_performing_an_incremental_backup.mdx @@ -0,0 +1,76 @@ +--- +title: "Performing an Incremental Backup" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/performing_an_incremental_backup.html" +--- + + + +The WAL files produced at the time of the parent backup up to the start of the incremental backup contain information about which blocks were modified during that time interval. That information is consolidated into an MBM file for each WAL file by the WAL scanner. + +The MBM files for the relevant WAL files are read, and the information is used to copy the modified blocks from the database cluster to the `archived_wals` directory as specified in the `archive_path` parameter in the `bart.cfg` file. When compared to a full backup, the number and sizes of relation files can be significantly less for an incremental backup. + +For comparison, the following is an abbreviated list of the files copied to the archived `base` subdirectory of a full backup for one database: + +```text +[root@localhost 14845]# pwd +/opt/backup/acctg/1476301238969/base/base/14845 +[root@localhost 14845]# ls +112 13182_vm 14740 16467 16615 2608_vm 2655 2699 2995 ... +113 13184 14742 16471 174 2609 2656 2701 2995_vm ... +1247 13186 14745 16473 175 2609_fsm 2657 2702 2996 ... +1247_fsm 13187 14747 16474 2187 2609_vm 2658 2703 2998 ... +1247_vm 13187_fsm 14748 16476 2328 2610 2659 2704 2998_vm ... +1249 13187_vm 14749 16477 2328_fsm 2610_fsm 2660 2753 2999 ... +1249_fsm 13189 14752 16479 2328_vm 2610_vm 2661 2753_fsm 2999_vm ... +1249_vm 13191 14754 16488 2336 2611 2662 2753_vm 3079 ... +1255 13192 14755 16490 2336_vm 2611_vm 2663 2754 3079_fsm ... + . + . + . +13182_fsm 14739 16465 16603 2608_fsm 2654 2696 2893_vm 3501_vm ... +``` + +In contrast, the following is the content of the archived `base` subdirectory of the same database from a subsequent incremental backup: + +```text +[root@localhost 14845]# pwd +/opt/backup/acctg/1476301835391/base/base/14845 +[root@localhost 14845]# ls +1247 1249 1259 16384 17006 2608 2610 2658 2663 2678 ... +1247_fsm 1249_fsm 1259_fsm 16387 17009 2608_fsm 2610_fsm 2659 2673 2679 ... +1247_vm 1249_vm 1259_vm 16389 17011 2608_vm 2610_vm 2662 2674 2703 ... +``` + +The information from the MBM files are consolidated into one file called a *consolidated block map* (CBM) file. During the restore operation for the incremental backup, the CBM file is used to identify the modified blocks to be restored for that backup. In addition, the incremental backup also stores other required subdirectories and files from the database cluster as is done for full backups. + +Before taking an incremental backup, an initial full backup must be taken with the `BACKUP` subcommand. This full backup establishes the parent of the first incremental backup. + +The syntax for taking a full backup is: + +```text +bart BACKUP –s { | all } [ -F { p | t } ] + [ -z ] [ –c ] + [ --backup-name ] + [ --thread-count ] + [ { --with-pg_basebackup | --no-pg_basebackup } ] +``` + +The syntax for taking an incremental backup is: + +```text +bart BACKUP –s { | all } [ -F p] + [ --parent { | } ] + [ --backup-name ] + [ --thread-count ] + [ --check ] +``` + +You must specify the following before taking an incremental backup: + +- `-Fp` option for plain text format as incremental backup can only be taken in the plain text format. +- `--check` option to verify if the required MBM files are present in the `archived_wals` directory. The `--parent` option must be specified when the `--check` option is used. + +See [BACKUP](../../03_using_bart/03_basic_bart_subcommand_usage/03_backup/#backup) for more information about using the `BACKUP` subcommand. diff --git a/product_docs/docs/bart/2.5.9/bart_user/02_overview/01_block-level_incremental_backup/05_restoring_an_incremental_backup.mdx b/product_docs/docs/bart/2.5.9/bart_user/02_overview/01_block-level_incremental_backup/05_restoring_an_incremental_backup.mdx new file mode 100644 index 00000000000..c86914aa329 --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_user/02_overview/01_block-level_incremental_backup/05_restoring_an_incremental_backup.mdx @@ -0,0 +1,42 @@ +--- +title: "Restoring an Incremental Backup" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/restoring_an_incremental_backup.html" +--- + + + +Restoring an incremental backup may require additional steps depending upon the host on which the incremental backup is to be restored: + +- [Restoring an Incremental Backup on a BART Host](#restoring-an-incremental-backup-on-a-bart-host) - This section outlines restoring an incremental backup onto the same host where BART has been installed. +- [Restoring an Incremental Backup on a Remote Host](#restoring-an-incremental-backup-on-a-remote-host) - This section outlines restoring an incremental backup onto a remote host where BART has not been installed. + + + +## Restoring an Incremental Backup on a BART Host + +Specify a backup identifier or name, and include the `-i` option when invoking the `RESTORE` subcommand to restore an incremental backup. All `RESTORE` options may be used in the same manner as when restoring a full backup. See [RESTORE](../../03_using_bart/03_basic_bart_subcommand_usage/08_restore/#restore) command for more details. + +First, all files from the full backup from the beginning of the backup chain are restored. For each incremental backup, the CBM file is used to identify and restore blocks from the incremental backup. If there are new relations or databases identified in the CBM file, then relevant relation files are copied. If consolidated block map information is found indicating the drop of a relation or a database, then the relevant files are removed from the restore directory. Similarly, if there is any indication of a table truncation, then the related files are truncated. + +Also note that you can use the `-w` option of the `RESTORE` subcommand to specify a multiple number of parallel worker processes to stream the modified blocks to the restore host. + + + +## Restoring an Incremental Backup on a Remote Host + +Ensure the `bart` program is available on the remote host when restoring an incremental backup on a remote host; the invocation of the `RESTORE` subcommand for an incremental backup results in the execution of the `bart` program on the remote host to restore the modified blocks to their proper location. + +To restore an incremental backup onto a remote host where BART has not been installed, perform the following steps: + +**Step 1:** Install `BART` on the remote host to which an incremental backup is to be restored. + +No editing is needed in the `bart.cfg` file installed on the remote host. + +**Step 2:** Determine the Linux operating system user account on the remote host to be used as the remote user. This user is specified by the `remote_host` parameter in the BART configuration file or by the `-r` option when using the `RESTORE` subcommand to restore the incremental backup. The remote user must be the owner of the directory where the incremental backup is to be restored on the remote host. By default, the user account is `enterprisedb` for Advanced Server or `postgres` for PostgreSQL. + +**Step 3:** Ensure a passwordless SSH/SCP connection is established from the BART user on the BART host to the remote user on the remote host. For information about creating a passwordless SSH/SCP connection, see the *EDB Backup and Recovery Installation and Upgrade Guide*, available at the [EDB website](/bart/latest/bart_inst/). + +When restoring an incremental backup, specify the backup identifier or name of the incremental backup that will be restored. See the [RESTORE](../../03_using_bart/03_basic_bart_subcommand_usage/08_restore/#restore) documentation for more details. To view an example of restoring an incremental backup, see the *EDB Backup and Recovery Reference Guide* available at the [EDB website](/bart/latest/bart_ref/). diff --git a/product_docs/docs/bart/2.5.9/bart_user/02_overview/01_block-level_incremental_backup/index.mdx b/product_docs/docs/bart/2.5.9/bart_user/02_overview/01_block-level_incremental_backup/index.mdx new file mode 100644 index 00000000000..3e65e3b0056 --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_user/02_overview/01_block-level_incremental_backup/index.mdx @@ -0,0 +1,24 @@ +--- +title: "Block-Level Incremental Backup" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/block-level_incremental_backup.html" +--- + + + +This section describes the basic concepts of a block-level incremental backup (referred to as an incremental backup). An incremental backup is a unique functionality of BART. + +An incremental backup provides a number of advantages when compared to using a full backup: + +- The amount of time required to produce an incremental backup is generally less than a full backup, as modified relation blocks are saved instead of all full relation files of the database cluster. +- An incremental backup uses less disk space than a full backup. + +Generally, all BART features (such as retention policy management) apply to incremental backups and full backups. See [Managing Incremental Backups](../../03_using_bart/02_managing_backups_using_a_retention_policy/05_managing_incremental_backups/#managing_incremental_backups) for more information. + +
+ +incremental_backup_limitations_and_requirements concept_overview wal_scanning_preparation_for_an_incremental_backup performing_an_incremental_backup restoring_an_incremental_backup + +
diff --git a/product_docs/docs/bart/2.5.9/bart_user/02_overview/02_creating_a_backup_chain.mdx b/product_docs/docs/bart/2.5.9/bart_user/02_overview/02_creating_a_backup_chain.mdx new file mode 100644 index 00000000000..644040d87f1 --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_user/02_overview/02_creating_a_backup_chain.mdx @@ -0,0 +1,22 @@ +--- +title: "Creating a Backup Chain" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/creating_a_backup_chain.html" +--- + + + +A *backup chain* is the set of backups consisting of a full backup and all of its successive incremental backups. Tracing back on the parent backups of all incremental backups in the chain eventually leads back to that single, full backup. + +It is possible to have a *multi-forked* backup chain, which is two or more successive lines of incremental backups, all of which begin with the same, full backup. Thus, within the chain there is a backup that serves as the parent of more than one incremental backup. + +Since restoration of an incremental backup is dependent upon first restoring the full backup, then all successive incremental backups up to, and including the incremental backup specified by the `RESTORE` subcommand, it is crucial to note the following: + +- Deletion or corruption of the full backup destroys the entire backup chain. It is not possible to restore any of the incremental backups that were part of that chain. +- Deletion or corruption of an incremental backup within the chain results in the inability to restore any incremental backup that was added to that successive line of backups following the deleted or corrupted backup. The full backup and incremental backups prior to the deleted or corrupted backup can still be restored. + +The actions of retention policy management are applied to the full backup and all of its successive incremental backups within the chain in an identical manner as if they were one backup. Thus, use of retention policy management does not result in the breakup of a backup chain. + +See the *EDB Backup and Recovery Reference Guide*, available at the [EDB website](/bart/latest/bart_ref/) for examples of creating a backup chain and restoring an incremental backup. diff --git a/product_docs/docs/bart/2.5.9/bart_user/02_overview/index.mdx b/product_docs/docs/bart/2.5.9/bart_user/02_overview/index.mdx new file mode 100644 index 00000000000..7b5b7e92fb3 --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_user/02_overview/index.mdx @@ -0,0 +1,97 @@ +--- +title: "Overview" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/overview.html" +--- + + + +BART provides a simplified interface for the continuous archiving and point-in-time recovery method provided with Postgres database servers. This consists of the following processes: + +- Capturing a complete image of a database cluster as a full base backup or referred to simply as a *full backup*. +- Capturing a modified image of a database cluster called a *block-level incremental backup* or referred as *incremental backup*, which is similar to a full backup, but contains the modified blocks of the relation files that have been changed since a previous backup. +- Archiving the `Write-Ahead Log segments` (WAL files), which continuously record changes to be made to the database files. +- Performing *Point-In-Time Recovery* (PITR) to a specified transaction ID or timestamp with respect to a timeline using a full backup along with successive, [block-level incremental backups](01_block-level_incremental_backup/#block-level_incremental_backup) that reside in the same backup chain, and the WAL files. + +Detailed information regarding WAL files and point-in-time recovery is documented in the [PostgreSQL Core Documentation](https://www.postgresql.org/docs/current/static/continuous-archiving.html). + +The general term *backup* refers to both full backups and incremental backups. + +When taking a full backup of a standby server, BART uses the PostgreSQL `pg_basebackup` utility program. However, it must be noted that for standby servers, you can only take a full backup, but cannot take an incremental or parallel backups. For information about standby servers, see the [PostgreSQL Documentation](https://www.postgresql.org/docs/current/static/high-availability.html). + +BART uses a centralized backup catalog, a single configuration file, and a command line interface controlling the necessary operations to simplify the management process. Reasonable defaults are automatically used for various backup and restore options. BART also performs the necessary recovery file configuration required for point-in-time recovery using its command line interface. + +BART also provides the following features to enhance backup management: + +- Automation of the WAL archiving command configuration. +- Usage of retention policies to evaluate, categorize, and delete obsolete backups. +- Compression of WAL files to conserve disk space. +- Customizable naming of backups to ease their usage. +- Easy access to comprehensive information about each backup. + +The key components of a BART installation are: + +- **BART Host.** The host system on which BART is installed. BART operations are invoked from this host system. The database server backups and archived WAL files are stored on this host as well. +- **BART User Account.** Linux operating system user account you choose to run BART. The BART user account owns the BART backup catalog directory. +- **BART Configuration File.** File in editable text format containing the configuration information that BART uses. +- **BART Backup Catalog.** File system directory structure containing all of the backups for the database servers that BART manages. It is also the default `archive_path` to store archived WAL files. +- **BART Backupinfo File.** File in text format containing information for a BART backup. A `backupinfo` file resides in each backup subdirectory within the BART backup catalog. +- **BART Command Line Utility Program.** Single, executable file named `bart`, which is used to manage all BART operations. +- **BART WAL Scanner Program.** Single, executable file named `bart-scanner`, which is used to scan WAL files to locate and record the modified blocks for incremental backups. + +Other concepts and terms referred to in this document include the following: + +- **Postgres Database Cluster.** Also commonly called the *data directory*, this is the file system directory where all of the data files related to a particular Postgres database server instance are stored. (Each specific running instance is identified by its host and port number when connecting to a database.) The database cluster is identified by the `–D` option when it is created, started, stopped, etc. by the `Postgres initdb` and `pg_ctl` commands. A full backup is a copy of a database cluster. + + The terms database cluster and database server are used somewhat interchangeably throughout this document, though a single database server can run multiple database clusters. + +- **Postgres User Account.** Linux operating system user account that runs the Advanced Server or PostgreSQL database server and owns the database cluster directory. + + - By default, the database user account is `enterprisedb` when Advanced Server is installed to support compatibility with Oracle databases. + + - By default, the database user account is `postgres` when Advanced Server is installed in PostgreSQL compatible mode. For a PostgreSQL database server, the default database user account is also `postgres`. + + The BART configuration parameter `cluster_owner` must be set to the database user account for each database server. + +- **Replication Database User.** For each database server that BART manages, a database superuser must be selected to act as the replication database user. This database user is used to connect to the database server when backups are taken. The database superusers created with an initial Postgres database server installation (`enterprisedb` or `postgres`) may be used for this purpose. The BART configuration parameter `user` must be set to this replication database user for each database server. + +- **Secure Shell (SSH)/Secure Copy (SCP).** Linux utility programs used to log into hosts (SSH) and copy files (SCP) between hosts. A valid user account must be specified that exists on the target host and in fact is the user account under which the SSH or SCP operations occur. + +For information on how all of these components are configured and used with BART, see the EDB Backup and Recovery Installation and Upgrade Guide available at the [EDB website](/bart/latest/bart_inst/). + +**Supported BART Operations** + +The following tables are not a conclusive list of the scenarios supported by BART, but instead provides an overview of some of the most common scenarios in both `pg_basebackup` (thread count=1) as well as parallel backup mode (thread count greater than 1). + +| | -Fp-xlog-method=fetch | -Fp-xlog-method=stream | -Ft-xlog-method=fetch | -Ft-xlog-method=stream | +| -------------------------------------------- | --------------------- | ---------------------- | --------------------- | ---------------------- | +| `Primary Database Server/Full backup` | Supported | Supported | Supported | Supported | +| `Primary Database Server/Incremental backup` | Supported | Supported | Not Supported | Not Supported | +| `Standby Database Server/Full backup` | Supported | Supported | Supported | Supported | +| `Standby Database Server/Incremental backup` | Not Supported | Not Supported | Not Supported | Not Supported | + +Backup + +| | Wal compression by BART | WAL scanner | +| -------------------------------------------- | ----------------------- | ----------- | +| `Primary Database Server/Full backup` | Supported | N/A | +| `Primary Database Server/Incremental backup` | Not Supported | N/A | +| `Standby Database Server/Full backup` | Supported | N/A | +| `Standby Database Server/Incremental backup` | Not Supported | N/A | + +Wal Archiving + +| | Wal compression = enabled | Wal compression = disabled | +| ------------------ | ------------------------- | -------------------------- | +| `Restore` | Supported | Supported | +| `Parallel restore` | Supported | Supported | + +Restore + +
+ +block-level_incremental_backup creating_a_backup_chain + +
diff --git a/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/01_bart_management_overview/01_performing_a_restore_operation.mdx b/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/01_bart_management_overview/01_performing_a_restore_operation.mdx new file mode 100644 index 00000000000..8b5fdec0c09 --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/01_bart_management_overview/01_performing_a_restore_operation.mdx @@ -0,0 +1,57 @@ +--- +title: "Performing a Restore Operation" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/performing_a_restore_operation.html" +--- + + + +The following steps describe the process of restoring a backup: + +**Step 1:** Use your system-specific command to shut down the database server. + +**Step 2:** Inspect the `pg_wal` subdirectory (inspect the `pg_xlog` subdirectory if you are using server version 9.6) of the data directory and save any WAL files that have not yet been archived to the `archive_path`. If there are files that have not been archived, save them to a temporary location. + +**Step 3:** If you want to restore to current data directory, it is recommended to make a copy of the current data directory and then delete all files and subdirectories under the data directory if you have enough extra space. If there is not enough space, then make a copy of `pg_wal` directory (or `pg_xlog` if you are using server version 9.6) until the server is successfully restored. + +If you want to restore to a new, empty directory, create the directory on which you want to restore the backed up database cluster. Ensure the data directory can be written to by the BART user account or by the user account specified by the `remote_host` configuration parameter, or by the `--remote-host` option of the `RESTORE` subcommand (if these are to be used). + +**Step 4:** Perform the same process for tablespaces as described in Step 3. The `tablespace_path` parameter in the BART configuration file must contain the tablespace directory paths to which the tablespace data files are to be restored. See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/latest/bart_inst/) for more information about this parameter. + +**Step 5:** Identify the backup to use for the restore operation and obtain the backup ID or backup name. + +To use the latest backup, omit the `-i` option; the `RESTORE` subcommand uses that backup by default. The backups can be listed with the `SHOW-BACKUPS` subcommand. + +**Step 6:** Run the BART `RESTORE` subcommand. + +- Minimal recovery settings will be saved in the `postgresql.auto.conf` file and archive recovery will proceed only until consistency is reached, with no restoration of files from the archive. See [Restore](../03_basic_bart_subcommand_usage/08_restore/#restore) for detailed information about `Restore` subcommand. + +- If the `-c` option is specified or if the `copy_wals_during_restore` BART configuration parameter is enabled for this database server, then the following actions occur: + + - In addition to restoring the database cluster to the directory specified by the `-p restore_path` option, the archived WAL files of the backup are copied from the BART backup catalog to the subdirectory `restore_path/archived_wals`. + - If recovery settings are saved in the `postgresql.auto.conf` file, the command string set in the `restore_command` parameter retrieves the WAL files from this `archived_wals` subdirectory relative to the `restore_path` parent directory as: `restore_command = cp archived_wals/%f %p` + +You must ensure that valid options are specified when using the `RESTORE` subcommand. BART will not generate an error message if invalid option values or invalid option combinations are provided. BART will accept the invalid options and pass them to the `postgresql.auto.conf` file, which will then be processed by the database server when it is restarted. + +**Step 7:** Copy any saved WAL files from Step 2 to the `restore_path/pg_xlog` subdirectory. + +**Step 8:** Inspect the restored directories and data files of the restored database cluster in directory `restore_path`. + +All files and directories must be owned by the user account that you intend to use to start the database server. Recursively change the user and group ownership of the `restore_path` directory, its files, and its subdirectories if necessary. There must only be directory access privileges for the user account that will start the database server. No other groups or users can have access to the directory. + +**Step 9:** The `postgresql.auto.conf` file should be configured to recover only until the cluster reaches consistency. In either case, the settings may be modified as desired. + +**Step 10:** Disable WAL archiving at this point. The BART `RESTORE` subcommand adds `archive_mode = off` to the end of the `postgresql.conf` file. + +- If you want to restart the database server with WAL archiving enabled, ensure that this additional parameter is deleted. +- The original `archive_mode` parameter still resides in the `postgresql.conf` file in its initial location with its last setting. + +**Step 11:** Start the database server to initiate recovery. After completion, check the database server log file to ensure the recovery was successful. + +If the backup is restored to a different location than where the original database cluster resided, operations dependent upon the database cluster location may fail if supporting service scripts are not updated to reflect the location where the backup has been restored. For information about the use and modification of service scripts, see the EDB Advanced Server Installation Guide available at the [EDB website](/epas/latest/). + +See [Restore](../03_basic_bart_subcommand_usage/08_restore/#restore) for more information about using the BART `Restore` subcommand. + +An example of a restore operation is documented in the EDB Backup and Recovery Reference Guide available at the [EDB website](/bart/latest/bart_ref/). diff --git a/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/01_bart_management_overview/02_point_in_time_recovery_operation.mdx b/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/01_bart_management_overview/02_point_in_time_recovery_operation.mdx new file mode 100644 index 00000000000..caaaa89e7c0 --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/01_bart_management_overview/02_point_in_time_recovery_operation.mdx @@ -0,0 +1,51 @@ +--- +title: "Point-In-Time Recovery Operation" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/point_in_time_recovery_operation.html" +--- + + + +The following steps outline how to perform a point-in-time recovery operation for a database cluster: + +1. Use your system-specific command to shut down the database server. + +2. If you want to: + a. restore the database cluster and tablespace files to new, empty directories, create the new directories with the appropriate directory ownership and permissions. + b. reuse the existing database cluster directories, delete all the files and subdirectories in the existing directories. We strongly recommend that you make a copy of this data before deleting it. Be sure to save any recent WAL files in the `pg_wal` subdirectory ( `pg_xlog` subdirectory if you are using server version 9.6) that have not been archived to `archive_path`. + +3. Run the BART `SHOW-BACKUPS -s ` subcommand to list the backup IDs and backup names of the backups for the database server. You will need to provide the appropriate backup ID or backup name with the BART `RESTORE` subcommand, unless you intend to restore the latest backup in which case the `-i` option of the `RESTORE` subcommand for specifying the backup ID or backup name may be omitted. + +4. Run the BART `RESTORE` subcommand with the appropriate options. + + - The backup is restored to the directory specified by the `-p restore_path` option. + + - In addition, if the `RESTORE` subcommand `-c` option is specified or if the enabled setting of the `copy_wals_during_restore` BART configuration parameter is applicable to the database server, then the required archived WAL files from the `archive_path` are copied to the `restore_path/archived_wals` subdirectory. + + - Ensure the `restore_path` directory and all subdirectories and files in the `restore_path` are owned by the proper Postgres user account (for example, `enterprisedb` or `postgres`). Also ensure that only the Postgres user account has access permission to the `restore_path` directory. + + Use the `chown` command to make the appropriate adjustments to file permissions; for example, the following command changes the ownership of `restore_path` to `enterprisedb`: + + `chown -R enterprisedb:enterprisedb restore_path` + + The following command restricts access to `restore_path`: + + `chmod 700 restore_path` + +5. Copy any saved WAL files from Step 2 that were not archived to the BART backup catalog to the `restore_path/pg_wal` subdirectory (`pg_xlog` subdirectory if you are using server version 9.6). + +6. Identify the timeline ID you wish to use to perform the restore operation. + + The available timeline IDs can be identified by the first non-zero digit of the WAL file names reading from left to right. + +7. Verify that the `postgresql.auto.conf` file created in the directory specified with the `RESTORE` subcommand’s `-p ` option was generated with the correct recovery parameter settings. + + If the `RESTORE` subcommand `-c` option is specified or if the enabled setting of the `copy_wals_during_restore` BART configuration parameter is applicable to the database server, then the `restore_command` parameter retrieves the archived WAL files from the `/archived_wals` subdirectory that was created by the `RESTORE` subcommand, otherwise the `restore_command` retrieves the archived WAL files from the BART backup catalog. + +8. The BART `RESTORE` subcommand disables WAL archiving in the restored database cluster. If you want to immediately enable WAL archiving, modify the `postgresql.conf` file by deleting the `archive_mode = off` parameter that BART appends to the end of the file. + +9. Start the database server, which will then perform the point-in-time recovery operation if recovery settings are saved in the `postgresql.auto.conf` file. + +For a detailed description of the `RESTORE` subcommand, see [Basic BART Subcommand Usage](../03_basic_bart_subcommand_usage/#basic_bart_subcommand_usage). An example of a Point-in-Time Recovery operation is documented in the *EDB Backup and Recovery Reference Guide* available at the [EDB website](/bart/latest/bart_ref/). See [Restore](../03_basic_bart_subcommand_usage/08_restore/#restore) for more information about using the `Restore` subcommand. diff --git a/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/01_bart_management_overview/index.mdx b/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/01_bart_management_overview/index.mdx new file mode 100644 index 00000000000..4cb9c779397 --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/01_bart_management_overview/index.mdx @@ -0,0 +1,34 @@ +--- +title: "BART Management Overview" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/bart_management_overview.html" +--- + + + +After configuring BART, you can begin the backup and recovery management process. The following steps will help you get started: + +1. Run the `CHECK-CONFIG` subcommand without the `-s` option. When the `CHECK-CONFIG` subcommand is used without specifying the `-s` option, it checks the parameters in the global section of the BART configuration file. +2. Run the `INIT` subcommand (if you have not already done so) to finish creation of the BART backup catalog, which results in the complete directory structure to which backups and WAL files are saved. This step must be done before restarting the database servers with enabled WAL archiving, otherwise the copy operation in the `archive_command` parameter of the `postgresql.conf` file or the `postgresql.auto.conf` file fails due to the absence of the target archive directory. When the directory structure is complete, the `archived_wals` subdirectory should exist for each database server. +3. Start the Postgres database servers with archiving enabled. Verify that the WAL files are appearing in the `archive_path`. The archiving frequency is dependent upon other `postgresql.conf` configuration parameters. Check the Postgres database server log files to ensure there are no archiving errors. Archiving should be operational before taking a backup in order to ensure that the WAL files that may be created during the backup process are archived. +4. Start the WAL scanner if you intend to take incremental backups. Since the WAL scanner processes the WAL files copied to the `archive path`, it is advantageous to commence the WAL scanning as soon as the WAL files begin to appear in the `archive_path` in order to keep the scanning in pace with the WAL archiving. +5. Run the BART `CHECK-CONFIG` subcommand for each database server with the `-s` option specifying the server name. This ensures the database server is properly configured for taking backups. +6. Create a full backup for each database server. The full backup establishes the starting point of when point-in-time recovery can begin and also establishes the initial parent backup for any incremental backups to be taken. + +There are now a number of other BART management processes you may perform: + +- Execute the `BACKUP` subcommand to create additional full backups or incremental backups. +- Use the `VERIFY-CHKSUM` subcommand to verify the checksum of the full backups. +- Display database server information with the `SHOW-SERVERS` subcommand. +- Display backup information with the `SHOW-BACKUPS` subcommand. +- Compress the archived WAL files in the `archive_path` by enabling WAL compression in the BART configuration file and then invoking the `MANAGE` subcommand. +- Determine and set the retention policy for backups in the BART configuration file. +- Establish the procedure for using the `MANAGE` subcommand to enforce the retention policy for backups. This may include using `cron` jobs to schedule the `MANAGE` subcommand. + +
+ +performing_a_restore_operation point_in_time_recovery_operation + +
diff --git a/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/01_overview_managing_backups_using_a_retention_policy.mdx b/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/01_overview_managing_backups_using_a_retention_policy.mdx new file mode 100644 index 00000000000..7169d6f7bb6 --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/01_overview_managing_backups_using_a_retention_policy.mdx @@ -0,0 +1,23 @@ +--- +title: "Overview - Managing Backups Using a Retention Policy" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/overview_managing_backups_using_a_retention_policy.html" +--- + + + +The BART retention policy results in the categorization of each backup in one of three statuses – *active*, *obsolete*, and *keep*. + +- **Active.** The backup satisfies the retention policy applicable to its server. Such backups would be considered necessary to ensure the recovery safety for the server and thus should be retained. +- **Obsolete.** The backup does not satisfy the retention policy applicable to its server. The backup is no longer considered necessary for the recovery safety of the server and thus can be deleted. +- **Keep.** The backup is to be retained regardless of the retention policy applicable to its server. The backup is considered vital to the recovery safety for the server and thus should not be deleted for an indefinite period of time. + +There are two types of retention policies - redundancy retention policy and recovery window retention policy. + +- **Redundancy Retention Policy** - The [redundancy retention policy](03_setting_the_retention_policy/#redundancy-retention-policy) relies on a specified, maximum number of most recent backups to retain for a given server. When the number of backups exceeds that maximum number, the oldest backups are considered obsolete (except for backups marked as keep). +- **Recovery Window Retention Policy** - The [recovery window retention policy](03_setting_the_retention_policy/#recovery-window-retention-policy) relies on a time frame (the recovery window) for when a backup should be considered active. The boundaries defining the recovery window are the current date/time (the ending boundary of the recovery window) and the date/time going back in the past for a specified length of time (the starting boundary of the recovery window). + - If the date/time the backup was taken is within the recovery window (that is, the backup date/time is on or after the starting date/time of the recovery window), then the backup is considered active, otherwise it is considered obsolete (except for backups marked as keep). + - Thus, for the recovery window retention policy, the recovery window time frame dynamically shifts, so the end of the recovery window is always the current date/time when the `MANAGE` subcommand is run. As you run the `MANAGE` subcommand at future points in time, the starting boundary of the recovery window moves forward in time. At some future point, the date/time of when a backup was taken will be earlier than the starting boundary of the recovery window. This is when an active backup’s status will be considered obsolete. + - You can see the starting boundary of the recovery window at any point in time by running the `SHOW-SERVERS` subcommand. The `RETENTION POLICY` field of the `SHOW-SERVERS` subcommand displays the starting boundary of the recovery window. diff --git a/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/02_marking_the_backup_status.mdx b/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/02_marking_the_backup_status.mdx new file mode 100644 index 00000000000..047552d0a9e --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/02_marking_the_backup_status.mdx @@ -0,0 +1,25 @@ +--- +title: "Marking the Backup Status" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/marking_the_backup_status.html" +--- + + + +When a backup is initially created with the `BACKUP` subcommand, it is always recorded with active status. Use the `MANAGE` subcommand to evaluate if the backup status should be changed to obsolete in accordance with the retention policy. You can review the current status of your backups with the `SHOW-BACKUPS` subcommand. + +Active backups are evaluated and also marked (that is, internally recorded by BART) as obsolete only when the `MANAGE` subcommand is invoked either with no options or with only the `-s` option. + +Once a backup has been marked as obsolete, you cannot change it back to active unless you perform the following steps: + +- Use the `MANAGE` subcommand with the `-c` option along with the backup identifier or name with the `-i` option. To keep this particular backup indefinitely, use `-c keep`, otherwise use `-c nokeep`. +- If you use the `-c nokeep` option, the backup status is changed back to active. When the `MANAGE` subcommand is used the next time, the backup is re-evaluated to determine if its status needs to be changed back to obsolete based on the current retention policy in the BART configuration file. + +After setting the `retention_policy` parameter and running the `MANAGE` subcommand if you change the `retention_policy` parameter, the current, marked status of the backups are probably inconsistent with the new `retention_policy` setting. To modify the backup status to be consistent with the new `retention_policy` setting, you need to run the `MANAGE` subcommand with: + +- the `-c nokeep` option to change the obsolete status to active status if there are backups currently marked as obsolete that would no longer be considered obsolete under a new retention policy. You can also specify the `-i all` option to change all backups back to active status, including those currently marked as keep. +- no options or with only the `-s` option to reset the marked status based on the new `retention_policy` setting in the BART configuration file. + +See [MANAGE](../03_basic_bart_subcommand_usage/07_manage/#manage) for usage information for the `MANAGE` subcommand. diff --git a/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/03_setting_the_retention_policy.mdx b/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/03_setting_the_retention_policy.mdx new file mode 100644 index 00000000000..a4396239bfe --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/03_setting_the_retention_policy.mdx @@ -0,0 +1,82 @@ +--- +title: "Setting the Retention Policy" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/setting_the_retention_policy.html" +--- + + + +The retention policy is determined by the `retention_policy` parameter in the BART configuration file. It can be applied globally to all servers, but each server can override the global retention policy with its own. For information about creating a global retention policy and an individual database server retention policy, see the EDB Backup and Recovery Installation and Upgrade Guide available at the [EDB website](/bart/latest/bart_inst/). + +There are two types of retention policies - redundancy retention policy and the recovery window retention policy as described in the following sections. + + + +## Redundancy Retention Policy + +To use the redundancy retention policy, set `retention_policy = max_number BACKUPS` where `max_number` is a positive integer designating the maximum number of most recent backups. + +**Additional Restrictions:** + +- The keyword `BACKUPS` must always be specified in plural form (for example, `1 BACKUPS`). +- BART will accept a maximum integer value of 2,147,483,647 for `max_number`; however, you should use a realistic, practical value based on your system environment. + +The redundancy retention policy is the default type of retention policy if all keywords `BACKUPS`, `DAYS`, `WEEKS`, and `MONTHS` following the `max_number` integer are omitted as shown by the following example: + +`retention_policy = 3` + +In the following example, the redundancy retention policy setting considers the three most recent backups as the active backups. Any older backups, except those marked as `keep`, are considered obsolete: + +```text +[ACCTG] +host = 127.0.0.1 +port = 5444 +user = enterprisedb +archive_command = 'cp %p %a/%f' +retention_policy = 3 BACKUPS +description = "Accounting" +``` + +The `SHOW-SERVERS` subcommand displays the `3 Backups` redundancy retention policy in the `RETENTION POLICY` field: + +```bash +-bash-4.1$ bart SHOW-SERVERS -s acctg +SERVER NAME : acctg +HOST NAME : 127.0.0.1 +USER NAME : enterprisedb +PORT : 5444 +REMOTE HOST : +RETENTION POLICY : 3 Backups +DISK UTILIZATION : 627.04 MB +NUMBER OF ARCHIVES : 25 +ARCHIVE PATH : /opt/backup/acctg/archived_wals +ARCHIVE COMMAND : cp %p /opt/backup/acctg/archived_wals/%f +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +DESCRIPTION : "Accounting" +``` + + + +## Recovery Window Retention Policy + +To use the recovery window retention policy, set the `retention_policy` parameter to the desired length of time for the recovery window in one of the following ways: + +- Set to `max_number DAYS` to define the start date/time recovery window boundary as the number of days specified by `max_number` going back in time from the current date/time. +- Set to `max_number WEEKS` to define the start date/time recovery window boundary as the number of weeks specified by `max_number` going back in time from the current date/time. +- Set to `max_number MONTHS` to define the start date/time recovery window boundary as the number of months specified by `max_number` going back in time from the current date/time. + +**Additional Restrictions:** + +- The keywords `DAYS`, `WEEKS`, and `MONTHS` must always be specified in plural form (for example, `1 DAYS`, `1 WEEKS`, or `1 MONTHS`). +- BART will accept a maximum integer value of `2,147,483,647` for `max_number`, however, a realistic, practical value based on your system environment must always be used. + +A backup is considered active if the date/time of the backup is equal to or greater than the start of the recovery window date/time. + +You can view the actual, calculated recovery window by: + +- Invoking the `MANAGE` subcommand in debug mode, along with the `-n` option. +- Using the `SHOW-SERVERS` subcommand. diff --git a/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/04_managing_the_backups_based_on_the_retention_policy.mdx b/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/04_managing_the_backups_based_on_the_retention_policy.mdx new file mode 100644 index 00000000000..def779a4026 --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/04_managing_the_backups_based_on_the_retention_policy.mdx @@ -0,0 +1,147 @@ +--- +title: "Managing the Backups Based on the Retention Policy" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/managing_the_backups_based_on_the_retention_policy.html" +--- + + + +The [MANAGE](../03_basic_bart_subcommand_usage/07_manage/#manage) subcommand is used to evaluate and categorize backups according to the retention policy set in the BART configuration file. When a backup is first created with the `BACKUP` subcommand, it is `active`. You can use the `MANAGE` subcommand to change the status of an active backup to `obsolete`. Obsolete backups can then be deleted. + +This section covers following aspects of backup management: + +- The rules for [deleting backups](#deletions_permitted_under_retention_policy) depending upon the backup status and the subcommand used. +- The process to retain a backup indefinitely by [marking it as keep](#marking-backups-for-indefinite-keep-status). This section also provides information about resetting backups status (that are marked as `obsolete` and `keep`) back to active status. +- The general process for [evaluating, marking, and then deleting obsolete backups](#evaluating-marking-and-deleting-obsolete-backups). + + + +## Deletions Permitted Under a Retention Policy + +This section describes how and under what conditions backups may be deleted under a retention policy. + +You must use the `MANAGE` subcommand to delete obsolete backups. Use the `DELETE` subcommand only for special administrative purposes. + +The deletion behavior of the `MANAGE` subcommand and the `DELETE` subcommand are based on different aspects of the retention policy. + +- The `MANAGE` subcommand deletion relies solely upon how a backup status is currently marked (that is, internally recorded by BART). The current setting of the `retention_policy` parameter in the BART configuration file is ignored. +- The `DELETE` subcommand relies solely upon the current setting of the `retention_policy` parameter in the BART configuration file. The current active, obsolete, or keep status of a backup is ignored. + +The specific deletion rules for the `MANAGE` and `DELETE` subcommands are as follows: + +- `MANAGE` subcommand: The `MANAGE` subcommand with the `-d` option can only delete backups marked as obsolete. This deletion occurs regardless of the current `retention_policy` setting in the BART configuration file. The deletion of backups relies on the last occasion when the backups have been marked. +- `DELETE` subcommand: + + - Under a redundancy retention policy currently set with the `retention_policy` parameter in the BART configuration file, any backup regardless of its marked status, can be deleted with the `DELETE` subcommand when the backup identifier or name is specified with the `-i` option and if the current total number of backups for the specified database server is greater than the maximum number of redundancy backups currently specified with the `retention_policy` parameter. + + If the total number of backups is less than or equal to the specified, maximum number of redundancy backups, then no additional backups can be deleted using `DELETE` with the `-i backup` option. + + - Under a recovery window retention policy currently set with the `retention_policy` parameter in the BART configuration file, any backup regardless of its marked status, can be deleted with the `DELETE` subcommand when the backup identifier or name is specified with the `-i` option, and if the backup date/time is not within the recovery window currently specified with the `retention_policy` parameter. If the backup date/time is within the recovery window, then it cannot be deleted using `DELETE` with the `-i backup` option. + + - Invoking the `DELETE` subcommand with the `-i all` option results in the deletion of all backups regardless of the retention policy and regardless of whether the status is marked as active, obsolete, or keep. + +The following table summarizes the deletion rules of backups according to their marked status. An entry of `Yes` indicates the backup may be deleted under the specified circumstances. An entry of `No` indicates that the backup may not be deleted. + + ++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
OperationRedundancy Retention PolicyRecovery Window Retention Policy
ActiveObsoleteKeepActiveObsoleteKeep
MANAGE –dNoYesNoNoYesNo
DELETE –i *backup* +

Yes

+

(see Note 1)

+
+

Yes

+

(see Note 1)

+
+

Yes

+

(see Note 1_)

+
+

Yes

+

(see Note 2

+
+

Yes

(see Note 2 +
+

Yes

(see Note 2) +
DELETE –i allYesYesYesYesYesYes
+ + + +!!! Note + Redundancy Retention Policy (Note 1) : Deletion occurs only if the total number of backups for the specified database server is greater than the specified, maximum number of redundancy backups currently set with the `redundancy_policy` parameter in the BART configuration file. + + + +!!! Note + Recovery Window Retention Policy (Note 2): Deletion occurs only if the backup is not within the recovery window currently set with the `redundancy_policy` parameter in the BART configuration file. + + + +## Marking Backups for Indefinite Keep Status + +There may be certain backups that you wish to keep for an indefinite period of time and do not wish to delete based upon the retention policy applied to the database server. Such backups can be marked as `keep` to exclude them from being marked as obsolete. Use the `MANAGE` subcommand with the `-c keep` option to retain such backups indefinitely. + + + +## Evaluating, Marking, and Deleting Obsolete Backups + +When the `MANAGE` subcommand is invoked, BART evaluates active backups: + +- If you include the `-s` option when invoking the `MANAGE` subcommand, BART evaluates backups for the database server. +- If you include the `-s all` option when invoking the `MANAGE` subcommand, BART evaluates backups for all database servers. +- If the `-s` option is omitted, the command evaluates the current number of backups for the database server based on the redundancy retention policy or the current date/time for a recovery window retention policy. + +!!! Note + The status of backups currently marked as `obsolete` or `keep` is not changed. To re-evaluate such backups and then classify them, their status must first be reset to `active` with the `MANAGE -c nokeep` option. See [Marking the Backup Status](02_marking_the_backup_status/#marking_the_backup_status) for more information. + +See the *EDB Backup and Recovery Reference Guide* available at the [EDB website](/bart/latest/bart_ref/) to review examples of how to evaluate, mark, and delete backups using a redundancy retention policy and recovery window retention policy, as well as examples of `MANAGE` subcommand. diff --git a/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/05_managing_incremental_backups.mdx b/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/05_managing_incremental_backups.mdx new file mode 100644 index 00000000000..c69f6b09086 --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/05_managing_incremental_backups.mdx @@ -0,0 +1,51 @@ +--- +title: "Managing Incremental Backups" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/managing_incremental_backups.html" +--- + + + +The following section summarizes how retention policy management affects incremental backups. + +- The retention policy rules are applied to full backups. + - A redundancy retention policy uses the number of full backups to determine if a backup is obsolete. Incremental backups are excluded from the comparison count against the `retention_policy` setting for the maximum number of backups. + - A recovery window retention policy uses the backup date/time of any full backups to determine if a backup is obsolete. The backup date/time of any successive incremental backups in the chain are ignored when comparing with the recovery window. +- The retention status of all incremental backups in a chain is set to the same status applied to the full backup of the chain. +- The actions applied by the `MANAGE` and `DELETE` subcommands on a full backup are applied to all incremental backups in the chain in the same manner. +- Thus, a backup chain (that is, the full backup and all its successive incremental backups) are treated by retention policy management as if they are all one, single backup. + - The status setting applied to the full backup is also applied to all incremental backups in its chain. + - If a full backup is marked as obsolete and then deleted according to the retention policy, all incremental backups in the chain are also marked obsolete and then deleted as well. + +The following are some specific points regarding the `MANAGE` and `DELETE` subcommands on incremental backups. + +- `MANAGE` subcommand: + - When the `MANAGE` subcommand is invoked, the status applied to the full backup is also applied to all successive incremental backups in the chain. + - The `MANAGE` subcommand with the `-c { keep | nokeep}` option cannot specify the backup identifier or backup name of an incremental backup with `-i` backup option. The `-i` backup option can only specify the backup identifier or backup name of a full backup. + - You can also use the `-i` all option to take a backup of all backups. When the `MANAGE` subcommand with the `-c { keep | nokeep }` option is applied to a full backup, the same status change is made to all incremental backups in the chain. +- `DELETE` subcommand: + - The `DELETE` subcommand with the `-s server -i` backup option specifies the backup identifier or backup name of an incremental backup in which case that incremental backup along with all its successive incremental backups are deleted, thus shortening that backup chain. + +## Using a Redundancy Retention Policy with Incremental Backups + +When a [redundancy retention policy](03_setting_the_retention_policy/#redundancy-retention-policy) is used and the `MANAGE` subcommand is invoked, the status of the oldest `active` full backup is changed to `obsolete` if the number of full backups exceeds the maximum number specified by the `retention_policy` parameter in the BART configuration file. + +!!! Note + When a full backup is changed from `active` to `obsolete`, all successive incremental backups in the chain of the full backup are also changed from `active` to `obsolete`. + +When determining the number of backups that exceeds the number specified by the `retention_policy` parameter, only full backups are counted for the comparison. Incremental backups are not included in the count for the comparison against the `retention_policy` parameter setting. + +See the *EDB Backup and Recovery Reference Guide* available at the [EDB website](/bart/latest/bart_ref/) for examples demonstrating use of the `MANAGE` and `DELETE` subcommands when a redundancy retention policy is in effect. + +## Using a Recovery Window Retention Policy with Incremental Backups + +If the `MANAGE` command is invoked when BART is configured to use a [recovery window retention policy](03_setting_the_retention_policy/#recovery-window-retention-policy), the status of `active` full backups are changed to `obsolete` if the date/time of the full backup is outside of the recovery window. + +!!! Note + If a full backup is changed from `active` to `obsolete`, all successive incremental backups in the chain of the full backup are also changed from `active` to `obsolete`. + +The status of an incremental backup is changed to `obsolete` regardless of whether or not the date/time of when the incremental backup was taken still lies within the recovery window. + +See the *EDB Backup and Recovery Reference Guide* available at the [EDB website](/bart/latest/bart_ref/) for examples demonstrating use of the `MANAGE` and `DELETE` subcommands when a recovery window retention policy is in effect. diff --git a/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/index.mdx b/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/index.mdx new file mode 100644 index 00000000000..aff92bbd6a5 --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/index.mdx @@ -0,0 +1,27 @@ +--- +title: "Managing Backups Using a Retention Policy" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/managing_backups_using_a_retention_policy.html" +--- + + + +Over the course of time when using BART, the number of backups can grow significantly. This ultimately leads to a large consumption of disk space unless an administrator periodically performs the process of deleting the oldest backups that are no longer needed. This process of determining when a backup is old enough to be deleted and then actually deleting such backups can be done and automated with the following basic steps: + +1. Determine and set a retention policy in the BART configuration file. A *retention policy* is a rule that determines when a backup is considered obsolete. The retention policy can be applied globally to all servers, but each server can override the global retention policy with its own. + +2. Use the `MANAGE` subcommand to categorize and manage backups according to the retention policy. + +3. Create a cron job to periodically run the `MANAGE` subcommand to evaluate the backups and then list and/or delete the obsolete backups. + + Retention policy management applies differently to incremental backups than to full backups. See [Managing Incremental Backups](05_managing_incremental_backups/#managing_incremental_backups) for information about how retention policy management is applied to each backup type. + + The following sections describe how retention policy management generally applies to backups, and its specific usage and effect on full backups. + +
+ +overview_managing_backups_using_a_retention_policy marking_the_backup_status setting_the_retention_policy managing_the_backups_based_on_the_retention_policy managing_incremental_backups + +
diff --git a/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/03_basic_bart_subcommand_usage/01_check_config.mdx b/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/03_basic_bart_subcommand_usage/01_check_config.mdx new file mode 100644 index 00000000000..f12dd038edd --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/03_basic_bart_subcommand_usage/01_check_config.mdx @@ -0,0 +1,35 @@ +--- +title: "CHECK-CONFIG" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/check_config.html" +--- + + + +The `CHECK-CONFIG` subcommand checks the parameter settings in the BART configuration file as well as the database server configuration for which the `-s` option is specified. + +**Syntax:** + +`bart CHECK-CONFIG [ –s server_name ]` + +The following table describes the option. + +| Options | Description | +| ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s ` or `--server ` | `server_name` is the name of the database server to be checked for proper configuration. If the option is omitted, the settings of the global section of the BART configuration file are checked. | + +- When the `-s` option is omitted, the global section \[BART] parameters including `bart_host`, `backup_path`, and `pg_basebackup_path` are checked. +- When the `-s` option is specified, the server section parameters are checked. In addition, certain database server `postgresql.conf` parameters are also checked, which include the following: + - The `cluster_owner` parameter must be set to the user account owning the database cluster directory. + - A passwordless SSH/SCP connection must be set between the BART user and the user account specified by the `cluster_owner` parameter. + - A database superuser must be specified by the BART `user` parameter. + - The `pg_hba.conf` file must contain a replication entry for the database superuser specified by the BART `user` parameter. + - The `archive_mode` parameter in the `postgresql.conf` file must be enabled. + - The `archive_command` parameter in the `postgresql.auto.conf` or the `postgresql.conf` file must be set. + - The `allow_incremental_backups` parameter in the BART configuration file must be enabled for database servers for which incremental backups are to be taken. + - Archiving of WAL files to the `archive_path` must be in process. + - The WAL scanner program must be running. + +The `CHECK-CONFIG` subcommand displays an error message if the required configuration is not properly set. diff --git a/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/03_basic_bart_subcommand_usage/02_init.mdx b/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/03_basic_bart_subcommand_usage/02_init.mdx new file mode 100644 index 00000000000..d8cdeed8126 --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/03_basic_bart_subcommand_usage/02_init.mdx @@ -0,0 +1,41 @@ +--- +title: "INIT" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/init.html" +--- + + + +The `INIT` subcommand is used to create the BART backup catalog directory, rebuild the BART `backupinfo` file, and set the `archive_command` in the PostgreSQL server based on the `archive_command` setting in the `bart.cfg` file. + +!!! Note + If the `archive_mode` configuration parameter is set to `off`, then the `-o` option must be used to set the Postgres `archive_command` using the BART `archive_command` parameter in the BART configuration file even if the `archive_command` is not currently set in `postgresql.conf` nor in `postgresql.auto.conf` file. + +**Syntax:** + +```text +bart INIT [ –s { | all } ] [ -o ] + [ -r [ -i { | | all } ] ] + [--no-configure] +``` + +All subcommand options are generally specified in lowercase. The following table describes the command options: + +| Options | Description | +| ------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { \| all }`

`--server { \| all }` | `server_name` is the name of the database server to which the `INIT` actions are to be applied. If `all` is specified or if the option is omitted, the actions are applied to all servers. | +| `-o`

`--override` | Overrides the existing, active Postgres `archive_command` configuration parameter setting in the `postgresql.conf` file or the `postgresql.auto.conf` file using the BART `archive_command` parameter in the BART configuration file. The `INIT` generated archive command string is written to the `postgresql.auto.conf` file. | +| `-r`

`--rebuild` | Rebuilds the backupinfo file (a text file named `backupinfo`) located in each backup subdirectory. This option is only intended for recovering from a situation where the backupinfo file has become corrupt.
If the backup was initially created with a user-defined backup name, and then the `INIT -r` option is invoked to rebuild that `backupinfo` file, the user-defined backup name is no longer available. Thus, future references to the backup must use the backup identifier. | +| `-i { \| \| all }`

`--backupid { \| \| all }` | `` is an integer, backup identifier and `` is the user-defined alphanumeric name for the backup. If `all` is specified or if the option is omitted, the backupinfo files of all backups for the database servers specified by the `-s` option are recreated. The `-i` option can only be used with the `-r` option. | +| `--no-configure` | Prevents the `archive_command` from being set in the PostgreSQL server. | + +**Archive Command Setting** + +After the `archive_command` is set, you need to either restart the PostgreSQL server or reload the configuration file in the PostgreSQL server based on the following conditions. + +- If the `archive_mode` is set to `off` and `archive_command` is not set in the PostgreSQL server, the `archive_command` is set based on the `archive_command` setting in the `bart.cfg` and also sets the `archive_mode` to `on`. In this case, you need to restart the PostgreSQL server using `pg_ctl restart` +- If the `archive_mode` is set to `on` and `archive_command` is not set in the PostgreSQL server, the `archive_command` is set based on the `archive_command` setting in the `bart.cfg`. In this case, you need to reload the configuration in the PostgreSQL server using `pg_reload_conf()` or `pg_ctl reload`. +- If the `archive_mode` is set to `off` and `archive_command` is already set in the PostgreSQL server, the `archive_mode` is set to on. In this case, you need to restart the PostgreSQL server using `pg_ctl restart` +- If the `archive_mode` is set to `on` and `archive_command` is already set in the PostgreSQL server, then the `archive_command` is not set unless `-o` option is specified. diff --git a/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/03_basic_bart_subcommand_usage/03_backup.mdx b/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/03_basic_bart_subcommand_usage/03_backup.mdx new file mode 100644 index 00000000000..aa12cd957e2 --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/03_basic_bart_subcommand_usage/03_backup.mdx @@ -0,0 +1,104 @@ +--- +title: "BACKUP" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/backup.html" +--- + + + +The `BACKUP` subcommand is used to create a full backup or an incremental backup. + +**Syntax for full backup:** + +```text +bart BACKUP –s { | all } [ -F { p | t } ] + [ -z ] [ –c ] + [ --backup-name ] + [ --thread-count ] + [ { --with-pg_basebackup | --no-pg_basebackup } ] +``` + +!!! Note + While taking a backup, if a file (for example, database server log file) exceeding 1 GB size is stored in the `$PGDATA` directory, the backup will fail. To avoid such backup failure, you need to store large files (exceeding 1 GB) outside the `$PGDATA` directory. + +**Syntax for incremental Backup:** + +```text +bart BACKUP –s { | all } [ -F p] + [ --parent { | } ] + [ --backup-name ] + [ --thread-count ] + [ --check ] +``` + +!!! Note + To take an [incremental backup](../../02_overview/01_block-level_incremental_backup/#block-level_incremental_backup), you must take a full backup first followed by incremental backup. + +**Please Note:** + +- While a `BACKUP` subcommand is in progress, no other subcommands must be invoked. Any subcommands invoked while a backup is in progress will skip and ignore the backups. + +- For full backup, the target default format is a tar file, whereas for incremental backup, only plain format must be specified. + +- The backup is saved in the `//` directory, where `` is the value assigned to the `` parameter in the BART configuration file, `` is the lowercase name of the database server as listed in the configuration file, and `` is a backup identifier assigned by BART to the particular backup. + +- MD5 checksums of the full backup and any user-defined tablespaces are saved as well for tar backups. + +- Before performing the backup, BART checks to ensure if there is enough disk space to completely store the backup in the BART backup catalog. + +- In the `postgresql.conf` file, ensure the `wal_keep_segments` configuration parameter is set to a sufficiently large value. A low setting of the `wal_keep_segments` configuration parameter may result in the deletion of some WAL files before the BART `BACKUP` subcommand saves them to the `archive_path`. For information about the `wal_keep_segments` parameter, see the [PostgreSQL Core Documentation](https://www.postgresql.org/docs/current/static/runtime-config-replication.html). + +- In the BART configuration file, setting `xlog_method=stream` will instruct the server to stream the transaction log in parallel with creation of the backup for a specific database server; otherwise the transaction log files are collected upon completion of the backup. See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/latest/bart_inst/) for details about database server setting. + + !!! Note + If the transaction log streaming method is used, the `-Fp` option for a plain text backup format must be specified with the `BACKUP` subcommand. + +- When you use BART to take a backup of PostgreSQL server, multiple backups can be taken simultaneously and if a backup is interrupted, the backup mode is terminated automatically without the need to run `pg_stop_backup()` command manually to terminate the backup. + +**Options** + +Along with the `BACKUP` subcommand, specify the following option: + +| Options | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { server_name \| all }`
`--server { server_name \| all }` | `server_name` is the database server name to be backed up as specified in the BART configuration file. If `all` is specified, all servers are backed up. This option is mandatory.
If `all` is specified, and a connection to a database server listed in the BART configuration file cannot be opened, the backup for that database server is skipped, but the backup operation continues for the other database servers. | + +Specify the following options as required. If you do not specify any of the following options, the backup is created using default settings. + +| Options | Description | +| -------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-F { p \| t }`
`--format { p \| t }` | Specify this option to provide the backup file format. Use `p` for plain text or `t` for tar. If the option is omitted, the default is tar format.
For taking incremental backups, the option `-Fp` must be specified. | +| `-z`
`--gzip` | This is applicable only for full backup. Specify this option to use gzip compression on the tar file output using the default compression level. This option is applicable only for the tar format. | +| `-c `
`--compress-level ` | This is applicable only for full backup. Specify this option to use the gzip compression level on the tar file output. `compression_level` is a digit from 1 through 9, with 9 being the best compression. This option is applicable only for the tar format. | +| `--parent { backup_id \| backup_name }` | Specify this option to take an incremental backup. `` is the backup identifier of a parent backup. `` is the user-defined alphanumeric name of a parent backup.
The parent is a backup taken prior to the incremental backup. The parent backup can be either a full backup or an incremental backup.
The option `–Fp` must be specified since an incremental backup can only be taken in plain text format.
An incremental backup cannot be taken on a standby database server. See [Block-Level Incremental Backup](../../02_overview/01_block-level_incremental_backup/#block-level_incremental_backup) for additional information on incremental backups. | +| `--backup-name ` | Specify this option to assign a user-defined, alphanumeric friendly name to the backup. The maximum permitted length of backup name is 49 characters.
The backup name may include the following variables to be substituted by the timestamp values when the backup is taken: 1) `%year` – 4-digit year, 2) `%month` – 2-digit month, 3) `%day` – 2-digit day, 4) `%hour` 2-digit hour, 5) `%minute` – 2-digit minute, and 6) `%second` – 2-digit second.
To include the percent sign (`%`) as a character in the backup name, specify `%%` in the alphanumeric string.
If the backup name contains space characters (i.e. more than one word) or when referenced with the option `-i` by other subcommands (such as `restore`), enclose the string in single quotes or double quotes. See [backup name examples](#backup_name_examples).
If the `--backup-name` option is not specified, and the `backup_name` parameter is not set for this database server in the BART configuration file, then the backup can only be referenced in other BART subcommands by the BART assigned backup identifier. | +| `--thread-count ` | Use this option to use the number of worker threads to run in parallel to copy blocks for a backup.
If the option `--thread-count` is omitted, then the `thread_count` parameter in the BART configuration file applicable to this database server is used.
If the option `--thread-count` is not enabled for this database server, then the `thread_count` setting in the global section of the BART configuration file is used.
If the option `--thread-count` is not set in the global section as well, the default number of threads is 1.
If parallel backup is run with N number of worker threads, then it will initiate N+ 1 concurrent connections with the server.
Thread count will not be effective if backup is taken on a standby server.
For more information about the `--thread-count` parameter, see the EDB Backup and Recovery Installation and Upgrade Guide available at the [EDB website](/bart/latest/bart_inst/) | +| `--with-pg_basebackup` | This is applicable only for full backup. Specify this option to use `pg_basebackup` to take a full backup. The number of thread counts in effect is ignored as given by the `thread_count` parameter in the BART configuration file.
When taking a full backup, if the thread count in effect is greater than `1`, then the `pg_basebackup` utility is not used to take the full backup (parallel worker threads are used) unless the option `--with-pg_basebackup` is specified with the `BACKUP` subcommand. | +| `--no-pg_basebackup` | This is applicable only for full backup. Specify this option if you do not want `pg_basebackup` to be used to take a full backup.
When taking a full backup, if the thread count in effect is only `1`, then the `pg_basebackup` utility is used to take the full backup unless the option `--no-pg_basebackup` is specified with the `BACKUP` subcommand. | +| `--check` | This is applicable only for incremental backup. Specify this option to verify if the required MBM files are present in the `archived_wals` directory as specified in the `archive_path` parameter in the `bart.cfg` file before taking an incremental backup. The option `--parent` must be specified when the option `--check` is used. An actual incremental backup is not taken when the option `--check` is specified. | + + + +**Backup Name Examples** + +The following examples demonstrate using the `--backup-name` clause: + +```text +./bart backup -s ppas12 -Ft --backup-name "YEAR = %year +MONTH = %month DAY = %day" +./bart backup -s ppas12 -Ft --backup-name "YEAR = %year +MONTH = %month DAY = %day %%" +./bart show-backups -s ppas12 -i "test backup" +``` + +**Error messages** + +The following table lists the error messages that may be encountered when using the `BACKUP` subcommand: + +| error message | Cause | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `edb@localhost bin]$ ./bart backup -s mktg -Ft`

`WARNING: xlog_method is empty, defaulting to global policy`

`ERROR: backup failed for server 'mktg'`

`free disk space is not enough to backup the server 'mktg'`

`space available 13.35 GB, approximately required 14.65 GB` | Insufficient free disk space. | +| `ERROR: backup failed for server 'mktg'`

`command failed with exit code 1`

`pg_basebackup: could not get transaction log end position from server: ERROR: requested WAL segment 00000001000000D50000006B has already been removed` | The wal_keep_segments configuration parameter is not set to a sufficiently large value in the postgresql.conf file. | +| `ERROR: backup failed for server 'mktg'`

`connection to the server failed: could not connect to server: Connection refused`

`Is the server running on host "172.16.114.132" and accepting`

`TCP/IP connections on port 5444?` | A connection to a database server listed in the BART configuration file fails. As a result the backup for that database server is skipped, but the backup operation continues for other database servers | diff --git a/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/03_basic_bart_subcommand_usage/04_show_servers.mdx b/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/03_basic_bart_subcommand_usage/04_show_servers.mdx new file mode 100644 index 00000000000..778efd3d4d6 --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/03_basic_bart_subcommand_usage/04_show_servers.mdx @@ -0,0 +1,21 @@ +--- +title: "SHOW-SERVERS" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/show_servers.html" +--- + + + +The `SHOW-SERVERS` subcommand displays the information for the managed database servers listed in the BART configuration file. + +**Syntax:** + +`bart SHOW-SERVERS [ –s { | all } ]` + +The following table describes the command options. + +| Options | Description | +| ---------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { \| all }`
`--server { \| all }` | `` is the name of the database server whose BART configuration information is to be displayed. If `all` is specified or if the option is omitted, information for all database servers is displayed. | diff --git a/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/03_basic_bart_subcommand_usage/05_show_backups.mdx b/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/03_basic_bart_subcommand_usage/05_show_backups.mdx new file mode 100644 index 00000000000..d006df69db1 --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/03_basic_bart_subcommand_usage/05_show_backups.mdx @@ -0,0 +1,25 @@ +--- +title: "SHOW-BACKUPS" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/show_backups.html" +--- + +The `SHOW-BACKUPS` subcommand displays the backup information for the managed database servers. + +**Syntax:** + +```text +bart SHOW-BACKUPS [ –s { | all } ] + [ -i { | | all } ] + [ -t ] +``` + +The following table describes the command options: + +| Options | Description | +| ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { \| all }`
`--server { \| all }` | `` is the name of the database server whose backup information is to be displayed.
If `all` is specified or if the option is omitted, the backup information for all database servers is displayed with the exception as described by the following note:
If `SHOW-BACKUPS` is invoked while the BART `BACKUP` subcommand is in progress, backups affected by the backup process are shown in progress status in the displayed backup information. | +| `-i { \| \| all }`
`--backupid { \| \| all }` | `` is a backup identifier and `` is the user-defined alphanumeric name for the backup.
If `all` is specified or if the option is omitted, all backup information for the relevant database server is displayed. | +| `-t`
`--toggle` | Displays more backup information in a list format. If the option is omitted, the default is a tabular format. | diff --git a/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/03_basic_bart_subcommand_usage/06_verify_chksum.mdx b/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/03_basic_bart_subcommand_usage/06_verify_chksum.mdx new file mode 100644 index 00000000000..4ec79d52d62 --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/03_basic_bart_subcommand_usage/06_verify_chksum.mdx @@ -0,0 +1,29 @@ +--- +title: "VERIFY-CHKSUM" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/verify_chksum.html" +--- + + + +The `VERIFY-CHKSUM` subcommand verifies the MD5 checksums of the full backups and any user-defined tablespaces for the specified database server or for all database servers. The checksum is verified by comparing the current checksum of the backup against the checksum when the backup was taken. + +!!! Note + The `VERIFY-CHKSUM` subcommand is only used for tar format backups. It is not applicable to plain format backups. + +**Syntax:** + +```text +bart VERIFY-CHKSUM + [ -s { | all } ] + [ -i { | | all } ] +``` + +The following table describes the command options: + +| Options | Description | +| ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { \| all }`

`--server { \| all }` | `` is the name of the database server whose tar backup checksums are to be verified. If `all` is specified or if the `-s` option is omitted, the checksums are verified for all database servers. | +| `-i { \| \| all }`

`--backupid { \| \| all }` | `` is the backup identifier of a tar format full backup whose checksum is to be verified along with any user-defined tablespaces.
`` is the user-defined alphanumeric name for the full backup.
If `all` is specified or if the `-i` option is omitted, the checksums of all tar backups for the relevant database server are verified. | diff --git a/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/03_basic_bart_subcommand_usage/07_manage.mdx b/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/03_basic_bart_subcommand_usage/07_manage.mdx new file mode 100644 index 00000000000..52a74badaa7 --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/03_basic_bart_subcommand_usage/07_manage.mdx @@ -0,0 +1,62 @@ +--- +title: "MANAGE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/manage.html" +--- + + + +The `MANAGE` subcommand can be invoked to: + +- Evaluate backups, mark their status, and delete obsolete backups based on the `retention_policy` parameter in the BART configuration file (See [Managing Backups Using a Retention Policy](../02_managing_backups_using_a_retention_policy/#managing_backups_using_a_retention_policy) for information about retention policy management). + +- Compress the archived WAL files based on the `wal_compression` parameter in the BART configuration file (See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/latest/bart_inst/) for information about setting this parameter). + + **Syntax:** + + ```text + bart MANAGE [ –s { | all} ] + [ -l ] [ -d ] + [ -c { keep | nokeep } + -i { | | all } ] + [ -n ] + ``` + +The following summarizes the actions performed when the `MANAGE` subcommand is invoked: + +- When the `MANAGE` subcommand is invoked with no options or with only the `-s ` or `-s all` option, the following actions are performed: + - For the server specified by the `-s` option, or for all servers (if `-s all` is specified or the `-s` option is omitted), active backups are marked as `obsolete` in accordance with the retention policy. + - All backups that were marked `obsolete` or `keep` prior to invoking the `MANAGE` subcommand remain marked with the same prior status. + - If WAL compression is enabled for the database server, then any uncompressed, archived WAL files in the BART backup catalog of the database server are compressed with gzip. +- When the `MANAGE` subcommand is invoked with any other option besides the `-s` option, the following actions are performed: + - For the server specified by the `-s` option, or for all servers, the action performed is determined by the other specified options (that is, `-l` to list obsolete backups, `-d` to delete obsolete backups, `-c` to keep or to return backups to `active` status, or `-n` to perform a dry run of any action). + - No marking of `active` backups to `obsolete` status is performed regardless of the retention policy. + - All backups that were marked `obsolete` or `keep` prior to invoking the `MANAGE` subcommand remain marked with the same prior status unless the `-c` option (without the `-n` option) is specified to change the backup status of the particular backup or all backups referenced with the `-i` option. + - No compression is applied to any uncompressed, archived WAL file in the BART backup catalog regardless of whether or not WAL compression is enabled. + +The following are additional considerations when using WAL compression: + +- Compression of archived WAL files is not permitted for database servers on which incremental backups are to be taken. +- The gzip compression program must be installed on the BART host and be accessible in the `PATH` of the BART user account. +- When the `RESTORE` subcommand is invoked, if the `-c` option is specified or if the `copy_wals_during_restore` BART configuration parameter is enabled for the database server, then the following actions occur: + + - If compressed, archived WAL files are stored in the BART backup catalog and the location to which the WAL files are to be restored is on a remote host relative to the BART host: + + - the archived WAL files are transmitted across the network to the remote host in compressed format only if the gzip compression program is accessible in the `PATH` of the remote user account that is used to log into the remote host when performing the `RESTORE` operation. + - This remote user is specified with either the `remote_host` parameter in the BART configuration file or the `RESTORE -r` option (see [RESTORE](08_restore/#restore)). + - Transmission of compressed WAL files results in less network traffic. After the compressed WAL files are transmitted across the network, the `RESTORE` subcommand uncompresses the files for the point-in-time recovery operation. + - If the gzip program is not accessible on the remote host in the manner described in the previous bullet point, then the compressed, archived WAL files are first uncompressed while on the BART host, then transmitted across the network to the remote host in uncompressed format. +- When the `RESTORE` subcommand is invoked without the `-c` option and the `copy_wals_during_restore` BART configuration parameter is disabled for the database server, then any compressed, archived WAL files needed for the `RESTORE` operation are uncompressed in the BART backup catalog. The uncompressed WAL files can then be saved to the remote host by the `restore_command` in the `postgresql.auto.conf` file when the database server archive recovery begins. + +The following table describes the command options: + +| Options | Description | +| ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `s { \| all }`
`--server { \| all }` | `` is the name of the database server to which the actions are to be applied. If `all` is specified or if the `-s` option is omitted, the actions are applied to all database servers. | +| `-l`
`--list-obsolete` | Lists the backups marked as obsolete. | +| `-d`
`--delete-obsolete` | Delete the backups marked as `obsolete`. This action physically deletes the backup along with its archived WAL files and any MBM files for incremental backups. | +| `-c { keep \| nokeep }`

`--change-status { keep \| nokeep }` | Specify `keep` to change the status of a backup to `keep` to retain it indefinitely.
Specify `nokeep` to change the status of any backup back to active status. The backup can then be re-evaluated and possibly be marked to `obsolete` according to the retention policy by subsequent usage of the `MANAGE` subcommand.
The `–i` option must be included when using the `-c` option. | +| `-i { \| \| all }`

`--backupid { \| \| all }` | `` is a backup identifier and `` is the user-defined alphanumeric name for the backup.
If `all` is specified, then actions are applied to all backups.
The `–c` option must be included when using the `-i` option. | +| `-n`
`--dry-run` | Performs the test run and displays the results prior to actually implementing the actions as if the operation was performed, however, no changes are actually made.
If `-n` is specified with the `-d` option, it displays which backups would be deleted, but does not actually delete the backups.
If `-n` is specified with the `-c` option, it displays the keep or nokeep action, but does not actually change the backup from its current status.
If `-n` is specified alone with no other options, or with only the `-s` option, it displays which active backups would be marked as obsolete, but does not actually change the backup status. In addition, no compression is performed on uncompressed, archived WAL files even if WAL compression is enabled for the database server. | diff --git a/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/03_basic_bart_subcommand_usage/08_restore.mdx b/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/03_basic_bart_subcommand_usage/08_restore.mdx new file mode 100644 index 00000000000..d74a4d1f5d6 --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/03_basic_bart_subcommand_usage/08_restore.mdx @@ -0,0 +1,46 @@ +--- +title: "RESTORE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/restore.html" +--- + + + +The `RESTORE` subcommand restores a backup and its archived WAL files for the designated database server to the specified directory location. If the appropriate `RESTORE` options are specified, all recovery settings will be saved in the `postgresql.auto.conf` file. + +**Syntax:** + +```text +bart RESTORE –s -p + [ –i { | } ] + [ -r ] + [ -w ] + [ -t ] + [ { -x | -g } ] + [ -c ] +``` + +For information about using a continuous archive backup for recovery, see the [PostgreSQL Core Documentation](https://www.postgresql.org/docs/13/static/continuous-archiving.html). This reference material provides detailed information about the underlying point-in-time recovery process and the meaning and usage of the restore options that are generated into the `postgresql.auto.conf` file by BART. + +**Please note**: + +- For special requirements when restoring an incremental backup to a remote database server, see [Restoring an Incremental Backup on a Remote Host](../../02_overview/01_block-level_incremental_backup/05_restoring_an_incremental_backup/#restoring_an_incremental_backup_on_a_remote_host). +- Check to ensure that the host where the backup is to be restored contains enough disk space for the backup and its archived WAL files. The `RESTORE` subcommand may result in an error while copying files if there is not enough disk space available. +- See [Performing a Restore Operation](../01_bart_management_overview/01_performing_a_restore_operation/#performing_a_restore_operation) to view steps on how to perform a restore operation and see [Point-In-Time Recovery Operation](../01_bart_management_overview/02_point_in_time_recovery_operation/#point_in_time_recovery_operation) to view steps on how to perform a point-in-time recovery operation. +- If the backup is restored to a different database cluster directory than where the original database cluster resided, certain operations dependent upon the database cluster location may fail. This happens if their supporting service scripts are not updated to reflect the new directory location of restored backup. For information about the usage and modification of service scripts, see the *EDB Advanced Server Installation Guide* available at the [EDB website](/epas/latest/). + +The following table describes the command options: + +| Options | Description | +| ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s `
`--server ` | `` is the name of the database server to be restored. | +| `-p `
`--restore-path ` | `` is the directory path where the backup of the database server is to be restored. The directory must be empty and have the proper ownership and privileges assigned to it. | +| `-i { \| }`

`--backupid { \| }` | `` is the backup identifier of the backup to be used for the restoration and `` is the user-defined alphanumeric name for the backup.
If the option is omitted, the default is to use the latest backup. | +| `-r or --remote-host ` | `` is the user account on the remote database server host that accepts a passwordless SSH/SCP login connection and is the owner of the directory where the backup is to be restored and `` is the IP address of the remote host to which the backup is to be restored. This option must be specified if the `` parameter for this database server is not set in the BART configuration file.
If the BART user account is not the same as the operating system account owning the `` directory given with the `-p` option, use the `` BART configuration parameter or the `RESTORE` subcommand `-r` option to specify the `` directory owner even when restoring to a directory on the same host as the BART host.
See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/latest/bart_inst/) for information about the `` parameter. | +| `-w `
`--workers ` | `` is the specification of the number of worker processes to run in parallel to stream the modified blocks of an incremental backup to the restore location.
For example, if 4 worker processes are specified, 4 receiver processes on the restore host and 4 streamer processes on the BART host are used. The output of each streamer process is connected to the input of a receiver process. When the receiver gets to the point where it needs a modified block file, it obtains those modified blocks from its input. With this method, the modified block files are never written to the restore host disk. If the `-w` option is omitted, the default is `1` \| worker process. | +| `-t `
`--target-tli ` | `` is the integer identifier of the timeline to be used for replaying the archived WAL files for point-in-time recovery. | +| `-x `
`--target-xid ` | `` is the integer identifier of the transaction ID that determines the transaction up to and including, which point-in-time recovery encompasses. Include either the `-x ` or the `--target-xid ` option if point-in-time recovery is desired. | +| `-g `

`--target-timestamp ` | `` is the timestamp that determines the point in time up to and including, which point-in-time recovery encompasses. Include either the `--target-timestamp ` or the `-g ` option if point-in-time recovery is desired. | +| `-c`
`--copy-wals` | Specify this option to copy archived WAL files from the BART backup catalog to `/archived_wals` directory.
If recovery settings are saved in the `postgresql.auto.conf` file for point-in-time recovery, the `restore_command` retrieves the WAL files from `/archived_wals` for the database server archive recovery.
If the `-c` option is omitted and the `copy_wals_during_restore` parameter in the BART configuration file is not enabled in a manner applicable to this database server, the `restore_command` in the `postgresql.auto.conf` file is generated by default to retrieve the archived WAL files directly from the BART backup catalog. See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/latest/bart_inst/) for information about the `copy_wals_during_restore` parameter. | \ No newline at end of file diff --git a/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/03_basic_bart_subcommand_usage/09_delete.mdx b/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/03_basic_bart_subcommand_usage/09_delete.mdx new file mode 100644 index 00000000000..7f9836ad724 --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/03_basic_bart_subcommand_usage/09_delete.mdx @@ -0,0 +1,34 @@ +--- +title: "DELETE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/delete.html" +--- + + + +The `DELETE` subcommand removes the subdirectory and data files from the BART backup catalog for the specified backups along with its archived WAL files. + +**Syntax:** + +```text +bart DELETE –s + -i { all | + [']{ | },... }['] + } + [ -n ] +``` + +!!! Note + While invoking the `DELETE` subcommand, you must specify a specific database server. + +For database servers under a retention policy, there are conditions where certain backups may not be deleted. See [Deletions Permitted Under a Retention Policy](../02_managing_backups_using_a_retention_policy/04_managing_the_backups_based_on_the_retention_policy/#deletions_permitted_under_retention_policy) for information about permitted backup deletions. + +The following table describes the command options: + +| Options | Description | +| -------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s `

`--server ` | `` is the name of the database server whose backups are to be deleted. | +| `-i { all \| [']{ \| },... }['] }`

`--backupid { all \| [']{ \| },... }['] }` | `` is the backup identifier of the backup to be deleted and `` is the user-defined alphanumeric name for the backup.
Multiple backup identifiers and backup names may be specified in a comma-separated list. The list must be enclosed within single quotes if there is any white space appearing before or after each comma.
If `all` is specified, all of the backups and their archived WAL files for the specified database server are deleted. | +| `-n`
`--dry-run` | Displays the results as if the deletions were done, however, no physical removal of the files are actually performed. In other words, a test run is performed so that you can see the potential results prior to actually initiating the action.
After the deletion, the BART backup catalog for the database server no longer contains the corresponding directory for the deleted backup ID. The `archived_wals` subdirectory no longer contains the WAL files of the backup. | diff --git a/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/03_basic_bart_subcommand_usage/index.mdx b/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/03_basic_bart_subcommand_usage/index.mdx new file mode 100644 index 00000000000..379dd137082 --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/03_basic_bart_subcommand_usage/index.mdx @@ -0,0 +1,50 @@ +--- +title: "Basic BART Subcommand Usage" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/basic_bart_subcommand_usage.html" +--- + + + +This section briefly describes the BART subcommands and options. You can invoke the `bart` program (located in the `/bin` directory) with the desired options and subcommands to manage your BART installation. + +To view examples of BART subcommands, see the *EDB Backup and Recovery Reference Guide* available at the [EDB website](/bart/latest/bart_ref/). + +**Syntax for invoking BART**: + + `bart [ general_option ]... [ subcommand ] [subcommand_option ]...` + +- When invoking a subcommand, the subcommand name is not case-sensitive (that is, the subcommand can be specified in uppercase, lowercase, or mixed case). +- Each subcommand has a number of its own applicable options that are specified following the subcommand. All options are available in both single-character and multi-character forms. +- Keywords are case-sensitive; options are generally specified in lowercase unless specified otherwise in this section. +- When invoking BART, the current user must be the BART user account (operating system user account used to run the BART command line program). For example, enterprisedb or postgres can be selected as the BART user account when the managed database servers are Advanced Server or PostgreSQL respectively. +- The chosen operating system user account must own the BART backup catalog directory, be able to run the `bart` program and the `bart scanner` program, and have a passwordless SSH/SCP connection established between database servers managed by BART. + +You can specify one or more of the following general options: + +| Options | Description | +| ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-h` or `--help` | Displays general syntax and information on BART usage. All subcommands support a help option (`-h`, `--help`). If the help option is specified, information is displayed regarding that particular subcommand. The subcommand, itself, is not executed. | +| `-v` or `--version` | Displays the BART version information. | +| `-d` or `--debug` | Displays debugging output while executing BART subcommands. | +| `-c `or `--config-path ` | Specifies `config_file_path` as the full directory path to a BART configuration file. Use this option if you do not want to use the default BART configuration file `/etc/bart.cfg`. | + +**Troubleshooting: Setting Path Environment Variable** + +If execution of BART subcommands fails with the following error message, then you need to set the `LD_LIBRARY_PATH` to include the `libpq` library directory: + + `./bart: symbol lookup error: ./bart: undefined symbol: PQping` + +**Workaround:** Set the `LD_LIBRARY_PATH` environment variable for the BART user account to include the directory containing the `libpq` library. This directory is `POSTGRES_INSTALL_HOME/lib`. + +It is suggested that the `PATH` and the `LD_LIBRARY_PATH` environment variable settings be placed in the BART user account’s profile. See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/latest/bart_inst/) for details. + +In the following sections, the `help` option is omitted from the syntax diagrams for the purpose of providing readability for the subcommand options. + +
+ +check_config init backup show_servers show_backups verify_chksum manage restore delete + +
diff --git a/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/04_running_the_bart_wal_scanner.mdx b/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/04_running_the_bart_wal_scanner.mdx new file mode 100644 index 00000000000..b047505556e --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/04_running_the_bart_wal_scanner.mdx @@ -0,0 +1,56 @@ +--- +title: "Running the BART WAL Scanner" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/running_the_bart_wal_scanner.html" +--- + + + +Use the BART WAL scanner to invoke the `bart-scanner` program located in the `BART_HOME/bin` directory. When invoking the WAL scanner, the current user must be the BART user account. + +**Syntax:** + +```text +bart-scanner + [ -d ] + [ -c ] + { –h | + -v | + --daemon | + -p | + | + RELOAD | + STOP +``` + +!!! Note + For clarity, the syntax diagram shows only the single-character option form (for example, `-d`), but the multi-character option form (for example, `--debug`) is supported as well. + +The WAL scanner processes each WAL file to find and record modified blocks in a corresponding modified block map (MBM) file. The default approach is that the WAL scanner gets notified whenever a new WAL file is added to the `archived_wals` directory specified in the `archive_path` parameter of the configuration file. It then scans the WAL file and produces the MBM file. + +The default approach does not work in some cases; for example when the WAL files are shipped to the `archive_path` using the Network File System (NFS) and also in case of some specific platforms. This results in the WAL files being copied to the `archived_wals` directory, but the WAL scanner does not scan them (as WAL scanner is not aware of WAL file) and produce the MBM files. This results in the failure of an incremental backup. This can be avoided by using the timer-based WAL scanning approach, which is done by using the `scan_interval` parameter in the BART configuration file. The value for `scan_interval` is the number of seconds after which the WAL scanner will initiate force scanning of the new WAL files. See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/latest/bart_inst/) for more information about `scan_interval` parameter. + +When the `bart-scanner` program is invoked, it forks a separate process for each database server enabled with the `allow_incremental_backups` parameter. + +The WAL scanner processes can run in either the foreground or background depending upon usage of the `--daemon` option. Use the `--daemon` option to run the WAL scanner process in the background so that all output messages can be viewed in the BART log file. If the `--daemon` option is omitted, the WAL scanner process runs in the foreground and all output messages can be viewed from the terminal running the program as well as in the BART log file. + +See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/latest/bart_inst/) for additional information about WAL scanning, `allow_incremental_backups`, and `logfile` parameters. + +!!! Note + The BART user account’s `LD_LIBRARY_PATH` environment variable may need to be set to include the directory containing the `libpq` library if invocation of the WAL scanner program fails. See [Basic BART Subcommand Usage](03_basic_bart_subcommand_usage/#basic_bart_subcommand_usage) for information about setting the `LD_LIBRARY_PATH` environment variable. + +The following table describes the scanner options: + +| Options | Description | +| ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-h` `--help` | Displays general syntax and information on WAL scanner usage. | +| `-v` `--version` | Displays the WAL scanner version information. | +| `-d` `--debug` | Displays debugging output while executing the WAL scanner with any of its options. | +| `-c ` `--config-path ` | Use this option to specify the `config_file_path` of a BART configuration file if you do not want to use the default BART configuration file path `BART_HOME/etc/bart.cfg`. | +| `--daemon` | Runs the WAL scanner as a background process. | +| `-p ` `--print ` | Use this option to specify the full directory path to an MBM file whose content is to be printed. The directory specified in the `archive_path` parameter in the `bart.cfg` file contains the MBM files. | +| `` | Specify the full directory path to a WAL file to be scanned. The directory specified in the `archive_path` parameter in the `bart.cfg` file contains the WAL files. Use this option if a WAL file in the archive path is missing its MBM file. This option is to be used for assisting the EnterpriseDB support team for debugging problems that may have been encountered. | +| `RELOAD` | Reloads the BART configuration file. The keyword `RELOAD` is not case-sensitive. The `RELOAD` option is useful if you make changes to the configuration file after the WAL scanner has been started. It will reload the configuration file and adjust the WAL scanners accordingly. For example, if a server section allowing incremental backups is removed from the BART configuration file, then the process attached to that server will stop. Similarly, if a server allowing incremental backups is added, a new WAL scanner process will be launched to scan the WAL files of that server. | +| `STOP` | Stops the WAL scanner. The keyword `STOP` is not case-sensitive. | diff --git a/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/index.mdx b/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/index.mdx new file mode 100644 index 00000000000..a076b82b5e9 --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_user/03_using_bart/index.mdx @@ -0,0 +1,19 @@ +--- +title: "Using BART" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/using_bart.html" +--- + + + +After installing and configuring the BART host and the database servers, you can start using BART. + +This section describes how to perform backup and recovery management operations using BART. Review the sections that follow before proceeding with any BART operation. + +
+ +bart_management_overview managing_backups_using_a_retention_policy basic_bart_subcommand_usage running_the_bart_wal_scanner + +
diff --git a/product_docs/docs/bart/2.5.9/bart_user/04_using_tablespaces.mdx b/product_docs/docs/bart/2.5.9/bart_user/04_using_tablespaces.mdx new file mode 100644 index 00000000000..94d5450778a --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_user/04_using_tablespaces.mdx @@ -0,0 +1,59 @@ +--- +title: "Using Tablespaces" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/using_tablespaces.html" +--- + + + +If the database cluster contains user-defined tablespaces (that is, tablespaces created with the `CREATE TABLESPACE` command): + +- You can take full backups with the `BACKUP` subcommand in either tar (`-Ft`) or plain text (`-Fp`) backup file format. +- You must take incremental backups in the plain text (`-Fp`) backup file format. +- You can take full backups using the transaction log streaming method (xlog_method = stream in the BART configuration file) `--with-pg_basebackup` and the `BACKUP` subcommand in either tar (`-Ft`) or plain text (`-Fp`) backup file format. + +!!! Note + If the particular database cluster you plan to back up contains tablespaces created by the `CREATE TABLESPACE` command, then you must set the `tablespace_path` parameter in the BART configuration file before you perform a BART `RESTORE` operation. + +The `tablespace_path` parameter specifies the directory paths to which you want the tablespaces to be restored. It takes the following format: + + `OID_1=tablespace_path_1;OID_2=tablespace_path_2 ...` + +Where `OID_1`, `OID_2`, … are the Object Identifiers of the tablespaces. You can find the OIDs of the tablespaces and their corresponding soft links to the directories by listing the contents of the `POSTGRES_INSTALL_HOME/data/pg_tblspc` subdirectory as shown in the following example: + +```text +[root@localhost pg_tblspc ]# pwd +/opt/PostgresPlus/9.6AS/data/pg_tblspc +[root@localhost pg_tblspc]# ls -l +total 0 +lrwxrwxrwx 1 enterprisedb enterprisedb 17 Aug 22 16:38 16644 -> /mnt/tablespace_1 +lrwxrwxrwx 1 enterprisedb enterprisedb 17 Aug 22 16:38 16645 -> /mnt/tablespace_2 +``` + +The OIDs are `16644` and `16645` to directories `/mnt/tablespace_1` and `/mnt/tablespace_2`, respectively. + +If you later wish to restore the tablespaces to the same locations as indicated in the preceding example, the BART configuration file must contain the following entry: + +```text +[ACCTG] +host = 127.0.0.1 +port = 5444 +user = enterprisedb +cluster_owner = enterprisedb +tablespace_path = 16644=/mnt/tablespace_1;16645=/mnt/tablespace_2 +description = "Accounting" +``` + +If you later wish to restore the tablespaces to different locations, specify the new directory locations in the `tablespace_path` parameter. + +In either case, the directories specified in the `tablespace_path` parameter must exist and be empty at the time you perform the `BART RESTORE` operation. + +If the database server is running on a remote host (in other words you are also using the `remote_host` configuration parameter or will specify the `--remote-host` option with the `RESTORE` subcommand), the specified tablespace directories must exist on the specified remote host. + +To view example of backing up and restoring a database cluster on a remote host containing tablespaces, see the *EDB Backup and Recovery Reference Guide* available at the [EDB website](/bart/latest/bart_ref/). + +The directories must be owned by the user account with which you intend to start the database server (typically the Postgres user account) with no access by other users or groups as is required for the directory path to which the main full backup is to be restored. + +To view a sample BART managed backup and recovery system consisting of both local and remote database servers, see the *EDB Backup and Recovery Reference Guide* available at the [EDB website](/bart/latest/bart_ref/). diff --git a/product_docs/docs/bart/2.5.9/bart_user/images/EDB_logo.png b/product_docs/docs/bart/2.5.9/bart_user/images/EDB_logo.png new file mode 100644 index 00000000000..39a54822d85 Binary files /dev/null and b/product_docs/docs/bart/2.5.9/bart_user/images/EDB_logo.png differ diff --git a/product_docs/docs/bart/2.5.9/bart_user/images/copy_1.png b/product_docs/docs/bart/2.5.9/bart_user/images/copy_1.png new file mode 100644 index 00000000000..b15833dc37d Binary files /dev/null and b/product_docs/docs/bart/2.5.9/bart_user/images/copy_1.png differ diff --git a/product_docs/docs/bart/2.5.9/bart_user/images/edb.png b/product_docs/docs/bart/2.5.9/bart_user/images/edb.png new file mode 100644 index 00000000000..71e5bdde787 Binary files /dev/null and b/product_docs/docs/bart/2.5.9/bart_user/images/edb.png differ diff --git a/product_docs/docs/bart/2.5.9/bart_user/images/edb_logo.svg b/product_docs/docs/bart/2.5.9/bart_user/images/edb_logo.svg new file mode 100644 index 00000000000..f24d1dfefee --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_user/images/edb_logo.svg @@ -0,0 +1,19 @@ + + + edb-logo-disc-dark + + + + \ No newline at end of file diff --git a/product_docs/docs/bart/2.5.9/bart_user/index.mdx b/product_docs/docs/bart/2.5.9/bart_user/index.mdx new file mode 100644 index 00000000000..50504d9e3db --- /dev/null +++ b/product_docs/docs/bart/2.5.9/bart_user/index.mdx @@ -0,0 +1,17 @@ +--- +navTitle: Backup and Recovery Guide +title: "EDB Postgres Backup and Recovery User Guide" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/genindex.html" + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/introduction.html" + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/conclusion.html" + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/index.html" +--- + +
+ +introduction overview using_bart using_tablespaces conclusion + +
diff --git a/product_docs/docs/bart/2.5.9/bart_v2.5.9_documentation.pdf b/product_docs/docs/bart/2.5.9/bart_v2.5.9_documentation.pdf new file mode 100644 index 00000000000..64af0d56209 Binary files /dev/null and b/product_docs/docs/bart/2.5.9/bart_v2.5.9_documentation.pdf differ diff --git a/product_docs/docs/bart/2.5.9/index.mdx b/product_docs/docs/bart/2.5.9/index.mdx new file mode 100644 index 00000000000..5a4e4fd6cc0 --- /dev/null +++ b/product_docs/docs/bart/2.5.9/index.mdx @@ -0,0 +1,17 @@ +--- +title: Backup and Recovery Tool +directoryDefaults: + description: "EDB Backup and Recovery Tool Version 2.5.9 Documentation and release notes. A tool to manage and configure PostgreSQL backups and disaster recovery." +navigation: + - "#Getting Started" + - bart_inst + - bart_qs_7 + - bart_qs_8 + - "#Guides" + - bart_user + - bart_ref +--- + + + + diff --git a/product_docs/docs/bart/2.5/bart_inst/02_installing_bart.mdx b/product_docs/docs/bart/2.5/bart_inst/02_installing_bart.mdx new file mode 100644 index 00000000000..ae888987e6e --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_inst/02_installing_bart.mdx @@ -0,0 +1,433 @@ +--- +title: 'Installing BART' + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/installation-getting-started/installation-upgrade-guide/2.6.1/installing_bart.html" +--- + +This section will walk you through performing a fresh installation of BART on a host. Installation instructions are organized into the following platform/installer specific sections: + +- [Installing BART on a CentOS Host](#installing-bart-on-a-centos-host) +- [Installing BART on a RHEL Host](#installing-bart-on-a-rhel-host) +- [Installing BART on a RHEL/CentOS 7 PPCLE Host](#installing-bart-on-a-rhelcentos-7-ppcle-host) +- [Installing BART on a Debian or Ubuntu Host](#installing-bart-on-a-debian-or-ubuntu-host) +- [Installing BART on an SLES 12 Host](#installing-bart-on-an-sles-12-host) + +!!! Note + If you are using the pdf version of this document, using the cut/paste command to copy may result in extra spaces or carriage returns in the pasted command. If a command fails, check the command carefully for additional characters. + +## Installing BART on a CentOS Host + +The following section demonstrates installing BART on a CentOS host using an RPM package.  This section assumes that the user has some knowledge of installation and system administration procedures, and has administrative privileges on the host. + +1. To install the repository configuration, assume superuser privileges and invoke one of the following platform-specific commands: + + On CentOS 7: + + ```text + yum -y install https://yum.enterprisedb.com/edbrepos/edb-repo-latest.noarch.rpm + ``` + + On CentOS 8: + + ```text + dnf -y install https://yum.enterprisedb.com/edbrepos/edb-repo-latest.noarch.rpm + ``` + +2. Replace the `USERNAME:PASSWORD` in the following command with the username and password of a registered EnterpriseDB user: + + ```text + sed -i "s@:@USERNAME:PASSWORD@" /etc/yum.repos.d/edb.repo + ``` + + To request credentials for the repository, visit the [EDB website](https://www.enterprisedb.com/user). + +3. Before installing BART, execute the following command to install the Extra Packages for Enterprise Linux (EPEL) release package: + + On CentOS 7: + + ```text + yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm + ``` + + On CentOS 8: + + ```text + dnf -y install epel-release + ``` + +4. For CentOS 8, enable the PowerTools repository to satisfy EPEL package dependencies: + + ```text + dnf config-manager --set-enabled PowerTools + ``` + +5. For CentOS 8, disable the built-in PostgreSQL module: + + ```text + dnf -qy module disable postgresql + ``` + +6. Optionally, install the `pg_basebackup` utility program using the server client package. If you do not already have the `pg_basebackup` program installed on the BART host, you can install a limited number of files that include the `pg_basebackup` program by invoking the following command: + + On CentOS 7: + + ```text + yum install edb-as-server-client + ``` + + On CentOS 8: + + ```text + dnf install edb-as-server-client + ``` + + In the above command, replace `` with the required Advanced Server version. The `pg_basebackup` version must be the same or more recent than the database server to be backed up. For example, `pg_basebackup` version 10 can be used to back up database server version 10, but cannot be used to back up database server version 11. + +7. Use the following command to install BART: + + On CentOS 7: + + ```text + yum -y install edb-bart-2.5.9 + ``` + + On CentOS 8: + + ```text + dnf -y install edb-bart-2.5.9 + ``` + + Repeat the installation process described in this section to install BART on each remote host on which an incremental backup is to be restored. + + To verify the BART installation, navigate to the `/usr/edb/bart/bin` directory and execute the following command: + + ```text + bart --version + ``` + + The `bart --version` command should return the current BART version. If the `bart --version` command returns an error stating the PATH is not available after switching from the root user to another BART user account, adjust the setting of the `PATH` environment variable to include the directory location of the BART `bin` subdirectory in the `~/.bashrc` or `~/.bash_profile` files of the following user accounts: + + - The BART user account on the BART host. See [Configuring BART](03_configuring_bart/#path) for details. + - The remote user account on the remote host to which incremental backups are to be restored. For details, see the *EDB Backup and Recovery User Guide* available at the [EDB website](/bart/2.5/bart_user/). + + Upon successful installation, BART is installed in the `BART_HOME` directory: + + `/usr/edb/bart` + + The installation includes the following files: + +| File Name | Location | Description | +| ------------------- | ----------------- | ------------------------------------- | +| bart | ``/bin | BART command line, executable program | +| bart-scanner | ``/bin | BART WAL scanner program | +| bart.cfg.sample | ``/etc | Sample BART configuration file | +| xlogreader_ident.so | ``/lib | Libraries supporting WAL versions | +| bart_license.txt | `` | License agreement | + +After BART is installed successfully, you need to [configure the installation](03_configuring_bart/#configuration). + +## Installing BART on a RHEL Host + +The following section demonstrates installing BART on a RHEL host using an RPM package.  This section assumes that the user has some knowledge of installation and system administration procedures, and has administrative privileges on the host. + +1. To install the repository configuration, assume superuser privileges and invoke one of the following platform-specific commands: + + On RHEL 7: + + ```text + yum -y install https://yum.enterprisedb.com/edbrepos/edb-repo-latest.noarch.rpm + ``` + + On RHEL 8: + + ```text + dnf -y install https://yum.enterprisedb.com/edbrepos/edb-repo-latest.noarch.rpm + ``` + +2. Replace the `USERNAME:PASSWORD` in the following command with the username and password of a registered EnterpriseDB user: + + ```text + sed -i "s@:@USERNAME:PASSWORD@" /etc/yum.repos.d/edb.repo + ``` + + To request credentials for the repository, visit the [EDB website](https://www.enterprisedb.com/user). + +3. Before installing BART, execute the following command to install the Extra Packages for Enterprise Linux (EPEL) release package: + + On RHEL 7: + + ```text + yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm + ``` + + On RHEL 8: + + ```text + dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm + ``` + +4. Enable the repository: + + On RHEL 7, enable the `optional, extras`, and `HA` repositories to satisfy EPEL package dependencies: + + ```text + subscription-manager repos --enable "rhel-*-optional-rpms" --enable "rhel-*-extras-rpms" --enable "rhel-ha-for-rhel-*-server-rpms" + ``` + + On RHEL 8, enable the `codeready-builder-for-rhel-8-*-rpms` repository to satisfy EPEL packages dependency: + + ```text + ARCH=$( /bin/arch ) + + subscription-manager repos --enable "codeready-builder-for-rhel-8-${ARCH}-rpms" + ``` + +5. For RHEL 8, disable the built-in PostgreSQL module: + + ```text + dnf -qy module disable postgresql + ``` + +6. Optionally, install the `pg_basebackup` utility program using the server client package. If you do not already have the `pg_basebackup` program installed on the BART host, you can install a limited number of files that include the `pg_basebackup` program by invoking the following command: + + On RHEL 7: + + ```text + yum install edb-as-server-client + ``` + + On RHEL 8: + + ```text + dnf install edb-as-server-client + ``` + + In the above command, replace `` with the required Advanced Server version. The `pg_basebackup` version must be the same or more recent than the database server to be backed up. For example, `pg_basebackup` version 10 can be used to back up database server version 10, but cannot be used to back up database server version 11. + +7. Use the following command to install the BART: + + On RHEL 7: + + ```text + yum -y install edb-bart-2.5.9 + ``` + + On RHEL 8: + + ```text + dnf -y install edb-bart-2.5.9 + ``` + + Repeat the installation process described in this section to install BART on each remote host on which an incremental backup is to be restored. + + To verify the BART installation, navigate to the `/usr/edb/bart/bin` directory and execute the following command: + + ```text + bart --version + ``` + + The `bart --version` command should return the current BART version. If the `bart --version` command returns an error stating the PATH is not available after switching from the root user to another BART user account, adjust the setting of the `PATH` environment variable to include the directory location of the BART `bin` subdirectory in the `~/.bashrc` or `~/.bash_profile` files of the following user accounts: + + - The BART user account on the BART host. See [Configuring BART](03_configuring_bart/#path) for details. + - The remote user account on the remote host to which incremental backups are to be restored. For details, see the *EDB Backup and Recovery User Guide* available at the [EDB website](/bart/2.5/bart_user/). + + Upon successful installation, BART is installed in the `BART_HOME` directory: + + `/usr/edb/bart` + + The installation includes the following files: + +| File Name | Location | Description | +| ------------------- | ----------------- | ------------------------------------- | +| bart | ``/bin | BART command line, executable program | +| bart-scanner | ``/bin | BART WAL scanner program | +| bart.cfg.sample | ``/etc | Sample BART configuration file | +| xlogreader_ident.so | ``/lib | Libraries supporting WAL versions | +| bart_license.txt | `` | License agreement | + +After BART is installed successfully, you need to [configure the installation](03_configuring_bart/#configuration). + + + +## Installing BART on a RHEL/CentOS 7 PPCLE Host + +The following section demonstrates installing BART on a RHEL host using an RPM package.  This section assumes that the user has some knowledge of installation and system administration procedures, and has administrative privileges on the host. + +1. Install Advance Toolchain: + + ```text + rpm --import https://public.dhe.ibm.com/software/server/POWER/Linux/toolchain/at/redhat/RHEL7/gpg-pubkey-6976a827-5164221b + + cat > /etc/yum.repos.d/advance-toolchain.repo <:@USERNAME:PASSWORD@" /etc/yum.repos.d/edb.repo + ``` + + To request credentials for the repository, visit the [EDB website](https://www.enterprisedb.com/user). + +4. Before installing BART, execute the following command to install the Extra Packages for Enterprise Linux (EPEL) release package: + + ```text + yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm + ``` + +5. On RHEL 7, enable the `optional, extras`, and `HA` repositories to satisfy EPEL package dependencies: + + ```text + subscription-manager repos --enable "rhel-*-optional-rpms" --enable "rhel-*-extras-rpms" --enable "rhel-ha-for-rhel-*-server-rpms" + ``` + +6. Invoke the following command to install BART: + + ```text + yum -y install edb-bart-2.5.9 + ``` + + + +## Installing BART on a Debian or Ubuntu Host + +Perform the following steps to install a Debian package using the EnterpriseDB apt repository. + +To request credentials for the repository, visit the [EDB website](https://www.enterprisedb.com/repository-access-request). + +1. Assume the superuser privileges. + + ```text + sudo su - + ``` + +2. To configure the EnterpriseDB repository on Debian 9 and Ubuntu 18: + + ```text + sh -c 'echo "deb https://username:password@apt.enterprisedb.com/$(lsb_release -cs)-edb/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/edb-$(lsb_release -cs).list' + ``` + + On Debian 10: + + a. Set up the EnterpriseDB repository: + + ```text + sh -c 'echo "deb [arch=amd64] https://apt.enterprisedb.com/$(lsb_release -cs)-edb/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/edb-$(lsb_release -cs).list' + ``` + + b. Substitute your EnterpriseDB credentials for the `username` and `password` placeholders in the following command: + + ```text + sh -c 'echo "machine apt.enterprisedb.com login password " > /etc/apt/auth.conf.d/edb.conf' + ``` + +3. Add support to your system for secure APT repositories. + + ```text + apt-get install apt-transport-https + ``` + +4. Add the EDB signing key; When invoking the command, replace the `username` and `password` with the credentials provided by EnterpriseDB. + + ```text + wget -q -O - https://apt.enterprisedb.com/edb-deb.gpg.key | apt-key add – + ``` + +5. Update the repository metadata. + + ```text + apt-get update + ``` + +6. Install the Debian package: + + a. Contact [EDB Support](https://support.enterprisedb.com) for information about how to install the BART 2.5.9 package. + + b. Navigate to the download directory and execute the following command: + + ```text + apt-get install ./edb-bart_2.5.9-1-deb10_amd64.deb + ``` + + + +## Installing BART on an SLES 12 Host + +This section provides instructions for installing BART on an SLES 12 SP4 host using the zypper package manager. BART is supported on SLES SP4 and SP5 versions. + +1. Assume superuser privileges. + + ```text + sudo su - + ``` + +2. Use the following command to add the EDB repository to your SLES host: + + ```text + zypper addrepo https://zypp.enterprisedb.com/suse/edb-sles.repo + ``` + +3. Invoke the following command to refresh the metadata: + + ```text + zypper refresh + ``` + +4. Install `SUSEConnect` to register the host with SUSE to allow access to SUSE repositories: + + ```text + zypper install SUSEConnect + ``` + +5. Register the host with SUSE to allow access to SUSE repositories and replace `'REGISTRATION_CODE'` and `'EMAIL'` with your SUSE registration information: + + ```text + SUSEConnect -r 'REGISTRATION_CODE' -e 'EMAIL' + ``` + + ```text + SUSEConnect -p PackageHub/12.4/x86_64 + ``` + + ```text + SUSEConnect -p sle-sdk/12.4/x86_64 + ``` + +6. Install the following repository for PEM dependencies: + + ```text + zypper addrepo https://download.opensuse.org/repositories/Apache:/Modules/SLE_12_SP4/Apache:Modules.repo + ``` + +7. Refresh the metadata: + + ```text + zypper refresh + ``` + +8. Then, use the zypper utility to install BART: + + ```text + zypper install edb-bart-2.5.9 + ``` diff --git a/product_docs/docs/bart/2.5/bart_inst/03_configuring_bart.mdx b/product_docs/docs/bart/2.5/bart_inst/03_configuring_bart.mdx new file mode 100644 index 00000000000..95395d5cef9 --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_inst/03_configuring_bart.mdx @@ -0,0 +1,643 @@ +--- +title: "Configuring BART" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/installation-getting-started/installation-upgrade-guide/2.6.1/configuring_bart.html" +--- + + + +To configure BART, you must establish the BART user account, [configure the BART host](#configuring-the-bart-host), and [configure the database server](#configuring_database_server) that will be backed up. + + + +## Establishing the BART User Account + +The BART user account is an operating system user that will run the BART command line program. The BART user account must: + +- own the BART backup catalog. +- be able to run the `bart` program and the `bart-scanner` program. +- be able to establish a SSH/SCP connection to and from each database server managed by BART. + +You can optionally use the `enterprisedb` database user as the BART user account for an Advanced Server database and `postgres` database user as the BART user account for a PostgreSQL server. If you do not wish to use an existing database user as the BART user account, you must create an operating system user to assume the role. + + + +## Configuring BART and Database Server + +As stated earlier, to configure BART, you must [configure the BART host](#configuring-the-bart-host) as well as the [database server](#configuring_database_server). The following table acts as a configuration parameter reference listing the mandatory and optional parameters with default values for `[SERVER]` as well as `[BART]` sections. + +- Parameters set in the `[BART]` section are applicable to all BART managed database servers. +- Parameters set in the `Server` section are applicable only to the specific server; the `Server` parameter setting overrides the `[BART]` section setting. + +For information about configuring BART host parameters, see the [BART Host Parameter Reference](#bart) and for information about configuring the database server parameters, see the [Database Server Parameter Reference](#server). + +| **Parameter** | **Type** | **Default** | **\[SERVER]** | **\[BART]** | +| -------------------------- | --------- | ------------------------------------------------------------ | ------------- | ----------- | +| `[BART]` | Mandatory | N/A | N/A | Yes | +| `` | Mandatory | N/A | N/A | Yes | +| `` | Mandatory | N/A | N/A | Yes | +| `` | Mandatory | N/A | N/A | Yes | +| `retention_policy` | Optional | `BACKUPS` | Yes | Yes | +| `wal_compression` | Optional | `Disabled` | Yes | Yes | +| `copy_wals_during_restore` | Optional | `Disabled` | Yes | Yes | +| `xlog_method` | Optional | `fetch` | Yes | Yes | +| `logfile` | Optional | `/tmp/bart.log` | N/A | Yes | +| `scanner_logfile` | Optional | `/tmp/bart_scanner.log` | N/A | Yes | +| `` | Optional | `/tmp` | N/A | Yes | +| `` | Optional | `` | N/A | Yes | +| `` | Optional | `1` | Yes | Yes | +| `` | Optional | `49152` | Yes | Yes | +| `` | Optional | `0` | Yes | Yes | +| `` | Optional | `20 seconds` | Yes | Yes | +| `` | Optional | `1` | Yes | Yes | +| `[Server Name]` | Mandatory | N/A | Yes | N/A | +| `` | Optional | N/A | Yes | N/A | +| `host` | Mandatory | N/A | Yes | N/A | +| `port` | Mandatory | `5444` for EPAS; `5432` for Postgres | Yes | N/A | +| `user` | Mandatory | N/A | Yes | N/A | +| `` | Optional | `BART backup catalog` | Yes | N/A | +| `` | Optional | N/A | Yes | N/A | +| `` | Mandatory | `enterprisedb` for EPAS

`postgres` for PostgreSQL | Yes | N/A | +| `` | Optional | N/A | Yes | N/A | +| `` | Optional | N/A | Yes | N/A | +| `allow_incremental_backup` | Optional | `Disabled` | Yes | N/A | +| `description` | Optional | N/A | Yes | N/A | + + + +### Configuring the BART Host + +To configure the BART host, perform the following steps on the BART host as a root user: + +**Step 1.** Navigate to the `usr/edb/bart/etc` directory and make a copy of the `bart.cfg.sample` file to create the `bart.cfg` file that will contain the parameter settings. + +**Step 2.** Confirm that the Postgres `pg_basebackup` utility program is installed on the BART host. The `pg_basebackup` utility resides in the `bin` directory under your Postgres installation. + + + +**Step 3.** Ensure the `LD_LIBRARY_PATH` environment variable includes the location of the `libpq` library. If your `libpq` library does not reside in the default location (`POSTGRES_INSTALL_HOME/lib`), you must add the library path to the `LD_LIBRARY_PATH` environment variable in the BART user account’s profile (`bash_profile`) located in `/home/`: + +```text +# .bash_profile +# Get the aliases and functions +if [ -f ~/.bashrc ]; then +. ~/.bashrc +fi +# User specific environment and startup programs +export LD_LIBRARY_PATH=/usr/edb/as11/lib:$LD_LIBRARY_PATH +``` + +**Step 4.** Create the BART backup catalog and ensure the BART user account holds privileges on the BART backup catalog. In the following example, the BART configuration file specifies `/opt/backup` as the parent directory for the BART backup catalog in the `` parameter: + +```text +[BART] + +bart_host = bartuser@192.168.2.22 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log +``` + +In the following example, `bartuser` is the BART user account. The example creates and sets the ownership and permissions on the BART backup catalog: + +```text +su root +mkdir /opt/backup +chown bartuser /opt/backup +chgrp bartuser /opt/backup +chmod 700 /opt/backup +``` + +If the subdirectory does not exist, BART creates a subdirectory for each database server listed in the configuration file when you invoke the `bart` command line program. + +**Step 5.** Use your choice of editor to open the BART configuration file (located in the `usr/edb/bart/etc` directory) and edit the configuration as required. You must add the mandatory parameters to the `[BART]` section. Default values may be used for optional parameters. + +The following table describes the `[BART]` host parameters. + + + +| **Parameters/Placeholder** | **Type** | **Description** | +| -------------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `[BART}` | Mandatory | Identifies the global section of the configuration file. It must be named BART. | +| `bart_host` | Mandatory | Specify the bart user name and the IP address of the bart host on which the BART utility resides. You must specify it in the form of <bart_user>@<bart_host_address>. | +| `backup_path` | Mandatory | Specify the path to the file system parent directory where all BART backups are stored. | +| `pg_basebackup_path` | Mandatory | Specify the path to the `pg_basebackup` program that you installed on the BART host. For information about `pg_basebackup` version-specific restrictions, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/2.5/bart_user/). | +| `wal_compression` | Optional | Set this parameter to `enabled` to compress the archived WAL files in gzip format in the BART backup catalog when the `MANAGE` subcommand is invoked. By default it is set to `disabled`. The gzip compression program must be in the BART user account’s `PATH` and the WAL compression setting must not be enabled for those database servers where you need to take incremental backups. | +| `copy_wals_during_restore` | Optional | Set this parameter to `enabled` to copy the archived WAL files from the BART backup catalog to the `restore_path/archived_wals` directory prior to the database server archive recovery. Enabling this option helps you save time during the restore operation. Set this parameter to `disabled` (default) to retrieve the archived WAL files directly from the BART backup catalog during the database server archive recovery. During the restore operation, recovery settings will be saved in the `postgresql.auto.conf` file. The `restore_command` in the `postgresql.auto.conf` file will be determined by the value specified in the `copy_wals_during_restore` parameter. If the `RESTORE` subcommand is invoked with the `-c` option, the archived WAL files are copied from the BART backup catalog to the `restore_path/archived_wals` directory, thus overriding any setting of the `copy_wals_during_restore` parameter. If the `RESTORE` subcommand is invoked without the `-c` option, the value specified by the `copy_wals_during_restore` parameter is used. | +| `xlog_method` | Optional | Specify how the transaction log is collected during the execution of `pg_basebackup` through the `BACKUP` subcommand. Set `xlog_method` to `fetch` (default) to collect the transaction log files after the backup is completed. Set to `stream` to stream the transaction log in parallel with the full backup creation. | +| `retention_policy` | Optional | Set this parameter to determine when an active backup should be marked as `obsolete` when the `MANAGE` subcommand is used. You can specify the retention policy either in terms of number of backups or duration (days, weeks, or months). ` BACKUPS` (default), ` DAYS`, ` WEEKS`, or ` MONTHS` where `` is a positive integer. For information about managing backups using a retention policy, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/2.5/bart_user/). | +| `logfile` | Optional | Use this parameter to specify the path to the BART log file. The default log file location is `/tmp/bart.log`. The log file will be created the first time you invoke the `bart` command line program using the sample configuration file value. To change the default setting, you must delete the `bart.log` file from the `/tmp` directory and create a new log file in another directory so that a new log file will be created and owned by the new BART user account. If no path to a log file is specified, BART does not create a log file. | +| `scanner_logfile` | Optional | Use this parameter to specify the path to the XLOG/WAL scanner log file. The default location is `/tmp/bart_scanner.log`. The scanner log file will be created the first time you invoke the `bart_scanner` program using the sample configuration file value. To change the default setting, you must delete the `bart_scanner.log` file from the `/tmp` directory and create a new log file in another directory so that a new log file will be created and owned by the new BART user account. If no path to a log file is specified, BART does not create a WAL scanner log file. | +| `` | Optional | Specify the socket directory path where all BART sockets will be stored. The default directory is `/tmp`. While specifying the `bart_socket_directory` path, you must ensure that the directory exists and the BART user has the required access permissions to the directory. | +| `` | Optional | Specify a user-friendly BART socket file name. Using this option overrides the default BART socket name generated using MD5 checksum. You must shut down the bart-scanner before setting this option. You can view the `` in the `sockPath` field after starting the bart-scanner in the debug mode. This option helps in preventing the use of MD5 during the bart-scanner startup, thus making BART more compliant in FIPS mode. | +| `` | Optional | Specify the number of worker threads for copying blocks (for incremental backups) or data files (for full backup) from the database server to the `archive_path` when the `BACKUP` subcommand is invoked. The default value is `1`. The same set of worker threads are used for the compression operation when taking full backups in order to provide parallel, compressed backups when the `BACKUP` subcommand is specified with the `-z` or `-c` options. The compression operation does not apply to incremental backups. See [thread count](#thread_count) for more information. | +| `` | Optional | Specify the number of blocks of memory used for copying modified blocks from the database server to the `archive_path` when the `BACKUP` subcommand is invoked for incremental backups. The default value is 49152 blocks; each block is 8192 bytes. The maximum permitted value is 131072 blocks and the minimum permitted value is 1 block. Reduce the `` setting if the server runs out of memory while executing the `pg_read_binary_file()`. | +| `` | Optional | Specify the number of seconds after which the WAL scanner should initiate force scanning of the new WAL files. The default value is 0, which means no brute-force scanning will be started. After upgrading to the latest version of BART, users who have set this parameter to a non-default value may see increased CPU consumption on the part of bart-scanner. If this is an issue, consider increasing the configured value of `scan_interval` parameter, or removing the setting if it is not required. | +| `` | Optional | Specify the number of seconds to wait for MBM files before timing out; this parameter is applicable only for incremental backup. You must set the `scan_interval` to a value significantly less than the MBM scan timeout. The default value is 20 seconds. The `mbm_scan_timeout` parameter value must be greater than 0. If the value is 0 or negative, then an error will be displayed during an incremental backup. | +| `` | Optional | Specify the number of parallel worker processes required to stream the modified blocks of an incremental backup to the restore host. The default value is 1. | + + + +**Thread Count** + +If the `BACKUP` subcommand is invoked with the `--thread-count` option, then the number of worker threads specified by this option overrides any setting of the `thread_count` parameter in the BART configuration file. If the `BACKUP` subcommand is invoked without the `--thread-count` option, then the following determines the number of worker threads used: + +- The setting of the `thread_count` parameter in the server section of the BART configuration file overrides the setting of `thread_count` in the global section for that particular database server. +- If omitted in the server section, the setting of `thread_count` in the global section is used. +- If the `thread_count` parameter is not specified in either section, the default is 1. +- When taking a full backup, if the `thread count` in effect is only 1, then the `pg_basebackup` utility is used to take the full backup unless the `--no-pg_basebackup` option is specified with the `BACKUP` subcommand. + +`` will not be effective if the backup is taken on a standby server. + +If parallel backup is run with `N` number of worker threads, then it will initiate `N + 1` concurrent connections with the server. + +**Step 6** Invoke the `CHECK-CONFIG` subcommand, omitting the `-s` option to check the parameter settings in the BART configuration file. It should return the current BART version. + +```text +bart CHECK-CONFIG +``` + +The `CHECK-CONFIG` subcommand displays an error message if the required configuration is not properly set. You need to check the logfile to fix this. + + + +### Configuring the Database Server + +To configure the database server, you must: + +1. [Authorize SSH/SCP access without a password prompt](#authorizing_ssh_scp_access). +2. [Create and configure a replication database user](#setting_up_a_replication_database_user). +3. [Adding the database server to the configuration file (server section)](#adding_a_database_server). +4. [Enable WAL archiving of the server](#enabling_wal_archiving). +5. [Verify the server configuration settings](#verifying_configuration_settings). + +The following section will walk you through the configuration process. + +!!! Note + You must authorize SSH/SCP access and set up a replication database user before restarting the database server with WAL archiving enabled. + + + +**Authorizing SSH/SCP Access** + +BART uses the Secure Shell (`ssh`) and Secure Copy (`scp`) Linux utility programs to copy the backup and WAL files from the BART managed database servers to the BART host as well as to restore backups. + +- The client/server `ssh` and `scp` commands must not prompt for a password when establishing a connection with the target server (the server to which a passwordless connection is being made). +- A passwordless connection uses *authorized public keys* (public key of a client user account) to authenticate with the target server. +- You must add the public key of each client user account to the target user account’s authorized public keys list on the target server. + +For BART usage, there are two scenarios that require a passwordless SSH/SCP connection: + +- When connecting from each BART managed database server (SSH/SCP client) to the BART host (target SSH/SCP server) to support WAL archiving as implemented by the `archive_command` parameter. + - In this case, the database server user account should generate the public key file (`id_rsa.pub`) with the `ssh-keygen –t rsa` command on the database server host. + - The public key file name should be appended to the `~/.ssh/authorized_keys` file on the BART host. The `authorized_keys` file is in the BART user account’s home directory. +- When connecting from the BART host (SSH/SCP client) to each BART managed database server (target SSH/SCP server) for taking incremental backups and for supporting restoration of the full backup, the archived WAL files, and the modified blocks, which occurs when the BART `RESTORE` subcommand is given. + - In this case, the BART user account should generate the public key file (`id_rsa.pub`) with the `ssh-keygen –t rsa` command on the BART host. + - The public key file name should be appended to the `~/.ssh/authorized_keys` file on the database server host. The `authorized_keys` file is in the home directory of the user account that owns the directory where the database backup is to be restored. +- If backups are to be taken from a given database server host, but restored to a different database server host, the passwordless SSH/SCP connections must be configured from the BART host to the database server host from which the backup is to be taken as well as from the BART host to the database server host to which the backup is to be restored. + +See the EDB Backup and Recovery Reference Guide available at the [EDB website](/bart/2.5/bart_ref/) to view examples of creating a passwordless connection. + +**Enabling Public Key Authentication** + +The following example enables SSH/SCP access on a CentOS 7.x host; similar (platform-specific) steps will apply to other platforms/versions. + +1. In the SSH server daemon configuration file (`sshd_config`) located in the `/etc/ssh`, set the `PubkeyAuthentication` parameter to `yes`. +2. Reload the configuration file: + +```text +service sshd reload +``` + +If you get any SSH or SCP errors, examine the `/var/log/secure` log file. + +**Creating a Passwordless Connection** + +The following general instructions will walk you through generating a client’s public key file, creating the target server’s authorized public keys file, and creating a passwordless connection. + +**Step 1.** On the client system, log in as the user account that will be initiating the SSH or SCP connection. + +**Step 2.** Navigate to the user account’s home directory and check for an existing `.ssh` subdirectory. If the `.ssh` directory does not exist, create one and assign the required privileges to the user. + +**Step 3.** Generate the public key file with the following command. Accept all prompted defaults and do not specify a passphrase when prompted for one. + +```text +ssh-keygen –t rsa +``` + +The public key file named `id_rsa.pub` is created in the `.ssh` subdirectory. + +**Step 4.** While logged into the client where you just generated the public key file, use `SCP` to make a temporary copy of it on the target server: + +```text +scp ~/.ssh/id_rsa.pub @:tmp.pub +``` + +**Step 5.** Navigate into the target user account’s home directory and check for an existing `.ssh` subdirectory. If it does not exist, create one and assign the required privileges to the user. + +**Step 6.** Append the temporary, client’s public key file, `tmp.pub`, to the `authorized_keys` file. If an `authorized keys` file does not exist, create a new file, but do not completely replace any existing `authorized keys` file. + +```text +cat tmp.pub >> ~/.ssh/authorized_keys +``` + +Make sure the `authorized_keys` file is only accessible by the file owner and not by groups or other users. If the `authorized_keys` file does not have the required permission setting or it was newly created, change the file permissions as follows: + +```text +chmod 600 ~/.ssh/authorized_keys +``` + +**Step 7.** Delete the temporary public key file: + +```text +rm tmp.pub +``` + +Now, when logged into the client system as `user` there should be no prompt for a password when commands such as the following is given: + +```text +ssh target_user@host_address +``` + + + +**Setting up a Replication Database User** + +For each database server that is to be managed by BART, a database user must be chosen to serve as the *replication database user*. The replication database user sets the Postgres `archive_command` configuration parameter when the `INIT` subcommand in invoked and creates backups when the `BACKUP` subcommand is invoked. The replication database user must be a `superuser`. + +When executed with the PSQL client, the following PostgreSQL command creates a superuser to be the replication database user: + +`CREATE ROLE repuser WITH LOGIN SUPERUSER PASSWORD 'password';` + +The `pg_hba.conf` file must minimally permit the replication database user to have access to the database. + +In the following example, the `pg_hba.conf` file permits the `repuser` (replication database user) to have access to the `template1` database. The IP address from which `repuser` has access to `template1` database is the location of the BART host: + +**For pg_basebackup only:** If `pg_basebackup` is to be used for taking any backups (such as for standby servers), the replication database user must also be included in the `pg_hba.conf` file as a `replication` database connection as shown by the last entry in the following example. + +```text +# TYPE DATABASE USER ADDRESS METHOD +# "local" is for Unix domain socket connections only +local all all md5 +# IPv4 local connections: +host template1 repuser 192.168.2.22/32 md5 +host all enterprisedb 127.0.0.1/32 md5 +# IPv6 local connections: +host all all ::1/128 md5 +# Allow replication connections from localhost, by a user with the +# replication privilege. +host replication repuser 192.168.2.22/32 md5 +``` + +The replication database user must be specified for the `user` parameter in the BART configuration file for the database server as shown in the following example: + +```text +[ACCTG] +host = 192.168.2.24 +port = 5444 +user = repuser +cluster_owner = enterprisedb +remote_host = enterprisedb@192.168.2.24 +description = "Accounting" +``` + +There must be no password prompt when connecting to the database server with the replication database user. There are several ways to permit this; one recommended method is to use a `.pgpass` file located in the BART user account’s home directory. + +For example, if `bartuser` is the BART user account, then the `.pgpass` file located in the `/home/bartuser` directory must contain the following entry: + +`192.168.2.24:5444::repuser:password` + +When `bartuser` invokes a BART backup, the password for the replication database user, `repuser`, is obtained from the `.pgpass` file of `bartuser` to connect to the database server running at `192.168.2.24` on `port 5444`. + +The `.pgpass` file must contain an entry for each BART managed database server and its corresponding replication database user and password. + + + +**Adding a Database Server to the BART Configuration File** + +To manage the backup and recovery of a database server, you must add entries to the `[SERVER]` section of the BART configuration file, which is located in `/etc` directory. + + + +*Database Server Parameter Reference* + +Set the following parameters in the \[`SERVER`] section of the BART configuration file. The parameter setting in the \[`SERVER`] section overrides the setting in the global \[`BART`] section for that particular database server. If omitted, the default value will be used. + +For each cluster serviced by BART, the following parameters are mandatory: + +```text +[HR] + +host = 192.168.2.24 +port = 5432 +user = postgres +cluster_owner = postgres +``` + +!!! Note + The port parameter setting is required only if the database server listens on a port other than the default (for example if Postgres listens on a port other than 5432). + +The following table describes the database server parameters. + + + + + + + + + +| **Parameters/Placeholder** | Type | **Description** | +| --------------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `[ServerName]` | Mandatory | Specify the server name that you want to backup using BART. It is not case-sensitive when referenced with BART subcommand options. A lowercase conversion of this name is used to create a subdirectory in the BART backup catalog for storing the backups and WAL files for this database server (for eg., epas12). | +| `` | Optional | Specify a [template](#backup_name_template) for user-defined, friendly names that will be assigned to the backups of the database server. The maximum permitted length of backup name is 49 characters. The `` parameter can be overridden by the `--backup-name` option of the `BACKUP` subcommand. If this parameter is omitted from the BART configuration file, and the `--backup-name` option with a user-defined name is not specified with the `BACKUP` subcommand, then the backup can only be referenced in BART subcommands by the BART assigned, integer backup identifier. | +| `host` | Mandatory | Specify the IP address of the database server to be configured for backup. | +| `port` | Mandatory | Specify the port number identifying the database server instance (that is, the relevant database cluster) to be backed up. The default port number for EPAS is `5444` and for Postgres it is `5432`. The port parameter setting is only required if the database server listens on a port other than the default value. | +| `User` | Mandatory | Specify the replication database user name used by BART to establish the connection to the database server for full backups. See [Setting up a Replication Database User](#setting_up_a_replication_database_user) for more information. | +| `` | Optional | Specify the path where archived WAL files will be stored. The default location is the BART backup catalog (`//archived_wals`). | +| `` | Optional | When the `INIT` subcommand is used, the content and variables specified in the BART `` result in the archive command string to be generated into the `Postgres archive_command` parameter in the `postgresql.auto.conf` file. To configure the BART `` parameter, enclose the command string within single quotes ('). If you do not specify the `` parameter in the configuration file, the default setting is taken as `'scp %p %h:%a/%f'`. See [Archive Command Auto Configuration](#archive_command_auto_configuration) for information about variables. The BART `` parameter in the BART configuration file, and the Postgres `` parameter in the `postgresql.conf` file (or the `postgresql.auto.conf` file) refer to two different parameters that are to be set in different manner. | +| `` | Mandatory | Specify the Linux operating system user account that owns the database cluster. This is typically `enterprisedb` for Advanced Server database clusters installed in the Oracle compatible mode, or `postgres` for Advanced Server database clusters installed in the PostgreSQL compatible mode and PostgreSQL database clusters. | +| `` | Optional | Specify the IP address of the remote server to which a backup is to be restored. Specify this parameter in the form of `@`. `` is the user account on the target database server host that accepts a passwordless SSH/SCP login connection and owns the directory where the backup is to be restored. `` is the IP address of the remote host. For restoring a backup to a remote host or for restoring any backup where `` and the BART user account are not the same users, either this parameter must be set or it may be specified with the `-r` option with the BART `RESTORE` subcommand. | +| `` | Optional | Specify path to which tablespaces are to be restored in the format `OID = `; If the backup is to be restored to a remote host specified by the `` parameter, then the tablespace paths must exist on the remote host. | +| `allow_incremental_backups` | Optional | Set this parameter to `enabled` to enable use of the WAL scanner and permit taking incremental backups when the `BACKUP` subcommand is invoked with the `--parent` option. Set it to `disabled` (default) to disallow incremental backups and thus permit only full backups. For information about using the `BACKUP` subcommand and running the WAL scanner, please see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/2.5/bart_user/). | +| `Description` | Optional | Specify the description that will be used to identify the database server. | + +For information regarding the following parameters, see [configuring the BART host](#configuring-the-bart-host). + +- `retention_policy` +- `xlog_method` +- `wal_compression` +- `copy_wals_during_restore`. +- `thread_count`. +- `batch_size`. +- `scan_interval`. +- `mbm_scan_timeout`. +- `workers` + + + +**Backup Name Template** + +- The template is an alphanumeric string that may include the following variables that will be replaced with the timestamp values when the backup is taken: + + - `%year` to be replaced by 4-digit year + - `%month` to be replaced by 2-digit month + - `%day` to be replaced by 2-digit day + - `%hour` to be replaced by 2-digit hour + - `%minute` to be replaced by 2-digit minute + - `%second` to be replaced by 2-digit second + +- To include a percent sign (`%`) as a character in the backup name, specify `%%` in the template. + +- Do not enclose the template string in quotes even if you want the template to include space characters, otherwise the enclosing quotes are stored as part of the backup name. However, when referenced with the `-i` option by BART subcommands use of space characters in the backup name requires enclosing the backup name in quotes. + +The following example shows the configuration settings of three database servers: + +```text +[ACCTG] + +host = 127.0.0.1 +port = 5444 +user = enterprisedb +cluster_owner = enterprisedb +backup_name = acctg_%year-%month-%dayT%hour:%minute:%second +archive_command = 'cp %p %a/%f' +allow_incremental_backups = enabled +retention_policy = 8 BACKUPS +description = "Accounting" + +[MKTG] + +host = 192.168.2.24 +port = 5444 +user = repuser +cluster_owner = enterprisedb +remote_host = enterprisedb@192.168.2.24 +allow_incremental_backups = enabled +description = "Marketing" + +[HR] + +host = 127.0.0.1 +port = 5432 +user = postgres +cluster_owner = postgres +retention_policy = 4 DAYS +description = "Human Resources" +``` + + + +**Enabling WAL Archiving** + +WAL archiving must be enabled for the database server for which BART is to perform backup and recovery management. + +- The WAL Archiving Configuration section describes the manual WAL archiving configuration process. +- The Archive Command Auto Configuration section describes an automated WAL archiving process. + +*WAL Archiving Configuration* + +Set the following configuration parameters in the `postgresql.conf` file to enable WAL archiving + +- Set `wal_level` to `replica` or higher. +- Set `archive_mode` to `on`. +- Set the PostgreSQL `archive_command` parameter to copy the WAL files to the `archive_path`. The `archive_command` configuration parameter mentioned here is located in the `postgresql.conf` file; the PostgreSQL `archive_command` parameter is used in a different manner than the BART [archive_command](#archive_command). +- Set `max_wal_senders` to a value high enough to leave at least one session available for the backup. If the `xlog_method=stream` parameter setting is to be used by this database server, the `max_wal_senders` setting must account for an additional session for the transaction log streaming (the setting must be a minimum of 2). See [Configuring the BART host](#configuring-the-bart-host) for information about the `xlog_method` parameter. + +For detailed information about WAL archiving, see the [PostgreSQL Core Documentation](https://www.postgresql.org/docs/12/static/continuous-archiving.html). + +The `ARCHIVE PATH` field displayed by the BART `SHOW-SERVERS` subcommand displays the full directory path where the WAL files should be copied as specified in the `archive_command` configuration parameter in the `postgresql.conf` file: + +```text +-bash-4.1$ bart SHOW-SERVERS -s acctg +SERVER NAME : acctg +HOST NAME : 192.168.2.24 +USER NAME : repuser +PORT : 5444 +REMOTE HOST : +RETENTION POLICY : none +DISK UTILIZATION : 0.00 bytes +NUMBER OF ARCHIVES : 0 +ARCHIVE PATH : /opt/backup/acctg/archived_wals +ARCHIVE COMMAND : (disabled) +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +INCREMENTAL BACKUP : DISABLED +DESCRIPTION : "Accounting" +``` + +The parameter settings in the following example will copy the WAL files to a directory named `/opt/backup/acctg/archived_wals` on the BART host located at `192.168.2.22` as the `bartuser` user account. Using the `bartuser` account ensures that the operation will have sufficient permissions to copy to the BART backup catalog owned by `bartuser`. + +```text +archive_mode = on # allows archiving to be done + # (change requires restart) +archive_command = 'scp %p bartuser@192.168.2.22:/opt/backup/acctg/archived_wals/%f' + # command to use to archive a logfile segment + # placeholders: %p = path of file to archive + # %f = file name only +... + +max_wal_senders = 1 # max number of walsender processes + # (change requires restart) +``` + +The database server must be restarted in order to initiate WAL archiving, but do not do so until you have verified that the full path of the BART backup catalog has been created by a prior BART subcommand or the archive operation will fail. + +Start the WAL scanner by executing the following command: + +```text +./bart-scanner +``` + + + +*Archive Command Auto Configuration* + +To enable WAL archiving: + +- In the `postgresql.conf` file, set the `wal_level` to `replica` or higher, `archive_mode` to `on`, and `max_wal_senders` to a value high enough to leave at least one session available for the backup. If the `xlog_method=stream` parameter setting is to be used by this database server as determined in the BART configuration file, the `max_wal_senders` setting must account for an additional session for the transaction log streaming (that is, the setting must be a minimum of `2`). See [Configuring the BART host](#configuring-the-bart-host) for information on the `xlog_method` parameter. + +- Configure the Postgres `archive_command` parameter automatically with the `INIT` subcommand and restart the database server when you are ready to initiate WAL archiving. The `INIT` subcommand invokes the Postgres `ALTER SYSTEM` command to set the Postgres `archive_command` configuration parameter in the `postgresql.auto.conf` file located in the managed database server’s `POSTGRES_INSTALL_HOME data directory`. For additional information about the `INIT` subcommand, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/2.5/bart_user/). + + The archive command string that the `INIT` subcommand generates into the `postgresql.auto.conf` file is determined by the parameter setting of the BART `archive_command` parameter in the server section of the BART configuration file. If the BART `archive_command` parameter is not set in the server section for a given database server, the command string that is configured uses the following default format: + + `'scp %p %h:%a/%f'` + + The following table describes these variables: + +| **Variable** | **Description** | +| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `%p` | The path of the file to archive used by the Postgres archiving process. | +| `%h` | Will be replaced by the `@` as specified in the <bart_host> parameter setting. | +| `%a` | Will be replaced by the BART `archived_wals` directory as specified in the [archive path](#archive_path) parameter setting. If the `` is not specified, then the default directory is `//archived_wals`. `` is the lowercase conversion of the database server name. | +| `%f` | The archived file name used by the Postgres archiving process. | + +The placeholders `%h` and `%a` are replaced by the `INIT` subcommand when creating the archive command string. The placeholders `%p` and `%f` are not replaced by the `INIT` subcommand, but are kept as given to be used by the Postgres archiving process. + +For example, to use the default archive command format, the BART configuration file contains the following settings where the BART `archive_command` parameter is omitted from the server section for `ACCTG`: + +```text +[BART] + +bart_host= bartuser@192.168.2.22 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log + +[ACCTG] + +host = 127.0.0.1 +port = 5444 +user = repuser +cluster_owner = enterprisedb +description = "Accounting" +``` + +The `INIT` subcommand is invoked by BART user account `bartuser` as follows: + +```text +[bartuser@localhost ~]$ bart INIT -s acctg -o +INFO: setting archive_command for server 'acctg' +WARNING: archive_command is set. server restart is required +``` + +If the BART backup catalog directory is not already complete, it will be completed. + +The resulting archive command string in the `postgresql.auto.conf` file located in the managed database server’s `POSTGRES_INSTALL_HOME/data directory` appears as follows: + +```text +# Do not edit this file manually! +# It will be overwritten by ALTER SYSTEM command. +archive_command = 'scp %p +bartuser@192.168.2.22:/opt/backup/acctg/archived_wals/%f' +``` + +Run the `INIT` subcommand with the `-o` option to override any existing `archive_command` setting in the `postgresql.conf` or the `postgresql.auto.conf` file. In addition, the `-o` option must be used to generate the command string if the `archive_mode` is set to off even if there are no existing settings of the `archive_command` in the `postgresql.conf` or `postgresql.auto.conf` files. + +In this example, the following BART configuration file is used with an explicit setting of the BART `archive_command` parameter: + +```text +[BART] + +bart_host= enterprisedb@192.168.2.22 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log + +[ACCTG] + +host = 127.0.0.1 +port = 5444 +user = repuser +cluster_owner = enterprisedb +archive_command = 'cp %p %a/%f' +description = "Accounting" +``` + +The `INIT` subcommand is invoked by BART user account `enterprisedb` as follows: + +```text +-bash-4.1$ bart INIT -s acctg -o +INFO: setting archive_command for server 'acctg' +WARNING: archive_command is set. server restart is required +``` + +The resulting Postgres `archive_command` parameter in the `postgresql.auto.conf` file appears as follows: + +```text +# Do not edit this file manually! +# It will be overwritten by ALTER SYSTEM command. +archive_command = 'cp %p /opt/backup/acctg/archived_wals/%f' +``` + +When the database server has been restarted, the `ARCHIVE COMMAND` field of the `SHOW-SERVERS` subcommand displays the active Postgres archive command as shown by the following example: + +```text +-bash-4.1$ bart SHOW-SERVERS -s acctg +SERVER NAME : acctg +HOST NAME : 127.0.0.1 +USER NAME : repuser +PORT : 5444 +REMOTE HOST : +RETENTION POLICY : none +DISK UTILIZATION : 48.00 MB +NUMBER OF ARCHIVES : 0 +ARCHIVE PATH : /opt/backup/acctg/archived_wals +ARCHIVE SCOMMAND : `cp %p /opt/backup/acctg/archived_wals/%f` +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +INCREMENTAL BACKUP : DISABLED +DESCRIPTION : "Accounting" +``` + + + +**Verifying Configuration Settings** + +To verify the parameter settings of the database server specified, execute tthe `CHECK-CONFIG` subcommand with the `–s` option: + +```text +bart CHECK-CONFIG [ –s server_name ] +``` + +The `CHECK-CONFIG` subcommand confirms the following: + +- The `cluster_owner` parameter is set to the user account owning the database cluster directory. +- A passwordless SSH/SCP connection is set between the BART user and the user account specified by the `cluster_owner` parameter. +- The BART `user` parameter specifies a database superuser. +- The BART `user` has access to the backup directory catalog. +- The `pg_hba.conf` file contains a replication entry for the database superuser specified by the BART `user` parameter. +- The `archive_mode` parameter in the `postgresql.conf` file is enabled. +- The `archive_command` parameter in the `postgresql.auto.conf` or the `postgresql.conf` file is set. +- The `allow_incremental_backups` parameter in the BART configuration file is enabled for database servers for which incremental backups are to be taken. +- Archiving of WAL files to the `archive_path` is in process. +- The WAL scanner program is running. + +After configuring the BART host and the database server(s), you can start using BART. For information about using BART, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/2.5/bart_user/). diff --git a/product_docs/docs/bart/2.5/bart_inst/04_upgrading_bart.mdx b/product_docs/docs/bart/2.5/bart_inst/04_upgrading_bart.mdx new file mode 100644 index 00000000000..4115c975dcf --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_inst/04_upgrading_bart.mdx @@ -0,0 +1,77 @@ +--- +title: "Upgrading BART" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/installation-getting-started/installation-upgrade-guide/2.6.1/upgrading_bart.html" +--- + + + +This section outlines the process of upgrading BART from an existing version to the latest version. + +**Upgrade Restrictions** + +The following restrictions apply with regard to previous BART versions. + +- You can take incremental backups using the latest version only when the parent backup (full or incremental backup) has also been taken with the latest version. +- Using the latest version, you can restore incremental backups that are taken only with the latest version of BART. However, using the latest version you can restore full backups that were taken with older versions. + + + +## Upgrading from Older Versions of BART + +Perform the following steps to upgrade from older versions of BART to the latest version: + +**Step 1:** Assume the identity of the BART user account and invoke the following command to stop the BART WAL scanner program (`bart-scanner`): + +```text +bart-scanner STOP +``` + +**Step 2:** As the `root` user, upgrade to the latest BART version with the `yum upgrade` command. + +- To upgrade the BART RPM package directly from the *EDB Yum Repository* website, specify only the package name: + + On CentOS 7: + + ```text + yum upgrade edb-bart + ``` + + You can also use a downloaded RPM package file to upgrade. To use a downloaded BART RPM package file to upgrade, use the `yum` command, specifying the complete RPM package file name: + + ```text + yum upgrade edb-bart-x.y.z rhel7.x86_64.rpm + ``` + + Where x denotes the major version of BART, and y and z denotes the minor version. + + On a Debian or Ubuntu Host: + On a Debian or Ubuntu Host: + + ```text + apt-get upgrade edb-bart + ``` + + On a SLES Host: + + ```text + zypper update edb-bart + ``` + +**Step 3:** Repeat the process described in this section to upgrade to the latest BART version on each remote hosts where an incremental backup will be restored. + +For additional information about restoration of incremental backups on remote hosts, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/2.5/bart_user/). + +**Step 4:** If the `bart --version` command returns an error stating the `PATH` is not available after switching from `root` user to another BART user account, adjust the setting of the `PATH` environment variable to include the location of the BART x.y.z executable (the `bin` subdirectory) in the `~/.bashrc` or `~/.bash_profile` files of the following user accounts: + +- The BART user account on the BART host. +- The remote user account on the remote host to which incremental backups are to be restored. For details, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/2.5/bart_user/). + +The `PATH` setting should be the same as set for BART x.y.z since all versions use `/usr/edb/bart/bin`. + +!!! Note + After upgrading to the latest BART version, you must take a new full backup of your system before performing an incremental backup. + + \ No newline at end of file diff --git a/product_docs/docs/bart/2.5/bart_inst/05_uninstalling_bart.mdx b/product_docs/docs/bart/2.5/bart_inst/05_uninstalling_bart.mdx new file mode 100644 index 00000000000..de8c1c0d00b --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_inst/05_uninstalling_bart.mdx @@ -0,0 +1,50 @@ +--- +title: "Uninstalling BART" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/installation-getting-started/installation-upgrade-guide/2.6.1/uninstalling_bart.html" +--- + + + +This section walks you through uninstalling BART. + +## Uninstalling BART on a RHEL/CentOS Host + +To uninstall BART on a RHEL/CentOS host, assume the identity of the `root` user and invoke the following command: + +On RHEL/CentOS 7: + +```text +yum remove edb-bart +``` + +On RHEL/CentOS 8: + +```text +dnf remove edb-bart +``` + +Uninstalling BART does not delete the backup files and archived WAL files that reside in the BART backup catalog. To permanently delete the backup files and archived WAL files in the BART backup catalog (`/opt/backup`), use one of the following commands: + +- `rm –rf /opt/backup` +- BART `DELETE` subcommand + +For information about the BART `DELETE` subcommand, see the *EDB Backup and Recovery User Guide* available at the [EDB website](/bart/2.5/bart_user/). + +## Uninstalling BART on an SLES 12 Host + +To uninstall BART on an SLES 12 host, assume the identity of the `root` user and invoke the following command: + +```text +zypper remove edb-bart +``` + +## Uninstalling BART on a Debian/Ubuntu Host + +To uninstall BART on a Debian or Ubuntu host, invoke the following command: + +```text +apt-get remove edb-bart +``` diff --git a/product_docs/docs/bart/2.5/bart_inst/images/EDB_logo.png b/product_docs/docs/bart/2.5/bart_inst/images/EDB_logo.png new file mode 100644 index 00000000000..39a54822d85 Binary files /dev/null and b/product_docs/docs/bart/2.5/bart_inst/images/EDB_logo.png differ diff --git a/product_docs/docs/bart/2.5/bart_inst/images/edb.png b/product_docs/docs/bart/2.5/bart_inst/images/edb.png new file mode 100644 index 00000000000..71e5bdde787 Binary files /dev/null and b/product_docs/docs/bart/2.5/bart_inst/images/edb.png differ diff --git a/product_docs/docs/bart/2.5/bart_inst/images/edb_logo.svg b/product_docs/docs/bart/2.5/bart_inst/images/edb_logo.svg new file mode 100644 index 00000000000..f24d1dfefee --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_inst/images/edb_logo.svg @@ -0,0 +1,19 @@ + + + edb-logo-disc-dark + + + + \ No newline at end of file diff --git a/product_docs/docs/bart/2.5/bart_inst/images/edblogo.png b/product_docs/docs/bart/2.5/bart_inst/images/edblogo.png new file mode 100644 index 00000000000..71e5bdde787 Binary files /dev/null and b/product_docs/docs/bart/2.5/bart_inst/images/edblogo.png differ diff --git a/product_docs/docs/bart/2.5/bart_inst/index.mdx b/product_docs/docs/bart/2.5/bart_inst/index.mdx new file mode 100644 index 00000000000..dd182be18aa --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_inst/index.mdx @@ -0,0 +1,45 @@ +--- +navTitle: Installation Guide +title: "EDB Postgres Backup and Recovery Installation Guide" +legacyRedirects: + - "/edb-docs/d/edb-backup-and-recovery-tool/installation-getting-started/installation-upgrade-guide/2.6.1/requirements_overview.html" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/installation-getting-started/installation-upgrade-guide/2.6.1/conclusion.html" + - "/edb-docs/d/edb-backup-and-recovery-tool/installation-getting-started/installation-upgrade-guide/2.6.1/genindex.html" + - "/edb-docs/d/edb-backup-and-recovery-tool/installation-getting-started/installation-upgrade-guide/2.6.1/index.html" +--- + +This guide provides information about how to install and configure the EDB Backup and Recovery Tool (BART) 2.5. + + + +## Requirements Overview + +### Supported Platforms and Database Versions + +- To view a complete list of platforms that EDB supports, visit the [EDB website.](https://www.enterprisedb.com/services-support/edb-supported-products-and-platforms) + +!!! Note + BART 2.5 does not support CentOS/RHEL/OEL 6.x platforms. EDB recommends migrating the EDB products running on these platforms to a supported platform. + +- BART supports the following database versions: + + - Advanced Server versions 9.6, 10, 11, and 12. + - PostgreSQL versions 9.6, 10, 11, and 12. + +### Software Requirements + +You require the following components to install BART. + +- BART Host Components - Use EDB packages to add BART host components; see [Installing BART](02_installing_bart/#installing-bart) for information about how to install these components. + +- Additional Components - In addition to the BART host components, the following components are required: + + - The [Secure Shell (SSH) server daemon and Secure Copy (SCP) client programs](03_configuring_bart/#authorizing_ssh_scp_access) must be enabled and activated on the BART host as well as on the remote database server hosts on which BART will be managing backup and recovery. + - BART uses the `pg_basebackup` utility program when taking full backups. + +### Limitation + +BART supports taking only a full backup of standby servers; it does not support taking incremental or parallel backups of standby servers. diff --git a/product_docs/docs/bart/2.5/bart_qs_7/images/EDB_logo.png b/product_docs/docs/bart/2.5/bart_qs_7/images/EDB_logo.png new file mode 100644 index 00000000000..39a54822d85 Binary files /dev/null and b/product_docs/docs/bart/2.5/bart_qs_7/images/EDB_logo.png differ diff --git a/product_docs/docs/bart/2.5/bart_qs_7/images/edb.png b/product_docs/docs/bart/2.5/bart_qs_7/images/edb.png new file mode 100644 index 00000000000..71e5bdde787 Binary files /dev/null and b/product_docs/docs/bart/2.5/bart_qs_7/images/edb.png differ diff --git a/product_docs/docs/bart/2.5/bart_qs_7/images/edb_logo.svg b/product_docs/docs/bart/2.5/bart_qs_7/images/edb_logo.svg new file mode 100644 index 00000000000..f24d1dfefee --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_qs_7/images/edb_logo.svg @@ -0,0 +1,19 @@ + + + edb-logo-disc-dark + + + + \ No newline at end of file diff --git a/product_docs/docs/bart/2.5/bart_qs_7/images/image2.png b/product_docs/docs/bart/2.5/bart_qs_7/images/image2.png new file mode 100644 index 00000000000..4eba2e7efa7 Binary files /dev/null and b/product_docs/docs/bart/2.5/bart_qs_7/images/image2.png differ diff --git a/product_docs/docs/bart/2.5/bart_qs_7/index.mdx b/product_docs/docs/bart/2.5/bart_qs_7/index.mdx new file mode 100644 index 00000000000..bf35c868fc3 --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_qs_7/index.mdx @@ -0,0 +1,321 @@ +--- +title: "Quick Start Guide for RHEL/CentOS 7" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/quick-start/quick-start-guide-for-rhelcentos-7/2.6.1/genindex.html" + - "/edb-docs/d/edb-backup-and-recovery-tool/quick-start/quick-start-guide-for-rhelcentos-7/2.6.1/index.html" +--- + +This tutorial demonstrates using `yum` to [install](#installing) and [configure](../bart_qs_8/#configuring) Backup and Recovery Tool (BART) 2.5 on a CentOS 7 host with minimal configuration settings.  The tutorial assumes that the user has some knowledge of installation and system administration procedures, and has administrative privileges on the host. + +For detailed information about BART installation and configuration, see the *BART Installation and Upgrade Guide*, available at the [EDB website](/bart/2.5/bart_inst/). + +- BART is tested with the following database versions: + + - Advanced Server - 9.6, 10, 11, and 12. + - PostgreSQL - 9.6, 10, 11, and 12. + + + +**Installing BART** + +The following steps describe installing BART on CentOS 7.x OS using `yum`. + +1. Assume superuser privileges and use `yum` to create the repository configuration file: + + ```text + yum install -y https://yum.enterprisedb.com/edbrepos/edb-repo-latest.noarch.rpm + ``` + +2. Create an EDB user account to request credentials to the EDB repository; for a user account visit the [EnterpriseDB website](https://www.enterprisedb.com/repository-access-request). + +3. Use your choice of editor to open the repository configuration file (named `edb.repo`, located in `/etc/yum.repos.d`), and set the `enabled` parameter value to `1`, and replace the `username` and `password` placeholders in the `baseurl` specification with the username and password of a registered EnterpriseDB user. + +4. Update the cache: + + ```text + yum makecache + ``` + +5. Install an Advanced Server or PostgreSQL database server. + + To install Advanced Server, execute the following command: + + ```text + yum -y install edb-as12-server + ``` + + Use sudo to assume the identity of the `enterprisedb` database superuser + + ```text + sudo su - enterprisedb + ``` + + Create an Advanced Server cluster named `acctg` on listener port `5444`: + + ```text + /usr/edb/as12/bin/initdb -D /var/lib/edb/as12/acctg + ``` + + As the `enterprisedb` user, start the cluster: + + ```text + /usr/edb/as12/bin/pg_ctl start -D /var/lib/edb/as12/acctg + ``` + + You can check the status of the cluster with the following command: + + ```text + /usr/edb/as12/bin/pg_ctl status -D /var/lib/edb/as12/acctg + ``` + + !!! Note + The BART host server is not required to have an Advanced Server or PostgreSQL installation, but must include a copy of the Postgres `libpq` library, the `pg_basebackup` utility program, and Boost Libraries 1.53 version for CentOS 7. + +6. If you do not already have the `pg_basebackup` program installed on the BART host, you can use the following command to install a limited number of files that include the `pg_basebackup` program: + + ```text + yum install edb-as-server-client + ``` + + Where <xx> is the Advanced Server version. + +7. As a root user, execute the following command to install BART: + + ```text + yum install edb-bart + ``` + +BART (the bart program and bart-scanner) is installed in the `/usr/edb/bart/bin` directory, referred to as ``. Repeat the installation process described in this section to install BART on all remote hosts where incremental backups are to be restored. + + + +**Configuring BART** + +Before configuring BART, establish the BART user account (the operating system user) that will run the BART command line program. Then, to configure the BART host and each database server that is to be managed by BART, perform the following steps: + +1. Assume superuser privileges, create the directory that will hold the BART backup catalog, and assign its ownership (with restrictive privileges) to the BART user account: + + In this example, `bartuser` is the BART user account and `/opt/backup` is the BART backup catalog. + + ```text + su root + mkdir /opt/backup + chown bartuser /opt/backup + chgrp bartuser /opt/backup + chmod 700 /opt/backup + ``` + +2. Navigate to the `/usr/edb/bart/etc` directory and copy the `bart.cfg.sample` file to create the BART configuration file (`bart.cfg`): + + ```text + cp bart.cfg.sample bart.cfg + ``` + +3. Open the BART configuration file (`bart.cfg`) using an editor of your choice and scroll through the BART configuration file to edit the file as required; sample settings are included for your reference. You must add the mandatory parameters to the `[BART]` and `[ServerName]` sections. Default values may be used for optional parameters. For detailed information about parameter settings, see the *BART Installation and Upgrade Guide*, available at the [EDB website](/bart/2.5/bart_inst/). + + Parameters set in the `[BART]` section are applicable to all BART managed database servers, while parameters set in the `[ServerName]` section are applicable only to the specific server; `[ServerName]` settings override `[BART]` section settings. + + In the following example, only mandatory parameters are set: + + ```text + [BART] + bart_host= bartuser@192.168.169.199 + backup_path = /opt/backup + pg_basebackup_path = /usr/edb/as12/bin/pg_basebackup + + [EPAS12] + host = 127.0.0.1 + user = repuser + cluster_owner = enterprisedb + ``` + +The following table describes only mandatory parameters: + +| **Parameters/Placeholder** | **Section** | **Description** | +| -------------------------- | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `bart_host` | `[BART]` | Use this field to specify the BART user and the IP address of the host on which the BART utility is installed. Specify the value in the form of `@`. | +| `backup_path` | `[BART]` | Use this field to specify the path where all BART backups and archived WAL files will be stored. Ensure the BART user account holds privileges to create subdirectories and files within the location specified in the `backup_path` parameter. The default `backup_path` is BART backup catalog (`/opt/backup`). | +| `pg_basebackup_path` | `[BART]` | Use this field to specify the path to the pg_basebackup utility (`/usr/edb/as/bin/pg_basebackup`). | +| `[ServerName]` | `[ServerName]` | Specify the name of the database server to be backed up (for example, \[EPAS12]). | +| `host` | `[ServerName]` | Specify the IP address of the database server to be configured for backup. | +| `user` | `[ServerName]` | Specify the replication database user name used by BART to establish the connection to the database server for full backups. | +| `cluster_owner` | `[ServerName]` | Specify the Linux operating system user account that owns the database cluster. | + +4. As a BART user, navigate to `/usr/edb/bart/bin` and invoke the following subcommand (omitting the `-s` option) to verify the \[BART] section parameter settings: + + ```text + bart CHECK-CONFIG + ``` + +5. Authorize [SSH/SCP access](../bart_qs_8/#passwordless) between the server and the BART host without a password prompt. + +6. Create a [replication database user](../bart_qs_8/#replication) for each database server that BART manages. + +7. To enable continuous WAL archiving for any database server for which BART is to perform a backup, modify the `postgresql.conf` file, setting: + + - `wal_level` to `replica` or higher (for Postgres 9.6 or later) + - `archive_mode` to `on` + - `archive_command` (if it is not set in the `bart.cfg` file) + - `max_wal_senders` to a value high enough to leave at least one session available for the backup. + + After setting the parameters, restart the database server. + +8. To start the WAL scanner, navigate to `/usr/edb/bart/bin` as a BART user and execute the following command: + + ```text + ./bart-scanner + ``` + +9. If you are using the default `archive_command`, then navigate to `/usr/edb/bart/bin` as a BART user, run the `INIT` subcommand without the `-o` option, and restart the database server: + + ```text + bart INIT [ -s { | all } ] + ``` + + Where `` is the name of the database server to be backed up. + + If you have customized the `archive_command` setting in the `bart.cfg` file, run the `INIT` subcommand with the `-o` option to override any existing Postgresql `archive_command` setting in the `postgresql.conf` or the `postgresql.auto.conf` file, and restart the database server. + + ```text + bart INIT [ -s { | all } ] [ -o ] + ``` + +10. To verify the database server parameter settings, as a BART user navigate to `/usr/edb/bart/bin` and invoke the `CHECK-CONFIG` subcommand with the -s option: + + ```text + bart CHECK-CONFIG [ -s ] + ``` + + BART is now configured successfully. For detailed information about using BART, see the *EDB Backup and Recovery Tool User Guide*, available at the [EDB website](/bart/2.5/bart_user/). + + + +**Creating a Passwordless Connection** + +The following example enables SSH/SCP access on a CentOS 7.x host; similar (platform-specific) steps will apply to other platforms/versions. You must create a passwordless connection between the BART host (SSH/SCP client) and the database server (target SSH/SCP server), as well as a passwordless connection between the database server (SSH/SCP client) and the BART host (target SSH/SCP server). + +1. Log in as the user account on the BART host that will be initiating the SSH or SCP connection and navigate to the user account’s home directory and check for an existing `.ssh` subdirectory. If the `.ssh` directory does not exist, create one with the required privileges. + +2. As a root user navigate to `/usr/edb/bart`, open the `/etc/ssh/sshd_config` file and set the `PubkeyAuthentication` parameter to `yes`. + +3. Reload the configuration file: + + ```text + service sshd reload + ``` + + If you get any SSH or SCP errors, examine the log file (`/var/log/secure`). + +4. As a BART user, use the following command to generate the public key file; you can accept the default responses: + + ```text + ssh-keygen -t rsa + ``` + + The public key file named `id_rsa.pub` is created in the `.ssh` subdirectory. + +5. Use `SCP` to make a temporary copy of the public key file on the target server: + + ```text + scp ~/.ssh/id_rsa.pub target_user@host_address:tmp.pub + ``` + +6. As a `target_user`, log into the target server using `ssh target_user@host_address` command and navigate to the user account’s home directory to check if there is an existing `.ssh` subdirectory. If it does not exist, create one with the required privileges. + +7. Append the client’s temporary public key file, `tmp.pub`, to the `authorized_keys` file: + + ```text + cat tmp.pub >> ~/.ssh/authorized_keys + ``` + + If an `authorized_keys` file does not exist, create a new file, but be careful not to completely replace any existing `authorized_keys` file. + +8. Ensure only the file owner (and not other groups or users) has access to `authorized_keys` file: + + ```text + chmod 600 ~/.ssh/authorized_keys + ``` + +9. Delete the temporary public key file: + + ```text + rm tmp.pub + ``` + + Now, when logged into the BART host as a user, there should be no prompt for a password when you are connecting to the target database server: + + ```text + ssh target_user@database_server_address + ``` + +**Creating a Passwordless Connection Between the Database Server and the BART Host** + +If backups are to be taken from a given database server host, but restored to a different database server host, the passwordless SSH/SCP connections must be configured from the BART host to the database server host from which the backup is to be taken as well as from the BART host to the database server host to which the backup is to be restored. + +An example of how to create a passwordless connection is documented in the *EDB Backup and Recovery Reference Guide*, available at the [EDB website](/bart/2.5/bart_ref/). + +Even when the Advanced Server database is on the same host as BART, and the Advanced Server database cluster owner is also the BART user account, a passwordless SSH/SCP connection must be established from the same user account to itself. + +1. On the database server, navigate into the target user account’s home directory to check for an existing `.ssh` subdirectory. If it does does not exist, create one in the user account’s home directory with the required privileges. + +2. As a database server user, generate the public key file: + + ```text + ssh-keygen -t rsa + ``` + +3. Create a temporary copy of the public key file: + + ```text + scp ~/.ssh/id_rsa.pub target_user@host_address:tmp.pub + ``` + +4. As a target user, log into the BART host and navigate to the user account’s home directory to check if there is an existing `.ssh` subdirectory. If it does not exist, create one with the required privileges: + + ```text + ssh target_user@host_address + ``` + +5. Append the temporary, client’s public key file to the `authorized_keys` file: + + ```text + cat tmp.pub >> ~/.ssh/authorized_keys + ``` + +If an `authorized_keys` file does not exist, create a new file, but do not completely replace any existing `authorized_keys` file. + +6. Ensure only the file owner (and not other groups or users) has access to `authorized_keys` file: + + ```text + chmod 600 ~/.ssh/authorized_keys + ``` + +7. Delete the temporary public key file: + + ```text + rm tmp.pub + ``` + + Now, when logged into the database server as a user, there should be no prompt for a password when you are connecting to the BART host: + + ```text + ssh bart_user@bartip_address + ``` + + + +**Creating a Replication Database User** + +1. To create a replication database user (a superuser), connect to the database server with the psql client, and invoke the following PostgreSQL command: + + ```text + CREATE ROLE WITH LOGIN SUPERUSER PASSWORD ''; + ``` + +2. Specify this replication database user in the `user` parameter of the `bart.cfg` file. + +3. The [pg_hba.conf](https://www.postgresql.org/docs/12/auth-pg-hba-conf.html) file must minimally permit the replication database user to have access to the database. The IP address from which the replication database user has access to the database is the BART host location. The replication database user must also be included in the `pg_hba.conf` file as a replication database connection if `pg_basebackup` is to be used for taking any backups. + +4. To ensure there is no password prompt when connecting to the database server with the replication database user, a recommended method is to use the `.pgpass` file located in the BART user account’s home directory (if it does not exist, you need to create the `.pgpass` file with the required privileges). The `.pgpass` file must contain an entry for each BART managed database server, and its corresponding replication database user and password. diff --git a/product_docs/docs/bart/2.5/bart_qs_8/images/EDB_logo.png b/product_docs/docs/bart/2.5/bart_qs_8/images/EDB_logo.png new file mode 100644 index 00000000000..39a54822d85 Binary files /dev/null and b/product_docs/docs/bart/2.5/bart_qs_8/images/EDB_logo.png differ diff --git a/product_docs/docs/bart/2.5/bart_qs_8/images/edb.png b/product_docs/docs/bart/2.5/bart_qs_8/images/edb.png new file mode 100644 index 00000000000..71e5bdde787 Binary files /dev/null and b/product_docs/docs/bart/2.5/bart_qs_8/images/edb.png differ diff --git a/product_docs/docs/bart/2.5/bart_qs_8/images/edb_logo.svg b/product_docs/docs/bart/2.5/bart_qs_8/images/edb_logo.svg new file mode 100644 index 00000000000..f24d1dfefee --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_qs_8/images/edb_logo.svg @@ -0,0 +1,19 @@ + + + edb-logo-disc-dark + + + + \ No newline at end of file diff --git a/product_docs/docs/bart/2.5/bart_qs_8/images/image2.png b/product_docs/docs/bart/2.5/bart_qs_8/images/image2.png new file mode 100644 index 00000000000..4eba2e7efa7 Binary files /dev/null and b/product_docs/docs/bart/2.5/bart_qs_8/images/image2.png differ diff --git a/product_docs/docs/bart/2.5/bart_qs_8/index.mdx b/product_docs/docs/bart/2.5/bart_qs_8/index.mdx new file mode 100644 index 00000000000..008295fcc1d --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_qs_8/index.mdx @@ -0,0 +1,317 @@ +--- +title: "Quick Start Guide for RHEL/CentOS 8" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/quick-start/quick-start-guide-for-rhelcentos-8/2.6.1/genindex.html" + - "/edb-docs/d/edb-backup-and-recovery-tool/quick-start/quick-start-guide-for-rhelcentos-8/2.6.1/index.html" +--- + +This tutorial demonstrates using the `dnf` command to install and configure the EDB Backup and Recovery Tool (BART) 2.5 on a CentOS 8 host with minimal configuration settings.  The tutorial assumes that the user has some knowledge of installation and system administration procedures and has administrative privileges on the host. + +For detailed information about BART installation and configuration, see the *BART Installation and Upgrade Guide* available at the [EDB website](/bart/2.5/bart_inst/). + +- BART is tested with the following database versions: + + - Advanced Server - 9.6, 10, 11, and 12. + - PostgreSQL - 9.6, 10, 11, and 12. + +**Installing BART** + +The following steps describe installing BART on CentOS 8.x OS. + +1. Assume superuser privileges and use `dnf` to create the repository configuration file: + + ```text + dnf install -y https://yum.enterprisedb.com/edbrepos/edb-repo-latest.noarch.rpm + ``` + +2. Create an EDB user account to request credentials to the EDB repository; for a user account visit the [EnterpriseDB website](https://www.enterprisedb.com/repository-access-request). + +3. Use your choice of editor to open the repository configuration file (named `edb.repo`, located in `/etc/yum.repos.d`), set the `enabled` parameter value to `1`, and replace the `username` and `password` placeholders in the `baseurl` specification with the username and password of a registered EnterpriseDB user. + +4. Update the cache: + + ```text + dnf makecache + ``` + +5. Install an Advanced Server or PostgreSQL database server. + + To install Advanced Server, execute the following command: + + ```text + dnf -y install edb-as12-server + ``` + + Use sudo to assume the identity of the `enterprisedb` database superuser: + + ```text + sudo su - enterprisedb + ``` + + Create an Advanced Server cluster named `acctg` on listener port `5444`: + + ```text + /usr/edb/as12/bin/initdb -D /var/lib/edb/as12/acctg + ``` + + As the `enterprisedb` user, start the cluster: + + ```text + /usr/edb/as12/bin/pg_ctl start -D /var/lib/edb/as12/acctg + ``` + + You can check the status of the cluster with the following command: + + ```text + /usr/edb/as12/bin/pg_ctl status -D /var/lib/edb/as12/acctg + ``` + + !!! Note + The BART host server is not required to have an Advanced Server or PostgreSQL installation, but must include a copy of the Postgres `libpq` library, the `pg_basebackup` utility program, and Boost Libraries 1.66 version for CentOS 8. + +6. If you do not already have the `pg_basebackup` program installed on the BART host, you can use the following command to install a limited number of files that include the `pg_basebackup` program: + + ```text + dnf install edb-asxx-server-client + ``` + +7. As a root user, use the following command to install the BART RPM package: + + ```text + dnf install edb-bart + ``` + +BART (the `bart` program and `bart-scanner`) is installed in the `/usr/edb/bart/bin` directory, referred to as ``. Repeat the installation process described in this section to install BART on all remote hosts where incremental backups are to be restored. + + + +**Configuring BART** + +Before configuring BART, establish the BART user account (the operating system user) to run the BART command line program. Then, to configure the BART host and each database server that is to be managed by BART, perform the following steps: + +1. Assume superuser privileges, create the directory that will hold the BART backup catalog, and assign its ownership (with restrictive privileges) to the BART user account: + + In this example, `bartuser` is the BART user account and `/opt/backup` is the BART backup catalog. + + ```text + su root + mkdir /opt/backup + chown bartuser /opt/backup + chgrp bartuser /opt/backup + chmod 700 /opt/backup + ``` + +2. Navigate to the `/usr/edb/bart/etc` directory and copy the `bart.cfg.sample` file to create the BART configuration file (`bart.cfg`): + + ```text + cp bart.cfg.sample bart.cfg + ``` + +3. Open the BART configuration file (`bart.cfg`) using an editor of your choice and scroll through the BART configuration file to edit the file as required; sample settings are included for your reference. You must add the mandatory parameters to the `[BART]` and `[ServerName]` sections. Default values may be used for optional parameters. For detailed information about parameter settings, see the *BART Installation and Upgrade Guide*, available at the [EDB website](/bart/2.5/bart_inst/). + + Parameters set in the `[BART]` section are applicable to all BART managed database servers, while parameters set in the `[ServerName]` section are applicable only to the specific server; `[ServerName]` settings override `[BART]` section settings. + + In the following example, only mandatory parameters are set: + + ```text + [BART] + bart_host= bartuser@192.168.169.199 + backup_path = /opt/backup + pg_basebackup_path = /usr/edb/as12/bin/pg_basebackup + + [EPAS12] + host = 127.0.0.1 + user = repuser + cluster_owner = enterprisedb + ``` + +The following table describes only mandatory parameters: + +| **Parameters/Placeholder** | **Section** | **Description** | +| -------------------------- | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `bart_host` | `[BART]` | Use this field to specify the BART user and the IP address of the host on which the BART utility is installed. Specify the value in the form of `@`. | +| `backup_path` | `[BART]` | Use this field to specify the path where all BART backups and archived WAL files will be stored. Ensure the BART user account holds privileges to create subdirectories and files within the location specified in the `backup_path` parameter. The default `backup_path` is BART backup catalog (`/opt/backup`). | +| `pg_basebackup_path` | `[BART]` | Use this field to specify the path to the pg_basebackup utility (`/usr/edb/as/bin/pg_basebackup`). | +| `[ServerName]` | `[ServerName]` | Specify the name of the database server to be backed up (for example, \[EPAS12]). | +| `host` | `[ServerName]` | Specify the IP address of the database server to be configured for backup. | +| `user` | `[ServerName]` | Specify the replication database user name used by BART to establish the connection to the database server for full backups. | +| `cluster_owner` | `[ServerName]` | Specify the Linux operating system user account that owns the database cluster. | + +4. As a BART user, navigate to `/usr/edb/bart/bin` and invoke the following subcommand (omitting the `-s` option) to verify the \[BART] section parameter settings: + + ```text + bart CHECK-CONFIG + ``` + +5. Authorize [SSH/SCP access](#passwordless) between the server and the BART host without a password prompt. + +6. Create a [replication database user](#replication) for each database server that BART manages. + +7. To enable continuous WAL archiving for any database server for which BART is to perform a backup, modify the `postgresql.conf` fil and set it to: + + - `wal_level` to `replica` or higher (for Postgres 9.6 or later) + - `archive_mode` to `on` + - `archive_command` (if it is not set in the `bart.cfg` file) + - `max_wal_senders` to a value high enough to leave at least one session available for the backup. + + After setting the parameters, restart the database server. + +8. To start the WAL scanner, navigate to `/usr/edb/bart/bin` as a BART user and execute the following command: + + ```text + ./bart-scanner + ``` + +9. If you are using the default `archive_command`, then navigate to `/usr/edb/bart/bin` as a BART user, run the `INIT` subcommand without the `-o` option, and restart the database server: + + ```text + bart INIT [ -s { | all } ] + ``` + + Where `` is the name of the database server to be backed up. + + If you have customized the `archive_command` setting in the `bart.cfg` file, run the `INIT` subcommand with the `-o` option to override any existing Postgresql `archive_command` setting in the `postgresql.conf` or the `postgresql.auto.conf` file, and restart the database server. + + ```text + bart INIT [ -s { | all } ] [ -o ] + ``` + +10. To verify the database server parameter settings, as a BART user navigate to `/usr/edb/bart/bin` and invoke the `CHECK-CONFIG` subcommand with the -s option: + + ```text + bart CHECK-CONFIG [ -s ] + ``` + + BART is now configured successfully. For detailed information about using BART, see the *EDB Backup and Recovery Tool User Guide* available at the [EDB website](/bart/2.5/bart_user/). + + + +**Creating a Passwordless Connection** + +The following example enables SSH/SCP access on a CentOS 8.x host; similar (platform-specific) steps will apply to other platforms/versions. You must create a passwordless connection between the BART host (SSH/SCP client) and the database server (target SSH/SCP server), as well as a passwordless connection between the database server (SSH/SCP client) and the BART host (target SSH/SCP server). + +1. Log in as the user account on the BART host that will be initiating the SSH or SCP connection and navigate to the user account’s home directory and check for an existing `.ssh` subdirectory. If the `.ssh` directory does not exist, create one with the required privileges. + +2. As a root user navigate to `/usr/edb/bart`, open the `/etc/ssh/sshd_config` file and set the `PubkeyAuthentication` parameter to `yes`. + +3. Reload the configuration file: + + ```text + service sshd reload + ``` + + If you get any SSH or SCP errors, examine the log file (`/var/log/secure`). + +4. As a BART user, use the following command to generate the public key file; you can accept the default responses: + + ```text + ssh-keygen -t rsa + ``` + + The public key file named `id_rsa.pub` is created in the `.ssh` subdirectory. + +5. Use `SCP` to make a temporary copy of the public key file on the target server: + + ```text + scp ~/.ssh/id_rsa.pub target_user@host_address:tmp.pub + ``` + +6. As a `target_user`, log into the target server using `ssh target_user@host_address` command and navigate to the user account’s home directory to check if there is an existing `.ssh` subdirectory. If it does not exist, create one with the required privileges. + +7. Append the temporary client’s public key file, `tmp.pub`, to the `authorized_keys` file: + + ```text + cat tmp.pub >> ~/.ssh/authorized_keys + ``` + + If an `authorized_keys` file does not exist, create a new file, but be careful not to completely replace any existing `authorized_keys` file. + +8. Ensure only the file owner (and not other groups or users) has access to `authorized_keys` file: + + ```text + chmod 600 ~/.ssh/authorized_keys + ``` + +9. Delete the temporary public key file: + + ```text + rm tmp.pub + ``` + + Now, when logged into the BART host as a user, there should be no prompt for a password when you are connecting to the target database server: + + ```text + ssh target_user@database_server_address + ``` + +**Creating a Passwordless Connection Between the Database Server and the BART Host** + +If backups are to be taken from a given database server host, but restored to a different database server host, the passwordless SSH/SCP connections must be configured from the BART host to the database server host from which the backup is to be taken as well as from the BART host to the database server host to which the backup is to be restored. + +An example of how to create a passwordless connection is documented in the *EDB Backup and Recovery Reference Guide*, available at the [EDB website](/bart/2.5/bart_ref/). + +Even when the Advanced Server database is on the same host as BART, and the Advanced Server database cluster owner is also the BART user account, a passwordless SSH/SCP connection must be established from the same user account to itself. + +1. On the database server, navigate into the target user account’s home directory to check for an existing `.ssh` subdirectory. If it does does not exist, create one in the user account’s home directory with the required privileges. + +2. As a database server user, generate the public key file: + + ```text + ssh-keygen -t rsa + ``` + +3. Create a temporary copy of the public key file: + + ```text + scp ~/.ssh/id_rsa.pub target_user@host_address:tmp.pub + ``` + +4. As a target user, log into the BART host and navigate to the user account’s home directory to check if there is an existing `.ssh` subdirectory. If it does not exist, create one with the required privileges: + + ```text + ssh target_user@host_address + ``` + +5. Append the client’s temporary public key file to the `authorized_keys` file: + + ```text + cat tmp.pub >> ~/.ssh/authorized_keys + ``` + +If the `authorized_keys file` does not exist, create a new file, but do not completely replace any existing `authorized_keys` file. + +6. Ensure that only the file owner (and not other groups or users) has access to `authorized_keys` file: + + ```text + chmod 600 ~/.ssh/authorized_keys + ``` + +7. Delete the temporary public key file: + + ```text + rm tmp.pub + ``` + + Now, when logged into the database server as a user, there should be no prompt for a password when you are connecting to the BART host: + + ```text + ssh bart_user@bartip_address + ``` + + + +**Creating a Replication Database User** + +1. To create a replication database user (a superuser), connect to the database server with the psql client, and invoke the following PostgreSQL command: + + ```text + CREATE ROLE WITH LOGIN SUPERUSER PASSWORD ''; + ``` + +2. Specify this replication database user in the `user` parameter of the `bart.cfg` file. + +3. The [pg_hba.conf](https://www.postgresql.org/docs/12/auth-pg-hba-conf.html) file must minimally permit the replication database user to have access to the database. The IP address from which the replication database user has access to the database is the BART host location. The replication database user must also be included in the `pg_hba.conf` file as a replication database connection if `pg_basebackup` is to be used for taking any backups. + +4. To ensure there is no password prompt when connecting to the database server with the replication database user, a recommended method is to use the `.pgpass` file located in the BART user account’s home directory (if it does not exist, you need to create the `.pgpass` file with the required privileges). The `.pgpass` file must contain an entry for each BART managed database server, and its corresponding replication database user and password. diff --git a/product_docs/docs/bart/2.5/bart_ref/01_bart_subcommands_examples/01_backup.mdx b/product_docs/docs/bart/2.5/bart_ref/01_bart_subcommands_examples/01_backup.mdx new file mode 100644 index 00000000000..97172dd9b88 --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_ref/01_bart_subcommands_examples/01_backup.mdx @@ -0,0 +1,218 @@ +--- +title: "BACKUP" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/backup.html" +--- + +Use the `BACKUP` subcommand to create a full or incremental backup. + +**Syntax for a Full Backup:** + +```text +bart BACKUP –s { | all } [ -F { p | t } ] + +[ -z ] [ –c ] + +[ --backup-name ] + +[ --thread-count ] + +[ { --with-pg_basebackup | --no-pg_basebackup } ] +``` + +**Syntax for an Incremental Backup:** + +```text +bart BACKUP –s [-Fp] + +[ --parent { | } ] + +[ --backup-name ] + +[ --thread-count ] + +``` + +Before performing an incremental backup, you must take a full backup. For more details about incremental backup, refer to *Block-Level Incremental Backup* in the *EDB Backup and Recovery User Guide* available at the [EDB website](/bart/2.5/bart_user/). + +The following table describes the `BACKUP` options: + +| Options | Description | +| ---------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { \| all }`
`--server { \| all }` | Use this option to specify the database server to be backed up.
Specify `` to take a backup of the database server (as specified in the BART configuration file).
Specify `all` to take a backup of all servers. | +| `-F { p \| t }`
`--format { p \| t }` | Use this option to specify the backup file format.
Specify `p` option to take backup in plain text format and specify `t` option to take backup in tar format. If the `p` or `t` option is omitted, the default is tar format.
Use `p` option with the `BACKUP` subcommand when streaming is used as a backup method.
An incremental backup can only be taken in plain text format (`p`). | +| `-z`
`(--gzip)` | This option is applicable only for full backup and `tar` format. Use this option to enable gzip compression of tar files using the default compression level (typically 6). | +| `-c `
`--compress-level ` | This is applicable only for full backup and tar format. Use this option to specify the gzip compression level on the tar file output. `` is a digit from 1 through 9, with 9 being the best compression. | +| `--backup-name ` | Use this option to assign a user-defined, alphanumeric friendly name to the backup. The maximum permitted length of backup name is 49 characters.
For detailed information about this parameter, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/2.5/bart_user/).
If the option `--backup-name` is not specified and the `backup_name` parameter is not set for this database server in the BART configuration file, then the backup can only be referenced in other BART subcommands by the BART assigned backup identifier. | +| `--thread-count ` | Use this option to specify the number of worker threads to run in parallel to copy blocks for a backup.
For detailed information about the `--thread-count` parameter, see the EDB Backup and Recovery Installation and Upgrade Guide available at the [EDB website](/bart/2.5/bart_inst/). | +| `--with-pg_basebackup` | This is applicable only for full backup. Use this option to specify the use of `pg_basebackup` to take a full backup. The number of thread counts in effect is ignored as given by the `thread_count` parameter in the BART configuration file.
When taking a full backup, if the thread count in effect is greater than `1`, then the `pg_basebackup` utility is not used to take the full backup (parallel worker threads are used) unless the `--with-pg_basebackup` option is specified with the `BACKUP` subcommand. | +| `--no-pg_basebackup` | This is applicable only for full backup. Use this option to specify that `pg_basebackup` is not to be used to take a full backup.
When taking a full backup, if the thread count in effect is only `1`, then the `pg_basebackup` utility is used to take the full backup unless the `--no-pg_basebackup` option is specified with the `BACKUP` subcommand. | +| `--parent { \| }` | Use this option to take an incremental backup. The parent backup is a backup taken prior to the incremental backup; it can be either a full backup or an incremental backup. `` is the backup identifier of a parent backup and `` is the user-defined alphanumeric name of a parent backup. | +| `--check` | This is applicable only for incremental backup. Use this option to verify if the required MBM files are present in the BART backup catalog before taking an incremental backup. However, an actual incremental backup is not taken when the `--check` option is specified.
The `--parent` option must be used along with the `--check` option. | + +**Examples** + +The following code sample demonstrates using variables with the `BACKUP` subcommand: + +```text +./bart backup -s ppas12 -Ft --backup-name "YEAR = %year MONTH = +%month DAY = %day" +``` + +```text +./bart backup -s ppas12 -Ft --backup-name "YEAR = %year MONTH = +%month DAY = %day %%" +``` + +```text +./bart show-backups -s ppas12 -i "test backup" +``` + +The following code sample displays the result of creating a full backup in the default tar format with gzip compression when the `BACKUP` subcommand was invoked. Note that checksums are generated for the full backup and user-defined tablespaces for the tar format backup: + +```text +[edb@localhost bin]$ ./bart BACKUP -s hr -z +INFO: DebugTarget - getVar(checkDiskSpace.bytesAvailable) +INFO: new backup identifier generated 1567591909098 +INFO: creating 5 harvester threads +NOTICE: all required WAL segments have been archived +INFO: backup completed successfully +INFO: +BART VERSION: 2.5 +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1567591909098 +BACKUP NAME: none +BACKUP PARENT: none +BACKUP LOCATION: /home/edb/bkup_new/hr/1567591909098 +BACKUP SIZE: 13.91 MB +BACKUP FORMAT: tar.gz +BACKUP TIMEZONE: America/New_York +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 0 +TABLESPACE(s): 3 +Oid Name Location +16387 test1 /home/edb/tbl1 +16388 test2 /home/edb/tbl2 +16389 test3 /home/edb/tbl3 + +START WAL LOCATION: 000000010000000000000025 +STOP WAL LOCATION: 000000010000000000000026 +BACKUP METHOD: streamed +BACKUP FROM: master +START TIME: 2019-09-04 06:11:49 EDT +STOP TIME: 2019-09-04 06:11:53 EDT +TOTAL DURATION: 4 sec(s) +``` + +The following code sample displays information about the directory containing the full backup: + +```text +[edb@localhost bin]$number_of_threads> +[edb@localhost bin]$ ls -l /home/edb/bkup_new/hr/ +total 8 +drwxrwxr-x. 3 edb edb 34 Aug 27 05:57 1566899819709 +drwxrwxr-x. 3 edb edb 58 Aug 27 05:57 1566899827751 +drwxrwxr-x. 3 edb edb 4096 Sep 4 06:11 1567591909098 +drwxrwxr-x. 2 edb edb 4096 Sep 4 06:11 archived_wals +[edb@localhost bin]$ +``` + +The following code sample displays information about the creation of a full backup while streaming the transaction log. Note that the `-Fp` option must be specified with the `BACKUP` subcommand when streaming is used as a backup method. + +```text +[edb@localhost bin]$ ./bart BACKUP -s ACCTG -Fp +INFO: DebugTarget - getVar(checkDiskSpace.bytesAvailable) +INFO: new backup identifier generated 1566898964200 +INFO: creating 5 harvester threads +NOTICE: pg_stop_backup complete, all required WAL segments have been archived +INFO: backup completed successfully +INFO: +BART VERSION: 2.5 +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1566898964200 +BACKUP NAME: none +BACKUP PARENT: none +BACKUP LOCATION: /home/edb/bkup_new/acctg/1566898964200 +BACKUP SIZE: 46.03 MB +BACKUP FORMAT: plain +BACKUP TIMEZONE: US/Eastern +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 0 +TABLESPACE(s): 0 +START WAL LOCATION: 000000010000000000000017 +BACKUP METHOD: streamed +BACKUP FROM: master +START TIME: 2019-08-27 05:42:44 EDT +STOP TIME: 2019-08-27 05:42:46 EDT +TOTAL DURATION: 2 sec(s) +``` + +The following code sample displays the assignment of a user-defined backup name with the `--backup-name` option: + +```text +[edb@localhost bin]$ ./bart BACKUP -s acctg --backup-name acctg_%year-%month-%day +INFO: DebugTarget - getVar(checkDiskSpace.bytesAvailable) +INFO: new backup identifier generated 1566899004804 +INFO: creating 5 harvester threads +NOTICE: pg_stop_backup complete, all required WAL segments have been archived +INFO: backup completed successfully +INFO: +BART VERSION: 2.5 +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1566899004804 +BACKUP NAME: acctg_2019-08-27 +BACKUP PARENT: none +BACKUP LOCATION: /home/edb/bkup_new/acctg/1566899004804 +BACKUP SIZE: 46.86 MB +BACKUP FORMAT: tar +BACKUP TIMEZONE: US/Eastern +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 0 +TABLESPACE(s): 0 +START WAL LOCATION: 00000001000000000000001A +BACKUP METHOD: streamed +BACKUP FROM: master +START TIME: 2019-08-27 05:43:24 EDT +STOP TIME: 2019-08-27 05:43:24 EDT +TOTAL DURATION: 0 sec(s) +``` + +The following code sample displays an incremental backup taken by specifying the `--parent` option. The option `-Fp` must be specified while taking an incremental backup as incremental backup can be taken only in plain text format. + +```text +[edb@localhost bin]$ ./bart BACKUP -s hr -Fp --parent hr_full_1 --backup-name +hr_incr_1 +INFO: DebugTarget - getVar(checkDiskSpace.bytesAvailable) +INFO: checking /home/edb/bkup_new/hr/archived_wals for MBM files from 0/20000028 to +0/22000000 +INFO: new backup identifier generated 1566899827751 +INFO: creating 5 harvester threads +NOTICE: all required WAL segments have been archived +INFO: backup completed successfully +INFO: +BART VERSION: 2.5 +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1566899827751 +BACKUP NAME: hr_incr_1 +BACKUP PARENT: 1566899819709 +BACKUP LOCATION: /home/edb/bkup_new/hr/1566899827751 +BACKUP SIZE: 7.19 MB +BACKUP FORMAT: plain +BACKUP TIMEZONE: America/New_York +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 0 +TABLESPACE(s): 0 +START WAL LOCATION: 000000010000000000000022 +STOP WAL LOCATION: 000000010000000000000023 +BACKUP METHOD: streamed +BACKUP FROM: master +START TIME: 2019-08-27 05:57:07 EDT +STOP TIME: 2019-08-27 05:57:08 EDT +TOTAL DURATION: 1 sec(s) +``` \ No newline at end of file diff --git a/product_docs/docs/bart/2.5/bart_ref/01_bart_subcommands_examples/02_check_config.mdx b/product_docs/docs/bart/2.5/bart_ref/01_bart_subcommands_examples/02_check_config.mdx new file mode 100644 index 00000000000..69c51d5249e --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_ref/01_bart_subcommands_examples/02_check_config.mdx @@ -0,0 +1,65 @@ +--- +title: "CHECK-CONFIG" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/check_config.html" +--- + +The `CHECK-CONFIG` subcommand checks the global parameter settings as well as the database server configuration in the BART configuration file. + +The following syntax is used to check the BART configuration file global section settings. + +```text +bart CHECK-CONFIG +``` + +The following syntax is used to check the database server configuration settings. + +```text +bart CHECK-CONFIG [ –s ] +``` + +The following table describes the `CHECK-CONFIG` option: + +| Option | Description | +| ------------------------------------------- | ------------------------------------------------------------------------------------------------------------ | +| `-s ` `--server ` | `` is the name of the database server whose configuration parameter settings are to be checked. | + +**Example** + +The following code sample demonstrates successfully checking the BART configuration file global parameters with the `bart CHECK-CONFIG` command: + +```text +bash-4.1$ bart CHECK-CONFIG +INFO: Verifying that pg_basebackup is executable +INFO: success - +INFO: success - pg_basebackup(/usr/edb/as11/bin/pg_basebackup) returns +version 11.400000 +``` + +The following code sample demonstrates successfully checking the BART configuration file database server parameters with the `bart CHECK-CONFIG` command with the `–s` option: + +```text +[edb@localhost bin]$ ./bart check-config -s hr +INFO: Checking server hr +INFO: Verifying cluster_owner and ssh/scp connectivity +INFO: success +INFO: Verifying user, host, and replication connectivity +INFO: success +INFO: Verifying that user is a database superuser +INFO: success +INFO: Verifying that cluster_owner can read cluster data files +INFO: success +INFO: Verifying that you have permission to write to vault +INFO: success +INFO: /home/edb/bkup_new/hr +INFO: Verifying database server configuration +INFO: success +INFO: Verifying that WAL archiving is working +INFO: waiting 30 seconds for +/home/edb/bkup_new/hr/archived_wals/00000001000000000000001E +INFO: success +INFO: Verifying that bart-scanner is configured and running +INFO: success +``` diff --git a/product_docs/docs/bart/2.5/bart_ref/01_bart_subcommands_examples/03_delete.mdx b/product_docs/docs/bart/2.5/bart_ref/01_bart_subcommands_examples/03_delete.mdx new file mode 100644 index 00000000000..14940d188ca --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_ref/01_bart_subcommands_examples/03_delete.mdx @@ -0,0 +1,141 @@ +--- +title: "DELETE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/delete.html" +--- + +The `DELETE` subcommand removes the subdirectory and data files from the BART backup catalog for the specified backups along with archived WAL files. + +**Syntax:** + +```text +bart DELETE –s +-i { all | [']{ | },... }['] } +[ -n ] +``` + +Note that when invoking the `DELETE` subcommand, you must specify a database server. + +For database servers under a retention policy, there are conditions where certain backups may not be deleted. For more information, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/2.5/bart_user/). + +The following table describes the `DELETE` options: + +| Options | Description | +| -------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s `
`--server ` | `` is the name of the database server whose backups are to be deleted. | +| ``-i { all \| [']{ \| }',... }[`] }``

``--backupid { all \| [']{ \| }',... }[`] }`` | `` is the backup identifier of the backup to be deleted. `` is the user-defined alphanumeric name for the backup.
Multiple backup identifiers and backup names may be specified in a comma-separated list. The list must be enclosed within single quotes if there is any white space appearing before or after each comma (see [Example](#deleting_multiple_backups_with_space_characters)).
If `all` is specified, all backups and their archived WAL files for the specified database server are deleted. | +| `-n`
`--dry-run` | Performs the test run and displays the results prior to physically removing files; no files are actually deleted. | + +**Example** + +The following code sample demonstrates deleting a backup from the specified database server: + +```text +[edb@localhost bin]$ ./bart DELETE -s acctg -i acctg_2019-08-27 +INFO: deleting backup 'acctg_2019-08-27' of server 'acctg' +INFO: deleting backup '1566900093665' +INFO: WALs of deleted backup(s) will belong to prior backup(if any), or will +be marked unused +WARNING: not marking any WALs as unused WALs, the WAL file +'/home/edb/bkup_new/acctg/archived_wals/000000010000000000000025' +is required, yet not available in archived_wals directory +INFO: backup(s) deleted +[edb@localhost bin]$ +``` + +After the deletion, the BART backup catalog for the database server no longer contains the corresponding directory for the deleted `backup ID`. The following code sample displays information about `archived_wals` subdirectory that no longer contains the backup WAL files: + +```text +[edb@localhost acctg]$ ls -l +total 16 +drwxrwxr-x. 3 edb edb 4096 Aug 27 06:03 1566900199604 +drwxrwxr-x. 3 edb edb 4096 Aug 27 06:03 1566900204377 +drwxrwxr-x. 3 edb edb 4096 Aug 27 06:03 1566900209087 +drwxrwxr-x. 3 edb edb 4096 Aug 27 06:05 1566900321228 +drwxrwxr-x. 2 edb edb 6 Aug 27 06:01 archived_wals +``` + +The following code sample demonstrates deleting multiple backups from the database server. + +```text +[edb@localhost bin]$ ./bart DELETE -s acctg -i `1566988095633,1566988100760, +acctg_2019-08-28` +INFO: deleting backup `1566988095633` of server `acctg` +INFO: deleting backup `1566988095633` +INFO: WALs of deleted backup(s) will belong to prior backup(if any), or will +be marked unused +WARNING: not marking any WALs as unused WALs, the WAL file +`/home/edb/bkup_new/acctg/archived_wals/000000010000000000000037` is required, +yet not available in archived_wals directory +INFO: backup(s) deleted +INFO: deleting backup `1566988100760` of server `acctg` +INFO: deleting backup `1566988100760` +INFO: WALs of deleted backup(s) will belong to prior backup(if any), or will +be marked unused +WARNING: not marking any WALs as unused WALs, the WAL file +`/home/edb/bkup_new/acctg/archived_wals/000000010000000000000039` is +required, yet not available in archived_wals directory +INFO: backup(s) deleted +INFO: deleting backup `acctg_2019-08-28` of server `acctg` +INFO: deleting backup `1566988115512` +INFO: WALs of deleted backup(s) will belong to prior backup(if any), or will +be marked unused +WARNING: not marking any WALs as unused WALs, the WAL file +`/home/edb/bkup_new/acctg/archived_wals/00000001000000000000003C` is required, +yet not available in archived_wals directory +INFO: backup(s) deleted +[edb@localhost bin]$ +[edb@localhost bin]$ +[edb@localhost bin]$ +[edb@localhost acctg]$ +[edb@localhost acctg]$ ls -l +total 8 +drwxrwxr-x. 3 edb edb 4096 Aug 28 06:28 1566988105086 +drwxrwxr-x. 3 edb edb 4096 Aug 28 06:28 1566988109477 +drwxrwxr-x. 2 edb edb 6 Aug 28 06:09 archived_wals +[edb@localhost acctg]$ +``` + + + +**Deleting Multiple Backups with Space Characters** + +The following code sample demonstrates deleting multiple backups; since there are space characters in the comma-separated list, the entire list must be enclosed within single quotes: + +```text +[edb@localhost bin]$ ./bart DELETE -s acctg -i +`1566900199604,1566900204377,1566900209087`; +INFO: deleting backup `1566900199604` of server `acctg` +INFO: deleting backup `1566900199604` +INFO: WALs of deleted backup(s) will belong to prior backup(if any), or will +be marked unused +WARNING: not marking any WALs as unused WALs, the WAL file +`/home/edb/bkup_new/acctg/archived_wals/000000010000000000000028` is required, +yet not available in archived_wals directory +INFO: backup(s) deleted +INFO: deleting backup `1566900204377` of server `acctg` +INFO: deleting backup `1566900204377` +INFO: WALs of deleted backup(s) will belong to prior backup(if any), or will +be marked unused +WARNING: not marking any WALs as unused WALs, the WAL file +`/home/edb/bkup_new/acctg/archived_wals/00000001000000000000002A` is required, +yet not available in archived_wals directory +INFO: backup(s) deleted +INFO: deleting backup `1566900209087` of server `acctg` +INFO: deleting backup `1566900209087` +INFO: WALs of deleted backup(s) will belong to prior backup(if any), or will +be marked unused +WARNING: not marking any WALs as unused WALs, the WAL file +`/home/edb/bkup_new/acctg/archived_wals/00000001000000000000002C` is required, +yet not available in archived_wals directory +INFO: backup(s) deleted +[edb@localhost bin]$ +[edb@localhost bin]$ +[edb@localhost acctg]$ ls -l +total 4 +drwxrwxr-x. 3 edb edb 4096 Aug 27 06:05 1566900321228 +drwxrwxr-x. 2 edb edb 6 Aug 27 06:01 archived_wals +[edb@localhost acctg]$ +``` diff --git a/product_docs/docs/bart/2.5/bart_ref/01_bart_subcommands_examples/04_init.mdx b/product_docs/docs/bart/2.5/bart_ref/01_bart_subcommands_examples/04_init.mdx new file mode 100644 index 00000000000..9f8b020ac03 --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_ref/01_bart_subcommands_examples/04_init.mdx @@ -0,0 +1,276 @@ +--- +title: "INIT" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/init.html" +--- + + + +The `INIT` subcommand is used to create the BART backup catalog directory, rebuild the BART `backupinfo` file, and set the `archive_command` in the server based on the `archive_command` setting in the `bart.cfg` file. + +**Syntax:** + +```text +bart INIT [ –s { | all } ] [ -o ] + +[ -r [ -i { | | all } ] ] + +[--no-configure] +``` + +The following table describes the `INIT` options: + +| Options | Description | +| ------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { \| all }`
`--server { \| all }` | `` is the name of the database server to which the `INIT` actions are to be applied. If `all` is specified or if the option is omitted, actions are applied to all servers. | +| `-o`
`--override` | Overrides the existing Postgres `archive_command` configuration parameter setting in the `postgresql.conf` file or the `postgresql.auto.conf` file using the BART `archive_command` parameter in the BART configuration file. The `INIT` generated `archive command` string is written to the `postgresql.auto.conf` file. | +| `-r`
`--rebuild` | Rebuilds the `backupinfo` file located in each backup subdirectory. If `all` is specified or if the option is omitted, the `backupinfo` files of all backups for the database servers specified by the `-s` option are recreated. This option is only intended for recovering from a situation where the backupinfo file has become corrupt.
If the backup was initially created with a user-defined backup name, and then the `INIT -r` option is invoked to rebuild that `backupinfo` file, the user-defined backup name is no longer available. Thus, future references to the backup must use the backup identifier. | +| `-i { \| \| all }`
`--backupid { \| \| all }` | `` is an integer, backup identifier and `` is the user-defined alphanumeric name for the backup. The `-i` option can only be used with the `-r` option. | +| `--no-configure` | Prevents the `archive_command` from being set in the PostgreSQL server. | + +**Examples** + +In the following code sample, you can see that `archive_mode = off` and `archive_command` is not set. After invoking the BART `INIT` subcommand, `archive_mode` is set to `on` and `archive_command` is set: + +```text +archive_mode = off # enables archiving; off, on, or always +# (change requires restart) +archive_command = '' +# command to use to archive a logfile segment +[edb@localhost bin]$ ./bart init -s ppas11 +INFO: setting archive_mode/archive_command for server 'ppas11' +WARNING: archive_mode/archive_command is set. Restart the PostgreSQL +server using 'pg_ctl restart' +[edb@localhost bin]$ +# Do not edit this file manually! +# It will be overwritten by the ALTER SYSTEM command. +archive_mode = 'on' +archive_command = 'scp %p +edb@127.0.0.1:/home/edb/bkup/ppas11/archived_wals/%f' +``` + +In the following code sample, you can see that `archive_mode = on`, and `archive_command` is not set. After invoking the `INIT` subcommand, `archive_command` is set: + +```text +archive_mode = on # enables archiving; off, on, or always +# (change requires restart) +archive_command = '' # command to use to archive a logfile segment +[edb@localhost bin]$ ./bart init -s ppas11 +INFO: setting archive_mode/archive_command for server 'ppas11' +WARNING: archive_command is set. Reload the configuration in the +PostgreSQL server using pg_reload_conf() or 'pg_ctl reload' +[edb@localhost bin]$ +# Do not edit this file manually! +# It will be overwritten by the ALTER SYSTEM command. +archive_command = 'scp %p +edb@127.0.0.1:/home/edb/bkup/ppas11/archived_wals/%f' +``` + +In the following code sample, you can see that `archive_mode = on` and `archive_command` are already set. After invoking the `INIT` subcommand, there is no change in their settings. Note that to override the existing `archive_command`, you must include the `-o` option. + +```text +archive_mode = on # enables archiving; off, on, or always +# (change requires restart) +archive_command = 'scp %p +edb@127.0.0.1:/home/edb/bkup/ppas11/archived_wals/%f' # command to use +to archive a logfile segment +# placeholders: %p = path of file to archive +[edb@localhost bin]$ ./bart init -s ppas11 +INFO: setting archive_mode/archive_command for server 'ppas11' +WARNING: archive_command is not set for server 'ppas11' +[edb@localhost bin]$ +# Do not edit this file manually! +# It will be overwritten by the ALTER SYSTEM command. +``` + +In the following code sample, you can see that `archive_mode = off` and `archive_command` is already set. After invoking the `INIT` subcommand `archive_mode` is set to `on`: + +```text +archive_mode = off # enables archiving; off, on, or always +# (change requires restart) +archive_command = 'scp %p +edb@127.0.0.1:/home/edb/bkup/ppas11/archived_wals/%f' # command to use +to archive a log file segment +[edb@localhost bin]$ ./bart init -s ppas11 +INFO: setting archive_mode/archive_command for server 'ppas11' +WARNING: archive_mode/archive_command is set. Restart the PostgreSQL +server using 'pg_ctl restart' +# Do not edit this file manually! +# It will be overwritten by the ALTER SYSTEM command. +archive_mode = 'on' +archive_command = 'scp %p +edb@127.0.0.1:/home/edb/bkup/ppas11/archived_wals/%f' +``` + +In the following code sample an existing `archive command` setting is overridden by resetting the `archive_command` in the PostgreSQL server with the `archive_command = 'cp %p %a/%f'` parameter from the `bart.cfg` file: + +```text +[BART] + +bart_host= enterprisedb@192.168.2.22 +backup_path = /opt/backup_edb +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log + +[ACCTG] + +host = 127.0.0.1 +port = 5444 +user = repuser +cluster_owner = enterprisedb +archive_command = 'cp %p %a/%f' +description = "Accounting" +``` + +The `archive_mode` and `archive_command` parameters in the database server are set as follows: + +```text +edb=# SHOW archive_mode; +archive_mode +-------------- +on +(1 row) +edb=# SHOW archive_command; +archive_command +------------------------------------------------------------------ +scp %p bartuser@192.168.2.22:/opt/backup/acctg/archived_wals/%f + +(1 row) +``` + +Invoke the `INIT` subcommand with the `-o` option to override the current `archive_command` setting in the PostgreSQL server: + +```text +-bash-4.1$ bart INIT -s acctg -o +INFO: setting archive_mode/archive_command for server 'acctg' +WARNING: archive_command is set. Reload the configuration in the +PostgreSQL server using pg_reload_conf() or 'pg_ctl reload' +``` + +Reload the database server configuration; a restart of the database server is not necessary to reset only the `archive_command` parameter: + +```text +[root@localhost tmp]# service ppas11 reload +``` + +The `archive_command` in the PostgreSQL server is now set as follows: + +```text +edb=# SHOW archive_command; + archive_command +----------------------------------------------- +cp %p /opt/backup_edb/acctg/archived_wals/%f +(1 row) +``` + +The new command string is written to the `postgresql.auto.conf` file: + +```text +# Do not edit this file manually! +# It will be overwritten by ALTER SYSTEM command. +archive_command = 'cp %p /opt/backup_edb/acctg/archived_wals/%f' +``` + +When you invoke the BART `INIT` command with the `-r` option, BART rebuilds the `backupinfo` file using the content of the backup directory for the server specified or for all servers. The BART `backupinfo` file is initially created by the `BACKUP` subcommand and contains the backup information used by BART. + +!!! Note + If the backup was initially created with a user-defined backup name, and then the `INIT -r` option is invoked to rebuild the `backupinfo` file, the user-defined backup name is no longer available. Thus, future references to the backup must use the backup identifier. + +The following code sample shows the `backupinfo` file location in a backup subdirectory: + +```text +[root@localhost acctg]# pwd +/opt/backup/acctg +[root@localhost acctg]# ls -l +total 4 +drwx------ 2 enterprisedb enterprisedb 38 Oct 26 10:21 1477491569966 +drwxrwxr-x 2 enterprisedb enterprisedb 4096 Oct 26 10:19 archived_wals +[root@localhost acctg]# ls -l 1477491569966 +total 61144 +-rw-rw-r-- 1 enterprisedb enterprisedb 703 Oct 26 10:19 backupinfo +-rw-rw-r-- 1 enterprisedb enterprisedb 62603776 Oct 26 10:19 base.tar +``` + +The following code sample displays the `backupinfo` file content: + +```text +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1477491569966 +BACKUP NAME: none +BACKUP PARENT: none +BACKUP LOCATION: /opt/backup/acctg/1477491569966 +BACKUP SIZE: 59.70 MB +BACKUP FORMAT: tar +BACKUP TIMEZONE: +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 1 +ChkSum File +84b3eeb1e3f7b3e75c2f689570d04f10 base.tar +TABLESPACE(s): 0 +START WAL LOCATION: 2/A5000028 (file 0000000100000002000000A5) +STOP WAL LOCATION: 2/A50000C0 (file 0000000100000002000000A5) +CHECKPOINT LOCATION: 2/A5000028 +BACKUP METHOD: streamed +BACKUP FROM: master +START TIME: 2016-10-26 10:19:30 EDT +LABEL: pg_basebackup base backup +STOP TIME: 2016-10-26 10:19:30 EDT +TOTAL DURATION: 0 sec(s) +``` + +The following code sample displays an error message if the `backupinfo` file is missing when invoking a BART subcommand: + +```text +-bash-4.2$ bart SHOW-BACKUPS +ERROR: 'backupinfo' file does not exist for backup '1477491569966' +please use 'INIT -r' to generate the file +``` + +The `backupinfo` file may be missing if the `BACKUP` subcommand did not complete successfully. + +The following code sample displays information about rebuilding the `backupinfo` file of the specified backup for database server `acctg`: + +```text +-bash-4.1$ bart INIT -s acctg -r -i 1428346620427 +INFO: rebuilding BACKUPINFO for backup '1428346620427' of server 'acctg' +INFO: backup checksum: ced59b72a7846ff8fb8afb6922c70649 of base.tar +``` + +The following code sample displays information about how the `backupinfo` files of all backups are rebuilt for all database servers: + +```text +-bash-4.1$ bart INIT -r + +INFO: rebuilding BACKUPINFO for backup '1428347191544' of server 'acctg' +INFO: backup checksum: 1ac5c61f055c910db314783212f2544f of base.tar +INFO: rebuilding BACKUPINFO for backup '1428346620427' of server 'acctg' +INFO: backup checksum: ced59b72a7846ff8fb8afb6922c70649 of base.tar +INFO: rebuilding BACKUPINFO for backup '1428347198335' of server 'dev' +INFO: backup checksum: a8890dd8ab7e6be5d5bc0f38028a237b of base.tar +INFO: rebuilding BACKUPINFO for backup '1428346957515' of server 'dev' +INFO: backup checksum: ea62549cf090573625d4adeb7d919700 of base.tar +``` + +The following code sample displays information about invoking `BART INIT` with the `-r - i` option: + +```text +edb@localhost bin]$ ./bart init -s ppas11 -i 1551778898392 -r +INFO: rebuilding BACKUPINFO for backup '1551778898392' of server +'ppas11' +[edb@localhost bin]$ ls /home/edb/bkup/ppas11/1551778898392/ +backupinfo backup_label base base-1.tar base-2.tar base-3.tar +base-4.tar base-5.tar base.tar +``` + +The following code sample displays information about invoking the `BART INIT` command with the `--no-configure` option. You can use the `--no-configure` option with the `INIT` subcommand to prevent the `archive_command` option from being set in the PostgreSQL server. + +```text +[edb@localhost bin]$ ./bart init -s ppas11 -o --no-configure +[edb@localhost bin]$ +# Do not edit this file manually! +# It will be overwritten by the ALTER SYSTEM command. +``` diff --git a/product_docs/docs/bart/2.5/bart_ref/01_bart_subcommands_examples/05_manage.mdx b/product_docs/docs/bart/2.5/bart_ref/01_bart_subcommands_examples/05_manage.mdx new file mode 100644 index 00000000000..467ff8b393c --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_ref/01_bart_subcommands_examples/05_manage.mdx @@ -0,0 +1,228 @@ +--- +title: "MANAGE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/manage.html" +--- + +The `MANAGE` subcommand can be invoked to: + +- Evaluate backups, mark their status, and delete obsolete backups based on the `retention_policy` parameter in the BART configuration file. +- Compress the archived WAL files based on the `wal_compression` parameter in the BART configuration file. + +**Syntax:** + +```text +bart MANAGE [ –s { | all} ] +[ -l ] [ -d ] +[ -c { keep | nokeep } +-i { | | all } ] +[ -n ] +``` + +To view detailed information about the `MANAGE` subcommand and retention policy management, see *the EDB Backup and Recovery User Guide*. For information about setting the `wal_compression` parameter, see the *EDB Backup and Recovery Installation and Upgrade Guide*. These guides are available at the [EDB website](/bart/2.5/bart_user/). + +The following table describes the `MANAGE` options: + +| Options | Description | +| ---------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `-s [ \| all ]`
`--server [ \| all ]` | `` is the name of the database server to which the `MANAGE` actions are to be applied.
If `all` is specified or if the `-s` option is omitted, actions are applied to all database servers. | +| `-l`
`--list-obsolete` | Lists the backups marked as obsolete. | +| `-d`
`--delete-obsolete` | Deletes the backups marked as obsolete. This action physically deletes the backup along with its archived WAL files and any MBM files for incremental backups. | +| `-c { keep \| nokeep }`
`--change-status { keep \| nokeep }` | Specify `keep` to change the backup status to `keep` to retain the backup indefinitely.

Specify `nokeep` to change the backup status back to `active`. You can then re-evaluate and possibly mark the backup as `obsolete` (according to the retention policy) using the `MANAGE` subcommand.

The `-c` option can only be used with the `-i` option. | +| `-i { \| \| all` }

`--backupid { \| \| all` } | `` is a backup identifier and `` is the user-defined alphanumeric name for the backup.
If `all` is specified, actions are applied to all backups.
The `-i` option can only be used with the `-c` option. | +| `-n`
`--dry-run` | Performs the test run and displays the results prior to actually implementing the actions as if the operation was performed, however, no changes are actually made.
If you specify `-n` with the `-d` option, it displays which backups would be deleted, but does not actually delete the backups.
If you specify `-n` with the `-c` option, it displays the keep or nokeep action, but does not actually change the backup status.
If you specify `-n` alone with no other options or if you specify `-n` with only the `-s` option, it displays which active backups would be marked as obsolete, but does not actually change the backup status. In addition, no compression is performed on uncompressed, archived WAL files even if WAL compression is enabled for the database server. | + +**Example** + +The following code sample performs a dry run for the specified database server displaying which active backups are evaluated as obsolete according to the retention policy, but does not actually change the backup status: + +```text +-bash-4.2$ bart MANAGE -s acctg -n +INFO: processing server 'acctg', backup '1482770807519' +INFO: processing server 'acctg', backup '1482770803000' +INFO: marking backup '1482770803000' as obsolete +INFO: 1 WAL file(s) marked obsolete +INFO: processing server 'acctg', backup '1482770735155' +INFO: marking backup '1482770735155' as obsolete +INFO: 2 incremental(s) of backup '1482770735155' will be marked obsolete +INFO: marking incremental backup '1482770780423' as obsolete +INFO: marking incremental backup '1482770763227' as obsolete +INFO: 3 WAL file(s) marked obsolete +INFO: 1 Unused WAL file(s) present +INFO: 2 Unused file(s) (WALs included) present, use 'MANAGE -l' for the +list +``` + +The following code sample marks active backups as obsolete according to the retention policy for the specified database server: + +```text +-bash-4.2$ bart MANAGE -s acctg +INFO: processing server 'acctg', backup '1482770807519' +INFO: processing server 'acctg', backup '1482770803000' +INFO: marking backup '1482770803000' as obsolete +INFO: 1 WAL file(s) marked obsolete +INFO: processing server 'acctg', backup '1482770735155' +INFO: marking backup '1482770735155' as obsolete +INFO: 2 incremental(s) of backup '1482770735155' will be marked obsolete +INFO: marking incremental backup '1482770780423' as obsolete +INFO: marking incremental backup '1482770763227' as obsolete +INFO: 3 WAL file(s) marked obsolete +INFO: 1 Unused WAL file(s) present +INFO: 2 Unused file(s) (WALs included) present, use 'MANAGE -l' for the +list +``` + +The following code sample lists backups marked as obsolete for the specified database server: + +```text +-bash-4.2$ bart MANAGE -s acctg -l +SERVER NAME: acctg +BACKUP ID: 1482770803000 +BACKUP STATUS: obsolete +BACKUP TIME: 2016-12-26 11:46:43 EST +BACKUP SIZE: 59.52 MB +WAL FILE(s): 1 +WAL FILE: 000000010000000100000055 +SERVER NAME: acctg +BACKUP ID: 1482770735155 +BACKUP STATUS: obsolete +BACKUP TIME: 2016-12-26 11:45:35 EST +BACKUP SIZE: 59.52 MB +INCREMENTAL BACKUP(s): 2 +BACKUP ID: 1482770780423 +BACKUP PARENT: 1482770735155 +BACKUP STATUS: obsolete +BACKUP TIME: 2016-12-26 11:45:35 EST +BACKUP SIZE: 59.52 MB +BACKUP ID: 1482770763227 +BACKUP PARENT: 1482770735155 +BACKUP STATUS: obsolete +BACKUP TIME: 2016-12-26 11:45:35 EST +BACKUP SIZE: 59.52 MB +WAL FILE(s): 3 +WAL FILE: 000000010000000100000054 +WAL FILE: 000000010000000100000053 +WAL FILE: 000000010000000100000052 +UNUSED FILE(s): 2 +UNUSED FILE: 000000010000000100000051 +UNUSED FILE: 0000000100000001510000280000000152000000.mbm +``` + +The following code sample deletes the obsolete backups for the specified database server: + +```text +-bash-4.2$ bart MANAGE -s acctg -d +INFO: removing all obsolete backups of server 'acctg' +INFO: removing obsolete backup '1482770803000' +INFO: 1 WAL file(s) will be removed +INFO: removing WAL file '000000010000000100000055' +INFO: removing obsolete backup '1482770735155' +INFO: 3 WAL file(s) will be removed +INFO: 2 incremental(s) of backup '1482770735155' will be removed +INFO: removing obsolete incremental backup '1482770780423' +INFO: removing obsolete incremental backup '1482770763227' +INFO: removing WAL file '000000010000000100000054' +INFO: removing WAL file '000000010000000100000053' +INFO: removing WAL file '000000010000000100000052' +INFO: 8 Unused file(s) will be removed +INFO: removing (unused) file '000000010000000100000056.00000028.backup' +INFO: removing (unused) file '000000010000000100000056' +INFO: removing (unused) file '000000010000000100000055.00000028.backup' +INFO: removing (unused) file '000000010000000100000054.00000028.backup' +INFO: removing (unused) file '000000010000000100000053.00000028.backup' +INFO: removing (unused) file '000000010000000100000052.00000028.backup' +INFO: removing (unused) file '000000010000000100000051' +INFO: removing (unused) file +'0000000100000001510000280000000152000000.mbm' +``` + +The following code sample changes the specified backup to keep status to retain it indefinitely: + +```text +-bash-4.2$ bart MANAGE -s acctg -c keep -i 1482770807519 +INFO: changing status of backup '1482770807519' of server 'acctg' from +'active' to 'keep' +INFO: 1 WAL file(s) changed +-bash-4.2$ bart SHOW-BACKUPS -s acctg -i 1482770807519 -t +SERVER NAME : acctg +BACKUP ID : 1482770807519 +BACKUP NAME : none +BACKUP PARENT : none +BACKUP STATUS : keep +BACKUP TIME : 2016-12-26 11:46:47 EST +BACKUP SIZE : 59.52 MB +WAL(S) SIZE : 16.00 MB +NO. OF WALS : 1 +FIRST WAL FILE : 000000010000000100000057 +CREATION TIME : 2016-12-26 11:52:47 EST +LAST WAL FILE : 000000010000000100000057 +CREATION TIME : 2016-12-26 11:52:47 EST +``` + +The following code sample resets the specified backup to active status: + +```text +-bash-4.2$ bart MANAGE -s acctg -c nokeep -i 1482770807519 +INFO: changing status of backup '1482770807519' of server 'acctg' from +'keep' to 'active' +INFO: 1 WAL file(s) changed +-bash-4.2$ bart SHOW-BACKUPS -s acctg -i 1482770807519 -t +SERVER NAME : acctg +BACKUP ID : 1482770807519 +BACKUP NAME : none +BACKUP PARENT : none +BACKUP STATUS : active +BACKUP TIME : 2016-12-26 11:46:47 EST +BACKUP SIZE : 59.52 MB +WAL(S) SIZE : 16.00 MB +NO. OF WALS : 1 +FIRST WAL FILE : 000000010000000100000057 +CREATION TIME : 2016-12-26 11:52:47 EST +LAST WAL FILE : 000000010000000100000057 +CREATION TIME : 2016-12-26 11:52:47 EST +``` + +The following code sample uses the enabled `wal_compression` parameter in the BART configuration file as shown by the following: + +```text +[ACCTG] + +host = 127.0.0.1 +port = 5445 +user = enterprisedb +cluster_owner = enterprisedb +allow_incremental_backups = disabled +wal_compression = enabled +description = "Accounting" +``` + +When the `MANAGE` subcommand is invoked, the following message is displayed indicating that WAL file compression is performed: + +```text +-bash-4.2$ bart MANAGE -s acctg +INFO: 4 WAL file(s) compressed +WARNING: 'retention_policy' is not set for server 'acctg' +``` + +The following code sample shows the archived WAL files in compressed format: + +```text +-bash-4.2$ pwd +/opt/backup/acctg +-bash-4.2$ ls -l archived_wals +total 160 +-rw------- 1 enterprisedb enterprisedb 27089 Dec 26 12:16 +00000001000000010000005B.gz +-rw------- 1 enterprisedb enterprisedb 305 Dec 26 12:17 +00000001000000010000005C.00000028.backup +-rw------- 1 enterprisedb enterprisedb 27112 Dec 26 12:17 +00000001000000010000005C.gz +-rw------- 1 enterprisedb enterprisedb 65995 Dec 26 12:18 +00000001000000010000005D.gz +-rw------- 1 enterprisedb enterprisedb 305 Dec 26 12:18 +00000001000000010000005E.00000028.backup +-rw------- 1 enterprisedb enterprisedb 27117 Dec 26 12:18 +00000001000000010000005E.gz +``` diff --git a/product_docs/docs/bart/2.5/bart_ref/01_bart_subcommands_examples/06_restore.mdx b/product_docs/docs/bart/2.5/bart_ref/01_bart_subcommands_examples/06_restore.mdx new file mode 100644 index 00000000000..e93ca1fb605 --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_ref/01_bart_subcommands_examples/06_restore.mdx @@ -0,0 +1,158 @@ +--- +title: "RESTORE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/restore.html" +--- + +The `RESTORE` subcommand restores a backup and its archived WAL files for the designated database server to the specified directory location. + +**Syntax for Restore**: + +```text +bart RESTORE –s -p +[ –i { | } ] +[ -r @ ] +[ -w ] +[ -t ] +[ { -x | -g } ] +[ -c ] +``` + +To view detailed information about the `RESTORE` subcommand, see the *EDB Backup and Recovery User Guide* available at the [EDB website](/bart/2.5/bart_user/). + +If the backup is restored to a different database cluster directory than where the original database cluster resided, then some operations dependent upon the database cluster location may fail. This happens if the supporting service scripts are not updated to reflect the new directory location of restored backup. + +For information about the use and modification of service scripts, see the EDB Advanced Server Installation Guide. + +The following table describes the `RESTORE` options: + +| Options | Description | +| --------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s `
`--server ` | `` is the name of the database server to be restored. | +| `-p --restore-path `
`--restore-path ` | `` is the directory path where the backup of the database server is to be restored. The directory must be empty and have the proper ownership and privileges assigned to it. | +| `-i { \| }`

`--backupid { \| }` | `backup_id` is the backup identifier of the backup to be used for the restoration and `` is the user-defined alphanumeric name for the backup.
If the option is omitted, the latest backup is restored by default. | +| `-r `

`--remote-host ` | `` is the user account on the remote database server host that accepts a passwordless SSH/SCP login connection and is the owner of the directory where the backup is to be restored.
`` is the IP address of the remote host to which the backup is to be restored. This option must be specified if the `remote_host` parameter for this database server is not set in the BART configuration file.
For information about the `remote_host` parameter, see the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/2.5/bart_inst/). | +| `-w `
`--workers ` | `` is the number of worker processes to run in parallel to stream the modified blocks of an incremental backup to the restore location. If the `-w` option is omitted, the default is `1` worker process.
For example, if four worker processes are specified, four receiver processes on the restore host and four streamer processes on the BART host are used. The output of each streamer process is connected to the input of a receiver process.
When the receiver gets to the point where it needs a modified block file, it obtains those modified blocks from its input. With this method, the modified block files are never written to the restore host disk. | +| `-t `
`--target-tli ` | `` is the integer identifier of the timeline to be used for replaying the archived WAL files for point-in-time recovery. | +| `-x `
`--target-xid ` | `` is the integer identifier of the transaction ID that determines the transaction up to and including, which point-in-time recovery encompasses. | +| `-g `

`--target-timestamp ` | `` is the timestamp that determines the point in time up to and including, which point-in-time recovery encompasses. | +| `-c`

`--copy-wals` | Specify this option to copy archived WAL files from the BART backup catalog to `/archived_wals` directory.
The `restore_command` retrieves the WAL files from `/archived_wals` for the database server archive recovery.
If the `-c` option is omitted and the `copy_wals_during_restore` parameter in the BART configuration file is not enabled in a manner applicable to this database server, then the `restore_command` in the `postgresql.conf` retrieves the archived WAL files directly from the BART backup catalog.
For information about the `copy_wals_during_restore` parameter, see the EDB Backup and Recovery Installation and Upgrade Guide available at the [EDB website](/bart/2.5/bart_inst/). | + +**Examples** + +The following code sample restores a database server(named `mktg`) to the `/opt/restore` directory up to timestamp `2015-12-15 10:47:00`: + +```text +-bash-4.1$ bart RESTORE -s mktg -i 1450194208824 -p /opt/restore -t 1 -g +'2015-12-15 10:47:00' +INFO: restoring backup '1450194208824' of server 'mktg' +INFO: restoring backup to enterprisedb@192.168.2.24:/opt/restore +INFO: base backup restored +INFO: WAL file(s) will be streamed from the BART host +INFO: writing recovery settings to postgresql.auto.conf file +INFO: archiving is disabled +INFO: tablespace(s) restored +``` + +The following parameters are set in the `postgresql.auto.conf` file: + +```text +restore_command = 'scp -o BatchMode=yes -o PasswordAuthentication=no +enterprisedb@192.168.2.22:/opt/backup/mktg/archived_wals/%f %p' +recovery_target_time = '2015-12-15 10:47:00' +recovery_target_timeline = 1 +``` + +The following is a list of the restored files and subdirectories: + +```text +[root@localhost restore]# pwd +/opt/restore +[root@localhost restore]# ls -l +total 108 +-rw------- 1 enterprisedb enterprisedb 208 Dec 15 10:43 backup_label +drwx------ 6 enterprisedb enterprisedb 4096 Dec 2 10:38 base +drwx------ 2 enterprisedb enterprisedb 4096 Dec 15 10:42 dbms_pipe +drwx------ 2 enterprisedb enterprisedb 4096 Dec 15 11:00 global +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_clog\ +-rw------- 1 enterprisedb enterprisedb 4438 Dec 2 10:38 pg_hba.conf +-rw------- 1 enterprisedb enterprisedb 1636 Nov 10 15:38 pg_ident.conf +drwxr-xr-x 2 enterprisedb enterprisedb 4096 Dec 15 10:42 pg_log +drwx------ 4 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_multixact +drwx------ 2 enterprisedb enterprisedb 4096 Dec 15 10:42 pg_notify +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_serial +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_snapshots +drwx------ 2 enterprisedb enterprisedb 4096 Dec 15 10:42 pg_stat +drwx------ 2 enterprisedb enterprisedb 4096 Dec 15 10:43 pg_stat_tmp +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_subtrans +drwx------ 2 enterprisedb enterprisedb 4096 Dec 15 11:00 pg_tblspc +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_twophase +-rw------- 1 enterprisedb enterprisedb 4 Nov 10 15:38 PG_VERSION +drwx------ 2 enterprisedb enterprisedb 4096 Dec 15 11:00 pg_xlog +-rw------- 1 enterprisedb enterprisedb 23906 Dec 15 11:00 +postgresql.conf +-rw-r--r-- 1 enterprisedb enterprisedb 217 Dec 15 11:00 +postgresql.auto.conf +``` + +**Example** + +The following code sample performs a `RESTORE` operation with the `copy_wals_during_restore` parameter enabled to copy the archived WAL files to the local `/archived_wals` directory: + +```text +-bash-4.1$ bart RESTORE -s hr -i hr_2017-03-29T13:50 -p +/opt/restore_pg96 -t 1 -g '2017-03-29 14:01:00' +INFO: restoring backup 'hr_2017-03-29T13:50' of server 'hr' +INFO: base backup restored +INFO: copying WAL file(s) to +postgres@192.168.2.24:/opt/restore_pg96/archived_wals +INFO: writing recovery settings to postgresql.auto.conf file +INFO: archiving is disabled +INFO: permissions set on $PGDATA +INFO: restore completed successfully +``` + +The following parameters are set in the `postgresql.auto.conf` file: + +```text +restore_command = 'cp archived_wals/%f %p' +recovery_target_time = '2017-03-29 14:01:00' +recovery_target_timeline = 1 +``` + +The following is a list of the restored files and subdirectories: + +```text +-bash-4.1$ pwd +/opt/restore_pg96 +-bash-4.1$ ls -l +total 128 +drwxr-xr-x 2 postgres postgres 4096 Mar 29 14:27 archived_wals +-rw------- 1 postgres postgres 206 Mar 29 13:50 backup_label +drwx------ 5 postgres postgres 4096 Mar 29 12:25 base +drwx------ 2 postgres postgres 4096 Mar 29 14:27 global +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_clog +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_commit_ts +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_dynshmem +-rw------- 1 postgres postgres 4212 Mar 29 13:18 pg_hba.conf +-rw------- 1 postgres postgres 1636 Mar 29 12:25 pg_ident.conf +drwxr-xr-x 2 postgres postgres 4096 Mar 29 13:45 pg_log +drwx------ 4 postgres postgres 4096 Mar 29 12:25 pg_logical +drwx------ 4 postgres postgres 4096 Mar 29 12:25 pg_multixact +drwx------ 2 postgres postgres 4096 Mar 29 13:43 pg_notify +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_replslot +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_serial +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_snapshots +drwx------ 2 postgres postgres 4096 Mar 29 13:43 pg_stat +drwx------ 2 postgres postgres 4096 Mar 29 13:50 pg_stat_tmp +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_subtrans +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_tblspc +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_twophase +-rw------- 1 postgres postgres 4 Mar 29 12:25 PG_VERSION +drwx------ 3 postgres postgres 4096 Mar 29 14:27 pg_xlog +-rw------- 1 postgres postgres 169 Mar 29 13:24 postgresql.auto.conf +-rw-r--r-- 1 postgres postgres 21458 Mar 29 14:27 postgresql.conf +-rw-r--r-- 1 postgres postgres 118 Mar 29 14:27 postgresql.auto.conf +``` \ No newline at end of file diff --git a/product_docs/docs/bart/2.5/bart_ref/01_bart_subcommands_examples/07_show_servers.mdx b/product_docs/docs/bart/2.5/bart_ref/01_bart_subcommands_examples/07_show_servers.mdx new file mode 100644 index 00000000000..8ada69b5622 --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_ref/01_bart_subcommands_examples/07_show_servers.mdx @@ -0,0 +1,77 @@ +--- +title: "SHOW-SERVERS" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/show_servers.html" +--- + +The `SHOW-SERVERS` subcommand displays information for the managed database servers listed in the BART configuration file. + +**Syntax:** + +```text +bart SHOW-SERVERS [ –s { | all } ] +``` + +The following table describes the `SHOW-SERVERS` option: + +| Option | Description | +| ---------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { \| all` }
`--server { \| all` } | `` is the name of the database server to which the `SHOW-SERVERS` actions are to be applied.
If `all` is specified or if the `-s` option is omitted, the actions are applied to all database servers. | + +**Example** + +The following code sample shows all the database servers managed by BART as returned by the `SHOW-SERVERS` subcommand: + +```text +-bash-4.2$ bart SHOW-SERVERS +SERVER NAME : acctg +BACKUP FRIENDLY NAME: acctg_%year-%month-%dayT%hour:%minute +HOST NAME : 127.0.0.1 +USER NAME : enterprisedb +PORT : 5444 +REMOTE HOST : +RETENTION POLICY : 6 Backups +DISK UTILIZATION : 0.00 bytes +NUMBER OF ARCHIVES : 0 +ARCHIVE PATH : /opt/backup/acctg/archived_wals +ARCHIVE COMMAND : (disabled) +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +INCREMENTAL BACKUP : DISABLED +DESCRIPTION : "Accounting" +SERVER NAME : hr +BACKUP FRIENDLY NAME: hr_%year-%month-%dayT%hour:%minute +HOST NAME : 192.168.2.24 +USER NAME : postgres +PORT : 5432 +REMOTE HOST : postgres@192.168.2.24 +RETENTION POLICY : 6 Backups +DISK UTILIZATION : 0.00 bytes +NUMBER OF ARCHIVES : 0 +ARCHIVE PATH : /opt/backup/hr/archived_wals +ARCHIVE COMMAND : (disabled) +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +INCREMENTAL BACKUP : DISABLED +DESCRIPTION : "Human Resources" +SERVER NAME : mktg +BACKUP FRIENDLY NAME: mktg_%year-%month-%dayT%hour:%minute +HOST NAME : 192.168.2.24 +USER NAME : repuser +PORT : 5444 +REMOTE HOST : enterprisedb@192.168.2.24 +RETENTION POLICY : 6 Backups +DISK UTILIZATION : 0.00 bytes +NUMBER OF ARCHIVES : 0 +ARCHIVE PATH : /opt/backup/mktg/archived_wals +ARCHIVE COMMAND : (disabled) +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +INCREMENTAL BACKUP : DISABLED\ +DESCRIPTION : "Marketing" +``` diff --git a/product_docs/docs/bart/2.5/bart_ref/01_bart_subcommands_examples/08_show_backups.mdx b/product_docs/docs/bart/2.5/bart_ref/01_bart_subcommands_examples/08_show_backups.mdx new file mode 100644 index 00000000000..03b7727add3 --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_ref/01_bart_subcommands_examples/08_show_backups.mdx @@ -0,0 +1,100 @@ +--- +title: "SHOW-BACKUPS" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/show_backups.html" +--- + +The `SHOW-BACKUPS` subcommand displays the backup information for the managed database servers. + +**Syntax:** + +```text +bart SHOW-BACKUPS [ –s { | all } ] +[ -i { | | all } ] +[ -t ] +``` + +The following table describes the `SHOW-BACKUPS` options: + +| Options | Description | +| ------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { \| all` }

`--server { \| all` } | `` is the name of the database server whose backup information is to be displayed.
If `all` is specified or if the option is omitted, the backup information for all database servers is displayed. | +| `-i { \| \| all }`

`--backupid { \| \| all }` | `` is a backup identifier and `` is the user-defined alphanumeric name for the backup.
If `all` is specified or if the option is omitted, all backup information for the relevant database server is displayed. | +| `-t`
`--toggle` | Displays detailed backup information in list format. If the option is omitted, the default is a tabular format. | + +**Example** + +The following code sample shows the backup from database server `dev`: + +```text +-bash-4.2$ bart SHOW-BACKUPS -s dev +SERVER NAME BACKUP ID BACKUP NAME BACKUP PARENT +BACKUP TIME BACKUP SIZE WAL(s) SIZE WAL FILES STATUS +dev 1477579596637 dev_2016-10-27T10:46:36 none +2016-10-27 10:46:37 EDT 54.50 MB 96.00 MB 6 active +``` + +The following code sample shows detailed information using the `-t` option: + +```text +-bash-4.2$ bart SHOW-BACKUPS -s dev -i 1477579596637 -t +SERVER NAME : dev +BACKUP ID : 1477579596637 +BACKUP NAME : dev_2016-10-27T10:46:36 +BACKUP PARENT : none +BACKUP STATUS : active +BACKUP TIME : 2016-10-27 10:46:37 EDT +BACKUP SIZE : 54.50 MB +WAL(S) SIZE : 80.00 MB +NO. OF WALS : 5 +FIRST WAL FILE : 0000000100000001000000EC +CREATION TIME : 2016-10-27 10:46:37 EDT +LAST WAL FILE : 0000000100000001000000F0 +CREATION TIME : 2016-10-27 11:22:01 EDT +``` + +The following code sample shows a listing of an incremental backup along with its parent backup: + +```text +-bash-4.2$ bart SHOW-BACKUPS +SERVER NAME BACKUP ID BACKUP NAME BACKUP PARENT +BACKUP TIME BACKUP SIZE WAL(s) SIZE WAL FILES STATUS +acctg 1477580293193 acctg_2016-10-27 none +2016-10-27 10:58:13 EDT 16.45 MB 16.00 MB 1 active +acctg 1477580111358 acctg_2016-10-27 none 2016-10-27 10:55:11 EDT 59.71 +MB 16.00 MB 1 active +``` + +The following code sample shows the complete, detailed information of the incremental backup and the parent backup: + +```text +-bash-4.2$ bart SHOW-BACKUPS -t +SERVER NAME : acctg +BACKUP ID : 1477580293193 +BACKUP NAME : none +BACKUP PARENT : acctg_2016-10-27 +BACKUP STATUS : active +BACKUP TIME : 2016-10-27 10:58:13 EDT +BACKUP SIZE : 16.45 MB +WAL(S) SIZE : 16.00 MB +NO. OF WALS : 1 +FIRST WAL FILE : 0000000100000002000000D9 +CREATION TIME : 2016-10-27 10:58:13 EDT +LAST WAL FILE : 0000000100000002000000D9 +CREATION TIME : 2016-10-27 10:58:13 EDT +SERVER NAME : acctg +BACKUP ID : 1477580111358 +BACKUP NAME : acctg_2016-10-27 +BACKUP PARENT : none +BACKUP STATUS : active +BACKUP TIME : 2016-10-27 10:55:11 EDT +BACKUP SIZE : 59.71 MB +WAL(S) SIZE : 16.00 MB +NO. OF WALS : 1 +FIRST WAL FILE : 0000000100000002000000D8 +CREATION TIME : 2016-10-27 10:55:12 EDT +LAST WAL FILE : 0000000100000002000000D8 +CREATION TIME : 2016-10-27 10:55:12 EDT +``` diff --git a/product_docs/docs/bart/2.5/bart_ref/01_bart_subcommands_examples/09_verify_chksum.mdx b/product_docs/docs/bart/2.5/bart_ref/01_bart_subcommands_examples/09_verify_chksum.mdx new file mode 100644 index 00000000000..973ae05dc7d --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_ref/01_bart_subcommands_examples/09_verify_chksum.mdx @@ -0,0 +1,41 @@ +--- +title: "VERIFY-CHKSUM" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/verify_chksum.html" +--- + +The `VERIFY-CHKSUM` subcommand verifies the MD5 checksums of the full backups and any user-defined tablespaces for the specified database server or for all database servers. The checksum is verified by comparing the current checksum of the backup against the checksum when the backup was taken. + +!!! Note + The `VERIFY-CHKSUM` subcommand is only used for tar format backups. + +**Syntax:** + +```text +bart VERIFY-CHKSUM +[ –s { | all } ] +[ -i { | | all } ] +``` + +The following table describes the `VERIFY-CHKSUM` options: + +| Options | Description | +| ---------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { \| all }`
`--server { \| all` } | `` is the name of the database server whose tar backup checksums are to be verified.
If `all` is specified or if the `-s` option is omitted, the checksums of all tar backups are verified for all database servers. | +| `-i { \| \| all` }

`--backupid { \| \| all` } | `` is the backup identifier of a tar format full backup whose checksum is to be verified along with any user-defined tablespaces. `` is the user-defined alphanumeric name for the full backup.
If `all` is specified or if the `-i` option is omitted, the checksums of all tar backups for the relevant database server are verified. | + +**Example** + +The following code sample verifies the checksum of all tar format backups of the specified database server: + +```text +-bash-4.1$ bart VERIFY-CHKSUM -s acctg -i all +SERVER NAME BACKUP ID VERIFY +acctg 1430239348243 OK +acctg 1430232284202 OK +acctg 1430232016284 OK +acctg 1430231949065 OK +acctg 1429821844271 OK +``` diff --git a/product_docs/docs/bart/2.5/bart_ref/01_bart_subcommands_examples/10_running_the_bart_wal_scanner.mdx b/product_docs/docs/bart/2.5/bart_ref/01_bart_subcommands_examples/10_running_the_bart_wal_scanner.mdx new file mode 100644 index 00000000000..cda813f49a8 --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_ref/01_bart_subcommands_examples/10_running_the_bart_wal_scanner.mdx @@ -0,0 +1,166 @@ +--- +title: "Running the BART WAL Scanner" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/running_the_bart_wal_scanner.html" +--- + +The BART WAL scanner is used to process each WAL file to find and record modified blocks in a corresponding MBM file. As a BART account user, use the BART WAL scanner to invoke the `bart-scanner` program located in the `/bin` directory. + +For detailed information about the WAL scanner and its usage, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/2.5/bart_user/). + +**Syntax:** + +```text +bart-scanner +[ -d ] +[ -c ] +{ –h | +-v | +--daemon | +-p | + | +RELOAD | +STOP +``` + +When the `bart-scanner` program is invoked, it forks a separate process for each database server enabled with the `allow_incremental_backups` parameter. + +The WAL scanner processes can run in either the foreground or background depending upon usage of the `--daemon` option: + +- If the `--daemon` option is specified, the WAL scanner process runs in the background. All output messages can be viewed in the BART log file. +- If the `--daemon` option is omitted, the WAL scanner process runs in the foreground. All output messages can be viewed from the terminal running the program as well as in the BART log file. + +The following table describes the `VERIFY-CHKSUM` options. + +| Options | Description | +| ---------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-h` `--help` | Displays general syntax and information on WAL scanner usage. | +| `-v` `--version` | Displays the WAL scanner version information. | +| `-d` `--debug` | Displays debugging output while executing the WAL scanner with any of its options. | +| `-c ` `--config-path ` | Specifies `` as the full directory path to a BART configuration file. Use this option if you do not want to use the default BART configuration file `/etc/bart.cfg` | +| `--daemon` | Runs the WAL scanner as a background process. | +| `-p ` `--print ` | Specifies the full directory path to an MBM file whose content is to be printed. The `archived_wals` directory as specified in the the `archive_path` parameter in the `bart.cfg` file contains the MBM files. | +| `` | Specifies the full directory path to a WAL file to be scanned. The archive path directory contains the WAL files. Use it if a WAL file in the archive path is missing its MBM file. This option is to be used for assisting the EnterpriseDB support team for debugging problems that may have been encountered. | +| `RELOAD` | Reloads the BART configuration file. The keyword `RELOAD` is case-insensitive. The `RELOAD` option is useful if you make changes to the configuration file after the WAL scanner has been started. It will reload the configuration file and adjust the WAL scanners accordingly. For example, if a server section allowing incremental backups is removed from the BART configuration file, then the process attached to that server will stop. Similarly, if a server allowing incremental backups is added, a new WAL scanner process will be launched to scan the WAL files of that server. | +| `STOP` | Stops the WAL scanner. The keyword `STOP` is not case-sensitive. | + +**Example** + +The following code sample demonstrates starting the WAL scanner to run interactively. The WAL scanner begins scanning existing WAL files in the archive path that have not yet been scanned (that is, there is no corresponding MBM file for the WAL file): + +```text +-bash-4.2$ bart-scanner +INFO: process created for server 'acctg', pid = 5287 +INFO: going to parse backlog of WALs, if any. +INFO: WAL file to be processed: 0000000100000000000000ED +INFO: WAL file to be processed: 0000000100000000000000EE +INFO: WAL file to be processed: 0000000100000000000000EF +INFO: WAL file to be processed: 0000000100000000000000F0 +INFO: WAL file to be processed: 0000000100000000000000F1 +``` + +The following code sample is the content of the archive path showing the MBM files created for the WAL files. (The user name and group name of the files have been removed from the example to list the WAL files and MBM files in a more readable manner): + +```text +[root@localhost archived_wals]# pwd +/opt/backup/acctg/archived_wals +[root@localhost archived_wals]# ls -l +total 81944 +-rw------- 1 ... ... 16777216 Dec 20 09:10 0000000100000000000000ED +-rw------- 1 ... ... 16777216 Dec 20 09:06 0000000100000000000000EE +-rw------- 1 ... ... 16777216 Dec 20 09:11 0000000100000000000000EF +-rw------- 1 ... ... 16777216 Dec 20 09:15 0000000100000000000000F0 +-rw------- 1 ... ... 16777216 Dec 20 09:16 0000000100000000000000F1 +-rw------- 1 ... ... 305 Dec 20 09:16 0000000100000000000000F1.00000028.backup +-rw-rw-r-- 1 ... ... 161 Dec 20 09:18 +0000000100000000ED00002800000000EE000000.mbm +-rw-rw-r-- 1 ... ... 161 Dec 20 09:18 +0000000100000000EE00002800000000EF000000.mbm +-rw-rw-r-- 1 ... ... 161 Dec 20 09:18 +0000000100000000EF00002800000000F0000000.mbm +-rw-rw-r-- 1 ... ... 161 Dec 20 09:18 +0000000100000000F000002800000000F1000000.mbm +-rw-rw-r-- 1 ... ... 161 Dec 20 09:18 +0000000100000000F100002800000000F2000000.mbm +``` + +To stop the interactively running WAL scanner, either enter `ctrl-C` at the terminal running the WAL scanner or invoke the `bart-scanner` program from another terminal with the `STOP` option: + +```text +-bash-4.2$ bart-scanner STOP +-bash-4.2$ +``` + +The terminal on which the WAL scanner was running interactively appears as follows after it has been stopped: + +```text +-bash-4.2$ bart-scanner +INFO: process created for server 'acctg', pid = 5287 +INFO: going to parse backlog of WALs, if any. +INFO: WAL file to be processed: 0000000100000000000000ED +INFO: WAL file to be processed: 0000000100000000000000EE +INFO: WAL file to be processed: 0000000100000000000000EF +INFO: WAL file to be processed: 0000000100000000000000F0 +INFO: WAL file to be processed: 0000000100000000000000F1 +INFO: bart-scanner stopped +-bash-4.2$ +``` + +The following code sample demonstrates invoking the WAL scanner to run as a background process with the `--daemon` option: + +```text +-bash-4.2$ bart-scanner --daemon +-bash-4.2$ +``` + +The WAL scanner runs as a background process. There is also a separate background process for each database server that has been enabled for WAL scanning with the `allow_incremental_backups` parameter in the BART configuration file: + +```text +-bash-4.2$ ps -ef | grep bart + enterpr+ 4340 1 0 09:48 ? 00:00:00 bart-scanner --daemon + enterpr+ 4341 4340 0 09:48 ? 00:00:00 bart-scanner --daemon + enterpr+ 4415 3673 0 09:50 pts/0 00:00:00 grep --color=auto bart +``` + +To stop the WAL scanner processes, invoke the WAL scanner with the `STOP` option: + +```text +-bash-4.2$ bart-scanner STOP +-bash-4.2$ +``` + +The following command demonstrates scanning an individual WAL file: + +```text +-bash-4.2$ bart-scanner /opt/backup/acctg/archived_wals/0000000100000000000000FF +-bash-4.2$ +``` + +To print the content of an MBM file for assisting the EnterpriseDB support team for debugging problems that may have been encountered, use the `-p` option to specify the file as shown in the following code sample: + +```text +-bash-4.2$ bart-scanner -p +/opt/backup/acctg/archived_wals/0000000100000000FF0000280000000100000000.mbm + +Header: +Version: 1.0:90500:1.2.0 +Scan Start: 2016-12-20 10:02:11 EST, Scan End: 2016-12-20 10:02:11 EST, Diff: 0 sec(s) +Start LSN: ff000028, End LSN: 100000000, TLI: 1 +flags: 0, Check Sum: f9cfe66ae2569894d6746b61503a767d + +Path: base/14845/16384 +NodeTag: BLOCK_CHANGE +Relation: relPath base/14845/16384, isTSNode 0, Blocks +*............................................................................. +First modified block: 0 +Total modified blocks: 1 + +Path: base/14845/16391 +NodeTag: BLOCK_CHANGE +Relation: relPath base/14845/16391, isTSNode 0, Blocks +*.............................................................................. +First modified block: 0 +Total modified blocks: 1 +``` diff --git a/product_docs/docs/bart/2.5/bart_ref/01_bart_subcommands_examples/index.mdx b/product_docs/docs/bart/2.5/bart_ref/01_bart_subcommands_examples/index.mdx new file mode 100644 index 00000000000..20c71192ef2 --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_ref/01_bart_subcommands_examples/index.mdx @@ -0,0 +1,115 @@ +--- +title: "BART Subcommand Syntax and Examples" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/bart_subcommands_examples.html" +--- + + + +This section briefly describes each BART subcommand and provides an example. + +**Invoking BART** + +BART subcommands are invoked at the Linux command line as a BART user. You can invoke the `bart` program (located in the `/bin` directory) with the desired options to manage your BART installation. + +The following examples demonstrate ways of invoking BART. In these examples, the BART user account is named `bartuser`. + +```text +$ su bartuser +Password: +$ export +LD_LIBRARY_PATH=/opt/PostgresPlus/9.6AS/lib/:$LD_LIBRARY_PATH +$ ./bart SHOW-SERVERS +``` + +To run BART from any current working directory: + +```text +$ su bartuser +Password: +$ export +LD_LIBRARY_PATH=/opt/PostgresPlus/9.6AS/lib/:$LD_LIBRARY_PATH +$ bart SHOW-SERVERS +``` + +**Syntax for invoking BART** + +```text +bart [ ]... [ ] []... +``` + +You can use either abbreviated or long option forms on the command line (for example `-h` or `--help`). + +**General Options** + +You can specify the following general options with `bart`. + +`-h` or (`--help`) + +- Displays general syntax and information about BART usage. +- All subcommands support a help option (`-h, --help`). If the help option is specified, information is displayed regarding that particular subcommand. The subcommand, itself, is not executed. + +The following code sample displays the result of invoking the `--help` option for the `BACKUP` subcommand: + +```text +-bash-4.2$ bart BACKUP --help +bart: backup and recovery tool + +Usage: +bart BACKUP [OPTION]... + +Options: +-h, --help Show this help message and exit +-s, --server Name of the server or 'all' (full backups only) to specify all servers +-F, --format=p|t Backup output format (tar (default) or plain) +-z, --gzip Enables gzip compression of tar files +-c, --compress-level Specifies the compression level (1 through 9, 9 being + best compression) +--backup-name Specify a friendly name for the current backup +--parent Specify parent backup for incremental backup +--check Verify checksum of required mbm files +``` + +`-v` (or `--version`) + +The following code sample displays information returned by the `bart --version` subcommand: + +```text +[edb@localhost bin]$ bart --version +bart (EnterpriseDB) 2.5.2 +[edb@localhost bin]$ +``` + +`-d` (or `--debug`) + +The following code sample displays debugging output returned by the `bart MANAGE` subcommand: + +```text +-bash-4.1$ bart -d MANAGE -n +DEBUG: Server: acctg, Now: 2015-04-17 16:34:03 EDT, RetentionWindow: +259200 (secs) ==> 72 hour(s) +DEBUG: Server: dev, Now: 2015-04-17 16:34:03 EDT, RetentionWindow: +1814400 (secs) ==> 504 hour(s) +DEBUG: Server: hr, Now: 2015-04-17 16:34:03 EDT, RetentionWindow: +7776000 (secs) ==> 2160 hour(s) +``` + +`-c` (or `--config-path) ` + +The following code sample demonstrates using the `-c` option to specify a non-default configuration file name and installation location: + +```text +$ su bartuser +Password: +$ export +LD_LIBRARY_PATH=/opt/PostgresPlus/9.6AS/lib/:$LD_LIBRARY_PATH +$ bart -c /home/bartuser/bart.cfg SHOW-SERVERS +``` + +
+ +backup check_config delete init manage restore show_servers show_backups verify_chksum running_the_bart_wal_scanner + +
diff --git a/product_docs/docs/bart/2.5/bart_ref/02_additional_examples.mdx b/product_docs/docs/bart/2.5/bart_ref/02_additional_examples.mdx new file mode 100644 index 00000000000..faea13bbb52 --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_ref/02_additional_examples.mdx @@ -0,0 +1,1473 @@ +--- +title: "Additional Examples" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/additional_examples.html" +--- + + + +This section lists examples of the following BART operations. + +- Restoring a database cluster with tablespaces. +- Restoring an incremental backup. +- Managing backups. +- Managing incremental backups. + +## Restoring a Database Cluster with Tablespaces + +The following code sample illustrates taking a backup and restoring a database cluster on a remote host containing tablespaces. For detailed information regarding using tablespaces, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/2.5/bart_user/). + +On an Advanced Server database running on a remote host, the following tablespaces are created for use by two tables: + +```text +edb=# CREATE TABLESPACE tblspc_1 LOCATION '/mnt/tablespace_1'; +CREATE TABLESPACE +edb=# CREATE TABLESPACE tblspc_2 LOCATION '/mnt/tablespace_2'; +CREATE TABLESPACE +edb=# \db + List of tablespaces +Name | Owner | Location +------------+-----------------+------------------- +pg_default | enterprisedb | +pg_global | enterprisedb | +tblspc_1 | enterprisedb | /mnt/tablespace_1 +tblspc_2 | enterprisedb | /mnt/tablespace_2 +(4 rows) + +edb=# CREATE TABLE tbl_tblspc_1 (c1 TEXT) TABLESPACE tblspc_1; +CREATE TABLE +edb=# CREATE TABLE tbl_tblspc_2 (c1 TEXT) TABLESPACE tblspc_2; +CREATE TABLE +edb=# \d tbl_tblspc_1 +Table "enterprisedb.tbl_tblspc_1" +Column | Type | Modifiers +-------+------+----------- +c1 | text | +Tablespace: "tblspc_1" + +edb=# \d tbl_tblspc_2 +Table "enterprisedb.tbl_tblspc_2" +Column | Type | Modifiers +-------+------+----------- +c1 | text | +Tablespace: "tblspc_2" +``` + +The following code sample shows the OIDs assigned to the tablespaces and the symbolic links to the tablespace directories: + +```text +-bash-4.1$ pwd +/opt/PostgresPlus/9.6AS/data/pg_tblspc +-bash-4.1$ ls -l +total 0 +lrwxrwxrwx 1 enterprisedb enterprisedb 17 Nov 16 16:17 16587 ->/mnt/tablespace_1 +lrwxrwxrwx 1 enterprisedb enterprisedb 17 Nov 16 16:17 16588 ->/mnt/tablespace_2 +``` + +The BART configuration file contains the following settings. Note that the `tablespace_path` parameter does not have to be set at this point. + +```text +[BART] +bart_host= enterprisedb@192.168.2.22 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log + +[ACCTG] +host = 192.168.2.24 +port = 5444 +user = repuser +cluster_owner = enterprisedb +remote_host = enterprisedb@192.168.2.24 +tablespace_path = +description = "Accounting" +``` + +After the necessary configuration steps are performed to ensure BART manages the remote database server, a full backup is taken as shown in the following code sample: + +```text +-bash-4.1$ bart BACKUP -s acctg + +INFO: creating backup for server 'acctg' +INFO: backup identifier: '1447709811516' +54521/54521 kB (100%), 3/3 tablespaces + +INFO: backup completed successfully +INFO: backup checksum: 594f69fe7d26af991d4173d3823e174f of 16587.tar +INFO: backup checksum: 7a5507567729a21c98a15c948ff6c015 of base.tar +INFO: backup checksum: ae8c62604c409635c9d9e82b29cc0399 of 16588.tar +INFO: +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1447709811516 +BACKUP NAME: none +BACKUP LOCATION: /opt/backup/acctg/1447709811516 +BACKUP SIZE: 53.25 MB +BACKUP FORMAT: tar +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 3 +ChkSum File +594f69fe7d26af991d4173d3823e174f 16587.tar +7a5507567729a21c98a15c948ff6c015 base.tar +ae8c62604c409635c9d9e82b29cc0399 16588.tar + +TABLESPACE(s): 2 +Oid Name Location +16587 tblspc_1 /mnt/tablespace_1 +16588 tblspc_2 /mnt/tablespace_2 +START WAL LOCATION: 00000001000000000000000F +BACKUP METHOD: streamed +BACKUP FROM: master +START TIME: 2015-11-16 16:36:51 EST +STOP TIME: 2015-11-16 16:36:52 EST +TOTAL DURATION: 1 sec(s) +``` + +Note that in the output from the preceding example, checksums are generated for the tablespaces as well as the full backup. + +Within the backup subdirectory `1447709811516` of the BART backup catalog, the tablespace data is stored with file names `16587.tar.gz` and `16588.tar.gz` as shown below: + +```text +-bash-4.1$ pwd +/opt/backup/acctg +-bash-4.1$ ls -l +total 8 +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 16:36 1447709811516 +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 16:43 archived_wals +-bash-4.1$ ls -l 1447709811516 +total 54536 +-rw-rw-r-- 1 enterprisedb enterprisedb 19968 Nov 16 16:36 16587.tar +-rw-rw-r-- 1 enterprisedb enterprisedb 19968 Nov 16 16:36 16588.tar +-rw-rw-r-- 1 enterprisedb enterprisedb 949 Nov 16 17:05 backupinfo +-rw-rw-r-- 1 enterprisedb enterprisedb 55792640 Nov 16 16:36 base.tar +``` + +When you are ready to restore the backup, in addition to creating the directory to which the main database cluster is to be restored, you must prepare the directories to which the tablespaces are to be restored. + +On the remote host, directories `/opt/restore_tblspc_1` and `/opt/restore_tblspc_2` are created and assigned the proper ownership and permissions as shown by the following example. The main database cluster is to be restored to `/opt/restore`. + +```text +[root@localhost opt]# mkdir restore_tblspc_1 +[root@localhost opt]# chown enterprisedb restore_tblspc_1 +[root@localhost opt]# chgrp enterprisedb restore_tblspc_1 +[root@localhost opt]# chmod 700 restore_tblspc_1 + +[root@localhost opt]# mkdir restore_tblspc_2 +[root@localhost opt]# chown enterprisedb restore_tblspc_2 +[root@localhost opt]# chgrp enterprisedb restore_tblspc_2 +[root@localhost opt]# chmod 700 restore_tblspc_2 +[root@localhost opt]# ls -l +total 20 +drwxr-xr-x 3 root daemon 4096 Nov 10 15:38 PostgresPlus +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 17:40 restore +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 17:40 +restore_tblspc_1 +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 17:41 +restore_tblspc_2 +drwxr-xr-x. 2 root root 4096 Nov 22 2013 rh +``` + +Set the `tablespace_path` parameter in the BART configuration file to specify the tablespace directories. The remote host user and IP address are specified by the `remote_host` configuration parameter. + +```text +[ACCTG] + +host = 192.168.2.24 +port = 5444 +user = repuser +cluster_owner = enterprisedb +remote_host = enterprisedb@192.168.2.24 +tablespace_path = +16587=/opt/restore_tblspc_1;16588=/opt/restore_tblspc_2 + +description = "Accounting" +``` + +The following code sample demonstrates invoking the `RESTORE` subcommand: + +```text +-bash-4.1$ bart RESTORE -s acctg -i 1447709811516 -p /opt/restore +INFO: restoring backup '1447709811516' of server 'acctg' +INFO: restoring backup to enterprisedb@192.168.2.24:/opt/restore +INFO: base backup restored +INFO: archiving is disabled +INFO: tablespace(s) restored +``` + +The following code sample shows the restored full backup (including the restored tablespaces): + +```text +bash-4.1$ pwd +/opt +-bash-4.1$ ls -l restore +total 104 +-rw------- 1 enterprisedb enterprisedb 206 Nov 16 16:36 backup_label.old +drwx------ 6 enterprisedb enterprisedb 4096 Nov 10 15:38 base +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 17:46 global +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_clog +-rw------- 1 enterprisedb enterprisedb 4438 Nov 10 16:23 pg_hba.conf +-rw------- 1 enterprisedb enterprisedb 1636 Nov 10 15:38 pg_ident.conf +drwxr-xr-x 2 enterprisedb enterprisedb 4096 Nov 16 17:45 pg_log +drwx------ 4 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_multixact +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 17:45 pg_notify +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_serial +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_snapshots +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 17:47 pg_stat +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 17:47 pg_stat_tmp +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_subtrans +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 17:42 pg_tblspc +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_twophase +-rw------- 1 enterprisedb enterprisedb 4 Nov 10 15:38 PG_VERSION +drwx------ 3 enterprisedb enterprisedb 4096 Nov 16 17:47 pg_xlog +-rw------- 1 enterprisedb enterprisedb 23906 Nov 16 17:42 postgresql.conf +-rw------- 1 enterprisedb enterprisedb 61 Nov 16 17:45 postmaster.opts +-bash-4.1$ +-bash-4.1$ ls -l restore_tblspc_1 +total 4 +drwx------ 3 enterprisedb enterprisedb 4096 Nov 16 16:18 +PG_9.6_201306121 +-bash-4.1$ ls -l restore_tblspc_2 +total 4 +drwx------ 3 enterprisedb enterprisedb 4096 Nov 16 16:18 +PG_9.6_201306121 +``` + +The symbolic links in the `pg_tblspc` subdirectory point to the restored directory location: + +```text +bash-4.1$ pwd +/opt/restore/pg_tblspc +-bash-4.1$ ls -l +total 0 +lrwxrwxrwx 1 enterprisedb enterprisedb 21 Nov 16 17:42 16587 -> +/opt/restore_tblspc_1 +lrwxrwxrwx 1 enterprisedb enterprisedb 21 Nov 16 17:42 16588 -> +/opt/restore_tblspc_2 +``` + +`psql` queries also show the restored tablespaces: + +```text +edb=# \db + + List of tablespaces +Name | Owner | Location +------------+--------------+----------------------- +pg_default | enterprisedb | +pg_global | enterprisedb | +tblspc_1 | enterprisedb | /opt/restore_tblspc_1 +tblspc_2 | enterprisedb | /opt/restore_tblspc_2 +``` + +## Restoring an Incremental Backup + +Restoring an incremental backup may require additional setup steps depending upon the host on which the incremental backup is to be restored. For more information, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/2.5/bart_user/). + +This section provides an example of creating backup chains and then restoring an incremental backup. + +**Creating a Backup Chain** + +A *backup chain* is the set of backups consisting of a full backup and all of its successive incremental backups. Tracing back on the parent backups of all incremental backups in the chain eventually leads back to that single, full backup. + +In the following example, the `allow_incremental_backups` parameter is set to `enabled` in the BART configuration file to permit incremental backups on the listed database server: + +```text +[BART] + +bart_host= enterprisedb@192.168.2.27 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log + +[ACCTG] + +host = 127.0.0.1 +port = 5445 +user = enterprisedb +cluster_owner = enterprisedb +allow_incremental_backups = enabled +description = "Accounting" +``` + +After the database server has been started with WAL archiving enabled to the BART backup catalog, the WAL scanner is started: + +```text +-bash-4.2$ bart-scanner --daemon +``` + +First, a full backup is taken. + +```text +-bash-4.2$ bart BACKUP -s acctg --backup-name full_1 +INFO: creating backup for server 'acctg' +INFO: backup identifier: '1490649204327'\ +63364/63364 kB (100%), 1/1 tablespace +INFO: backup completed successfully +INFO: backup checksum: aae27d4a7c09dffc82f423221154db7e of base.tar +INFO: +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1490649204327 +BACKUP NAME: full_1 +BACKUP PARENT: none +BACKUP LOCATION: /opt/backup/acctg/1490649204327 +BACKUP SIZE: 61.88 MB +BACKUP FORMAT: tar +BACKUP TIMEZONE: US/Eastern +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 1 +ChkSum File +aae27d4a7c09dffc82f423221154db7e base.tar +TABLESPACE(s): 0 +START WAL LOCATION: 00000001000000000000000E +BACKUP METHOD: streamed +BACKUP FROM: master +START TIME: 2017-03-27 17:13:24 EDT +STOP TIME: 2017-03-27 17:13:25 EDT +TOTAL DURATION: 1 sec(s) +``` + +A series of incremental backups are taken. The first incremental backup specifies the full backup as the parent. Each successive incremental backup then uses the preceding incremental backup as its parent. + +```text +-bash-4.2$ bart BACKUP -s acctg -F p --parent full_1 --backup-name +incr_1-a +INFO: creating incremental backup for server 'acctg' +INFO: checking mbm files /opt/backup/acctg/archived_wals +INFO: new backup identifier generated 1490649255649 +INFO: reading directory /opt/backup/acctg/archived_wals +INFO: all files processed +NOTICE: pg_stop_backup complete, all required WAL segments have been +archived +INFO: incremental backup completed successfully +INFO: +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1490649255649 +BACKUP NAME: incr_1-a +BACKUP PARENT: 1490649204327 +BACKUP LOCATION: /opt/backup/acctg/1490649255649 +BACKUP SIZE: 16.56 MB +BACKUP FORMAT: plain +BACKUP TIMEZONE: US/Eastern +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 0 +TABLESPACE(s): 0 +START WAL LOCATION: 000000010000000000000010 +STOP WAL LOCATION: 000000010000000000000010 +BACKUP METHOD: pg_start_backup +BACKUP FROM: master +START TIME: 2017-03-27 17:14:15 EDT +STOP TIME: 2017-03-27 17:14:16 EDT +TOTAL DURATION: 1 sec(s) +-bash-4.2$ bart BACKUP -s acctg -F p --parent incr_1-a --backup-name +incr_1-b +INFO: creating incremental backup for server 'acctg' +INFO: checking mbm files /opt/backup/acctg/archived_wals +INFO: new backup identifier generated 1490649336845 +INFO: reading directory /opt/backup/acctg/archived_wals +INFO: all files processed +NOTICE: pg_stop_backup complete, all required WAL segments have been +archived +INFO: incremental backup completed successfully +. +. +. +-bash-4.2$ bart BACKUP -s acctg -F p --parent incr_1-b --backup-name +incr_1-c +INFO: creating incremental backup for server 'acctg' +INFO: checking mbm files /opt/backup/acctg/archived_wals +INFO: new backup identifier generated 1490649414316 +INFO: reading directory /opt/backup/acctg/archived_wals +INFO: all files processed +NOTICE: pg_stop_backup complete, all required WAL segments have been +archived +INFO: incremental backup completed successfully +. +. +. +``` + +The following output of the `SHOW-BACKUPS` subcommand lists the backup chain, which are backups `full_1, incr_1-a, incr_1-b, and incr_1-c`. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID BACKUP NAME BACKUP PARENT BACKUP TIME ... +acctg 1490649414316 incr_1-c incr_1-b 2017-03-27 17:16:55 ... +acctg 1490649336845 incr_1-b incr_1-a 2017-03-27 17:15:37 ... +acctg 1490649255649 incr_1-a full_1 2017-03-27 17:14:16 ... +acctg 1490649204327 full_1 none 2017-03-27 17:13:25 ... +``` + +For the `full backup full_1`, the `BACKUP PARENT` field contains `none`. For each incremental backup, the `BACKUP PARENT` field contains the backup identifier or name of its parent backup. + +A second backup chain is created in the same manner with the `BACKUP` subcommand. The following example shows the addition of the resulting, second backup chain consisting of full backup `full_2` and incremental backups `incr_2-a` and `incr_2-b`. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID BACKUP NAME BACKUP PARENT BACKUP TIME ... +acctg 1490649605607 incr_2-b incr_2-a 2017-03-27 17:20:06 ... +acctg 1490649587702 incr_2-a full_2 2017-03-27 17:19:48 ... +acctg 1490649528633 full_2 none 2017-03-27 17:18:49 ... +acctg 1490649414316 incr_1-c incr_1-b 2017-03-27 17:16:55 ... +acctg 1490649336845 incr_1-b incr_1-a 2017-03-27 17:15:37 ... +acctg 1490649255649 incr_1-a full_1 2017-03-27 17:14:16 ... +acctg 1490649204327 full_1 none 2017-03-27 17:13:25 ... +``` + +The following additional incremental backups starting with `incr_1-b-1`, which designates `incr_1-b` as the parent, results in the forking from that backup into a second line of backups in the chain consisting of `full_1, incr_1-a, incr_1-b, incr_1-b-1, incr_1-b-2`, and `incr_1-b-3` as shown in the following list: + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID BACKUP NAME BACKUP PARENT BACKUP TIME ... +acctg 1490649791430 incr_1-b-3 incr_1-b-2 2017-03-27 17:23:12 ... +acctg 1490649763929 incr_1-b-2 incr_1-b-1 2017-03-27 17:22:44 ... +acctg 1490649731672 incr_1-b-1 incr_1-b 2017-03-27 17:22:12 ... +acctg 1490649605607 incr_2-b incr_2-a 2017-03-27 17:20:06 ... +acctg 1490649587702 incr_2-a full_2 2017-03-27 17:19:48 ... +acctg 1490649528633 full_2 none 2017-03-27 17:18:49 ... +acctg 1490649414316 incr_1-c incr_1-b 2017-03-27 17:16:55 ... +acctg 1490649336845 incr_1-b incr_1-a 2017-03-27 17:15:37 ... +acctg 1490649255649 incr_1-a full_1 2017-03-27 17:14:16 ... +acctg 1490649204327 full_1 none 2017-03-27 17:13:25 ... +``` + +**Restoring an Incremental Backup** + +Restoring an incremental backup is done with the `RESTORE` subcommand in the same manner as for restoring a full backup. Specify the backup identifier or backup name of the incremental backup to be restored as shown in the following example. + +```text +-bash-4.2$ bart RESTORE -s acctg -p /opt/restore -i incr_1-b +INFO: restoring incremental backup 'incr_1-b' of server 'acctg' +INFO: base backup restored +INFO: archiving is disabled +INFO: permissions set on $PGDATA +INFO: incremental restore completed successfully +``` + +Restoring incremental backup `incr_1-b` as shown by the preceding example results in the restoration of full backup `full_1`, then incremental backups `incr_1-a` and finally, `incr_1-b`. + +## Managing Backups + +This section illustrates evaluating, marking, and deleting backups using the `MANAGE` subcommand using a redundancy retention policy and a recovery window retention policy. For detailed information about the `MANAGE` subcommand, see the *EDB Backup and Recovery User Guide* available at the [EDB website](/bart/2.5/bart_user/). + + + +### Using a Redundancy Retention Policy + +The following code sample uses a redundancy retention policy to evaluate, mark, and delete backups as shown by the following server configuration: + +```text +[ACCTG] +host = 127.0.0.1 +port = 5444 +user = enterprisedb +archive_command = 'cp %p %a/%f' +retention_policy = 3 BACKUPS +description = "Accounting" +``` + +The following list is the set of backups. Note that the last backup in the list has been marked as `keep`. + +```text +-bash-4.1$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID BACKUP TIME BACKUP SIZE WAL(s) SIZE +WAL FILES STATUS +acctg 1428768344061 2015-04-11 12:05:46 EDT 5.72 MB 48.00 MB +3 active +acctg 1428684537299 2015-04-10 12:49:00 EDT 5.72 MB 272.00 MB +17 active +acctg 1428589759899 2015-04-09 10:29:27 EDT 5.65 MB 96.00 MB +6 active +acctg 1428502049836 2015-04-08 10:07:30 EDT 55.25 MB 96.00 MB +6 active +acctg 1428422324880 2015-04-07 11:58:45 EDT 54.53 MB 32.00 MB +2 active +acctg 1428355371389 2015-04-06 17:22:53 EDT 5.71 MB 16.00 MB +1 keep +``` + +Invoke the `MANAGE` subcommand with the `-n` option to perform a dry run to observe which active backups would be changed to obsolete according to the retention policy as shown in the following code sample: + +```text +-bash-4.1$ bart MANAGE -s acctg -n +INFO: processing server 'acctg', backup '1428768344061' +INFO: processing server 'acctg', backup '1428684537299' +INFO: processing server 'acctg', backup '1428589759899' +INFO: processing server 'acctg', backup '1428502049836' +INFO: marking backup '1428502049836' as obsolete +INFO: 6 WAL file(s) marked obsolete +INFO: processing server 'acctg', backup '1428422324880' +INFO: marking backup '1428422324880' as obsolete +INFO: 2 WAL file(s) marked obsolete +INFO: processing server 'acctg', backup '1428355371389' +``` + +The dry run shows that backups `1428502049836` and `1428422324880` would be marked as `obsolete`. + +!!! Note + A dry run does not change the backup status. The two backups that would be considered obsolete are still marked as `active`: + +```text +-bash-4.1$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID BACKUP TIME BACKUP SIZE WAL(s) SIZE +WAL FILES STATUS +acctg 1428768344061 2015-04-11 12:05:46 EDT 5.72 MB 48.00 MB +3 active +acctg 1428684537299 2015-04-10 12:49:00 EDT 5.72 MB 272.00 MB +17 active +acctg 1428589759899 2015-04-09 10:29:27 EDT 5.65 MB 96.00 MB +6 active +acctg 1428502049836 2015-04-08 10:07:30 EDT 55.25 MB 96.00 MB +6 active +acctg 1428422324880 2015-04-07 11:58:45 EDT 54.53 MB 32.00 MB +2 active +acctg 1428355371389 2015-04-06 17:22:53 EDT 5.71 MB 16.00 MB +1 keep +``` + +Invoke the `MANAGE` subcommand omitting the `-n` option to change and mark the status of the backups as `obsolete`: + +```text +-bash-4.1$ bart MANAGE -s acctg +INFO: processing server 'acctg', backup '1428768344061' +INFO: processing server 'acctg', backup '1428684537299' +INFO: processing server 'acctg', backup '1428589759899' +INFO: processing server 'acctg', backup '1428502049836' +INFO: marking backup '1428502049836' as obsolete +INFO: 6 WAL file(s) marked obsolete +INFO: processing server 'acctg', backup '1428422324880' +INFO: marking backup '1428422324880' as obsolete +INFO: 2 WAL file(s) marked obsolete +INFO: processing server 'acctg', backup '1428355371389' +``` + +The obsolete backups can be observed in a number of ways. Use the `MANAGE` subcommand with the `-l` option to list the `obsolete` backups: + +```text +-bash-4.1$ bart MANAGE -s acctg -l +INFO: 6 WAL file(s) will be removed +SERVER NAME: acctg +BACKUP ID: 1428502049836 +BACKUP STATUS: obsolete +BACKUP TIME: 2015-04-08 10:07:30 EDT +BACKUP SIZE: 55.25 MB +WAL FILE(s): 6 +WAL FILE: 000000010000000100000003 +WAL FILE: 000000010000000100000002 +WAL FILE: 000000010000000100000001 +WAL FILE: 000000010000000100000000 +WAL FILE: 0000000100000000000000E3 +WAL FILE: 0000000100000000000000E2 +INFO: 2 WAL file(s) will be removed +SERVER NAME: acctg +BACKUP ID: 1428422324880 +BACKUP STATUS: obsolete +BACKUP TIME: 2015-04-07 11:58:45 EDT +BACKUP SIZE: 54.53 MB +WAL FILE(s): 2 +WAL FILE: 0000000100000000000000E1 +WAL FILE: 0000000100000000000000E0 +``` + +The `STATUS` field of the `SHOW-BACKUPS` subcommand displays the current status: + +```text +-bash-4.1$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID BACKUP TIME BACKUP SIZE WAL(s) SIZE +WAL FILES STATUS +acctg 1428768344061 2015-04-11 12:05:46 EDT 5.72 MB 48.00 MB +3 active +acctg 1428684537299 2015-04-10 12:49:00 EDT 5.72 MB 272.00 MB +17 active +acctg 1428589759899 2015-04-09 10:29:27 EDT 5.65 MB 96.00 MB +6 active +acctg 1428502049836 2015-04-08 10:07:30 EDT 55.25 MB 96.00 MB +6 obsolete +acctg 1428422324880 2015-04-07 11:58:45 EDT 54.53 MB 32.00 MB +2 obsolete +acctg 1428355371389 2015-04-06 17:22:53 EDT 5.71 MB 16.00 MB +1 keep +``` + +The details of an individual backup can be displayed using the `SHOW-BACKUPS` subcommand with the `-t` option. Note the status in the `BACKUP STATUS` field. + +```text +-bash-4.1$ bart SHOW-BACKUPS -s acctg -i 1428502049836 -t +SERVER NAME : acctg +BACKUP ID : 1428502049836 +BACKUP NAME : none +BACKUP STATUS : obsolete +BACKUP TIME : 2015-04-08 10:07:30 EDT +BACKUP SIZE : 55.25 MB +WAL(S) SIZE : 96.00 MB +NO. OF WALS : 6 +FIRST WAL FILE : 0000000100000000000000E2 +CREATION TIME : 2015-04-08 10:07:30 EDT +LAST WAL FILE : 000000010000000100000003 +CREATION TIME : 2015-04-09 10:25:46 EDT +``` + +Use the `MANAGE` subcommand with the `-d` option to physically delete the `obsolete` backups including the unneeded WAL files. + +```text +-bash-4.1$ bart MANAGE -s acctg -d +INFO: removing all obsolete backups of server 'acctg' +INFO: removing obsolete backup '1428502049836' +INFO: 6 WAL file(s) will be removed +INFO: removing WAL file '000000010000000100000003' +INFO: removing WAL file '000000010000000100000002' +INFO: removing WAL file '000000010000000100000001' +INFO: removing WAL file '000000010000000100000000' +INFO: removing WAL file '0000000100000000000000E3' +INFO: removing WAL file '0000000100000000000000E2' +INFO: removing obsolete backup '1428422324880' +INFO: 2 WAL file(s) will be removed +INFO: removing WAL file '0000000100000000000000E1' +INFO: removing WAL file '0000000100000000000000E0' +``` + +The `SHOW-BACKUPS` subcommand now displays the remaining backups marked as `active` or `keep`: + +```text +-bash-4.1$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID BACKUP TIME BACKUP SIZE WAL(s) SIZE +WAL FILES STATUS +acctg 1428768344061 2015-04-11 12:05:46 EDT 5.72 MB 48.00 MB +3 active +acctg 1428684537299 2015-04-10 12:49:00 EDT 5.72 MB 272.00 MB +17 active +acctg 1428589759899 2015-04-09 10:29:27 EDT 5.65 MB 96.00 MB +6 active +acctg 1428355371389 2015-04-06 17:22:53 EDT 5.71 MB 16.00 MB +1 keep +``` + + + +### Using a Recovery Window Retention Policy + +This section illustrates the evaluation, marking, and deletion of backup using a recovery window retention policy. To use the recovery window retention policy, set the `retention_policy` parameter to the desired length of time for the recovery window. + +This section provides examples of the following: + +- How to view the calculated recovery window. +- How to evaluate, mark, and delete backup using a recovery window retention policy. + +#### Viewing the Recovery Window + +You can view the actual, calculated recovery window by invoking any of the following subcommands: + +- `MANAGE` subcommand in debug mode (along with the `-n` option). +- `SHOW-SERVERS` subcommand. + +##### Viewing the Recovery Window Using the Manage Subcommand + +When invoking BART in debug mode with the `MANAGE` subcommand and the `-n` option, the length of the recovery window is calculated based on the `retention_policy` setting and the current date/time. + +For example, using the following `retention_policy` settings: + +```text +[ACCTG] + +host = 127.0.0.1 +port = 5444 +user = enterprisedb +archive_command = 'cp %p %a/%f' +retention_policy = 3 DAYS +backup-name = acctg_%year-%month-%dayT%hour:%minute:%second +description = "Accounting" + +[DEV] + +host = 127.0.0.1 +port = 5445 +user = enterprisedb +archive_command = 'cp %p %a/%f' +retention_policy = 3 WEEKS +description = "Development" + +[HR] + +host = 127.0.0.1 +port = 5432 +user = postgres +retention_policy = 3 MONTHS +description = "Human Resources" +``` + +If the `MANAGE` subcommand is invoked in debug mode along with the `-n` option on 2015-04-17, the following results are displayed: + +```text +-bash-4.1$ bart -d MANAGE -n +DEBUG: Server: acctg, Now: 2015-04-17 16:34:03 EDT, RetentionWindow: +259200 (secs) ==> 72 hour(s) +DEBUG: Server: dev, Now: 2015-04-17 16:34:03 EDT, RetentionWindow: +1814400 (secs) ==> 504 hour(s) +DEBUG: Server: hr, Now: 2015-04-17 16:34:03 EDT, RetentionWindow: +7776000 (secs) ==> 2160 hour(s) +``` + +For server `acctg`, 72 hours translates to a recovery window of 3 days. + +For server `dev`, 504 hours translates to a recovery window of 21 days (3 weeks). + +For server `hr`, 2160 hours translates to a recovery window of 90 days (3 months). + +For a setting of ` MONTHS`, the calculated total number of days for the recovery window is dependent upon the actual number of days in the preceding months from the current date/time. Thus, ` MONTHS` is not always exactly equivalent to ` x 30 DAYS`. For example, if the current date/time is in the month of March, a 1-month recovery window would be equivalent to only 28 days because the preceding month is February. Thus, for a current date of March 31, a 1-month recovery window would start on March 3. However, the typical result is that the day of the month of the starting recovery window boundary will be the same day of the month of when the `MANAGE` subcommand is invoked. + +##### Viewing the Recovery Window Using the Show-Servers Subcommand + +This section provides an example of viewing the recovery window using the `SHOW-SERVERS` subcommand; the `RETENTION POLICY` field displays the start of the recovery window. + +In the following code sample, the recovery window retention policy setting considers the backups taken within a 3-day recovery window as the active backups. + +```text +[ACCTG] +host = 127.0.0.1 +port = 5444 +user = enterprisedb +archive_command = 'cp %p %a/%f' +retention_policy = 3 DAYS +description = "Accounting" +``` + +The start of the 3-day recovery window displayed in the `RETENTION POLICY` field is `2015-04-07 14:57:36 EDT` when the `SHOW-SERVERS` subcommand is invoked on `2015-04-10`. + +At this current point in time, backups taken on or after `2015-04-07 14:57:36 EDT` would be considered active. Backups taken prior to `2015-04-07 14:57:36 EDT` would be considered obsolete except for backups marked as `keep`. + +```text +-bash-4.1$ date +Fri Apr 10 14:57:33 EDT 2015 +-bash-4.1$ +-bash-4.1$ bart SHOW-SERVERS -s acctg +SERVER NAME : acctg +HOST NAME : 127.0.0.1 +USER NAME : enterprisedb +PORT : 5444 +REMOTE HOST : +RETENTION POLICY : 2015-04-07 14:57:36 EDT +DISK UTILIZATION : 824.77 MB +NUMBER OF ARCHIVES : 37 +ARCHIVE PATH : /opt/backup/acctg/archived_wals +ARCHIVE COMMAND : cp %p /opt/backup/acctg/archived_wals/%f +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +DESCRIPTION : "Accounting" +``` + +In the following code sample, the recovery window retention policy setting considers the backups taken within a 3-week recovery window as the `active` backups. + +```text +[DEV] +host = 127.0.0.1 +port = 5445 +user = enterprisedb +archive_command = 'cp %p %a/%f' +retention_policy = 3 WEEKS +description = "Development" +``` + +The start of the 3-week recovery window displayed in the `RETENTION POLICY` field is `2015-03-20 14:59:42 EDT` when the `SHOW-SERVERS` subcommand is invoked on `2015-04-10`. + +At this current point in time, backups taken on or after `2015-03-20 14:59:42 EDT` would be considered `active`. Backups taken prior to `2015-03-20 14:59:42 EDT` would be considered `obsolete` except for backups marked as `keep`. + +```text +-bash-4.1$ date +Fri Apr 10 14:59:39 EDT 2015 +-bash-4.1$ +-bash-4.1$ bart SHOW-SERVERS -s dev +SERVER NAME : dev +HOST NAME : 127.0.0.1 +USER NAME : enterprisedb +PORT : 5445 +REMOTE HOST : +RETENTION POLICY : 2015-03-20 14:59:42 EDT +DISK UTILIZATION : 434.53 MB +NUMBER OF ARCHIVES : 22 +ARCHIVE PATH : /opt/backup/dev/archived_wals +ARCHIVE COMMAND : cp %p /opt/backup/dev/archived_wals/%f +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +DESCRIPTION : "Development" +``` + +In the following code sample, the recovery window retention policy setting considers the backups taken within a 3-month recovery window as the `active` backups. + +```text +[HR] +host = 127.0.0.1 +port = 5432 +user = postgres +retention_policy = 3 MONTHS +description = "Human Resources" +``` + +The start of the 3-month recovery window displayed in the `RETENTION POLICY` field is `2015-01-10 14:04:23 EST` when the `SHOW-SERVERS` subcommand is invoked on `2015-04-10`. + +At this current point in time, backups taken on or after `2015-01-10 14:04:23 EST` would be considered `active`. Backups taken prior to `2015-01-10 14:04:23 EST` would be considered `obsolete`, except for backups marked as `keep`. + +```text +-bash-4.1$ date +Fri Apr 10 15:04:19 EDT 2015 +-bash-4.1$ +-bash-4.1$ bart SHOW-SERVERS -s hr +SERVER NAME : hr +HOST NAME : 127.0.0.1 +USER NAME : postgres +PORT : 5432 +REMOTE HOST : +RETENTION POLICY : 2015-01-10 14:04:23 EST +DISK UTILIZATION : 480.76 MB +NUMBER OF ARCHIVES : 26 +ARCHIVE PATH : /opt/backup/hr/archived_wals +ARCHIVE COMMAND : scp %p +enterprisedb@192.168.2.22:/opt/backup/hr/archived_wals/%f +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +DESCRIPTION : "Human Resources" +``` + +#### Evaluating, Marking, and Deleting Backup Using a Recovery Window Retention Policy + +The following code sample uses a recovery window retention policy to evaluate, mark, and delete backups as shown by the following server configuration: + +```text +[DEV] +host = 127.0.0.1 +port = 5445 +user = enterprisedb +archive_command = 'cp %p %a/%f' +retention_policy = 3 DAYS +description = "Development" +``` + +The following is the current set of backups. Note that the last backup in the list has been marked as `keep`. + +```text +-bash-4.1$ bart SHOW-BACKUPS -s dev +SERVER NAME BACKUP ID BACKUP TIME BACKUP SIZE WAL(s) SIZE +WAL FILES STATUS +dev 1428933278236 2015-04-13 09:54:40 EDT 5.65 MB 16.00 MB +1 active +dev 1428862187757 2015-04-12 14:09:50 EDT 5.65 MB 32.00 MB +2 active +dev 1428768351638 2015-04-11 12:05:54 EDT 5.65 MB 32.00 MB +2 active +dev 1428684544008 2015-04-10 12:49:06 EDT 5.65 MB 224.00 MB +14 active +dev 1428590536488 2015-04-09 10:42:18 EDT 5.65 MB 48.00 MB +3 active +dev 1428502171990 2015-04-08 10:09:34 EDT 5.65 MB 80.00 MB +5 keep +``` + +The current date and time is `2015-04-13 16:46:35 EDT` as shown below: + +```text +-bash-4.1$ date +Mon Apr 13 16:46:35 EDT 2015 +``` + +Thus, a 3-day recovery window would evaluate backups prior to `2015-04-10 16:46:35 EDT` as `obsolete` except for those marked as `keep`. + +Invoke the `MANAGE` subcommand with the `-n` option to perform a dry run to observe which active backups would be changed to `obsolete` according to the retention policy. + +```text +-bash-4.1$ bart MANAGE -s dev -n +INFO: processing server 'dev', backup '1428933278236' +INFO: processing server 'dev', backup '1428862187757' +INFO: processing server 'dev', backup '1428768351638' +INFO: processing server 'dev', backup '1428684544008' +INFO: marking backup '1428684544008' as obsolete +INFO: 14 WAL file(s) marked obsolete +INFO: 1 Unused WAL file(s) present +INFO: processing server 'dev', backup '1428590536488' +INFO: marking backup '1428590536488' as obsolete +INFO: 3 WAL file(s) marked obsolete +INFO: 1 Unused WAL file(s) present +INFO: processing server 'dev', backup '1428502171990' +``` + +The dry run shows that backups `1428684544008` and `1428590536488` would be marked as `obsolete`. + +Also note that a dry run does not change the backup status. The two backups that would be considered obsolete are still marked as `active`: + +```text +-bash-4.1$ bart SHOW-BACKUPS -s dev\ + SERVER NAME BACKUP ID BACKUP TIME BACKUP SIZE WAL(s) SIZE + WAL FILES STATUS + dev 1428933278236 2015-04-13 09:54:40 EDT 5.65 MB 16.00 MB + 1 active + dev 1428862187757 2015-04-12 14:09:50 EDT 5.65 MB 32.00 MB + 2 active + dev 1428768351638 2015-04-11 12:05:54 EDT 5.65 MB 32.00 MB + 2 active + dev 1428684544008 2015-04-10 12:49:06 EDT 5.65 MB 224.00 MB + 14 active + dev 1428590536488 2015-04-09 10:42:18 EDT 5.65 MB 48.00 MB + 3 active + dev 1428502171990 2015-04-08 10:09:34 EDT 5.65 MB 80.00 MB + 5 keep +``` + +Invoke the `MANAGE` subcommand omitting the `-n` option to change and mark the status of the backups as `obsolete`: + +```text +-bash-4.1$ bart MANAGE -s dev +INFO: processing server 'dev', backup '1428933278236' +INFO: processing server 'dev', backup '1428862187757' +INFO: processing server 'dev', backup '1428768351638' +INFO: processing server 'dev', backup '1428684544008' +INFO: marking backup '1428684544008' as obsolete +INFO: 14 WAL file(s) marked obsolete +INFO: 1 Unused WAL file(s) present +INFO: processing server 'dev', backup '1428590536488' +INFO: marking backup '1428590536488' as obsolete +INFO: 3 WAL file(s) marked obsolete +INFO: 1 Unused WAL file(s) present +INFO: processing server 'dev', backup '1428502171990' +``` + +The obsolete backups can be observed in a number of ways. Use the `MANAGE` subcommand with the `-l` option to list the `obsolete` backups: + +```text +-bash-4.1$ bart MANAGE -s dev -l +INFO: 14 WAL file(s) will be removed +INFO: 1 Unused WAL file(s) will be removed +SERVER NAME: dev +BACKUP ID: 1428684544008 +BACKUP STATUS: obsolete +BACKUP TIME: 2015-04-10 12:49:06 EDT +BACKUP SIZE: 5.65 MB +WAL FILE(s): 14 +UNUSED WAL FILE(s): 1 +WAL FILE: 00000001000000000000002E +WAL FILE: 00000001000000000000002D +WAL FILE: 00000001000000000000002C +WAL FILE: 00000001000000000000002B +WAL FILE: 00000001000000000000002A +WAL FILE: 000000010000000000000029 +WAL FILE: 000000010000000000000028 +WAL FILE: 000000010000000000000027 +WAL FILE: 000000010000000000000026 +WAL FILE: 000000010000000000000025 +WAL FILE: 000000010000000000000024 +WAL FILE: 000000010000000000000023 +WAL FILE: 000000010000000000000022 +WAL FILE: 000000010000000000000021 +UNUSED WAL FILE: 00000001000000000000000F.00000028 +INFO: 3 WAL file(s) will be removed +INFO: 1 Unused WAL file(s) will be removed +SERVER NAME: dev +BACKUP ID: 1428590536488 +BACKUP STATUS: obsolete +BACKUP TIME: 2015-04-09 10:42:18 EDT\ +BACKUP SIZE: 5.65 MB +WAL FILE(s): 3 +UNUSED WAL FILE(s): 1 +WAL FILE: 000000010000000000000020 +WAL FILE: 00000001000000000000001F +WAL FILE: 00000001000000000000001E +UNUSED WAL FILE: 00000001000000000000000F.00000028 +``` + +The `STATUS` field of the `SHOW-BACKUPS` subcommand displays the current status: + +```text +-bash-4.1$ bart SHOW-BACKUPS -s dev +SERVER NAME BACKUP ID BACKUP TIME BACKUP SIZE WAL(s) SIZE +WAL FILES STATUS +dev 1428933278236 2015-04-13 09:54:40 EDT 5.65 MB 16.00 MB +1 active +dev 1428862187757 2015-04-12 14:09:50 EDT 5.65 MB 32.00 MB +2 active +dev 1428768351638 2015-04-11 12:05:54 EDT 5.65 MB 32.00 MB +2 active +dev 1428684544008 2015-04-10 12:49:06 EDT 5.65 MB 224.00 MB +14 obsolete +dev 1428590536488 2015-04-09 10:42:18 EDT 5.65 MB 48.00 MB +3 obsolete +dev 1428502171990 2015-04-08 10:09:34 EDT 5.65 MB 80.00 MB +5 keep +``` + +The details of an individual backup can be displayed using the `SHOW-BACKUPS` subcommand with the `-t` option. Note the status in the `BACKUP STATUS` field. + +```text +-bash-4.1$ bart SHOW-BACKUPS -s dev -i 1428684544008 -t +SERVER NAME : dev +BACKUP ID : 1428684544008 +BACKUP NAME : none +BACKUP STATUS : obsolete +BACKUP TIME : 2015-04-10 12:49:06 EDT +BACKUP SIZE : 5.65 MB +WAL(S) SIZE : 224.00 MB +NO. OF WALS : 14 +FIRST WAL FILE : 000000010000000000000021 +CREATION TIME : 2015-04-10 12:49:06 EDT +LAST WAL FILE : 00000001000000000000002E +CREATION TIME : 2015-04-11 12:02:15 EDT +``` + +Use the `MANAGE` subcommand with the `-d` option to physically delete the obsolete backups including the unneeded WAL files. + +```text +-bash-4.1$ bart MANAGE -s dev -d +INFO: removing all obsolete backups of server 'dev' +INFO: removing obsolete backup '1428684544008' +INFO: 14 WAL file(s) will be removed +INFO: 1 Unused WAL file(s) will be removed +INFO: removing WAL file '00000001000000000000002E' +INFO: removing WAL file '00000001000000000000002D' +INFO: removing WAL file '00000001000000000000002C' +INFO: removing WAL file '00000001000000000000002B' +INFO: removing WAL file '00000001000000000000002A' +INFO: removing WAL file '000000010000000000000029' +INFO: removing WAL file '000000010000000000000028' +INFO: removing WAL file '000000010000000000000027' +INFO: removing WAL file '000000010000000000000026' +INFO: removing WAL file '000000010000000000000025' +INFO: removing WAL file '000000010000000000000024' +INFO: removing WAL file '000000010000000000000023' +INFO: removing WAL file '000000010000000000000022' +INFO: removing WAL file '000000010000000000000021' +INFO: removing (unused) WAL file '00000001000000000000000F.00000028' +INFO: removing obsolete backup '1428590536488' +INFO: 3 WAL file(s) will be removed +INFO: removing WAL file '000000010000000000000020' +INFO: removing WAL file '00000001000000000000001F' +INFO: removing WAL file '00000001000000000000001E' +``` + +The `SHOW-BACKUPS` subcommand now displays the remaining backups marked as `active` or `keep`: + +```text +-bash-4.1$ bart SHOW-BACKUPS -s dev +SERVER NAME BACKUP ID BACKUP TIME BACKUP SIZE WAL(s) SIZE +WAL FILES STATUS +dev 1428933278236 2015-04-13 09:54:40 EDT 5.65 MB 16.00 MB +1 active +dev 1428862187757 2015-04-12 14:09:50 EDT 5.65 MB 32.00 MB +2 active +dev 1428768351638 2015-04-11 12:05:54 EDT 5.65 MB 32.00 MB +2 active +dev 1428502171990 2015-04-08 10:09:34 EDT 5.65 MB 80.00 MB +5 keep +``` + +## Managing Incremental Backups + +This section illustrates evaluating, marking, and deleting incremental backups using the `MANAGE` and `DELETE` subcommands utilizing redundancy retention policy and recovery window retention policy. For detailed information about the `MANAGE` and `DELETE` subcommands, as well as the redundancy retention and recovery window retention policy, see the *EDB Backup and Recovery User Guide* available at the [EDB website](/bart/2.5/bart_user/). + +- [Using a Redundancy Retention Policy](#redundancy_retention_policy) provides an example of using the `MANAGE` and `DELETE` subcommands when a 3 backup redundancy retention policy is in effect. +- [Using a Recovery Window Retention Policy](#recovery_window_retention_policy) provides an example of using the `MANAGE` and `DELETE` subcommands when a 1-day recovery window retention policy is in effect. + + + +### Using a Redundancy Retention Policy + +The following code sample uses the `MANAGE` and `DELETE` subcommands to evaluate, mark, and delete incremental backups when a 3 backup redundancy retention policy is in effect. The example uses the following server configuration: + +```text +[ACCTG] + +host = 192.168.2.24 +port = 5445 +user = enterprisedb +cluster_owner = enterprisedb +remote_host = enterprisedb@192.168.2.24 +allow_incremental_backups = enabled +retention_policy = 3 BACKUPS +description = "Accounting" +``` + +The example uses the following set of backups. In these code samples, some columns have been omitted from the `SHOW-BACKUPS` output to display the relevant information in a more observable manner. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME ... STATUS +acctg 1481749696905 ... 1481749673603 2016-12-14 16:08:17 EST ... active +acctg 1481749673603 ... 1481749651927 2016-12-14 16:07:53 EST ... active +acctg 1481749651927 ... 1481749619582 2016-12-14 16:07:32 EST ... active +acctg 1481749619582 ... none 2016-12-14 16:07:00 EST ... active +``` + +There is one backup chain. The first backup is the initial full backup. + +Backup chain: `1481749619582 => 1481749651927 => 1481749673603 => 1481749696905` + +The `MANAGE` subcommand is invoked as shown by the following: + +```text +-bash-4.2$ bart MANAGE -s acctg +INFO: processing server 'acctg', backup '1481749619582' +INFO: 2 Unused WAL file(s) present +INFO: 4 Unused file(s) (WALs included) present, use 'MANAGE -l' for the +list +``` + +The following code sample shows the resulting status of the backups: + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME ... STATUS +acctg 1481749696905 ... 1481749673603 2016-12-14 16:08:17 EST ... active +acctg 1481749673603 ... 1481749651927 2016-12-14 16:07:53 EST ... active +acctg 1481749651927 ... 1481749619582 2016-12-14 16:07:32 EST ... active +acctg 1481749619582 ... none 2016-12-14 16:07:00 EST ... active +``` + +The status remains active for all backups. Even though the total number of backups exceeds the 3 backup redundancy retention policy, it is only the total number of full backups that is used to determine if the redundancy retention policy has been exceeded. Additional full backups are added including a second backup chain. The following example shows the resulting list of backups: + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME ... STATUS +acctg 1481750365397 ... none 2016-12-14 16:19:26 EST ... active +acctg 1481750098924 ... 1481749997807 2016-12-14 16:14:59 EST ... active +acctg 1481749997807 ... none 2016-12-14 16:13:18 EST ... active +acctg 1481749992003 ... none 2016-12-14 16:13:12 EST ... active +acctg 1481749696905 ... 1481749673603 2016-12-14 16:08:17 EST ... active +acctg 1481749673603 ... 1481749651927 2016-12-14 16:07:53 EST ... active +acctg 1481749651927 ... 1481749619582 2016-12-14 16:07:32 EST ... active +acctg 1481749619582 ... none 2016-12-14 16:07:00 EST ... active +``` + +Second backup chain: `1481749997807 => 1481750098924` + +The `MANAGE` subcommand is invoked, but now with a total of four active full backups. + +```text +-bash-4.2$ bart MANAGE -s acctg +INFO: processing server 'acctg', backup '1481750365397' +INFO: processing server 'acctg', backup '1481749997807' +INFO: processing server 'acctg', backup '1481749992003' +INFO: processing server 'acctg', backup '1481749619582' +INFO: marking backup '1481749619582' as obsolete +INFO: 3 incremental(s) of backup '1481749619582' will be marked obsolete +INFO: marking incremental backup '1481749696905' as obsolete +INFO: marking incremental backup '1481749673603' as obsolete +INFO: marking incremental backup '1481749651927' as obsolete +INFO: 4 WAL file(s) marked obsolete +INFO: 2 Unused WAL file(s) present +INFO: 4 Unused file(s) (WALs included) present, use 'MANAGE -l' for the +list +``` + +The oldest full backup and its chain of incremental backups are now marked as obsolete. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME ... STATUS +acctg 1481750365397 ... none 2016-12-14 16:19:26 EST ... active +acctg 1481750098924 ... 1481749997807 2016-12-14 16:14:59 EST ... active +acctg 1481749997807 ... none 2016-12-14 16:13:18 EST ... active +acctg 1481749992003 ... none 2016-12-14 16:13:12 EST ... active +acctg 1481749696905 ... 1481749673603 2016-12-14 16:08:17 EST ... obsolete +acctg 1481749673603 ... 1481749651927 2016-12-14 16:07:53 EST ... obsolete +acctg 1481749651927 ... 1481749619582 2016-12-14 16:07:32 EST ... obsolete +acctg 1481749619582 ... none 2016-12-14 16:07:00 EST ... obsolete +``` + +Invoking the `MANAGE` subcommand with the `-d` option deletes the entire obsolete backup chain. + +```text +-bash-4.2$ bart MANAGE -s acctg -d +INFO: removing all obsolete backups of server 'acctg' +INFO: removing obsolete backup '1481749619582' +INFO: 4 WAL file(s) will be removed +INFO: 3 incremental(s) of backup '1481749619582' will be removed +INFO: removing obsolete incremental backup '1481749696905' +INFO: removing obsolete incremental backup '1481749673603' +INFO: removing obsolete incremental backup '1481749651927' +INFO: removing WAL file '000000010000000100000000' +INFO: removing WAL file '0000000100000000000000FF' +INFO: removing WAL file '0000000100000000000000FE' +INFO: removing WAL file '0000000100000000000000FD' +INFO: 16 Unused file(s) will be removed +INFO: removing (unused) file '000000010000000100000004.00000028.backup' +. +. +. +INFO: removing (unused) file +'0000000100000000FB00002800000000FC000000.mbm' +``` + +The following code sample shows the remaining full backups and the second backup chain. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME ... STATUS +acctg 1481750365397 ... none 2016-12-14 16:19:26 EST ... active +acctg 1481750098924 ... 1481749997807 2016-12-14 16:14:59 EST ... active +acctg 1481749997807 ... none 2016-12-14 16:13:18 EST ... active +acctg 1481749992003 ... none 2016-12-14 16:13:12 EST ... active +``` + + + +### Using a Recovery Window Retention Policy + +The following example demonstrates using the `MANAGE` and `DELETE` subcommands to evaluate, mark, and delete incremental backups when a 1-day recovery window retention policy is in effect. The example uses the following server configuration: + +```text +[ACCTG] + +host = 192.168.2.24 +port = 5445 +user = enterprisedb +cluster_owner = enterprisedb +remote_host = enterprisedb@192.168.2.24 +allow_incremental_backups = enabled +retention_policy = 1 DAYS +description = "Accounting" +``` + +The example uses the following set of backups. In the samples, some columns have been omitted from the `SHOW-BACKUPS` output to display the relevant information in a more observable manner. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME ... STATUS +acctg 1481559303348 ... 1481554203288 2016-12-12 11:15:03 EST ... active +acctg 1481559014359 ... 1481554802918 2016-12-12 11:10:14 EST ... active +acctg 1481554802918 ... 1481553914533 2016-12-12 10:00:03 EST ... active +acctg 1481554203288 ... 1481553651165 2016-12-12 09:50:03 EST ... active +acctg 1481553914533 ... 1481553088053 2016-12-12 09:45:14 EST ... active +acctg 1481553651165 ... none 2016-12-12 09:40:51 EST ... active +acctg 1481553088053 ... 1481552078404 2016-12-12 09:31:28 EST ... active +acctg 1481552078404 ... none 2016-12-12 09:14:39 EST ... active +``` + +There are two backup chains. In each of the following chains, the first backup is the initial full backup. + +First backup chain: `1481552078404 => 1481553088053 => 1481553914533 => 1481554802918 => 1481559014359` + +Second backup chain: `1481553651165 => 1481554203288 => 1481559303348` + +The `MANAGE` subcommand is invoked when the first full backup `1481552078404` falls out of the recovery window. When the `MANAGE` subcommand is invoked, it is `2016-12-13 09:20:03 EST`, thus making the start of the 1-day recovery window at `2016-12-12 09:20:03 EST` exactly one day earlier. This backup was taken at `2016-12-12 09:14:39 EST`, which is about 5 ½ minutes before the start of the recovery window, thus making the backup obsolete. + +```text +-bash-4.2$ date +Tue Dec 13 09:20:03 EST 2016 +-bash-4.2$ bart MANAGE -s acctg +INFO: processing server 'acctg', backup '1481553651165' +INFO: processing server 'acctg', backup '1481552078404' +INFO: marking backup '1481552078404' as obsolete +INFO: 4 incremental(s) of backup '1481552078404' will be marked obsolete +INFO: marking incremental backup '1481559014359' as obsolete +INFO: marking incremental backup '1481554802918' as obsolete +INFO: marking incremental backup '1481553914533' as obsolete +INFO: marking incremental backup '1481553088053' as obsolete +INFO: 7 WAL file(s) marked obsolete +INFO: 1 Unused WAL file(s) present +INFO: 2 Unused file(s) (WALs included) present, use 'MANAGE -l' for the list +``` + +The incremental backup date and time are within the recovery window since they were taken after the start of the recovery window of `2016-12-12 09:20:03 EST`, but all backups in the chain are marked as `obsolete`. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg\ +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME +... STATUS +acctg 1481559303348 ... 1481554203288 2016-12-12 11:15:03 EST +... active +acctg 1481559014359 ... 1481554802918 2016-12-12 11:10:14 EST +... obsolete +acctg 1481554802918 ... 1481553914533 2016-12-12 10:00:03 EST +... obsolete +acctg 1481554203288 ... 1481553651165 2016-12-12 09:50:03 EST +... active +acctg 1481553914533 ... 1481553088053 2016-12-12 09:45:14 EST +... obsolete +acctg 1481553651165 ... none 2016-12-12 09:40:51 EST +... active +acctg 1481553088053 ... 1481552078404 2016-12-12 09:31:28 EST +... obsolete +acctg 1481552078404 ... none 2016-12-12 09:14:39 EST +... obsolete +``` + +The following code sample shows how the entire backup chain is changed back to active status by invoking the `MANAGE` subcommand with the `-c nokeep` option on the full backup of the chain. + +```text +-bash-4.2$ bart MANAGE -s acctg -c nokeep -i 1481552078404 +INFO: changing status of backup '1481552078404' of server 'acctg' from +'obsolete' to 'active' +INFO: status of 4 incremental(s) of backup '1481552078404' will be +changed +INFO: changing status of incremental backup '1481559014359' of server +'acctg' from 'obsolete' to 'active' +INFO: changing status of incremental backup '1481554802918' of server +'acctg' from 'obsolete' to 'active' +INFO: changing status of incremental backup '1481553914533' of server +'acctg' from 'obsolete' to 'active' +INFO: changing status of incremental backup '1481553088053' of server +'acctg' from 'obsolete' to 'active' +INFO: 7 WAL file(s) changed +``` + +The backup chain has now been reset to active status. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME ... STATUS +acctg 1481559303348 ... 1481554203288 2016-12-12 11:15:03 EST ... active +acctg 1481559014359 ... 1481554802918 2016-12-12 11:10:14 EST ... active +acctg 1481554802918 ... 1481553914533 2016-12-12 10:00:03 EST ... active +acctg 1481554203288 ... 1481553651165 2016-12-12 09:50:03 EST ... active +acctg 1481553914533 ... 1481553088053 2016-12-12 09:45:14 EST ... active +acctg 1481553651165 ... none 2016-12-12 09:40:51 EST ... active +acctg 1481553088053 ... 1481552078404 2016-12-12 09:31:28 EST ... active +acctg 1481552078404 ... none 2016-12-12 09:14:39 EST ... active +``` + +The following code sample shows usage of the `DELETE` subcommand on an incremental backup. The specified incremental backup `1481554802918` in the first backup chain as well as its successive incremental backup `1481559014359` are deleted. + +```text +-bash-4.2$ bart DELETE -s acctg -i 1481554802918 +INFO: deleting backup '1481554802918' of server 'acctg' +INFO: deleting backup '1481554802918' +INFO: 1 incremental backup(s) will be deleted +INFO: deleting incremental backup '1481559014359' +INFO: WALs of deleted backup(s) will belong to prior backup(if any), or +will be marked unused +INFO: 2 Unused file(s) will be removed +INFO: removing (unused) file '0000000100000000000000BA' +INFO: removing (unused) file +'0000000100000000BA00002800000000BB000000.mbm' +INFO: backup(s) deleted +``` + +The results show that the backups `1481554802918` and `1481559014359` are no longer listed by the `SHOW-BACKUPS` subcommand. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME ... STATUS +acctg 1481559303348 ... 1481554203288 2016-12-12 11:15:03 EST ... active +acctg 1481554203288 ... 1481553651165 2016-12-12 09:50:03 EST ... active +acctg 1481553914533 ... 1481553088053 2016-12-12 09:45:14 EST ... active +acctg 1481553651165 ... none 2016-12-12 09:40:51 EST ... active +acctg 1481553088053 ... 1481552078404 2016-12-12 09:31:28 EST ... active +acctg 1481552078404 ... none 2016-12-12 09:14:39 EST ... active +``` + +The `MANAGE` subcommand is invoked again. This time both backup chains are marked `obsolete` since the full backups of both chains fall out of the start of the recovery window, which is now `2016-12-12 09:55:03 EST`. + +```text +-bash-4.2$ date +Tue Dec 13 09:55:03 EST 2016 +-bash-4.2$ bart MANAGE -s acctg +INFO: processing server 'acctg', backup '1481553651165' +INFO: marking backup '1481553651165' as obsolete +INFO: 2 incremental(s) of backup '1481553651165' will be marked obsolete +INFO: marking incremental backup '1481559303348' as obsolete +INFO: marking incremental backup '1481554203288' as obsolete +INFO: 38 WAL file(s) marked obsolete +INFO: processing server 'acctg', backup '1481552078404' +INFO: marking backup '1481552078404' as obsolete +INFO: 2 incremental(s) of backup '1481552078404' will be marked obsolete +INFO: marking incremental backup '1481553914533' as obsolete +INFO: marking incremental backup '1481553088053' as obsolete +INFO: 7 WAL file(s) marked obsolete +``` + +The following code sample shows both backup chains marked as `obsolete`. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME +... STATUS +acctg 1481559303348 ... 1481554203288 2016-12-12 11:15:03 EST +... obsolete +acctg 1481554203288 ... 1481553651165 2016-12-12 09:50:03 EST +... obsolete +acctg 1481553914533 ... 1481553088053 2016-12-12 09:45:14 EST +... obsolete +acctg 1481553651165 ... none 2016-12-12 09:40:51 EST +... obsolete +acctg 1481553088053 ... 1481552078404 2016-12-12 09:31:28 EST +... obsolete +acctg 1481552078404 ... none 2016-12-12 09:14:39 EST +... obsolete +``` + +The following code sample demonstrates using the `MANAGE` subcommand with the `-c keep` option to keep a backup chain indefinitely. The `MANAGE` subcommand with the `-c keep` option must specify the backup identifier or backup name of the full backup of the chain, and not any incremental backup. + +```text +-bash-4.2$ bart MANAGE -s acctg -c keep -i 1481553651165 +INFO: changing status of backup '1481553651165' of server 'acctg' from +'obsolete' to 'keep' +INFO: status of 2 incremental(s) of backup '1481553651165' will be +changed +INFO: changing status of incremental backup '1481559303348' of server +'acctg' from 'obsolete' to 'keep' +INFO: changing status of incremental backup '1481554203288' of server +'acctg' from 'obsolete' to 'keep' +INFO: 38 WAL file(s) changed +``` + +The full backup `1481553651165` and its successive incremental backups `1481554203288` and `1481559303348` have been changed to `keep` status: + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME +... STATUS +acctg 1481559303348 ... 1481554203288 2016-12-12 11:15:03 EST +... keep +acctg 1481554203288 ... 1481553651165 2016-12-12 09:50:03 EST +... keep +acctg 1481553914533 ... 1481553088053 2016-12-12 09:45:14 EST +... obsolete +acctg 1481553651165 ... none 2016-12-12 09:40:51 EST +... keep +acctg 1481553088053 ... 1481552078404 2016-12-12 09:31:28 EST +... obsolete +acctg 1481552078404 ... none 2016-12-12 09:14:39 EST +... obsolete +``` + +Finally, the `MANAGE` subcommand with the `-d` option is used to delete the `obsolete` backup chain: + +```text +-bash-4.2$ bart MANAGE -s acctg -d +INFO: removing all obsolete backups of server 'acctg' +INFO: removing obsolete backup '1481552078404' +INFO: 7 WAL file(s) will be removed +INFO: 2 incremental(s) of backup '1481552078404' will be removed +INFO: removing obsolete incremental backup '1481553914533' +INFO: removing obsolete incremental backup '1481553088053' +INFO: removing WAL file '0000000100000000000000C1' +INFO: removing WAL file '0000000100000000000000C0' +INFO: removing WAL file '0000000100000000000000BF' +INFO: removing WAL file '0000000100000000000000BE' +INFO: removing WAL file '0000000100000000000000BD' +INFO: removing WAL file '0000000100000000000000BC' +INFO: removing WAL file '0000000100000000000000BB' +INFO: 48 Unused file(s) will be removed +INFO: removing (unused) file '0000000100000000000000FA' +. +. +. +INFO: removing (unused) file '0000000100000000000000BB.00000028.backup' +``` + +Only the backup chain with the `keep` status remains as shown below: + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME +... STATUS +acctg 1481559303348 ... 1481554203288 2016-12-12 11:15:03 EST +... keep +acctg 1481554203288 ... 1481553651165 2016-12-12 09:50:03 EST +... keep +acctg 1481553651165 ... none 2016-12-12 09:40:51 EST +... keep +``` diff --git a/product_docs/docs/bart/2.5/bart_ref/03_sample_bart_system_with_local_and_remote_database_servers.mdx b/product_docs/docs/bart/2.5/bart_ref/03_sample_bart_system_with_local_and_remote_database_servers.mdx new file mode 100644 index 00000000000..a383fec90bf --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_ref/03_sample_bart_system_with_local_and_remote_database_servers.mdx @@ -0,0 +1,1385 @@ +--- +title: "Sample BART System with Local and Remote Database Servers" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/sample_bart_system_with_local_and_remote_database_servers.html" +--- + + + +This section describes a sample BART managed backup and recovery system consisting of both local and remote database servers. The complete steps to configure and operate the system are provided. + +For detailed information about configuring a BART system, see the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/2.5/bart_inst/). For detailed information about the operational procedures and BART subcommands, see the *EDB Backup and Recovery User Guide* available at the [EDB website](/bart/2.5/bart_user/). + +The environment for this sample system is as follows: + +- BART on host `192.168.2.22` running with BART user account `enterprisedb` +- Local Advanced Server on host `192.168.2.22` running with user account `enterprisedb` +- Remote Advanced Server on host `192.168.2.24` running with user account `enterprisedb` +- Remote PostgreSQL server on host `192.168.2.24` running with user account `postgres` + +Passwordless SSH/SCP connections are required between the following: + +- BART on host `192.168.2.22` and the local Advanced Server on the same host `192.168.2.22` +- BART on host `192.168.2.22` and the remote Advanced Server on host `192.168.2.24` +- BART on host `192.168.2.22` and the remote PostgreSQL server on host `192.168.2.24` + +The following sections demonstrate configuring and taking full backups only. To support incremental backups as well, enable the `allow_incremental_backups` parameter for the desired database servers and use the `WAL scanner` program. + +- [The BART Configuration File](#bart_configuration_file) shows the settings used in the BART configuration file. +- [Establishing SSH/SCP Passwordless Connections](#establishing-sshscp-passwordless-connections) provides an example of how to establish an SSH/SCP passwordless connection. +- [Configuring a Replication Database User](#configuring-a-replication-database-user) provides an example of how to configure the replication database user. +- [WAL Archiving Configuration Parameters](#wal-archiving-configuration-parameters) provides an example of how to configure WAL archiving. +- [Creating the BART Backup Catalog](#creating-the-bart-backup-catalog-backup_path) provides information about creating a BART Backup Catalog. +- [Starting the Database Servers with WAL Archiving](#starting-the-database-servers-with-wal-archiving) provides example of starting the database servers with WAL archiving. +- [Taking a Full Backup](#taking-a-full-backup) illustrates taking the first full backup of the database servers. +- [Using Point-In-Time Recovery](#using-point-in-time-recovery) demonstrates the point-in-time recovery operation on the remote PostgreSQL database server. + + + +## The BART Configuration File + +The following code sample shows the settings used in the BART configuration file for the examples that follow: + +```text +[BART] +bart_host= enterprisedb@192.168.2.22 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +retention_policy = 6 BACKUPS +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log + +[ACCTG] +host = 127.0.0.1 +port = 5444 +user = enterprisedb +cluster_owner = enterprisedb +backup_name = acctg_%year-%month-%dayT%hour:%minute +archive_command = 'cp %p %a/%f' +description = "Accounting" + +[MKTG] + +host = 192.168.2.24 +port = 5444 +user = repuser +cluster_owner = enterprisedb +backup_name = mktg_%year-%month-%dayT%hour:%minute +remote_host = enterprisedb@192.168.2.24 +description = "Marketing" + +[HR] + +host = 192.168.2.24 +port = 5432 +user = postgres +cluster_owner = postgres +backup_name = hr_%year-%month-%dayT%hour:%minute +remote_host = postgres@192.168.2.24 +copy_wals_during_restore = enabled +description = "Human Resources" +``` + + + +## Establishing SSH/SCP Passwordless Connections + +This section demonstrates how passwordless SSH/SCP connections are established with the authorized public keys files. + + + +### Generating a Public Key File for the BART User Account + +The BART user account is `enterprisedb` with a home directory of `/opt/PostgresPlus/9.6AS`. + +To generate the public key file, as a root user, first create the `.ssh` subdirectory in the BART user’s home directory and assign ownership of this directory to the `enterprisedb` user, ensuring there are no groups or other users that can access the `.ssh` directory. + +```text +[root@localhost 9.6AS]# pwd +/opt/PostgresPlus/9.6AS +[root@localhost 9.6AS]# mkdir .ssh +[root@localhost 9.6AS]# chown enterprisedb .ssh +[root@localhost 9.6AS]# chgrp enterprisedb .ssh +[root@localhost 9.6AS]# chmod 700 .ssh +[root@localhost 9.6AS]# ls -la | grep ssh +drwx------ 2 enterprisedb enterprisedb 4096 Apr 23 13:02 .ssh +``` + +Generate the public key file: + +```text +[user@localhost ~]$ su - enterprisedb +Password: +-bash-4.1$ pwd +/opt/PostgresPlus/9.6AS +-bash-4.1$ ssh-keygen -t rsa +Generating public/private rsa key pair. +Enter file in which to save the key +(/opt/PostgresPlus/9.6AS/.ssh/id_rsa): +Enter passphrase (empty for no passphrase): +Enter same passphrase again: +Your identification has been saved in +/opt/PostgresPlus/9.6AS/.ssh/id_rsa. +Your public key has been saved in +/opt/PostgresPlus/9.6AS/.ssh/id_rsa.pub. +The key fingerprint is: +de:65:34:d6:b1:d2:32:3c:b0:43:c6:a3:c0:9f:f4:64 +enterprisedb@localhost.localdomain +The key's randomart image is: ++----[ RSA 2048]----+ +| . .+ . | +| o .oE+ o o | +| + * o.X + | +| + .+ * | +| S o | +| . . o | +| . . | +| + | +| | ++-------------------+ +``` + +The following are the resulting files. `id_rsa.pub` is the public key file of BART user account `enterprisedb`. + +```text +-bash-4.1$ ls -l .ssh +total 8 +-rw------- 1 enterprisedb enterprisedb 1675 Apr 23 13:04 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Apr 23 13:04 id_rsa.pub +``` + +### Configuring Access between Local Advanced Server and the BART Host + +Even when the Advanced Server database is on the same host as the BART user account, and the Advanced Server database cluster owner is also the BART user account (`enterprisedb` is this case), a passwordless SSH/SCP connection must be established from the same user account to itself. + +On the BART host where the public key file was just generated (as shown in [Generating a Public Key File for the BART User Account](#generating-a-public-key-file-for-the-bart-user-account)), create the authorized keys file by appending the public key file to any existing authorized keys file. + +Log into the BART host as the BART user account and append the public key file, `id_rsa.pub` onto the `authorized_keys` file in the same `.ssh` directory. + +```text +[user@localhost ~]$ su - enterprisedb +Password: +Last login: Thu Mar 23 10:27:35 EDT 2017 on pts/0 +-bash-4.2$ pwd +/opt/PostgresPlus/9.6AS +-bash-4.2$ ls -l .ssh +total 12 +-rw------- 1 enterprisedb enterprisedb 1675 Mar 23 09:54 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Mar 23 09:54 id_rsa.pub +-rw-r--r-- 1 enterprisedb enterprisedb 345 Mar 23 10:05 known_hosts +-bash-4.2$ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys +-bash-4.2$ ls -l .ssh +total 16 +-rw-rw-r-- 1 enterprisedb enterprisedb 416 Mar 23 10:33 authorized_keys +-rw------- 1 enterprisedb enterprisedb 1675 Mar 23 09:54 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Mar 23 09:54 id_rsa.pub +-rw-r--r-- 1 enterprisedb enterprisedb 345 Mar 23 10:05 known_hosts +``` + +The `authorized_keys` file must have file permission `600` as set by the following `chmod 600` command, or the passwordless connection will fail: + +```text +-bash-4.2$ chmod 600 ~/.ssh/authorized_keys +-bash-4.2$ ls -l .ssh +total 16 +-rw------- 1 enterprisedb enterprisedb 416 Mar 23 10:33 authorized_keys +-rw------- 1 enterprisedb enterprisedb 1675 Mar 23 09:54 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Mar 23 09:54 id_rsa.pub +-rw-r--r-- 1 enterprisedb enterprisedb 345 Mar 23 10:05 known_hosts +``` + +Test the passwordless connection. Use the `ssh` command to verify that you can access the same user account as you are currently logged in as (`enterprisedb`) without being prompted for a password: + +```text +-bash-4.2$ ssh enterprisedb@127.0.0.1 +Last login: Thu Mar 23 10:27:50 2017 +-bash-4.2$ exit +logout +Connection to 127.0.0.1 closed. +``` + +### Configuring Access from Remote Advanced Server to BART Host + +On the remote host `192.168.2.24`, create the public key file for the remote database server user account, `enterprisedb`, for access to the BART user account, `enterprisedb`, on the BART host 192.168.2.22. + +Create the `.ssh` directory for user account `enterprisedb` on the remote host: + +```text +[root@localhost 9.6AS]# pwd +/opt/PostgresPlus/9.6AS +[root@localhost 9.6AS]# mkdir .ssh +[root@localhost 9.6AS]# chown enterprisedb .ssh +[root@localhost 9.6AS]# chgrp enterprisedb .ssh +[root@localhost 9.6AS]# chmod 700 .ssh +[root@localhost 9.6AS]# ls -la | grep ssh +drwx------ 2 enterprisedb enterprisedb 4096 Apr 23 13:08 .ssh +``` + +Generate the public key file on the remote host for user account `enterprisedb`: + +```text +[user@localhost ~]$ su - enterprisedb +Password: +-bash-4.1$ ssh-keygen -t rsa +Generating public/private rsa key pair. +Enter file in which to save the key +(/opt/PostgresPlus/9.6AS/.ssh/id_rsa): +Enter passphrase (empty for no passphrase): +Enter same passphrase again: +Your identification has been saved in +/opt/PostgresPlus/9.6AS/.ssh/id_rsa. +Your public key has been saved in +/opt/PostgresPlus/9.6AS/.ssh/id_rsa.pub. +The key fingerprint is: +15:27:1e:1e:61:4b:48:66:67:0b:b2:be:fc:ea:ea:e6 +enterprisedb@localhost.localdomain +The key's randomart image is: ++--[ RSA 2048]---+ +| ..=.@.. | +| =.O O | +| . * | +| . . | +| . S | +| . . | +| o | +| . . | +| +Eoo.. | ++----------------+ +``` + +Copy the generated public key file, `id_rsa.pub`, to the BART user account, `enterprisedb`, on the BART host, `192.168.2.22`: + +```text +-bash-4.1$ scp ~/.ssh/id_rsa.pub enterprisedb@192.168.2.22:/tmp/tmp.pub +The authenticity of host '192.168.2.22 (192.168.2.22)' can't be +established. +RSA key fingerprint is b8:a9:97:31:79:16:b8:2b:b0:60:5a:91:38:d7:68:22. +Are you sure you want to continue connecting (yes/no)? yes +Warning: Permanently added '192.168.2.22' (RSA) to the list of known hosts. +enterprisedb@192.168.2.22's password: +id_rsa.pub +``` + +Log into the BART host as the BART user account and append the temporary public key file, `/tmp/tmp.pub` onto the `authorized_keys` file owned by the BART user account. + +```text +-bash-4.1$ ssh enterprisedb@192.168.2.22 +enterprisedb@192.168.2.22's password: +Last login: Tue Apr 21 17:03:24 2015 from 192.168.2.22 +-bash-4.1$ pwd +/opt/PostgresPlus/9.6AS +-bash-4.1$ cat /tmp/tmp.pub >> ~/.ssh/authorized_keys +-bash-4.1$ ls -l .ssh +total 12 +-rw-rw-r-- 1 enterprisedb enterprisedb 416 Apr 23 13:15 authorized_keys +-rw------- 1 enterprisedb enterprisedb 1675 Apr 23 13:04 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Apr 23 13:04 id_rsa.pub +``` + +The `authorized_keys` file must have file permission `600` as set by the following `chmod 600` command, otherwise the passwordless connection fails: + +```text +-bash-4.1$ chmod 600 ~/.ssh/authorized_keys +-bash-4.1$ ls -l .ssh +total 12 +-rw------- 1 enterprisedb enterprisedb 416 Apr 23 13:15 authorized_keys +-rw------- 1 enterprisedb enterprisedb 1675 Apr 23 13:04 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Apr 23 13:04 id_rsa.pub +-bash-4.1$ rm /tmp/tmp.pub +-bash-4.1$ exit +logout +Connection to 192.168.2.22 closed. +``` + +Test the passwordless connection. From the remote host, verify that you can log into the BART host with the BART user account without being prompted for a password: + +```text +-bash-4.1$ ssh enterprisedb@192.168.2.22 +Last login: Thu Apr 23 13:14:48 2015 from 192.168.2.24 +-bash-4.1$ exit +logout +Connection to 192.168.2.22 closed. +``` + +### Configuring Access from the BART Host to a Remote Advanced Server + +On the BART host `192.168.2.22`, copy the public key file for the BART user account, `enterprisedb`, for access to the remote database server user account, `enterprisedb`, on the remote host `192.168.2.24`. + +The following lists the current SSH keys files in the BART user’s `.ssh` directory on the BART host: + +```text +[user@localhost ~]$ su - enterprisedb +Password: +-bash-4.1$ pwd +/opt/PostgresPlus/9.6AS +-bash-4.1$ ls -l .ssh +total 12 +-rw------- 1 enterprisedb enterprisedb 416 Apr 23 13:15 authorized_keys +-rw------- 1 enterprisedb enterprisedb 1675 Apr 23 13:04 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Apr 23 13:04 id_rsa.pub +``` + +The public key file, `id_rsa.pub`, for BART user account `enterprisedb` on the BART host that was earlier generated in [Generating a Public Key File for the BART User Account](#generating-a-public-key-file-for-the-bart-user-account), is now copied to the remote Advanced Server host on `192.168.2.24`: + +```text +-bash-4.1$ scp ~/.ssh/id_rsa.pub enterprisedb@192.168.2.24:/tmp/tmp.pub +The authenticity of host '192.168.2.24 (192.168.2.24)' can't be +established. +RSA key fingerprint is 59:41:fb:0c:ae:64:3d:3f:a2:d9:90:95:cf:2c:99:f2. +Are you sure you want to continue connecting (yes/no)? yes +Warning: Permanently added '192.168.2.24' (RSA) to the list of known +hosts. +enterprisedb@192.168.2.24's password: +id_rsa.pub +``` + +Log into the `enterprisedb` user account on the remote host and copy the public key file onto the `authorized_keys` file of the remote `enterprisedb` user account under its `.ssh` directory: + +```text +-bash-4.1$ ssh enterprisedb@192.168.2.24 +enterprisedb@192.168.2.24's password: +Last login: Tue Apr 21 09:53:18 2015 from 192.168.2.22 +-bash-4.1$ pwd +/opt/PostgresPlus/9.6AS +-bash-4.1$ ls -l .ssh +total 12 +-rw------- 1 enterprisedb enterprisedb 1675 Apr 23 13:11 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Apr 23 13:11 id_rsa.pub +-rw-r--r-- 1 enterprisedb enterprisedb 394 Apr 23 13:12 known_hosts +-bash-4.1$ cat /tmp/tmp.pub >> ~/.ssh/authorized_keys +``` + +Adjust the file permission on `authorized_keys`: + +```text +-bash-4.1$ chmod 600 ~/.ssh/authorized_keys +-bash-4.1$ ls -l .ssh +total 16 +-rw------- 1 enterprisedb enterprisedb 416 Apr 23 13:26 authorized_keys +-rw------- 1 enterprisedb enterprisedb 1675 Apr 23 13:11 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Apr 23 13:11 id_rsa.pub +-rw-r--r-- 1 enterprisedb enterprisedb 394 Apr 23 13:12 known_hosts +-bash-4.1$ rm /tmp/tmp.pub +-bash-4.1$ exit +logout +Connection to 192.168.2.24 closed. +``` + +While logged into the BART host, test the passwordless connection from the BART host to the remote Advanced Server host: + +```text +-bash-4.1$ ssh enterprisedb@192.168.2.24 +Last login: Thu Apr 23 13:25:53 2015 from 192.168.2.22 +-bash-4.1$ exit +logout +Connection to 192.168.2.24 closed. +``` + +### Configuring Access from a Remote PostgreSQL Server to a BART Host + +On the remote host (192.168.2.24), create a public key file owned by the database server user account (`postgres`), allowing access to the BART user account (`enterprisedb`) on the BART host (192.168.2.22). + +Create the `.ssh` directory for the `postgres` user account on the remote host: + +```text +[root@localhost 9.6]# cd /opt/PostgreSQL/9.6 +[root@localhost 9.6]# mkdir .ssh +[root@localhost 9.6]# chown postgres .ssh +[root@localhost 9.6]# chgrp postgres .ssh +[root@localhost 9.6]# chmod 700 .ssh +[root@localhost 9.6]# ls -la | grep ssh +drwx------ 2 postgres postgres 4096 Apr 23 13:32 .ssh +``` + +Create and copy the generated public key file, `id_rsa.pub`, to the BART user account (`enterprisedb`), on the BART host (`192.168.2.22`): + +```text +[user@localhost ~]$ su - postgres +Password: +-bash-4.1$ pwd +/opt/PostgreSQL/9.6 +-bash-4.1$ ssh-keygen -t rsa +Generating public/private rsa key pair. +Enter file in which to save the key (/opt/PostgreSQL/9.6/.ssh/id_rsa): +Enter passphrase (empty for no passphrase): +Enter same passphrase again: +Your identification has been saved in /opt/PostgreSQL/9.6/.ssh/id_rsa. +Your public key has been saved in /opt/PostgreSQL/9.6/.ssh/id_rsa.pub. +The key fingerprint is: +1f:f8:76:d6:fc:a5:1a:c5:5a:66:66:01:d0:a0:ca:ba +postgres@localhost.localdomain +The key's randomart image is: ++--[ RSA 2048]----+ +| o+. | +| . .. | +| . . | +| . . . . . | +| o S . O | +| . o . @ | +| . + = o .| +| . . o . o.| +| E ... .| ++-----------------+ +-bash-4.1$ ls -l .ssh +total 8 +-rw------- 1 postgres postgres 1671 Apr 23 13:36 id_rsa +-rw-r--r-- 1 postgres postgres 412 Apr 23 13:36 id_rsa.pub +-bash-4.1$ scp ~/.ssh/id_rsa.pub enterprisedb@192.168.2.22:/tmp/tmp.pub +The authenticity of host '192.168.2.22 (192.168.2.22)' can't be +established. +RSA key fingerprint is b8:a9:97:31:79:16:b8:2b:b0:60:5a:91:38:d7:68:22. +Are you sure you want to continue connecting (yes/no)? yes +Warning: Permanently added '192.168.2.22' (RSA) to the list of known +hosts. +enterprisedb@192.168.2.22's password: +id_rsa.pub +``` + +Log into the BART host as the BART user account and append the temporary public key file, `/tmp/tmp.pub`, onto the `authorized_keys` file owned by the BART user account. + +```text +-bash-4.1$ ssh enterprisedb@192.168.2.22 +enterprisedb@192.168.2.22's password: +Last login: Thu Apr 23 13:19:25 2015 from 192.168.2.24 +-bash-4.1$ pwd +/opt/PostgresPlus/9.6AS +-bash-4.1$ cat /tmp/tmp.pub >> ~/.ssh/authorized_keys +-bash-4.1$ ls -l .ssh +total 16 +-rw------- 1 enterprisedb enterprisedb 828 Apr 23 13:40 authorized_keys +-rw------- 1 enterprisedb enterprisedb 1675 Apr 23 13:04 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Apr 23 13:04 id_rsa.pub +-rw-r--r-- 1 enterprisedb enterprisedb 394 Apr 23 13:24 known_hosts +-bash-4.1$ rm /tmp/tmp.pub +-bash-4.1$ exit +logout +Connection to 192.168.2.22 closed. +``` + +Make sure the `authorized_keys` file has file permission 600 as shown, or the passwordless connection will fail. Test the passwordless connection; from the remote host, while logged in as user account `postgres`, verify that you can log into the BART host with the BART user account without being prompted for a password: + +```text +-bash-4.1$ pwd +/opt/PostgreSQL/9.6 +-bash-4.1$ ssh enterprisedb@192.168.2.22 +Last login: Thu Apr 23 13:40:10 2015 from 192.168.2.24 +-bash-4.1$ exit +logout +Connection to 192.168.2.22 closed. +``` + +### Configuring Access from the BART Host to Remote PostgreSQL + +Copy the public key file on the BART host that is owned by the BART user account (`enterprisedb`) to the remote database server user account (`postgres`), on the remote host (192.168.2.24). + +The following lists the current SSH keys files in the BART user’s `.ssh` directory on the BART host: + +```text +[user@localhost ~]$ su - enterprisedb +Password: +-bash-4.1$ ls -l .ssh +total 16 +-rw------- 1 enterprisedb enterprisedb 828 Apr 23 13:40 authorized_keys +-rw------- 1 enterprisedb enterprisedb 1675 Apr 23 13:04 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Apr 23 13:04 id_rsa.pub +-rw-r--r-- 1 enterprisedb enterprisedb 394 Apr 23 13:24 known_hosts +``` + +The public key file, `id_rsa.pub`, for BART user account `enterprisedb` on the BART host that was earlier generated in [Generating a Public Key File for the BART User Account](#generating-a-public-key-file-for-the-bart-user-account), now resides on the remote PostgreSQL host: + +```text +-bash-4.1$ scp ~/.ssh/id_rsa.pub postgres@192.168.2.24:/tmp/tmp.pub +postgres@192.168.2.24's password: +id_rsa.pub +``` + +Log into the `postgres` user account on the remote host and copy the public key file onto the `authorized_keys` file of `postgres` under its `.ssh` directory: + +```text +-bash-4.1$ ssh postgres@192.168.2.24 +postgres@192.168.2.24's password: +Last login: Mon Jan 26 18:08:36 2015 from 192.168.2.19 +-bash-4.1$ pwd +/opt/PostgreSQL/9.6 +-bash-4.1$ cat /tmp/tmp.pub >> ~/.ssh/authorized_keys +``` + +Adjust the file permissions on `authorized_keys`: + +```text +-bash-4.1$ ls -l .ssh +total 16 +-rw-rw-r-- 1 postgres postgres 416 Apr 23 13:52 authorized_keys +-rw------- 1 postgres postgres 1671 Apr 23 13:36 id_rsa +-rw-r--r-- 1 postgres postgres 412 Apr 23 13:36 id_rsa.pub +-rw-r--r-- 1 postgres postgres 394 Apr 23 13:36 known_hosts +-bash-4.1$ chmod 600 ~/.ssh/authorized_keys +-bash-4.1$ ls -l .ssh +total 16 +-rw------- 1 postgres postgres 416 Apr 23 13:52 authorized_keys +-rw------- 1 postgres postgres 1671 Apr 23 13:36 id_rsa +-rw-r--r-- 1 postgres postgres 412 Apr 23 13:36 id_rsa.pub +-rw-r--r-- 1 postgres postgres 394 Apr 23 13:36 known_hosts +-bash-4.1$ rm /tmp/tmp.pub +-bash-4.1$ exit +logout +Connection to 192.168.2.24 closed. +``` + +Test the passwordless connection from the BART host to the remote PostgreSQL host: + +```text +[user@localhost ~]$ su - enterprisedb +Password: +-bash-4.1$ ssh postgres@192.168.2.24 +Last login: Thu Apr 23 13:52:25 2015 from 192.168.2.22 +-bash-4.1$ exit +logout +Connection to 192.168.2.24 closed. +``` + + + +## Configuring a Replication Database User + +This section demonstrates how a replication database user is established. + +**All database servers must use a superuser as the replication database user.** + +The replication database user for each database server is specified by the `user` parameter in the BART configuration file as shown by the following: + +```text +[ACCTG] + +host = 127.0.0.1 +port = 5444 +user = enterprisedb <=== Replication Database User +cluster_owner = enterprisedb +backup_name = acctg_%year-%month-%dayT%hour:%minute +archive_command = 'cp %p %a/%f' +description = "Accounting" + +[MKTG] +host = 192.168.2.24 +port = 5444 +user = repuser <=== Replication Database User +cluster_owner = enterprisedb +backup_name = mktg_%year-%month-%dayT%hour:%minute +remote_host = enterprisedb@192.168.2.24 +description = "Marketing" + +[HR] + +host = 192.168.2.24 +port = 5432 +user = postgres <=== Replication Database User +cluster_owner = enterprisedb +backup_name = hr_%year-%month-%dayT%hour:%minute +remote_host = postgres@192.168.2.24 +copy_wals_during_restore = enabled +description = "Human Resources" +``` + +Add entries to the `.pgpass` file on each server to allow the BART user account to initiate a backup without being prompted for credentials. The `.pgpass` file is located in `/opt/PostgresPlus/9.6AS/.pgpass`: + +```text +127.0.0.1:5444:*:enterprisedb:password +192.168.2.24:5444:*:repuser:password +192.168.2.24:5432:*:postgres:password +``` + +For more information about using a `.pgpass` file, please see the [PostgreSQL documentation](https://www.postgresql.org/docs/12/libpq-pgpass.html). + +While connected to `MKTG` on 192.168.2.24, execute the following `CREATE ROLE` command to create the replication database superuser: + +```text +CREATE ROLE repuser WITH LOGIN SUPERUSER PASSWORD 'password'; +``` + +Access is granted in the `pg_hba.conf` file for the local Advanced Server: + +```text +# TYPE DATABASE USER ADDRESS METHOD +# "local" is for Unix domain socket connections only +local all all md5 +# IPv4 local connections: +host template1 enterprisedb 127.0.0.1/32 md5 +host edb enterprisedb 127.0.0.1/32 md5 +#host all all 127.0.0.1/32 md5 +# IPv6 local connections: +host all all ::1/128 md5 +# Allow replication connections from localhost, by a user with the +# replication privilege. +#local replication enterprisedb md5 +host replication enterprisedb 127.0.0.1/32 md5 +``` + +Similarly, access is granted in the `pg_hba.conf` file for the remote Advanced Server installation: + +```text +# TYPE DATABASE USER ADDRESS METHOD +# "local" is for Unix domain socket connections only +local all all md5 +# IPv4 local connections: +host template1 repuser 192.168.2.22/32 md5 +host all enterprisedb 127.0.0.1/32 md5 +#host all all 127.0.0.1/32 md5 +# IPv6 local connections: +host all all ::1/128 md5 +# Allow replication connections from localhost, by a user with the +# replication privilege. +#local replication enterprisedb md5 +host replication repuser 192.168.2.22/32 md5 +``` + +Access is also granted in the `pg_hba.conf` file for the remote PostgreSQL server: + +```text +# TYPE DATABASE USER ADDRESS METHOD +# "local" is for Unix domain socket connections only +local all all md5 +# IPv4 local connections: +host template1 postgres 192.168.2.22/32 md5 +host all all 127.0.0.1/32 md5 +# IPv6 local connections: +host all all ::1/128 md5 +# Allow replication connections from localhost, by a user with the +q# replication privilege. +#local replication postgres md5 +host replication postgres 192.168.2.22/32 md5 +``` + + + +## WAL Archiving Configuration Parameters + +Use the following parameters in the `postgresql.conf` file to enable WAL archiving. The `postgresql.conf` file for the local Advanced Server database (`ACCTG`) is set as follows: + +```text +wal_level = archive +archive_mode = on # allows archiving to be done + # (change requires restart) +#archive_command = '' # command to use to archive + a logfile segment + # placeholders: %p = path of + file to archive + # %f = file name only +max_wal_senders = 3 +``` + +When the `INIT` subcommand is invoked, the Postgres `archive_command` configuration parameter in the `postgresql.auto.conf` file will be set based on the BART `archive_command` parameter located in the BART configuration file. + +!!! Note + If the Postgres `archive_command` is already set, invoke the `INIT` subcommand with the `-- no-configure` option to prevent the `archive_command` from being reset. For details, see [INIT](../bart_user/03_using_bart/03_basic_bart_subcommand_usage/02_init/#init). + +```text +[BART] +bart_host= enterprisedb@192.168.2.22 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +retention_policy = 6 BACKUPS +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log + +[ACCTG] +host = 127.0.0.1 +port = 5444 +user = enterprisedb +cluster_owner = enterprisedb +backup_name = acctg_%year-%month-%dayT%hour:%minute +archive_command = 'cp %p %a/%f' +description = "Accounting" +``` + +When the `INIT` subcommand is invoked, the `postgresql.auto.conf` file contains the following: + +```text +# Do not edit this file manually! +# It will be overwritten by ALTER SYSTEM command. +archive_command = 'cp %p /opt/backup/acctg/archived_wals/%f' +``` + +The `archive_command` uses the `cp` command instead of `scp` since the BART backup catalog is local to this database cluster and the BART user account (the account that owns the backup catalog, `enterprisedb`), is the same user account running Advanced Server. The result is that there is no directory permission conflict during the archive operation. + +The `postgresql.conf` file for the remote Advanced Server, `MKTG` is set as follows: + +```text +wal_level = archive +archive_mode = on # allows archiving to be done + # (change requires restart) +archive_command = '' # command to use to archive a + logfile segment + # placeholders: %p = path of + file to archive + # %f = file name only +max_wal_senders = 3 +``` + +When the `INIT` subcommand is invoked, the Postgres `archive_command` configuration parameter in the `postgresql.auto.conf` file will be set by the default BART format of the BART `archive_command` parameter (since it is not explicitly set for this database server in the BART configuration file). + +```text +[BART] +bart_host= enterprisedb@192.168.2.22 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +retention_policy = 6 BACKUPS +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log +. +. +. +[MKTG] + +host = 192.168.2.24 +port = 5444 +user = repuser +cluster_owner = enterprisedb +backup_name = mktg_%year-%month-%dayT%hour:%minute +remote_host = enterprisedb@192.168.2.24 +description = "Marketing" +``` + +The default BART `archive_command` format is: + +```text +archive_command = 'scp %p %h:%a/%f' +``` + +The `postgresql.auto.conf` file contains the following after the `INIT` subcommand is invoked: + +```text +# Do not edit this file manually! +# It will be overwritten by ALTER SYSTEM command. +archive_command = 'scp %p +enterprisedb@192.168.2.22:/opt/backup/hr/archived_wals/%f' +``` + +The `archive_command` uses the `scp` command since the BART backup catalog is remote relative to this database cluster. The BART user account, `enterprisedb`, is specified on the `scp` command since this is the user account owning the BART backup catalog where the archived WAL files are to be copied. The result is that there is no directory permission conflict during the archive operation. + +The `postgresql.conf` file for the remote PostgreSQL server (`HR`) is set as follows: + +```text +wal_level = archive +archive_mode = on # allows archiving to be done + # (change requires restart) +#archive_command = '' # command to use to archive a + logfile segment + # placeholders: %p = path of + file to archive + # %f = file name only +max_wal_senders = 3 +``` + +When the `INIT` subcommand is invoked, the Postgres `archive_command` configuration parameter in the `postgresql.auto.conf` file will be set by the default BART format of the BART `archive_command` parameter (since it is not explicitly set for this database server in the BART configuration file): + +```text +[BART] + +bart_host= enterprisedb@192.168.2.22 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +retention_policy = 6 BACKUPS +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log +. +. +. +[HR] + +host = 192.168.2.24 +port = 5432 +user = postgres +cluster_owner = postgres +backup_name = hr_%year-%month-%dayT%hour:%minute +remote_host = postgres@192.168.2.24 +copy_wals_during_restore = enabled +description = "Human Resources" +``` + +The default BART `archive_command` format is: + +```text +archive_command = 'scp %p %h:%a/%f' +``` + +The `postgresql.auto.conf` file contains the following after the `INIT` subcommand is invoked: + +```text +# Do not edit this file manually! +# It will be overwritten by ALTER SYSTEM command. +archive_command = 'scp %p +enterprisedb@192.168.2.22:/opt/backup/hr/archived_wals/%f' +``` + +The `archive_command` uses the `scp` command since the BART backup catalog is remote relative to this database cluster. The BART user account, `enterprisedb`, is specified on the `scp` command since this is the user account owning the BART backup catalog where the archived WAL files are to be copied. The result is that there is no directory permission conflict during the archive operation. + + + +## Creating the BART Backup Catalog (backup_path) + +Create the directory specified by the `backup_path` configuration parameter. + +```text +[BART] + +bart_host= enterprisedb@192.168.2.22 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +retention_policy = 6 BACKUPS +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log +``` + +Ensure that the directory is owned by the BART user account: + +```text +[root@localhost opt]# pwd +/opt +[root@localhost opt]# mkdir backup +[root@localhost opt]# chown enterprisedb backup +[root@localhost opt]# chgrp enterprisedb backup +[root@localhost opt]# chmod 700 backup +[root@localhost opt]# ls -l | grep backup +drwx------ 2 enterprisedb enterprisedb 4096 Apr 23 15:36 backup +``` + +Use the BART `INIT` subcommand to complete the directory structure and set the Postgres `archive_command` configuration parameter. + +Before invoking any BART subcommands, set up a profile under the BART user account’s home directory to set the `LD_LIBRARY_PATH` and `PATH` environment variables. For more information regarding setting this variable, see the EDB Backup and Recovery Installation and Upgrade Guide available at the [EDB website](/bart/2.5/bart_inst/). + +The `-o` option is specified with the `INIT` subcommand to force the setting of the Postgres `archive_command` configuration parameter when `archive_mode` is `off` or if the Postgres `archive_command` parameter is already set and needs to be overridden. + +```text +[user@localhost ~]$ su - enterprisedb +Password: +-bash-4.1$ bart INIT -o +INFO: setting archive_command for server 'acctg' +WARNING: archive_command is set. server restart is required +INFO: setting archive_command for server 'hr' +WARNING: archive_command is set. server restart is required +INFO: setting archive_command for server 'mktg' +WARNING: archive_command is set. server restart is required +``` + +The BART `SHOW-SERVERS` subcommand displays the following: + +```text +-bash-4.1$ bart SHOW-SERVERS +SERVER NAME : acctg +BACKUP FRIENDLY NAME: acctg_%year-%month-%dayT%hour:%minute +HOST NAME : 127.0.0.1 +USER NAME : enterprisedb +PORT : 5444 +REMOTE HOST : +RETENTION POLICY : 6 Backups +DISK UTILIZATION : 0.00 bytes +NUMBER OF ARCHIVES : 0 +ARCHIVE PATH : /opt/backup/acctg/archived_wals +ARCHIVE COMMAND : (disabled) +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +INCREMENTAL BACKUP : DISABLED +DESCRIPTION : "Accounting" +SERVER NAME : hr +BACKUP FRIENDLY NAME: hr_%year-%month-%dayT%hour:%minute +HOST NAME : 192.168.2.24 +USER NAME : postgres +PORT : 5432 +REMOTE HOST : postgres@192.168.2.24 +RETENTION POLICY : 6 Backups +DISK UTILIZATION : 0.00 bytes +NUMBER OF ARCHIVES : 0 +ARCHIVE PATH : /opt/backup/hr/archived_wals +ARCHIVE COMMAND : (disabled) +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +INCREMENTAL BACKUP : DISABLED +DESCRIPTION : "Human Resources" +SERVER NAME : mktg +BACKUP FRIENDLY NAME: mktg_%year-%month-%dayT%hour:%minute +HOST NAME : 192.168.2.24 +USER NAME : repuser +PORT : 5444 +REMOTE HOST : enterprisedb@192.168.2.24 +RETENTION POLICY : 6 Backups +DISK UTILIZATION : 0.00 bytes +NUMBER OF ARCHIVES : 0 +ARCHIVE PATH : /opt/backup/mktg/archived_wals +ARCHIVE COMMAND : (disabled) +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +INCREMENTAL BACKUP : DISABLED +DESCRIPTION : "Marketing" +-bash-4.1$ cd /opt/backup +-bash-4.1$ pwd +/opt/backup +-bash-4.1$ ls -l +total 12 +drwxrwxr-x 3 enterprisedb enterprisedb 4096 Mar 29 13:16 acctg +drwxrwxr-x 3 enterprisedb enterprisedb 4096 Mar 29 13:16 hr +drwxrwxr-x 3 enterprisedb enterprisedb 4096 Mar 29 13:16 mktg +-bash-4.1$ ls -l acctg +total 4 +drwxrwxr-x 2 enterprisedb enterprisedb 4096 Mar 29 13:16 archived_wals +-bash-4.1$ ls -l hr +total 4 +drwxrwxr-x 2 enterprisedb enterprisedb 4096 Mar 29 13:16 archived_wals +-bash-4.1$ ls -l mktg +total 4 +drwxrwxr-x 2 enterprisedb enterprisedb 4096 Mar 29 13:16 archived_wals +``` + +The `ARCHIVE PATH` field displays the full directory path to where the WAL files are copied. This directory path must match the directory path specified in the Postgres `archive_command` parameter of the `postgresql.conf` file or the `postgresql.auto.conf` file of each database server. + + + +### Starting the Database Servers with WAL Archiving + +After the BART backup catalog directory structure has been configured, start the archiving of WAL files from the database servers by restarting each database server. + +On BART host 192.168.2.22: + +```text +[root@localhost data]# service ppas-9.6 restart +``` + +On remote host 192.168.2.24: + +```text +[root@localhost data]# service ppas-9.6 restart + +[root@localhost data]# service postgresql-9.6 restart +``` + +In the BART backup catalog, verify that the WAL files are archiving. + +Archived WAL files may not appear very frequently depending upon how often WAL archiving is set to switch to a new segment file with the `archive_timeout` parameter in your database server configuration settings. + +Verify that there are no archiving-related errors in the database server log files. + +## Taking a Full Backup + +The following code sample shows the first full backup of the database servers. + +```text +-bash-4.1$ bart BACKUP -s acctg -z +INFO: creating backup for server 'acctg' +INFO: backup identifier: '1490809695281' +60776/60776 kB (100%), 1/1 tablespace + +INFO: backup completed successfully +INFO: backup checksum: 37f3defb98ca88dcf05079815555dfc2 of base.tar.gz +INFO: +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1490809695281 +BACKUP NAME: acctg_2017-03-29T13:48 +BACKUP PARENT: none +BACKUP LOCATION: /opt/backup/acctg/1490809695281 +BACKUP SIZE: 6.10 MB +BACKUP FORMAT: tar.gz +BACKUP TIMEZONE: US/Eastern +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 1 +ChkSum File +37f3defb98ca88dcf05079815555dfc2 base.tar.gz + +TABLESPACE(s): 0 +START WAL LOCATION: 000000010000000000000004 +STOP WAL LOCATION: 000000010000000000000004 +BACKUP METHOD: streamed +BACKUP FROM: primary +START TIME: 2017-03-29 13:48:15 EDT +STOP TIME: 2017-03-29 13:48:17 EDT +TOTAL DURATION: 2 sec(s) + +-bash-4.1$ bart BACKUP -s mktg -z +INFO: creating backup for server 'mktg' +INFO: backup identifier: '1490809751193' +61016/61016 kB (100%), 1/1 tablespace + +INFO: backup completed successfully +INFO: backup checksum: 8b010e130a105e76d01346bb56dfcf14 of base.tar.gz +INFO: +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1490809751193 +BACKUP NAME: mktg_2017-03-29T13:49 +BACKUP PARENT: none +BACKUP LOCATION: /opt/backup/mktg/1490809751193 +BACKUP SIZE: 6.13 MB +BACKUP FORMAT: tar.gz +BACKUP TIMEZONE: US/Eastern +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 1 +ChkSum File +8b010e130a105e76d01346bb56dfcf14 base.tar.gz + +TABLESPACE(s): 0 +START WAL LOCATION: 000000010000000100000085 +BACKUP METHOD: streamed +BACKUP FROM: primary +START TIME: 2017-03-29 13:49:11 EDT +STOP TIME: 2017-03-29 13:49:14 EDT +TOTAL DURATION: 3 sec(s) + +-bash-4.1$ bart BACKUP -s hr -z +INFO: creating backup for server 'hr' +INFO: backup identifier: '1490809824946' +38991/38991 kB (100%), 1/1 tablespace +INFO: backup completed successfully +INFO: backup checksum: 277e8a1a80ba3474f541eb316a417c9a of base.tar.gz +INFO: +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1490809824946 +BACKUP NAME: hr_2017-03-29T13:50 +BACKUP PARENT: none +BACKUP LOCATION: /opt/backup/hr/1490809824946 +BACKUP SIZE: 2.59 MB +BACKUP FORMAT: tar.gz +BACKUP TIMEZONE: US/Eastern +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 1 +ChkSum File +277e8a1a80ba3474f541eb316a417c9a base.tar.gz + +TABLESPACE(s): 0 +START WAL LOCATION: 000000010000000000000002 +BACKUP METHOD: streamed +BACKUP FROM: primary +START TIME: 2017-03-29 13:50:25 EDT +STOP TIME: 2017-03-29 13:50:26 EDT +TOTAL DURATION: 1 sec(s) +``` + +The following code sample shows the backup directories created for each backup of each database server. The backup ID is used as the backup directory name. + +```text +-bash-4.1$ cd /opt/backup +-bash-4.1$ ls -l +total 12 +drwxrwxr-x 4 enterprisedb enterprisedb 4096 Mar 29 13:48 acctg +drwxrwxr-x 4 enterprisedb enterprisedb 4096 Mar 29 13:50 hr +drwxrwxr-x 4 enterprisedb enterprisedb 4096 Mar 29 13:49 mktg +-bash-4.1$ ls -l acctg +total 8 +drwx------ 2 enterprisedb enterprisedb 4096 Mar 29 13:48 1490809695281 +drwxrwxr-x 2 enterprisedb enterprisedb 4096 Mar 29 13:48 archived_wals +-bash-4.1$ ls -l hr +total 8 +drwx------ 2 enterprisedb enterprisedb 4096 Mar 29 13:50 1490809824946 +drwxrwxr-x 2 enterprisedb enterprisedb 4096 Mar 29 13:50 archived_wals +-bash-4.1$ ls -l mktg +total 8 +drwx------ 2 enterprisedb enterprisedb 4096 Mar 29 13:49 1490809751193 +drwxrwxr-x 2 enterprisedb enterprisedb 4096 Mar 29 13:49 archived_wals +``` + + + +## Using Point-In-Time Recovery + +This section demonstrates using the point-in-time recovery operation on the remote PostgreSQL database server. + +The following tables were created about two minutes apart with WAL archiving enabled: + +```text +postgres=# \dt + + List of relations +Schema | Name | Type | Owner + +--------+----------------+---------+--------- +public | hr_rmt_t1_1356 | table | postgres +public | hr_rmt_t1_1358 | table | postgres +public | hr_rmt_t1_1400 | table | postgres +public | hr_rmt_t1_1402 | table | postgres +public | hr_rmt_t1_1404 | table | postgres +public | hr_rmt_t1_1406 | table | postgres +(6 rows) +``` + +In the table name `hr_rmt_t_, n` represents the active timeline. `` is the approximate time the table was created. For example, `hr_rmt_t1_1356` was created at approximately 1:56 PM while timeline #1 is active. + +The PostgreSQL database server was then stopped. WAL files that have been created, but not yet archived must be identified, and then saved. The following archived WAL files are in the BART backup catalog: + +```text +-bash-4.1$ ls -l hr/archived_wals +total 49156 +-rw------- 1 enterprisedb enterprisedb 16777216 Mar 29 13:50 +000000010000000000000001 +-rw------- 1 enterprisedb enterprisedb 16777216 Mar 29 13:50 +000000010000000000000002 +-rw------- 1 enterprisedb enterprisedb 302 Mar 29 13:50 +000000010000000000000002.00000028.backup +-rw------- 1 enterprisedb enterprisedb 16777216 Mar 29 14:07 +000000010000000000000003 +``` + +The following sample lists the current PostgreSQL server WAL files. The unarchived WAL files are marked with two stars (\*\*). + +```text +-bash-4.1$ cd /opt/PostgreSQL/9.6/data/pg_xlog +-bash-4.1$ pwd +/opt/PostgreSQL/9.6/data/pg_xlog +-bash-4.1$ ls -l +total 49160 +-rw------- 1 postgres postgres 302 Mar 29 13:50 +000000010000000000000002.00000028.backup +-rw------- 1 postgres postgres 16777216 Mar 29 14:07 +000000010000000000000003 +-rw------- 1 postgres postgres 16777216 Mar 29 14:07 +**000000010000000000000004** +-rw------- 1 postgres postgres 16777216 Mar 29 13:50 +**000000010000000000000005** +drwx------ 2 postgres postgres 4096 Mar 29 14:07 archive_status +``` + +Copies of the unarchived WAL files are saved to a temporary location: + +```text +-bash-4.1$ mkdir /tmp/unarchived_pg96_wals +-bash-4.1$ pwd +/opt/PostgreSQL/9.6/data/pg_xlog +bash-4.1$ cp -p 000000010000000000000004 /tmp/unarchived_pg96_wals +bash-4.1$ cp -p 000000010000000000000005 /tmp/unarchived_pg96_wals +bash-4.1$ ls -l /tmp/unarchived_pg96_wals +total 32768 +-rw------- 1 postgres postgres 16777216 Mar 29 14:07 000000010000000000000004 +-rw------- 1 postgres postgres 16777216 Mar 29 13:50 000000010000000000000005 +``` + +On the remote host, a directory is created to which the PostgreSQL database cluster is to be restored. This restore path is named `/opt/restore_pg96` and is owned by user account `postgres`. + +```text +[user@localhost ~]$ su root +Password: +[root@localhost user]# cd /opt +[root@localhost opt]# mkdir restore_pg96 +[root@localhost opt]# chown postgres restore_pg96 +[root@localhost opt]# chgrp postgres restore_pg96 +[root@localhost opt]# chmod 700 restore_pg96 +[root@localhost opt]# ls -l +total 16 +drwxr-xr-x 4 root daemon 4096 Mar 29 12:10 PostgresPlus +drwxr-xr-x 3 root daemon 4096 Mar 29 12:25 PostgreSQL +drwx------ 2 postgres postgres 4096 Mar 29 14:15 restore_pg96 +drwxr-xr-x. 2 root root 4096 Nov 22 2013 rh +``` + +In the BART configuration file, the remote user and remote host IP address, `postgres@192.168.2.24`, have been set with the `remote_host` parameter. If not given in the BART configuration file, this information must then be specified by the `--remote-host` option when giving the `RESTORE` subcommand (for example, `bart RESTORE --remote-host postgres@192.168.2.24 …`). + +```text +[HR] + +host = 192.168.2.24 +port = 5432 +user = postgres +cluster_owner = postgres +backup_name = hr_%year-%month-%dayT%hour:%minute +remote_host = postgres@192.168.2.24 +copy_wals_during_restore = enabled +description = "Human Resources" +``` + +Use the `SHOW-BACKUPS` subcommand to identify the backup to use with the `RESTORE` subcommand. + +```text +SERVER NAME BACKUP ID BACKUP NAME BACKUP PARENT +BACKUP TIME +BACKUP SIZE WAL(s) SIZE WAL FILES STATUS +acctg 1490809695281 acctg_2017-03-29T13:48 none +2017-03-29 13:48:17 EDT +6.10 MB 32.00 MB 2 active +hr 1490809824946 hr_2017-03-29T13:50 none +2017-03-29 13:50:26 EDT +2.59 MB 32.00 MB 2 active +mktg 1490809751193 mktg_2017-03-29T13:49 none +2017-03-29 13:49:14 EDT +6.13 MB 64.00 MB 4 active +``` + +The `-t` option with the `SHOW-BACKUPS` subcommand displays additional backup information: + +```text +-bash-4.1$ bart SHOW-BACKUPS -s hr -i 1490809824946 -t +SERVER NAME : hr +BACKUP ID : 1490809824946 +BACKUP NAME : hr_2017-03-29T13:50 +BACKUP PARENT : none +BACKUP STATUS : active +BACKUP TIME : 2017-03-29 13:50:26 EDT +BACKUP SIZE : 2.59 MB +WAL(S) SIZE : 32.00 MB +NO. OF WALS : 2 +FIRST WAL FILE : 000000010000000000000002 +CREATION TIME : 2017-03-29 13:50:31 EDT +LAST WAL FILE : 000000010000000000000003 +CREATION TIME : 2017-03-29 14:07:35 EDT +``` + +A recovery is made using timeline `1` to `2017-03-29 14:01:00`. + +```text +-bash-4.1$ bart RESTORE -s hr -i hr_2017-03-29T13:50 -p +/opt/restore_pg96 -t 1 -g '2017-03-29 14:01:00' +INFO: restoring backup 'hr_2017-03-29T13:50' of server 'hr' +INFO: base backup restored +INFO: copying WAL file(s) to +postgres@192.168.2.24:/opt/restore_pg96/archived_wals +INFO: writing recovery settings to postgresql.auto.conf file +INFO: archiving is disabled +INFO: permissions set on $PGDATA +INFO: restore completed successfully +``` + +The following example shows the restored backup files in the restore path directory, `/opt/restore_pg96`: + +```text +-bash-4.1$ pwd +/opt/restore_pg96 +-bash-4.1$ ls -l +total 128 +drwxr-xr-x 2 postgres postgres 4096 Mar 29 14:27 archived_wals +-rw------- 1 postgres postgres 206 Mar 29 13:50 backup_label +drwx------ 5 postgres postgres 4096 Mar 29 12:25 base +drwx------ 2 postgres postgres 4096 Mar 29 14:27 global +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_clog +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_commit_ts +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_dynshmem +-rw------- 1 postgres postgres 4212 Mar 29 13:18 pg_hba.conf +-rw------- 1 postgres postgres 1636 Mar 29 12:25 pg_ident.conf +drwxr-xr-x 2 postgres postgres 4096 Mar 29 13:45 pg_log +drwx------ 4 postgres postgres 4096 Mar 29 12:25 pg_logical +drwx------ 4 postgres postgres 4096 Mar 29 12:25 pg_multixact +drwx------ 2 postgres postgres 4096 Mar 29 13:43 pg_notify +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_replslot +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_serial +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_snapshots +drwx------ 2 postgres postgres 4096 Mar 29 13:43 pg_stat +drwx------ 2 postgres postgres 4096 Mar 29 13:50 pg_stat_tmp +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_subtrans +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_tblspc +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_twophase +-rw------- 1 postgres postgres 4 Mar 29 12:25 PG_VERSION +drwx------ 3 postgres postgres 4096 Mar 29 14:27 pg_xlog +-rw------- 1 postgres postgres 169 Mar 29 13:24 postgresql.auto.conf +-rw-r--r-- 1 postgres postgres 21458 Mar 29 14:27 postgresql.conf +-rw-r--r-- 1 postgres postgres 118 Mar 29 14:27 postgresql.auto.conf +``` + +Copy the saved, unarchived WAL files to the restore path `pg_xlog` subdirectory (`/opt/restore_pg96/pg_xlog`): + +```text +-bash-4.1$ pwd +/opt/restore_pg96/pg_xlog +-bash-4.1$ ls -l +total 16388 +-rw------- 1 postgres postgres 16777216 Mar 29 13:50 +000000010000000000000002 +drwx------ 2 postgres postgres 4096 Mar 29 14:27 archive_status +-bash-4.1$ ls -l /tmp/unarchived_pg96_wals +total 32768 +-rw------- 1 postgres postgres 16777216 Mar 29 14:07 +000000010000000000000004 +-rw------- 1 postgres postgres 16777216 Mar 29 13:50 +000000010000000000000005 +-bash-4.1$ cp -p /tmp/unarchived_pg96_wals/* . +-bash-4.1$ ls -l +total 49156 +-rw------- 1 postgres postgres 16777216 Mar 29 13:50 +000000010000000000000002 +-rw------- 1 postgres postgres 16777216 Mar 29 14:07 +000000010000000000000004 +-rw------- 1 postgres postgres 16777216 Mar 29 13:50 +000000010000000000000005 +drwx------ 2 postgres postgres 4096 Mar 29 14:27 archive_status +``` + +Inspect the `/opt/restore_pg96/postgresql.auto.conf` file to verify that it contains the correct recovery settings: + +```text +restore_command = 'cp archived_wals/%f %p' +recovery_target_time = '2017-03-29 14:01:00' +recovery_target_timeline = 1 +``` + +Note that the command restores from the `archived_wals` subdirectory of `/opt/restore_pg96` since the `copy_wals_during_restore` parameter in the BART configuration file is set to `enabled` for database server `hr`. + +Start the database server to initiate the point-in-time recovery operation: + +```text +[user@localhost ~]$ su postgres +Password: +bash-4.1$ cd /opt/restore_pg96 +bash-4.1$ /opt/PostgreSQL/9.6/bin/pg_ctl start -D /opt/restore_pg96 -l +/opt/restore_pg96/pg_log/logfile +server starting +``` + +Inspect the database server log file to ensure the operation did not result in any errors: + +```text +2017-03-29 14:33:23 EDT LOG: database system was interrupted; last known +up at 2017-03-29 13:50:25 EDT +2017-03-29 14:33:23 EDT LOG: starting point-in-time recovery to +2017-03-29 14:01:00-04 +2017-03-29 14:33:23 EDT LOG: restored log file +"000000010000000000000002" from archive +2017-03-29 14:33:23 EDT LOG: redo starts at 0/2000098 +2017-03-29 14:33:23 EDT LOG: consistent recovery state reached at +0/20000C0 +2017-03-29 14:33:23 EDT LOG: restored log file +"000000010000000000000003" from archive +2017-03-29 14:33:23 EDT LOG: recovery stopping before commit of +transaction 1762, time 2017-03-29 14:02:28.100072-04 +2017-03-29 14:33:23 EDT LOG: redo done at 0/303F390 +2017-03-29 14:33:23 EDT LOG: last completed transaction was at log time +2017-03-29 14:00:43.351333-04 +cp: cannot stat `archived_wals/00000002.history': No such file or +directory +2017-03-29 14:33:23 EDT LOG: selected new timeline ID: 2 +cp: cannot stat `archived_wals/00000001.history': No such file or +directory +2017-03-29 14:33:23 EDT LOG: archive recovery complete +2017-03-29 14:33:23 EDT LOG: MultiXact member wraparound protections are +now enabled +2017-03-29 14:33:23 EDT LOG: database system is ready to accept +connections +2017-03-29 14:33:23 EDT LOG: autovacuum launcher started +``` + +The tables that exist in the recovered database cluster are: + +```text +postgres=# \dt + List of relations +Schema | Name | Type | Owner +--------+----------------+-------+---------- +public | hr_rmt_t1_1356 | table | postgres +public | hr_rmt_t1_1358 | table | postgres +public | hr_rmt_t1_1400 | table | postgres +(3 rows) +``` + +Since recovery was up to and including 2017-03-29 14:01:00, the following tables created after 14:01 are not present: + +```text +public | hr_rmt_t1_1402 | table | postgres +public | hr_rmt_t1_1404 | table | postgres +public | hr_rmt_t1_1406 | table | postgres +``` + +The BART `RESTORE` operation stops WAL archiving by adding an `archive_mode = off` parameter at the very end of the `postgresql.conf` file. This last parameter in the file overrides any other previous setting of the same parameter in the file. Delete the last setting and restart the database server to start WAL archiving. + +```text +# Add settings for extensions here +archive_mode = off +``` diff --git a/product_docs/docs/bart/2.5/bart_ref/images/EDB_logo.png b/product_docs/docs/bart/2.5/bart_ref/images/EDB_logo.png new file mode 100755 index 00000000000..39a54822d85 Binary files /dev/null and b/product_docs/docs/bart/2.5/bart_ref/images/EDB_logo.png differ diff --git a/product_docs/docs/bart/2.5/bart_ref/images/edb.png b/product_docs/docs/bart/2.5/bart_ref/images/edb.png new file mode 100755 index 00000000000..71e5bdde787 Binary files /dev/null and b/product_docs/docs/bart/2.5/bart_ref/images/edb.png differ diff --git a/product_docs/docs/bart/2.5/bart_ref/images/edb_logo.svg b/product_docs/docs/bart/2.5/bart_ref/images/edb_logo.svg new file mode 100755 index 00000000000..f24d1dfefee --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_ref/images/edb_logo.svg @@ -0,0 +1,19 @@ + + + edb-logo-disc-dark + + + + \ No newline at end of file diff --git a/product_docs/docs/bart/2.5/bart_ref/images/image2.png b/product_docs/docs/bart/2.5/bart_ref/images/image2.png new file mode 100755 index 00000000000..4eba2e7efa7 Binary files /dev/null and b/product_docs/docs/bart/2.5/bart_ref/images/image2.png differ diff --git a/product_docs/docs/bart/2.5/bart_ref/index.mdx b/product_docs/docs/bart/2.5/bart_ref/index.mdx new file mode 100644 index 00000000000..2f5c5504dcf --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_ref/index.mdx @@ -0,0 +1,33 @@ +--- +navTitle: Reference Guide +title: "EDB Postgres Backup and Recovery Reference Guide" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/genindex.html" + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/conclusion.html" + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/index.html" +--- + +This guide acts as a quick reference for BART subcommands and provides comprehensive examples of the following BART operations: + +- Performing a full backup of database servers +- Performing a point-in-time recovery (PITR) on a remote PostgreSQL database server +- Restoring an incremental backup +- Restoring a database cluster with tablespaces +- Evaluating, marking, and deleting backups and incremental backups +- Configuring and operating local and remote database servers + +For detailed information about BART subcommands and operations, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/2.5/bart_user/). + +The document is organized as follows: + +- See [Subcommands](01_bart_subcommands_examples/#using_bart_subcommands) to view BART subcommand examples. +- See [Examples](02_additional_examples/#examples) to view BART operations examples. +- See [Sample BART System](03_sample_bart_system_with_local_and_remote_database_servers/#a_sample_bart_system_with_local_and_remote_database_servers) to view examples of both local and remote database server configuration and operation. + +
+ +bart_subcommands_examples additional_examples sample_bart_system_with_local_and_remote_database_servers conclusion + +
diff --git a/product_docs/docs/bart/2.5/bart_user/01_introduction.mdx b/product_docs/docs/bart/2.5/bart_user/01_introduction.mdx new file mode 100644 index 00000000000..4e6b92da76a --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_user/01_introduction.mdx @@ -0,0 +1,55 @@ +--- +title: "Introduction" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/introduction.html" +--- + +The EDB Backup and Recovery Tool (BART) is an administrative utility that provides simplified backup and recovery management for multiple local or remote EDB Advanced Server and PostgreSQL database servers. + +BART provides the following features: + +- Support for complete, hot, physical backups of multiple Advanced Servers and PostgreSQL database servers +- Support for two types of backups – full base backups and block-level incremental backups +- Backup and recovery management of database servers on local or remote hosts +- A single, centralized catalog for backup data +- Retention policy support for defining and managing how long backups should be kept +- The capability to store the backup data in compressed format +- Verified backup data with checksums +- Backup information displayed in an easy-to-read format +- A simplified point-in-time recovery process + +This guide provides the following information about using BART: + +- an [overview](02_overview/#overview) of the BART components and concepts. +- [backup and recovery management process](03_using_bart/#using_bart). +- [using tablespaces](04_using_tablespaces/#using_tablespaces). + +For information about installing BART, see the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/2.5/bart_inst/). For examples of BART operations and subcommand usage, see the *EDB Backup and Recovery Reference Guide* available at the [EDB website](/bart/2.5/bart_ref/). + + + +## Conventions Used in this Guide + +The following is a list of conventions used throughout this document. + +- Much of the information in this document applies interchangeably to the PostgreSQL and EDB Advanced Server database systems. The term *Advanced Server* is used to refer to EDB Advanced Server. The term *Postgres* is used to generically refer to both PostgreSQL and Advanced Server. When a distinction needs to be made between these two database systems, the specific names, PostgreSQL or Advanced Server are used. + +- The installation directory of the PostgreSQL or Advanced Server products is referred to as `POSTGRES_INSTALL_HOME`: + + - For PostgreSQL Linux installations, this defaults to `/opt/PostgreSQL/` for version 10 and earlier. For later versions, the installation directory is `/var/lib/pgsql/`. + - For Advanced Server Linux installations performed using the interactive installer for version 10 and earlier, this defaults to `/opt/PostgresPlus/AS` or `/opt/edb/as`. For Advanced Server Linux installations performed with an RPM package, this defaults to `/usr/ppas-` or `/usr/edb/as`. For Advanced Server Linux installations performed with an RPM package for version 11 or later, this defaults to `/usr/edb/as`. + +## Restrictions on pg_basebackup + +BART takes full backups using the `pg_basebackup` utility program under the following conditions: + +- The backup is taken on a standby server. +- The `--with-pg_basebackup` option is specified with the `BACKUP` subcommand (see [Backup](03_using_bart/03_basic_bart_subcommand_usage/03_backup/#backup)). +- The number of thread count in effect is 1, and the `with-pg_basebackup` option is not specified with the `BACKUP` subcommand. +- Database servers can only be backed up using `pg_basebackup` utility program of the same or later version than the database server version. + +In the global section of the BART configuration file, the `pg_basebackup_path` parameter specifies the complete directory path to the `pg_basebackup` program. For information about the `pg_basebackup_path` parameter and the `thread_count`, see the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/2.5/bart_inst/). + +For information about `pg_basebackup`, see the [PostgreSQL Core Documentation](https://postgresql.org/docs/12/static/app-pgbasebackup.html). diff --git a/product_docs/docs/bart/2.5/bart_user/02_overview/01_block-level_incremental_backup/01_incremental_backup_limitations_and_requirements.mdx b/product_docs/docs/bart/2.5/bart_user/02_overview/01_block-level_incremental_backup/01_incremental_backup_limitations_and_requirements.mdx new file mode 100644 index 00000000000..54629dd07b9 --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_user/02_overview/01_block-level_incremental_backup/01_incremental_backup_limitations_and_requirements.mdx @@ -0,0 +1,42 @@ +--- +title: "Incremental Backup Limitations and Requirements" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/incremental_backup_limitations_and_requirements.html" +--- + + + +The following limitations apply to incremental backup: + +- If you have restored a full or incremental backup, you must take a full backup before enabling incremental backup. +- If a standby node has been promoted to the role of a primary node, you must take a full backup before enabling incremental backup on the cluster. +- On a standby database server, you cannot take an incremental backup. + +You must meet the following requirements before implementing incremental backup: + +- You must create or select an operating system account to be used as the BART user account. + +- You must create or select the replication database user, which must be a superuser. + +- In the BART configuration file: + + - You must set the `cluster_owner` parameter to the Linux operating system user account that owns the database cluster directory from which incremental backups are to be taken. + - You must enable the `allow_incremental_backups` parameter. + +- A passwordless SSH/SCP connection must be established between the BART user account on the BART host and the `cluster_owner` user account on the database server. + + It must be noted that a passwordless SSH/SCP connection must be established even if BART and the database server are running on the same host and the BART user account and the `cluster_owner` user account are the same account. + +- In addition to the BART host (where the BART backup catalog resides), the BART package must also be installed on every remote database server on which incremental backups are to be restored. To restore an incremental backup, the `bart` program must be executable on the remote host by the remote user (the remote user is specified by the `remote_host` parameter in the BART configuration file or by the `-r` option when using the `RESTORE` subcommand to restore the incremental backup). + +- When [restoring incremental backups on a remote database server](05_restoring_an_incremental_backup/#restoring-an-incremental-backup-on-a-remote-host), a passwordless SSH/SCP connection must be established from the BART user account on the BART host to the remote user on the remote host (the remote user is specified by the `remote_host` parameter in the BART configuration file or by the `-r` option when using the `RESTORE` subcommand to restore the incremental backup). + +- Compression of archived WAL files in the BART backup catalog is not permitted for database servers on which incremental backups are to be taken. The `wal_compression` setting in the BART configuration file must be disabled for those database servers. + +- The incremental backup must be on the same timeline as the parent backup. The timeline changes after each recovery operation so an incremental backup cannot use a parent backup from an earlier timeline. + +For information about configuring these requirements, see the EDB Backup and Recovery Installation and Upgrade Guide available at the [EDB website](/bart/2.5/bart_inst/). + +The following section provides an overview of the basic incremental backup concepts. diff --git a/product_docs/docs/bart/2.5/bart_user/02_overview/01_block-level_incremental_backup/02_concept_overview.mdx b/product_docs/docs/bart/2.5/bart_user/02_overview/01_block-level_incremental_backup/02_concept_overview.mdx new file mode 100644 index 00000000000..b433ff411af --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_user/02_overview/01_block-level_incremental_backup/02_concept_overview.mdx @@ -0,0 +1,33 @@ +--- +title: "Concept Overview" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/concept_overview.html" +--- + + + +Using incremental backups involves the following sequence of steps: + +1. Configure BART, and enable and initiate archiving of WAL files to the `archive_path` in the same manner as done for full backups. + + The default `archive_path` is the BART backup catalog (`//archived_wals`). Using the `` parameter in the server section of the BART configuration file, you can specify the location where WAL files will be archived. + + For more information about the `archive_path` parameter and configuring BART, see the EDB Backup and Recovery Installation and Upgrade Guide available at the [EDB website](/bart/2.5/bart_inst/). + +2. Take an initial full backup with the `BACKUP` subcommand. This full backup establishes the parent of the first incremental backup. + +3. Scan all WAL files produced by database servers on which incremental backups are to be taken. These WAL files are scanned once they have been archived to the `archive_path`. + + Each scanned WAL file results in a modified block map (MBM) file that records the location of modified blocks obtained from the corresponding WAL file. The BART WAL scanner program `bart-scanner` performs this process. + +4. Take incremental backups using the `BACKUP` subcommand with the `--parent` option to specify the backup identifier or name of a previous, full backup or an incremental backup. Any previous backup may be chosen as the parent as long as all backups belong to the same timeline. + +5. The incremental backup process identifies which WAL files may contain changes from when the parent backup was taken to the starting point of the incremental backup. The corresponding MBM files are used to locate and copy the modified blocks to the incremental backup directory along with other database cluster directories and files. Instead of backing up all, full relation files, only the modified blocks are copied and saved. In addition, the relevant MBM files are condensed into one consolidated block map (CBM) file that is stored with the incremental backup. + + Multiple block copier threads can be used to copy the modified blocks to the incremental backup directory. See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/2.5/bart_inst/) for information about setting the `thread_count` parameter in the BART configuration file. See [Backup](../../03_using_bart/03_basic_bart_subcommand_usage/03_backup/#backup) for information about using the `--thread-count` option with the `BACKUP` subcommand. + +6. Invoke the restore process for an incremental backup using the `RESTORE` subcommand in the same manner as restoring a full backup. The `-i` option specifies the backup identifier or name of the incremental backup to restore. The restore process begins by going back through the chain of past, parent incremental backups until the initial full backup starting the chain is identified. This full backup provides the initial set of directories and files to be restored to the location specified with the `-p` option. Each subsequent incremental backup in the chain is then restored. Restoration of an incremental backup uses its CBM file to restore the modified blocks from the incremental backup. + +The following sections provide some additional information on these procedures. diff --git a/product_docs/docs/bart/2.5/bart_user/02_overview/01_block-level_incremental_backup/03_wal_scanning_preparation_for_an_incremental_backup.mdx b/product_docs/docs/bart/2.5/bart_user/02_overview/01_block-level_incremental_backup/03_wal_scanning_preparation_for_an_incremental_backup.mdx new file mode 100644 index 00000000000..b62fd717336 --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_user/02_overview/01_block-level_incremental_backup/03_wal_scanning_preparation_for_an_incremental_backup.mdx @@ -0,0 +1,54 @@ +--- +title: "WAL Scanning – Preparation for an Incremental Backup" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/wal_scanning_preparation_for_an_incremental_backup.html" +--- + + + +The WAL scanner program (`bart-scanner`) scans the WAL files created from the time of the parent backup up to the start of the incremental backup to determine which blocks have modified since the parent backup, and records the information in a file called the *modified block map (MBM) file*. One MBM file is created for each WAL file. + +The MBM file is stored in the directory where archived_wals will be stored, as specified in the `archive_path` parameter in the `bart.cfg` file. If the `archive_path` is not specified, the default `archived_wals` directory is: + +`//` + +Where: + +`` is the BART backup catalog parent directory specified in the global section of the BART configuration file. + +`` is the lowercase conversion of the database server name specified in the server section of the BART configuration file. + +The following code snippet is the content of the archive path showing the MBM files created for the WAL files. (The user name and group name of the files have been removed from the example to list the WAL files and MBM files in a more comparable manner): + +```text +[root@localhost archived_wals]# pwd +/opt/backup/acctg/archived_wals +[root@localhost archived_wals]# ls -l +total 131104 +-rw------- 1 ... ... 16777216 Oct 12 09:38 000000010000000100000078 +-rw------- 1 ... ... 16777216 Oct 12 09:38 000000010000000100000079 +-rw------- 1 ... ... 16777216 Oct 12 09:38 00000001000000010000007A +-rw------- 1 ... ... 16777216 Oct 12 09:35 00000001000000010000007B +-rw------- 1 ... ... 16777216 Oct 12 09:38 00000001000000010000007C +-rw------- 1 ... ... 16777216 Oct 12 09:39 00000001000000010000007D +-rw------- 1 ... ... 16777216 Oct 12 09:42 00000001000000010000007E +-rw------- 1 ... ... 16777216 Oct 12 09:47 00000001000000010000007F +-rw-rw-r-- 1 ... ... 161 Oct 12 09:49 0000000100000001780000280000000179000000.mbm +-rw-rw-r-- 1 ... ... 684 Oct 12 09:49 000000010000000179000028000000017A000000.mbm +-rw-rw-r-- 1 ... ... 161 Oct 12 09:49 00000001000000017A000028000000017B000000.mbm +-rw-rw-r-- 1 ... ... 161 Oct 12 09:49 00000001000000017B000028000000017C000000.mbm +-rw-rw-r-- 1 ... ...1524 Oct 12 09:49 00000001000000017C000028000000017D000000.mbm +-rw-rw-r-- 1 ... ... 161 Oct 12 09:49 00000001000000017D000028000000017E000000.mbm +-rw-rw-r-- 1 ... ... 161 Oct 12 09:49 00000001000000017E000028000000017F000000.mbm +-rw-rw-r-- 1 ... ... 161 Oct 12 09:49 00000001000000017F0000280000000180000000.mbm +``` + +MBM files have the suffix, `.mbm`. + +In preparation for any incremental backup, the WAL files should be scanned as soon as they are copied to the `archive_path`. Thus, the WAL scanner should be running as soon as the WAL files from the database cluster are archived to the `archive_path`. If the `archive_path` contains WAL files that have not yet been scanned, starting the WAL scanner begins scanning these files. If WAL file fails to be scanned (resulting in a missing MBM file), you can use the WAL scanner to specify an individual WAL file. + +Under certain conditions such as when the Network File System (NFS) is used to copy WAL files to the `archive_path`, the WAL files may have been missed by the WAL scanner program for scanning and creation of MBM files. Use the `scan_interval` parameter in the BART configuration file to initiate force scanning of WAL files in the `archive_path` to ensure MBM files are generated. See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/2.5/bart_inst/) for more information about the `scan_interval` parameter. + +See [Running the BART WAL Scanner](../../03_using_bart/04_running_the_bart_wal_scanner/#running_the_bart_wal_scanner) for information about using the WAL scanner. diff --git a/product_docs/docs/bart/2.5/bart_user/02_overview/01_block-level_incremental_backup/04_performing_an_incremental_backup.mdx b/product_docs/docs/bart/2.5/bart_user/02_overview/01_block-level_incremental_backup/04_performing_an_incremental_backup.mdx new file mode 100644 index 00000000000..7cd01990da6 --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_user/02_overview/01_block-level_incremental_backup/04_performing_an_incremental_backup.mdx @@ -0,0 +1,76 @@ +--- +title: "Performing an Incremental Backup" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/performing_an_incremental_backup.html" +--- + + + +The WAL files produced at the time of the parent backup up to the start of the incremental backup contain information about which blocks were modified during that time interval. That information is consolidated into an MBM file for each WAL file by the WAL scanner. + +The MBM files for the relevant WAL files are read, and the information is used to copy the modified blocks from the database cluster to the `archived_wals` directory as specified in the `archive_path` parameter in the `bart.cfg` file. When compared to a full backup, the number and sizes of relation files can be significantly less for an incremental backup. + +For comparison, the following is an abbreviated list of the files copied to the archived `base` subdirectory of a full backup for one database: + +```text +[root@localhost 14845]# pwd +/opt/backup/acctg/1476301238969/base/base/14845 +[root@localhost 14845]# ls +112 13182_vm 14740 16467 16615 2608_vm 2655 2699 2995 ... +113 13184 14742 16471 174 2609 2656 2701 2995_vm ... +1247 13186 14745 16473 175 2609_fsm 2657 2702 2996 ... +1247_fsm 13187 14747 16474 2187 2609_vm 2658 2703 2998 ... +1247_vm 13187_fsm 14748 16476 2328 2610 2659 2704 2998_vm ... +1249 13187_vm 14749 16477 2328_fsm 2610_fsm 2660 2753 2999 ... +1249_fsm 13189 14752 16479 2328_vm 2610_vm 2661 2753_fsm 2999_vm ... +1249_vm 13191 14754 16488 2336 2611 2662 2753_vm 3079 ... +1255 13192 14755 16490 2336_vm 2611_vm 2663 2754 3079_fsm ... + . + . + . +13182_fsm 14739 16465 16603 2608_fsm 2654 2696 2893_vm 3501_vm ... +``` + +In contrast, the following is the content of the archived `base` subdirectory of the same database from a subsequent incremental backup: + +```text +[root@localhost 14845]# pwd +/opt/backup/acctg/1476301835391/base/base/14845 +[root@localhost 14845]# ls +1247 1249 1259 16384 17006 2608 2610 2658 2663 2678 ... +1247_fsm 1249_fsm 1259_fsm 16387 17009 2608_fsm 2610_fsm 2659 2673 2679 ... +1247_vm 1249_vm 1259_vm 16389 17011 2608_vm 2610_vm 2662 2674 2703 ... +``` + +The information from the MBM files are consolidated into one file called a *consolidated block map* (CBM) file. During the restore operation for the incremental backup, the CBM file is used to identify the modified blocks to be restored for that backup. In addition, the incremental backup also stores other required subdirectories and files from the database cluster as is done for full backups. + +Before taking an incremental backup, an initial full backup must be taken with the `BACKUP` subcommand. This full backup establishes the parent of the first incremental backup. + +The syntax for taking a full backup is: + +```text +bart BACKUP –s { | all } [ -F { p | t } ] + [ -z ] [ –c ] + [ --backup-name ] + [ --thread-count ] + [ { --with-pg_basebackup | --no-pg_basebackup } ] +``` + +The syntax for taking an incremental backup is: + +```text +bart BACKUP –s { | all } [ -F p] + [ --parent { | } ] + [ --backup-name ] + [ --thread-count ] + [ --check ] +``` + +You must specify the following before taking an incremental backup: + +- `-Fp` option for plain text format as incremental backup can only be taken in the plain text format. +- `--check` option to verify if the required MBM files are present in the `archived_wals` directory. The `--parent` option must be specified when the `--check` option is used. + +See [BACKUP](../../03_using_bart/03_basic_bart_subcommand_usage/03_backup/#backup) for more information about using the `BACKUP` subcommand. diff --git a/product_docs/docs/bart/2.5/bart_user/02_overview/01_block-level_incremental_backup/05_restoring_an_incremental_backup.mdx b/product_docs/docs/bart/2.5/bart_user/02_overview/01_block-level_incremental_backup/05_restoring_an_incremental_backup.mdx new file mode 100644 index 00000000000..a511a1938fe --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_user/02_overview/01_block-level_incremental_backup/05_restoring_an_incremental_backup.mdx @@ -0,0 +1,42 @@ +--- +title: "Restoring an Incremental Backup" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/restoring_an_incremental_backup.html" +--- + + + +Restoring an incremental backup may require additional steps depending upon the host on which the incremental backup is to be restored: + +- [Restoring an Incremental Backup on a BART Host](#restoring-an-incremental-backup-on-a-bart-host) - This section outlines restoring an incremental backup onto the same host where BART has been installed. +- [Restoring an Incremental Backup on a Remote Host](#restoring-an-incremental-backup-on-a-remote-host) - This section outlines restoring an incremental backup onto a remote host where BART has not been installed. + + + +## Restoring an Incremental Backup on a BART Host + +Specify a backup identifier or name, and include the `-i` option when invoking the `RESTORE` subcommand to restore an incremental backup. All `RESTORE` options may be used in the same manner as when restoring a full backup. See [RESTORE](../../03_using_bart/03_basic_bart_subcommand_usage/08_restore/#restore) command for more details. + +First, all files from the full backup from the beginning of the backup chain are restored. For each incremental backup, the CBM file is used to identify and restore blocks from the incremental backup. If there are new relations or databases identified in the CBM file, then relevant relation files are copied. If consolidated block map information is found indicating the drop of a relation or a database, then the relevant files are removed from the restore directory. Similarly, if there is any indication of a table truncation, then the related files are truncated. + +Also note that you can use the `-w` option of the `RESTORE` subcommand to specify a multiple number of parallel worker processes to stream the modified blocks to the restore host. + + + +## Restoring an Incremental Backup on a Remote Host + +Ensure the `bart` program is available on the remote host when restoring an incremental backup on a remote host; the invocation of the `RESTORE` subcommand for an incremental backup results in the execution of the `bart` program on the remote host to restore the modified blocks to their proper location. + +To restore an incremental backup onto a remote host where BART has not been installed, perform the following steps: + +**Step 1:** Install `BART` on the remote host to which an incremental backup is to be restored. + +No editing is needed in the `bart.cfg` file installed on the remote host. + +**Step 2:** Determine the Linux operating system user account on the remote host to be used as the remote user. This user is specified by the `remote_host` parameter in the BART configuration file or by the `-r` option when using the `RESTORE` subcommand to restore the incremental backup. The remote user must be the owner of the directory where the incremental backup is to be restored on the remote host. By default, the user account is `enterprisedb` for Advanced Server or `postgres` for PostgreSQL. + +**Step 3:** Ensure a passwordless SSH/SCP connection is established from the BART user on the BART host to the remote user on the remote host. For information about creating a passwordless SSH/SCP connection, see the *EDB Backup and Recovery Installation and Upgrade Guide*, available at the [EDB website](/bart/2.5/bart_inst/). + +When restoring an incremental backup, specify the backup identifier or name of the incremental backup that will be restored. See the [RESTORE](../../03_using_bart/03_basic_bart_subcommand_usage/08_restore/#restore) documentation for more details. To view an example of restoring an incremental backup, see the *EDB Backup and Recovery Reference Guide* available at the [EDB website](/bart/2.5/bart_ref/). diff --git a/product_docs/docs/bart/2.5/bart_user/02_overview/01_block-level_incremental_backup/index.mdx b/product_docs/docs/bart/2.5/bart_user/02_overview/01_block-level_incremental_backup/index.mdx new file mode 100644 index 00000000000..3e65e3b0056 --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_user/02_overview/01_block-level_incremental_backup/index.mdx @@ -0,0 +1,24 @@ +--- +title: "Block-Level Incremental Backup" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/block-level_incremental_backup.html" +--- + + + +This section describes the basic concepts of a block-level incremental backup (referred to as an incremental backup). An incremental backup is a unique functionality of BART. + +An incremental backup provides a number of advantages when compared to using a full backup: + +- The amount of time required to produce an incremental backup is generally less than a full backup, as modified relation blocks are saved instead of all full relation files of the database cluster. +- An incremental backup uses less disk space than a full backup. + +Generally, all BART features (such as retention policy management) apply to incremental backups and full backups. See [Managing Incremental Backups](../../03_using_bart/02_managing_backups_using_a_retention_policy/05_managing_incremental_backups/#managing_incremental_backups) for more information. + +
+ +incremental_backup_limitations_and_requirements concept_overview wal_scanning_preparation_for_an_incremental_backup performing_an_incremental_backup restoring_an_incremental_backup + +
diff --git a/product_docs/docs/bart/2.5/bart_user/02_overview/02_creating_a_backup_chain.mdx b/product_docs/docs/bart/2.5/bart_user/02_overview/02_creating_a_backup_chain.mdx new file mode 100644 index 00000000000..d45de3e33ab --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_user/02_overview/02_creating_a_backup_chain.mdx @@ -0,0 +1,22 @@ +--- +title: "Creating a Backup Chain" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/creating_a_backup_chain.html" +--- + + + +A *backup chain* is the set of backups consisting of a full backup and all of its successive incremental backups. Tracing back on the parent backups of all incremental backups in the chain eventually leads back to that single, full backup. + +It is possible to have a *multi-forked* backup chain, which is two or more successive lines of incremental backups, all of which begin with the same, full backup. Thus, within the chain there is a backup that serves as the parent of more than one incremental backup. + +Since restoration of an incremental backup is dependent upon first restoring the full backup, then all successive incremental backups up to, and including the incremental backup specified by the `RESTORE` subcommand, it is crucial to note the following: + +- Deletion or corruption of the full backup destroys the entire backup chain. It is not possible to restore any of the incremental backups that were part of that chain. +- Deletion or corruption of an incremental backup within the chain results in the inability to restore any incremental backup that was added to that successive line of backups following the deleted or corrupted backup. The full backup and incremental backups prior to the deleted or corrupted backup can still be restored. + +The actions of retention policy management are applied to the full backup and all of its successive incremental backups within the chain in an identical manner as if they were one backup. Thus, use of retention policy management does not result in the breakup of a backup chain. + +See the *EDB Backup and Recovery Reference Guide*, available at the [EDB website](/bart/2.5/bart_ref/) for examples of creating a backup chain and restoring an incremental backup. diff --git a/product_docs/docs/bart/2.5/bart_user/02_overview/index.mdx b/product_docs/docs/bart/2.5/bart_user/02_overview/index.mdx new file mode 100644 index 00000000000..8a5e6c69b66 --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_user/02_overview/index.mdx @@ -0,0 +1,97 @@ +--- +title: "Overview" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/overview.html" +--- + + + +BART provides a simplified interface for the continuous archiving and point-in-time recovery method provided with Postgres database servers. This consists of the following processes: + +- Capturing a complete image of a database cluster as a full base backup or referred to simply as a *full backup*. +- Capturing a modified image of a database cluster called a *block-level incremental backup* or referred as *incremental backup*, which is similar to a full backup, but contains the modified blocks of the relation files that have been changed since a previous backup. +- Archiving the `Write-Ahead Log segments` (WAL files), which continuously record changes to be made to the database files. +- Performing *Point-In-Time Recovery* (PITR) to a specified transaction ID or timestamp with respect to a timeline using a full backup along with successive, [block-level incremental backups](01_block-level_incremental_backup/#block-level_incremental_backup) that reside in the same backup chain, and the WAL files. + +Detailed information regarding WAL files and point-in-time recovery is documented in the [PostgreSQL Core Documentation](https://www.postgresql.org/docs/12/static/continuous-archiving.html). + +The general term *backup* refers to both full backups and incremental backups. + +When taking a full backup of a standby server, BART uses the PostgreSQL `pg_basebackup` utility program. However, it must be noted that for standby servers, you can only take a full backup, but cannot take an incremental or parallel backups. For information about standby servers, see the [PostgreSQL Documentation](https://www.postgresql.org/docs/12/static/high-availability.html). + +BART uses a centralized backup catalog, a single configuration file, and a command line interface controlling the necessary operations to simplify the management process. Reasonable defaults are automatically used for various backup and restore options. BART also performs the necessary recovery file configuration required for point-in-time recovery using its command line interface. + +BART also provides the following features to enhance backup management: + +- Automation of the WAL archiving command configuration. +- Usage of retention policies to evaluate, categorize, and delete obsolete backups. +- Compression of WAL files to conserve disk space. +- Customizable naming of backups to ease their usage. +- Easy access to comprehensive information about each backup. + +The key components of a BART installation are: + +- **BART Host.** The host system on which BART is installed. BART operations are invoked from this host system. The database server backups and archived WAL files are stored on this host as well. +- **BART User Account.** Linux operating system user account you choose to run BART. The BART user account owns the BART backup catalog directory. +- **BART Configuration File.** File in editable text format containing the configuration information that BART uses. +- **BART Backup Catalog.** File system directory structure containing all of the backups for the database servers that BART manages. It is also the default `archive_path` to store archived WAL files. +- **BART Backupinfo File.** File in text format containing information for a BART backup. A `backupinfo` file resides in each backup subdirectory within the BART backup catalog. +- **BART Command Line Utility Program.** Single, executable file named `bart`, which is used to manage all BART operations. +- **BART WAL Scanner Program.** Single, executable file named `bart-scanner`, which is used to scan WAL files to locate and record the modified blocks for incremental backups. + +Other concepts and terms referred to in this document include the following: + +- **Postgres Database Cluster.** Also commonly called the *data directory*, this is the file system directory where all of the data files related to a particular Postgres database server instance are stored. (Each specific running instance is identified by its host and port number when connecting to a database.) The database cluster is identified by the `–D` option when it is created, started, stopped, etc. by the `Postgres initdb` and `pg_ctl` commands. A full backup is a copy of a database cluster. + + The terms database cluster and database server are used somewhat interchangeably throughout this document, though a single database server can run multiple database clusters. + +- **Postgres User Account.** Linux operating system user account that runs the Advanced Server or PostgreSQL database server and owns the database cluster directory. + + - By default, the database user account is `enterprisedb` when Advanced Server is installed to support compatibility with Oracle databases. + + - By default, the database user account is `postgres` when Advanced Server is installed in PostgreSQL compatible mode. For a PostgreSQL database server, the default database user account is also `postgres`. + + The BART configuration parameter `cluster_owner` must be set to the database user account for each database server. + +- **Replication Database User.** For each database server that BART manages, a database superuser must be selected to act as the replication database user. This database user is used to connect to the database server when backups are taken. The database superusers created with an initial Postgres database server installation (`enterprisedb` or `postgres`) may be used for this purpose. The BART configuration parameter `user` must be set to this replication database user for each database server. + +- **Secure Shell (SSH)/Secure Copy (SCP).** Linux utility programs used to log into hosts (SSH) and copy files (SCP) between hosts. A valid user account must be specified that exists on the target host and in fact is the user account under which the SSH or SCP operations occur. + +For information on how all of these components are configured and used with BART, see the EDB Backup and Recovery Installation and Upgrade Guide available at the [EDB website](/bart/2.5/bart_inst/). + +**Supported BART Operations** + +The following tables are not a conclusive list of the scenarios supported by BART, but instead provides an overview of some of the most common scenarios in both `pg_basebackup` (thread count=1) as well as parallel backup mode (thread count greater than 1). + +| | -Fp-xlog-method=fetch | -Fp-xlog-method=stream | -Ft-xlog-method=fetch | -Ft-xlog-method=stream | +| -------------------------------------------- | --------------------- | ---------------------- | --------------------- | ---------------------- | +| `Primary Database Server/Full backup` | Supported | Supported | Supported | Supported | +| `Primary Database Server/Incremental backup` | Supported | Supported | Not Supported | Not Supported | +| `Standby Database Server/Full backup` | Supported | Supported | Supported | Supported | +| `Standby Database Server/Incremental backup` | Not Supported | Not Supported | Not Supported | Not Supported | + +Backup + +| | Wal compression by BART | WAL scanner | +| -------------------------------------------- | ----------------------- | ----------- | +| `Primary Database Server/Full backup` | Supported | N/A | +| `Primary Database Server/Incremental backup` | Not Supported | N/A | +| `Standby Database Server/Full backup` | Supported | N/A | +| `Standby Database Server/Incremental backup` | Not Supported | N/A | + +Wal Archiving + +| | Wal compression = enabled | Wal compression = disabled | +| ------------------ | ------------------------- | -------------------------- | +| `Restore` | Supported | Supported | +| `Parallel restore` | Supported | Supported | + +Restore + +
+ +block-level_incremental_backup creating_a_backup_chain + +
diff --git a/product_docs/docs/bart/2.5/bart_user/03_using_bart/01_bart_management_overview/01_performing_a_restore_operation.mdx b/product_docs/docs/bart/2.5/bart_user/03_using_bart/01_bart_management_overview/01_performing_a_restore_operation.mdx new file mode 100644 index 00000000000..f6daf08042c --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_user/03_using_bart/01_bart_management_overview/01_performing_a_restore_operation.mdx @@ -0,0 +1,57 @@ +--- +title: "Performing a Restore Operation" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/performing_a_restore_operation.html" +--- + + + +The following steps describe the process of restoring a backup: + +**Step 1:** Use your system-specific command to shut down the database server. + +**Step 2:** Inspect the `pg_wal` subdirectory (inspect the `pg_xlog` subdirectory if you are using server version 9.6) of the data directory and save any WAL files that have not yet been archived to the `archive_path`. If there are files that have not been archived, save them to a temporary location. + +**Step 3:** If you want to restore to current data directory, it is recommended to make a copy of the current data directory and then delete all files and subdirectories under the data directory if you have enough extra space. If there is not enough space, then make a copy of `pg_wal` directory (or `pg_xlog` if you are using server version 9.6) until the server is successfully restored. + +If you want to restore to a new, empty directory, create the directory on which you want to restore the backed up database cluster. Ensure the data directory can be written to by the BART user account or by the user account specified by the `remote_host` configuration parameter, or by the `--remote-host` option of the `RESTORE` subcommand (if these are to be used). + +**Step 4:** Perform the same process for tablespaces as described in Step 3. The `tablespace_path` parameter in the BART configuration file must contain the tablespace directory paths to which the tablespace data files are to be restored. See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/2.5/bart_inst/) for more information about this parameter. + +**Step 5:** Identify the backup to use for the restore operation and obtain the backup ID or backup name. + +To use the latest backup, omit the `-i` option; the `RESTORE` subcommand uses that backup by default. The backups can be listed with the `SHOW-BACKUPS` subcommand. + +**Step 6:** Run the BART `RESTORE` subcommand. + +- Minimal recovery settings will be saved in the `postgresql.auto.conf` file and archive recovery will proceed only until consistency is reached, with no restoration of files from the archive. See [Restore](../03_basic_bart_subcommand_usage/08_restore/#restore) for detailed information about `Restore` subcommand. + +- If the `-c` option is specified or if the `copy_wals_during_restore` BART configuration parameter is enabled for this database server, then the following actions occur: + + - In addition to restoring the database cluster to the directory specified by the `-p restore_path` option, the archived WAL files of the backup are copied from the BART backup catalog to the subdirectory `restore_path/archived_wals`. + - If recovery settings are saved in the `postgresql.auto.conf` file, the command string set in the `restore_command` parameter retrieves the WAL files from this `archived_wals` subdirectory relative to the `restore_path` parent directory as: `restore_command = cp archived_wals/%f %p` + +You must ensure that valid options are specified when using the `RESTORE` subcommand. BART will not generate an error message if invalid option values or invalid option combinations are provided. BART will accept the invalid options and pass them to the `postgresql.auto.conf` file, which will then be processed by the database server when it is restarted. + +**Step 7:** Copy any saved WAL files from Step 2 to the `restore_path/pg_xlog` subdirectory. + +**Step 8:** Inspect the restored directories and data files of the restored database cluster in directory `restore_path`. + +All files and directories must be owned by the user account that you intend to use to start the database server. Recursively change the user and group ownership of the `restore_path` directory, its files, and its subdirectories if necessary. There must only be directory access privileges for the user account that will start the database server. No other groups or users can have access to the directory. + +**Step 9:** The `postgresql.auto.conf` file should be configured to recover only until the cluster reaches consistency. In either case, the settings may be modified as desired. + +**Step 10:** Disable WAL archiving at this point. The BART `RESTORE` subcommand adds `archive_mode = off` to the end of the `postgresql.conf` file. + +- If you want to restart the database server with WAL archiving enabled, ensure that this additional parameter is deleted. +- The original `archive_mode` parameter still resides in the `postgresql.conf` file in its initial location with its last setting. + +**Step 11:** Start the database server to initiate recovery. After completion, check the database server log file to ensure the recovery was successful. + +If the backup is restored to a different location than where the original database cluster resided, operations dependent upon the database cluster location may fail if supporting service scripts are not updated to reflect the location where the backup has been restored. For information about the use and modification of service scripts, see the EDB Advanced Server Installation Guide. + +See [Restore](../03_basic_bart_subcommand_usage/08_restore/#restore) for more information about using the BART `Restore` subcommand. + +An example of a restore operation is documented in the EDB Backup and Recovery Reference Guide available at the [EDB website](/bart/2.5/bart_ref/). diff --git a/product_docs/docs/bart/2.5/bart_user/03_using_bart/01_bart_management_overview/02_point_in_time_recovery_operation.mdx b/product_docs/docs/bart/2.5/bart_user/03_using_bart/01_bart_management_overview/02_point_in_time_recovery_operation.mdx new file mode 100644 index 00000000000..ffd0aa13bf7 --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_user/03_using_bart/01_bart_management_overview/02_point_in_time_recovery_operation.mdx @@ -0,0 +1,51 @@ +--- +title: "Point-In-Time Recovery Operation" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/point_in_time_recovery_operation.html" +--- + + + +The following steps outline how to perform a point-in-time recovery operation for a database cluster: + +1. Use your system-specific command to shut down the database server. + +2. If you want to: + a. restore the database cluster and tablespace files to new, empty directories, create the new directories with the appropriate directory ownership and permissions. + b. reuse the existing database cluster directories, delete all the files and subdirectories in the existing directories. We strongly recommend that you make a copy of this data before deleting it. Be sure to save any recent WAL files in the `pg_wal` subdirectory ( `pg_xlog` subdirectory if you are using server version 9.6) that have not been archived to `archive_path`. + +3. Run the BART `SHOW-BACKUPS -s ` subcommand to list the backup IDs and backup names of the backups for the database server. You will need to provide the appropriate backup ID or backup name with the BART `RESTORE` subcommand, unless you intend to restore the latest backup in which case the `-i` option of the `RESTORE` subcommand for specifying the backup ID or backup name may be omitted. + +4. Run the BART `RESTORE` subcommand with the appropriate options. + + - The backup is restored to the directory specified by the `-p restore_path` option. + + - In addition, if the `RESTORE` subcommand `-c` option is specified or if the enabled setting of the `copy_wals_during_restore` BART configuration parameter is applicable to the database server, then the required archived WAL files from the `archive_path` are copied to the `restore_path/archived_wals` subdirectory. + + - Ensure the `restore_path` directory and all subdirectories and files in the `restore_path` are owned by the proper Postgres user account (for example, `enterprisedb` or `postgres`). Also ensure that only the Postgres user account has access permission to the `restore_path` directory. + + Use the `chown` command to make the appropriate adjustments to file permissions; for example, the following command changes the ownership of `restore_path` to `enterprisedb`: + + `chown -R enterprisedb:enterprisedb restore_path` + + The following command restricts access to `restore_path`: + + `chmod 700 restore_path` + +5. Copy any saved WAL files from Step 2 that were not archived to the BART backup catalog to the `restore_path/pg_wal` subdirectory (`pg_xlog` subdirectory if you are using server version 9.6). + +6. Identify the timeline ID you wish to use to perform the restore operation. + + The available timeline IDs can be identified by the first non-zero digit of the WAL file names reading from left to right. + +7. Verify that the `postgresql.auto.conf` file created in the directory specified with the `RESTORE` subcommand’s `-p ` option was generated with the correct recovery parameter settings. + + If the `RESTORE` subcommand `-c` option is specified or if the enabled setting of the `copy_wals_during_restore` BART configuration parameter is applicable to the database server, then the `restore_command` parameter retrieves the archived WAL files from the `/archived_wals` subdirectory that was created by the `RESTORE` subcommand, otherwise the `restore_command` retrieves the archived WAL files from the BART backup catalog. + +8. The BART `RESTORE` subcommand disables WAL archiving in the restored database cluster. If you want to immediately enable WAL archiving, modify the `postgresql.conf` file by deleting the `archive_mode = off` parameter that BART appends to the end of the file. + +9. Start the database server, which will then perform the point-in-time recovery operation if recovery settings are saved in the `postgresql.auto.conf` file. + +For a detailed description of the `RESTORE` subcommand, see [Basic BART Subcommand Usage](../03_basic_bart_subcommand_usage/#basic_bart_subcommand_usage). An example of a Point-in-Time Recovery operation is documented in the *EDB Backup and Recovery Reference Guide* available at the [EDB website](/bart/2.5/bart_ref/). See [Restore](../03_basic_bart_subcommand_usage/08_restore/#restore) for more information about using the `Restore` subcommand. diff --git a/product_docs/docs/bart/2.5/bart_user/03_using_bart/01_bart_management_overview/index.mdx b/product_docs/docs/bart/2.5/bart_user/03_using_bart/01_bart_management_overview/index.mdx new file mode 100644 index 00000000000..4cb9c779397 --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_user/03_using_bart/01_bart_management_overview/index.mdx @@ -0,0 +1,34 @@ +--- +title: "BART Management Overview" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/bart_management_overview.html" +--- + + + +After configuring BART, you can begin the backup and recovery management process. The following steps will help you get started: + +1. Run the `CHECK-CONFIG` subcommand without the `-s` option. When the `CHECK-CONFIG` subcommand is used without specifying the `-s` option, it checks the parameters in the global section of the BART configuration file. +2. Run the `INIT` subcommand (if you have not already done so) to finish creation of the BART backup catalog, which results in the complete directory structure to which backups and WAL files are saved. This step must be done before restarting the database servers with enabled WAL archiving, otherwise the copy operation in the `archive_command` parameter of the `postgresql.conf` file or the `postgresql.auto.conf` file fails due to the absence of the target archive directory. When the directory structure is complete, the `archived_wals` subdirectory should exist for each database server. +3. Start the Postgres database servers with archiving enabled. Verify that the WAL files are appearing in the `archive_path`. The archiving frequency is dependent upon other `postgresql.conf` configuration parameters. Check the Postgres database server log files to ensure there are no archiving errors. Archiving should be operational before taking a backup in order to ensure that the WAL files that may be created during the backup process are archived. +4. Start the WAL scanner if you intend to take incremental backups. Since the WAL scanner processes the WAL files copied to the `archive path`, it is advantageous to commence the WAL scanning as soon as the WAL files begin to appear in the `archive_path` in order to keep the scanning in pace with the WAL archiving. +5. Run the BART `CHECK-CONFIG` subcommand for each database server with the `-s` option specifying the server name. This ensures the database server is properly configured for taking backups. +6. Create a full backup for each database server. The full backup establishes the starting point of when point-in-time recovery can begin and also establishes the initial parent backup for any incremental backups to be taken. + +There are now a number of other BART management processes you may perform: + +- Execute the `BACKUP` subcommand to create additional full backups or incremental backups. +- Use the `VERIFY-CHKSUM` subcommand to verify the checksum of the full backups. +- Display database server information with the `SHOW-SERVERS` subcommand. +- Display backup information with the `SHOW-BACKUPS` subcommand. +- Compress the archived WAL files in the `archive_path` by enabling WAL compression in the BART configuration file and then invoking the `MANAGE` subcommand. +- Determine and set the retention policy for backups in the BART configuration file. +- Establish the procedure for using the `MANAGE` subcommand to enforce the retention policy for backups. This may include using `cron` jobs to schedule the `MANAGE` subcommand. + +
+ +performing_a_restore_operation point_in_time_recovery_operation + +
diff --git a/product_docs/docs/bart/2.5/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/01_overview_managing_backups_using_a_retention_policy.mdx b/product_docs/docs/bart/2.5/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/01_overview_managing_backups_using_a_retention_policy.mdx new file mode 100644 index 00000000000..7169d6f7bb6 --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/01_overview_managing_backups_using_a_retention_policy.mdx @@ -0,0 +1,23 @@ +--- +title: "Overview - Managing Backups Using a Retention Policy" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/overview_managing_backups_using_a_retention_policy.html" +--- + + + +The BART retention policy results in the categorization of each backup in one of three statuses – *active*, *obsolete*, and *keep*. + +- **Active.** The backup satisfies the retention policy applicable to its server. Such backups would be considered necessary to ensure the recovery safety for the server and thus should be retained. +- **Obsolete.** The backup does not satisfy the retention policy applicable to its server. The backup is no longer considered necessary for the recovery safety of the server and thus can be deleted. +- **Keep.** The backup is to be retained regardless of the retention policy applicable to its server. The backup is considered vital to the recovery safety for the server and thus should not be deleted for an indefinite period of time. + +There are two types of retention policies - redundancy retention policy and recovery window retention policy. + +- **Redundancy Retention Policy** - The [redundancy retention policy](03_setting_the_retention_policy/#redundancy-retention-policy) relies on a specified, maximum number of most recent backups to retain for a given server. When the number of backups exceeds that maximum number, the oldest backups are considered obsolete (except for backups marked as keep). +- **Recovery Window Retention Policy** - The [recovery window retention policy](03_setting_the_retention_policy/#recovery-window-retention-policy) relies on a time frame (the recovery window) for when a backup should be considered active. The boundaries defining the recovery window are the current date/time (the ending boundary of the recovery window) and the date/time going back in the past for a specified length of time (the starting boundary of the recovery window). + - If the date/time the backup was taken is within the recovery window (that is, the backup date/time is on or after the starting date/time of the recovery window), then the backup is considered active, otherwise it is considered obsolete (except for backups marked as keep). + - Thus, for the recovery window retention policy, the recovery window time frame dynamically shifts, so the end of the recovery window is always the current date/time when the `MANAGE` subcommand is run. As you run the `MANAGE` subcommand at future points in time, the starting boundary of the recovery window moves forward in time. At some future point, the date/time of when a backup was taken will be earlier than the starting boundary of the recovery window. This is when an active backup’s status will be considered obsolete. + - You can see the starting boundary of the recovery window at any point in time by running the `SHOW-SERVERS` subcommand. The `RETENTION POLICY` field of the `SHOW-SERVERS` subcommand displays the starting boundary of the recovery window. diff --git a/product_docs/docs/bart/2.5/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/02_marking_the_backup_status.mdx b/product_docs/docs/bart/2.5/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/02_marking_the_backup_status.mdx new file mode 100644 index 00000000000..047552d0a9e --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/02_marking_the_backup_status.mdx @@ -0,0 +1,25 @@ +--- +title: "Marking the Backup Status" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/marking_the_backup_status.html" +--- + + + +When a backup is initially created with the `BACKUP` subcommand, it is always recorded with active status. Use the `MANAGE` subcommand to evaluate if the backup status should be changed to obsolete in accordance with the retention policy. You can review the current status of your backups with the `SHOW-BACKUPS` subcommand. + +Active backups are evaluated and also marked (that is, internally recorded by BART) as obsolete only when the `MANAGE` subcommand is invoked either with no options or with only the `-s` option. + +Once a backup has been marked as obsolete, you cannot change it back to active unless you perform the following steps: + +- Use the `MANAGE` subcommand with the `-c` option along with the backup identifier or name with the `-i` option. To keep this particular backup indefinitely, use `-c keep`, otherwise use `-c nokeep`. +- If you use the `-c nokeep` option, the backup status is changed back to active. When the `MANAGE` subcommand is used the next time, the backup is re-evaluated to determine if its status needs to be changed back to obsolete based on the current retention policy in the BART configuration file. + +After setting the `retention_policy` parameter and running the `MANAGE` subcommand if you change the `retention_policy` parameter, the current, marked status of the backups are probably inconsistent with the new `retention_policy` setting. To modify the backup status to be consistent with the new `retention_policy` setting, you need to run the `MANAGE` subcommand with: + +- the `-c nokeep` option to change the obsolete status to active status if there are backups currently marked as obsolete that would no longer be considered obsolete under a new retention policy. You can also specify the `-i all` option to change all backups back to active status, including those currently marked as keep. +- no options or with only the `-s` option to reset the marked status based on the new `retention_policy` setting in the BART configuration file. + +See [MANAGE](../03_basic_bart_subcommand_usage/07_manage/#manage) for usage information for the `MANAGE` subcommand. diff --git a/product_docs/docs/bart/2.5/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/03_setting_the_retention_policy.mdx b/product_docs/docs/bart/2.5/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/03_setting_the_retention_policy.mdx new file mode 100644 index 00000000000..f30524d0e69 --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/03_setting_the_retention_policy.mdx @@ -0,0 +1,82 @@ +--- +title: "Setting the Retention Policy" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/setting_the_retention_policy.html" +--- + + + +The retention policy is determined by the `retention_policy` parameter in the BART configuration file. It can be applied globally to all servers, but each server can override the global retention policy with its own. For information about creating a global retention policy and an individual database server retention policy, see the EDB Backup and Recovery Installation and Upgrade Guide available at the [EDB website](/bart/2.5/bart_inst/). + +There are two types of retention policies - redundancy retention policy and the recovery window retention policy as described in the following sections. + + + +## Redundancy Retention Policy + +To use the redundancy retention policy, set `retention_policy = max_number BACKUPS` where `max_number` is a positive integer designating the maximum number of most recent backups. + +**Additional Restrictions:** + +- The keyword `BACKUPS` must always be specified in plural form (for example, `1 BACKUPS`). +- BART will accept a maximum integer value of 2,147,483,647 for `max_number`; however, you should use a realistic, practical value based on your system environment. + +The redundancy retention policy is the default type of retention policy if all keywords `BACKUPS`, `DAYS`, `WEEKS`, and `MONTHS` following the `max_number` integer are omitted as shown by the following example: + +`retention_policy = 3` + +In the following example, the redundancy retention policy setting considers the three most recent backups as the active backups. Any older backups, except those marked as `keep`, are considered obsolete: + +```text +[ACCTG] +host = 127.0.0.1 +port = 5444 +user = enterprisedb +archive_command = 'cp %p %a/%f' +retention_policy = 3 BACKUPS +description = "Accounting" +``` + +The `SHOW-SERVERS` subcommand displays the `3 Backups` redundancy retention policy in the `RETENTION POLICY` field: + +```bash +-bash-4.1$ bart SHOW-SERVERS -s acctg +SERVER NAME : acctg +HOST NAME : 127.0.0.1 +USER NAME : enterprisedb +PORT : 5444 +REMOTE HOST : +RETENTION POLICY : 3 Backups +DISK UTILIZATION : 627.04 MB +NUMBER OF ARCHIVES : 25 +ARCHIVE PATH : /opt/backup/acctg/archived_wals +ARCHIVE COMMAND : cp %p /opt/backup/acctg/archived_wals/%f +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +DESCRIPTION : "Accounting" +``` + + + +## Recovery Window Retention Policy + +To use the recovery window retention policy, set the `retention_policy` parameter to the desired length of time for the recovery window in one of the following ways: + +- Set to `max_number DAYS` to define the start date/time recovery window boundary as the number of days specified by `max_number` going back in time from the current date/time. +- Set to `max_number WEEKS` to define the start date/time recovery window boundary as the number of weeks specified by `max_number` going back in time from the current date/time. +- Set to `max_number MONTHS` to define the start date/time recovery window boundary as the number of months specified by `max_number` going back in time from the current date/time. + +**Additional Restrictions:** + +- The keywords `DAYS`, `WEEKS`, and `MONTHS` must always be specified in plural form (for example, `1 DAYS`, `1 WEEKS`, or `1 MONTHS`). +- BART will accept a maximum integer value of `2,147,483,647` for `max_number`, however, a realistic, practical value based on your system environment must always be used. + +A backup is considered active if the date/time of the backup is equal to or greater than the start of the recovery window date/time. + +You can view the actual, calculated recovery window by: + +- Invoking the `MANAGE` subcommand in debug mode, along with the `-n` option. +- Using the `SHOW-SERVERS` subcommand. diff --git a/product_docs/docs/bart/2.5/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/04_managing_the_backups_based_on_the_retention_policy.mdx b/product_docs/docs/bart/2.5/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/04_managing_the_backups_based_on_the_retention_policy.mdx new file mode 100644 index 00000000000..2a744e416e8 --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/04_managing_the_backups_based_on_the_retention_policy.mdx @@ -0,0 +1,147 @@ +--- +title: "Managing the Backups Based on the Retention Policy" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/managing_the_backups_based_on_the_retention_policy.html" +--- + + + +The [MANAGE](../03_basic_bart_subcommand_usage/07_manage/#manage) subcommand is used to evaluate and categorize backups according to the retention policy set in the BART configuration file. When a backup is first created with the `BACKUP` subcommand, it is `active`. You can use the `MANAGE` subcommand to change the status of an active backup to `obsolete`. Obsolete backups can then be deleted. + +This section covers following aspects of backup management: + +- The rules for [deleting backups](#deletions_permitted_under_retention_policy) depending upon the backup status and the subcommand used. +- The process to retain a backup indefinitely by [marking it as keep](#marking-backups-for-indefinite-keep-status). This section also provides information about resetting backups status (that are marked as `obsolete` and `keep`) back to active status. +- The general process for [evaluating, marking, and then deleting obsolete backups](#evaluating-marking-and-deleting-obsolete-backups). + + + +## Deletions Permitted Under a Retention Policy + +This section describes how and under what conditions backups may be deleted under a retention policy. + +You must use the `MANAGE` subcommand to delete obsolete backups. Use the `DELETE` subcommand only for special administrative purposes. + +The deletion behavior of the `MANAGE` subcommand and the `DELETE` subcommand are based on different aspects of the retention policy. + +- The `MANAGE` subcommand deletion relies solely upon how a backup status is currently marked (that is, internally recorded by BART). The current setting of the `retention_policy` parameter in the BART configuration file is ignored. +- The `DELETE` subcommand relies solely upon the current setting of the `retention_policy` parameter in the BART configuration file. The current active, obsolete, or keep status of a backup is ignored. + +The specific deletion rules for the `MANAGE` and `DELETE` subcommands are as follows: + +- `MANAGE` subcommand: The `MANAGE` subcommand with the `-d` option can only delete backups marked as obsolete. This deletion occurs regardless of the current `retention_policy` setting in the BART configuration file. The deletion of backups relies on the last occasion when the backups have been marked. +- `DELETE` subcommand: + + - Under a redundancy retention policy currently set with the `retention_policy` parameter in the BART configuration file, any backup regardless of its marked status, can be deleted with the `DELETE` subcommand when the backup identifier or name is specified with the `-i` option and if the current total number of backups for the specified database server is greater than the maximum number of redundancy backups currently specified with the `retention_policy` parameter. + + If the total number of backups is less than or equal to the specified, maximum number of redundancy backups, then no additional backups can be deleted using `DELETE` with the `-i backup` option. + + - Under a recovery window retention policy currently set with the `retention_policy` parameter in the BART configuration file, any backup regardless of its marked status, can be deleted with the `DELETE` subcommand when the backup identifier or name is specified with the `-i` option, and if the backup date/time is not within the recovery window currently specified with the `retention_policy` parameter. If the backup date/time is within the recovery window, then it cannot be deleted using `DELETE` with the `-i backup` option. + + - Invoking the `DELETE` subcommand with the `-i all` option results in the deletion of all backups regardless of the retention policy and regardless of whether the status is marked as active, obsolete, or keep. + +The following table summarizes the deletion rules of backups according to their marked status. An entry of `Yes` indicates the backup may be deleted under the specified circumstances. An entry of `No` indicates that the backup may not be deleted. + + ++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
OperationRedundancy Retention PolicyRecovery Window Retention Policy
ActiveObsoleteKeepActiveObsoleteKeep
MANAGE –dNoYesNoNoYesNo
DELETE –i *backup* +

Yes

+

(see Note 1)

+
+

Yes

+

(see Note 1)

+
+

Yes

+

(see Note 1_)

+
+

Yes

+

(see Note 2

+
+

Yes

(see Note 2 +
+

Yes

(see Note 2) +
DELETE –i allYesYesYesYesYesYes
+ + + +!!! Note + Redundancy Retention Policy (Note 1) : Deletion occurs only if the total number of backups for the specified database server is greater than the specified, maximum number of redundancy backups currently set with the `redundancy_policy` parameter in the BART configuration file. + + + +!!! Note + Recovery Window Retention Policy (Note 2): Deletion occurs only if the backup is not within the recovery window currently set with the `redundancy_policy` parameter in the BART configuration file. + + + +## Marking Backups for Indefinite Keep Status + +There may be certain backups that you wish to keep for an indefinite period of time and do not wish to delete based upon the retention policy applied to the database server. Such backups can be marked as `keep` to exclude them from being marked as obsolete. Use the `MANAGE` subcommand with the `-c keep` option to retain such backups indefinitely. + + + +## Evaluating, Marking, and Deleting Obsolete Backups + +When the `MANAGE` subcommand is invoked, BART evaluates active backups: + +- If you include the `-s` option when invoking the `MANAGE` subcommand, BART evaluates backups for the database server. +- If you include the `-s all` option when invoking the `MANAGE` subcommand, BART evaluates backups for all database servers. +- If the `-s` option is omitted, the command evaluates the current number of backups for the database server based on the redundancy retention policy or the current date/time for a recovery window retention policy. + +!!! Note + The status of backups currently marked as `obsolete` or `keep` is not changed. To re-evaluate such backups and then classify them, their status must first be reset to `active` with the `MANAGE -c nokeep` option. See [Marking the Backup Status](02_marking_the_backup_status/#marking_the_backup_status) for more information. + +See the *EDB Backup and Recovery Reference Guide* available at the [EDB website](/bart/2.5/bart_ref/) to review examples of how to evaluate, mark, and delete backups using a redundancy retention policy and recovery window retention policy, as well as examples of `MANAGE` subcommand. diff --git a/product_docs/docs/bart/2.5/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/05_managing_incremental_backups.mdx b/product_docs/docs/bart/2.5/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/05_managing_incremental_backups.mdx new file mode 100644 index 00000000000..7b25ea009fe --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/05_managing_incremental_backups.mdx @@ -0,0 +1,51 @@ +--- +title: "Managing Incremental Backups" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/managing_incremental_backups.html" +--- + + + +The following section summarizes how retention policy management affects incremental backups. + +- The retention policy rules are applied to full backups. + - A redundancy retention policy uses the number of full backups to determine if a backup is obsolete. Incremental backups are excluded from the comparison count against the `retention_policy` setting for the maximum number of backups. + - A recovery window retention policy uses the backup date/time of any full backups to determine if a backup is obsolete. The backup date/time of any successive incremental backups in the chain are ignored when comparing with the recovery window. +- The retention status of all incremental backups in a chain is set to the same status applied to the full backup of the chain. +- The actions applied by the `MANAGE` and `DELETE` subcommands on a full backup are applied to all incremental backups in the chain in the same manner. +- Thus, a backup chain (that is, the full backup and all its successive incremental backups) are treated by retention policy management as if they are all one, single backup. + - The status setting applied to the full backup is also applied to all incremental backups in its chain. + - If a full backup is marked as obsolete and then deleted according to the retention policy, all incremental backups in the chain are also marked obsolete and then deleted as well. + +The following are some specific points regarding the `MANAGE` and `DELETE` subcommands on incremental backups. + +- `MANAGE` subcommand: + - When the `MANAGE` subcommand is invoked, the status applied to the full backup is also applied to all successive incremental backups in the chain. + - The `MANAGE` subcommand with the `-c { keep | nokeep}` option cannot specify the backup identifier or backup name of an incremental backup with `-i` backup option. The `-i` backup option can only specify the backup identifier or backup name of a full backup. + - You can also use the `-i` all option to take a backup of all backups. When the `MANAGE` subcommand with the `-c { keep | nokeep }` option is applied to a full backup, the same status change is made to all incremental backups in the chain. +- `DELETE` subcommand: + - The `DELETE` subcommand with the `-s server -i` backup option specifies the backup identifier or backup name of an incremental backup in which case that incremental backup along with all its successive incremental backups are deleted, thus shortening that backup chain. + +## Using a Redundancy Retention Policy with Incremental Backups + +When a [redundancy retention policy](03_setting_the_retention_policy/#redundancy-retention-policy) is used and the `MANAGE` subcommand is invoked, the status of the oldest `active` full backup is changed to `obsolete` if the number of full backups exceeds the maximum number specified by the `retention_policy` parameter in the BART configuration file. + +!!! Note + When a full backup is changed from `active` to `obsolete`, all successive incremental backups in the chain of the full backup are also changed from `active` to `obsolete`. + +When determining the number of backups that exceeds the number specified by the `retention_policy` parameter, only full backups are counted for the comparison. Incremental backups are not included in the count for the comparison against the `retention_policy` parameter setting. + +See the *EDB Backup and Recovery Reference Guide* available at the [EDB website](/bart/2.5/bart_ref/) for examples demonstrating use of the `MANAGE` and `DELETE` subcommands when a redundancy retention policy is in effect. + +## Using a Recovery Window Retention Policy with Incremental Backups + +If the `MANAGE` command is invoked when BART is configured to use a [recovery window retention policy](03_setting_the_retention_policy/#recovery-window-retention-policy), the status of `active` full backups are changed to `obsolete` if the date/time of the full backup is outside of the recovery window. + +!!! Note + If a full backup is changed from `active` to `obsolete`, all successive incremental backups in the chain of the full backup are also changed from `active` to `obsolete`. + +The status of an incremental backup is changed to `obsolete` regardless of whether or not the date/time of when the incremental backup was taken still lies within the recovery window. + +See the *EDB Backup and Recovery Reference Guide* available at the [EDB website](/bart/2.5/bart_ref/) for examples demonstrating use of the `MANAGE` and `DELETE` subcommands when a recovery window retention policy is in effect. diff --git a/product_docs/docs/bart/2.5/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/index.mdx b/product_docs/docs/bart/2.5/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/index.mdx new file mode 100644 index 00000000000..aff92bbd6a5 --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/index.mdx @@ -0,0 +1,27 @@ +--- +title: "Managing Backups Using a Retention Policy" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/managing_backups_using_a_retention_policy.html" +--- + + + +Over the course of time when using BART, the number of backups can grow significantly. This ultimately leads to a large consumption of disk space unless an administrator periodically performs the process of deleting the oldest backups that are no longer needed. This process of determining when a backup is old enough to be deleted and then actually deleting such backups can be done and automated with the following basic steps: + +1. Determine and set a retention policy in the BART configuration file. A *retention policy* is a rule that determines when a backup is considered obsolete. The retention policy can be applied globally to all servers, but each server can override the global retention policy with its own. + +2. Use the `MANAGE` subcommand to categorize and manage backups according to the retention policy. + +3. Create a cron job to periodically run the `MANAGE` subcommand to evaluate the backups and then list and/or delete the obsolete backups. + + Retention policy management applies differently to incremental backups than to full backups. See [Managing Incremental Backups](05_managing_incremental_backups/#managing_incremental_backups) for information about how retention policy management is applied to each backup type. + + The following sections describe how retention policy management generally applies to backups, and its specific usage and effect on full backups. + +
+ +overview_managing_backups_using_a_retention_policy marking_the_backup_status setting_the_retention_policy managing_the_backups_based_on_the_retention_policy managing_incremental_backups + +
diff --git a/product_docs/docs/bart/2.5/bart_user/03_using_bart/03_basic_bart_subcommand_usage/01_check_config.mdx b/product_docs/docs/bart/2.5/bart_user/03_using_bart/03_basic_bart_subcommand_usage/01_check_config.mdx new file mode 100644 index 00000000000..f12dd038edd --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_user/03_using_bart/03_basic_bart_subcommand_usage/01_check_config.mdx @@ -0,0 +1,35 @@ +--- +title: "CHECK-CONFIG" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/check_config.html" +--- + + + +The `CHECK-CONFIG` subcommand checks the parameter settings in the BART configuration file as well as the database server configuration for which the `-s` option is specified. + +**Syntax:** + +`bart CHECK-CONFIG [ –s server_name ]` + +The following table describes the option. + +| Options | Description | +| ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s ` or `--server ` | `server_name` is the name of the database server to be checked for proper configuration. If the option is omitted, the settings of the global section of the BART configuration file are checked. | + +- When the `-s` option is omitted, the global section \[BART] parameters including `bart_host`, `backup_path`, and `pg_basebackup_path` are checked. +- When the `-s` option is specified, the server section parameters are checked. In addition, certain database server `postgresql.conf` parameters are also checked, which include the following: + - The `cluster_owner` parameter must be set to the user account owning the database cluster directory. + - A passwordless SSH/SCP connection must be set between the BART user and the user account specified by the `cluster_owner` parameter. + - A database superuser must be specified by the BART `user` parameter. + - The `pg_hba.conf` file must contain a replication entry for the database superuser specified by the BART `user` parameter. + - The `archive_mode` parameter in the `postgresql.conf` file must be enabled. + - The `archive_command` parameter in the `postgresql.auto.conf` or the `postgresql.conf` file must be set. + - The `allow_incremental_backups` parameter in the BART configuration file must be enabled for database servers for which incremental backups are to be taken. + - Archiving of WAL files to the `archive_path` must be in process. + - The WAL scanner program must be running. + +The `CHECK-CONFIG` subcommand displays an error message if the required configuration is not properly set. diff --git a/product_docs/docs/bart/2.5/bart_user/03_using_bart/03_basic_bart_subcommand_usage/02_init.mdx b/product_docs/docs/bart/2.5/bart_user/03_using_bart/03_basic_bart_subcommand_usage/02_init.mdx new file mode 100644 index 00000000000..d8cdeed8126 --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_user/03_using_bart/03_basic_bart_subcommand_usage/02_init.mdx @@ -0,0 +1,41 @@ +--- +title: "INIT" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/init.html" +--- + + + +The `INIT` subcommand is used to create the BART backup catalog directory, rebuild the BART `backupinfo` file, and set the `archive_command` in the PostgreSQL server based on the `archive_command` setting in the `bart.cfg` file. + +!!! Note + If the `archive_mode` configuration parameter is set to `off`, then the `-o` option must be used to set the Postgres `archive_command` using the BART `archive_command` parameter in the BART configuration file even if the `archive_command` is not currently set in `postgresql.conf` nor in `postgresql.auto.conf` file. + +**Syntax:** + +```text +bart INIT [ –s { | all } ] [ -o ] + [ -r [ -i { | | all } ] ] + [--no-configure] +``` + +All subcommand options are generally specified in lowercase. The following table describes the command options: + +| Options | Description | +| ------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { \| all }`

`--server { \| all }` | `server_name` is the name of the database server to which the `INIT` actions are to be applied. If `all` is specified or if the option is omitted, the actions are applied to all servers. | +| `-o`

`--override` | Overrides the existing, active Postgres `archive_command` configuration parameter setting in the `postgresql.conf` file or the `postgresql.auto.conf` file using the BART `archive_command` parameter in the BART configuration file. The `INIT` generated archive command string is written to the `postgresql.auto.conf` file. | +| `-r`

`--rebuild` | Rebuilds the backupinfo file (a text file named `backupinfo`) located in each backup subdirectory. This option is only intended for recovering from a situation where the backupinfo file has become corrupt.
If the backup was initially created with a user-defined backup name, and then the `INIT -r` option is invoked to rebuild that `backupinfo` file, the user-defined backup name is no longer available. Thus, future references to the backup must use the backup identifier. | +| `-i { \| \| all }`

`--backupid { \| \| all }` | `` is an integer, backup identifier and `` is the user-defined alphanumeric name for the backup. If `all` is specified or if the option is omitted, the backupinfo files of all backups for the database servers specified by the `-s` option are recreated. The `-i` option can only be used with the `-r` option. | +| `--no-configure` | Prevents the `archive_command` from being set in the PostgreSQL server. | + +**Archive Command Setting** + +After the `archive_command` is set, you need to either restart the PostgreSQL server or reload the configuration file in the PostgreSQL server based on the following conditions. + +- If the `archive_mode` is set to `off` and `archive_command` is not set in the PostgreSQL server, the `archive_command` is set based on the `archive_command` setting in the `bart.cfg` and also sets the `archive_mode` to `on`. In this case, you need to restart the PostgreSQL server using `pg_ctl restart` +- If the `archive_mode` is set to `on` and `archive_command` is not set in the PostgreSQL server, the `archive_command` is set based on the `archive_command` setting in the `bart.cfg`. In this case, you need to reload the configuration in the PostgreSQL server using `pg_reload_conf()` or `pg_ctl reload`. +- If the `archive_mode` is set to `off` and `archive_command` is already set in the PostgreSQL server, the `archive_mode` is set to on. In this case, you need to restart the PostgreSQL server using `pg_ctl restart` +- If the `archive_mode` is set to `on` and `archive_command` is already set in the PostgreSQL server, then the `archive_command` is not set unless `-o` option is specified. diff --git a/product_docs/docs/bart/2.5/bart_user/03_using_bart/03_basic_bart_subcommand_usage/03_backup.mdx b/product_docs/docs/bart/2.5/bart_user/03_using_bart/03_basic_bart_subcommand_usage/03_backup.mdx new file mode 100644 index 00000000000..6bb4215ed62 --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_user/03_using_bart/03_basic_bart_subcommand_usage/03_backup.mdx @@ -0,0 +1,104 @@ +--- +title: "BACKUP" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/backup.html" +--- + + + +The `BACKUP` subcommand is used to create a full backup or an incremental backup. + +**Syntax for full backup:** + +```text +bart BACKUP –s { | all } [ -F { p | t } ] + [ -z ] [ –c ] + [ --backup-name ] + [ --thread-count ] + [ { --with-pg_basebackup | --no-pg_basebackup } ] +``` + +!!! Note + While taking a backup, if a file (for example, database server log file) exceeding 1 GB size is stored in the `$PGDATA` directory, the backup will fail. To avoid such backup failure, you need to store large files (exceeding 1 GB) outside the `$PGDATA` directory. + +**Syntax for incremental Backup:** + +```text +bart BACKUP –s { | all } [ -F p] + [ --parent { | } ] + [ --backup-name ] + [ --thread-count ] + [ --check ] +``` + +!!! Note + To take an [incremental backup](../../02_overview/01_block-level_incremental_backup/#block-level_incremental_backup), you must take a full backup first followed by incremental backup. + +**Please Note:** + +- While a `BACKUP` subcommand is in progress, no other subcommands must be invoked. Any subcommands invoked while a backup is in progress will skip and ignore the backups. + +- For full backup, the target default format is a tar file, whereas for incremental backup, only plain format must be specified. + +- The backup is saved in the `//` directory, where `` is the value assigned to the `` parameter in the BART configuration file, `` is the lowercase name of the database server as listed in the configuration file, and `` is a backup identifier assigned by BART to the particular backup. + +- MD5 checksums of the full backup and any user-defined tablespaces are saved as well for tar backups. + +- Before performing the backup, BART checks to ensure if there is enough disk space to completely store the backup in the BART backup catalog. + +- In the `postgresql.conf` file, ensure the `wal_keep_segments` configuration parameter is set to a sufficiently large value. A low setting of the `wal_keep_segments` configuration parameter may result in the deletion of some WAL files before the BART `BACKUP` subcommand saves them to the `archive_path`. For information about the `wal_keep_segments` parameter, see the [PostgreSQL Core Documentation](https://www.postgresql.org/docs/12/static/runtime-config-replication.html). + +- In the BART configuration file, setting `xlog_method=stream` will instruct the server to stream the transaction log in parallel with creation of the backup for a specific database server; otherwise the transaction log files are collected upon completion of the backup. See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/2.5/bart_inst/) for details about database server setting. + + !!! Note + If the transaction log streaming method is used, the `-Fp` option for a plain text backup format must be specified with the `BACKUP` subcommand. + +- When you use BART to take a backup of PostgreSQL server, multiple backups can be taken simultaneously and if a backup is interrupted, the backup mode is terminated automatically without the need to run `pg_stop_backup()` command manually to terminate the backup. + +**Options** + +Along with the `BACKUP` subcommand, specify the following option: + +| Options | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { server_name \| all }`
`--server { server_name \| all }` | `server_name` is the database server name to be backed up as specified in the BART configuration file. If `all` is specified, all servers are backed up. This option is mandatory.
If `all` is specified, and a connection to a database server listed in the BART configuration file cannot be opened, the backup for that database server is skipped, but the backup operation continues for the other database servers. | + +Specify the following options as required. If you do not specify any of the following options, the backup is created using default settings. + +| Options | Description | +| -------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-F { p \| t }`
`--format { p \| t }` | Specify this option to provide the backup file format. Use `p` for plain text or `t` for tar. If the option is omitted, the default is tar format.
For taking incremental backups, the option `-Fp` must be specified. | +| `-z`
`--gzip` | This is applicable only for full backup. Specify this option to use gzip compression on the tar file output using the default compression level. This option is applicable only for the tar format. | +| `-c `
`--compress-level ` | This is applicable only for full backup. Specify this option to use the gzip compression level on the tar file output. `compression_level` is a digit from 1 through 9, with 9 being the best compression. This option is applicable only for the tar format. | +| `--parent { backup_id \| backup_name }` | Specify this option to take an incremental backup. `` is the backup identifier of a parent backup. `` is the user-defined alphanumeric name of a parent backup.
The parent is a backup taken prior to the incremental backup. The parent backup can be either a full backup or an incremental backup.
The option `–Fp` must be specified since an incremental backup can only be taken in plain text format.
An incremental backup cannot be taken on a standby database server. See [Block-Level Incremental Backup](../../02_overview/01_block-level_incremental_backup/#block-level_incremental_backup) for additional information on incremental backups. | +| `--backup-name ` | Specify this option to assign a user-defined, alphanumeric friendly name to the backup. The maximum permitted length of backup name is 49 characters.
The backup name may include the following variables to be substituted by the timestamp values when the backup is taken: 1) `%year` – 4-digit year, 2) `%month` – 2-digit month, 3) `%day` – 2-digit day, 4) `%hour` 2-digit hour, 5) `%minute` – 2-digit minute, and 6) `%second` – 2-digit second.
To include the percent sign (`%`) as a character in the backup name, specify `%%` in the alphanumeric string.
If the backup name contains space characters (i.e. more than one word) or when referenced with the option `-i` by other subcommands (such as `restore`), enclose the string in single quotes or double quotes. See [backup name examples](#backup_name_examples).
If the `--backup-name` option is not specified, and the `backup_name` parameter is not set for this database server in the BART configuration file, then the backup can only be referenced in other BART subcommands by the BART assigned backup identifier. | +| `--thread-count ` | Use this option to use the number of worker threads to run in parallel to copy blocks for a backup.
If the option `--thread-count` is omitted, then the `thread_count` parameter in the BART configuration file applicable to this database server is used.
If the option `--thread-count` is not enabled for this database server, then the `thread_count` setting in the global section of the BART configuration file is used.
If the option `--thread-count` is not set in the global section as well, the default number of threads is 1.
If parallel backup is run with N number of worker threads, then it will initiate N+ 1 concurrent connections with the server.
Thread count will not be effective if backup is taken on a standby server.
For more information about the `--thread-count` parameter, see the EDB Backup and Recovery Installation and Upgrade Guide available at the [EDB website](/bart/2.5/bart_inst/) | +| `--with-pg_basebackup` | This is applicable only for full backup. Specify this option to use `pg_basebackup` to take a full backup. The number of thread counts in effect is ignored as given by the `thread_count` parameter in the BART configuration file.
When taking a full backup, if the thread count in effect is greater than `1`, then the `pg_basebackup` utility is not used to take the full backup (parallel worker threads are used) unless the option `--with-pg_basebackup` is specified with the `BACKUP` subcommand. | +| `--no-pg_basebackup` | This is applicable only for full backup. Specify this option if you do not want `pg_basebackup` to be used to take a full backup.
When taking a full backup, if the thread count in effect is only `1`, then the `pg_basebackup` utility is used to take the full backup unless the option `--no-pg_basebackup` is specified with the `BACKUP` subcommand. | +| `--check` | This is applicable only for incremental backup. Specify this option to verify if the required MBM files are present in the `archived_wals` directory as specified in the `archive_path` parameter in the `bart.cfg` file before taking an incremental backup. The option `--parent` must be specified when the option `--check` is used. An actual incremental backup is not taken when the option `--check` is specified. | + + + +**Backup Name Examples** + +The following examples demonstrate using the `--backup-name` clause: + +```text +./bart backup -s ppas12 -Ft --backup-name "YEAR = %year +MONTH = %month DAY = %day" +./bart backup -s ppas12 -Ft --backup-name "YEAR = %year +MONTH = %month DAY = %day %%" +./bart show-backups -s ppas12 -i "test backup" +``` + +**Error messages** + +The following table lists the error messages that may be encountered when using the `BACKUP` subcommand: + +| error message | Cause | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `edb@localhost bin]$ ./bart backup -s mktg -Ft`

`WARNING: xlog_method is empty, defaulting to global policy`

`ERROR: backup failed for server 'mktg'`

`free disk space is not enough to backup the server 'mktg'`

`space available 13.35 GB, approximately required 14.65 GB` | Insufficient free disk space. | +| `ERROR: backup failed for server 'mktg'`

`command failed with exit code 1`

`pg_basebackup: could not get transaction log end position from server: ERROR: requested WAL segment 00000001000000D50000006B has already been removed` | The wal_keep_segments configuration parameter is not set to a sufficiently large value in the postgresql.conf file. | +| `ERROR: backup failed for server 'mktg'`

`connection to the server failed: could not connect to server: Connection refused`

`Is the server running on host "172.16.114.132" and accepting`

`TCP/IP connections on port 5444?` | A connection to a database server listed in the BART configuration file fails. As a result the backup for that database server is skipped, but the backup operation continues for other database servers | diff --git a/product_docs/docs/bart/2.5/bart_user/03_using_bart/03_basic_bart_subcommand_usage/04_show_servers.mdx b/product_docs/docs/bart/2.5/bart_user/03_using_bart/03_basic_bart_subcommand_usage/04_show_servers.mdx new file mode 100644 index 00000000000..778efd3d4d6 --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_user/03_using_bart/03_basic_bart_subcommand_usage/04_show_servers.mdx @@ -0,0 +1,21 @@ +--- +title: "SHOW-SERVERS" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/show_servers.html" +--- + + + +The `SHOW-SERVERS` subcommand displays the information for the managed database servers listed in the BART configuration file. + +**Syntax:** + +`bart SHOW-SERVERS [ –s { | all } ]` + +The following table describes the command options. + +| Options | Description | +| ---------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { \| all }`
`--server { \| all }` | `` is the name of the database server whose BART configuration information is to be displayed. If `all` is specified or if the option is omitted, information for all database servers is displayed. | diff --git a/product_docs/docs/bart/2.5/bart_user/03_using_bart/03_basic_bart_subcommand_usage/05_show_backups.mdx b/product_docs/docs/bart/2.5/bart_user/03_using_bart/03_basic_bart_subcommand_usage/05_show_backups.mdx new file mode 100644 index 00000000000..d006df69db1 --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_user/03_using_bart/03_basic_bart_subcommand_usage/05_show_backups.mdx @@ -0,0 +1,25 @@ +--- +title: "SHOW-BACKUPS" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/show_backups.html" +--- + +The `SHOW-BACKUPS` subcommand displays the backup information for the managed database servers. + +**Syntax:** + +```text +bart SHOW-BACKUPS [ –s { | all } ] + [ -i { | | all } ] + [ -t ] +``` + +The following table describes the command options: + +| Options | Description | +| ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { \| all }`
`--server { \| all }` | `` is the name of the database server whose backup information is to be displayed.
If `all` is specified or if the option is omitted, the backup information for all database servers is displayed with the exception as described by the following note:
If `SHOW-BACKUPS` is invoked while the BART `BACKUP` subcommand is in progress, backups affected by the backup process are shown in progress status in the displayed backup information. | +| `-i { \| \| all }`
`--backupid { \| \| all }` | `` is a backup identifier and `` is the user-defined alphanumeric name for the backup.
If `all` is specified or if the option is omitted, all backup information for the relevant database server is displayed. | +| `-t`
`--toggle` | Displays more backup information in a list format. If the option is omitted, the default is a tabular format. | diff --git a/product_docs/docs/bart/2.5/bart_user/03_using_bart/03_basic_bart_subcommand_usage/06_verify_chksum.mdx b/product_docs/docs/bart/2.5/bart_user/03_using_bart/03_basic_bart_subcommand_usage/06_verify_chksum.mdx new file mode 100644 index 00000000000..4ec79d52d62 --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_user/03_using_bart/03_basic_bart_subcommand_usage/06_verify_chksum.mdx @@ -0,0 +1,29 @@ +--- +title: "VERIFY-CHKSUM" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/verify_chksum.html" +--- + + + +The `VERIFY-CHKSUM` subcommand verifies the MD5 checksums of the full backups and any user-defined tablespaces for the specified database server or for all database servers. The checksum is verified by comparing the current checksum of the backup against the checksum when the backup was taken. + +!!! Note + The `VERIFY-CHKSUM` subcommand is only used for tar format backups. It is not applicable to plain format backups. + +**Syntax:** + +```text +bart VERIFY-CHKSUM + [ -s { | all } ] + [ -i { | | all } ] +``` + +The following table describes the command options: + +| Options | Description | +| ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { \| all }`

`--server { \| all }` | `` is the name of the database server whose tar backup checksums are to be verified. If `all` is specified or if the `-s` option is omitted, the checksums are verified for all database servers. | +| `-i { \| \| all }`

`--backupid { \| \| all }` | `` is the backup identifier of a tar format full backup whose checksum is to be verified along with any user-defined tablespaces.
`` is the user-defined alphanumeric name for the full backup.
If `all` is specified or if the `-i` option is omitted, the checksums of all tar backups for the relevant database server are verified. | diff --git a/product_docs/docs/bart/2.5/bart_user/03_using_bart/03_basic_bart_subcommand_usage/07_manage.mdx b/product_docs/docs/bart/2.5/bart_user/03_using_bart/03_basic_bart_subcommand_usage/07_manage.mdx new file mode 100644 index 00000000000..17424fed04b --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_user/03_using_bart/03_basic_bart_subcommand_usage/07_manage.mdx @@ -0,0 +1,62 @@ +--- +title: "MANAGE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/manage.html" +--- + + + +The `MANAGE` subcommand can be invoked to: + +- Evaluate backups, mark their status, and delete obsolete backups based on the `retention_policy` parameter in the BART configuration file (See [Managing Backups Using a Retention Policy](../02_managing_backups_using_a_retention_policy/#managing_backups_using_a_retention_policy) for information about retention policy management). + +- Compress the archived WAL files based on the `wal_compression` parameter in the BART configuration file (See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/2.5/bart_inst/) for information about setting this parameter). + + **Syntax:** + + ```text + bart MANAGE [ –s { | all} ] + [ -l ] [ -d ] + [ -c { keep | nokeep } + -i { | | all } ] + [ -n ] + ``` + +The following summarizes the actions performed when the `MANAGE` subcommand is invoked: + +- When the `MANAGE` subcommand is invoked with no options or with only the `-s ` or `-s all` option, the following actions are performed: + - For the server specified by the `-s` option, or for all servers (if `-s all` is specified or the `-s` option is omitted), active backups are marked as `obsolete` in accordance with the retention policy. + - All backups that were marked `obsolete` or `keep` prior to invoking the `MANAGE` subcommand remain marked with the same prior status. + - If WAL compression is enabled for the database server, then any uncompressed, archived WAL files in the BART backup catalog of the database server are compressed with gzip. +- When the `MANAGE` subcommand is invoked with any other option besides the `-s` option, the following actions are performed: + - For the server specified by the `-s` option, or for all servers, the action performed is determined by the other specified options (that is, `-l` to list obsolete backups, `-d` to delete obsolete backups, `-c` to keep or to return backups to `active` status, or `-n` to perform a dry run of any action). + - No marking of `active` backups to `obsolete` status is performed regardless of the retention policy. + - All backups that were marked `obsolete` or `keep` prior to invoking the `MANAGE` subcommand remain marked with the same prior status unless the `-c` option (without the `-n` option) is specified to change the backup status of the particular backup or all backups referenced with the `-i` option. + - No compression is applied to any uncompressed, archived WAL file in the BART backup catalog regardless of whether or not WAL compression is enabled. + +The following are additional considerations when using WAL compression: + +- Compression of archived WAL files is not permitted for database servers on which incremental backups are to be taken. +- The gzip compression program must be installed on the BART host and be accessible in the `PATH` of the BART user account. +- When the `RESTORE` subcommand is invoked, if the `-c` option is specified or if the `copy_wals_during_restore` BART configuration parameter is enabled for the database server, then the following actions occur: + + - If compressed, archived WAL files are stored in the BART backup catalog and the location to which the WAL files are to be restored is on a remote host relative to the BART host: + + - the archived WAL files are transmitted across the network to the remote host in compressed format only if the gzip compression program is accessible in the `PATH` of the remote user account that is used to log into the remote host when performing the `RESTORE` operation. + - This remote user is specified with either the `remote_host` parameter in the BART configuration file or the `RESTORE -r` option (see [RESTORE](08_restore/#restore)). + - Transmission of compressed WAL files results in less network traffic. After the compressed WAL files are transmitted across the network, the `RESTORE` subcommand uncompresses the files for the point-in-time recovery operation. + - If the gzip program is not accessible on the remote host in the manner described in the previous bullet point, then the compressed, archived WAL files are first uncompressed while on the BART host, then transmitted across the network to the remote host in uncompressed format. +- When the `RESTORE` subcommand is invoked without the `-c` option and the `copy_wals_during_restore` BART configuration parameter is disabled for the database server, then any compressed, archived WAL files needed for the `RESTORE` operation are uncompressed in the BART backup catalog. The uncompressed WAL files can then be saved to the remote host by the `restore_command` in the `postgresql.auto.conf` file when the database server archive recovery begins. + +The following table describes the command options: + +| Options | Description | +| ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `s { \| all }`
`--server { \| all }` | `` is the name of the database server to which the actions are to be applied. If `all` is specified or if the `-s` option is omitted, the actions are applied to all database servers. | +| `-l`
`--list-obsolete` | Lists the backups marked as obsolete. | +| `-d`
`--delete-obsolete` | Delete the backups marked as `obsolete`. This action physically deletes the backup along with its archived WAL files and any MBM files for incremental backups. | +| `-c { keep \| nokeep }`

`--change-status { keep \| nokeep }` | Specify `keep` to change the status of a backup to `keep` to retain it indefinitely.
Specify `nokeep` to change the status of any backup back to active status. The backup can then be re-evaluated and possibly be marked to `obsolete` according to the retention policy by subsequent usage of the `MANAGE` subcommand.
The `–i` option must be included when using the `-c` option. | +| `-i { \| \| all }`

`--backupid { \| \| all }` | `` is a backup identifier and `` is the user-defined alphanumeric name for the backup.
If `all` is specified, then actions are applied to all backups.
The `–c` option must be included when using the `-i` option. | +| `-n`
`--dry-run` | Performs the test run and displays the results prior to actually implementing the actions as if the operation was performed, however, no changes are actually made.
If `-n` is specified with the `-d` option, it displays which backups would be deleted, but does not actually delete the backups.
If `-n` is specified with the `-c` option, it displays the keep or nokeep action, but does not actually change the backup from its current status.
If `-n` is specified alone with no other options, or with only the `-s` option, it displays which active backups would be marked as obsolete, but does not actually change the backup status. In addition, no compression is performed on uncompressed, archived WAL files even if WAL compression is enabled for the database server. | diff --git a/product_docs/docs/bart/2.5/bart_user/03_using_bart/03_basic_bart_subcommand_usage/08_restore.mdx b/product_docs/docs/bart/2.5/bart_user/03_using_bart/03_basic_bart_subcommand_usage/08_restore.mdx new file mode 100644 index 00000000000..0d9b25e4fbd --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_user/03_using_bart/03_basic_bart_subcommand_usage/08_restore.mdx @@ -0,0 +1,46 @@ +--- +title: "RESTORE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/restore.html" +--- + + + +The `RESTORE` subcommand restores a backup and its archived WAL files for the designated database server to the specified directory location. If the appropriate `RESTORE` options are specified, all recovery settings will be saved in the `postgresql.auto.conf` file. + +**Syntax:** + +```text +bart RESTORE –s -p + [ –i { | } ] + [ -r ] + [ -w ] + [ -t ] + [ { -x | -g } ] + [ -c ] +``` + +For information about using a continuous archive backup for recovery, see the [PostgreSQL Core Documentation](https://www.postgresql.org/docs/12/static/continuous-archiving.html). This reference material provides detailed information about the underlying point-in-time recovery process and the meaning and usage of the restore options that are generated into the `postgresql.auto.conf` file by BART. + +**Please note**: + +- For special requirements when restoring an incremental backup to a remote database server, see [Restoring an Incremental Backup on a Remote Host](../../02_overview/01_block-level_incremental_backup/05_restoring_an_incremental_backup/#restoring_an_incremental_backup_on_a_remote_host). +- Check to ensure that the host where the backup is to be restored contains enough disk space for the backup and its archived WAL files. The `RESTORE` subcommand may result in an error while copying files if there is not enough disk space available. +- See [Performing a Restore Operation](../01_bart_management_overview/01_performing_a_restore_operation/#performing_a_restore_operation) to view steps on how to perform a restore operation and see [Point-In-Time Recovery Operation](../01_bart_management_overview/02_point_in_time_recovery_operation/#point_in_time_recovery_operation) to view steps on how to perform a point-in-time recovery operation. +- If the backup is restored to a different database cluster directory than where the original database cluster resided, certain operations dependent upon the database cluster location may fail. This happens if their supporting service scripts are not updated to reflect the new directory location of restored backup. For information about the usage and modification of service scripts, see the *EDB Advanced Server Installation Guide*. + +The following table describes the command options: + +| Options | Description | +| ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s `
`--server ` | `` is the name of the database server to be restored. | +| `-p `
`--restore-path ` | `` is the directory path where the backup of the database server is to be restored. The directory must be empty and have the proper ownership and privileges assigned to it. | +| `-i { \| }`

`--backupid { \| }` | `` is the backup identifier of the backup to be used for the restoration and `` is the user-defined alphanumeric name for the backup.
If the option is omitted, the default is to use the latest backup. | +| `-r or --remote-host ` | `` is the user account on the remote database server host that accepts a passwordless SSH/SCP login connection and is the owner of the directory where the backup is to be restored and `` is the IP address of the remote host to which the backup is to be restored. This option must be specified if the `` parameter for this database server is not set in the BART configuration file.
If the BART user account is not the same as the operating system account owning the `` directory given with the `-p` option, use the `` BART configuration parameter or the `RESTORE` subcommand `-r` option to specify the `` directory owner even when restoring to a directory on the same host as the BART host.
See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/2.5/bart_inst/) for information about the `` parameter. | +| `-w `
`--workers ` | `` is the specification of the number of worker processes to run in parallel to stream the modified blocks of an incremental backup to the restore location.
For example, if 4 worker processes are specified, 4 receiver processes on the restore host and 4 streamer processes on the BART host are used. The output of each streamer process is connected to the input of a receiver process. When the receiver gets to the point where it needs a modified block file, it obtains those modified blocks from its input. With this method, the modified block files are never written to the restore host disk. If the `-w` option is omitted, the default is `1` \| worker process. | +| `-t `
`--target-tli ` | `` is the integer identifier of the timeline to be used for replaying the archived WAL files for point-in-time recovery. | +| `-x `
`--target-xid ` | `` is the integer identifier of the transaction ID that determines the transaction up to and including, which point-in-time recovery encompasses. Include either the `-x ` or the `--target-xid ` option if point-in-time recovery is desired. | +| `-g `

`--target-timestamp ` | `` is the timestamp that determines the point in time up to and including, which point-in-time recovery encompasses. Include either the `--target-timestamp ` or the `-g ` option if point-in-time recovery is desired. | +| `-c`
`--copy-wals` | Specify this option to copy archived WAL files from the BART backup catalog to `/archived_wals` directory.
If recovery settings are saved in the `postgresql.auto.conf` file for point-in-time recovery, the `restore_command` retrieves the WAL files from `/archived_wals` for the database server archive recovery.
If the `-c` option is omitted and the `copy_wals_during_restore` parameter in the BART configuration file is not enabled in a manner applicable to this database server, the `restore_command` in the `postgresql.auto.conf` file is generated by default to retrieve the archived WAL files directly from the BART backup catalog. See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/2.5/bart_inst/) for information about the `copy_wals_during_restore` parameter. | \ No newline at end of file diff --git a/product_docs/docs/bart/2.5/bart_user/03_using_bart/03_basic_bart_subcommand_usage/09_delete.mdx b/product_docs/docs/bart/2.5/bart_user/03_using_bart/03_basic_bart_subcommand_usage/09_delete.mdx new file mode 100644 index 00000000000..7f9836ad724 --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_user/03_using_bart/03_basic_bart_subcommand_usage/09_delete.mdx @@ -0,0 +1,34 @@ +--- +title: "DELETE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/delete.html" +--- + + + +The `DELETE` subcommand removes the subdirectory and data files from the BART backup catalog for the specified backups along with its archived WAL files. + +**Syntax:** + +```text +bart DELETE –s + -i { all | + [']{ | },... }['] + } + [ -n ] +``` + +!!! Note + While invoking the `DELETE` subcommand, you must specify a specific database server. + +For database servers under a retention policy, there are conditions where certain backups may not be deleted. See [Deletions Permitted Under a Retention Policy](../02_managing_backups_using_a_retention_policy/04_managing_the_backups_based_on_the_retention_policy/#deletions_permitted_under_retention_policy) for information about permitted backup deletions. + +The following table describes the command options: + +| Options | Description | +| -------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s `

`--server ` | `` is the name of the database server whose backups are to be deleted. | +| `-i { all \| [']{ \| },... }['] }`

`--backupid { all \| [']{ \| },... }['] }` | `` is the backup identifier of the backup to be deleted and `` is the user-defined alphanumeric name for the backup.
Multiple backup identifiers and backup names may be specified in a comma-separated list. The list must be enclosed within single quotes if there is any white space appearing before or after each comma.
If `all` is specified, all of the backups and their archived WAL files for the specified database server are deleted. | +| `-n`
`--dry-run` | Displays the results as if the deletions were done, however, no physical removal of the files are actually performed. In other words, a test run is performed so that you can see the potential results prior to actually initiating the action.
After the deletion, the BART backup catalog for the database server no longer contains the corresponding directory for the deleted backup ID. The `archived_wals` subdirectory no longer contains the WAL files of the backup. | diff --git a/product_docs/docs/bart/2.5/bart_user/03_using_bart/03_basic_bart_subcommand_usage/index.mdx b/product_docs/docs/bart/2.5/bart_user/03_using_bart/03_basic_bart_subcommand_usage/index.mdx new file mode 100644 index 00000000000..8dc5080fcef --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_user/03_using_bart/03_basic_bart_subcommand_usage/index.mdx @@ -0,0 +1,50 @@ +--- +title: "Basic BART Subcommand Usage" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/basic_bart_subcommand_usage.html" +--- + + + +This section briefly describes the BART subcommands and options. You can invoke the `bart` program (located in the `/bin` directory) with the desired options and subcommands to manage your BART installation. + +To view examples of BART subcommands, see the *EDB Backup and Recovery Reference Guide* available at the [EDB website](/bart/2.5/bart_ref/). + +**Syntax for invoking BART**: + + `bart [ general_option ]... [ subcommand ] [subcommand_option ]...` + +- When invoking a subcommand, the subcommand name is not case-sensitive (that is, the subcommand can be specified in uppercase, lowercase, or mixed case). +- Each subcommand has a number of its own applicable options that are specified following the subcommand. All options are available in both single-character and multi-character forms. +- Keywords are case-sensitive; options are generally specified in lowercase unless specified otherwise in this section. +- When invoking BART, the current user must be the BART user account (operating system user account used to run the BART command line program). For example, enterprisedb or postgres can be selected as the BART user account when the managed database servers are Advanced Server or PostgreSQL respectively. +- The chosen operating system user account must own the BART backup catalog directory, be able to run the `bart` program and the `bart scanner` program, and have a passwordless SSH/SCP connection established between database servers managed by BART. + +You can specify one or more of the following general options: + +| Options | Description | +| ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-h` or `--help` | Displays general syntax and information on BART usage. All subcommands support a help option (`-h`, `--help`). If the help option is specified, information is displayed regarding that particular subcommand. The subcommand, itself, is not executed. | +| `-v` or `--version` | Displays the BART version information. | +| `-d` or `--debug` | Displays debugging output while executing BART subcommands. | +| `-c `or `--config-path ` | Specifies `config_file_path` as the full directory path to a BART configuration file. Use this option if you do not want to use the default BART configuration file `/etc/bart.cfg`. | + +**Troubleshooting: Setting Path Environment Variable** + +If execution of BART subcommands fails with the following error message, then you need to set the `LD_LIBRARY_PATH` to include the `libpq` library directory: + + `./bart: symbol lookup error: ./bart: undefined symbol: PQping` + +**Workaround:** Set the `LD_LIBRARY_PATH` environment variable for the BART user account to include the directory containing the `libpq` library. This directory is `POSTGRES_INSTALL_HOME/lib`. + +It is suggested that the `PATH` and the `LD_LIBRARY_PATH` environment variable settings be placed in the BART user account’s profile. See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/2.5/bart_inst/) for details. + +In the following sections, the `help` option is omitted from the syntax diagrams for the purpose of providing readability for the subcommand options. + +
+ +check_config init backup show_servers show_backups verify_chksum manage restore delete + +
diff --git a/product_docs/docs/bart/2.5/bart_user/03_using_bart/04_running_the_bart_wal_scanner.mdx b/product_docs/docs/bart/2.5/bart_user/03_using_bart/04_running_the_bart_wal_scanner.mdx new file mode 100644 index 00000000000..9b111c3ba0e --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_user/03_using_bart/04_running_the_bart_wal_scanner.mdx @@ -0,0 +1,56 @@ +--- +title: "Running the BART WAL Scanner" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/running_the_bart_wal_scanner.html" +--- + + + +Use the BART WAL scanner to invoke the `bart-scanner` program located in the `BART_HOME/bin` directory. When invoking the WAL scanner, the current user must be the BART user account. + +**Syntax:** + +```text +bart-scanner + [ -d ] + [ -c ] + { –h | + -v | + --daemon | + -p | + | + RELOAD | + STOP +``` + +!!! Note + For clarity, the syntax diagram shows only the single-character option form (for example, `-d`), but the multi-character option form (for example, `--debug`) is supported as well. + +The WAL scanner processes each WAL file to find and record modified blocks in a corresponding modified block map (MBM) file. The default approach is that the WAL scanner gets notified whenever a new WAL file is added to the `archived_wals` directory specified in the `archive_path` parameter of the configuration file. It then scans the WAL file and produces the MBM file. + +The default approach does not work in some cases; for example when the WAL files are shipped to the `archive_path` using the Network File System (NFS) and also in case of some specific platforms. This results in the WAL files being copied to the `archived_wals` directory, but the WAL scanner does not scan them (as WAL scanner is not aware of WAL file) and produce the MBM files. This results in the failure of an incremental backup. This can be avoided by using the timer-based WAL scanning approach, which is done by using the `scan_interval` parameter in the BART configuration file. The value for `scan_interval` is the number of seconds after which the WAL scanner will initiate force scanning of the new WAL files. See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/2.5/bart_inst/) for more information about `scan_interval` parameter. + +When the `bart-scanner` program is invoked, it forks a separate process for each database server enabled with the `allow_incremental_backups` parameter. + +The WAL scanner processes can run in either the foreground or background depending upon usage of the `--daemon` option. Use the `--daemon` option to run the WAL scanner process in the background so that all output messages can be viewed in the BART log file. If the `--daemon` option is omitted, the WAL scanner process runs in the foreground and all output messages can be viewed from the terminal running the program as well as in the BART log file. + +See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/2.5/bart_inst/) for additional information about WAL scanning, `allow_incremental_backups`, and `logfile` parameters. + +!!! Note + The BART user account’s `LD_LIBRARY_PATH` environment variable may need to be set to include the directory containing the `libpq` library if invocation of the WAL scanner program fails. See [Basic BART Subcommand Usage](03_basic_bart_subcommand_usage/#basic_bart_subcommand_usage) for information about setting the `LD_LIBRARY_PATH` environment variable. + +The following table describes the scanner options: + +| Options | Description | +| ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-h` `--help` | Displays general syntax and information on WAL scanner usage. | +| `-v` `--version` | Displays the WAL scanner version information. | +| `-d` `--debug` | Displays debugging output while executing the WAL scanner with any of its options. | +| `-c ` `--config-path ` | Use this option to specify the `config_file_path` of a BART configuration file if you do not want to use the default BART configuration file path `BART_HOME/etc/bart.cfg`. | +| `--daemon` | Runs the WAL scanner as a background process. | +| `-p ` `--print ` | Use this option to specify the full directory path to an MBM file whose content is to be printed. The directory specified in the `archive_path` parameter in the `bart.cfg` file contains the MBM files. | +| `` | Specify the full directory path to a WAL file to be scanned. The directory specified in the `archive_path` parameter in the `bart.cfg` file contains the WAL files. Use this option if a WAL file in the archive path is missing its MBM file. This option is to be used for assisting the EnterpriseDB support team for debugging problems that may have been encountered. | +| `RELOAD` | Reloads the BART configuration file. The keyword `RELOAD` is not case-sensitive. The `RELOAD` option is useful if you make changes to the configuration file after the WAL scanner has been started. It will reload the configuration file and adjust the WAL scanners accordingly. For example, if a server section allowing incremental backups is removed from the BART configuration file, then the process attached to that server will stop. Similarly, if a server allowing incremental backups is added, a new WAL scanner process will be launched to scan the WAL files of that server. | +| `STOP` | Stops the WAL scanner. The keyword `STOP` is not case-sensitive. | diff --git a/product_docs/docs/bart/2.5/bart_user/03_using_bart/index.mdx b/product_docs/docs/bart/2.5/bart_user/03_using_bart/index.mdx new file mode 100644 index 00000000000..a076b82b5e9 --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_user/03_using_bart/index.mdx @@ -0,0 +1,19 @@ +--- +title: "Using BART" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/using_bart.html" +--- + + + +After installing and configuring the BART host and the database servers, you can start using BART. + +This section describes how to perform backup and recovery management operations using BART. Review the sections that follow before proceeding with any BART operation. + +
+ +bart_management_overview managing_backups_using_a_retention_policy basic_bart_subcommand_usage running_the_bart_wal_scanner + +
diff --git a/product_docs/docs/bart/2.5/bart_user/04_using_tablespaces.mdx b/product_docs/docs/bart/2.5/bart_user/04_using_tablespaces.mdx new file mode 100644 index 00000000000..1615d140aef --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_user/04_using_tablespaces.mdx @@ -0,0 +1,59 @@ +--- +title: "Using Tablespaces" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/using_tablespaces.html" +--- + + + +If the database cluster contains user-defined tablespaces (that is, tablespaces created with the `CREATE TABLESPACE` command): + +- You can take full backups with the `BACKUP` subcommand in either tar (`-Ft`) or plain text (`-Fp`) backup file format. +- You must take incremental backups in the plain text (`-Fp`) backup file format. +- You can take full backups using the transaction log streaming method (xlog_method = stream in the BART configuration file) `--with-pg_basebackup` and the `BACKUP` subcommand in either tar (`-Ft`) or plain text (`-Fp`) backup file format. + +!!! Note + If the particular database cluster you plan to back up contains tablespaces created by the `CREATE TABLESPACE` command, then you must set the `tablespace_path` parameter in the BART configuration file before you perform a BART `RESTORE` operation. + +The `tablespace_path` parameter specifies the directory paths to which you want the tablespaces to be restored. It takes the following format: + + `OID_1=tablespace_path_1;OID_2=tablespace_path_2 ...` + +Where `OID_1`, `OID_2`, … are the Object Identifiers of the tablespaces. You can find the OIDs of the tablespaces and their corresponding soft links to the directories by listing the contents of the `POSTGRES_INSTALL_HOME/data/pg_tblspc` subdirectory as shown in the following example: + +```text +[root@localhost pg_tblspc ]# pwd +/opt/PostgresPlus/9.6AS/data/pg_tblspc +[root@localhost pg_tblspc]# ls -l +total 0 +lrwxrwxrwx 1 enterprisedb enterprisedb 17 Aug 22 16:38 16644 -> /mnt/tablespace_1 +lrwxrwxrwx 1 enterprisedb enterprisedb 17 Aug 22 16:38 16645 -> /mnt/tablespace_2 +``` + +The OIDs are `16644` and `16645` to directories `/mnt/tablespace_1` and `/mnt/tablespace_2`, respectively. + +If you later wish to restore the tablespaces to the same locations as indicated in the preceding example, the BART configuration file must contain the following entry: + +```text +[ACCTG] +host = 127.0.0.1 +port = 5444 +user = enterprisedb +cluster_owner = enterprisedb +tablespace_path = 16644=/mnt/tablespace_1;16645=/mnt/tablespace_2 +description = "Accounting" +``` + +If you later wish to restore the tablespaces to different locations, specify the new directory locations in the `tablespace_path` parameter. + +In either case, the directories specified in the `tablespace_path` parameter must exist and be empty at the time you perform the `BART RESTORE` operation. + +If the database server is running on a remote host (in other words you are also using the `remote_host` configuration parameter or will specify the `--remote-host` option with the `RESTORE` subcommand), the specified tablespace directories must exist on the specified remote host. + +To view example of backing up and restoring a database cluster on a remote host containing tablespaces, see the *EDB Backup and Recovery Reference Guide* available at the [EDB website](/bart/2.5/bart_ref/). + +The directories must be owned by the user account with which you intend to start the database server (typically the Postgres user account) with no access by other users or groups as is required for the directory path to which the main full backup is to be restored. + +To view a sample BART managed backup and recovery system consisting of both local and remote database servers, see the *EDB Backup and Recovery Reference Guide* available at the [EDB website](/bart/2.5/bart_ref/). diff --git a/product_docs/docs/bart/2.5/bart_user/images/EDB_logo.png b/product_docs/docs/bart/2.5/bart_user/images/EDB_logo.png new file mode 100644 index 00000000000..39a54822d85 Binary files /dev/null and b/product_docs/docs/bart/2.5/bart_user/images/EDB_logo.png differ diff --git a/product_docs/docs/bart/2.5/bart_user/images/copy_1.png b/product_docs/docs/bart/2.5/bart_user/images/copy_1.png new file mode 100644 index 00000000000..b15833dc37d Binary files /dev/null and b/product_docs/docs/bart/2.5/bart_user/images/copy_1.png differ diff --git a/product_docs/docs/bart/2.5/bart_user/images/edb.png b/product_docs/docs/bart/2.5/bart_user/images/edb.png new file mode 100644 index 00000000000..71e5bdde787 Binary files /dev/null and b/product_docs/docs/bart/2.5/bart_user/images/edb.png differ diff --git a/product_docs/docs/bart/2.5/bart_user/images/edb_logo.svg b/product_docs/docs/bart/2.5/bart_user/images/edb_logo.svg new file mode 100644 index 00000000000..f24d1dfefee --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_user/images/edb_logo.svg @@ -0,0 +1,19 @@ + + + edb-logo-disc-dark + + + + \ No newline at end of file diff --git a/product_docs/docs/bart/2.5/bart_user/index.mdx b/product_docs/docs/bart/2.5/bart_user/index.mdx new file mode 100644 index 00000000000..50504d9e3db --- /dev/null +++ b/product_docs/docs/bart/2.5/bart_user/index.mdx @@ -0,0 +1,17 @@ +--- +navTitle: Backup and Recovery Guide +title: "EDB Postgres Backup and Recovery User Guide" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/genindex.html" + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/introduction.html" + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/conclusion.html" + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/index.html" +--- + +
+ +introduction overview using_bart using_tablespaces conclusion + +
diff --git a/product_docs/docs/bart/2.5/bart_v2.5_documentation.pdf b/product_docs/docs/bart/2.5/bart_v2.5_documentation.pdf new file mode 100644 index 00000000000..8d0f4d884fe Binary files /dev/null and b/product_docs/docs/bart/2.5/bart_v2.5_documentation.pdf differ diff --git a/product_docs/docs/bart/2.5/index.mdx b/product_docs/docs/bart/2.5/index.mdx new file mode 100644 index 00000000000..478643cec40 --- /dev/null +++ b/product_docs/docs/bart/2.5/index.mdx @@ -0,0 +1,18 @@ +--- +title: Backup and Recovery Tool +directoryDefaults: + description: "EDB Backup and Recovery Tool Version 2.5 Documentation and release notes. A tool to manage and configure PostgreSQL backups and disaster recovery." +navigation: + - "#Getting Started" + - bart_inst + - bart_qs_7 + - bart_qs_8 + - "#Guides" + - bart_user + - bart_ref +#legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/p/edb-backup-and-recovery-tool/2.5" +--- + + diff --git a/product_docs/docs/bart/2.6.1/bart_inst/02_installing_bart.mdx b/product_docs/docs/bart/2.6.1/bart_inst/02_installing_bart.mdx new file mode 100644 index 00000000000..20b4b7e19e5 --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_inst/02_installing_bart.mdx @@ -0,0 +1,429 @@ +--- +title: 'Installing BART' + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/installation-getting-started/installation-upgrade-guide/2.6.1/installing_bart.html" +--- + +This section will walk you through performing a fresh installation of BART on a host. Installation instructions are organized into the following platform/installer specific sections: + +- [Installing BART on a CentOS](#installing-bart-on-a-centos-host) +- [Installing BART on a RHEL Host](#installing-bart-on-a-rhel-host) +- [Installing BART on a CentOS or RHEL Host](#installing-bart-on-a-rhelcentos-7-ppcle-host) +- [Installing BART on a Debian or Ubuntu Host](#installing-bart-on-a-debian-or-ubuntu-host) +- [Installing BART on an SLES 12 Host](#installing-bart-on-an-sles-12-host) + +!!! Note + If you are using the pdf version of this document, using cut/paste to copy command may result in extra spaces or carriage returns in the pasted command. If a command fails, check the command carefully for additional characters. + +## Installing BART on a CentOS Host + +The following section demonstrates installing BART on a CentOS host using an RPM package.  This section assumes that the user has some knowledge of installation and system administration procedures, and has administrative privileges on the host. + +1. To install the repository configuration, assume superuser privileges and invoke one of the following platform-specific commands: + + On CentOS 7: + + ```text + yum -y install https://yum.enterprisedb.com/edbrepos/edb-repo-latest.noarch.rpm + ``` + + On CentOS 8: + + ```text + dnf -y install https://yum.enterprisedb.com/edbrepos/edb-repo-latest.noarch.rpm + ``` + +2. Replace the `USERNAME:PASSWORD` in the following command with the username and password of a registered EnterpriseDB user: + + ```text + sed -i "s@:@USERNAME:PASSWORD@" /etc/yum.repos.d/edb.repo + ``` + + To request credentials for the repository, visit the [EDB website](https://www.enterprisedb.com/user). + +3. Before installing BART, execute the following command to install the Extra Packages for Enterprise Linux (EPEL) release package: + + On CentOS 7: + + ```text + yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm + ``` + + On CentOS 8: + + ```text + dnf -y install epel-release + ``` + +4. For CentOS 8, enable the PowerTools repository to satisfy EPEL package dependencies: + + ```text + dnf config-manager --set-enabled PowerTools + ``` + +5. For CentOS 8, disable the built-in PostgreSQL module: + + ```text + dnf -qy module disable postgresql + ``` + +6. Optionally, install the `pg_basebackup` utility program using the server client package. If you do not already have the `pg_basebackup` program installed on the BART host, you can install a limited number of files that include the `pg_basebackup` program by invoking the following command: + + On CentOS 7: + + ```text + yum install edb-as-server-client + ``` + + On CentOS 8: + + ```text + dnf install edb-as-server-client + ``` + + In the above command, replace `` with the required Advanced Server version. The `pg_basebackup` version must be the same or more recent than the database server to be backed up. For example, `pg_basebackup` version 10 can be used to back up database server version 10, but cannot be used to back up database server version 11. + +7. Use the following command to install BART: + + On CentOS 7: + + ```text + yum -y install edb-bart + ``` + + On CentOS 8: + + ```text + dnf -y install edb-bart + ``` + + Repeat the installation process described in this section to install BART on each remote host on which an incremental backup is to be restored. + + To verify the BART installation, navigate to the `/usr/edb/bart/bin` directory and execute the following command: + + ```text + bart --version + ``` + + The `bart --version` command should return the current BART version. If the `bart --version` command returns an error stating the PATH is not available after switching from the root user to another BART user account, adjust the setting of the `PATH` environment variable to include the directory location of the BART `bin` subdirectory in the `~/.bashrc` or `~/.bash_profile` files of the following user accounts: + + - The BART user account on the BART host. See [Configuring BART](03_configuring_bart/#path) for details. + - The remote user account on the remote host to which incremental backups are to be restored. For details, see the *EDB Backup and Recovery User Guide* available at the [EDB website](/bart/latest/bart_user/). + + Upon successful installation, BART is installed in the `BART_HOME` directory: + + `/usr/edb/bart` + + The installation includes the following files: + +| File Name | Location | Description | +| ------------------- | ----------------- | ------------------------------------- | +| bart | ``/bin | BART command line, executable program | +| bart-scanner | ``/bin | BART WAL scanner program | +| bart.cfg.sample | ``/etc | Sample BART configuration file | +| xlogreader_ident.so | ``/lib | Libraries supporting WAL versions | +| bart_license.txt | `` | License agreement | + +After BART is installed successfully, you need to [configure the installation](03_configuring_bart/#configuration). + +## Installing BART on a RHEL Host + +The following section demonstrates installing BART on a RHEL host using an RPM package.  This section assumes that the user has some knowledge of installation and system administration procedures, and has administrative privileges on the host. + +1. To install the repository configuration, assume superuser privileges and invoke one of the following platform-specific commands: + + On RHEL 7: + + ```text + yum -y install https://yum.enterprisedb.com/edbrepos/edb-repo-latest.noarch.rpm + ``` + + On RHEL 8: + + ```text + dnf -y install https://yum.enterprisedb.com/edbrepos/edb-repo-latest.noarch.rpm + ``` + +2. Replace the `USERNAME:PASSWORD` in the following command with the username and password of a registered EnterpriseDB user: + + ```text + sed -i "s@:@USERNAME:PASSWORD@" /etc/yum.repos.d/edb.repo + ``` + + To request credentials for the repository, visit the [EDB website](https://www.enterprisedb.com/user). + +3. Before installing BART, execute the following command to install the Extra Packages for Enterprise Linux (EPEL) release package: + + On RHEL 7: + + ```text + yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm + ``` + + On RHEL 8: + + ```text + dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm + ``` + +4. Enable the repository: + + On RHEL 7, enable the `optional, extras`, and `HA` repositories to satisfy EPEL package dependencies: + + ```text + subscription-manager repos --enable "rhel-*-optional-rpms" --enable "rhel-*-extras-rpms" --enable "rhel-ha-for-rhel-*-server-rpms" + ``` + + On RHEL 8, enable the `codeready-builder-for-rhel-8-*-rpms` repository to satisfy EPEL packages dependency: + + ```text + ARCH=$( /bin/arch ) + + subscription-manager repos --enable "codeready-builder-for-rhel-8-${ARCH}-rpms" + ``` + +5. For RHEL 8, disable the built-in PostgreSQL module: + + ```text + dnf -qy module disable postgresql + ``` + +6. Optionally, install the `pg_basebackup` utility program using the server client package. If you do not already have the `pg_basebackup` program installed on the BART host, you can install a limited number of files that include the `pg_basebackup` program by invoking the following command: + + On RHEL 7: + + ```text + yum install edb-as-server-client + ``` + + On RHEL 8: + + ```text + dnf install edb-as-server-client + ``` + + In the above command, replace `` with the required Advanced Server version. The `pg_basebackup` version must be the same or more recent than the database server to be backed up. For example, `pg_basebackup` version 10 can be used to back up database server version 10, but cannot be used to back up database server version 11. + +7. Use the following command to install the BART: + + On RHEL 7: + + ```text + yum -y install edb-bart + ``` + + On RHEL 8: + + ```text + dnf -y install edb-bart + ``` + + Repeat the installation process described in this section to install BART on each remote host on which an incremental backup is to be restored. + + To verify the BART installation, navigate to the `/usr/edb/bart/bin` directory and execute the following command: + + ```text + bart --version + ``` + + The `bart --version` command should return the current BART version. If the `bart --version` command returns an error stating the PATH is not available after switching from the root user to another BART user account, adjust the setting of the `PATH` environment variable to include the directory location of the BART `bin` subdirectory in the `~/.bashrc` or `~/.bash_profile` files of the following user accounts: + + - The BART user account on the BART host. See [Configuring BART](03_configuring_bart/#path) for details. + - The remote user account on the remote host to which incremental backups are to be restored. For details, see the *EDB Backup and Recovery User Guide* available at the [EDB website](/bart/latest/bart_user/). + + Upon successful installation, BART is installed in the `BART_HOME` directory: + + `/usr/edb/bart` + + The installation includes the following files: + +| File Name | Location | Description | +| ------------------- | ----------------- | ------------------------------------- | +| bart | ``/bin | BART command line, executable program | +| bart-scanner | ``/bin | BART WAL scanner program | +| bart.cfg.sample | ``/etc | Sample BART configuration file | +| xlogreader_ident.so | ``/lib | Libraries supporting WAL versions | +| bart_license.txt | `` | License agreement | + +After BART is installed successfully, you need to [configure the installation](03_configuring_bart/#configuration). + + + +## Installing BART on a RHEL/CentOS 7 PPCLE Host + +The following section demonstrates installing BART on a RHEL host using an RPM package.  This section assumes that the user has some knowledge of installation and system administration procedures, and has administrative privileges on the host. + +1. Install Advance Toolchain: + + ```text + rpm --import https://public.dhe.ibm.com/software/server/POWER/Linux/toolchain/at/redhat/RHEL7/gpg-pubkey-6976a827-5164221b + + cat > /etc/yum.repos.d/advance-toolchain.repo <:@USERNAME:PASSWORD@" /etc/yum.repos.d/edb.repo + ``` + + To request credentials for the repository, visit the [EDB website](https://www.enterprisedb.com/user). + +4. Before installing BART, execute the following command to install the Extra Packages for Enterprise Linux (EPEL) release package: + + ```text + yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm + ``` + +5. On RHEL 7, enable the `optional, extras`, and `HA` repositories to satisfy EPEL package dependencies: + + ```text + subscription-manager repos --enable "rhel-*-optional-rpms" --enable "rhel-*-extras-rpms" --enable "rhel-ha-for-rhel-*-server-rpms" + ``` + +6. Invoke the following command to install BART: + + ```text + yum -y install edb-bart + ``` + + + +## Installing BART on a Debian or Ubuntu Host + +Perform the following steps to install a Debian package using the EnterpriseDB apt repository. + +To request credentials for the repository, visit the [EDB website](https://www.enterprisedb.com/repository-access-request). + +1. Assume the superuser privileges. + + ```text + sudo su - + ``` + +2. To configure the EnterpriseDB repository on Debian 9, Ubuntu 18, and Ubuntu 20: + + ```text + sh -c 'echo "deb https://username:password@apt.enterprisedb.com/$(lsb_release -cs)-edb/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/edb-$(lsb_release -cs).list' + ``` + + On Debian 10: + + a. Set up the EnterpriseDB repository: + + ```text + sh -c 'echo "deb [arch=amd64] https://apt.enterprisedb.com/$(lsb_release -cs)-edb/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/edb-$(lsb_release -cs).list' + ``` + + b. Substitute your EnterpriseDB credentials for the `username` and `password` placeholders in the following command: + + ```text + sh -c 'echo "machine apt.enterprisedb.com login password " > /etc/apt/auth.conf.d/edb.conf' + ``` + +3. Add support to your system for secure APT repositories. + + ```text + apt-get install apt-transport-https + ``` + +4. Add the EDB signing key; When invoking the command, replace the `username` and `password` with the credentials provided by EnterpriseDB. + + ```text + wget -q -O - https://apt.enterprisedb.com/edb-deb.gpg.key | apt-key add – + ``` + +5. Update the repository metadata. + + ```text + apt-get update + ``` + +6. Install the Debian package. + + ```text + apt-get install edb-bart + ``` + + + +## Installing BART on an SLES 12 Host + +This section provides instructions for installing BART on an SLES 12 SP4 host using the zypper package manager. BART is supported on SLES SP4 and SP5 versions. + +1. Assume superuser privileges. + + ```text + sudo su - + ``` + +2. Use the following command to add the EDB repository to your SLES host: + + ```text + zypper addrepo https://zypp.enterprisedb.com/suse/edb-sles.repo + ``` + +3. Invoke the following command to refresh the metadata: + + ```text + zypper refresh + ``` + +4. Install `SUSEConnect` to register the host with SUSE to allow access to SUSE repositories: + + ```text + zypper install SUSEConnect + ``` + +5. Register the host with SUSE to allow access to SUSE repositories and replace `'REGISTRATION_CODE'` and `'EMAIL'` with your SUSE registration information: + + ```text + SUSEConnect -r 'REGISTRATION_CODE' -e 'EMAIL' + ``` + + ```text + SUSEConnect -p PackageHub/12.4/x86_64 + ``` + + ```text + SUSEConnect -p sle-sdk/12.4/x86_64 + ``` + +6. Install the following repository for PEM dependencies: + + ```text + zypper addrepo https://download.opensuse.org/repositories/Apache:/Modules/SLE_12_SP4/Apache:Modules.repo + ``` + +7. Refresh the metadata: + + ```text + zypper refresh + ``` + +8. Then, use the zypper utility to install BART: + + ```text + zypper -n install edb-bart + ``` diff --git a/product_docs/docs/bart/2.6.1/bart_inst/03_configuring_bart.mdx b/product_docs/docs/bart/2.6.1/bart_inst/03_configuring_bart.mdx new file mode 100644 index 00000000000..e9b3a129f84 --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_inst/03_configuring_bart.mdx @@ -0,0 +1,641 @@ +--- +title: "Configuring BART" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/installation-getting-started/installation-upgrade-guide/2.6.1/configuring_bart.html" +--- + + + +To configure BART, you must establish the BART user account, [configure the BART host](#configuring-the-bart-host), and [configure the database server](#configuring_database_server) that will be backed up. + + + +## Establishing the BART User Account + +The BART user account is an operating system user that will run the BART command line program. The BART user account must: + +- own the BART backup catalog. +- be able to run the `bart` program and the `bart-scanner` program. +- be able to establish a SSH/SCP connection to and from each database server managed by BART. + +You can optionally use the `enterprisedb` database user as the BART user account for an Advanced Server database and `postgres` database user as the BART user account for a PostgreSQL server. If you do not wish to use an existing database user as the BART user account, you must create an operating system user to assume the role. + + + +## Configuring BART and Database Server + +As stated earlier, to configure BART, you must [configure the BART host](#configuring-the-bart-host) as well as the [database server](#configuring_database_server). The following table acts as a configuration parameter reference listing the mandatory and optional parameters with default values for `[SERVER]` as well as `[BART]` sections. + +- Parameters set in the `[BART]` section are applicable to all BART managed database servers. +- Parameters set in the `Server` section are applicable only to the specific server; the `Server` parameter setting overrides the `[BART]` section setting. + +For information about configuring BART host parameters, see the [BART Host Parameter Reference](#bart) and for information about configuring the database server parameters, see the [Database Server Parameter Reference](#server). + +| **Parameter** | **Type** | **Default** | **\[SERVER]** | **\[BART]** | +| -------------------------- | --------- | ------------------------------------------------------------ | ------------- | ----------- | +| `[BART]` | Mandatory | N/A | N/A | Yes | +| `` | Mandatory | N/A | N/A | Yes | +| `` | Mandatory | N/A | N/A | Yes | +| `` | Mandatory | N/A | N/A | Yes | +| `retention_policy` | Optional | `BACKUPS` | Yes | Yes | +| `wal_compression` | Optional | `Disabled` | Yes | Yes | +| `copy_wals_during_restore` | Optional | `Disabled` | Yes | Yes | +| `xlog_method` | Optional | `fetch` | Yes | Yes | +| `logfile` | Optional | `/tmp/bart.log` | N/A | Yes | +| `scanner_logfile` | Optional | `/tmp/bart_scanner.log` | N/A | Yes | +| `` | Optional | `/tmp` | N/A | Yes | +| `` | Optional | `1` | Yes | Yes | +| `` | Optional | `49152` | Yes | Yes | +| `` | Optional | `0` | Yes | Yes | +| `` | Optional | `20 seconds` | Yes | Yes | +| `` | Optional | `1` | Yes | Yes | +| `[Server Name]` | Mandatory | N/A | Yes | N/A | +| `` | Optional | N/A | Yes | N/A | +| `host` | Mandatory | N/A | Yes | N/A | +| `port` | Mandatory | `5444` for EPAS; `5432` for Postgres | Yes | N/A | +| `user` | Mandatory | N/A | Yes | N/A | +| `` | Optional | `BART backup catalog` | Yes | N/A | +| `` | Optional | N/A | Yes | N/A | +| `` | Mandatory | `enterprisedb` for EPAS

`postgres` for PostgreSQL | Yes | N/A | +| `` | Optional | N/A | Yes | N/A | +| `` | Optional | N/A | Yes | N/A | +| `allow_incremental_backup` | Optional | `Disabled` | Yes | N/A | +| `description` | Optional | N/A | Yes | N/A | + + + +### Configuring the BART Host + +To configure the BART host, perform the following steps on the BART host as a root user: + +**Step 1.** Navigate to the `usr/edb/bart/etc` directory and make a copy of the `bart.cfg.sample` file to create the `bart.cfg` file that will contain the parameter settings. + +**Step 2.** Confirm that the Postgres `pg_basebackup` utility program is installed on the BART host. The `pg_basebackup` utility resides in the `bin` directory under your Postgres installation. + + + +**Step 3.** Ensure the `LD_LIBRARY_PATH` environment variable includes the location of the `libpq` library. If your `libpq` library does not reside in the default location (`POSTGRES_INSTALL_HOME/lib`), you must add the library path to the `LD_LIBRARY_PATH` environment variable in the BART user account’s profile (`bash_profile`) located in `/home/`: + +```text +# .bash_profile +# Get the aliases and functions +if [ -f ~/.bashrc ]; then +. ~/.bashrc +fi +# User specific environment and startup programs +export LD_LIBRARY_PATH=/usr/edb/as11/lib:$LD_LIBRARY_PATH +``` + +**Step 4.** Create the BART backup catalog and ensure the BART user account holds privileges on the BART backup catalog. In the following example, the BART configuration file specifies `/opt/backup` as the parent directory for the BART backup catalog in the `` parameter: + +```text +[BART] + +bart_host = bartuser@192.168.2.22 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log +``` + +In the following example, `bartuser` is the BART user account. The example creates and sets the ownership and permissions on the BART backup catalog: + +```text +su root +mkdir /opt/backup +chown bartuser /opt/backup +chgrp bartuser /opt/backup +chmod 700 /opt/backup +``` + +If the subdirectory does not exist, BART creates a subdirectory for each database server listed in the configuration file when you invoke the `bart` command line program. + +**Step 5.** Use your choice of editor to open the BART configuration file (located in the `usr/edb/bart/etc` directory) and edit the configuration as required. You must add the mandatory parameters to the `[BART]` section. Default values may be used for optional parameters. + +The following table describes the `[BART]` host parameters. + + + +| **Parameters/Placeholder** | **Type** | **Description** | +| -------------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `[BART}` | Mandatory | Identifies the global section of the configuration file. It must be named BART. | +| `bart_host` | Mandatory | Specify the bart user name and the IP address of the bart host on which the BART utility resides. You must specify it in the form of <bart_user>@<bart_host_address>. | +| `backup_path` | Mandatory | Specify the path to the file system parent directory where all BART backups are stored. | +| `pg_basebackup_path` | Mandatory | Specify the path to the `pg_basebackup` program that you installed on the BART host. For information about `pg_basebackup` version-specific restrictions, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/latest/bart_user/). | +| `wal_compression` | Optional | Set this parameter to `enabled` to compress the archived WAL files in gzip format in the BART backup catalog when the `MANAGE` subcommand is invoked. By default it is set to `disabled`. The gzip compression program must be in the BART user account’s `PATH` and the WAL compression setting must not be enabled for those database servers where you need to take incremental backups. | +| `copy_wals_during_restore` | Optional | Set this parameter to `enabled` to copy the archived WAL files from the BART backup catalog to the `restore_path/archived_wals` directory prior to the database server archive recovery. Enabling this option helps you save time during the restore operation. Set this parameter to `disabled` (default) to retrieve the archived WAL files directly from the BART backup catalog during the database server archive recovery. During the restore operation, recovery settings will be saved in the `postgresql.auto.conf` file. The `restore_command` in the `postgresql.auto.conf` file will be determined by the value specified in the `copy_wals_during_restore` parameter. If the `RESTORE` subcommand is invoked with the `-c` option, the archived WAL files are copied from the BART backup catalog to the `restore_path/archived_wals` directory, thus overriding any setting of the `copy_wals_during_restore` parameter. If the `RESTORE` subcommand is invoked without the `-c` option, the value specified by the `copy_wals_during_restore` parameter is used. | +| `xlog_method` | Optional | Specify how the transaction log is collected during the execution of `pg_basebackup` through the `BACKUP` subcommand. Set `xlog_method` to `fetch` (default) to collect the transaction log files after the backup is completed. Set to `stream` to stream the transaction log in parallel with the full backup creation. | +| `retention_policy` | Optional | Set this parameter to determine when an active backup should be marked as `obsolete` when the `MANAGE` subcommand is used. You can specify the retention policy either in terms of number of backups or duration (days, weeks, or months). ` BACKUPS` (default), ` DAYS`, ` WEEKS`, or ` MONTHS` where `` is a positive integer. For information about managing backups using a retention policy, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/latest/bart_user/). | +| `logfile` | Optional | Use this parameter to specify the path to the BART log file. The default log file location is `/tmp/bart.log`. The log file will be created the first time you invoke the `bart` command line program using the sample configuration file value. To change the default setting, you must delete the `bart.log` file from the `/tmp` directory and create a new log file in another directory so that a new log file will be created and owned by the new BART user account. If no path to a log file is specified, BART does not create a log file. | +| `scanner_logfile` | Optional | Use this parameter to specify the path to the XLOG/WAL scanner log file. The default location is `/tmp/bart_scanner.log`. The scanner log file will be created the first time you invoke the `bart_scanner` program using the sample configuration file value. To change the default setting, you must delete the `bart_scanner.log` file from the `/tmp` directory and create a new log file in another directory so that a new log file will be created and owned by the new BART user account. If no path to a log file is specified, BART does not create a WAL scanner log file. | +| `` | Optional | Specify the socket directory path where all BART sockets will be stored. The default directory is `/tmp`. While specifying the `bart_socket_directory` path, you must ensure that the directory exists and the BART user has the required access permissions to the directory. | +| `` | Optional | Specify the number of worker threads for copying blocks (for incremental backups) or data files (for full backup) from the database server to the `archive_path` when the `BACKUP` subcommand is invoked. The default value is `1`. The same set of worker threads are used for the compression operation when taking full backups in order to provide parallel, compressed backups when the `BACKUP` subcommand is specified with the `-z` or `-c` options. The compression operation does not apply to incremental backups. See [thread count](#thread_count) for more information. | +| `` | Optional | Specify the number of blocks of memory used for copying modified blocks from the database server to the `archive_path` when the `BACKUP` subcommand is invoked for incremental backups. The default value is 49152 blocks; each block is 8192 bytes. The maximum permitted value is 131072 blocks and the minimum permitted value is 1 block. Reduce the `` setting if the server runs out of memory while executing the `pg_read_binary_file()`. | +| `` | Optional | Specify the number of seconds after which the WAL scanner should initiate force scanning of the new WAL files. The default value is 0, which means no brute-force scanning will be started. After upgrading to the latest version of BART, users who have set this parameter to a non-default value may see increased CPU consumption on the part of bart-scanner. If this is an issue, consider increasing the configured value of `scan_interval` parameter, or removing the setting if it is not required. | +| `` | Optional | Specify the number of seconds to wait for MBM files before timing out; this parameter is applicable only for incremental backup. You must set the `scan_interval` to a value significantly less than the MBM scan timeout. The default value is 20 seconds. The `mbm_scan_timeout` parameter value must be greater than 0. If the value is 0 or negative, then an error will be displayed during an incremental backup. | +| `` | Optional | Specify the number of parallel worker processes required to stream the modified blocks of an incremental backup to the restore host. The default value is 1. | + + + +**Thread Count** + +If the `BACKUP` subcommand is invoked with the `--thread-count` option, then the number of worker threads specified by this option overrides any setting of the `thread_count` parameter in the BART configuration file. If the `BACKUP` subcommand is invoked without the `--thread-count` option, then the following determines the number of worker threads used: + +- The setting of the `thread_count` parameter in the server section of the BART configuration file overrides the setting of `thread_count` in the global section for that particular database server. +- If omitted in the server section, the setting of `thread_count` in the global section is used. +- If the `thread_count` parameter is not specified in either section, the default is 1. +- When taking a full backup, if the `thread count` in effect is only 1, then the `pg_basebackup` utility is used to take the full backup unless the `--no-pg_basebackup` option is specified with the `BACKUP` subcommand. + +`` will not be effective if the backup is taken on a standby server. + +If parallel backup is run with `N` number of worker threads, then it will initiate `N + 1` concurrent connections with the server. + +**Step 6** Invoke the `CHECK-CONFIG` subcommand, omitting the `-s` option to check the parameter settings in the BART configuration file. It should return the current BART version. + +```text +bart CHECK-CONFIG +``` + +The `CHECK-CONFIG` subcommand displays an error message if the required configuration is not properly set. You need to check the logfile to fix this. + + + +### Configuring the Database Server + +To configure the database server, you must: + +1. [Authorize SSH/SCP access without a password prompt](#authorizing_ssh_scp_access). +2. [Create and configure a replication database user](#setting_up_a_replication_database_user). +3. [Adding the database server to the configuration file (server section)](#adding_a_database_server). +4. [Enable WAL archiving of the server](#enabling_wal_archiving). +5. [Verify the server configuration settings](#verifying_configuration_settings). + +The following section will walk you through the configuration process. + +!!! Note + You must authorize SSH/SCP access and set up a replication database user before restarting the database server with WAL archiving enabled. + + + +**Authorizing SSH/SCP Access** + +BART uses the Secure Shell (`ssh`) and Secure Copy (`scp`) Linux utility programs to copy the backup and WAL files from the BART managed database servers to the BART host as well as to restore backups. + +- The client/server `ssh` and `scp` commands must not prompt for a password when establishing a connection with the target server (the server to which a passwordless connection is being made). +- A passwordless connection uses *authorized public keys* (public key of a client user account) to authenticate with the target server. +- You must add the public key of each client user account to the target user account’s authorized public keys list on the target server. + +For BART usage, there are two scenarios that require a passwordless SSH/SCP connection: + +- When connecting from each BART managed database server (SSH/SCP client) to the BART host (target SSH/SCP server) to support WAL archiving as implemented by the `archive_command` parameter. + - In this case, the database server user account should generate the public key file (`id_rsa.pub`) with the `ssh-keygen –t rsa` command on the database server host. + - The public key file name should be appended to the `~/.ssh/authorized_keys` file on the BART host. The `authorized_keys` file is in the BART user account’s home directory. +- When connecting from the BART host (SSH/SCP client) to each BART managed database server (target SSH/SCP server) for taking incremental backups and for supporting restoration of the full backup, the archived WAL files, and the modified blocks, which occurs when the BART `RESTORE` subcommand is given. + - In this case, the BART user account should generate the public key file (`id_rsa.pub`) with the `ssh-keygen –t rsa` command on the BART host. + - The public key file name should be appended to the `~/.ssh/authorized_keys` file on the database server host. The `authorized_keys` file is in the home directory of the user account that owns the directory where the database backup is to be restored. +- If backups are to be taken from a given database server host, but restored to a different database server host, the passwordless SSH/SCP connections must be configured from the BART host to the database server host from which the backup is to be taken as well as from the BART host to the database server host to which the backup is to be restored. + +See the EDB Backup and Recovery Reference Guide available at the [EDB website](/bart/latest/bart_ref/) to view examples of creating a passwordless connection. + +**Enabling Public Key Authentication** + +The following example enables SSH/SCP access on a CentOS 7.x host; similar (platform-specific) steps will apply to other platforms/versions. + +1. In the SSH server daemon configuration file (`sshd_config`) located in the `/etc/ssh`, set the `PubkeyAuthentication` parameter to `yes`. +2. Reload the configuration file: + +```text +service sshd reload +``` + +If you get any SSH or SCP errors, examine the `/var/log/secure` log file. + +**Creating a Passwordless Connection** + +The following general instructions will walk you through generating a client’s public key file, creating the target server’s authorized public keys file, and creating a passwordless connection. + +**Step 1.** On the client system, log in as the user account that will be initiating the SSH or SCP connection. + +**Step 2.** Navigate to the user account’s home directory and check for an existing `.ssh` subdirectory. If the `.ssh` directory does not exist, create one and assign the required privileges to the user. + +**Step 3.** Generate the public key file with the following command. Accept all prompted defaults and do not specify a passphrase when prompted for one. + +```text +ssh-keygen –t rsa +``` + +The public key file named `id_rsa.pub` is created in the `.ssh` subdirectory. + +**Step 4.** While logged into the client where you just generated the public key file, use `SCP` to make a temporary copy of it on the target server: + +```text +scp ~/.ssh/id_rsa.pub @:tmp.pub +``` + +**Step 5.** Navigate into the target user account’s home directory and check for an existing `.ssh` subdirectory. If it does not exist, create one and assign the required privileges to the user. + +**Step 6.** Append the temporary, client’s public key file, `tmp.pub`, to the `authorized_keys` file. If an `authorized keys` file does not exist, create a new file, but do not completely replace any existing `authorized keys` file. + +```text +cat tmp.pub >> ~/.ssh/authorized_keys +``` + +Make sure the `authorized_keys` file is only accessible by the file owner and not by groups or other users. If the `authorized_keys` file does not have the required permission setting or it was newly created, change the file permissions as follows: + +```text +chmod 600 ~/.ssh/authorized_keys +``` + +**Step 7.** Delete the temporary public key file: + +```text +rm tmp.pub +``` + +Now, when logged into the client system as `user` there should be no prompt for a password when commands such as the following is given: + +```text +ssh target_user@host_address +``` + + + +**Setting up a Replication Database User** + +For each database server that is to be managed by BART, a database user must be chosen to serve as the *replication database user*. The replication database user sets the Postgres `archive_command` configuration parameter when the `INIT` subcommand in invoked and creates backups when the `BACKUP` subcommand is invoked. The replication database user must be a `superuser`. + +When executed with the PSQL client, the following PostgreSQL command creates a superuser to be the replication database user: + +`CREATE ROLE repuser WITH LOGIN SUPERUSER PASSWORD 'password';` + +The `pg_hba.conf` file must minimally permit the replication database user to have access to the database. + +In the following example, the `pg_hba.conf` file permits the `repuser` (replication database user) to have access to the `template1` database. The IP address from which `repuser` has access to `template1` database is the location of the BART host: + +**For pg_basebackup only:** If `pg_basebackup` is to be used for taking any backups (such as for standby servers), the replication database user must also be included in the `pg_hba.conf` file as a `replication` database connection as shown by the last entry in the following example. + +```text +# TYPE DATABASE USER ADDRESS METHOD +# "local" is for Unix domain socket connections only +local all all md5 +# IPv4 local connections: +host template1 repuser 192.168.2.22/32 md5 +host all enterprisedb 127.0.0.1/32 md5 +# IPv6 local connections: +host all all ::1/128 md5 +# Allow replication connections from localhost, by a user with the +# replication privilege. +host replication repuser 192.168.2.22/32 md5 +``` + +The replication database user must be specified for the `user` parameter in the BART configuration file for the database server as shown in the following example: + +```text +[ACCTG] +host = 192.168.2.24 +port = 5444 +user = repuser +cluster_owner = enterprisedb +remote_host = enterprisedb@192.168.2.24 +description = "Accounting" +``` + +There must be no password prompt when connecting to the database server with the replication database user. There are several ways to permit this; one recommended method is to use a `.pgpass` file located in the BART user account’s home directory. + +For example, if `bartuser` is the BART user account, then the `.pgpass` file located in the `/home/bartuser` directory must contain the following entry: + +`192.168.2.24:5444::repuser:password` + +When `bartuser` invokes a BART backup, the password for the replication database user, `repuser`, is obtained from the `.pgpass` file of `bartuser` to connect to the database server running at `192.168.2.24` on `port 5444`. + +The `.pgpass` file must contain an entry for each BART managed database server and its corresponding replication database user and password. + + + +**Adding a Database Server to the BART Configuration File** + +To manage the backup and recovery of a database server, you must add entries to the `[SERVER]` section of the BART configuration file, which is located in `/etc` directory. + + + +*Database Server Parameter Reference* + +Set the following parameters in the \[`SERVER`] section of the BART configuration file. The parameter setting in the \[`SERVER`] section overrides the setting in the global \[`BART`] section for that particular database server. If omitted, the default value will be used. + +For each cluster serviced by BART, the following parameters are mandatory: + +```text +[HR] + +host = 192.168.2.24 +port = 5432 +user = postgres +cluster_owner = postgres +``` + +!!! Note + The port parameter setting is required only if the database server listens on a port other than the default (for example if Postgres listens on a port other than 5432). + +The following table describes the database server parameters. + + + + + + + + + +| **Parameters/Placeholder** | Type | **Description** | +| --------------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `[ServerName]` | Mandatory | Specify the server name that you want to backup using BART. It is not case-sensitive when referenced with BART subcommand options. A lowercase conversion of this name is used to create a subdirectory in the BART backup catalog for storing the backups and WAL files for this database server (for eg., epas12). | +| `` | Optional | Specify a [template](#backup_name_template) for user-defined, friendly names that will be assigned to the backups of the database server. The maximum permitted length of backup name is 49 characters. The `` parameter can be overridden by the `--backup-name` option of the `BACKUP` subcommand. If this parameter is omitted from the BART configuration file, and the `--backup-name` option with a user-defined name is not specified with the `BACKUP` subcommand, then the backup can only be referenced in BART subcommands by the BART assigned, integer backup identifier. | +| `host` | Mandatory | Specify the IP address of the database server to be configured for backup. | +| `port` | Mandatory | Specify the port number identifying the database server instance (that is, the relevant database cluster) to be backed up. The default port number for EPAS is `5444` and for Postgres it is `5432`. The port parameter setting is only required if the database server listens on a port other than the default value. | +| `User` | Mandatory | Specify the replication database user name used by BART to establish the connection to the database server for full backups. See [Setting up a Replication Database User](#setting_up_a_replication_database_user) for more information. | +| `` | Optional | Specify the path where archived WAL files will be stored. The default location is the BART backup catalog (`//archived_wals`). | +| `` | Optional | When the `INIT` subcommand is used, the content and variables specified in the BART `` result in the archive command string to be generated into the `Postgres archive_command` parameter in the `postgresql.auto.conf` file. To configure the BART `` parameter, enclose the command string within single quotes ('). If you do not specify the `` parameter in the configuration file, the default setting is taken as `'scp %p %h:%a/%f'`. See [Archive Command Auto Configuration](#archive_command_auto_configuration) for information about variables. The BART `` parameter in the BART configuration file, and the Postgres `` parameter in the `postgresql.conf` file (or the `postgresql.auto.conf` file) refer to two different parameters that are to be set in different manner. | +| `` | Mandatory | Specify the Linux operating system user account that owns the database cluster. This is typically `enterprisedb` for Advanced Server database clusters installed in the Oracle compatible mode, or `postgres` for Advanced Server database clusters installed in the PostgreSQL compatible mode and PostgreSQL database clusters. | +| `` | Optional | Specify the IP address of the remote server to which a backup is to be restored. Specify this parameter in the form of `@`. `` is the user account on the target database server host that accepts a passwordless SSH/SCP login connection and owns the directory where the backup is to be restored. `` is the IP address of the remote host. For restoring a backup to a remote host or for restoring any backup where `` and the BART user account are not the same users, either this parameter must be set or it may be specified with the `-r` option with the BART `RESTORE` subcommand. | +| `` | Optional | Specify path to which tablespaces are to be restored in the format `OID = `; If the backup is to be restored to a remote host specified by the `` parameter, then the tablespace paths must exist on the remote host. | +| `allow_incremental_backups` | Optional | Set this parameter to `enabled` to enable use of the WAL scanner and permit taking incremental backups when the `BACKUP` subcommand is invoked with the `--parent` option. Set it to `disabled` (default) to disallow incremental backups and thus permit only full backups. For information about using the `BACKUP` subcommand and running the WAL scanner, please see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/latest/bart_user/). | +| `Description` | Optional | Specify the description that will be used to identify the database server. | + +For information regarding the following parameters, see [configuring the BART host](#configuring-the-bart-host). + +- `retention_policy` +- `xlog_method` +- `wal_compression` +- `copy_wals_during_restore`. +- `thread_count`. +- `batch_size`. +- `scan_interval`. +- `mbm_scan_timeout`. +- `workers` + + + +**Backup Name Template** + +- The template is an alphanumeric string that may include the following variables that will be replaced with the timestamp values when the backup is taken: + + - `%year` to be replaced by 4-digit year + - `%month` to be replaced by 2-digit month + - `%day` to be replaced by 2-digit day + - `%hour` to be replaced by 2-digit hour + - `%minute` to be replaced by 2-digit minute + - `%second` to be replaced by 2-digit second + +- To include a percent sign (`%`) as a character in the backup name, specify `%%` in the template. + +- Do not enclose the template string in quotes even if you want the template to include space characters, otherwise the enclosing quotes are stored as part of the backup name. However, when referenced with the `-i` option by BART subcommands use of space characters in the backup name requires enclosing the backup name in quotes. + +The following example shows the configuration settings of three database servers: + +```text +[ACCTG] + +host = 127.0.0.1 +port = 5444 +user = enterprisedb +cluster_owner = enterprisedb +backup_name = acctg_%year-%month-%dayT%hour:%minute:%second +archive_command = 'cp %p %a/%f' +allow_incremental_backups = enabled +retention_policy = 8 BACKUPS +description = "Accounting" + +[MKTG] + +host = 192.168.2.24 +port = 5444 +user = repuser +cluster_owner = enterprisedb +remote_host = enterprisedb@192.168.2.24 +allow_incremental_backups = enabled +description = "Marketing" + +[HR] + +host = 127.0.0.1 +port = 5432 +user = postgres +cluster_owner = postgres +retention_policy = 4 DAYS +description = "Human Resources" +``` + + + +**Enabling WAL Archiving** + +WAL archiving must be enabled for the database server for which BART is to perform backup and recovery management. + +- The WAL Archiving Configuration section describes the manual WAL archiving configuration process. +- The Archive Command Auto Configuration section describes an automated WAL archiving process. + +*WAL Archiving Configuration* + +Set the following configuration parameters in the `postgresql.conf` file to enable WAL archiving + +- Set `wal_level` to `replica` or higher. +- Set `archive_mode` to `on`. +- Set the PostgreSQL `archive_command` parameter to copy the WAL files to the `archive_path`. The `archive_command` configuration parameter mentioned here is located in the `postgresql.conf` file; the PostgreSQL `archive_command` parameter is used in a different manner than the BART [archive_command](#archive_command). +- Set `max_wal_senders` to a value high enough to leave at least one session available for the backup. If the `xlog_method=stream` parameter setting is to be used by this database server, the `max_wal_senders` setting must account for an additional session for the transaction log streaming (the setting must be a minimum of 2). See [Configuring the BART host](#configuring-the-bart-host) for information about the `xlog_method` parameter. + +For detailed information about WAL archiving, see the [PostgreSQL Core Documentation](https://www.postgresql.org/docs/current/static/continuous-archiving.html). + +The `ARCHIVE PATH` field displayed by the BART `SHOW-SERVERS` subcommand displays the full directory path where the WAL files should be copied as specified in the `archive_command` configuration parameter in the `postgresql.conf` file: + +```text +-bash-4.1$ bart SHOW-SERVERS -s acctg +SERVER NAME : acctg +HOST NAME : 192.168.2.24 +USER NAME : repuser +PORT : 5444 +REMOTE HOST : +RETENTION POLICY : none +DISK UTILIZATION : 0.00 bytes +NUMBER OF ARCHIVES : 0 +ARCHIVE PATH : /opt/backup/acctg/archived_wals +ARCHIVE COMMAND : (disabled) +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +INCREMENTAL BACKUP : DISABLED +DESCRIPTION : "Accounting" +``` + +The parameter settings in the following example will copy the WAL files to a directory named `/opt/backup/acctg/archived_wals` on the BART host located at `192.168.2.22` as the `bartuser` user account. Using the `bartuser` account ensures that the operation will have sufficient permissions to copy to the BART backup catalog owned by `bartuser`. + +```text +archive_mode = on # allows archiving to be done + # (change requires restart) +archive_command = 'scp %p bartuser@192.168.2.22:/opt/backup/acctg/archived_wals/%f' + # command to use to archive a logfile segment + # placeholders: %p = path of file to archive + # %f = file name only +... + +max_wal_senders = 1 # max number of walsender processes + # (change requires restart) +``` + +The database server must be restarted in order to initiate WAL archiving, but do not do so until you have verified that the full path of the BART backup catalog has been created by a prior BART subcommand or the archive operation will fail. + +Start the WAL scanner by executing the following command: + +```text +./bart-scanner +``` + + + +*Archive Command Auto Configuration* + +To enable WAL archiving: + +- In the `postgresql.conf` file, set the `wal_level` to `replica` or higher, `archive_mode` to `on`, and `max_wal_senders` to a value high enough to leave at least one session available for the backup. If the `xlog_method=stream` parameter setting is to be used by this database server as determined in the BART configuration file, the `max_wal_senders` setting must account for an additional session for the transaction log streaming (that is, the setting must be a minimum of `2`). See [Configuring the BART host](#configuring-the-bart-host) for information on the `xlog_method` parameter. + +- Configure the Postgres `archive_command` parameter automatically with the `INIT` subcommand and restart the database server when you are ready to initiate WAL archiving. The `INIT` subcommand invokes the Postgres `ALTER SYSTEM` command to set the Postgres `archive_command` configuration parameter in the `postgresql.auto.conf` file located in the managed database server’s `POSTGRES_INSTALL_HOME data directory`. For additional information about the `INIT` subcommand, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/latest/bart_user/). + + The archive command string that the `INIT` subcommand generates into the `postgresql.auto.conf` file is determined by the parameter setting of the BART `archive_command` parameter in the server section of the BART configuration file. If the BART `archive_command` parameter is not set in the server section for a given database server, the command string that is configured uses the following default format: + + `'scp %p %h:%a/%f'` + + The following table describes these variables: + +| **Variable** | **Description** | +| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `%p` | The path of the file to archive used by the Postgres archiving process. | +| `%h` | Will be replaced by the `@` as specified in the <bart_host> parameter setting. | +| `%a` | Will be replaced by the BART `archived_wals` directory as specified in the [archive path](#archive_path) parameter setting. If the `` is not specified, then the default directory is `//archived_wals`. `` is the lowercase conversion of the database server name. | +| `%f` | The archived file name used by the Postgres archiving process. | + +The placeholders `%h` and `%a` are replaced by the `INIT` subcommand when creating the archive command string. The placeholders `%p` and `%f` are not replaced by the `INIT` subcommand, but are kept as given to be used by the Postgres archiving process. + +For example, to use the default archive command format, the BART configuration file contains the following settings where the BART `archive_command` parameter is omitted from the server section for `ACCTG`: + +```text +[BART] + +bart_host= bartuser@192.168.2.22 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log + +[ACCTG] + +host = 127.0.0.1 +port = 5444 +user = repuser +cluster_owner = enterprisedb +description = "Accounting" +``` + +The `INIT` subcommand is invoked by BART user account `bartuser` as follows: + +```text +[bartuser@localhost ~]$ bart INIT -s acctg -o +INFO: setting archive_command for server 'acctg' +WARNING: archive_command is set. server restart is required +``` + +If the BART backup catalog directory is not already complete, it will be completed. + +The resulting archive command string in the `postgresql.auto.conf` file located in the managed database server’s `POSTGRES_INSTALL_HOME/data directory` appears as follows: + +```text +# Do not edit this file manually! +# It will be overwritten by ALTER SYSTEM command. +archive_command = 'scp %p +bartuser@192.168.2.22:/opt/backup/acctg/archived_wals/%f' +``` + +Run the `INIT` subcommand with the `-o` option to override any existing `archive_command` setting in the `postgresql.conf` or the `postgresql.auto.conf` file. In addition, the `-o` option must be used to generate the command string if the `archive_mode` is set to off even if there are no existing settings of the `archive_command` in the `postgresql.conf` or `postgresql.auto.conf` files. + +In this example, the following BART configuration file is used with an explicit setting of the BART `archive_command` parameter: + +```text +[BART] + +bart_host= enterprisedb@192.168.2.22 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log + +[ACCTG] + +host = 127.0.0.1 +port = 5444 +user = repuser +cluster_owner = enterprisedb +archive_command = 'cp %p %a/%f' +description = "Accounting" +``` + +The `INIT` subcommand is invoked by BART user account `enterprisedb` as follows: + +```text +-bash-4.1$ bart INIT -s acctg -o +INFO: setting archive_command for server 'acctg' +WARNING: archive_command is set. server restart is required +``` + +The resulting Postgres `archive_command` parameter in the `postgresql.auto.conf` file appears as follows: + +```text +# Do not edit this file manually! +# It will be overwritten by ALTER SYSTEM command. +archive_command = 'cp %p /opt/backup/acctg/archived_wals/%f' +``` + +When the database server has been restarted, the `ARCHIVE COMMAND` field of the `SHOW-SERVERS` subcommand displays the active Postgres archive command as shown by the following example: + +```text +-bash-4.1$ bart SHOW-SERVERS -s acctg +SERVER NAME : acctg +HOST NAME : 127.0.0.1 +USER NAME : repuser +PORT : 5444 +REMOTE HOST : +RETENTION POLICY : none +DISK UTILIZATION : 48.00 MB +NUMBER OF ARCHIVES : 0 +ARCHIVE PATH : /opt/backup/acctg/archived_wals +ARCHIVE SCOMMAND : `cp %p /opt/backup/acctg/archived_wals/%f` +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +INCREMENTAL BACKUP : DISABLED +DESCRIPTION : "Accounting" +``` + + + +**Verifying Configuration Settings** + +To verify the parameter settings of the database server specified, execute tthe `CHECK-CONFIG` subcommand with the `–s` option: + +```text +bart CHECK-CONFIG [ –s server_name ] +``` + +The `CHECK-CONFIG` subcommand confirms the following: + +- The `cluster_owner` parameter is set to the user account owning the database cluster directory. +- A passwordless SSH/SCP connection is set between the BART user and the user account specified by the `cluster_owner` parameter. +- The BART `user` parameter specifies a database superuser. +- The BART `user` has access to the backup directory catalog. +- The `pg_hba.conf` file contains a replication entry for the database superuser specified by the BART `user` parameter. +- The `archive_mode` parameter in the `postgresql.conf` file is enabled. +- The `archive_command` parameter in the `postgresql.auto.conf` or the `postgresql.conf` file is set. +- The `allow_incremental_backups` parameter in the BART configuration file is enabled for database servers for which incremental backups are to be taken. +- Archiving of WAL files to the `archive_path` is in process. +- The WAL scanner program is running. + +After configuring the BART host and the database server(s), you can start using BART. For information about using BART, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/latest/bart_user/). diff --git a/product_docs/docs/bart/2.6.1/bart_inst/04_upgrading_bart.mdx b/product_docs/docs/bart/2.6.1/bart_inst/04_upgrading_bart.mdx new file mode 100644 index 00000000000..587f13c4aaa --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_inst/04_upgrading_bart.mdx @@ -0,0 +1,98 @@ +--- +title: "Upgrading BART" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/installation-getting-started/installation-upgrade-guide/2.6.1/upgrading_bart.html" +--- + + + +This section outlines the process of upgrading BART from an existing version to the latest version. + +- [Upgrading from BART 2.0](#upgrading-from-bart-20) describes the upgrade process from BART 2.0 to the latest version. +- [Upgrading from Older Versions of BART (except 2.0)](#upgrading_from_older_versions_except_2_0_to_latest_versions_of_bart) describes the upgrade process from previous BART versions (except 2.0) to the latest version. + +**Upgrade Restrictions** + +The following restrictions apply with regard to previous BART versions. + +- You can take incremental backups using the latest version only when the parent backup (full or incremental backup) has also been taken with the latest version. +- Using the latest version, you can restore incremental backups that are taken only with the latest version of BART. However, using the latest version you can restore full backups that were taken with older versions. + + + +## Upgrading from Older Versions of BART (except 2.0) + +Perform the following steps to upgrade from older versions of BART (except 2.0) to the latest version: + +**Step 1:** Assume the identity of the BART user account and invoke the following command to stop the BART WAL scanner program (`bart-scanner`): + +```text +bart-scanner STOP +``` + +**Step 2:** As the `root` user, upgrade to the latest BART version with the `yum upgrade` command. + +- To upgrade the BART RPM package directly from the *EDB Yum Repository* website, specify only the package name: + + On CentOS 7: + + ```text + yum upgrade edb-bart + ``` + + You can also use a downloaded RPM package file to upgrade. To use a downloaded BART RPM package file to upgrade, use the `yum` command, specifying the complete RPM package file name: + + ```text + yum upgrade edb-bart-2.6.1 rhel7.x86_64.rpm + ``` + +**Step 3:** Repeat the process described in this section to upgrade to the latest BART version on each remote hosts where an incremental backup will be restored. + +For additional information about restoration of incremental backups on remote hosts, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/latest/bart_user/). + +**Step 4:** If the `bart --version` command returns an error stating the `PATH` is not available after switching from `root` user to another BART user account, adjust the setting of the `PATH` environment variable to include the location of the BART 2.6.1 executable (the `bin` subdirectory) in the `~/.bashrc` or `~/.bash_profile` files of the following user accounts: + +- The BART user account on the BART host. +- The remote user account on the remote host to which incremental backups are to be restored. For details, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/latest/bart_user/). + +The `PATH` setting should be the same as set for BART 2.6.1 since all versions use `/usr/edb/bart/bin`. + +!!! Note + After upgrading to the latest BART version, you must take a new full backup of your system before performing an incremental backup. + + + +## Upgrading from BART 2.0 + +Perform the following steps to upgrade BART 2.0 to the latest version of BART: + +**Step 1:** Install the latest version of BART. For information about how to install, see [installing BART](02_installing_bart/#installing-bart). + +**Step 2:** Save a copy of your BART 2.0 configuration file. The default location of the BART 2.0 configuration file is `/usr/edb/bart2.0/etc/bart.cfg`. + +**Step 3:** Invoke the following command to remove BART 2.0: + + On CentOS 7: + +```text +yum remove edb-bart20 +``` + +**Step 4:** Place the BART 2.0 configuration file (`bart.cfg`) that you saved in Step 2 in the newly created `/usr/edb/bart/etc` directory. You can use many of the same configuration parameters for BART 2.6.1, but note that you must use a new directory for the BART backup catalog. A new set of full backups and incremental backups taken using BART 2.6.1 must be stored in a new BART backup catalog. + +To specify an alternative configuration file name or location, use the `-c` option with BART subcommands. For more information about the `-c` option, see the EDB Backup and Recovery Us available at the [EDB website](/bart/latest/bart_user/). + +!!! Note + The `bart.cfg` configuration file is only required on the BART 2.6.1 host from which you will invoke BART subcommands. BART does not require the `bart.cfg` file on hosts on which an incremental backup will be restored. + +**Step 5:** Adjust the setting of the `PATH` environment variable to include the location of the BART 2.6.1 executable (the `bin` subdirectory) in the `~/.bashrc` or `~/.bash_profile` files for the following user accounts: + +- The BART user account on the BART host. +- The user account on the remote host to which incremental backups will be restored. For details, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/latest/bart_user/). + +**Step 6:** Perform the BART 2.6.1 installation and BART 2.0 removal process on each remote host on which an incremental backup was restored using BART 2.0. + +!!! Note + After upgrading to the latest BART version, you must take a new full backup of your system before performing an incremental backup. diff --git a/product_docs/docs/bart/2.6.1/bart_inst/05_uninstalling_bart.mdx b/product_docs/docs/bart/2.6.1/bart_inst/05_uninstalling_bart.mdx new file mode 100644 index 00000000000..8374221ef88 --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_inst/05_uninstalling_bart.mdx @@ -0,0 +1,50 @@ +--- +title: "Uninstalling BART" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/installation-getting-started/installation-upgrade-guide/2.6.1/uninstalling_bart.html" +--- + + + +This section walks you through uninstalling BART. + +## Uninstalling BART on a RHEL/CentOS Host + +To uninstall BART on a RHEL/CentOS host, assume the identity of the `root` user and invoke the following command: + +On RHEL/CentOS 7: + +```text +yum remove edb-bart +``` + +On RHEL/CentOS 8: + +```text +dnf remove edb-bart +``` + +Uninstalling BART does not delete the backup files and archived WAL files that reside in the BART backup catalog. To permanently delete the backup files and archived WAL files in the BART backup catalog (`/opt/backup`), use one of the following commands: + +- `rm –rf /opt/backup` +- BART `DELETE` subcommand + +For information about the BART `DELETE` subcommand, see the *EDB Backup and Recovery User Guide* available at the [EDB website](/bart/latest/bart_user/). + +## Uninstalling BART on an SLES 12 Host + +To uninstall BART on an SLES 12 host, assume the identity of the `root` user and invoke the following command: + +```text +zypper remove edb-bart +``` + +## Uninstalling BART on a Debian/Ubuntu Host + +To uninstall BART on a Debian or Ubuntu host, invoke the following command: + +```text +apt-get remove edb-bart +``` diff --git a/product_docs/docs/bart/2.6.1/bart_inst/images/EDB_logo.png b/product_docs/docs/bart/2.6.1/bart_inst/images/EDB_logo.png new file mode 100644 index 00000000000..39a54822d85 Binary files /dev/null and b/product_docs/docs/bart/2.6.1/bart_inst/images/EDB_logo.png differ diff --git a/product_docs/docs/bart/2.6.1/bart_inst/images/edb.png b/product_docs/docs/bart/2.6.1/bart_inst/images/edb.png new file mode 100644 index 00000000000..71e5bdde787 Binary files /dev/null and b/product_docs/docs/bart/2.6.1/bart_inst/images/edb.png differ diff --git a/product_docs/docs/bart/2.6.1/bart_inst/images/edb_logo.svg b/product_docs/docs/bart/2.6.1/bart_inst/images/edb_logo.svg new file mode 100644 index 00000000000..f24d1dfefee --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_inst/images/edb_logo.svg @@ -0,0 +1,19 @@ + + + edb-logo-disc-dark + + + + \ No newline at end of file diff --git a/product_docs/docs/bart/2.6.1/bart_inst/images/edblogo.png b/product_docs/docs/bart/2.6.1/bart_inst/images/edblogo.png new file mode 100644 index 00000000000..71e5bdde787 Binary files /dev/null and b/product_docs/docs/bart/2.6.1/bart_inst/images/edblogo.png differ diff --git a/product_docs/docs/bart/2.6.1/bart_inst/index.mdx b/product_docs/docs/bart/2.6.1/bart_inst/index.mdx new file mode 100644 index 00000000000..84027aa9a38 --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_inst/index.mdx @@ -0,0 +1,45 @@ +--- +navTitle: Installation Guide +title: "EDB Postgres Backup and Recovery Installation Guide" +legacyRedirects: + - "/edb-docs/d/edb-backup-and-recovery-tool/installation-getting-started/installation-upgrade-guide/2.6.1/requirements_overview.html" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/installation-getting-started/installation-upgrade-guide/2.6.1/conclusion.html" + - "/edb-docs/d/edb-backup-and-recovery-tool/installation-getting-started/installation-upgrade-guide/2.6.1/genindex.html" + - "/edb-docs/d/edb-backup-and-recovery-tool/installation-getting-started/installation-upgrade-guide/2.6.1/index.html" +--- + +This guide provides information about how to install and configure the EDB Backup and Recovery Tool (BART) 2.6.1. + + + +## Requirements Overview + +### Supported Platforms and Database Versions + +- To view a complete list of supported platforms, visit the [EDB website.](https://www.enterprisedb.com/services-support/edb-supported-products-and-platforms) + +!!! Note + BART 2.6.1 is no longer supported on CentOS/RHEL/OEL 6.x platforms. It is strongly recommended that EDB products running on these platforms be migrated to a supported platform. + +- BART supports the following database versions: + + - Advanced Server versions 9.6, 10, 11, 12, and 13. + - PostgreSQL versions 9.6, 10, 11, 12, and 13. + +### Software Requirements + +The following components are required for BART installation. + +- BART Host Components - Use EDB packages to add BART host components; see [Installing BART](02_installing_bart/#installing-bart) for information about how to install these components. + +- Additional Components - In addition to the BART host components, the following components are required: + + - The [Secure Shell (SSH) server daemon and Secure Copy (SCP) client programs](03_configuring_bart/#authorizing_ssh_scp_access) must be enabled and activated on the BART host as well as on the remote database server hosts on which BART will be managing backup and recovery. + - BART uses the `pg_basebackup` utility program when taking full backups. + +### Limitation + +BART supports taking only a full backup of standby servers; it does not support taking incremental or parallel backups of standby servers. diff --git a/product_docs/docs/bart/2.6.1/bart_qs_7/images/EDB_logo.png b/product_docs/docs/bart/2.6.1/bart_qs_7/images/EDB_logo.png new file mode 100644 index 00000000000..39a54822d85 Binary files /dev/null and b/product_docs/docs/bart/2.6.1/bart_qs_7/images/EDB_logo.png differ diff --git a/product_docs/docs/bart/2.6.1/bart_qs_7/images/edb.png b/product_docs/docs/bart/2.6.1/bart_qs_7/images/edb.png new file mode 100644 index 00000000000..71e5bdde787 Binary files /dev/null and b/product_docs/docs/bart/2.6.1/bart_qs_7/images/edb.png differ diff --git a/product_docs/docs/bart/2.6.1/bart_qs_7/images/edb_logo.svg b/product_docs/docs/bart/2.6.1/bart_qs_7/images/edb_logo.svg new file mode 100644 index 00000000000..f24d1dfefee --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_qs_7/images/edb_logo.svg @@ -0,0 +1,19 @@ + + + edb-logo-disc-dark + + + + \ No newline at end of file diff --git a/product_docs/docs/bart/2.6.1/bart_qs_7/images/image2.png b/product_docs/docs/bart/2.6.1/bart_qs_7/images/image2.png new file mode 100644 index 00000000000..4eba2e7efa7 Binary files /dev/null and b/product_docs/docs/bart/2.6.1/bart_qs_7/images/image2.png differ diff --git a/product_docs/docs/bart/2.6.1/bart_qs_7/index.mdx b/product_docs/docs/bart/2.6.1/bart_qs_7/index.mdx new file mode 100644 index 00000000000..14253b7d52e --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_qs_7/index.mdx @@ -0,0 +1,321 @@ +--- +title: "Quick Start Guide for RHEL/CentOS 7" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/quick-start/quick-start-guide-for-rhelcentos-7/2.6.1/genindex.html" + - "/edb-docs/d/edb-backup-and-recovery-tool/quick-start/quick-start-guide-for-rhelcentos-7/2.6.1/index.html" +--- + +This tutorial demonstrates using `yum` to [install](#installing) and [configure](../bart_qs_8/#configuring) Backup and Recovery Tool (BART) 2.6.1 on a CentOS 7 host with minimal configuration settings.  The tutorial assumes that the user has some knowledge of installation and system administration procedures, and has administrative privileges on the host. + +For detailed information about BART installation and configuration, see the *BART Installation and Upgrade Guide*, available at the [EDB website](/bart/latest/bart_inst/). + +- BART is tested with the following database versions: + + - Advanced Server - 9.6, 10, 11, 12, and 13. + - PostgreSQL - 9.6, 10, 11, 12, and 13. + + + +**Installing BART** + +The following steps describe installing BART on CentOS 7.x OS using `yum`. + +1. Assume superuser privileges and use `yum` to create the repository configuration file: + + ```text + yum install -y https://yum.enterprisedb.com/edbrepos/edb-repo-latest.noarch.rpm + ``` + +2. Create an EDB user account to request credentials to the EDB repository; for a user account visit the [EnterpriseDB website](https://www.enterprisedb.com/repository-access-request). + +3. Use your choice of editor to open the repository configuration file (named `edb.repo`, located in `/etc/yum.repos.d`), and set the `enabled` parameter value to `1`, and replace the `username` and `password` placeholders in the `baseurl` specification with the username and password of a registered EnterpriseDB user. + +4. Update the cache: + + ```text + yum makecache + ``` + +5. Install an Advanced Server or PostgreSQL database server. + + To install Advanced Server, execute the following command: + + ```text + yum -y install edb-as12-server + ``` + + Use sudo to assume the identity of the `enterprisedb` database superuser + + ```text + sudo su - enterprisedb + ``` + + Create an Advanced Server cluster named `acctg` on listener port `5444`: + + ```text + /usr/edb/as12/bin/initdb -D /var/lib/edb/as12/acctg + ``` + + As the `enterprisedb` user, start the cluster: + + ```text + /usr/edb/as12/bin/pg_ctl start -D /var/lib/edb/as12/acctg + ``` + + You can check the status of the cluster with the following command: + + ```text + /usr/edb/as12/bin/pg_ctl status -D /var/lib/edb/as12/acctg + ``` + + !!! Note + The BART host server is not required to have an Advanced Server or PostgreSQL installation, but must include a copy of the Postgres `libpq` library, the `pg_basebackup` utility program, and Boost Libraries 1.53 version for CentOS 7. + +6. If you do not already have the `pg_basebackup` program installed on the BART host, you can use the following command to install a limited number of files that include the `pg_basebackup` program: + + ```text + yum install edb-as-server-client + ``` + + Where <xx> is the Advanced Server version. + +7. As a root user, execute the following command to install BART: + + ```text + yum install edb-bart + ``` + +BART (the bart program and bart-scanner) is installed in the `/usr/edb/bart/bin` directory, referred to as ``. Repeat the installation process described in this section to install BART on all remote hosts where incremental backups are to be restored. + + + +**Configuring BART** + +Before configuring BART, establish the BART user account (the operating system user) that will run the BART command line program. Then, to configure the BART host and each database server that is to be managed by BART, perform the following steps: + +1. Assume superuser privileges, create the directory that will hold the BART backup catalog, and assign its ownership (with restrictive privileges) to the BART user account: + + In this example, `bartuser` is the BART user account and `/opt/backup` is the BART backup catalog. + + ```text + su root + mkdir /opt/backup + chown bartuser /opt/backup + chgrp bartuser /opt/backup + chmod 700 /opt/backup + ``` + +2. Navigate to the `/usr/edb/bart/etc` directory and copy the `bart.cfg.sample` file to create the BART configuration file (`bart.cfg`): + + ```text + cp bart.cfg.sample bart.cfg + ``` + +3. Open the BART configuration file (`bart.cfg`) using an editor of your choice and scroll through the BART configuration file to edit the file as required; sample settings are included for your reference. You must add the mandatory parameters to the `[BART]` and `[ServerName]` sections. Default values may be used for optional parameters. For detailed information about parameter settings, see the *BART Installation and Upgrade Guide*, available at the [EDB website](/bart/latest/bart_inst/). + + Parameters set in the `[BART]` section are applicable to all BART managed database servers, while parameters set in the `[ServerName]` section are applicable only to the specific server; `[ServerName]` settings override `[BART]` section settings. + + In the following example, only mandatory parameters are set: + + ```text + [BART] + bart_host= bartuser@192.168.169.199 + backup_path = /opt/backup + pg_basebackup_path = /usr/edb/as12/bin/pg_basebackup + + [EPAS12] + host = 127.0.0.1 + user = repuser + cluster_owner = enterprisedb + ``` + +The following table describes only mandatory parameters: + +| **Parameters/Placeholder** | **Section** | **Description** | +| -------------------------- | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `bart_host` | `[BART]` | Use this field to specify the BART user and the IP address of the host on which the BART utility is installed. Specify the value in the form of `@`. | +| `backup_path` | `[BART]` | Use this field to specify the path where all BART backups and archived WAL files will be stored. Ensure the BART user account holds privileges to create subdirectories and files within the location specified in the `backup_path` parameter. The default `backup_path` is BART backup catalog (`/opt/backup`). | +| `pg_basebackup_path` | `[BART]` | Use this field to specify the path to the pg_basebackup utility (`/usr/edb/as/bin/pg_basebackup`). | +| `[ServerName]` | `[ServerName]` | Specify the name of the database server to be backed up (for example, \[EPAS12]). | +| `host` | `[ServerName]` | Specify the IP address of the database server to be configured for backup. | +| `user` | `[ServerName]` | Specify the replication database user name used by BART to establish the connection to the database server for full backups. | +| `cluster_owner` | `[ServerName]` | Specify the Linux operating system user account that owns the database cluster. | + +4. As a BART user, navigate to `/usr/edb/bart/bin` and invoke the following subcommand (omitting the `-s` option) to verify the \[BART] section parameter settings: + + ```text + bart CHECK-CONFIG + ``` + +5. Authorize [SSH/SCP access](../bart_qs_8/#passwordless) between the server and the BART host without a password prompt. + +6. Create a [replication database user](../bart_qs_8/#replication) for each database server that BART manages. + +7. To enable continuous WAL archiving for any database server for which BART is to perform a backup, modify the `postgresql.conf` file, setting: + + - `wal_level` to `replica` or higher (for Postgres 9.6 or later) + - `archive_mode` to `on` + - `archive_command` (if it is not set in the `bart.cfg` file) + - `max_wal_senders` to a value high enough to leave at least one session available for the backup. + + After setting the parameters, restart the database server. + +8. To start the WAL scanner, navigate to `/usr/edb/bart/bin` as a BART user and execute the following command: + + ```text + ./bart-scanner + ``` + +9. If you are using the default `archive_command`, then navigate to `/usr/edb/bart/bin` as a BART user, run the `INIT` subcommand without the `-o` option, and restart the database server: + + ```text + bart INIT [ -s { | all } ] + ``` + + Where `` is the name of the database server to be backed up. + + If you have customized the `archive_command` setting in the `bart.cfg` file, run the `INIT` subcommand with the `-o` option to override any existing Postgresql `archive_command` setting in the `postgresql.conf` or the `postgresql.auto.conf` file, and restart the database server. + + ```text + bart INIT [ -s { | all } ] [ -o ] + ``` + +10. To verify the database server parameter settings, as a BART user navigate to `/usr/edb/bart/bin` and invoke the `CHECK-CONFIG` subcommand with the -s option: + + ```text + bart CHECK-CONFIG [ -s ] + ``` + + BART is now configured successfully. For detailed information about using BART, see the *EDB Backup and Recovery Tool User Guide*, available at the [EDB website](/bart/latest/bart_user/). + + + +**Creating a Passwordless Connection** + +The following example enables SSH/SCP access on a CentOS 7.x host; similar (platform-specific) steps will apply to other platforms/versions. You must create a passwordless connection between the BART host (SSH/SCP client) and the database server (target SSH/SCP server), as well as a passwordless connection between the database server (SSH/SCP client) and the BART host (target SSH/SCP server). + +1. Log in as the user account on the BART host that will be initiating the SSH or SCP connection and navigate to the user account’s home directory and check for an existing `.ssh` subdirectory. If the `.ssh` directory does not exist, create one with the required privileges. + +2. As a root user navigate to `/usr/edb/bart`, open the `/etc/ssh/sshd_config` file and set the `PubkeyAuthentication` parameter to `yes`. + +3. Reload the configuration file: + + ```text + service sshd reload + ``` + + If you get any SSH or SCP errors, examine the log file (`/var/log/secure`). + +4. As a BART user, use the following command to generate the public key file; you can accept the default responses: + + ```text + ssh-keygen -t rsa + ``` + + The public key file named `id_rsa.pub` is created in the `.ssh` subdirectory. + +5. Use `SCP` to make a temporary copy of the public key file on the target server: + + ```text + scp ~/.ssh/id_rsa.pub target_user@host_address:tmp.pub + ``` + +6. As a `target_user`, log into the target server using `ssh target_user@host_address` command and navigate to the user account’s home directory to check if there is an existing `.ssh` subdirectory. If it does not exist, create one with the required privileges. + +7. Append the client’s temporary public key file, `tmp.pub`, to the `authorized_keys` file: + + ```text + cat tmp.pub >> ~/.ssh/authorized_keys + ``` + + If an `authorized_keys` file does not exist, create a new file, but be careful not to completely replace any existing `authorized_keys` file. + +8. Ensure only the file owner (and not other groups or users) has access to `authorized_keys` file: + + ```text + chmod 600 ~/.ssh/authorized_keys + ``` + +9. Delete the temporary public key file: + + ```text + rm tmp.pub + ``` + + Now, when logged into the BART host as a user, there should be no prompt for a password when you are connecting to the target database server: + + ```text + ssh target_user@database_server_address + ``` + +**Creating a Passwordless Connection Between the Database Server and the BART Host** + +If backups are to be taken from a given database server host, but restored to a different database server host, the passwordless SSH/SCP connections must be configured from the BART host to the database server host from which the backup is to be taken as well as from the BART host to the database server host to which the backup is to be restored. + +An example of how to create a passwordless connection is documented in the *EDB Backup and Recovery Reference Guide*, available at the [EDB website](/bart/latest/bart_ref/). + +Even when the Advanced Server database is on the same host as BART, and the Advanced Server database cluster owner is also the BART user account, a passwordless SSH/SCP connection must be established from the same user account to itself. + +1. On the database server, navigate into the target user account’s home directory to check for an existing `.ssh` subdirectory. If it does does not exist, create one in the user account’s home directory with the required privileges. + +2. As a database server user, generate the public key file: + + ```text + ssh-keygen -t rsa + ``` + +3. Create a temporary copy of the public key file: + + ```text + scp ~/.ssh/id_rsa.pub target_user@host_address:tmp.pub + ``` + +4. As a target user, log into the BART host and navigate to the user account’s home directory to check if there is an existing `.ssh` subdirectory. If it does not exist, create one with the required privileges: + + ```text + ssh target_user@host_address + ``` + +5. Append the temporary, client’s public key file to the `authorized_keys` file: + + ```text + cat tmp.pub >> ~/.ssh/authorized_keys + ``` + +If an `authorized_keys` file does not exist, create a new file, but do not completely replace any existing `authorized_keys` file. + +6. Ensure only the file owner (and not other groups or users) has access to `authorized_keys` file: + + ```text + chmod 600 ~/.ssh/authorized_keys + ``` + +7. Delete the temporary public key file: + + ```text + rm tmp.pub + ``` + + Now, when logged into the database server as a user, there should be no prompt for a password when you are connecting to the BART host: + + ```text + ssh bart_user@bartip_address + ``` + + + +**Creating a Replication Database User** + +1. To create a replication database user (a superuser), connect to the database server with the psql client, and invoke the following PostgreSQL command: + + ```text + CREATE ROLE WITH LOGIN SUPERUSER PASSWORD ''; + ``` + +2. Specify this replication database user in the `user` parameter of the `bart.cfg` file. + +3. The [pg_hba.conf](https://www.postgresql.org/docs/current/auth-pg-hba-conf.html) file must minimally permit the replication database user to have access to the database. The IP address from which the replication database user has access to the database is the BART host location. The replication database user must also be included in the `pg_hba.conf` file as a replication database connection if `pg_basebackup` is to be used for taking any backups. + +4. To ensure there is no password prompt when connecting to the database server with the replication database user, a recommended method is to use the `.pgpass` file located in the BART user account’s home directory (if it does not exist, you need to create the `.pgpass` file with the required privileges). The `.pgpass` file must contain an entry for each BART managed database server, and its corresponding replication database user and password. diff --git a/product_docs/docs/bart/2.6.1/bart_qs_8/images/EDB_logo.png b/product_docs/docs/bart/2.6.1/bart_qs_8/images/EDB_logo.png new file mode 100644 index 00000000000..39a54822d85 Binary files /dev/null and b/product_docs/docs/bart/2.6.1/bart_qs_8/images/EDB_logo.png differ diff --git a/product_docs/docs/bart/2.6.1/bart_qs_8/images/edb.png b/product_docs/docs/bart/2.6.1/bart_qs_8/images/edb.png new file mode 100644 index 00000000000..71e5bdde787 Binary files /dev/null and b/product_docs/docs/bart/2.6.1/bart_qs_8/images/edb.png differ diff --git a/product_docs/docs/bart/2.6.1/bart_qs_8/images/edb_logo.svg b/product_docs/docs/bart/2.6.1/bart_qs_8/images/edb_logo.svg new file mode 100644 index 00000000000..f24d1dfefee --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_qs_8/images/edb_logo.svg @@ -0,0 +1,19 @@ + + + edb-logo-disc-dark + + + + \ No newline at end of file diff --git a/product_docs/docs/bart/2.6.1/bart_qs_8/images/image2.png b/product_docs/docs/bart/2.6.1/bart_qs_8/images/image2.png new file mode 100644 index 00000000000..4eba2e7efa7 Binary files /dev/null and b/product_docs/docs/bart/2.6.1/bart_qs_8/images/image2.png differ diff --git a/product_docs/docs/bart/2.6.1/bart_qs_8/index.mdx b/product_docs/docs/bart/2.6.1/bart_qs_8/index.mdx new file mode 100644 index 00000000000..0067c183210 --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_qs_8/index.mdx @@ -0,0 +1,317 @@ +--- +title: "Quick Start Guide for RHEL/CentOS 8" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/quick-start/quick-start-guide-for-rhelcentos-8/2.6.1/genindex.html" + - "/edb-docs/d/edb-backup-and-recovery-tool/quick-start/quick-start-guide-for-rhelcentos-8/2.6.1/index.html" +--- + +This tutorial demonstrates using the `dnf` command to install and configure the EDB Backup and Recovery Tool (BART) 2.6.1 on a CentOS 8 host with minimal configuration settings.  The tutorial assumes that the user has some knowledge of installation and system administration procedures, and has administrative privileges on the host. + +For detailed information about BART installation and configuration, see the *BART Installation and Upgrade Guide* available at the [EDB website](/bart/latest/bart_inst/). + +- BART is tested with the following database versions: + + - Advanced Server - 9.6, 10, 11, 12, and 13. + - PostgreSQL - 9.6, 10, 11, 12, and 13. + +**Installing BART** + +The following steps describe installing BART on CentOS 8.x OS. + +1. Assume superuser privileges and use `dnf` to create the repository configuration file: + + ```text + dnf install -y https://yum.enterprisedb.com/edbrepos/edb-repo-latest.noarch.rpm + ``` + +2. Create an EDB user account to request credentials to the EDB repository; for a user account visit the [EnterpriseDB website](https://www.enterprisedb.com/repository-access-request). + +3. Use your choice of editor to open the repository configuration file (named `edb.repo`, located in `/etc/yum.repos.d`) and set the value of the `enabled` parameter to `1`, and replace the `username` and `password` placeholders in the `baseurl` specification with the username and password of a registered EnterpriseDB user. + +4. Update the cache: + + ```text + dnf makecache + ``` + +5. Install an Advanced Server or PostgreSQL database server. + + To install Advanced Server, execute the following command: + + ```text + dnf -y install edb-as12-server + ``` + + Use sudo to assume the identity of the `enterprisedb` database superuser: + + ```text + sudo su - enterprisedb + ``` + + Create an Advanced Server cluster named `acctg` on listener port `5444`: + + ```text + /usr/edb/as12/bin/initdb -D /var/lib/edb/as12/acctg + ``` + + As the `enterprisedb` user, start the cluster: + + ```text + /usr/edb/as12/bin/pg_ctl start -D /var/lib/edb/as12/acctg + ``` + + You can check the status of the cluster with the following command: + + ```text + /usr/edb/as12/bin/pg_ctl status -D /var/lib/edb/as12/acctg + ``` + + !!! Note + The BART host server is not required to have an Advanced Server or PostgreSQL installation, but must include a copy of the Postgres `libpq` library, the `pg_basebackup` utility program, and Boost Libraries 1.66 version for CentOS 8. + +6. If you do not already have the `pg_basebackup` program installed on the BART host, you can use the following command to install a limited number of files that include the `pg_basebackup` program: + + ```text + dnf install edb-asxx-server-client + ``` + +7. As a root user, use the following command to install the BART RPM package: + + ```text + dnf install edb-bart + ``` + +BART (the `bart` program and `bart-scanner`) is installed in the `/usr/edb/bart/bin` directory, referred to as ``. Repeat the installation process described in this section to install BART on all remote hosts where incremental backups are to be restored. + + + +**Configuring BART** + +Before configuring BART, establish the BART user account (the operating system user) that will run the BART command line program. Then, to configure the BART host and each database server that is to be managed by BART, perform the following steps: + +1. Assume superuser privileges, create the directory that will hold the BART backup catalog, and assign its ownership (with restrictive privileges) to the BART user account: + + In this example, `bartuser` is the BART user account and `/opt/backup` is the BART backup catalog. + + ```text + su root + mkdir /opt/backup + chown bartuser /opt/backup + chgrp bartuser /opt/backup + chmod 700 /opt/backup + ``` + +2. Navigate to the `/usr/edb/bart/etc` directory and copy the `bart.cfg.sample` file to create the BART configuration file (`bart.cfg`): + + ```text + cp bart.cfg.sample bart.cfg + ``` + +3. Open the BART configuration file (`bart.cfg`) using an editor of your choice and scroll through the BART configuration file to edit the file as required; sample settings are included for your reference. You must add the mandatory parameters to the `[BART]` and `[ServerName]` sections. Default values may be used for optional parameters. For detailed information about parameter settings, see the *BART Installation and Upgrade Guide*, available at the [EDB website](/bart/latest/bart_inst/). + + Parameters set in the `[BART]` section are applicable to all BART managed database servers, while parameters set in the `[ServerName]` section are applicable only to the specific server; `[ServerName]` settings override `[BART]` section settings. + + In the following example, only mandatory parameters are set: + + ```text + [BART] + bart_host= bartuser@192.168.169.199 + backup_path = /opt/backup + pg_basebackup_path = /usr/edb/as12/bin/pg_basebackup + + [EPAS12] + host = 127.0.0.1 + user = repuser + cluster_owner = enterprisedb + ``` + +The following table describes only mandatory parameters: + +| **Parameters/Placeholder** | **Section** | **Description** | +| -------------------------- | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `bart_host` | `[BART]` | Use this field to specify the BART user and the IP address of the host on which the BART utility is installed. Specify the value in the form of `@`. | +| `backup_path` | `[BART]` | Use this field to specify the path where all BART backups and archived WAL files will be stored. Ensure the BART user account holds privileges to create subdirectories and files within the location specified in the `backup_path` parameter. The default `backup_path` is BART backup catalog (`/opt/backup`). | +| `pg_basebackup_path` | `[BART]` | Use this field to specify the path to the pg_basebackup utility (`/usr/edb/as/bin/pg_basebackup`). | +| `[ServerName]` | `[ServerName]` | Specify the name of the database server to be backed up (for example, \[EPAS12]). | +| `host` | `[ServerName]` | Specify the IP address of the database server to be configured for backup. | +| `user` | `[ServerName]` | Specify the replication database user name used by BART to establish the connection to the database server for full backups. | +| `cluster_owner` | `[ServerName]` | Specify the Linux operating system user account that owns the database cluster. | + +4. As a BART user, navigate to `/usr/edb/bart/bin` and invoke the following subcommand (omitting the `-s` option) to verify the \[BART] section parameter settings: + + ```text + bart CHECK-CONFIG + ``` + +5. Authorize [SSH/SCP access](#passwordless) between the server and the BART host without a password prompt. + +6. Create a [replication database user](#replication) for each database server that BART manages. + +7. To enable continuous WAL archiving for any database server for which BART is to perform a backup, modify the `postgresql.conf` file, setting: + + - `wal_level` to `replica` or higher (for Postgres 9.6 or later) + - `archive_mode` to `on` + - `archive_command` (if it is not set in the `bart.cfg` file) + - `max_wal_senders` to a value high enough to leave at least one session available for the backup. + + After setting the parameters, restart the database server. + +8. To start the WAL scanner, navigate to `/usr/edb/bart/bin` as a BART user and execute the following command: + + ```text + ./bart-scanner + ``` + +9. If you are using the default `archive_command`, then navigate to `/usr/edb/bart/bin` as a BART user, run the `INIT` subcommand without the `-o` option, and restart the database server: + + ```text + bart INIT [ -s { | all } ] + ``` + + Where `` is the name of the database server to be backed up. + + If you have customized the `archive_command` setting in the `bart.cfg` file, run the `INIT` subcommand with the `-o` option to override any existing Postgresql `archive_command` setting in the `postgresql.conf` or the `postgresql.auto.conf` file, and restart the database server. + + ```text + bart INIT [ -s { | all } ] [ -o ] + ``` + +10. To verify the database server parameter settings, as a BART user navigate to `/usr/edb/bart/bin` and invoke the `CHECK-CONFIG` subcommand with the -s option: + + ```text + bart CHECK-CONFIG [ -s ] + ``` + + BART is now configured successfully. For detailed information about using BART, see the *EDB Backup and Recovery Tool User Guide* available at the [EDB website](/bart/latest/bart_user/). + + + +**Creating a Passwordless Connection** + +The following example enables SSH/SCP access on a CentOS 7.x host; similar (platform-specific) steps will apply to other platforms/versions. You must create a passwordless connection between the BART host (SSH/SCP client) and the database server (target SSH/SCP server), as well as a passwordless connection between the database server (SSH/SCP client) and the BART host (target SSH/SCP server). + +1. Log in as the user account on the BART host that will be initiating the SSH or SCP connection and navigate to the user account’s home directory and check for an existing `.ssh` subdirectory. If the `.ssh` directory does not exist, create one with the required privileges. + +2. As a root user navigate to `/usr/edb/bart`, open the `/etc/ssh/sshd_config` file and set the `PubkeyAuthentication` parameter to `yes`. + +3. Reload the configuration file: + + ```text + service sshd reload + ``` + + If you get any SSH or SCP errors, examine the log file (`/var/log/secure`). + +4. As a BART user, use the following command to generate the public key file; you can accept the default responses: + + ```text + ssh-keygen -t rsa + ``` + + The public key file named `id_rsa.pub` is created in the `.ssh` subdirectory. + +5. Use `SCP` to make a temporary copy of the public key file on the target server: + + ```text + scp ~/.ssh/id_rsa.pub target_user@host_address:tmp.pub + ``` + +6. As a `target_user`, log into the target server using `ssh target_user@host_address` command and navigate to the user account’s home directory to check if there is an existing `.ssh` subdirectory. If it does not exist, create one with the required privileges. + +7. Append the temporary client’s public key file, `tmp.pub`, to the `authorized_keys` file: + + ```text + cat tmp.pub >> ~/.ssh/authorized_keys + ``` + + If an `authorized_keys` file does not exist, create a new file, but be careful not to completely replace any existing `authorized_keys` file. + +8. Ensure only the file owner (and not other groups or users) has access to `authorized_keys` file: + + ```text + chmod 600 ~/.ssh/authorized_keys + ``` + +9. Delete the temporary public key file: + + ```text + rm tmp.pub + ``` + + Now, when logged into the BART host as a user, there should be no prompt for a password when you are connecting to the target database server: + + ```text + ssh target_user@database_server_address + ``` + +**Creating a Passwordless Connection Between the Database Server and the BART Host** + +If backups are to be taken from a given database server host, but restored to a different database server host, the passwordless SSH/SCP connections must be configured from the BART host to the database server host from which the backup is to be taken as well as from the BART host to the database server host to which the backup is to be restored. + +An example of how to create a passwordless connection is documented in the *EDB Backup and Recovery Reference Guide*, available at the [EDB website](/bart/latest/bart_ref/). + +Even when the Advanced Server database is on the same host as BART, and the Advanced Server database cluster owner is also the BART user account, a passwordless SSH/SCP connection must be established from the same user account to itself. + +1. On the database server, navigate into the target user account’s home directory to check for an existing `.ssh` subdirectory. If it does does not exist, create one in the user account’s home directory with the required privileges. + +2. As a database server user, generate the public key file: + + ```text + ssh-keygen -t rsa + ``` + +3. Create a temporary copy of the public key file: + + ```text + scp ~/.ssh/id_rsa.pub target_user@host_address:tmp.pub + ``` + +4. As a target user, log into the BART host and navigate to the user account’s home directory to check if there is an existing `.ssh` subdirectory. If it does not exist, create one with the required privileges: + + ```text + ssh target_user@host_address + ``` + +5. Append the client’s temporary public key file to the `authorized_keys` file: + + ```text + cat tmp.pub >> ~/.ssh/authorized_keys + ``` + +If the `authorized_keys file` does not exist, create a new file, but do not completely replace any existing `authorized_keys` file. + +6. Ensure that only the file owner (and not other groups or users) has access to `authorized_keys` file: + + ```text + chmod 600 ~/.ssh/authorized_keys + ``` + +7. Delete the temporary public key file: + + ```text + rm tmp.pub + ``` + + Now, when logged into the database server as a user, there should be no prompt for a password when you are connecting to the BART host: + + ```text + ssh bart_user@bartip_address + ``` + + + +**Creating a Replication Database User** + +1. To create a replication database user (a superuser), connect to the database server with the psql client, and invoke the following PostgreSQL command: + + ```text + CREATE ROLE WITH LOGIN SUPERUSER PASSWORD ''; + ``` + +2. Specify this replication database user in the `user` parameter of the `bart.cfg` file. + +3. The [pg_hba.conf](https://www.postgresql.org/docs/current/auth-pg-hba-conf.html) file must minimally permit the replication database user to have access to the database. The IP address from which the replication database user has access to the database is the BART host location. The replication database user must also be included in the `pg_hba.conf` file as a replication database connection if `pg_basebackup` is to be used for taking any backups. + +4. To ensure there is no password prompt when connecting to the database server with the replication database user, a recommended method is to use the `.pgpass` file located in the BART user account’s home directory (if it does not exist, you need to create the `.pgpass` file with the required privileges). The `.pgpass` file must contain an entry for each BART managed database server, and its corresponding replication database user and password. diff --git a/product_docs/docs/bart/2.6.1/bart_ref/01_bart_subcommands_examples/01_backup.mdx b/product_docs/docs/bart/2.6.1/bart_ref/01_bart_subcommands_examples/01_backup.mdx new file mode 100644 index 00000000000..8b8f85eb4d0 --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_ref/01_bart_subcommands_examples/01_backup.mdx @@ -0,0 +1,271 @@ +--- +title: "BACKUP" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/backup.html" +--- + +Use the `BACKUP` subcommand to create a full or incremental backup. + +**Syntax for a Full Backup:** + +```text +bart BACKUP –s { | all } [ -F { p | t } ] + +[ -z ] [ –c ] + +[ --backup-name ] + +[ --thread-count ] + +[ { --with-pg_basebackup | --no-pg_basebackup } ] +``` + +**Syntax for an Incremental Backup:** + +```text +bart BACKUP –s [-Fp] + +[ --parent { | } ] + +[ --backup-name ] + +[ --thread-count ] + +[ { --checksum-algorithm } ] +``` + +Before performing an incremental backup, you must take a full backup. For more details about incremental backup, refer to *Block-Level Incremental Backup* in the *EDB Backup and Recovery User Guide* available at the [EDB website](/bart/latest/bart_user/). + +The following table describes the `BACKUP` options: + +| Options | Description | +| ---------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { \| all }`
`--server { \| all }` | Use this option to specify the database server to be backed up.
Specify `` to take a backup of the database server (as specified in the BART configuration file).
Specify `all` to take a backup of all servers. | +| `-F { p \| t }`
`--format { p \| t }` | Use this option to specify the backup file format.
Specify `p` option to take backup in plain text format and specify `t` option to take backup in tar format. If the `p` or `t` option is omitted, the default is tar format.
Use `p` option with the `BACKUP` subcommand when streaming is used as a backup method.
An incremental backup can only be taken in plain text format (`p`). | +| `-z`
`(--gzip)` | This option is applicable only for full backup and `tar` format. Use this option to enable gzip compression of tar files using the default compression level (typically 6). | +| `-c `
`--compress-level ` | This is applicable only for full backup and tar format. Use this option to specify the gzip compression level on the tar file output. `` is a digit from 1 through 9, with 9 being the best compression. | +| `--backup-name ` | Use this option to assign a user-defined, alphanumeric friendly name to the backup. The maximum permitted length of backup name is 49 characters.
For detailed information about this parameter, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/latest/bart_user/).
If the option `--backup-name` is not specified and the `backup_name` parameter is not set for this database server in the BART configuration file, then the backup can only be referenced in other BART subcommands by the BART assigned backup identifier. | +| `--thread-count ` | Use this option to specify the number of worker threads to run in parallel to copy blocks for a backup.
For detailed information about the `--thread-count` parameter, see the EDB Backup and Recovery Installation and Upgrade Guide available at the [EDB website](/bart/latest/bart_inst/). | +| `--with-pg_basebackup` | This is applicable only for full backup. Use this option to specify the use of `pg_basebackup` to take a full backup. The number of thread counts in effect is ignored as given by the `thread_count` parameter in the BART configuration file.
When taking a full backup, if the thread count in effect is greater than `1`, then the `pg_basebackup` utility is not used to take the full backup (parallel worker threads are used) unless the `--with-pg_basebackup` option is specified with the `BACKUP` subcommand. | +| `--no-pg_basebackup` | This is applicable only for full backup. Use this option to specify that `pg_basebackup` is not to be used to take a full backup.
When taking a full backup, if the thread count in effect is only `1`, then the `pg_basebackup` utility is used to take the full backup unless the `--no-pg_basebackup` option is specified with the `BACKUP` subcommand. | +| `--parent { \| }` | Use this option to take an incremental backup. The parent backup is a backup taken prior to the incremental backup; it can be either a full backup or an incremental backup. `` is the backup identifier of a parent backup and `` is the user-defined alphanumeric name of a parent backup. | +| `--check` | This is applicable only for incremental backup. Use this option to verify if the required MBM files are present in the BART backup catalog before taking an incremental backup. However, an actual incremental backup is not taken when the `--check` option is specified.
The `--parent` option must be used along with the `--check` option. | +| `--checksum-algorithm` | While taking a backup, you can specify one of the following values with the `--checksum-algorithm` option:
`--checksum-algorithm=MD5` (default) to generate MD5 checksum files.
`--checksum-algorithm=SHA256` to generate SHA256 checksum files.
`--checksum-algorithm=NONE` to skip generating checksum files. | + +**Examples** + +The following code sample demonstrates using variables with the `BACKUP` subcommand: + +```text +./bart backup -s ppas12 -Ft --backup-name "YEAR = %year MONTH = +%month DAY = %day" +``` + +```text +./bart backup -s ppas12 -Ft --backup-name "YEAR = %year MONTH = +%month DAY = %day %%" +``` + +```text +./bart show-backups -s ppas12 -i "test backup" +``` + +The following code sample displays the result of creating a full backup in the default tar format with gzip compression when the `BACKUP` subcommand was invoked. Note that checksums are generated for the full backup and user-defined tablespaces for the tar format backup: + +```text +[edb@localhost bin]$ ./bart BACKUP -s hr -z +INFO: DebugTarget - getVar(checkDiskSpace.bytesAvailable) +INFO: new backup identifier generated 1567591909098 +INFO: creating 5 harvester threads +NOTICE: all required WAL segments have been archived +INFO: backup completed successfully +INFO: +BART VERSION: 2.5 +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1567591909098 +BACKUP NAME: none +BACKUP PARENT: none +BACKUP LOCATION: /home/edb/bkup_new/hr/1567591909098 +BACKUP SIZE: 13.91 MB +BACKUP FORMAT: tar.gz +BACKUP TIMEZONE: America/New_York +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 0 +TABLESPACE(s): 3 +Oid Name Location +16387 test1 /home/edb/tbl1 +16388 test2 /home/edb/tbl2 +16389 test3 /home/edb/tbl3 + +START WAL LOCATION: 000000010000000000000025 +STOP WAL LOCATION: 000000010000000000000026 +BACKUP METHOD: streamed +BACKUP FROM: master +START TIME: 2019-09-04 06:11:49 EDT +STOP TIME: 2019-09-04 06:11:53 EDT +TOTAL DURATION: 4 sec(s) +``` + +The following code sample displays information about the directory containing the full backup: + +```text +[edb@localhost bin]$number_of_threads> +[edb@localhost bin]$ ls -l /home/edb/bkup_new/hr/ +total 8 +drwxrwxr-x. 3 edb edb 34 Aug 27 05:57 1566899819709 +drwxrwxr-x. 3 edb edb 58 Aug 27 05:57 1566899827751 +drwxrwxr-x. 3 edb edb 4096 Sep 4 06:11 1567591909098 +drwxrwxr-x. 2 edb edb 4096 Sep 4 06:11 archived_wals +[edb@localhost bin]$ +``` + +The following code sample displays information about the creation of a full backup while streaming the transaction log. Note that the `-Fp` option must be specified with the `BACKUP` subcommand when streaming is used as a backup method. + +```text +[edb@localhost bin]$ ./bart BACKUP -s ACCTG -Fp +INFO: DebugTarget - getVar(checkDiskSpace.bytesAvailable) +INFO: new backup identifier generated 1566898964200 +INFO: creating 5 harvester threads +NOTICE: pg_stop_backup complete, all required WAL segments have been archived +INFO: backup completed successfully +INFO: +BART VERSION: 2.5 +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1566898964200 +BACKUP NAME: none +BACKUP PARENT: none +BACKUP LOCATION: /home/edb/bkup_new/acctg/1566898964200 +BACKUP SIZE: 46.03 MB +BACKUP FORMAT: plain +BACKUP TIMEZONE: US/Eastern +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 0 +TABLESPACE(s): 0 +START WAL LOCATION: 000000010000000000000017 +BACKUP METHOD: streamed +BACKUP FROM: master +START TIME: 2019-08-27 05:42:44 EDT +STOP TIME: 2019-08-27 05:42:46 EDT +TOTAL DURATION: 2 sec(s) +``` + +The following code sample displays the assignment of a user-defined backup name with the `--backup-name` option: + +```text +[edb@localhost bin]$ ./bart BACKUP -s acctg --backup-name acctg_%year-%month-%day +INFO: DebugTarget - getVar(checkDiskSpace.bytesAvailable) +INFO: new backup identifier generated 1566899004804 +INFO: creating 5 harvester threads +NOTICE: pg_stop_backup complete, all required WAL segments have been archived +INFO: backup completed successfully +INFO: +BART VERSION: 2.5 +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1566899004804 +BACKUP NAME: acctg_2019-08-27 +BACKUP PARENT: none +BACKUP LOCATION: /home/edb/bkup_new/acctg/1566899004804 +BACKUP SIZE: 46.86 MB +BACKUP FORMAT: tar +BACKUP TIMEZONE: US/Eastern +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 0 +TABLESPACE(s): 0 +START WAL LOCATION: 00000001000000000000001A +BACKUP METHOD: streamed +BACKUP FROM: master +START TIME: 2019-08-27 05:43:24 EDT +STOP TIME: 2019-08-27 05:43:24 EDT +TOTAL DURATION: 0 sec(s) +``` + +The following code sample displays an incremental backup taken by specifying the `--parent` option. The option `-Fp` must be specified while taking an incremental backup as incremental backup can be taken only in plain text format. + +```text +[edb@localhost bin]$ ./bart BACKUP -s hr -Fp --parent hr_full_1 --backup-name +hr_incr_1 +INFO: DebugTarget - getVar(checkDiskSpace.bytesAvailable) +INFO: checking /home/edb/bkup_new/hr/archived_wals for MBM files from 0/20000028 to +0/22000000 +INFO: new backup identifier generated 1566899827751 +INFO: creating 5 harvester threads +NOTICE: all required WAL segments have been archived +INFO: backup completed successfully +INFO: +BART VERSION: 2.5 +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1566899827751 +BACKUP NAME: hr_incr_1 +BACKUP PARENT: 1566899819709 +BACKUP LOCATION: /home/edb/bkup_new/hr/1566899827751 +BACKUP SIZE: 7.19 MB +BACKUP FORMAT: plain +BACKUP TIMEZONE: America/New_York +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 0 +TABLESPACE(s): 0 +START WAL LOCATION: 000000010000000000000022 +STOP WAL LOCATION: 000000010000000000000023 +BACKUP METHOD: streamed +BACKUP FROM: master +START TIME: 2019-08-27 05:57:07 EDT +STOP TIME: 2019-08-27 05:57:08 EDT +TOTAL DURATION: 1 sec(s) +``` + + + +The following code sample displays an incremental backup taken by specifying the `--checksum-algorithm=NONE` option to skip generating checksum files. + +First, the bart-scanner is started. + +```text +edb@localhost bin]$ +[edb@localhost bin]$ ./bart-scanner -d --checksum-algorithm=NONE +DEBUG: sockPath = /tmp/fc557c1c8853d75f1cb52a8a578f371a +INFO: process created for server 'ppas11', pid = 19012 +DEBUG: could not load XLogReaderLibrary at this time, archived_wals is empty +``` + +Then, an incremental backup is taken with the `--checksum-algorithm=NONE` option to skip generating checksum files. + +```text +[edb@localhost bin]$ ./bart backup -s ppas11 -Fp --parent 1593506709152 --checksum-algorithm=NONE +INFO: DebugTarget - getVar(checkDiskSpace.bytesAvailable) +INFO: checking /home/edb/bkup/ppas11/archived_wals for MBM files from 1/D3000028 to 1/D9000000 +INFO: new backup identifier generated 1593507779811 +INFO: creating 5 harvester threads +NOTICE: pg_stop_backup complete, all required WAL segments have been archived +INFO: backup completed successfully +INFO: +BART VERSION: 2.6devel +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1593507779811 +BACKUP NAME: none +BACKUP PARENT: 1593506709152 +BACKUP LOCATION: /home/edb/bkup/ppas11/1593507779811 +BACKUP SIZE: 7.30 MB +BACKUP FORMAT: plain +BACKUP TIMEZONE: US/Eastern +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 0 +TABLESPACE(s): 0 +START WAL LOCATION: 0000000100000001000000D9 +BACKUP METHOD: streamed +BACKUP FROM: master +START TIME: 2020-06-30 05:02:59 EDT +STOP TIME: 2020-06-30 05:03:05 EDT +TOTAL DURATION: 6 sec(s) +``` + +!!! Note + To restore an incremental backup taken with the `--checksum-algorithm=NONE` option, you must specify [--disable-checksum while restoring](06_restore/#restoring_an_incremental_backup_using_disable_checksum). + +Similarly, you can specify `--checksum-algorithm=MD5` or `--checksum-algorithm=SHA256` while taking an incremental backup if you want to generate MD5 or SHAD256 checksum files. diff --git a/product_docs/docs/bart/2.6.1/bart_ref/01_bart_subcommands_examples/02_check_config.mdx b/product_docs/docs/bart/2.6.1/bart_ref/01_bart_subcommands_examples/02_check_config.mdx new file mode 100644 index 00000000000..69c51d5249e --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_ref/01_bart_subcommands_examples/02_check_config.mdx @@ -0,0 +1,65 @@ +--- +title: "CHECK-CONFIG" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/check_config.html" +--- + +The `CHECK-CONFIG` subcommand checks the global parameter settings as well as the database server configuration in the BART configuration file. + +The following syntax is used to check the BART configuration file global section settings. + +```text +bart CHECK-CONFIG +``` + +The following syntax is used to check the database server configuration settings. + +```text +bart CHECK-CONFIG [ –s ] +``` + +The following table describes the `CHECK-CONFIG` option: + +| Option | Description | +| ------------------------------------------- | ------------------------------------------------------------------------------------------------------------ | +| `-s ` `--server ` | `` is the name of the database server whose configuration parameter settings are to be checked. | + +**Example** + +The following code sample demonstrates successfully checking the BART configuration file global parameters with the `bart CHECK-CONFIG` command: + +```text +bash-4.1$ bart CHECK-CONFIG +INFO: Verifying that pg_basebackup is executable +INFO: success - +INFO: success - pg_basebackup(/usr/edb/as11/bin/pg_basebackup) returns +version 11.400000 +``` + +The following code sample demonstrates successfully checking the BART configuration file database server parameters with the `bart CHECK-CONFIG` command with the `–s` option: + +```text +[edb@localhost bin]$ ./bart check-config -s hr +INFO: Checking server hr +INFO: Verifying cluster_owner and ssh/scp connectivity +INFO: success +INFO: Verifying user, host, and replication connectivity +INFO: success +INFO: Verifying that user is a database superuser +INFO: success +INFO: Verifying that cluster_owner can read cluster data files +INFO: success +INFO: Verifying that you have permission to write to vault +INFO: success +INFO: /home/edb/bkup_new/hr +INFO: Verifying database server configuration +INFO: success +INFO: Verifying that WAL archiving is working +INFO: waiting 30 seconds for +/home/edb/bkup_new/hr/archived_wals/00000001000000000000001E +INFO: success +INFO: Verifying that bart-scanner is configured and running +INFO: success +``` diff --git a/product_docs/docs/bart/2.6.1/bart_ref/01_bart_subcommands_examples/03_delete.mdx b/product_docs/docs/bart/2.6.1/bart_ref/01_bart_subcommands_examples/03_delete.mdx new file mode 100644 index 00000000000..a148c571880 --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_ref/01_bart_subcommands_examples/03_delete.mdx @@ -0,0 +1,141 @@ +--- +title: "DELETE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/delete.html" +--- + +The `DELETE` subcommand removes the subdirectory and data files from the BART backup catalog for the specified backups along with archived WAL files. + +**Syntax:** + +```text +bart DELETE –s +-i { all | [']{ | },... }['] } +[ -n ] +``` + +Note that when invoking the `DELETE` subcommand, you must specify a database server. + +For database servers under a retention policy, there are conditions where certain backups may not be deleted. For more information, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/latest/bart_user/). + +The following table describes the `DELETE` options: + +| Options | Description | +| -------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s `
`--server ` | `` is the name of the database server whose backups are to be deleted. | +| ``-i { all \| [']{ \| }',... }[`] }``

``--backupid { all \| [']{ \| }',... }[`] }`` | `` is the backup identifier of the backup to be deleted. `` is the user-defined alphanumeric name for the backup.
Multiple backup identifiers and backup names may be specified in a comma-separated list. The list must be enclosed within single quotes if there is any white space appearing before or after each comma (see [Example](#deleting_multiple_backups_with_space_characters)).
If `all` is specified, all backups and their archived WAL files for the specified database server are deleted. | +| `-n`
`--dry-run` | Performs the test run and displays the results prior to physically removing files; no files are actually deleted. | + +**Example** + +The following code sample demonstrates deleting a backup from the specified database server: + +```text +[edb@localhost bin]$ ./bart DELETE -s acctg -i acctg_2019-08-27 +INFO: deleting backup 'acctg_2019-08-27' of server 'acctg' +INFO: deleting backup '1566900093665' +INFO: WALs of deleted backup(s) will belong to prior backup(if any), or will +be marked unused +WARNING: not marking any WALs as unused WALs, the WAL file +'/home/edb/bkup_new/acctg/archived_wals/000000010000000000000025' +is required, yet not available in archived_wals directory +INFO: backup(s) deleted +[edb@localhost bin]$ +``` + +After the deletion, the BART backup catalog for the database server no longer contains the corresponding directory for the deleted `backup ID`. The following code sample displays information about `archived_wals` subdirectory that no longer contains the backup WAL files: + +```text +[edb@localhost acctg]$ ls -l +total 16 +drwxrwxr-x. 3 edb edb 4096 Aug 27 06:03 1566900199604 +drwxrwxr-x. 3 edb edb 4096 Aug 27 06:03 1566900204377 +drwxrwxr-x. 3 edb edb 4096 Aug 27 06:03 1566900209087 +drwxrwxr-x. 3 edb edb 4096 Aug 27 06:05 1566900321228 +drwxrwxr-x. 2 edb edb 6 Aug 27 06:01 archived_wals +``` + +The following code sample demonstrates deleting multiple backups from the database server. + +```text +[edb@localhost bin]$ ./bart DELETE -s acctg -i `1566988095633,1566988100760, +acctg_2019-08-28` +INFO: deleting backup `1566988095633` of server `acctg` +INFO: deleting backup `1566988095633` +INFO: WALs of deleted backup(s) will belong to prior backup(if any), or will +be marked unused +WARNING: not marking any WALs as unused WALs, the WAL file +`/home/edb/bkup_new/acctg/archived_wals/000000010000000000000037` is required, +yet not available in archived_wals directory +INFO: backup(s) deleted +INFO: deleting backup `1566988100760` of server `acctg` +INFO: deleting backup `1566988100760` +INFO: WALs of deleted backup(s) will belong to prior backup(if any), or will +be marked unused +WARNING: not marking any WALs as unused WALs, the WAL file +`/home/edb/bkup_new/acctg/archived_wals/000000010000000000000039` is +required, yet not available in archived_wals directory +INFO: backup(s) deleted +INFO: deleting backup `acctg_2019-08-28` of server `acctg` +INFO: deleting backup `1566988115512` +INFO: WALs of deleted backup(s) will belong to prior backup(if any), or will +be marked unused +WARNING: not marking any WALs as unused WALs, the WAL file +`/home/edb/bkup_new/acctg/archived_wals/00000001000000000000003C` is required, +yet not available in archived_wals directory +INFO: backup(s) deleted +[edb@localhost bin]$ +[edb@localhost bin]$ +[edb@localhost bin]$ +[edb@localhost acctg]$ +[edb@localhost acctg]$ ls -l +total 8 +drwxrwxr-x. 3 edb edb 4096 Aug 28 06:28 1566988105086 +drwxrwxr-x. 3 edb edb 4096 Aug 28 06:28 1566988109477 +drwxrwxr-x. 2 edb edb 6 Aug 28 06:09 archived_wals +[edb@localhost acctg]$ +``` + + + +**Deleting Multiple Backups with Space Characters** + +The following code sample demonstrates deleting multiple backups; since there are space characters in the comma-separated list, the entire list must be enclosed within single quotes: + +```text +[edb@localhost bin]$ ./bart DELETE -s acctg -i +`1566900199604,1566900204377,1566900209087`; +INFO: deleting backup `1566900199604` of server `acctg` +INFO: deleting backup `1566900199604` +INFO: WALs of deleted backup(s) will belong to prior backup(if any), or will +be marked unused +WARNING: not marking any WALs as unused WALs, the WAL file +`/home/edb/bkup_new/acctg/archived_wals/000000010000000000000028` is required, +yet not available in archived_wals directory +INFO: backup(s) deleted +INFO: deleting backup `1566900204377` of server `acctg` +INFO: deleting backup `1566900204377` +INFO: WALs of deleted backup(s) will belong to prior backup(if any), or will +be marked unused +WARNING: not marking any WALs as unused WALs, the WAL file +`/home/edb/bkup_new/acctg/archived_wals/00000001000000000000002A` is required, +yet not available in archived_wals directory +INFO: backup(s) deleted +INFO: deleting backup `1566900209087` of server `acctg` +INFO: deleting backup `1566900209087` +INFO: WALs of deleted backup(s) will belong to prior backup(if any), or will +be marked unused +WARNING: not marking any WALs as unused WALs, the WAL file +`/home/edb/bkup_new/acctg/archived_wals/00000001000000000000002C` is required, +yet not available in archived_wals directory +INFO: backup(s) deleted +[edb@localhost bin]$ +[edb@localhost bin]$ +[edb@localhost acctg]$ ls -l +total 4 +drwxrwxr-x. 3 edb edb 4096 Aug 27 06:05 1566900321228 +drwxrwxr-x. 2 edb edb 6 Aug 27 06:01 archived_wals +[edb@localhost acctg]$ +``` diff --git a/product_docs/docs/bart/2.6.1/bart_ref/01_bart_subcommands_examples/04_init.mdx b/product_docs/docs/bart/2.6.1/bart_ref/01_bart_subcommands_examples/04_init.mdx new file mode 100644 index 00000000000..9f8b020ac03 --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_ref/01_bart_subcommands_examples/04_init.mdx @@ -0,0 +1,276 @@ +--- +title: "INIT" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/init.html" +--- + + + +The `INIT` subcommand is used to create the BART backup catalog directory, rebuild the BART `backupinfo` file, and set the `archive_command` in the server based on the `archive_command` setting in the `bart.cfg` file. + +**Syntax:** + +```text +bart INIT [ –s { | all } ] [ -o ] + +[ -r [ -i { | | all } ] ] + +[--no-configure] +``` + +The following table describes the `INIT` options: + +| Options | Description | +| ------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { \| all }`
`--server { \| all }` | `` is the name of the database server to which the `INIT` actions are to be applied. If `all` is specified or if the option is omitted, actions are applied to all servers. | +| `-o`
`--override` | Overrides the existing Postgres `archive_command` configuration parameter setting in the `postgresql.conf` file or the `postgresql.auto.conf` file using the BART `archive_command` parameter in the BART configuration file. The `INIT` generated `archive command` string is written to the `postgresql.auto.conf` file. | +| `-r`
`--rebuild` | Rebuilds the `backupinfo` file located in each backup subdirectory. If `all` is specified or if the option is omitted, the `backupinfo` files of all backups for the database servers specified by the `-s` option are recreated. This option is only intended for recovering from a situation where the backupinfo file has become corrupt.
If the backup was initially created with a user-defined backup name, and then the `INIT -r` option is invoked to rebuild that `backupinfo` file, the user-defined backup name is no longer available. Thus, future references to the backup must use the backup identifier. | +| `-i { \| \| all }`
`--backupid { \| \| all }` | `` is an integer, backup identifier and `` is the user-defined alphanumeric name for the backup. The `-i` option can only be used with the `-r` option. | +| `--no-configure` | Prevents the `archive_command` from being set in the PostgreSQL server. | + +**Examples** + +In the following code sample, you can see that `archive_mode = off` and `archive_command` is not set. After invoking the BART `INIT` subcommand, `archive_mode` is set to `on` and `archive_command` is set: + +```text +archive_mode = off # enables archiving; off, on, or always +# (change requires restart) +archive_command = '' +# command to use to archive a logfile segment +[edb@localhost bin]$ ./bart init -s ppas11 +INFO: setting archive_mode/archive_command for server 'ppas11' +WARNING: archive_mode/archive_command is set. Restart the PostgreSQL +server using 'pg_ctl restart' +[edb@localhost bin]$ +# Do not edit this file manually! +# It will be overwritten by the ALTER SYSTEM command. +archive_mode = 'on' +archive_command = 'scp %p +edb@127.0.0.1:/home/edb/bkup/ppas11/archived_wals/%f' +``` + +In the following code sample, you can see that `archive_mode = on`, and `archive_command` is not set. After invoking the `INIT` subcommand, `archive_command` is set: + +```text +archive_mode = on # enables archiving; off, on, or always +# (change requires restart) +archive_command = '' # command to use to archive a logfile segment +[edb@localhost bin]$ ./bart init -s ppas11 +INFO: setting archive_mode/archive_command for server 'ppas11' +WARNING: archive_command is set. Reload the configuration in the +PostgreSQL server using pg_reload_conf() or 'pg_ctl reload' +[edb@localhost bin]$ +# Do not edit this file manually! +# It will be overwritten by the ALTER SYSTEM command. +archive_command = 'scp %p +edb@127.0.0.1:/home/edb/bkup/ppas11/archived_wals/%f' +``` + +In the following code sample, you can see that `archive_mode = on` and `archive_command` are already set. After invoking the `INIT` subcommand, there is no change in their settings. Note that to override the existing `archive_command`, you must include the `-o` option. + +```text +archive_mode = on # enables archiving; off, on, or always +# (change requires restart) +archive_command = 'scp %p +edb@127.0.0.1:/home/edb/bkup/ppas11/archived_wals/%f' # command to use +to archive a logfile segment +# placeholders: %p = path of file to archive +[edb@localhost bin]$ ./bart init -s ppas11 +INFO: setting archive_mode/archive_command for server 'ppas11' +WARNING: archive_command is not set for server 'ppas11' +[edb@localhost bin]$ +# Do not edit this file manually! +# It will be overwritten by the ALTER SYSTEM command. +``` + +In the following code sample, you can see that `archive_mode = off` and `archive_command` is already set. After invoking the `INIT` subcommand `archive_mode` is set to `on`: + +```text +archive_mode = off # enables archiving; off, on, or always +# (change requires restart) +archive_command = 'scp %p +edb@127.0.0.1:/home/edb/bkup/ppas11/archived_wals/%f' # command to use +to archive a log file segment +[edb@localhost bin]$ ./bart init -s ppas11 +INFO: setting archive_mode/archive_command for server 'ppas11' +WARNING: archive_mode/archive_command is set. Restart the PostgreSQL +server using 'pg_ctl restart' +# Do not edit this file manually! +# It will be overwritten by the ALTER SYSTEM command. +archive_mode = 'on' +archive_command = 'scp %p +edb@127.0.0.1:/home/edb/bkup/ppas11/archived_wals/%f' +``` + +In the following code sample an existing `archive command` setting is overridden by resetting the `archive_command` in the PostgreSQL server with the `archive_command = 'cp %p %a/%f'` parameter from the `bart.cfg` file: + +```text +[BART] + +bart_host= enterprisedb@192.168.2.22 +backup_path = /opt/backup_edb +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log + +[ACCTG] + +host = 127.0.0.1 +port = 5444 +user = repuser +cluster_owner = enterprisedb +archive_command = 'cp %p %a/%f' +description = "Accounting" +``` + +The `archive_mode` and `archive_command` parameters in the database server are set as follows: + +```text +edb=# SHOW archive_mode; +archive_mode +-------------- +on +(1 row) +edb=# SHOW archive_command; +archive_command +------------------------------------------------------------------ +scp %p bartuser@192.168.2.22:/opt/backup/acctg/archived_wals/%f + +(1 row) +``` + +Invoke the `INIT` subcommand with the `-o` option to override the current `archive_command` setting in the PostgreSQL server: + +```text +-bash-4.1$ bart INIT -s acctg -o +INFO: setting archive_mode/archive_command for server 'acctg' +WARNING: archive_command is set. Reload the configuration in the +PostgreSQL server using pg_reload_conf() or 'pg_ctl reload' +``` + +Reload the database server configuration; a restart of the database server is not necessary to reset only the `archive_command` parameter: + +```text +[root@localhost tmp]# service ppas11 reload +``` + +The `archive_command` in the PostgreSQL server is now set as follows: + +```text +edb=# SHOW archive_command; + archive_command +----------------------------------------------- +cp %p /opt/backup_edb/acctg/archived_wals/%f +(1 row) +``` + +The new command string is written to the `postgresql.auto.conf` file: + +```text +# Do not edit this file manually! +# It will be overwritten by ALTER SYSTEM command. +archive_command = 'cp %p /opt/backup_edb/acctg/archived_wals/%f' +``` + +When you invoke the BART `INIT` command with the `-r` option, BART rebuilds the `backupinfo` file using the content of the backup directory for the server specified or for all servers. The BART `backupinfo` file is initially created by the `BACKUP` subcommand and contains the backup information used by BART. + +!!! Note + If the backup was initially created with a user-defined backup name, and then the `INIT -r` option is invoked to rebuild the `backupinfo` file, the user-defined backup name is no longer available. Thus, future references to the backup must use the backup identifier. + +The following code sample shows the `backupinfo` file location in a backup subdirectory: + +```text +[root@localhost acctg]# pwd +/opt/backup/acctg +[root@localhost acctg]# ls -l +total 4 +drwx------ 2 enterprisedb enterprisedb 38 Oct 26 10:21 1477491569966 +drwxrwxr-x 2 enterprisedb enterprisedb 4096 Oct 26 10:19 archived_wals +[root@localhost acctg]# ls -l 1477491569966 +total 61144 +-rw-rw-r-- 1 enterprisedb enterprisedb 703 Oct 26 10:19 backupinfo +-rw-rw-r-- 1 enterprisedb enterprisedb 62603776 Oct 26 10:19 base.tar +``` + +The following code sample displays the `backupinfo` file content: + +```text +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1477491569966 +BACKUP NAME: none +BACKUP PARENT: none +BACKUP LOCATION: /opt/backup/acctg/1477491569966 +BACKUP SIZE: 59.70 MB +BACKUP FORMAT: tar +BACKUP TIMEZONE: +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 1 +ChkSum File +84b3eeb1e3f7b3e75c2f689570d04f10 base.tar +TABLESPACE(s): 0 +START WAL LOCATION: 2/A5000028 (file 0000000100000002000000A5) +STOP WAL LOCATION: 2/A50000C0 (file 0000000100000002000000A5) +CHECKPOINT LOCATION: 2/A5000028 +BACKUP METHOD: streamed +BACKUP FROM: master +START TIME: 2016-10-26 10:19:30 EDT +LABEL: pg_basebackup base backup +STOP TIME: 2016-10-26 10:19:30 EDT +TOTAL DURATION: 0 sec(s) +``` + +The following code sample displays an error message if the `backupinfo` file is missing when invoking a BART subcommand: + +```text +-bash-4.2$ bart SHOW-BACKUPS +ERROR: 'backupinfo' file does not exist for backup '1477491569966' +please use 'INIT -r' to generate the file +``` + +The `backupinfo` file may be missing if the `BACKUP` subcommand did not complete successfully. + +The following code sample displays information about rebuilding the `backupinfo` file of the specified backup for database server `acctg`: + +```text +-bash-4.1$ bart INIT -s acctg -r -i 1428346620427 +INFO: rebuilding BACKUPINFO for backup '1428346620427' of server 'acctg' +INFO: backup checksum: ced59b72a7846ff8fb8afb6922c70649 of base.tar +``` + +The following code sample displays information about how the `backupinfo` files of all backups are rebuilt for all database servers: + +```text +-bash-4.1$ bart INIT -r + +INFO: rebuilding BACKUPINFO for backup '1428347191544' of server 'acctg' +INFO: backup checksum: 1ac5c61f055c910db314783212f2544f of base.tar +INFO: rebuilding BACKUPINFO for backup '1428346620427' of server 'acctg' +INFO: backup checksum: ced59b72a7846ff8fb8afb6922c70649 of base.tar +INFO: rebuilding BACKUPINFO for backup '1428347198335' of server 'dev' +INFO: backup checksum: a8890dd8ab7e6be5d5bc0f38028a237b of base.tar +INFO: rebuilding BACKUPINFO for backup '1428346957515' of server 'dev' +INFO: backup checksum: ea62549cf090573625d4adeb7d919700 of base.tar +``` + +The following code sample displays information about invoking `BART INIT` with the `-r - i` option: + +```text +edb@localhost bin]$ ./bart init -s ppas11 -i 1551778898392 -r +INFO: rebuilding BACKUPINFO for backup '1551778898392' of server +'ppas11' +[edb@localhost bin]$ ls /home/edb/bkup/ppas11/1551778898392/ +backupinfo backup_label base base-1.tar base-2.tar base-3.tar +base-4.tar base-5.tar base.tar +``` + +The following code sample displays information about invoking the `BART INIT` command with the `--no-configure` option. You can use the `--no-configure` option with the `INIT` subcommand to prevent the `archive_command` option from being set in the PostgreSQL server. + +```text +[edb@localhost bin]$ ./bart init -s ppas11 -o --no-configure +[edb@localhost bin]$ +# Do not edit this file manually! +# It will be overwritten by the ALTER SYSTEM command. +``` diff --git a/product_docs/docs/bart/2.6.1/bart_ref/01_bart_subcommands_examples/05_manage.mdx b/product_docs/docs/bart/2.6.1/bart_ref/01_bart_subcommands_examples/05_manage.mdx new file mode 100644 index 00000000000..75e63130a8e --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_ref/01_bart_subcommands_examples/05_manage.mdx @@ -0,0 +1,228 @@ +--- +title: "MANAGE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/manage.html" +--- + +The `MANAGE` subcommand can be invoked to: + +- Evaluate backups, mark their status, and delete obsolete backups based on the `retention_policy` parameter in the BART configuration file. +- Compress the archived WAL files based on the `wal_compression` parameter in the BART configuration file. + +**Syntax:** + +```text +bart MANAGE [ –s { | all} ] +[ -l ] [ -d ] +[ -c { keep | nokeep } +-i { | | all } ] +[ -n ] +``` + +To view detailed information about the `MANAGE` subcommand and retention policy management, see *the EDB Backup and Recovery User Guide*. For information about setting the `wal_compression` parameter, see the *EDB Backup and Recovery Installation and Upgrade Guide*. These guides are available at the [EDB website](/bart/latest/bart_user/). + +The following table describes the `MANAGE` options: + +| Options | Description | +| ---------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `-s [ \| all ]`
`--server [ \| all ]` | `` is the name of the database server to which the `MANAGE` actions are to be applied.
If `all` is specified or if the `-s` option is omitted, actions are applied to all database servers. | +| `-l`
`--list-obsolete` | Lists the backups marked as obsolete. | +| `-d`
`--delete-obsolete` | Deletes the backups marked as obsolete. This action physically deletes the backup along with its archived WAL files and any MBM files for incremental backups. | +| `-c { keep \| nokeep }`
`--change-status { keep \| nokeep }` | Specify `keep` to change the backup status to `keep` to retain the backup indefinitely.

Specify `nokeep` to change the backup status back to `active`. You can then re-evaluate and possibly mark the backup as `obsolete` (according to the retention policy) using the `MANAGE` subcommand.

The `-c` option can only be used with the `-i` option. | +| `-i { \| \| all` }

`--backupid { \| \| all` } | `` is a backup identifier and `` is the user-defined alphanumeric name for the backup.
If `all` is specified, actions are applied to all backups.
The `-i` option can only be used with the `-c` option. | +| `-n`
`--dry-run` | Performs the test run and displays the results prior to actually implementing the actions as if the operation was performed, however, no changes are actually made.
If you specify `-n` with the `-d` option, it displays which backups would be deleted, but does not actually delete the backups.
If you specify `-n` with the `-c` option, it displays the keep or nokeep action, but does not actually change the backup status.
If you specify `-n` alone with no other options or if you specify `-n` with only the `-s` option, it displays which active backups would be marked as obsolete, but does not actually change the backup status. In addition, no compression is performed on uncompressed, archived WAL files even if WAL compression is enabled for the database server. | + +**Example** + +The following code sample performs a dry run for the specified database server displaying which active backups are evaluated as obsolete according to the retention policy, but does not actually change the backup status: + +```text +-bash-4.2$ bart MANAGE -s acctg -n +INFO: processing server 'acctg', backup '1482770807519' +INFO: processing server 'acctg', backup '1482770803000' +INFO: marking backup '1482770803000' as obsolete +INFO: 1 WAL file(s) marked obsolete +INFO: processing server 'acctg', backup '1482770735155' +INFO: marking backup '1482770735155' as obsolete +INFO: 2 incremental(s) of backup '1482770735155' will be marked obsolete +INFO: marking incremental backup '1482770780423' as obsolete +INFO: marking incremental backup '1482770763227' as obsolete +INFO: 3 WAL file(s) marked obsolete +INFO: 1 Unused WAL file(s) present +INFO: 2 Unused file(s) (WALs included) present, use 'MANAGE -l' for the +list +``` + +The following code sample marks active backups as obsolete according to the retention policy for the specified database server: + +```text +-bash-4.2$ bart MANAGE -s acctg +INFO: processing server 'acctg', backup '1482770807519' +INFO: processing server 'acctg', backup '1482770803000' +INFO: marking backup '1482770803000' as obsolete +INFO: 1 WAL file(s) marked obsolete +INFO: processing server 'acctg', backup '1482770735155' +INFO: marking backup '1482770735155' as obsolete +INFO: 2 incremental(s) of backup '1482770735155' will be marked obsolete +INFO: marking incremental backup '1482770780423' as obsolete +INFO: marking incremental backup '1482770763227' as obsolete +INFO: 3 WAL file(s) marked obsolete +INFO: 1 Unused WAL file(s) present +INFO: 2 Unused file(s) (WALs included) present, use 'MANAGE -l' for the +list +``` + +The following code sample lists backups marked as obsolete for the specified database server: + +```text +-bash-4.2$ bart MANAGE -s acctg -l +SERVER NAME: acctg +BACKUP ID: 1482770803000 +BACKUP STATUS: obsolete +BACKUP TIME: 2016-12-26 11:46:43 EST +BACKUP SIZE: 59.52 MB +WAL FILE(s): 1 +WAL FILE: 000000010000000100000055 +SERVER NAME: acctg +BACKUP ID: 1482770735155 +BACKUP STATUS: obsolete +BACKUP TIME: 2016-12-26 11:45:35 EST +BACKUP SIZE: 59.52 MB +INCREMENTAL BACKUP(s): 2 +BACKUP ID: 1482770780423 +BACKUP PARENT: 1482770735155 +BACKUP STATUS: obsolete +BACKUP TIME: 2016-12-26 11:45:35 EST +BACKUP SIZE: 59.52 MB +BACKUP ID: 1482770763227 +BACKUP PARENT: 1482770735155 +BACKUP STATUS: obsolete +BACKUP TIME: 2016-12-26 11:45:35 EST +BACKUP SIZE: 59.52 MB +WAL FILE(s): 3 +WAL FILE: 000000010000000100000054 +WAL FILE: 000000010000000100000053 +WAL FILE: 000000010000000100000052 +UNUSED FILE(s): 2 +UNUSED FILE: 000000010000000100000051 +UNUSED FILE: 0000000100000001510000280000000152000000.mbm +``` + +The following code sample deletes the obsolete backups for the specified database server: + +```text +-bash-4.2$ bart MANAGE -s acctg -d +INFO: removing all obsolete backups of server 'acctg' +INFO: removing obsolete backup '1482770803000' +INFO: 1 WAL file(s) will be removed +INFO: removing WAL file '000000010000000100000055' +INFO: removing obsolete backup '1482770735155' +INFO: 3 WAL file(s) will be removed +INFO: 2 incremental(s) of backup '1482770735155' will be removed +INFO: removing obsolete incremental backup '1482770780423' +INFO: removing obsolete incremental backup '1482770763227' +INFO: removing WAL file '000000010000000100000054' +INFO: removing WAL file '000000010000000100000053' +INFO: removing WAL file '000000010000000100000052' +INFO: 8 Unused file(s) will be removed +INFO: removing (unused) file '000000010000000100000056.00000028.backup' +INFO: removing (unused) file '000000010000000100000056' +INFO: removing (unused) file '000000010000000100000055.00000028.backup' +INFO: removing (unused) file '000000010000000100000054.00000028.backup' +INFO: removing (unused) file '000000010000000100000053.00000028.backup' +INFO: removing (unused) file '000000010000000100000052.00000028.backup' +INFO: removing (unused) file '000000010000000100000051' +INFO: removing (unused) file +'0000000100000001510000280000000152000000.mbm' +``` + +The following code sample changes the specified backup to keep status to retain it indefinitely: + +```text +-bash-4.2$ bart MANAGE -s acctg -c keep -i 1482770807519 +INFO: changing status of backup '1482770807519' of server 'acctg' from +'active' to 'keep' +INFO: 1 WAL file(s) changed +-bash-4.2$ bart SHOW-BACKUPS -s acctg -i 1482770807519 -t +SERVER NAME : acctg +BACKUP ID : 1482770807519 +BACKUP NAME : none +BACKUP PARENT : none +BACKUP STATUS : keep +BACKUP TIME : 2016-12-26 11:46:47 EST +BACKUP SIZE : 59.52 MB +WAL(S) SIZE : 16.00 MB +NO. OF WALS : 1 +FIRST WAL FILE : 000000010000000100000057 +CREATION TIME : 2016-12-26 11:52:47 EST +LAST WAL FILE : 000000010000000100000057 +CREATION TIME : 2016-12-26 11:52:47 EST +``` + +The following code sample resets the specified backup to active status: + +```text +-bash-4.2$ bart MANAGE -s acctg -c nokeep -i 1482770807519 +INFO: changing status of backup '1482770807519' of server 'acctg' from +'keep' to 'active' +INFO: 1 WAL file(s) changed +-bash-4.2$ bart SHOW-BACKUPS -s acctg -i 1482770807519 -t +SERVER NAME : acctg +BACKUP ID : 1482770807519 +BACKUP NAME : none +BACKUP PARENT : none +BACKUP STATUS : active +BACKUP TIME : 2016-12-26 11:46:47 EST +BACKUP SIZE : 59.52 MB +WAL(S) SIZE : 16.00 MB +NO. OF WALS : 1 +FIRST WAL FILE : 000000010000000100000057 +CREATION TIME : 2016-12-26 11:52:47 EST +LAST WAL FILE : 000000010000000100000057 +CREATION TIME : 2016-12-26 11:52:47 EST +``` + +The following code sample uses the enabled `wal_compression` parameter in the BART configuration file as shown by the following: + +```text +[ACCTG] + +host = 127.0.0.1 +port = 5445 +user = enterprisedb +cluster_owner = enterprisedb +allow_incremental_backups = disabled +wal_compression = enabled +description = "Accounting" +``` + +When the `MANAGE` subcommand is invoked, the following message is displayed indicating that WAL file compression is performed: + +```text +-bash-4.2$ bart MANAGE -s acctg +INFO: 4 WAL file(s) compressed +WARNING: 'retention_policy' is not set for server 'acctg' +``` + +The following code sample shows the archived WAL files in compressed format: + +```text +-bash-4.2$ pwd +/opt/backup/acctg +-bash-4.2$ ls -l archived_wals +total 160 +-rw------- 1 enterprisedb enterprisedb 27089 Dec 26 12:16 +00000001000000010000005B.gz +-rw------- 1 enterprisedb enterprisedb 305 Dec 26 12:17 +00000001000000010000005C.00000028.backup +-rw------- 1 enterprisedb enterprisedb 27112 Dec 26 12:17 +00000001000000010000005C.gz +-rw------- 1 enterprisedb enterprisedb 65995 Dec 26 12:18 +00000001000000010000005D.gz +-rw------- 1 enterprisedb enterprisedb 305 Dec 26 12:18 +00000001000000010000005E.00000028.backup +-rw------- 1 enterprisedb enterprisedb 27117 Dec 26 12:18 +00000001000000010000005E.gz +``` diff --git a/product_docs/docs/bart/2.6.1/bart_ref/01_bart_subcommands_examples/06_restore.mdx b/product_docs/docs/bart/2.6.1/bart_ref/01_bart_subcommands_examples/06_restore.mdx new file mode 100644 index 00000000000..52490745796 --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_ref/01_bart_subcommands_examples/06_restore.mdx @@ -0,0 +1,175 @@ +--- +title: "RESTORE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/restore.html" +--- + +The `RESTORE` subcommand restores a backup and its archived WAL files for the designated database server to the specified directory location. + +**Syntax for Restore**: + +```text +bart RESTORE –s -p +[ –i { | } ] +[ -r @ ] +[ -w ] +[ -t ] +[ { -x | -g } ] +[ -c ] +[ --disable-checksum ] +``` + +To view detailed information about the `RESTORE` subcommand, see the *EDB Backup and Recovery User Guide* available at the [EDB website](/bart/latest/bart_user/). + +If the backup is restored to a different database cluster directory than where the original database cluster resided, then some operations dependent upon the database cluster location may fail. This happens if the supporting service scripts are not updated to reflect the new directory location of restored backup. + +For information about the use and modification of service scripts, see the EDB Advanced Server Installation Guide available at the [EDB website](/epas/latest/). + +The following table describes the `RESTORE` options: + +| Options | Description | +| --------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s `
`--server ` | `` is the name of the database server to be restored. | +| `-p --restore-path `
`--restore-path ` | `` is the directory path where the backup of the database server is to be restored. The directory must be empty and have the proper ownership and privileges assigned to it. | +| `-i { \| }`

`--backupid { \| }` | `backup_id` is the backup identifier of the backup to be used for the restoration and `` is the user-defined alphanumeric name for the backup.
If the option is omitted, the latest backup is restored by default. | +| `-r `

`--remote-host ` | `` is the user account on the remote database server host that accepts a passwordless SSH/SCP login connection and is the owner of the directory where the backup is to be restored.
`` is the IP address of the remote host to which the backup is to be restored. This option must be specified if the `remote_host` parameter for this database server is not set in the BART configuration file.
For information about the `remote_host` parameter, see the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/latest/bart_inst/). | +| `-w `
`--workers ` | `` is the number of worker processes to run in parallel to stream the modified blocks of an incremental backup to the restore location. If the `-w` option is omitted, the default is `1` worker process.
For example, if four worker processes are specified, four receiver processes on the restore host and four streamer processes on the BART host are used. The output of each streamer process is connected to the input of a receiver process.
When the receiver gets to the point where it needs a modified block file, it obtains those modified blocks from its input. With this method, the modified block files are never written to the restore host disk. | +| `-t `
`--target-tli ` | `` is the integer identifier of the timeline to be used for replaying the archived WAL files for point-in-time recovery. | +| `-x `
`--target-xid ` | `` is the integer identifier of the transaction ID that determines the transaction up to and including, which point-in-time recovery encompasses. | +| `-g `

`--target-timestamp ` | `` is the timestamp that determines the point in time up to and including, which point-in-time recovery encompasses. | +| `-c`

`--copy-wals` | Specify this option to copy archived WAL files from the BART backup catalog to `/archived_wals` directory.
The `restore_command` retrieves the WAL files from `/archived_wals` for the database server archive recovery.
If the `-c` option is omitted and the `copy_wals_during_restore` parameter in the BART configuration file is not enabled in a manner applicable to this database server, then the `restore_command` in the `postgresql.conf` retrieves the archived WAL files directly from the BART backup catalog.
For information about the `copy_wals_during_restore` parameter, see the EDB Backup and Recovery Installation and Upgrade Guide available at the [EDB website](/bart/latest/bart_inst/). | +| `--disable-checksum` | While restoring a backup, specify this option to skip verifying the MD5 or SHA256 checksum files.
If you set the `--checksum-algorithm=NONE` option with the BART scanner or while taking a backup, you also need to specify the `--disable checksum` option while restoring an incremental backup. | + +**Examples** + +The following code sample restores a database server(named `mktg`) to the `/opt/restore` directory up to timestamp `2015-12-15 10:47:00`: + +```text +-bash-4.1$ bart RESTORE -s mktg -i 1450194208824 -p /opt/restore -t 1 -g +'2015-12-15 10:47:00' +INFO: restoring backup '1450194208824' of server 'mktg' +INFO: restoring backup to enterprisedb@192.168.2.24:/opt/restore +INFO: base backup restored +INFO: WAL file(s) will be streamed from the BART host +INFO: writing recovery settings to postgresql.auto.conf file +INFO: archiving is disabled +INFO: tablespace(s) restored +``` + +The following parameters are set in the `postgresql.auto.conf` file: + +```text +restore_command = 'scp -o BatchMode=yes -o PasswordAuthentication=no +enterprisedb@192.168.2.22:/opt/backup/mktg/archived_wals/%f %p' +recovery_target_time = '2015-12-15 10:47:00' +recovery_target_timeline = 1 +``` + +The following is a list of the restored files and subdirectories: + +```text +[root@localhost restore]# pwd +/opt/restore +[root@localhost restore]# ls -l +total 108 +-rw------- 1 enterprisedb enterprisedb 208 Dec 15 10:43 backup_label +drwx------ 6 enterprisedb enterprisedb 4096 Dec 2 10:38 base +drwx------ 2 enterprisedb enterprisedb 4096 Dec 15 10:42 dbms_pipe +drwx------ 2 enterprisedb enterprisedb 4096 Dec 15 11:00 global +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_clog\ +-rw------- 1 enterprisedb enterprisedb 4438 Dec 2 10:38 pg_hba.conf +-rw------- 1 enterprisedb enterprisedb 1636 Nov 10 15:38 pg_ident.conf +drwxr-xr-x 2 enterprisedb enterprisedb 4096 Dec 15 10:42 pg_log +drwx------ 4 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_multixact +drwx------ 2 enterprisedb enterprisedb 4096 Dec 15 10:42 pg_notify +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_serial +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_snapshots +drwx------ 2 enterprisedb enterprisedb 4096 Dec 15 10:42 pg_stat +drwx------ 2 enterprisedb enterprisedb 4096 Dec 15 10:43 pg_stat_tmp +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_subtrans +drwx------ 2 enterprisedb enterprisedb 4096 Dec 15 11:00 pg_tblspc +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_twophase +-rw------- 1 enterprisedb enterprisedb 4 Nov 10 15:38 PG_VERSION +drwx------ 2 enterprisedb enterprisedb 4096 Dec 15 11:00 pg_xlog +-rw------- 1 enterprisedb enterprisedb 23906 Dec 15 11:00 +postgresql.conf +-rw-r--r-- 1 enterprisedb enterprisedb 217 Dec 15 11:00 +postgresql.auto.conf +``` + +**Example** + +The following code sample performs a `RESTORE` operation with the `copy_wals_during_restore` parameter enabled to copy the archived WAL files to the local `/archived_wals` directory: + +```text +-bash-4.1$ bart RESTORE -s hr -i hr_2017-03-29T13:50 -p +/opt/restore_pg96 -t 1 -g '2017-03-29 14:01:00' +INFO: restoring backup 'hr_2017-03-29T13:50' of server 'hr' +INFO: base backup restored +INFO: copying WAL file(s) to +postgres@192.168.2.24:/opt/restore_pg96/archived_wals +INFO: writing recovery settings to postgresql.auto.conf file +INFO: archiving is disabled +INFO: permissions set on $PGDATA +INFO: restore completed successfully +``` + +The following parameters are set in the `postgresql.auto.conf` file: + +```text +restore_command = 'cp archived_wals/%f %p' +recovery_target_time = '2017-03-29 14:01:00' +recovery_target_timeline = 1 +``` + +The following is a list of the restored files and subdirectories: + +```text +-bash-4.1$ pwd +/opt/restore_pg96 +-bash-4.1$ ls -l +total 128 +drwxr-xr-x 2 postgres postgres 4096 Mar 29 14:27 archived_wals +-rw------- 1 postgres postgres 206 Mar 29 13:50 backup_label +drwx------ 5 postgres postgres 4096 Mar 29 12:25 base +drwx------ 2 postgres postgres 4096 Mar 29 14:27 global +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_clog +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_commit_ts +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_dynshmem +-rw------- 1 postgres postgres 4212 Mar 29 13:18 pg_hba.conf +-rw------- 1 postgres postgres 1636 Mar 29 12:25 pg_ident.conf +drwxr-xr-x 2 postgres postgres 4096 Mar 29 13:45 pg_log +drwx------ 4 postgres postgres 4096 Mar 29 12:25 pg_logical +drwx------ 4 postgres postgres 4096 Mar 29 12:25 pg_multixact +drwx------ 2 postgres postgres 4096 Mar 29 13:43 pg_notify +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_replslot +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_serial +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_snapshots +drwx------ 2 postgres postgres 4096 Mar 29 13:43 pg_stat +drwx------ 2 postgres postgres 4096 Mar 29 13:50 pg_stat_tmp +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_subtrans +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_tblspc +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_twophase +-rw------- 1 postgres postgres 4 Mar 29 12:25 PG_VERSION +drwx------ 3 postgres postgres 4096 Mar 29 14:27 pg_xlog +-rw------- 1 postgres postgres 169 Mar 29 13:24 postgresql.auto.conf +-rw-r--r-- 1 postgres postgres 21458 Mar 29 14:27 postgresql.conf +-rw-r--r-- 1 postgres postgres 118 Mar 29 14:27 postgresql.auto.conf +``` + + + +The following code sample displays restoring an [incremental backup](01_backup/#incremental_backup_using_checksum_algorithm) taken using `--checksum-algorithm=NONE` option. To restore this incremental backup, you must specify the `--disable-checksum` option to skip verifying MD5 or SHA256 checksum files. + +```text +[edb@localhost bin]$ ./bart restore -s ppas11 -i 1593507779811 -p /home/edb/RESTORE/ --disable-checksum +INFO: restoring incremental backup '1593507779811' of server 'ppas11' +INFO: base backup restored +INFO: writing recovery.conf file +INFO: WAL file(s) will be streamed from the BART host +INFO: archiving is disabled +INFO: permissions set on $PGDATA +INFO: incremental restore completed successfully +``` diff --git a/product_docs/docs/bart/2.6.1/bart_ref/01_bart_subcommands_examples/07_show_servers.mdx b/product_docs/docs/bart/2.6.1/bart_ref/01_bart_subcommands_examples/07_show_servers.mdx new file mode 100644 index 00000000000..8ada69b5622 --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_ref/01_bart_subcommands_examples/07_show_servers.mdx @@ -0,0 +1,77 @@ +--- +title: "SHOW-SERVERS" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/show_servers.html" +--- + +The `SHOW-SERVERS` subcommand displays information for the managed database servers listed in the BART configuration file. + +**Syntax:** + +```text +bart SHOW-SERVERS [ –s { | all } ] +``` + +The following table describes the `SHOW-SERVERS` option: + +| Option | Description | +| ---------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { \| all` }
`--server { \| all` } | `` is the name of the database server to which the `SHOW-SERVERS` actions are to be applied.
If `all` is specified or if the `-s` option is omitted, the actions are applied to all database servers. | + +**Example** + +The following code sample shows all the database servers managed by BART as returned by the `SHOW-SERVERS` subcommand: + +```text +-bash-4.2$ bart SHOW-SERVERS +SERVER NAME : acctg +BACKUP FRIENDLY NAME: acctg_%year-%month-%dayT%hour:%minute +HOST NAME : 127.0.0.1 +USER NAME : enterprisedb +PORT : 5444 +REMOTE HOST : +RETENTION POLICY : 6 Backups +DISK UTILIZATION : 0.00 bytes +NUMBER OF ARCHIVES : 0 +ARCHIVE PATH : /opt/backup/acctg/archived_wals +ARCHIVE COMMAND : (disabled) +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +INCREMENTAL BACKUP : DISABLED +DESCRIPTION : "Accounting" +SERVER NAME : hr +BACKUP FRIENDLY NAME: hr_%year-%month-%dayT%hour:%minute +HOST NAME : 192.168.2.24 +USER NAME : postgres +PORT : 5432 +REMOTE HOST : postgres@192.168.2.24 +RETENTION POLICY : 6 Backups +DISK UTILIZATION : 0.00 bytes +NUMBER OF ARCHIVES : 0 +ARCHIVE PATH : /opt/backup/hr/archived_wals +ARCHIVE COMMAND : (disabled) +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +INCREMENTAL BACKUP : DISABLED +DESCRIPTION : "Human Resources" +SERVER NAME : mktg +BACKUP FRIENDLY NAME: mktg_%year-%month-%dayT%hour:%minute +HOST NAME : 192.168.2.24 +USER NAME : repuser +PORT : 5444 +REMOTE HOST : enterprisedb@192.168.2.24 +RETENTION POLICY : 6 Backups +DISK UTILIZATION : 0.00 bytes +NUMBER OF ARCHIVES : 0 +ARCHIVE PATH : /opt/backup/mktg/archived_wals +ARCHIVE COMMAND : (disabled) +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +INCREMENTAL BACKUP : DISABLED\ +DESCRIPTION : "Marketing" +``` diff --git a/product_docs/docs/bart/2.6.1/bart_ref/01_bart_subcommands_examples/08_show_backups.mdx b/product_docs/docs/bart/2.6.1/bart_ref/01_bart_subcommands_examples/08_show_backups.mdx new file mode 100644 index 00000000000..03b7727add3 --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_ref/01_bart_subcommands_examples/08_show_backups.mdx @@ -0,0 +1,100 @@ +--- +title: "SHOW-BACKUPS" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/show_backups.html" +--- + +The `SHOW-BACKUPS` subcommand displays the backup information for the managed database servers. + +**Syntax:** + +```text +bart SHOW-BACKUPS [ –s { | all } ] +[ -i { | | all } ] +[ -t ] +``` + +The following table describes the `SHOW-BACKUPS` options: + +| Options | Description | +| ------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { \| all` }

`--server { \| all` } | `` is the name of the database server whose backup information is to be displayed.
If `all` is specified or if the option is omitted, the backup information for all database servers is displayed. | +| `-i { \| \| all }`

`--backupid { \| \| all }` | `` is a backup identifier and `` is the user-defined alphanumeric name for the backup.
If `all` is specified or if the option is omitted, all backup information for the relevant database server is displayed. | +| `-t`
`--toggle` | Displays detailed backup information in list format. If the option is omitted, the default is a tabular format. | + +**Example** + +The following code sample shows the backup from database server `dev`: + +```text +-bash-4.2$ bart SHOW-BACKUPS -s dev +SERVER NAME BACKUP ID BACKUP NAME BACKUP PARENT +BACKUP TIME BACKUP SIZE WAL(s) SIZE WAL FILES STATUS +dev 1477579596637 dev_2016-10-27T10:46:36 none +2016-10-27 10:46:37 EDT 54.50 MB 96.00 MB 6 active +``` + +The following code sample shows detailed information using the `-t` option: + +```text +-bash-4.2$ bart SHOW-BACKUPS -s dev -i 1477579596637 -t +SERVER NAME : dev +BACKUP ID : 1477579596637 +BACKUP NAME : dev_2016-10-27T10:46:36 +BACKUP PARENT : none +BACKUP STATUS : active +BACKUP TIME : 2016-10-27 10:46:37 EDT +BACKUP SIZE : 54.50 MB +WAL(S) SIZE : 80.00 MB +NO. OF WALS : 5 +FIRST WAL FILE : 0000000100000001000000EC +CREATION TIME : 2016-10-27 10:46:37 EDT +LAST WAL FILE : 0000000100000001000000F0 +CREATION TIME : 2016-10-27 11:22:01 EDT +``` + +The following code sample shows a listing of an incremental backup along with its parent backup: + +```text +-bash-4.2$ bart SHOW-BACKUPS +SERVER NAME BACKUP ID BACKUP NAME BACKUP PARENT +BACKUP TIME BACKUP SIZE WAL(s) SIZE WAL FILES STATUS +acctg 1477580293193 acctg_2016-10-27 none +2016-10-27 10:58:13 EDT 16.45 MB 16.00 MB 1 active +acctg 1477580111358 acctg_2016-10-27 none 2016-10-27 10:55:11 EDT 59.71 +MB 16.00 MB 1 active +``` + +The following code sample shows the complete, detailed information of the incremental backup and the parent backup: + +```text +-bash-4.2$ bart SHOW-BACKUPS -t +SERVER NAME : acctg +BACKUP ID : 1477580293193 +BACKUP NAME : none +BACKUP PARENT : acctg_2016-10-27 +BACKUP STATUS : active +BACKUP TIME : 2016-10-27 10:58:13 EDT +BACKUP SIZE : 16.45 MB +WAL(S) SIZE : 16.00 MB +NO. OF WALS : 1 +FIRST WAL FILE : 0000000100000002000000D9 +CREATION TIME : 2016-10-27 10:58:13 EDT +LAST WAL FILE : 0000000100000002000000D9 +CREATION TIME : 2016-10-27 10:58:13 EDT +SERVER NAME : acctg +BACKUP ID : 1477580111358 +BACKUP NAME : acctg_2016-10-27 +BACKUP PARENT : none +BACKUP STATUS : active +BACKUP TIME : 2016-10-27 10:55:11 EDT +BACKUP SIZE : 59.71 MB +WAL(S) SIZE : 16.00 MB +NO. OF WALS : 1 +FIRST WAL FILE : 0000000100000002000000D8 +CREATION TIME : 2016-10-27 10:55:12 EDT +LAST WAL FILE : 0000000100000002000000D8 +CREATION TIME : 2016-10-27 10:55:12 EDT +``` diff --git a/product_docs/docs/bart/2.6.1/bart_ref/01_bart_subcommands_examples/09_verify_chksum.mdx b/product_docs/docs/bart/2.6.1/bart_ref/01_bart_subcommands_examples/09_verify_chksum.mdx new file mode 100644 index 00000000000..973ae05dc7d --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_ref/01_bart_subcommands_examples/09_verify_chksum.mdx @@ -0,0 +1,41 @@ +--- +title: "VERIFY-CHKSUM" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/verify_chksum.html" +--- + +The `VERIFY-CHKSUM` subcommand verifies the MD5 checksums of the full backups and any user-defined tablespaces for the specified database server or for all database servers. The checksum is verified by comparing the current checksum of the backup against the checksum when the backup was taken. + +!!! Note + The `VERIFY-CHKSUM` subcommand is only used for tar format backups. + +**Syntax:** + +```text +bart VERIFY-CHKSUM +[ –s { | all } ] +[ -i { | | all } ] +``` + +The following table describes the `VERIFY-CHKSUM` options: + +| Options | Description | +| ---------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { \| all }`
`--server { \| all` } | `` is the name of the database server whose tar backup checksums are to be verified.
If `all` is specified or if the `-s` option is omitted, the checksums of all tar backups are verified for all database servers. | +| `-i { \| \| all` }

`--backupid { \| \| all` } | `` is the backup identifier of a tar format full backup whose checksum is to be verified along with any user-defined tablespaces. `` is the user-defined alphanumeric name for the full backup.
If `all` is specified or if the `-i` option is omitted, the checksums of all tar backups for the relevant database server are verified. | + +**Example** + +The following code sample verifies the checksum of all tar format backups of the specified database server: + +```text +-bash-4.1$ bart VERIFY-CHKSUM -s acctg -i all +SERVER NAME BACKUP ID VERIFY +acctg 1430239348243 OK +acctg 1430232284202 OK +acctg 1430232016284 OK +acctg 1430231949065 OK +acctg 1429821844271 OK +``` diff --git a/product_docs/docs/bart/2.6.1/bart_ref/01_bart_subcommands_examples/10_running_the_bart_wal_scanner.mdx b/product_docs/docs/bart/2.6.1/bart_ref/01_bart_subcommands_examples/10_running_the_bart_wal_scanner.mdx new file mode 100644 index 00000000000..12305fb7733 --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_ref/01_bart_subcommands_examples/10_running_the_bart_wal_scanner.mdx @@ -0,0 +1,168 @@ +--- +title: "Running the BART WAL Scanner" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/running_the_bart_wal_scanner.html" +--- + +The BART WAL scanner is used to process each WAL file to find and record modified blocks in a corresponding MBM file. As a BART account user, use the BART WAL scanner to invoke the `bart-scanner` program located in the `/bin` directory. + +For detailed information about the WAL scanner and its usage, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/latest/bart_user/). + +**Syntax:** + +```text +bart-scanner +[ -d ] +[ -c ] +{ –h | +-v | +--daemon | +-p | + | +RELOAD | +STOP +--checksum-algorithm } +``` + +When the `bart-scanner` program is invoked, it forks a separate process for each database server enabled with the `allow_incremental_backups` parameter. + +The WAL scanner processes can run in either the foreground or background depending upon usage of the `--daemon` option: + +- If the `--daemon` option is specified, the WAL scanner process runs in the background. All output messages can be viewed in the BART log file. +- If the `--daemon` option is omitted, the WAL scanner process runs in the foreground. All output messages can be viewed from the terminal running the program as well as in the BART log file. + +The following table describes the `VERIFY-CHKSUM` options. + +| Options | Description | +| ---------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-h` `--help` | Displays general syntax and information on WAL scanner usage. | +| `-v` `--version` | Displays the WAL scanner version information. | +| `-d` `--debug` | Displays debugging output while executing the WAL scanner with any of its options. | +| `-c ` `--config-path ` | Specifies `` as the full directory path to a BART configuration file. Use this option if you do not want to use the default BART configuration file `/etc/bart.cfg` | +| `--daemon` | Runs the WAL scanner as a background process. | +| `-p ` `--print ` | Specifies the full directory path to an MBM file whose content is to be printed. The `archived_wals` directory as specified in the the `archive_path` parameter in the `bart.cfg` file contains the MBM files. | +| `` | Specifies the full directory path to a WAL file to be scanned. The archive path directory contains the WAL files. Use it if a WAL file in the archive path is missing its MBM file. This option is to be used for assisting the EnterpriseDB support team for debugging problems that may have been encountered. | +| `RELOAD` | Reloads the BART configuration file. The keyword `RELOAD` is case-insensitive. The `RELOAD` option is useful if you make changes to the configuration file after the WAL scanner has been started. It will reload the configuration file and adjust the WAL scanners accordingly. For example, if a server section allowing incremental backups is removed from the BART configuration file, then the process attached to that server will stop. Similarly, if a server allowing incremental backups is added, a new WAL scanner process will be launched to scan the WAL files of that server. | +| `STOP` | Stops the WAL scanner. The keyword `STOP` is not case-sensitive. | +| `--checksum-algorithm` | While invoking the WAL scanner, you can specify one of the following values with the `--checksum-algorithm` option: `--checksum-algorithm=MD5` (default) to generate MD5 checksum files. `--checksum-algorithm=SHA256` to generate SHA256 checksum files. `--checksum-algorithm=NONE` to skip generating checksum files. | + +**Example** + +The following code sample demonstrates starting the WAL scanner to run interactively. The WAL scanner begins scanning existing WAL files in the archive path that have not yet been scanned (that is, there is no corresponding MBM file for the WAL file): + +```text +-bash-4.2$ bart-scanner +INFO: process created for server 'acctg', pid = 5287 +INFO: going to parse backlog of WALs, if any. +INFO: WAL file to be processed: 0000000100000000000000ED +INFO: WAL file to be processed: 0000000100000000000000EE +INFO: WAL file to be processed: 0000000100000000000000EF +INFO: WAL file to be processed: 0000000100000000000000F0 +INFO: WAL file to be processed: 0000000100000000000000F1 +``` + +The following code sample is the content of the archive path showing the MBM files created for the WAL files. (The user name and group name of the files have been removed from the example to list the WAL files and MBM files in a more readable manner): + +```text +[root@localhost archived_wals]# pwd +/opt/backup/acctg/archived_wals +[root@localhost archived_wals]# ls -l +total 81944 +-rw------- 1 ... ... 16777216 Dec 20 09:10 0000000100000000000000ED +-rw------- 1 ... ... 16777216 Dec 20 09:06 0000000100000000000000EE +-rw------- 1 ... ... 16777216 Dec 20 09:11 0000000100000000000000EF +-rw------- 1 ... ... 16777216 Dec 20 09:15 0000000100000000000000F0 +-rw------- 1 ... ... 16777216 Dec 20 09:16 0000000100000000000000F1 +-rw------- 1 ... ... 305 Dec 20 09:16 0000000100000000000000F1.00000028.backup +-rw-rw-r-- 1 ... ... 161 Dec 20 09:18 +0000000100000000ED00002800000000EE000000.mbm +-rw-rw-r-- 1 ... ... 161 Dec 20 09:18 +0000000100000000EE00002800000000EF000000.mbm +-rw-rw-r-- 1 ... ... 161 Dec 20 09:18 +0000000100000000EF00002800000000F0000000.mbm +-rw-rw-r-- 1 ... ... 161 Dec 20 09:18 +0000000100000000F000002800000000F1000000.mbm +-rw-rw-r-- 1 ... ... 161 Dec 20 09:18 +0000000100000000F100002800000000F2000000.mbm +``` + +To stop the interactively running WAL scanner, either enter `ctrl-C` at the terminal running the WAL scanner or invoke the `bart-scanner` program from another terminal with the `STOP` option: + +```text +-bash-4.2$ bart-scanner STOP +-bash-4.2$ +``` + +The terminal on which the WAL scanner was running interactively appears as follows after it has been stopped: + +```text +-bash-4.2$ bart-scanner +INFO: process created for server 'acctg', pid = 5287 +INFO: going to parse backlog of WALs, if any. +INFO: WAL file to be processed: 0000000100000000000000ED +INFO: WAL file to be processed: 0000000100000000000000EE +INFO: WAL file to be processed: 0000000100000000000000EF +INFO: WAL file to be processed: 0000000100000000000000F0 +INFO: WAL file to be processed: 0000000100000000000000F1 +INFO: bart-scanner stopped +-bash-4.2$ +``` + +The following code sample demonstrates invoking the WAL scanner to run as a background process with the `--daemon` option: + +```text +-bash-4.2$ bart-scanner --daemon +-bash-4.2$ +``` + +The WAL scanner runs as a background process. There is also a separate background process for each database server that has been enabled for WAL scanning with the `allow_incremental_backups` parameter in the BART configuration file: + +```text +-bash-4.2$ ps -ef | grep bart + enterpr+ 4340 1 0 09:48 ? 00:00:00 bart-scanner --daemon + enterpr+ 4341 4340 0 09:48 ? 00:00:00 bart-scanner --daemon + enterpr+ 4415 3673 0 09:50 pts/0 00:00:00 grep --color=auto bart +``` + +To stop the WAL scanner processes, invoke the WAL scanner with the `STOP` option: + +```text +-bash-4.2$ bart-scanner STOP +-bash-4.2$ +``` + +The following command demonstrates scanning an individual WAL file: + +```text +-bash-4.2$ bart-scanner /opt/backup/acctg/archived_wals/0000000100000000000000FF +-bash-4.2$ +``` + +To print the content of an MBM file for assisting the EnterpriseDB support team for debugging problems that may have been encountered, use the `-p` option to specify the file as shown in the following code sample: + +```text +-bash-4.2$ bart-scanner -p +/opt/backup/acctg/archived_wals/0000000100000000FF0000280000000100000000.mbm + +Header: +Version: 1.0:90500:1.2.0 +Scan Start: 2016-12-20 10:02:11 EST, Scan End: 2016-12-20 10:02:11 EST, Diff: 0 sec(s) +Start LSN: ff000028, End LSN: 100000000, TLI: 1 +flags: 0, Check Sum: f9cfe66ae2569894d6746b61503a767d + +Path: base/14845/16384 +NodeTag: BLOCK_CHANGE +Relation: relPath base/14845/16384, isTSNode 0, Blocks +*............................................................................. +First modified block: 0 +Total modified blocks: 1 + +Path: base/14845/16391 +NodeTag: BLOCK_CHANGE +Relation: relPath base/14845/16391, isTSNode 0, Blocks +*.............................................................................. +First modified block: 0 +Total modified blocks: 1 +``` diff --git a/product_docs/docs/bart/2.6.1/bart_ref/01_bart_subcommands_examples/index.mdx b/product_docs/docs/bart/2.6.1/bart_ref/01_bart_subcommands_examples/index.mdx new file mode 100644 index 00000000000..20c71192ef2 --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_ref/01_bart_subcommands_examples/index.mdx @@ -0,0 +1,115 @@ +--- +title: "BART Subcommand Syntax and Examples" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/bart_subcommands_examples.html" +--- + + + +This section briefly describes each BART subcommand and provides an example. + +**Invoking BART** + +BART subcommands are invoked at the Linux command line as a BART user. You can invoke the `bart` program (located in the `/bin` directory) with the desired options to manage your BART installation. + +The following examples demonstrate ways of invoking BART. In these examples, the BART user account is named `bartuser`. + +```text +$ su bartuser +Password: +$ export +LD_LIBRARY_PATH=/opt/PostgresPlus/9.6AS/lib/:$LD_LIBRARY_PATH +$ ./bart SHOW-SERVERS +``` + +To run BART from any current working directory: + +```text +$ su bartuser +Password: +$ export +LD_LIBRARY_PATH=/opt/PostgresPlus/9.6AS/lib/:$LD_LIBRARY_PATH +$ bart SHOW-SERVERS +``` + +**Syntax for invoking BART** + +```text +bart [ ]... [ ] []... +``` + +You can use either abbreviated or long option forms on the command line (for example `-h` or `--help`). + +**General Options** + +You can specify the following general options with `bart`. + +`-h` or (`--help`) + +- Displays general syntax and information about BART usage. +- All subcommands support a help option (`-h, --help`). If the help option is specified, information is displayed regarding that particular subcommand. The subcommand, itself, is not executed. + +The following code sample displays the result of invoking the `--help` option for the `BACKUP` subcommand: + +```text +-bash-4.2$ bart BACKUP --help +bart: backup and recovery tool + +Usage: +bart BACKUP [OPTION]... + +Options: +-h, --help Show this help message and exit +-s, --server Name of the server or 'all' (full backups only) to specify all servers +-F, --format=p|t Backup output format (tar (default) or plain) +-z, --gzip Enables gzip compression of tar files +-c, --compress-level Specifies the compression level (1 through 9, 9 being + best compression) +--backup-name Specify a friendly name for the current backup +--parent Specify parent backup for incremental backup +--check Verify checksum of required mbm files +``` + +`-v` (or `--version`) + +The following code sample displays information returned by the `bart --version` subcommand: + +```text +[edb@localhost bin]$ bart --version +bart (EnterpriseDB) 2.5.2 +[edb@localhost bin]$ +``` + +`-d` (or `--debug`) + +The following code sample displays debugging output returned by the `bart MANAGE` subcommand: + +```text +-bash-4.1$ bart -d MANAGE -n +DEBUG: Server: acctg, Now: 2015-04-17 16:34:03 EDT, RetentionWindow: +259200 (secs) ==> 72 hour(s) +DEBUG: Server: dev, Now: 2015-04-17 16:34:03 EDT, RetentionWindow: +1814400 (secs) ==> 504 hour(s) +DEBUG: Server: hr, Now: 2015-04-17 16:34:03 EDT, RetentionWindow: +7776000 (secs) ==> 2160 hour(s) +``` + +`-c` (or `--config-path) ` + +The following code sample demonstrates using the `-c` option to specify a non-default configuration file name and installation location: + +```text +$ su bartuser +Password: +$ export +LD_LIBRARY_PATH=/opt/PostgresPlus/9.6AS/lib/:$LD_LIBRARY_PATH +$ bart -c /home/bartuser/bart.cfg SHOW-SERVERS +``` + +
+ +backup check_config delete init manage restore show_servers show_backups verify_chksum running_the_bart_wal_scanner + +
diff --git a/product_docs/docs/bart/2.6.1/bart_ref/02_additional_examples.mdx b/product_docs/docs/bart/2.6.1/bart_ref/02_additional_examples.mdx new file mode 100644 index 00000000000..38a519f727d --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_ref/02_additional_examples.mdx @@ -0,0 +1,1473 @@ +--- +title: "Additional Examples" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/additional_examples.html" +--- + + + +This section lists examples of the following BART operations. + +- Restoring a database cluster with tablespaces. +- Restoring an incremental backup. +- Managing backups. +- Managing incremental backups. + +## Restoring a Database Cluster with Tablespaces + +The following code sample illustrates taking a backup and restoring a database cluster on a remote host containing tablespaces. For detailed information regarding using tablespaces, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/latest/bart_user/). + +On an Advanced Server database running on a remote host, the following tablespaces are created for use by two tables: + +```text +edb=# CREATE TABLESPACE tblspc_1 LOCATION '/mnt/tablespace_1'; +CREATE TABLESPACE +edb=# CREATE TABLESPACE tblspc_2 LOCATION '/mnt/tablespace_2'; +CREATE TABLESPACE +edb=# \db + List of tablespaces +Name | Owner | Location +------------+-----------------+------------------- +pg_default | enterprisedb | +pg_global | enterprisedb | +tblspc_1 | enterprisedb | /mnt/tablespace_1 +tblspc_2 | enterprisedb | /mnt/tablespace_2 +(4 rows) + +edb=# CREATE TABLE tbl_tblspc_1 (c1 TEXT) TABLESPACE tblspc_1; +CREATE TABLE +edb=# CREATE TABLE tbl_tblspc_2 (c1 TEXT) TABLESPACE tblspc_2; +CREATE TABLE +edb=# \d tbl_tblspc_1 +Table "enterprisedb.tbl_tblspc_1" +Column | Type | Modifiers +-------+------+----------- +c1 | text | +Tablespace: "tblspc_1" + +edb=# \d tbl_tblspc_2 +Table "enterprisedb.tbl_tblspc_2" +Column | Type | Modifiers +-------+------+----------- +c1 | text | +Tablespace: "tblspc_2" +``` + +The following code sample shows the OIDs assigned to the tablespaces and the symbolic links to the tablespace directories: + +```text +-bash-4.1$ pwd +/opt/PostgresPlus/9.6AS/data/pg_tblspc +-bash-4.1$ ls -l +total 0 +lrwxrwxrwx 1 enterprisedb enterprisedb 17 Nov 16 16:17 16587 ->/mnt/tablespace_1 +lrwxrwxrwx 1 enterprisedb enterprisedb 17 Nov 16 16:17 16588 ->/mnt/tablespace_2 +``` + +The BART configuration file contains the following settings. Note that the `tablespace_path` parameter does not have to be set at this point. + +```text +[BART] +bart_host= enterprisedb@192.168.2.22 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log + +[ACCTG] +host = 192.168.2.24 +port = 5444 +user = repuser +cluster_owner = enterprisedb +remote_host = enterprisedb@192.168.2.24 +tablespace_path = +description = "Accounting" +``` + +After the necessary configuration steps are performed to ensure BART manages the remote database server, a full backup is taken as shown in the following code sample: + +```text +-bash-4.1$ bart BACKUP -s acctg + +INFO: creating backup for server 'acctg' +INFO: backup identifier: '1447709811516' +54521/54521 kB (100%), 3/3 tablespaces + +INFO: backup completed successfully +INFO: backup checksum: 594f69fe7d26af991d4173d3823e174f of 16587.tar +INFO: backup checksum: 7a5507567729a21c98a15c948ff6c015 of base.tar +INFO: backup checksum: ae8c62604c409635c9d9e82b29cc0399 of 16588.tar +INFO: +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1447709811516 +BACKUP NAME: none +BACKUP LOCATION: /opt/backup/acctg/1447709811516 +BACKUP SIZE: 53.25 MB +BACKUP FORMAT: tar +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 3 +ChkSum File +594f69fe7d26af991d4173d3823e174f 16587.tar +7a5507567729a21c98a15c948ff6c015 base.tar +ae8c62604c409635c9d9e82b29cc0399 16588.tar + +TABLESPACE(s): 2 +Oid Name Location +16587 tblspc_1 /mnt/tablespace_1 +16588 tblspc_2 /mnt/tablespace_2 +START WAL LOCATION: 00000001000000000000000F +BACKUP METHOD: streamed +BACKUP FROM: master +START TIME: 2015-11-16 16:36:51 EST +STOP TIME: 2015-11-16 16:36:52 EST +TOTAL DURATION: 1 sec(s) +``` + +Note that in the output from the preceding example, checksums are generated for the tablespaces as well as the full backup. + +Within the backup subdirectory `1447709811516` of the BART backup catalog, the tablespace data is stored with file names `16587.tar.gz` and `16588.tar.gz` as shown below: + +```text +-bash-4.1$ pwd +/opt/backup/acctg +-bash-4.1$ ls -l +total 8 +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 16:36 1447709811516 +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 16:43 archived_wals +-bash-4.1$ ls -l 1447709811516 +total 54536 +-rw-rw-r-- 1 enterprisedb enterprisedb 19968 Nov 16 16:36 16587.tar +-rw-rw-r-- 1 enterprisedb enterprisedb 19968 Nov 16 16:36 16588.tar +-rw-rw-r-- 1 enterprisedb enterprisedb 949 Nov 16 17:05 backupinfo +-rw-rw-r-- 1 enterprisedb enterprisedb 55792640 Nov 16 16:36 base.tar +``` + +When you are ready to restore the backup, in addition to creating the directory to which the main database cluster is to be restored, you must prepare the directories to which the tablespaces are to be restored. + +On the remote host, directories `/opt/restore_tblspc_1` and `/opt/restore_tblspc_2` are created and assigned the proper ownership and permissions as shown by the following example. The main database cluster is to be restored to `/opt/restore`. + +```text +[root@localhost opt]# mkdir restore_tblspc_1 +[root@localhost opt]# chown enterprisedb restore_tblspc_1 +[root@localhost opt]# chgrp enterprisedb restore_tblspc_1 +[root@localhost opt]# chmod 700 restore_tblspc_1 + +[root@localhost opt]# mkdir restore_tblspc_2 +[root@localhost opt]# chown enterprisedb restore_tblspc_2 +[root@localhost opt]# chgrp enterprisedb restore_tblspc_2 +[root@localhost opt]# chmod 700 restore_tblspc_2 +[root@localhost opt]# ls -l +total 20 +drwxr-xr-x 3 root daemon 4096 Nov 10 15:38 PostgresPlus +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 17:40 restore +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 17:40 +restore_tblspc_1 +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 17:41 +restore_tblspc_2 +drwxr-xr-x. 2 root root 4096 Nov 22 2013 rh +``` + +Set the `tablespace_path` parameter in the BART configuration file to specify the tablespace directories. The remote host user and IP address are specified by the `remote_host` configuration parameter. + +```text +[ACCTG] + +host = 192.168.2.24 +port = 5444 +user = repuser +cluster_owner = enterprisedb +remote_host = enterprisedb@192.168.2.24 +tablespace_path = +16587=/opt/restore_tblspc_1;16588=/opt/restore_tblspc_2 + +description = "Accounting" +``` + +The following code sample demonstrates invoking the `RESTORE` subcommand: + +```text +-bash-4.1$ bart RESTORE -s acctg -i 1447709811516 -p /opt/restore +INFO: restoring backup '1447709811516' of server 'acctg' +INFO: restoring backup to enterprisedb@192.168.2.24:/opt/restore +INFO: base backup restored +INFO: archiving is disabled +INFO: tablespace(s) restored +``` + +The following code sample shows the restored full backup (including the restored tablespaces): + +```text +bash-4.1$ pwd +/opt +-bash-4.1$ ls -l restore +total 104 +-rw------- 1 enterprisedb enterprisedb 206 Nov 16 16:36 backup_label.old +drwx------ 6 enterprisedb enterprisedb 4096 Nov 10 15:38 base +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 17:46 global +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_clog +-rw------- 1 enterprisedb enterprisedb 4438 Nov 10 16:23 pg_hba.conf +-rw------- 1 enterprisedb enterprisedb 1636 Nov 10 15:38 pg_ident.conf +drwxr-xr-x 2 enterprisedb enterprisedb 4096 Nov 16 17:45 pg_log +drwx------ 4 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_multixact +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 17:45 pg_notify +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_serial +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_snapshots +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 17:47 pg_stat +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 17:47 pg_stat_tmp +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_subtrans +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 17:42 pg_tblspc +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_twophase +-rw------- 1 enterprisedb enterprisedb 4 Nov 10 15:38 PG_VERSION +drwx------ 3 enterprisedb enterprisedb 4096 Nov 16 17:47 pg_xlog +-rw------- 1 enterprisedb enterprisedb 23906 Nov 16 17:42 postgresql.conf +-rw------- 1 enterprisedb enterprisedb 61 Nov 16 17:45 postmaster.opts +-bash-4.1$ +-bash-4.1$ ls -l restore_tblspc_1 +total 4 +drwx------ 3 enterprisedb enterprisedb 4096 Nov 16 16:18 +PG_9.6_201306121 +-bash-4.1$ ls -l restore_tblspc_2 +total 4 +drwx------ 3 enterprisedb enterprisedb 4096 Nov 16 16:18 +PG_9.6_201306121 +``` + +The symbolic links in the `pg_tblspc` subdirectory point to the restored directory location: + +```text +bash-4.1$ pwd +/opt/restore/pg_tblspc +-bash-4.1$ ls -l +total 0 +lrwxrwxrwx 1 enterprisedb enterprisedb 21 Nov 16 17:42 16587 -> +/opt/restore_tblspc_1 +lrwxrwxrwx 1 enterprisedb enterprisedb 21 Nov 16 17:42 16588 -> +/opt/restore_tblspc_2 +``` + +`psql` queries also show the restored tablespaces: + +```text +edb=# \db + + List of tablespaces +Name | Owner | Location +------------+--------------+----------------------- +pg_default | enterprisedb | +pg_global | enterprisedb | +tblspc_1 | enterprisedb | /opt/restore_tblspc_1 +tblspc_2 | enterprisedb | /opt/restore_tblspc_2 +``` + +## Restoring an Incremental Backup + +Restoring an incremental backup may require additional setup steps depending upon the host on which the incremental backup is to be restored. For more information, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/latest/bart_user/). + +This section provides an example of creating backup chains and then restoring an incremental backup. + +**Creating a Backup Chain** + +A *backup chain* is the set of backups consisting of a full backup and all of its successive incremental backups. Tracing back on the parent backups of all incremental backups in the chain eventually leads back to that single, full backup. + +In the following example, the `allow_incremental_backups` parameter is set to `enabled` in the BART configuration file to permit incremental backups on the listed database server: + +```text +[BART] + +bart_host= enterprisedb@192.168.2.27 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log + +[ACCTG] + +host = 127.0.0.1 +port = 5445 +user = enterprisedb +cluster_owner = enterprisedb +allow_incremental_backups = enabled +description = "Accounting" +``` + +After the database server has been started with WAL archiving enabled to the BART backup catalog, the WAL scanner is started: + +```text +-bash-4.2$ bart-scanner --daemon +``` + +First, a full backup is taken. + +```text +-bash-4.2$ bart BACKUP -s acctg --backup-name full_1 +INFO: creating backup for server 'acctg' +INFO: backup identifier: '1490649204327'\ +63364/63364 kB (100%), 1/1 tablespace +INFO: backup completed successfully +INFO: backup checksum: aae27d4a7c09dffc82f423221154db7e of base.tar +INFO: +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1490649204327 +BACKUP NAME: full_1 +BACKUP PARENT: none +BACKUP LOCATION: /opt/backup/acctg/1490649204327 +BACKUP SIZE: 61.88 MB +BACKUP FORMAT: tar +BACKUP TIMEZONE: US/Eastern +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 1 +ChkSum File +aae27d4a7c09dffc82f423221154db7e base.tar +TABLESPACE(s): 0 +START WAL LOCATION: 00000001000000000000000E +BACKUP METHOD: streamed +BACKUP FROM: master +START TIME: 2017-03-27 17:13:24 EDT +STOP TIME: 2017-03-27 17:13:25 EDT +TOTAL DURATION: 1 sec(s) +``` + +A series of incremental backups are taken. The first incremental backup specifies the full backup as the parent. Each successive incremental backup then uses the preceding incremental backup as its parent. + +```text +-bash-4.2$ bart BACKUP -s acctg -F p --parent full_1 --backup-name +incr_1-a +INFO: creating incremental backup for server 'acctg' +INFO: checking mbm files /opt/backup/acctg/archived_wals +INFO: new backup identifier generated 1490649255649 +INFO: reading directory /opt/backup/acctg/archived_wals +INFO: all files processed +NOTICE: pg_stop_backup complete, all required WAL segments have been +archived +INFO: incremental backup completed successfully +INFO: +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1490649255649 +BACKUP NAME: incr_1-a +BACKUP PARENT: 1490649204327 +BACKUP LOCATION: /opt/backup/acctg/1490649255649 +BACKUP SIZE: 16.56 MB +BACKUP FORMAT: plain +BACKUP TIMEZONE: US/Eastern +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 0 +TABLESPACE(s): 0 +START WAL LOCATION: 000000010000000000000010 +STOP WAL LOCATION: 000000010000000000000010 +BACKUP METHOD: pg_start_backup +BACKUP FROM: master +START TIME: 2017-03-27 17:14:15 EDT +STOP TIME: 2017-03-27 17:14:16 EDT +TOTAL DURATION: 1 sec(s) +-bash-4.2$ bart BACKUP -s acctg -F p --parent incr_1-a --backup-name +incr_1-b +INFO: creating incremental backup for server 'acctg' +INFO: checking mbm files /opt/backup/acctg/archived_wals +INFO: new backup identifier generated 1490649336845 +INFO: reading directory /opt/backup/acctg/archived_wals +INFO: all files processed +NOTICE: pg_stop_backup complete, all required WAL segments have been +archived +INFO: incremental backup completed successfully +. +. +. +-bash-4.2$ bart BACKUP -s acctg -F p --parent incr_1-b --backup-name +incr_1-c +INFO: creating incremental backup for server 'acctg' +INFO: checking mbm files /opt/backup/acctg/archived_wals +INFO: new backup identifier generated 1490649414316 +INFO: reading directory /opt/backup/acctg/archived_wals +INFO: all files processed +NOTICE: pg_stop_backup complete, all required WAL segments have been +archived +INFO: incremental backup completed successfully +. +. +. +``` + +The following output of the `SHOW-BACKUPS` subcommand lists the backup chain, which are backups `full_1, incr_1-a, incr_1-b, and incr_1-c`. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID BACKUP NAME BACKUP PARENT BACKUP TIME ... +acctg 1490649414316 incr_1-c incr_1-b 2017-03-27 17:16:55 ... +acctg 1490649336845 incr_1-b incr_1-a 2017-03-27 17:15:37 ... +acctg 1490649255649 incr_1-a full_1 2017-03-27 17:14:16 ... +acctg 1490649204327 full_1 none 2017-03-27 17:13:25 ... +``` + +For the `full backup full_1`, the `BACKUP PARENT` field contains `none`. For each incremental backup, the `BACKUP PARENT` field contains the backup identifier or name of its parent backup. + +A second backup chain is created in the same manner with the `BACKUP` subcommand. The following example shows the addition of the resulting, second backup chain consisting of full backup `full_2` and incremental backups `incr_2-a` and `incr_2-b`. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID BACKUP NAME BACKUP PARENT BACKUP TIME ... +acctg 1490649605607 incr_2-b incr_2-a 2017-03-27 17:20:06 ... +acctg 1490649587702 incr_2-a full_2 2017-03-27 17:19:48 ... +acctg 1490649528633 full_2 none 2017-03-27 17:18:49 ... +acctg 1490649414316 incr_1-c incr_1-b 2017-03-27 17:16:55 ... +acctg 1490649336845 incr_1-b incr_1-a 2017-03-27 17:15:37 ... +acctg 1490649255649 incr_1-a full_1 2017-03-27 17:14:16 ... +acctg 1490649204327 full_1 none 2017-03-27 17:13:25 ... +``` + +The following additional incremental backups starting with `incr_1-b-1`, which designates `incr_1-b` as the parent, results in the forking from that backup into a second line of backups in the chain consisting of `full_1, incr_1-a, incr_1-b, incr_1-b-1, incr_1-b-2`, and `incr_1-b-3` as shown in the following list: + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID BACKUP NAME BACKUP PARENT BACKUP TIME ... +acctg 1490649791430 incr_1-b-3 incr_1-b-2 2017-03-27 17:23:12 ... +acctg 1490649763929 incr_1-b-2 incr_1-b-1 2017-03-27 17:22:44 ... +acctg 1490649731672 incr_1-b-1 incr_1-b 2017-03-27 17:22:12 ... +acctg 1490649605607 incr_2-b incr_2-a 2017-03-27 17:20:06 ... +acctg 1490649587702 incr_2-a full_2 2017-03-27 17:19:48 ... +acctg 1490649528633 full_2 none 2017-03-27 17:18:49 ... +acctg 1490649414316 incr_1-c incr_1-b 2017-03-27 17:16:55 ... +acctg 1490649336845 incr_1-b incr_1-a 2017-03-27 17:15:37 ... +acctg 1490649255649 incr_1-a full_1 2017-03-27 17:14:16 ... +acctg 1490649204327 full_1 none 2017-03-27 17:13:25 ... +``` + +**Restoring an Incremental Backup** + +Restoring an incremental backup is done with the `RESTORE` subcommand in the same manner as for restoring a full backup. Specify the backup identifier or backup name of the incremental backup to be restored as shown in the following example. + +```text +-bash-4.2$ bart RESTORE -s acctg -p /opt/restore -i incr_1-b +INFO: restoring incremental backup 'incr_1-b' of server 'acctg' +INFO: base backup restored +INFO: archiving is disabled +INFO: permissions set on $PGDATA +INFO: incremental restore completed successfully +``` + +Restoring incremental backup `incr_1-b` as shown by the preceding example results in the restoration of full backup `full_1`, then incremental backups `incr_1-a` and finally, `incr_1-b`. + +## Managing Backups + +This section illustrates evaluating, marking, and deleting backups using the `MANAGE` subcommand using a redundancy retention policy and a recovery window retention policy. For detailed information about the `MANAGE` subcommand, see the *EDB Backup and Recovery User Guide* available at the [EDB website](/bart/latest/bart_user/). + + + +### Using a Redundancy Retention Policy + +The following code sample uses a redundancy retention policy to evaluate, mark, and delete backups as shown by the following server configuration: + +```text +[ACCTG] +host = 127.0.0.1 +port = 5444 +user = enterprisedb +archive_command = 'cp %p %a/%f' +retention_policy = 3 BACKUPS +description = "Accounting" +``` + +The following list is the set of backups. Note that the last backup in the list has been marked as `keep`. + +```text +-bash-4.1$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID BACKUP TIME BACKUP SIZE WAL(s) SIZE +WAL FILES STATUS +acctg 1428768344061 2015-04-11 12:05:46 EDT 5.72 MB 48.00 MB +3 active +acctg 1428684537299 2015-04-10 12:49:00 EDT 5.72 MB 272.00 MB +17 active +acctg 1428589759899 2015-04-09 10:29:27 EDT 5.65 MB 96.00 MB +6 active +acctg 1428502049836 2015-04-08 10:07:30 EDT 55.25 MB 96.00 MB +6 active +acctg 1428422324880 2015-04-07 11:58:45 EDT 54.53 MB 32.00 MB +2 active +acctg 1428355371389 2015-04-06 17:22:53 EDT 5.71 MB 16.00 MB +1 keep +``` + +Invoke the `MANAGE` subcommand with the `-n` option to perform a dry run to observe which active backups would be changed to obsolete according to the retention policy as shown in the following code sample: + +```text +-bash-4.1$ bart MANAGE -s acctg -n +INFO: processing server 'acctg', backup '1428768344061' +INFO: processing server 'acctg', backup '1428684537299' +INFO: processing server 'acctg', backup '1428589759899' +INFO: processing server 'acctg', backup '1428502049836' +INFO: marking backup '1428502049836' as obsolete +INFO: 6 WAL file(s) marked obsolete +INFO: processing server 'acctg', backup '1428422324880' +INFO: marking backup '1428422324880' as obsolete +INFO: 2 WAL file(s) marked obsolete +INFO: processing server 'acctg', backup '1428355371389' +``` + +The dry run shows that backups `1428502049836` and `1428422324880` would be marked as `obsolete`. + +!!! Note + A dry run does not change the backup status. The two backups that would be considered obsolete are still marked as `active`: + +```text +-bash-4.1$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID BACKUP TIME BACKUP SIZE WAL(s) SIZE +WAL FILES STATUS +acctg 1428768344061 2015-04-11 12:05:46 EDT 5.72 MB 48.00 MB +3 active +acctg 1428684537299 2015-04-10 12:49:00 EDT 5.72 MB 272.00 MB +17 active +acctg 1428589759899 2015-04-09 10:29:27 EDT 5.65 MB 96.00 MB +6 active +acctg 1428502049836 2015-04-08 10:07:30 EDT 55.25 MB 96.00 MB +6 active +acctg 1428422324880 2015-04-07 11:58:45 EDT 54.53 MB 32.00 MB +2 active +acctg 1428355371389 2015-04-06 17:22:53 EDT 5.71 MB 16.00 MB +1 keep +``` + +Invoke the `MANAGE` subcommand omitting the `-n` option to change and mark the status of the backups as `obsolete`: + +```text +-bash-4.1$ bart MANAGE -s acctg +INFO: processing server 'acctg', backup '1428768344061' +INFO: processing server 'acctg', backup '1428684537299' +INFO: processing server 'acctg', backup '1428589759899' +INFO: processing server 'acctg', backup '1428502049836' +INFO: marking backup '1428502049836' as obsolete +INFO: 6 WAL file(s) marked obsolete +INFO: processing server 'acctg', backup '1428422324880' +INFO: marking backup '1428422324880' as obsolete +INFO: 2 WAL file(s) marked obsolete +INFO: processing server 'acctg', backup '1428355371389' +``` + +The obsolete backups can be observed in a number of ways. Use the `MANAGE` subcommand with the `-l` option to list the `obsolete` backups: + +```text +-bash-4.1$ bart MANAGE -s acctg -l +INFO: 6 WAL file(s) will be removed +SERVER NAME: acctg +BACKUP ID: 1428502049836 +BACKUP STATUS: obsolete +BACKUP TIME: 2015-04-08 10:07:30 EDT +BACKUP SIZE: 55.25 MB +WAL FILE(s): 6 +WAL FILE: 000000010000000100000003 +WAL FILE: 000000010000000100000002 +WAL FILE: 000000010000000100000001 +WAL FILE: 000000010000000100000000 +WAL FILE: 0000000100000000000000E3 +WAL FILE: 0000000100000000000000E2 +INFO: 2 WAL file(s) will be removed +SERVER NAME: acctg +BACKUP ID: 1428422324880 +BACKUP STATUS: obsolete +BACKUP TIME: 2015-04-07 11:58:45 EDT +BACKUP SIZE: 54.53 MB +WAL FILE(s): 2 +WAL FILE: 0000000100000000000000E1 +WAL FILE: 0000000100000000000000E0 +``` + +The `STATUS` field of the `SHOW-BACKUPS` subcommand displays the current status: + +```text +-bash-4.1$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID BACKUP TIME BACKUP SIZE WAL(s) SIZE +WAL FILES STATUS +acctg 1428768344061 2015-04-11 12:05:46 EDT 5.72 MB 48.00 MB +3 active +acctg 1428684537299 2015-04-10 12:49:00 EDT 5.72 MB 272.00 MB +17 active +acctg 1428589759899 2015-04-09 10:29:27 EDT 5.65 MB 96.00 MB +6 active +acctg 1428502049836 2015-04-08 10:07:30 EDT 55.25 MB 96.00 MB +6 obsolete +acctg 1428422324880 2015-04-07 11:58:45 EDT 54.53 MB 32.00 MB +2 obsolete +acctg 1428355371389 2015-04-06 17:22:53 EDT 5.71 MB 16.00 MB +1 keep +``` + +The details of an individual backup can be displayed using the `SHOW-BACKUPS` subcommand with the `-t` option. Note the status in the `BACKUP STATUS` field. + +```text +-bash-4.1$ bart SHOW-BACKUPS -s acctg -i 1428502049836 -t +SERVER NAME : acctg +BACKUP ID : 1428502049836 +BACKUP NAME : none +BACKUP STATUS : obsolete +BACKUP TIME : 2015-04-08 10:07:30 EDT +BACKUP SIZE : 55.25 MB +WAL(S) SIZE : 96.00 MB +NO. OF WALS : 6 +FIRST WAL FILE : 0000000100000000000000E2 +CREATION TIME : 2015-04-08 10:07:30 EDT +LAST WAL FILE : 000000010000000100000003 +CREATION TIME : 2015-04-09 10:25:46 EDT +``` + +Use the `MANAGE` subcommand with the `-d` option to physically delete the `obsolete` backups including the unneeded WAL files. + +```text +-bash-4.1$ bart MANAGE -s acctg -d +INFO: removing all obsolete backups of server 'acctg' +INFO: removing obsolete backup '1428502049836' +INFO: 6 WAL file(s) will be removed +INFO: removing WAL file '000000010000000100000003' +INFO: removing WAL file '000000010000000100000002' +INFO: removing WAL file '000000010000000100000001' +INFO: removing WAL file '000000010000000100000000' +INFO: removing WAL file '0000000100000000000000E3' +INFO: removing WAL file '0000000100000000000000E2' +INFO: removing obsolete backup '1428422324880' +INFO: 2 WAL file(s) will be removed +INFO: removing WAL file '0000000100000000000000E1' +INFO: removing WAL file '0000000100000000000000E0' +``` + +The `SHOW-BACKUPS` subcommand now displays the remaining backups marked as `active` or `keep`: + +```text +-bash-4.1$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID BACKUP TIME BACKUP SIZE WAL(s) SIZE +WAL FILES STATUS +acctg 1428768344061 2015-04-11 12:05:46 EDT 5.72 MB 48.00 MB +3 active +acctg 1428684537299 2015-04-10 12:49:00 EDT 5.72 MB 272.00 MB +17 active +acctg 1428589759899 2015-04-09 10:29:27 EDT 5.65 MB 96.00 MB +6 active +acctg 1428355371389 2015-04-06 17:22:53 EDT 5.71 MB 16.00 MB +1 keep +``` + + + +### Using a Recovery Window Retention Policy + +This section illustrates the evaluation, marking, and deletion of backup using a recovery window retention policy. To use the recovery window retention policy, set the `retention_policy` parameter to the desired length of time for the recovery window. + +This section provides examples of the following: + +- How to view the calculated recovery window. +- How to evaluate, mark, and delete backup using a recovery window retention policy. + +#### Viewing the Recovery Window + +You can view the actual, calculated recovery window by invoking any of the following subcommands: + +- `MANAGE` subcommand in debug mode (along with the `-n` option). +- `SHOW-SERVERS` subcommand. + +##### Viewing the Recovery Window Using the Manage Subcommand + +When invoking BART in debug mode with the `MANAGE` subcommand and the `-n` option, the length of the recovery window is calculated based on the `retention_policy` setting and the current date/time. + +For example, using the following `retention_policy` settings: + +```text +[ACCTG] + +host = 127.0.0.1 +port = 5444 +user = enterprisedb +archive_command = 'cp %p %a/%f' +retention_policy = 3 DAYS +backup-name = acctg_%year-%month-%dayT%hour:%minute:%second +description = "Accounting" + +[DEV] + +host = 127.0.0.1 +port = 5445 +user = enterprisedb +archive_command = 'cp %p %a/%f' +retention_policy = 3 WEEKS +description = "Development" + +[HR] + +host = 127.0.0.1 +port = 5432 +user = postgres +retention_policy = 3 MONTHS +description = "Human Resources" +``` + +If the `MANAGE` subcommand is invoked in debug mode along with the `-n` option on 2015-04-17, the following results are displayed: + +```text +-bash-4.1$ bart -d MANAGE -n +DEBUG: Server: acctg, Now: 2015-04-17 16:34:03 EDT, RetentionWindow: +259200 (secs) ==> 72 hour(s) +DEBUG: Server: dev, Now: 2015-04-17 16:34:03 EDT, RetentionWindow: +1814400 (secs) ==> 504 hour(s) +DEBUG: Server: hr, Now: 2015-04-17 16:34:03 EDT, RetentionWindow: +7776000 (secs) ==> 2160 hour(s) +``` + +For server `acctg`, 72 hours translates to a recovery window of 3 days. + +For server `dev`, 504 hours translates to a recovery window of 21 days (3 weeks). + +For server `hr`, 2160 hours translates to a recovery window of 90 days (3 months). + +For a setting of ` MONTHS`, the calculated total number of days for the recovery window is dependent upon the actual number of days in the preceding months from the current date/time. Thus, ` MONTHS` is not always exactly equivalent to ` x 30 DAYS`. For example, if the current date/time is in the month of March, a 1-month recovery window would be equivalent to only 28 days because the preceding month is February. Thus, for a current date of March 31, a 1-month recovery window would start on March 3. However, the typical result is that the day of the month of the starting recovery window boundary will be the same day of the month of when the `MANAGE` subcommand is invoked. + +##### Viewing the Recovery Window Using the Show-Servers Subcommand + +This section provides an example of viewing the recovery window using the `SHOW-SERVERS` subcommand; the `RETENTION POLICY` field displays the start of the recovery window. + +In the following code sample, the recovery window retention policy setting considers the backups taken within a 3-day recovery window as the active backups. + +```text +[ACCTG] +host = 127.0.0.1 +port = 5444 +user = enterprisedb +archive_command = 'cp %p %a/%f' +retention_policy = 3 DAYS +description = "Accounting" +``` + +The start of the 3-day recovery window displayed in the `RETENTION POLICY` field is `2015-04-07 14:57:36 EDT` when the `SHOW-SERVERS` subcommand is invoked on `2015-04-10`. + +At this current point in time, backups taken on or after `2015-04-07 14:57:36 EDT` would be considered active. Backups taken prior to `2015-04-07 14:57:36 EDT` would be considered obsolete except for backups marked as `keep`. + +```text +-bash-4.1$ date +Fri Apr 10 14:57:33 EDT 2015 +-bash-4.1$ +-bash-4.1$ bart SHOW-SERVERS -s acctg +SERVER NAME : acctg +HOST NAME : 127.0.0.1 +USER NAME : enterprisedb +PORT : 5444 +REMOTE HOST : +RETENTION POLICY : 2015-04-07 14:57:36 EDT +DISK UTILIZATION : 824.77 MB +NUMBER OF ARCHIVES : 37 +ARCHIVE PATH : /opt/backup/acctg/archived_wals +ARCHIVE COMMAND : cp %p /opt/backup/acctg/archived_wals/%f +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +DESCRIPTION : "Accounting" +``` + +In the following code sample, the recovery window retention policy setting considers the backups taken within a 3-week recovery window as the `active` backups. + +```text +[DEV] +host = 127.0.0.1 +port = 5445 +user = enterprisedb +archive_command = 'cp %p %a/%f' +retention_policy = 3 WEEKS +description = "Development" +``` + +The start of the 3-week recovery window displayed in the `RETENTION POLICY` field is `2015-03-20 14:59:42 EDT` when the `SHOW-SERVERS` subcommand is invoked on `2015-04-10`. + +At this current point in time, backups taken on or after `2015-03-20 14:59:42 EDT` would be considered `active`. Backups taken prior to `2015-03-20 14:59:42 EDT` would be considered `obsolete` except for backups marked as `keep`. + +```text +-bash-4.1$ date +Fri Apr 10 14:59:39 EDT 2015 +-bash-4.1$ +-bash-4.1$ bart SHOW-SERVERS -s dev +SERVER NAME : dev +HOST NAME : 127.0.0.1 +USER NAME : enterprisedb +PORT : 5445 +REMOTE HOST : +RETENTION POLICY : 2015-03-20 14:59:42 EDT +DISK UTILIZATION : 434.53 MB +NUMBER OF ARCHIVES : 22 +ARCHIVE PATH : /opt/backup/dev/archived_wals +ARCHIVE COMMAND : cp %p /opt/backup/dev/archived_wals/%f +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +DESCRIPTION : "Development" +``` + +In the following code sample, the recovery window retention policy setting considers the backups taken within a 3-month recovery window as the `active` backups. + +```text +[HR] +host = 127.0.0.1 +port = 5432 +user = postgres +retention_policy = 3 MONTHS +description = "Human Resources" +``` + +The start of the 3-month recovery window displayed in the `RETENTION POLICY` field is `2015-01-10 14:04:23 EST` when the `SHOW-SERVERS` subcommand is invoked on `2015-04-10`. + +At this current point in time, backups taken on or after `2015-01-10 14:04:23 EST` would be considered `active`. Backups taken prior to `2015-01-10 14:04:23 EST` would be considered `obsolete`, except for backups marked as `keep`. + +```text +-bash-4.1$ date +Fri Apr 10 15:04:19 EDT 2015 +-bash-4.1$ +-bash-4.1$ bart SHOW-SERVERS -s hr +SERVER NAME : hr +HOST NAME : 127.0.0.1 +USER NAME : postgres +PORT : 5432 +REMOTE HOST : +RETENTION POLICY : 2015-01-10 14:04:23 EST +DISK UTILIZATION : 480.76 MB +NUMBER OF ARCHIVES : 26 +ARCHIVE PATH : /opt/backup/hr/archived_wals +ARCHIVE COMMAND : scp %p +enterprisedb@192.168.2.22:/opt/backup/hr/archived_wals/%f +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +DESCRIPTION : "Human Resources" +``` + +#### Evaluating, Marking, and Deleting Backup Using a Recovery Window Retention Policy + +The following code sample uses a recovery window retention policy to evaluate, mark, and delete backups as shown by the following server configuration: + +```text +[DEV] +host = 127.0.0.1 +port = 5445 +user = enterprisedb +archive_command = 'cp %p %a/%f' +retention_policy = 3 DAYS +description = "Development" +``` + +The following is the current set of backups. Note that the last backup in the list has been marked as `keep`. + +```text +-bash-4.1$ bart SHOW-BACKUPS -s dev +SERVER NAME BACKUP ID BACKUP TIME BACKUP SIZE WAL(s) SIZE +WAL FILES STATUS +dev 1428933278236 2015-04-13 09:54:40 EDT 5.65 MB 16.00 MB +1 active +dev 1428862187757 2015-04-12 14:09:50 EDT 5.65 MB 32.00 MB +2 active +dev 1428768351638 2015-04-11 12:05:54 EDT 5.65 MB 32.00 MB +2 active +dev 1428684544008 2015-04-10 12:49:06 EDT 5.65 MB 224.00 MB +14 active +dev 1428590536488 2015-04-09 10:42:18 EDT 5.65 MB 48.00 MB +3 active +dev 1428502171990 2015-04-08 10:09:34 EDT 5.65 MB 80.00 MB +5 keep +``` + +The current date and time is `2015-04-13 16:46:35 EDT` as shown below: + +```text +-bash-4.1$ date +Mon Apr 13 16:46:35 EDT 2015 +``` + +Thus, a 3-day recovery window would evaluate backups prior to `2015-04-10 16:46:35 EDT` as `obsolete` except for those marked as `keep`. + +Invoke the `MANAGE` subcommand with the `-n` option to perform a dry run to observe which active backups would be changed to `obsolete` according to the retention policy. + +```text +-bash-4.1$ bart MANAGE -s dev -n +INFO: processing server 'dev', backup '1428933278236' +INFO: processing server 'dev', backup '1428862187757' +INFO: processing server 'dev', backup '1428768351638' +INFO: processing server 'dev', backup '1428684544008' +INFO: marking backup '1428684544008' as obsolete +INFO: 14 WAL file(s) marked obsolete +INFO: 1 Unused WAL file(s) present +INFO: processing server 'dev', backup '1428590536488' +INFO: marking backup '1428590536488' as obsolete +INFO: 3 WAL file(s) marked obsolete +INFO: 1 Unused WAL file(s) present +INFO: processing server 'dev', backup '1428502171990' +``` + +The dry run shows that backups `1428684544008` and `1428590536488` would be marked as `obsolete`. + +Also note that a dry run does not change the backup status. The two backups that would be considered obsolete are still marked as `active`: + +```text +-bash-4.1$ bart SHOW-BACKUPS -s dev\ + SERVER NAME BACKUP ID BACKUP TIME BACKUP SIZE WAL(s) SIZE + WAL FILES STATUS + dev 1428933278236 2015-04-13 09:54:40 EDT 5.65 MB 16.00 MB + 1 active + dev 1428862187757 2015-04-12 14:09:50 EDT 5.65 MB 32.00 MB + 2 active + dev 1428768351638 2015-04-11 12:05:54 EDT 5.65 MB 32.00 MB + 2 active + dev 1428684544008 2015-04-10 12:49:06 EDT 5.65 MB 224.00 MB + 14 active + dev 1428590536488 2015-04-09 10:42:18 EDT 5.65 MB 48.00 MB + 3 active + dev 1428502171990 2015-04-08 10:09:34 EDT 5.65 MB 80.00 MB + 5 keep +``` + +Invoke the `MANAGE` subcommand omitting the `-n` option to change and mark the status of the backups as `obsolete`: + +```text +-bash-4.1$ bart MANAGE -s dev +INFO: processing server 'dev', backup '1428933278236' +INFO: processing server 'dev', backup '1428862187757' +INFO: processing server 'dev', backup '1428768351638' +INFO: processing server 'dev', backup '1428684544008' +INFO: marking backup '1428684544008' as obsolete +INFO: 14 WAL file(s) marked obsolete +INFO: 1 Unused WAL file(s) present +INFO: processing server 'dev', backup '1428590536488' +INFO: marking backup '1428590536488' as obsolete +INFO: 3 WAL file(s) marked obsolete +INFO: 1 Unused WAL file(s) present +INFO: processing server 'dev', backup '1428502171990' +``` + +The obsolete backups can be observed in a number of ways. Use the `MANAGE` subcommand with the `-l` option to list the `obsolete` backups: + +```text +-bash-4.1$ bart MANAGE -s dev -l +INFO: 14 WAL file(s) will be removed +INFO: 1 Unused WAL file(s) will be removed +SERVER NAME: dev +BACKUP ID: 1428684544008 +BACKUP STATUS: obsolete +BACKUP TIME: 2015-04-10 12:49:06 EDT +BACKUP SIZE: 5.65 MB +WAL FILE(s): 14 +UNUSED WAL FILE(s): 1 +WAL FILE: 00000001000000000000002E +WAL FILE: 00000001000000000000002D +WAL FILE: 00000001000000000000002C +WAL FILE: 00000001000000000000002B +WAL FILE: 00000001000000000000002A +WAL FILE: 000000010000000000000029 +WAL FILE: 000000010000000000000028 +WAL FILE: 000000010000000000000027 +WAL FILE: 000000010000000000000026 +WAL FILE: 000000010000000000000025 +WAL FILE: 000000010000000000000024 +WAL FILE: 000000010000000000000023 +WAL FILE: 000000010000000000000022 +WAL FILE: 000000010000000000000021 +UNUSED WAL FILE: 00000001000000000000000F.00000028 +INFO: 3 WAL file(s) will be removed +INFO: 1 Unused WAL file(s) will be removed +SERVER NAME: dev +BACKUP ID: 1428590536488 +BACKUP STATUS: obsolete +BACKUP TIME: 2015-04-09 10:42:18 EDT\ +BACKUP SIZE: 5.65 MB +WAL FILE(s): 3 +UNUSED WAL FILE(s): 1 +WAL FILE: 000000010000000000000020 +WAL FILE: 00000001000000000000001F +WAL FILE: 00000001000000000000001E +UNUSED WAL FILE: 00000001000000000000000F.00000028 +``` + +The `STATUS` field of the `SHOW-BACKUPS` subcommand displays the current status: + +```text +-bash-4.1$ bart SHOW-BACKUPS -s dev +SERVER NAME BACKUP ID BACKUP TIME BACKUP SIZE WAL(s) SIZE +WAL FILES STATUS +dev 1428933278236 2015-04-13 09:54:40 EDT 5.65 MB 16.00 MB +1 active +dev 1428862187757 2015-04-12 14:09:50 EDT 5.65 MB 32.00 MB +2 active +dev 1428768351638 2015-04-11 12:05:54 EDT 5.65 MB 32.00 MB +2 active +dev 1428684544008 2015-04-10 12:49:06 EDT 5.65 MB 224.00 MB +14 obsolete +dev 1428590536488 2015-04-09 10:42:18 EDT 5.65 MB 48.00 MB +3 obsolete +dev 1428502171990 2015-04-08 10:09:34 EDT 5.65 MB 80.00 MB +5 keep +``` + +The details of an individual backup can be displayed using the `SHOW-BACKUPS` subcommand with the `-t` option. Note the status in the `BACKUP STATUS` field. + +```text +-bash-4.1$ bart SHOW-BACKUPS -s dev -i 1428684544008 -t +SERVER NAME : dev +BACKUP ID : 1428684544008 +BACKUP NAME : none +BACKUP STATUS : obsolete +BACKUP TIME : 2015-04-10 12:49:06 EDT +BACKUP SIZE : 5.65 MB +WAL(S) SIZE : 224.00 MB +NO. OF WALS : 14 +FIRST WAL FILE : 000000010000000000000021 +CREATION TIME : 2015-04-10 12:49:06 EDT +LAST WAL FILE : 00000001000000000000002E +CREATION TIME : 2015-04-11 12:02:15 EDT +``` + +Use the `MANAGE` subcommand with the `-d` option to physically delete the obsolete backups including the unneeded WAL files. + +```text +-bash-4.1$ bart MANAGE -s dev -d +INFO: removing all obsolete backups of server 'dev' +INFO: removing obsolete backup '1428684544008' +INFO: 14 WAL file(s) will be removed +INFO: 1 Unused WAL file(s) will be removed +INFO: removing WAL file '00000001000000000000002E' +INFO: removing WAL file '00000001000000000000002D' +INFO: removing WAL file '00000001000000000000002C' +INFO: removing WAL file '00000001000000000000002B' +INFO: removing WAL file '00000001000000000000002A' +INFO: removing WAL file '000000010000000000000029' +INFO: removing WAL file '000000010000000000000028' +INFO: removing WAL file '000000010000000000000027' +INFO: removing WAL file '000000010000000000000026' +INFO: removing WAL file '000000010000000000000025' +INFO: removing WAL file '000000010000000000000024' +INFO: removing WAL file '000000010000000000000023' +INFO: removing WAL file '000000010000000000000022' +INFO: removing WAL file '000000010000000000000021' +INFO: removing (unused) WAL file '00000001000000000000000F.00000028' +INFO: removing obsolete backup '1428590536488' +INFO: 3 WAL file(s) will be removed +INFO: removing WAL file '000000010000000000000020' +INFO: removing WAL file '00000001000000000000001F' +INFO: removing WAL file '00000001000000000000001E' +``` + +The `SHOW-BACKUPS` subcommand now displays the remaining backups marked as `active` or `keep`: + +```text +-bash-4.1$ bart SHOW-BACKUPS -s dev +SERVER NAME BACKUP ID BACKUP TIME BACKUP SIZE WAL(s) SIZE +WAL FILES STATUS +dev 1428933278236 2015-04-13 09:54:40 EDT 5.65 MB 16.00 MB +1 active +dev 1428862187757 2015-04-12 14:09:50 EDT 5.65 MB 32.00 MB +2 active +dev 1428768351638 2015-04-11 12:05:54 EDT 5.65 MB 32.00 MB +2 active +dev 1428502171990 2015-04-08 10:09:34 EDT 5.65 MB 80.00 MB +5 keep +``` + +## Managing Incremental Backups + +This section illustrates evaluating, marking, and deleting incremental backups using the `MANAGE` and `DELETE` subcommands utilizing redundancy retention policy and recovery window retention policy. For detailed information about the `MANAGE` and `DELETE` subcommands, as well as the redundancy retention and recovery window retention policy, see the *EDB Backup and Recovery User Guide* available at the [EDB website](/bart/latest/bart_user/). + +- [Using a Redundancy Retention Policy](#redundancy_retention_policy) provides an example of using the `MANAGE` and `DELETE` subcommands when a 3 backup redundancy retention policy is in effect. +- [Using a Recovery Window Retention Policy](#recovery_window_retention_policy) provides an example of using the `MANAGE` and `DELETE` subcommands when a 1-day recovery window retention policy is in effect. + + + +### Using a Redundancy Retention Policy + +The following code sample uses the `MANAGE` and `DELETE` subcommands to evaluate, mark, and delete incremental backups when a 3 backup redundancy retention policy is in effect. The example uses the following server configuration: + +```text +[ACCTG] + +host = 192.168.2.24 +port = 5445 +user = enterprisedb +cluster_owner = enterprisedb +remote_host = enterprisedb@192.168.2.24 +allow_incremental_backups = enabled +retention_policy = 3 BACKUPS +description = "Accounting" +``` + +The example uses the following set of backups. In these code samples, some columns have been omitted from the `SHOW-BACKUPS` output to display the relevant information in a more observable manner. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME ... STATUS +acctg 1481749696905 ... 1481749673603 2016-12-14 16:08:17 EST ... active +acctg 1481749673603 ... 1481749651927 2016-12-14 16:07:53 EST ... active +acctg 1481749651927 ... 1481749619582 2016-12-14 16:07:32 EST ... active +acctg 1481749619582 ... none 2016-12-14 16:07:00 EST ... active +``` + +There is one backup chain. The first backup is the initial full backup. + +Backup chain: `1481749619582 => 1481749651927 => 1481749673603 => 1481749696905` + +The `MANAGE` subcommand is invoked as shown by the following: + +```text +-bash-4.2$ bart MANAGE -s acctg +INFO: processing server 'acctg', backup '1481749619582' +INFO: 2 Unused WAL file(s) present +INFO: 4 Unused file(s) (WALs included) present, use 'MANAGE -l' for the +list +``` + +The following code sample shows the resulting status of the backups: + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME ... STATUS +acctg 1481749696905 ... 1481749673603 2016-12-14 16:08:17 EST ... active +acctg 1481749673603 ... 1481749651927 2016-12-14 16:07:53 EST ... active +acctg 1481749651927 ... 1481749619582 2016-12-14 16:07:32 EST ... active +acctg 1481749619582 ... none 2016-12-14 16:07:00 EST ... active +``` + +The status remains active for all backups. Even though the total number of backups exceeds the 3 backup redundancy retention policy, it is only the total number of full backups that is used to determine if the redundancy retention policy has been exceeded. Additional full backups are added including a second backup chain. The following example shows the resulting list of backups: + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME ... STATUS +acctg 1481750365397 ... none 2016-12-14 16:19:26 EST ... active +acctg 1481750098924 ... 1481749997807 2016-12-14 16:14:59 EST ... active +acctg 1481749997807 ... none 2016-12-14 16:13:18 EST ... active +acctg 1481749992003 ... none 2016-12-14 16:13:12 EST ... active +acctg 1481749696905 ... 1481749673603 2016-12-14 16:08:17 EST ... active +acctg 1481749673603 ... 1481749651927 2016-12-14 16:07:53 EST ... active +acctg 1481749651927 ... 1481749619582 2016-12-14 16:07:32 EST ... active +acctg 1481749619582 ... none 2016-12-14 16:07:00 EST ... active +``` + +Second backup chain: `1481749997807 => 1481750098924` + +The `MANAGE` subcommand is invoked, but now with a total of four active full backups. + +```text +-bash-4.2$ bart MANAGE -s acctg +INFO: processing server 'acctg', backup '1481750365397' +INFO: processing server 'acctg', backup '1481749997807' +INFO: processing server 'acctg', backup '1481749992003' +INFO: processing server 'acctg', backup '1481749619582' +INFO: marking backup '1481749619582' as obsolete +INFO: 3 incremental(s) of backup '1481749619582' will be marked obsolete +INFO: marking incremental backup '1481749696905' as obsolete +INFO: marking incremental backup '1481749673603' as obsolete +INFO: marking incremental backup '1481749651927' as obsolete +INFO: 4 WAL file(s) marked obsolete +INFO: 2 Unused WAL file(s) present +INFO: 4 Unused file(s) (WALs included) present, use 'MANAGE -l' for the +list +``` + +The oldest full backup and its chain of incremental backups are now marked as obsolete. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME ... STATUS +acctg 1481750365397 ... none 2016-12-14 16:19:26 EST ... active +acctg 1481750098924 ... 1481749997807 2016-12-14 16:14:59 EST ... active +acctg 1481749997807 ... none 2016-12-14 16:13:18 EST ... active +acctg 1481749992003 ... none 2016-12-14 16:13:12 EST ... active +acctg 1481749696905 ... 1481749673603 2016-12-14 16:08:17 EST ... obsolete +acctg 1481749673603 ... 1481749651927 2016-12-14 16:07:53 EST ... obsolete +acctg 1481749651927 ... 1481749619582 2016-12-14 16:07:32 EST ... obsolete +acctg 1481749619582 ... none 2016-12-14 16:07:00 EST ... obsolete +``` + +Invoking the `MANAGE` subcommand with the `-d` option deletes the entire obsolete backup chain. + +```text +-bash-4.2$ bart MANAGE -s acctg -d +INFO: removing all obsolete backups of server 'acctg' +INFO: removing obsolete backup '1481749619582' +INFO: 4 WAL file(s) will be removed +INFO: 3 incremental(s) of backup '1481749619582' will be removed +INFO: removing obsolete incremental backup '1481749696905' +INFO: removing obsolete incremental backup '1481749673603' +INFO: removing obsolete incremental backup '1481749651927' +INFO: removing WAL file '000000010000000100000000' +INFO: removing WAL file '0000000100000000000000FF' +INFO: removing WAL file '0000000100000000000000FE' +INFO: removing WAL file '0000000100000000000000FD' +INFO: 16 Unused file(s) will be removed +INFO: removing (unused) file '000000010000000100000004.00000028.backup' +. +. +. +INFO: removing (unused) file +'0000000100000000FB00002800000000FC000000.mbm' +``` + +The following code sample shows the remaining full backups and the second backup chain. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME ... STATUS +acctg 1481750365397 ... none 2016-12-14 16:19:26 EST ... active +acctg 1481750098924 ... 1481749997807 2016-12-14 16:14:59 EST ... active +acctg 1481749997807 ... none 2016-12-14 16:13:18 EST ... active +acctg 1481749992003 ... none 2016-12-14 16:13:12 EST ... active +``` + + + +### Using a Recovery Window Retention Policy + +The following example demonstrates using the `MANAGE` and `DELETE` subcommands to evaluate, mark, and delete incremental backups when a 1-day recovery window retention policy is in effect. The example uses the following server configuration: + +```text +[ACCTG] + +host = 192.168.2.24 +port = 5445 +user = enterprisedb +cluster_owner = enterprisedb +remote_host = enterprisedb@192.168.2.24 +allow_incremental_backups = enabled +retention_policy = 1 DAYS +description = "Accounting" +``` + +The example uses the following set of backups. In the samples, some columns have been omitted from the `SHOW-BACKUPS` output to display the relevant information in a more observable manner. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME ... STATUS +acctg 1481559303348 ... 1481554203288 2016-12-12 11:15:03 EST ... active +acctg 1481559014359 ... 1481554802918 2016-12-12 11:10:14 EST ... active +acctg 1481554802918 ... 1481553914533 2016-12-12 10:00:03 EST ... active +acctg 1481554203288 ... 1481553651165 2016-12-12 09:50:03 EST ... active +acctg 1481553914533 ... 1481553088053 2016-12-12 09:45:14 EST ... active +acctg 1481553651165 ... none 2016-12-12 09:40:51 EST ... active +acctg 1481553088053 ... 1481552078404 2016-12-12 09:31:28 EST ... active +acctg 1481552078404 ... none 2016-12-12 09:14:39 EST ... active +``` + +There are two backup chains. In each of the following chains, the first backup is the initial full backup. + +First backup chain: `1481552078404 => 1481553088053 => 1481553914533 => 1481554802918 => 1481559014359` + +Second backup chain: `1481553651165 => 1481554203288 => 1481559303348` + +The `MANAGE` subcommand is invoked when the first full backup `1481552078404` falls out of the recovery window. When the `MANAGE` subcommand is invoked, it is `2016-12-13 09:20:03 EST`, thus making the start of the 1-day recovery window at `2016-12-12 09:20:03 EST` exactly one day earlier. This backup was taken at `2016-12-12 09:14:39 EST`, which is about 5 ½ minutes before the start of the recovery window, thus making the backup obsolete. + +```text +-bash-4.2$ date +Tue Dec 13 09:20:03 EST 2016 +-bash-4.2$ bart MANAGE -s acctg +INFO: processing server 'acctg', backup '1481553651165' +INFO: processing server 'acctg', backup '1481552078404' +INFO: marking backup '1481552078404' as obsolete +INFO: 4 incremental(s) of backup '1481552078404' will be marked obsolete +INFO: marking incremental backup '1481559014359' as obsolete +INFO: marking incremental backup '1481554802918' as obsolete +INFO: marking incremental backup '1481553914533' as obsolete +INFO: marking incremental backup '1481553088053' as obsolete +INFO: 7 WAL file(s) marked obsolete +INFO: 1 Unused WAL file(s) present +INFO: 2 Unused file(s) (WALs included) present, use 'MANAGE -l' for the list +``` + +The incremental backup date and time are within the recovery window since they were taken after the start of the recovery window of `2016-12-12 09:20:03 EST`, but all backups in the chain are marked as `obsolete`. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg\ +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME +... STATUS +acctg 1481559303348 ... 1481554203288 2016-12-12 11:15:03 EST +... active +acctg 1481559014359 ... 1481554802918 2016-12-12 11:10:14 EST +... obsolete +acctg 1481554802918 ... 1481553914533 2016-12-12 10:00:03 EST +... obsolete +acctg 1481554203288 ... 1481553651165 2016-12-12 09:50:03 EST +... active +acctg 1481553914533 ... 1481553088053 2016-12-12 09:45:14 EST +... obsolete +acctg 1481553651165 ... none 2016-12-12 09:40:51 EST +... active +acctg 1481553088053 ... 1481552078404 2016-12-12 09:31:28 EST +... obsolete +acctg 1481552078404 ... none 2016-12-12 09:14:39 EST +... obsolete +``` + +The following code sample shows how the entire backup chain is changed back to active status by invoking the `MANAGE` subcommand with the `-c nokeep` option on the full backup of the chain. + +```text +-bash-4.2$ bart MANAGE -s acctg -c nokeep -i 1481552078404 +INFO: changing status of backup '1481552078404' of server 'acctg' from +'obsolete' to 'active' +INFO: status of 4 incremental(s) of backup '1481552078404' will be +changed +INFO: changing status of incremental backup '1481559014359' of server +'acctg' from 'obsolete' to 'active' +INFO: changing status of incremental backup '1481554802918' of server +'acctg' from 'obsolete' to 'active' +INFO: changing status of incremental backup '1481553914533' of server +'acctg' from 'obsolete' to 'active' +INFO: changing status of incremental backup '1481553088053' of server +'acctg' from 'obsolete' to 'active' +INFO: 7 WAL file(s) changed +``` + +The backup chain has now been reset to active status. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME ... STATUS +acctg 1481559303348 ... 1481554203288 2016-12-12 11:15:03 EST ... active +acctg 1481559014359 ... 1481554802918 2016-12-12 11:10:14 EST ... active +acctg 1481554802918 ... 1481553914533 2016-12-12 10:00:03 EST ... active +acctg 1481554203288 ... 1481553651165 2016-12-12 09:50:03 EST ... active +acctg 1481553914533 ... 1481553088053 2016-12-12 09:45:14 EST ... active +acctg 1481553651165 ... none 2016-12-12 09:40:51 EST ... active +acctg 1481553088053 ... 1481552078404 2016-12-12 09:31:28 EST ... active +acctg 1481552078404 ... none 2016-12-12 09:14:39 EST ... active +``` + +The following code sample shows usage of the `DELETE` subcommand on an incremental backup. The specified incremental backup `1481554802918` in the first backup chain as well as its successive incremental backup `1481559014359` are deleted. + +```text +-bash-4.2$ bart DELETE -s acctg -i 1481554802918 +INFO: deleting backup '1481554802918' of server 'acctg' +INFO: deleting backup '1481554802918' +INFO: 1 incremental backup(s) will be deleted +INFO: deleting incremental backup '1481559014359' +INFO: WALs of deleted backup(s) will belong to prior backup(if any), or +will be marked unused +INFO: 2 Unused file(s) will be removed +INFO: removing (unused) file '0000000100000000000000BA' +INFO: removing (unused) file +'0000000100000000BA00002800000000BB000000.mbm' +INFO: backup(s) deleted +``` + +The results show that the backups `1481554802918` and `1481559014359` are no longer listed by the `SHOW-BACKUPS` subcommand. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME ... STATUS +acctg 1481559303348 ... 1481554203288 2016-12-12 11:15:03 EST ... active +acctg 1481554203288 ... 1481553651165 2016-12-12 09:50:03 EST ... active +acctg 1481553914533 ... 1481553088053 2016-12-12 09:45:14 EST ... active +acctg 1481553651165 ... none 2016-12-12 09:40:51 EST ... active +acctg 1481553088053 ... 1481552078404 2016-12-12 09:31:28 EST ... active +acctg 1481552078404 ... none 2016-12-12 09:14:39 EST ... active +``` + +The `MANAGE` subcommand is invoked again. This time both backup chains are marked `obsolete` since the full backups of both chains fall out of the start of the recovery window, which is now `2016-12-12 09:55:03 EST`. + +```text +-bash-4.2$ date +Tue Dec 13 09:55:03 EST 2016 +-bash-4.2$ bart MANAGE -s acctg +INFO: processing server 'acctg', backup '1481553651165' +INFO: marking backup '1481553651165' as obsolete +INFO: 2 incremental(s) of backup '1481553651165' will be marked obsolete +INFO: marking incremental backup '1481559303348' as obsolete +INFO: marking incremental backup '1481554203288' as obsolete +INFO: 38 WAL file(s) marked obsolete +INFO: processing server 'acctg', backup '1481552078404' +INFO: marking backup '1481552078404' as obsolete +INFO: 2 incremental(s) of backup '1481552078404' will be marked obsolete +INFO: marking incremental backup '1481553914533' as obsolete +INFO: marking incremental backup '1481553088053' as obsolete +INFO: 7 WAL file(s) marked obsolete +``` + +The following code sample shows both backup chains marked as `obsolete`. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME +... STATUS +acctg 1481559303348 ... 1481554203288 2016-12-12 11:15:03 EST +... obsolete +acctg 1481554203288 ... 1481553651165 2016-12-12 09:50:03 EST +... obsolete +acctg 1481553914533 ... 1481553088053 2016-12-12 09:45:14 EST +... obsolete +acctg 1481553651165 ... none 2016-12-12 09:40:51 EST +... obsolete +acctg 1481553088053 ... 1481552078404 2016-12-12 09:31:28 EST +... obsolete +acctg 1481552078404 ... none 2016-12-12 09:14:39 EST +... obsolete +``` + +The following code sample demonstrates using the `MANAGE` subcommand with the `-c keep` option to keep a backup chain indefinitely. The `MANAGE` subcommand with the `-c keep` option must specify the backup identifier or backup name of the full backup of the chain, and not any incremental backup. + +```text +-bash-4.2$ bart MANAGE -s acctg -c keep -i 1481553651165 +INFO: changing status of backup '1481553651165' of server 'acctg' from +'obsolete' to 'keep' +INFO: status of 2 incremental(s) of backup '1481553651165' will be +changed +INFO: changing status of incremental backup '1481559303348' of server +'acctg' from 'obsolete' to 'keep' +INFO: changing status of incremental backup '1481554203288' of server +'acctg' from 'obsolete' to 'keep' +INFO: 38 WAL file(s) changed +``` + +The full backup `1481553651165` and its successive incremental backups `1481554203288` and `1481559303348` have been changed to `keep` status: + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME +... STATUS +acctg 1481559303348 ... 1481554203288 2016-12-12 11:15:03 EST +... keep +acctg 1481554203288 ... 1481553651165 2016-12-12 09:50:03 EST +... keep +acctg 1481553914533 ... 1481553088053 2016-12-12 09:45:14 EST +... obsolete +acctg 1481553651165 ... none 2016-12-12 09:40:51 EST +... keep +acctg 1481553088053 ... 1481552078404 2016-12-12 09:31:28 EST +... obsolete +acctg 1481552078404 ... none 2016-12-12 09:14:39 EST +... obsolete +``` + +Finally, the `MANAGE` subcommand with the `-d` option is used to delete the `obsolete` backup chain: + +```text +-bash-4.2$ bart MANAGE -s acctg -d +INFO: removing all obsolete backups of server 'acctg' +INFO: removing obsolete backup '1481552078404' +INFO: 7 WAL file(s) will be removed +INFO: 2 incremental(s) of backup '1481552078404' will be removed +INFO: removing obsolete incremental backup '1481553914533' +INFO: removing obsolete incremental backup '1481553088053' +INFO: removing WAL file '0000000100000000000000C1' +INFO: removing WAL file '0000000100000000000000C0' +INFO: removing WAL file '0000000100000000000000BF' +INFO: removing WAL file '0000000100000000000000BE' +INFO: removing WAL file '0000000100000000000000BD' +INFO: removing WAL file '0000000100000000000000BC' +INFO: removing WAL file '0000000100000000000000BB' +INFO: 48 Unused file(s) will be removed +INFO: removing (unused) file '0000000100000000000000FA' +. +. +. +INFO: removing (unused) file '0000000100000000000000BB.00000028.backup' +``` + +Only the backup chain with the `keep` status remains as shown below: + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME +... STATUS +acctg 1481559303348 ... 1481554203288 2016-12-12 11:15:03 EST +... keep +acctg 1481554203288 ... 1481553651165 2016-12-12 09:50:03 EST +... keep +acctg 1481553651165 ... none 2016-12-12 09:40:51 EST +... keep +``` diff --git a/product_docs/docs/bart/2.6.1/bart_ref/03_sample_bart_system_with_local_and_remote_database_servers.mdx b/product_docs/docs/bart/2.6.1/bart_ref/03_sample_bart_system_with_local_and_remote_database_servers.mdx new file mode 100644 index 00000000000..b1527216806 --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_ref/03_sample_bart_system_with_local_and_remote_database_servers.mdx @@ -0,0 +1,1385 @@ +--- +title: "Sample BART System with Local and Remote Database Servers" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/sample_bart_system_with_local_and_remote_database_servers.html" +--- + + + +This section describes a sample BART managed backup and recovery system consisting of both local and remote database servers. The complete steps to configure and operate the system are provided. + +For detailed information about configuring a BART system, see the *EDB Backup and Recovery Installation and Upgrade Guide*. For detailed information about the operational procedures and BART subcommands, see the *EDB Backup and Recovery User Guide*. These guides are available at the [EDB website](/bart/latest/bart_inst/). + +The environment for this sample system is as follows: + +- BART on host `192.168.2.22` running with BART user account `enterprisedb` +- Local Advanced Server on host `192.168.2.22` running with user account `enterprisedb` +- Remote Advanced Server on host `192.168.2.24` running with user account `enterprisedb` +- Remote PostgreSQL server on host `192.168.2.24` running with user account `postgres` + +Passwordless SSH/SCP connections are required between the following: + +- BART on host `192.168.2.22` and the local Advanced Server on the same host `192.168.2.22` +- BART on host `192.168.2.22` and the remote Advanced Server on host `192.168.2.24` +- BART on host `192.168.2.22` and the remote PostgreSQL server on host `192.168.2.24` + +The following sections demonstrate configuring and taking full backups only. To support incremental backups as well, enable the `allow_incremental_backups` parameter for the desired database servers and use the `WAL scanner` program. + +- [The BART Configuration File](#bart_configuration_file) shows the settings used in the BART configuration file. +- [Establishing SSH/SCP Passwordless Connections](#establishing-sshscp-passwordless-connections) provides an example of how to establish an SSH/SCP passwordless connection. +- [Configuring a Replication Database User](#configuring-a-replication-database-user) provides an example of how to configure the replication database user. +- [WAL Archiving Configuration Parameters](#wal-archiving-configuration-parameters) provides an example of how to configure WAL archiving. +- [Creating the BART Backup Catalog](#creating-the-bart-backup-catalog-backup_path) provides information about creating a BART Backup Catalog. +- [Starting the Database Servers with WAL Archiving](#starting-the-database-servers-with-wal-archiving) provides example of starting the database servers with WAL archiving. +- [Taking a Full Backup](#taking-a-full-backup) illustrates taking the first full backup of the database servers. +- [Using Point-In-Time Recovery](#using-point-in-time-recovery) demonstrates the point-in-time recovery operation on the remote PostgreSQL database server. + + + +## The BART Configuration File + +The following code sample shows the settings used in the BART configuration file for the examples that follow: + +```text +[BART] +bart_host= enterprisedb@192.168.2.22 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +retention_policy = 6 BACKUPS +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log + +[ACCTG] +host = 127.0.0.1 +port = 5444 +user = enterprisedb +cluster_owner = enterprisedb +backup_name = acctg_%year-%month-%dayT%hour:%minute +archive_command = 'cp %p %a/%f' +description = "Accounting" + +[MKTG] + +host = 192.168.2.24 +port = 5444 +user = repuser +cluster_owner = enterprisedb +backup_name = mktg_%year-%month-%dayT%hour:%minute +remote_host = enterprisedb@192.168.2.24 +description = "Marketing" + +[HR] + +host = 192.168.2.24 +port = 5432 +user = postgres +cluster_owner = postgres +backup_name = hr_%year-%month-%dayT%hour:%minute +remote_host = postgres@192.168.2.24 +copy_wals_during_restore = enabled +description = "Human Resources" +``` + + + +## Establishing SSH/SCP Passwordless Connections + +This section demonstrates how passwordless SSH/SCP connections are established with the authorized public keys files. + + + +### Generating a Public Key File for the BART User Account + +The BART user account is `enterprisedb` with a home directory of `/opt/PostgresPlus/9.6AS`. + +To generate the public key file, as a root user, first create the `.ssh` subdirectory in the BART user’s home directory and assign ownership of this directory to the `enterprisedb` user, ensuring there are no groups or other users that can access the `.ssh` directory. + +```text +[root@localhost 9.6AS]# pwd +/opt/PostgresPlus/9.6AS +[root@localhost 9.6AS]# mkdir .ssh +[root@localhost 9.6AS]# chown enterprisedb .ssh +[root@localhost 9.6AS]# chgrp enterprisedb .ssh +[root@localhost 9.6AS]# chmod 700 .ssh +[root@localhost 9.6AS]# ls -la | grep ssh +drwx------ 2 enterprisedb enterprisedb 4096 Apr 23 13:02 .ssh +``` + +Generate the public key file: + +```text +[user@localhost ~]$ su - enterprisedb +Password: +-bash-4.1$ pwd +/opt/PostgresPlus/9.6AS +-bash-4.1$ ssh-keygen -t rsa +Generating public/private rsa key pair. +Enter file in which to save the key +(/opt/PostgresPlus/9.6AS/.ssh/id_rsa): +Enter passphrase (empty for no passphrase): +Enter same passphrase again: +Your identification has been saved in +/opt/PostgresPlus/9.6AS/.ssh/id_rsa. +Your public key has been saved in +/opt/PostgresPlus/9.6AS/.ssh/id_rsa.pub. +The key fingerprint is: +de:65:34:d6:b1:d2:32:3c:b0:43:c6:a3:c0:9f:f4:64 +enterprisedb@localhost.localdomain +The key's randomart image is: ++----[ RSA 2048]----+ +| . .+ . | +| o .oE+ o o | +| + * o.X + | +| + .+ * | +| S o | +| . . o | +| . . | +| + | +| | ++-------------------+ +``` + +The following are the resulting files. `id_rsa.pub` is the public key file of BART user account `enterprisedb`. + +```text +-bash-4.1$ ls -l .ssh +total 8 +-rw------- 1 enterprisedb enterprisedb 1675 Apr 23 13:04 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Apr 23 13:04 id_rsa.pub +``` + +### Configuring Access between Local Advanced Server and the BART Host + +Even when the Advanced Server database is on the same host as the BART user account, and the Advanced Server database cluster owner is also the BART user account (`enterprisedb` is this case), a passwordless SSH/SCP connection must be established from the same user account to itself. + +On the BART host where the public key file was just generated (as shown in [Generating a Public Key File for the BART User Account](#generating-a-public-key-file-for-the-bart-user-account)), create the authorized keys file by appending the public key file to any existing authorized keys file. + +Log into the BART host as the BART user account and append the public key file, `id_rsa.pub` onto the `authorized_keys` file in the same `.ssh` directory. + +```text +[user@localhost ~]$ su - enterprisedb +Password: +Last login: Thu Mar 23 10:27:35 EDT 2017 on pts/0 +-bash-4.2$ pwd +/opt/PostgresPlus/9.6AS +-bash-4.2$ ls -l .ssh +total 12 +-rw------- 1 enterprisedb enterprisedb 1675 Mar 23 09:54 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Mar 23 09:54 id_rsa.pub +-rw-r--r-- 1 enterprisedb enterprisedb 345 Mar 23 10:05 known_hosts +-bash-4.2$ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys +-bash-4.2$ ls -l .ssh +total 16 +-rw-rw-r-- 1 enterprisedb enterprisedb 416 Mar 23 10:33 authorized_keys +-rw------- 1 enterprisedb enterprisedb 1675 Mar 23 09:54 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Mar 23 09:54 id_rsa.pub +-rw-r--r-- 1 enterprisedb enterprisedb 345 Mar 23 10:05 known_hosts +``` + +The `authorized_keys` file must have file permission `600` as set by the following `chmod 600` command, or the passwordless connection will fail: + +```text +-bash-4.2$ chmod 600 ~/.ssh/authorized_keys +-bash-4.2$ ls -l .ssh +total 16 +-rw------- 1 enterprisedb enterprisedb 416 Mar 23 10:33 authorized_keys +-rw------- 1 enterprisedb enterprisedb 1675 Mar 23 09:54 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Mar 23 09:54 id_rsa.pub +-rw-r--r-- 1 enterprisedb enterprisedb 345 Mar 23 10:05 known_hosts +``` + +Test the passwordless connection. Use the `ssh` command to verify that you can access the same user account as you are currently logged in as (`enterprisedb`) without being prompted for a password: + +```text +-bash-4.2$ ssh enterprisedb@127.0.0.1 +Last login: Thu Mar 23 10:27:50 2017 +-bash-4.2$ exit +logout +Connection to 127.0.0.1 closed. +``` + +### Configuring Access from Remote Advanced Server to BART Host + +On the remote host `192.168.2.24`, create the public key file for the remote database server user account, `enterprisedb`, for access to the BART user account, `enterprisedb`, on the BART host 192.168.2.22. + +Create the `.ssh` directory for user account `enterprisedb` on the remote host: + +```text +[root@localhost 9.6AS]# pwd +/opt/PostgresPlus/9.6AS +[root@localhost 9.6AS]# mkdir .ssh +[root@localhost 9.6AS]# chown enterprisedb .ssh +[root@localhost 9.6AS]# chgrp enterprisedb .ssh +[root@localhost 9.6AS]# chmod 700 .ssh +[root@localhost 9.6AS]# ls -la | grep ssh +drwx------ 2 enterprisedb enterprisedb 4096 Apr 23 13:08 .ssh +``` + +Generate the public key file on the remote host for user account `enterprisedb`: + +```text +[user@localhost ~]$ su - enterprisedb +Password: +-bash-4.1$ ssh-keygen -t rsa +Generating public/private rsa key pair. +Enter file in which to save the key +(/opt/PostgresPlus/9.6AS/.ssh/id_rsa): +Enter passphrase (empty for no passphrase): +Enter same passphrase again: +Your identification has been saved in +/opt/PostgresPlus/9.6AS/.ssh/id_rsa. +Your public key has been saved in +/opt/PostgresPlus/9.6AS/.ssh/id_rsa.pub. +The key fingerprint is: +15:27:1e:1e:61:4b:48:66:67:0b:b2:be:fc:ea:ea:e6 +enterprisedb@localhost.localdomain +The key's randomart image is: ++--[ RSA 2048]---+ +| ..=.@.. | +| =.O O | +| . * | +| . . | +| . S | +| . . | +| o | +| . . | +| +Eoo.. | ++----------------+ +``` + +Copy the generated public key file, `id_rsa.pub`, to the BART user account, `enterprisedb`, on the BART host, `192.168.2.22`: + +```text +-bash-4.1$ scp ~/.ssh/id_rsa.pub enterprisedb@192.168.2.22:/tmp/tmp.pub +The authenticity of host '192.168.2.22 (192.168.2.22)' can't be +established. +RSA key fingerprint is b8:a9:97:31:79:16:b8:2b:b0:60:5a:91:38:d7:68:22. +Are you sure you want to continue connecting (yes/no)? yes +Warning: Permanently added '192.168.2.22' (RSA) to the list of known hosts. +enterprisedb@192.168.2.22's password: +id_rsa.pub +``` + +Log into the BART host as the BART user account and append the temporary public key file, `/tmp/tmp.pub` onto the `authorized_keys` file owned by the BART user account. + +```text +-bash-4.1$ ssh enterprisedb@192.168.2.22 +enterprisedb@192.168.2.22's password: +Last login: Tue Apr 21 17:03:24 2015 from 192.168.2.22 +-bash-4.1$ pwd +/opt/PostgresPlus/9.6AS +-bash-4.1$ cat /tmp/tmp.pub >> ~/.ssh/authorized_keys +-bash-4.1$ ls -l .ssh +total 12 +-rw-rw-r-- 1 enterprisedb enterprisedb 416 Apr 23 13:15 authorized_keys +-rw------- 1 enterprisedb enterprisedb 1675 Apr 23 13:04 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Apr 23 13:04 id_rsa.pub +``` + +The `authorized_keys` file must have file permission `600` as set by the following `chmod 600` command, otherwise the passwordless connection fails: + +```text +-bash-4.1$ chmod 600 ~/.ssh/authorized_keys +-bash-4.1$ ls -l .ssh +total 12 +-rw------- 1 enterprisedb enterprisedb 416 Apr 23 13:15 authorized_keys +-rw------- 1 enterprisedb enterprisedb 1675 Apr 23 13:04 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Apr 23 13:04 id_rsa.pub +-bash-4.1$ rm /tmp/tmp.pub +-bash-4.1$ exit +logout +Connection to 192.168.2.22 closed. +``` + +Test the passwordless connection. From the remote host, verify that you can log into the BART host with the BART user account without being prompted for a password: + +```text +-bash-4.1$ ssh enterprisedb@192.168.2.22 +Last login: Thu Apr 23 13:14:48 2015 from 192.168.2.24 +-bash-4.1$ exit +logout +Connection to 192.168.2.22 closed. +``` + +### Configuring Access from the BART Host to a Remote Advanced Server + +On the BART host `192.168.2.22`, copy the public key file for the BART user account, `enterprisedb`, for access to the remote database server user account, `enterprisedb`, on the remote host `192.168.2.24`. + +The following lists the current SSH keys files in the BART user’s `.ssh` directory on the BART host: + +```text +[user@localhost ~]$ su - enterprisedb +Password: +-bash-4.1$ pwd +/opt/PostgresPlus/9.6AS +-bash-4.1$ ls -l .ssh +total 12 +-rw------- 1 enterprisedb enterprisedb 416 Apr 23 13:15 authorized_keys +-rw------- 1 enterprisedb enterprisedb 1675 Apr 23 13:04 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Apr 23 13:04 id_rsa.pub +``` + +The public key file, `id_rsa.pub`, for BART user account `enterprisedb` on the BART host that was earlier generated in [Generating a Public Key File for the BART User Account](#generating-a-public-key-file-for-the-bart-user-account), is now copied to the remote Advanced Server host on `192.168.2.24`: + +```text +-bash-4.1$ scp ~/.ssh/id_rsa.pub enterprisedb@192.168.2.24:/tmp/tmp.pub +The authenticity of host '192.168.2.24 (192.168.2.24)' can't be +established. +RSA key fingerprint is 59:41:fb:0c:ae:64:3d:3f:a2:d9:90:95:cf:2c:99:f2. +Are you sure you want to continue connecting (yes/no)? yes +Warning: Permanently added '192.168.2.24' (RSA) to the list of known +hosts. +enterprisedb@192.168.2.24's password: +id_rsa.pub +``` + +Log into the `enterprisedb` user account on the remote host and copy the public key file onto the `authorized_keys` file of the remote `enterprisedb` user account under its `.ssh` directory: + +```text +-bash-4.1$ ssh enterprisedb@192.168.2.24 +enterprisedb@192.168.2.24's password: +Last login: Tue Apr 21 09:53:18 2015 from 192.168.2.22 +-bash-4.1$ pwd +/opt/PostgresPlus/9.6AS +-bash-4.1$ ls -l .ssh +total 12 +-rw------- 1 enterprisedb enterprisedb 1675 Apr 23 13:11 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Apr 23 13:11 id_rsa.pub +-rw-r--r-- 1 enterprisedb enterprisedb 394 Apr 23 13:12 known_hosts +-bash-4.1$ cat /tmp/tmp.pub >> ~/.ssh/authorized_keys +``` + +Adjust the file permission on `authorized_keys`: + +```text +-bash-4.1$ chmod 600 ~/.ssh/authorized_keys +-bash-4.1$ ls -l .ssh +total 16 +-rw------- 1 enterprisedb enterprisedb 416 Apr 23 13:26 authorized_keys +-rw------- 1 enterprisedb enterprisedb 1675 Apr 23 13:11 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Apr 23 13:11 id_rsa.pub +-rw-r--r-- 1 enterprisedb enterprisedb 394 Apr 23 13:12 known_hosts +-bash-4.1$ rm /tmp/tmp.pub +-bash-4.1$ exit +logout +Connection to 192.168.2.24 closed. +``` + +While logged into the BART host, test the passwordless connection from the BART host to the remote Advanced Server host: + +```text +-bash-4.1$ ssh enterprisedb@192.168.2.24 +Last login: Thu Apr 23 13:25:53 2015 from 192.168.2.22 +-bash-4.1$ exit +logout +Connection to 192.168.2.24 closed. +``` + +### Configuring Access from a Remote PostgreSQL Server to a BART Host + +On the remote host (192.168.2.24), create a public key file owned by the database server user account (`postgres`), allowing access to the BART user account (`enterprisedb`) on the BART host (192.168.2.22). + +Create the `.ssh` directory for the `postgres` user account on the remote host: + +```text +[root@localhost 9.6]# cd /opt/PostgreSQL/9.6 +[root@localhost 9.6]# mkdir .ssh +[root@localhost 9.6]# chown postgres .ssh +[root@localhost 9.6]# chgrp postgres .ssh +[root@localhost 9.6]# chmod 700 .ssh +[root@localhost 9.6]# ls -la | grep ssh +drwx------ 2 postgres postgres 4096 Apr 23 13:32 .ssh +``` + +Create and copy the generated public key file, `id_rsa.pub`, to the BART user account (`enterprisedb`), on the BART host (`192.168.2.22`): + +```text +[user@localhost ~]$ su - postgres +Password: +-bash-4.1$ pwd +/opt/PostgreSQL/9.6 +-bash-4.1$ ssh-keygen -t rsa +Generating public/private rsa key pair. +Enter file in which to save the key (/opt/PostgreSQL/9.6/.ssh/id_rsa): +Enter passphrase (empty for no passphrase): +Enter same passphrase again: +Your identification has been saved in /opt/PostgreSQL/9.6/.ssh/id_rsa. +Your public key has been saved in /opt/PostgreSQL/9.6/.ssh/id_rsa.pub. +The key fingerprint is: +1f:f8:76:d6:fc:a5:1a:c5:5a:66:66:01:d0:a0:ca:ba +postgres@localhost.localdomain +The key's randomart image is: ++--[ RSA 2048]----+ +| o+. | +| . .. | +| . . | +| . . . . . | +| o S . O | +| . o . @ | +| . + = o .| +| . . o . o.| +| E ... .| ++-----------------+ +-bash-4.1$ ls -l .ssh +total 8 +-rw------- 1 postgres postgres 1671 Apr 23 13:36 id_rsa +-rw-r--r-- 1 postgres postgres 412 Apr 23 13:36 id_rsa.pub +-bash-4.1$ scp ~/.ssh/id_rsa.pub enterprisedb@192.168.2.22:/tmp/tmp.pub +The authenticity of host '192.168.2.22 (192.168.2.22)' can't be +established. +RSA key fingerprint is b8:a9:97:31:79:16:b8:2b:b0:60:5a:91:38:d7:68:22. +Are you sure you want to continue connecting (yes/no)? yes +Warning: Permanently added '192.168.2.22' (RSA) to the list of known +hosts. +enterprisedb@192.168.2.22's password: +id_rsa.pub +``` + +Log into the BART host as the BART user account and append the temporary public key file, `/tmp/tmp.pub`, onto the `authorized_keys` file owned by the BART user account. + +```text +-bash-4.1$ ssh enterprisedb@192.168.2.22 +enterprisedb@192.168.2.22's password: +Last login: Thu Apr 23 13:19:25 2015 from 192.168.2.24 +-bash-4.1$ pwd +/opt/PostgresPlus/9.6AS +-bash-4.1$ cat /tmp/tmp.pub >> ~/.ssh/authorized_keys +-bash-4.1$ ls -l .ssh +total 16 +-rw------- 1 enterprisedb enterprisedb 828 Apr 23 13:40 authorized_keys +-rw------- 1 enterprisedb enterprisedb 1675 Apr 23 13:04 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Apr 23 13:04 id_rsa.pub +-rw-r--r-- 1 enterprisedb enterprisedb 394 Apr 23 13:24 known_hosts +-bash-4.1$ rm /tmp/tmp.pub +-bash-4.1$ exit +logout +Connection to 192.168.2.22 closed. +``` + +Make sure the `authorized_keys` file has file permission 600 as shown, or the passwordless connection will fail. Test the passwordless connection; from the remote host, while logged in as user account `postgres`, verify that you can log into the BART host with the BART user account without being prompted for a password: + +```text +-bash-4.1$ pwd +/opt/PostgreSQL/9.6 +-bash-4.1$ ssh enterprisedb@192.168.2.22 +Last login: Thu Apr 23 13:40:10 2015 from 192.168.2.24 +-bash-4.1$ exit +logout +Connection to 192.168.2.22 closed. +``` + +### Configuring Access from the BART Host to Remote PostgreSQL + +Copy the public key file on the BART host that is owned by the BART user account (`enterprisedb`) to the remote database server user account (`postgres`), on the remote host (192.168.2.24). + +The following lists the current SSH keys files in the BART user’s `.ssh` directory on the BART host: + +```text +[user@localhost ~]$ su - enterprisedb +Password: +-bash-4.1$ ls -l .ssh +total 16 +-rw------- 1 enterprisedb enterprisedb 828 Apr 23 13:40 authorized_keys +-rw------- 1 enterprisedb enterprisedb 1675 Apr 23 13:04 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Apr 23 13:04 id_rsa.pub +-rw-r--r-- 1 enterprisedb enterprisedb 394 Apr 23 13:24 known_hosts +``` + +The public key file, `id_rsa.pub`, for BART user account `enterprisedb` on the BART host that was earlier generated in [Generating a Public Key File for the BART User Account](#generating-a-public-key-file-for-the-bart-user-account), now resides on the remote PostgreSQL host: + +```text +-bash-4.1$ scp ~/.ssh/id_rsa.pub postgres@192.168.2.24:/tmp/tmp.pub +postgres@192.168.2.24's password: +id_rsa.pub +``` + +Log into the `postgres` user account on the remote host and copy the public key file onto the `authorized_keys` file of `postgres` under its `.ssh` directory: + +```text +-bash-4.1$ ssh postgres@192.168.2.24 +postgres@192.168.2.24's password: +Last login: Mon Jan 26 18:08:36 2015 from 192.168.2.19 +-bash-4.1$ pwd +/opt/PostgreSQL/9.6 +-bash-4.1$ cat /tmp/tmp.pub >> ~/.ssh/authorized_keys +``` + +Adjust the file permissions on `authorized_keys`: + +```text +-bash-4.1$ ls -l .ssh +total 16 +-rw-rw-r-- 1 postgres postgres 416 Apr 23 13:52 authorized_keys +-rw------- 1 postgres postgres 1671 Apr 23 13:36 id_rsa +-rw-r--r-- 1 postgres postgres 412 Apr 23 13:36 id_rsa.pub +-rw-r--r-- 1 postgres postgres 394 Apr 23 13:36 known_hosts +-bash-4.1$ chmod 600 ~/.ssh/authorized_keys +-bash-4.1$ ls -l .ssh +total 16 +-rw------- 1 postgres postgres 416 Apr 23 13:52 authorized_keys +-rw------- 1 postgres postgres 1671 Apr 23 13:36 id_rsa +-rw-r--r-- 1 postgres postgres 412 Apr 23 13:36 id_rsa.pub +-rw-r--r-- 1 postgres postgres 394 Apr 23 13:36 known_hosts +-bash-4.1$ rm /tmp/tmp.pub +-bash-4.1$ exit +logout +Connection to 192.168.2.24 closed. +``` + +Test the passwordless connection from the BART host to the remote PostgreSQL host: + +```text +[user@localhost ~]$ su - enterprisedb +Password: +-bash-4.1$ ssh postgres@192.168.2.24 +Last login: Thu Apr 23 13:52:25 2015 from 192.168.2.22 +-bash-4.1$ exit +logout +Connection to 192.168.2.24 closed. +``` + + + +## Configuring a Replication Database User + +This section demonstrates how a replication database user is established. + +**All database servers must use a superuser as the replication database user.** + +The replication database user for each database server is specified by the `user` parameter in the BART configuration file as shown by the following: + +```text +[ACCTG] + +host = 127.0.0.1 +port = 5444 +user = enterprisedb <=== Replication Database User +cluster_owner = enterprisedb +backup_name = acctg_%year-%month-%dayT%hour:%minute +archive_command = 'cp %p %a/%f' +description = "Accounting" + +[MKTG] +host = 192.168.2.24 +port = 5444 +user = repuser <=== Replication Database User +cluster_owner = enterprisedb +backup_name = mktg_%year-%month-%dayT%hour:%minute +remote_host = enterprisedb@192.168.2.24 +description = "Marketing" + +[HR] + +host = 192.168.2.24 +port = 5432 +user = postgres <=== Replication Database User +cluster_owner = enterprisedb +backup_name = hr_%year-%month-%dayT%hour:%minute +remote_host = postgres@192.168.2.24 +copy_wals_during_restore = enabled +description = "Human Resources" +``` + +Add entries to the `.pgpass` file on each server to allow the BART user account to initiate a backup without being prompted for credentials. The `.pgpass` file is located in `/opt/PostgresPlus/9.6AS/.pgpass`: + +```text +127.0.0.1:5444:*:enterprisedb:password +192.168.2.24:5444:*:repuser:password +192.168.2.24:5432:*:postgres:password +``` + +For more information about using a `.pgpass` file, please see the [PostgreSQL documentation](https://www.postgresql.org/docs/current/libpq-pgpass.html). + +While connected to `MKTG` on 192.168.2.24, execute the following `CREATE ROLE` command to create the replication database superuser: + +```text +CREATE ROLE repuser WITH LOGIN SUPERUSER PASSWORD 'password'; +``` + +Access is granted in the `pg_hba.conf` file for the local Advanced Server: + +```text +# TYPE DATABASE USER ADDRESS METHOD +# "local" is for Unix domain socket connections only +local all all md5 +# IPv4 local connections: +host template1 enterprisedb 127.0.0.1/32 md5 +host edb enterprisedb 127.0.0.1/32 md5 +#host all all 127.0.0.1/32 md5 +# IPv6 local connections: +host all all ::1/128 md5 +# Allow replication connections from localhost, by a user with the +# replication privilege. +#local replication enterprisedb md5 +host replication enterprisedb 127.0.0.1/32 md5 +``` + +Similarly, access is granted in the `pg_hba.conf` file for the remote Advanced Server installation: + +```text +# TYPE DATABASE USER ADDRESS METHOD +# "local" is for Unix domain socket connections only +local all all md5 +# IPv4 local connections: +host template1 repuser 192.168.2.22/32 md5 +host all enterprisedb 127.0.0.1/32 md5 +#host all all 127.0.0.1/32 md5 +# IPv6 local connections: +host all all ::1/128 md5 +# Allow replication connections from localhost, by a user with the +# replication privilege. +#local replication enterprisedb md5 +host replication repuser 192.168.2.22/32 md5 +``` + +Access is also granted in the `pg_hba.conf` file for the remote PostgreSQL server: + +```text +# TYPE DATABASE USER ADDRESS METHOD +# "local" is for Unix domain socket connections only +local all all md5 +# IPv4 local connections: +host template1 postgres 192.168.2.22/32 md5 +host all all 127.0.0.1/32 md5 +# IPv6 local connections: +host all all ::1/128 md5 +# Allow replication connections from localhost, by a user with the +q# replication privilege. +#local replication postgres md5 +host replication postgres 192.168.2.22/32 md5 +``` + + + +## WAL Archiving Configuration Parameters + +Use the following parameters in the `postgresql.conf` file to enable WAL archiving. The `postgresql.conf` file for the local Advanced Server database (`ACCTG`) is set as follows: + +```text +wal_level = archive +archive_mode = on # allows archiving to be done + # (change requires restart) +#archive_command = '' # command to use to archive + a logfile segment + # placeholders: %p = path of + file to archive + # %f = file name only +max_wal_senders = 3 +``` + +When the `INIT` subcommand is invoked, the Postgres `archive_command` configuration parameter in the `postgresql.auto.conf` file will be set based on the BART `archive_command` parameter located in the BART configuration file. + +!!! Note + If the Postgres `archive_command` is already set, invoke the `INIT` subcommand with the `-- no-configure` option to prevent the `archive_command` from being reset. For details, see [INIT](../bart_user/03_using_bart/03_basic_bart_subcommand_usage/02_init/#init). + +```text +[BART] +bart_host= enterprisedb@192.168.2.22 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +retention_policy = 6 BACKUPS +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log + +[ACCTG] +host = 127.0.0.1 +port = 5444 +user = enterprisedb +cluster_owner = enterprisedb +backup_name = acctg_%year-%month-%dayT%hour:%minute +archive_command = 'cp %p %a/%f' +description = "Accounting" +``` + +When the `INIT` subcommand is invoked, the `postgresql.auto.conf` file contains the following: + +```text +# Do not edit this file manually! +# It will be overwritten by ALTER SYSTEM command. +archive_command = 'cp %p /opt/backup/acctg/archived_wals/%f' +``` + +The `archive_command` uses the `cp` command instead of `scp` since the BART backup catalog is local to this database cluster and the BART user account (the account that owns the backup catalog, `enterprisedb`), is the same user account running Advanced Server. The result is that there is no directory permission conflict during the archive operation. + +The `postgresql.conf` file for the remote Advanced Server, `MKTG` is set as follows: + +```text +wal_level = archive +archive_mode = on # allows archiving to be done + # (change requires restart) +archive_command = '' # command to use to archive a + logfile segment + # placeholders: %p = path of + file to archive + # %f = file name only +max_wal_senders = 3 +``` + +When the `INIT` subcommand is invoked, the Postgres `archive_command` configuration parameter in the `postgresql.auto.conf` file will be set by the default BART format of the BART `archive_command` parameter (since it is not explicitly set for this database server in the BART configuration file). + +```text +[BART] +bart_host= enterprisedb@192.168.2.22 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +retention_policy = 6 BACKUPS +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log +. +. +. +[MKTG] + +host = 192.168.2.24 +port = 5444 +user = repuser +cluster_owner = enterprisedb +backup_name = mktg_%year-%month-%dayT%hour:%minute +remote_host = enterprisedb@192.168.2.24 +description = "Marketing" +``` + +The default BART `archive_command` format is: + +```text +archive_command = 'scp %p %h:%a/%f' +``` + +The `postgresql.auto.conf` file contains the following after the `INIT` subcommand is invoked: + +```text +# Do not edit this file manually! +# It will be overwritten by ALTER SYSTEM command. +archive_command = 'scp %p +enterprisedb@192.168.2.22:/opt/backup/hr/archived_wals/%f' +``` + +The `archive_command` uses the `scp` command since the BART backup catalog is remote relative to this database cluster. The BART user account, `enterprisedb`, is specified on the `scp` command since this is the user account owning the BART backup catalog where the archived WAL files are to be copied. The result is that there is no directory permission conflict during the archive operation. + +The `postgresql.conf` file for the remote PostgreSQL server (`HR`) is set as follows: + +```text +wal_level = archive +archive_mode = on # allows archiving to be done + # (change requires restart) +#archive_command = '' # command to use to archive a + logfile segment + # placeholders: %p = path of + file to archive + # %f = file name only +max_wal_senders = 3 +``` + +When the `INIT` subcommand is invoked, the Postgres `archive_command` configuration parameter in the `postgresql.auto.conf` file will be set by the default BART format of the BART `archive_command` parameter (since it is not explicitly set for this database server in the BART configuration file): + +```text +[BART] + +bart_host= enterprisedb@192.168.2.22 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +retention_policy = 6 BACKUPS +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log +. +. +. +[HR] + +host = 192.168.2.24 +port = 5432 +user = postgres +cluster_owner = postgres +backup_name = hr_%year-%month-%dayT%hour:%minute +remote_host = postgres@192.168.2.24 +copy_wals_during_restore = enabled +description = "Human Resources" +``` + +The default BART `archive_command` format is: + +```text +archive_command = 'scp %p %h:%a/%f' +``` + +The `postgresql.auto.conf` file contains the following after the `INIT` subcommand is invoked: + +```text +# Do not edit this file manually! +# It will be overwritten by ALTER SYSTEM command. +archive_command = 'scp %p +enterprisedb@192.168.2.22:/opt/backup/hr/archived_wals/%f' +``` + +The `archive_command` uses the `scp` command since the BART backup catalog is remote relative to this database cluster. The BART user account, `enterprisedb`, is specified on the `scp` command since this is the user account owning the BART backup catalog where the archived WAL files are to be copied. The result is that there is no directory permission conflict during the archive operation. + + + +## Creating the BART Backup Catalog (backup_path) + +Create the directory specified by the `backup_path` configuration parameter. + +```text +[BART] + +bart_host= enterprisedb@192.168.2.22 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +retention_policy = 6 BACKUPS +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log +``` + +Ensure that the directory is owned by the BART user account: + +```text +[root@localhost opt]# pwd +/opt +[root@localhost opt]# mkdir backup +[root@localhost opt]# chown enterprisedb backup +[root@localhost opt]# chgrp enterprisedb backup +[root@localhost opt]# chmod 700 backup +[root@localhost opt]# ls -l | grep backup +drwx------ 2 enterprisedb enterprisedb 4096 Apr 23 15:36 backup +``` + +Use the BART `INIT` subcommand to complete the directory structure and set the Postgres `archive_command` configuration parameter. + +Before invoking any BART subcommands, set up a profile under the BART user account’s home directory to set the `LD_LIBRARY_PATH` and `PATH` environment variables. For more information regarding setting this variable, see the EDB Backup and Recovery Installation and Upgrade Guide available at the [EDB website](/bart/latest/bart_inst/). + +The `-o` option is specified with the `INIT` subcommand to force the setting of the Postgres `archive_command` configuration parameter when `archive_mode` is `off` or if the Postgres `archive_command` parameter is already set and needs to be overridden. + +```text +[user@localhost ~]$ su - enterprisedb +Password: +-bash-4.1$ bart INIT -o +INFO: setting archive_command for server 'acctg' +WARNING: archive_command is set. server restart is required +INFO: setting archive_command for server 'hr' +WARNING: archive_command is set. server restart is required +INFO: setting archive_command for server 'mktg' +WARNING: archive_command is set. server restart is required +``` + +The BART `SHOW-SERVERS` subcommand displays the following: + +```text +-bash-4.1$ bart SHOW-SERVERS +SERVER NAME : acctg +BACKUP FRIENDLY NAME: acctg_%year-%month-%dayT%hour:%minute +HOST NAME : 127.0.0.1 +USER NAME : enterprisedb +PORT : 5444 +REMOTE HOST : +RETENTION POLICY : 6 Backups +DISK UTILIZATION : 0.00 bytes +NUMBER OF ARCHIVES : 0 +ARCHIVE PATH : /opt/backup/acctg/archived_wals +ARCHIVE COMMAND : (disabled) +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +INCREMENTAL BACKUP : DISABLED +DESCRIPTION : "Accounting" +SERVER NAME : hr +BACKUP FRIENDLY NAME: hr_%year-%month-%dayT%hour:%minute +HOST NAME : 192.168.2.24 +USER NAME : postgres +PORT : 5432 +REMOTE HOST : postgres@192.168.2.24 +RETENTION POLICY : 6 Backups +DISK UTILIZATION : 0.00 bytes +NUMBER OF ARCHIVES : 0 +ARCHIVE PATH : /opt/backup/hr/archived_wals +ARCHIVE COMMAND : (disabled) +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +INCREMENTAL BACKUP : DISABLED +DESCRIPTION : "Human Resources" +SERVER NAME : mktg +BACKUP FRIENDLY NAME: mktg_%year-%month-%dayT%hour:%minute +HOST NAME : 192.168.2.24 +USER NAME : repuser +PORT : 5444 +REMOTE HOST : enterprisedb@192.168.2.24 +RETENTION POLICY : 6 Backups +DISK UTILIZATION : 0.00 bytes +NUMBER OF ARCHIVES : 0 +ARCHIVE PATH : /opt/backup/mktg/archived_wals +ARCHIVE COMMAND : (disabled) +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +INCREMENTAL BACKUP : DISABLED +DESCRIPTION : "Marketing" +-bash-4.1$ cd /opt/backup +-bash-4.1$ pwd +/opt/backup +-bash-4.1$ ls -l +total 12 +drwxrwxr-x 3 enterprisedb enterprisedb 4096 Mar 29 13:16 acctg +drwxrwxr-x 3 enterprisedb enterprisedb 4096 Mar 29 13:16 hr +drwxrwxr-x 3 enterprisedb enterprisedb 4096 Mar 29 13:16 mktg +-bash-4.1$ ls -l acctg +total 4 +drwxrwxr-x 2 enterprisedb enterprisedb 4096 Mar 29 13:16 archived_wals +-bash-4.1$ ls -l hr +total 4 +drwxrwxr-x 2 enterprisedb enterprisedb 4096 Mar 29 13:16 archived_wals +-bash-4.1$ ls -l mktg +total 4 +drwxrwxr-x 2 enterprisedb enterprisedb 4096 Mar 29 13:16 archived_wals +``` + +The `ARCHIVE PATH` field displays the full directory path to where the WAL files are copied. This directory path must match the directory path specified in the Postgres `archive_command` parameter of the `postgresql.conf` file or the `postgresql.auto.conf` file of each database server. + + + +### Starting the Database Servers with WAL Archiving + +After the BART backup catalog directory structure has been configured, start the archiving of WAL files from the database servers by restarting each database server. + +On BART host 192.168.2.22: + +```text +[root@localhost data]# service ppas-9.6 restart +``` + +On remote host 192.168.2.24: + +```text +[root@localhost data]# service ppas-9.6 restart + +[root@localhost data]# service postgresql-9.6 restart +``` + +In the BART backup catalog, verify that the WAL files are archiving. + +Archived WAL files may not appear very frequently depending upon how often WAL archiving is set to switch to a new segment file with the `archive_timeout` parameter in your database server configuration settings. + +Verify that there are no archiving-related errors in the database server log files. + +## Taking a Full Backup + +The following code sample shows the first full backup of the database servers. + +```text +-bash-4.1$ bart BACKUP -s acctg -z +INFO: creating backup for server 'acctg' +INFO: backup identifier: '1490809695281' +60776/60776 kB (100%), 1/1 tablespace + +INFO: backup completed successfully +INFO: backup checksum: 37f3defb98ca88dcf05079815555dfc2 of base.tar.gz +INFO: +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1490809695281 +BACKUP NAME: acctg_2017-03-29T13:48 +BACKUP PARENT: none +BACKUP LOCATION: /opt/backup/acctg/1490809695281 +BACKUP SIZE: 6.10 MB +BACKUP FORMAT: tar.gz +BACKUP TIMEZONE: US/Eastern +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 1 +ChkSum File +37f3defb98ca88dcf05079815555dfc2 base.tar.gz + +TABLESPACE(s): 0 +START WAL LOCATION: 000000010000000000000004 +STOP WAL LOCATION: 000000010000000000000004 +BACKUP METHOD: streamed +BACKUP FROM: primary +START TIME: 2017-03-29 13:48:15 EDT +STOP TIME: 2017-03-29 13:48:17 EDT +TOTAL DURATION: 2 sec(s) + +-bash-4.1$ bart BACKUP -s mktg -z +INFO: creating backup for server 'mktg' +INFO: backup identifier: '1490809751193' +61016/61016 kB (100%), 1/1 tablespace + +INFO: backup completed successfully +INFO: backup checksum: 8b010e130a105e76d01346bb56dfcf14 of base.tar.gz +INFO: +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1490809751193 +BACKUP NAME: mktg_2017-03-29T13:49 +BACKUP PARENT: none +BACKUP LOCATION: /opt/backup/mktg/1490809751193 +BACKUP SIZE: 6.13 MB +BACKUP FORMAT: tar.gz +BACKUP TIMEZONE: US/Eastern +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 1 +ChkSum File +8b010e130a105e76d01346bb56dfcf14 base.tar.gz + +TABLESPACE(s): 0 +START WAL LOCATION: 000000010000000100000085 +BACKUP METHOD: streamed +BACKUP FROM: primary +START TIME: 2017-03-29 13:49:11 EDT +STOP TIME: 2017-03-29 13:49:14 EDT +TOTAL DURATION: 3 sec(s) + +-bash-4.1$ bart BACKUP -s hr -z +INFO: creating backup for server 'hr' +INFO: backup identifier: '1490809824946' +38991/38991 kB (100%), 1/1 tablespace +INFO: backup completed successfully +INFO: backup checksum: 277e8a1a80ba3474f541eb316a417c9a of base.tar.gz +INFO: +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1490809824946 +BACKUP NAME: hr_2017-03-29T13:50 +BACKUP PARENT: none +BACKUP LOCATION: /opt/backup/hr/1490809824946 +BACKUP SIZE: 2.59 MB +BACKUP FORMAT: tar.gz +BACKUP TIMEZONE: US/Eastern +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 1 +ChkSum File +277e8a1a80ba3474f541eb316a417c9a base.tar.gz + +TABLESPACE(s): 0 +START WAL LOCATION: 000000010000000000000002 +BACKUP METHOD: streamed +BACKUP FROM: primary +START TIME: 2017-03-29 13:50:25 EDT +STOP TIME: 2017-03-29 13:50:26 EDT +TOTAL DURATION: 1 sec(s) +``` + +The following code sample shows the backup directories created for each backup of each database server. The backup ID is used as the backup directory name. + +```text +-bash-4.1$ cd /opt/backup +-bash-4.1$ ls -l +total 12 +drwxrwxr-x 4 enterprisedb enterprisedb 4096 Mar 29 13:48 acctg +drwxrwxr-x 4 enterprisedb enterprisedb 4096 Mar 29 13:50 hr +drwxrwxr-x 4 enterprisedb enterprisedb 4096 Mar 29 13:49 mktg +-bash-4.1$ ls -l acctg +total 8 +drwx------ 2 enterprisedb enterprisedb 4096 Mar 29 13:48 1490809695281 +drwxrwxr-x 2 enterprisedb enterprisedb 4096 Mar 29 13:48 archived_wals +-bash-4.1$ ls -l hr +total 8 +drwx------ 2 enterprisedb enterprisedb 4096 Mar 29 13:50 1490809824946 +drwxrwxr-x 2 enterprisedb enterprisedb 4096 Mar 29 13:50 archived_wals +-bash-4.1$ ls -l mktg +total 8 +drwx------ 2 enterprisedb enterprisedb 4096 Mar 29 13:49 1490809751193 +drwxrwxr-x 2 enterprisedb enterprisedb 4096 Mar 29 13:49 archived_wals +``` + + + +## Using Point-In-Time Recovery + +This section demonstrates using the point-in-time recovery operation on the remote PostgreSQL database server. + +The following tables were created about two minutes apart with WAL archiving enabled: + +```text +postgres=# \dt + + List of relations +Schema | Name | Type | Owner + +--------+----------------+---------+--------- +public | hr_rmt_t1_1356 | table | postgres +public | hr_rmt_t1_1358 | table | postgres +public | hr_rmt_t1_1400 | table | postgres +public | hr_rmt_t1_1402 | table | postgres +public | hr_rmt_t1_1404 | table | postgres +public | hr_rmt_t1_1406 | table | postgres +(6 rows) +``` + +In the table name `hr_rmt_t_, n` represents the active timeline. `` is the approximate time the table was created. For example, `hr_rmt_t1_1356` was created at approximately 1:56 PM while timeline #1 is active. + +The PostgreSQL database server was then stopped. WAL files that have been created, but not yet archived must be identified, and then saved. The following archived WAL files are in the BART backup catalog: + +```text +-bash-4.1$ ls -l hr/archived_wals +total 49156 +-rw------- 1 enterprisedb enterprisedb 16777216 Mar 29 13:50 +000000010000000000000001 +-rw------- 1 enterprisedb enterprisedb 16777216 Mar 29 13:50 +000000010000000000000002 +-rw------- 1 enterprisedb enterprisedb 302 Mar 29 13:50 +000000010000000000000002.00000028.backup +-rw------- 1 enterprisedb enterprisedb 16777216 Mar 29 14:07 +000000010000000000000003 +``` + +The following sample lists the current PostgreSQL server WAL files. The unarchived WAL files are marked with two stars (\*\*). + +```text +-bash-4.1$ cd /opt/PostgreSQL/9.6/data/pg_xlog +-bash-4.1$ pwd +/opt/PostgreSQL/9.6/data/pg_xlog +-bash-4.1$ ls -l +total 49160 +-rw------- 1 postgres postgres 302 Mar 29 13:50 +000000010000000000000002.00000028.backup +-rw------- 1 postgres postgres 16777216 Mar 29 14:07 +000000010000000000000003 +-rw------- 1 postgres postgres 16777216 Mar 29 14:07 +**000000010000000000000004** +-rw------- 1 postgres postgres 16777216 Mar 29 13:50 +**000000010000000000000005** +drwx------ 2 postgres postgres 4096 Mar 29 14:07 archive_status +``` + +Copies of the unarchived WAL files are saved to a temporary location: + +```text +-bash-4.1$ mkdir /tmp/unarchived_pg96_wals +-bash-4.1$ pwd +/opt/PostgreSQL/9.6/data/pg_xlog +bash-4.1$ cp -p 000000010000000000000004 /tmp/unarchived_pg96_wals +bash-4.1$ cp -p 000000010000000000000005 /tmp/unarchived_pg96_wals +bash-4.1$ ls -l /tmp/unarchived_pg96_wals +total 32768 +-rw------- 1 postgres postgres 16777216 Mar 29 14:07 000000010000000000000004 +-rw------- 1 postgres postgres 16777216 Mar 29 13:50 000000010000000000000005 +``` + +On the remote host, a directory is created to which the PostgreSQL database cluster is to be restored. This restore path is named `/opt/restore_pg96` and is owned by user account `postgres`. + +```text +[user@localhost ~]$ su root +Password: +[root@localhost user]# cd /opt +[root@localhost opt]# mkdir restore_pg96 +[root@localhost opt]# chown postgres restore_pg96 +[root@localhost opt]# chgrp postgres restore_pg96 +[root@localhost opt]# chmod 700 restore_pg96 +[root@localhost opt]# ls -l +total 16 +drwxr-xr-x 4 root daemon 4096 Mar 29 12:10 PostgresPlus +drwxr-xr-x 3 root daemon 4096 Mar 29 12:25 PostgreSQL +drwx------ 2 postgres postgres 4096 Mar 29 14:15 restore_pg96 +drwxr-xr-x. 2 root root 4096 Nov 22 2013 rh +``` + +In the BART configuration file, the remote user and remote host IP address, `postgres@192.168.2.24`, have been set with the `remote_host` parameter. If not given in the BART configuration file, this information must then be specified by the `--remote-host` option when giving the `RESTORE` subcommand (for example, `bart RESTORE --remote-host postgres@192.168.2.24 …`). + +```text +[HR] + +host = 192.168.2.24 +port = 5432 +user = postgres +cluster_owner = postgres +backup_name = hr_%year-%month-%dayT%hour:%minute +remote_host = postgres@192.168.2.24 +copy_wals_during_restore = enabled +description = "Human Resources" +``` + +Use the `SHOW-BACKUPS` subcommand to identify the backup to use with the `RESTORE` subcommand. + +```text +SERVER NAME BACKUP ID BACKUP NAME BACKUP PARENT +BACKUP TIME +BACKUP SIZE WAL(s) SIZE WAL FILES STATUS +acctg 1490809695281 acctg_2017-03-29T13:48 none +2017-03-29 13:48:17 EDT +6.10 MB 32.00 MB 2 active +hr 1490809824946 hr_2017-03-29T13:50 none +2017-03-29 13:50:26 EDT +2.59 MB 32.00 MB 2 active +mktg 1490809751193 mktg_2017-03-29T13:49 none +2017-03-29 13:49:14 EDT +6.13 MB 64.00 MB 4 active +``` + +The `-t` option with the `SHOW-BACKUPS` subcommand displays additional backup information: + +```text +-bash-4.1$ bart SHOW-BACKUPS -s hr -i 1490809824946 -t +SERVER NAME : hr +BACKUP ID : 1490809824946 +BACKUP NAME : hr_2017-03-29T13:50 +BACKUP PARENT : none +BACKUP STATUS : active +BACKUP TIME : 2017-03-29 13:50:26 EDT +BACKUP SIZE : 2.59 MB +WAL(S) SIZE : 32.00 MB +NO. OF WALS : 2 +FIRST WAL FILE : 000000010000000000000002 +CREATION TIME : 2017-03-29 13:50:31 EDT +LAST WAL FILE : 000000010000000000000003 +CREATION TIME : 2017-03-29 14:07:35 EDT +``` + +A recovery is made using timeline `1` to `2017-03-29 14:01:00`. + +```text +-bash-4.1$ bart RESTORE -s hr -i hr_2017-03-29T13:50 -p +/opt/restore_pg96 -t 1 -g '2017-03-29 14:01:00' +INFO: restoring backup 'hr_2017-03-29T13:50' of server 'hr' +INFO: base backup restored +INFO: copying WAL file(s) to +postgres@192.168.2.24:/opt/restore_pg96/archived_wals +INFO: writing recovery settings to postgresql.auto.conf file +INFO: archiving is disabled +INFO: permissions set on $PGDATA +INFO: restore completed successfully +``` + +The following example shows the restored backup files in the restore path directory, `/opt/restore_pg96`: + +```text +-bash-4.1$ pwd +/opt/restore_pg96 +-bash-4.1$ ls -l +total 128 +drwxr-xr-x 2 postgres postgres 4096 Mar 29 14:27 archived_wals +-rw------- 1 postgres postgres 206 Mar 29 13:50 backup_label +drwx------ 5 postgres postgres 4096 Mar 29 12:25 base +drwx------ 2 postgres postgres 4096 Mar 29 14:27 global +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_clog +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_commit_ts +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_dynshmem +-rw------- 1 postgres postgres 4212 Mar 29 13:18 pg_hba.conf +-rw------- 1 postgres postgres 1636 Mar 29 12:25 pg_ident.conf +drwxr-xr-x 2 postgres postgres 4096 Mar 29 13:45 pg_log +drwx------ 4 postgres postgres 4096 Mar 29 12:25 pg_logical +drwx------ 4 postgres postgres 4096 Mar 29 12:25 pg_multixact +drwx------ 2 postgres postgres 4096 Mar 29 13:43 pg_notify +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_replslot +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_serial +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_snapshots +drwx------ 2 postgres postgres 4096 Mar 29 13:43 pg_stat +drwx------ 2 postgres postgres 4096 Mar 29 13:50 pg_stat_tmp +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_subtrans +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_tblspc +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_twophase +-rw------- 1 postgres postgres 4 Mar 29 12:25 PG_VERSION +drwx------ 3 postgres postgres 4096 Mar 29 14:27 pg_xlog +-rw------- 1 postgres postgres 169 Mar 29 13:24 postgresql.auto.conf +-rw-r--r-- 1 postgres postgres 21458 Mar 29 14:27 postgresql.conf +-rw-r--r-- 1 postgres postgres 118 Mar 29 14:27 postgresql.auto.conf +``` + +Copy the saved, unarchived WAL files to the restore path `pg_xlog` subdirectory (`/opt/restore_pg96/pg_xlog`): + +```text +-bash-4.1$ pwd +/opt/restore_pg96/pg_xlog +-bash-4.1$ ls -l +total 16388 +-rw------- 1 postgres postgres 16777216 Mar 29 13:50 +000000010000000000000002 +drwx------ 2 postgres postgres 4096 Mar 29 14:27 archive_status +-bash-4.1$ ls -l /tmp/unarchived_pg96_wals +total 32768 +-rw------- 1 postgres postgres 16777216 Mar 29 14:07 +000000010000000000000004 +-rw------- 1 postgres postgres 16777216 Mar 29 13:50 +000000010000000000000005 +-bash-4.1$ cp -p /tmp/unarchived_pg96_wals/* . +-bash-4.1$ ls -l +total 49156 +-rw------- 1 postgres postgres 16777216 Mar 29 13:50 +000000010000000000000002 +-rw------- 1 postgres postgres 16777216 Mar 29 14:07 +000000010000000000000004 +-rw------- 1 postgres postgres 16777216 Mar 29 13:50 +000000010000000000000005 +drwx------ 2 postgres postgres 4096 Mar 29 14:27 archive_status +``` + +Inspect the `/opt/restore_pg96/postgresql.auto.conf` file to verify that it contains the correct recovery settings: + +```text +restore_command = 'cp archived_wals/%f %p' +recovery_target_time = '2017-03-29 14:01:00' +recovery_target_timeline = 1 +``` + +Note that the command restores from the `archived_wals` subdirectory of `/opt/restore_pg96` since the `copy_wals_during_restore` parameter in the BART configuration file is set to `enabled` for database server `hr`. + +Start the database server to initiate the point-in-time recovery operation: + +```text +[user@localhost ~]$ su postgres +Password: +bash-4.1$ cd /opt/restore_pg96 +bash-4.1$ /opt/PostgreSQL/9.6/bin/pg_ctl start -D /opt/restore_pg96 -l +/opt/restore_pg96/pg_log/logfile +server starting +``` + +Inspect the database server log file to ensure the operation did not result in any errors: + +```text +2017-03-29 14:33:23 EDT LOG: database system was interrupted; last known +up at 2017-03-29 13:50:25 EDT +2017-03-29 14:33:23 EDT LOG: starting point-in-time recovery to +2017-03-29 14:01:00-04 +2017-03-29 14:33:23 EDT LOG: restored log file +"000000010000000000000002" from archive +2017-03-29 14:33:23 EDT LOG: redo starts at 0/2000098 +2017-03-29 14:33:23 EDT LOG: consistent recovery state reached at +0/20000C0 +2017-03-29 14:33:23 EDT LOG: restored log file +"000000010000000000000003" from archive +2017-03-29 14:33:23 EDT LOG: recovery stopping before commit of +transaction 1762, time 2017-03-29 14:02:28.100072-04 +2017-03-29 14:33:23 EDT LOG: redo done at 0/303F390 +2017-03-29 14:33:23 EDT LOG: last completed transaction was at log time +2017-03-29 14:00:43.351333-04 +cp: cannot stat `archived_wals/00000002.history': No such file or +directory +2017-03-29 14:33:23 EDT LOG: selected new timeline ID: 2 +cp: cannot stat `archived_wals/00000001.history': No such file or +directory +2017-03-29 14:33:23 EDT LOG: archive recovery complete +2017-03-29 14:33:23 EDT LOG: MultiXact member wraparound protections are +now enabled +2017-03-29 14:33:23 EDT LOG: database system is ready to accept +connections +2017-03-29 14:33:23 EDT LOG: autovacuum launcher started +``` + +The tables that exist in the recovered database cluster are: + +```text +postgres=# \dt + List of relations +Schema | Name | Type | Owner +--------+----------------+-------+---------- +public | hr_rmt_t1_1356 | table | postgres +public | hr_rmt_t1_1358 | table | postgres +public | hr_rmt_t1_1400 | table | postgres +(3 rows) +``` + +Since recovery was up to and including 2017-03-29 14:01:00, the following tables created after 14:01 are not present: + +```text +public | hr_rmt_t1_1402 | table | postgres +public | hr_rmt_t1_1404 | table | postgres +public | hr_rmt_t1_1406 | table | postgres +``` + +The BART `RESTORE` operation stops WAL archiving by adding an `archive_mode = off` parameter at the very end of the `postgresql.conf` file. This last parameter in the file overrides any other previous setting of the same parameter in the file. Delete the last setting and restart the database server to start WAL archiving. + +```text +# Add settings for extensions here +archive_mode = off +``` diff --git a/product_docs/docs/bart/2.6.1/bart_ref/images/EDB_logo.png b/product_docs/docs/bart/2.6.1/bart_ref/images/EDB_logo.png new file mode 100755 index 00000000000..39a54822d85 Binary files /dev/null and b/product_docs/docs/bart/2.6.1/bart_ref/images/EDB_logo.png differ diff --git a/product_docs/docs/bart/2.6.1/bart_ref/images/edb.png b/product_docs/docs/bart/2.6.1/bart_ref/images/edb.png new file mode 100755 index 00000000000..71e5bdde787 Binary files /dev/null and b/product_docs/docs/bart/2.6.1/bart_ref/images/edb.png differ diff --git a/product_docs/docs/bart/2.6.1/bart_ref/images/edb_logo.svg b/product_docs/docs/bart/2.6.1/bart_ref/images/edb_logo.svg new file mode 100755 index 00000000000..f24d1dfefee --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_ref/images/edb_logo.svg @@ -0,0 +1,19 @@ + + + edb-logo-disc-dark + + + + \ No newline at end of file diff --git a/product_docs/docs/bart/2.6.1/bart_ref/images/image2.png b/product_docs/docs/bart/2.6.1/bart_ref/images/image2.png new file mode 100755 index 00000000000..4eba2e7efa7 Binary files /dev/null and b/product_docs/docs/bart/2.6.1/bart_ref/images/image2.png differ diff --git a/product_docs/docs/bart/2.6.1/bart_ref/index.mdx b/product_docs/docs/bart/2.6.1/bart_ref/index.mdx new file mode 100644 index 00000000000..6a8817bd039 --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_ref/index.mdx @@ -0,0 +1,33 @@ +--- +navTitle: Reference Guide +title: "EDB Postgres Backup and Recovery Reference Guide" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/genindex.html" + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/conclusion.html" + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/index.html" +--- + +This guide acts as a quick reference for BART subcommands and provides comprehensive examples of the following BART operations: + +- Performing a full backup of database servers +- Performing a point-in-time recovery (PITR) on a remote PostgreSQL database server +- Restoring an incremental backup +- Restoring a database cluster with tablespaces +- Evaluating, marking, and deleting backups and incremental backups +- Configuring and operating local and remote database servers + +For detailed information about BART subcommands and operations, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/latest/bart_user/). + +The document is organized as follows: + +- See [Subcommands](01_bart_subcommands_examples/#using_bart_subcommands) to view BART subcommand examples. +- See [Examples](02_additional_examples/#examples) to view BART operations examples. +- See [Sample BART System](03_sample_bart_system_with_local_and_remote_database_servers/#a_sample_bart_system_with_local_and_remote_database_servers) to view examples of both local and remote database server configuration and operation. + +
+ +bart_subcommands_examples additional_examples sample_bart_system_with_local_and_remote_database_servers conclusion + +
diff --git a/product_docs/docs/bart/2.6.1/bart_user/01_introduction.mdx b/product_docs/docs/bart/2.6.1/bart_user/01_introduction.mdx new file mode 100644 index 00000000000..1212b2847bf --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_user/01_introduction.mdx @@ -0,0 +1,55 @@ +--- +title: "Introduction" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/introduction.html" +--- + +The EDB Backup and Recovery Tool (BART) is an administrative utility that provides simplified backup and recovery management for multiple local or remote EDB Advanced Server and PostgreSQL database servers. + +BART provides the following features: + +- Support for complete, hot, physical backups of multiple Advanced Servers and PostgreSQL database servers +- Support for two types of backups – full base backups and block-level incremental backups +- Backup and recovery management of database servers on local or remote hosts +- A single, centralized catalog for backup data +- Retention policy support for defining and managing how long backups should be kept +- The capability to store the backup data in compressed format +- Verified backup data with checksums +- Backup information displayed in an easy-to-read format +- A simplified point-in-time recovery process + +This guide provides the following information about using BART: + +- an [overview](02_overview/#overview) of the BART components and concepts. +- [backup and recovery management process](03_using_bart/#using_bart). +- [using tablespaces](04_using_tablespaces/#using_tablespaces). + +For information about installing BART, see the *EDB Backup and Recovery Installation and Upgrade Guide*; for examples of BART operations and subcommand usage, see the *EDB Backup and Recovery Reference Guide*. These guides are available at the [EDB website](/bart/latest/bart_inst/). + + + +## Conventions Used in this Guide + +The following is a list of conventions used throughout this document. + +- Much of the information in this document applies interchangeably to the PostgreSQL and EDB Advanced Server database systems. The term *Advanced Server* is used to refer to EDB Advanced Server. The term *Postgres* is used to generically refer to both PostgreSQL and Advanced Server. When a distinction needs to be made between these two database systems, the specific names, PostgreSQL or Advanced Server are used. + +- The installation directory of the PostgreSQL or Advanced Server products is referred to as `POSTGRES_INSTALL_HOME`: + + - For PostgreSQL Linux installations, this defaults to `/opt/PostgreSQL/` for version 10 and earlier. For later versions, the installation directory is `/var/lib/pgsql/`. + - For Advanced Server Linux installations performed using the interactive installer for version 10 and earlier, this defaults to `/opt/PostgresPlus/AS` or `/opt/edb/as`. For Advanced Server Linux installations performed with an RPM package, this defaults to `/usr/ppas-` or `/usr/edb/as`. For Advanced Server Linux installations performed with an RPM package for version 11 or later, this defaults to `/usr/edb/as`. + +## Restrictions on pg_basebackup + +BART takes full backups using the `pg_basebackup` utility program under the following conditions: + +- The backup is taken on a standby server. +- The `--with-pg_basebackup` option is specified with the `BACKUP` subcommand (see [Backup](03_using_bart/03_basic_bart_subcommand_usage/03_backup/#backup)). +- The number of thread count in effect is 1, and the `with-pg_basebackup` option is not specified with the `BACKUP` subcommand. +- Database servers can only be backed up using `pg_basebackup` utility program of the same or later version than the database server version. + +In the global section of the BART configuration file, the `pg_basebackup_path` parameter specifies the complete directory path to the `pg_basebackup` program. For information about the `pg_basebackup_path` parameter and the `thread_count`, see the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/latest/bart_inst/). + +For information about `pg_basebackup`, see the [PostgreSQL Core Documentation](https://postgresql.org/docs/current/static/app-pgbasebackup.html). diff --git a/product_docs/docs/bart/2.6.1/bart_user/02_overview/01_block-level_incremental_backup/01_incremental_backup_limitations_and_requirements.mdx b/product_docs/docs/bart/2.6.1/bart_user/02_overview/01_block-level_incremental_backup/01_incremental_backup_limitations_and_requirements.mdx new file mode 100644 index 00000000000..a3fe8894d09 --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_user/02_overview/01_block-level_incremental_backup/01_incremental_backup_limitations_and_requirements.mdx @@ -0,0 +1,42 @@ +--- +title: "Incremental Backup Limitations and Requirements" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/incremental_backup_limitations_and_requirements.html" +--- + + + +The following limitations apply to incremental backup: + +- If you have restored a full or incremental backup, you must take a full backup before enabling incremental backup. +- If a standby node has been promoted to the role of a primary node, you must take a full backup before enabling incremental backup on the cluster. +- On a standby database server, you cannot take an incremental backup. + +You must meet the following requirements before implementing incremental backup: + +- You must create or select an operating system account to be used as the BART user account. + +- You must create or select the replication database user, which must be a superuser. + +- In the BART configuration file: + + - You must set the `cluster_owner` parameter to the Linux operating system user account that owns the database cluster directory from which incremental backups are to be taken. + - You must enable the `allow_incremental_backups` parameter. + +- A passwordless SSH/SCP connection must be established between the BART user account on the BART host and the `cluster_owner` user account on the database server. + + It must be noted that a passwordless SSH/SCP connection must be established even if BART and the database server are running on the same host and the BART user account and the `cluster_owner` user account are the same account. + +- In addition to the BART host (where the BART backup catalog resides), the BART package must also be installed on every remote database server on which incremental backups are to be restored. To restore an incremental backup, the `bart` program must be executable on the remote host by the remote user (the remote user is specified by the `remote_host` parameter in the BART configuration file or by the `-r` option when using the `RESTORE` subcommand to restore the incremental backup). + +- When [restoring incremental backups on a remote database server](05_restoring_an_incremental_backup/#restoring-an-incremental-backup-on-a-remote-host), a passwordless SSH/SCP connection must be established from the BART user account on the BART host to the remote user on the remote host (the remote user is specified by the `remote_host` parameter in the BART configuration file or by the `-r` option when using the `RESTORE` subcommand to restore the incremental backup). + +- Compression of archived WAL files in the BART backup catalog is not permitted for database servers on which incremental backups are to be taken. The `wal_compression` setting in the BART configuration file must be disabled for those database servers. + +- The incremental backup must be on the same timeline as the parent backup. The timeline changes after each recovery operation so an incremental backup cannot use a parent backup from an earlier timeline. + +For information about configuring these requirements, see the EDB Backup and Recovery Installation and Upgrade Guide available at the [EDB website](/bart/latest/bart_inst/). + +The following section provides an overview of the basic incremental backup concepts. diff --git a/product_docs/docs/bart/2.6.1/bart_user/02_overview/01_block-level_incremental_backup/02_concept_overview.mdx b/product_docs/docs/bart/2.6.1/bart_user/02_overview/01_block-level_incremental_backup/02_concept_overview.mdx new file mode 100644 index 00000000000..8183d4802bd --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_user/02_overview/01_block-level_incremental_backup/02_concept_overview.mdx @@ -0,0 +1,33 @@ +--- +title: "Concept Overview" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/concept_overview.html" +--- + + + +Using incremental backups involves the following sequence of steps: + +1. Configure BART, and enable and initiate archiving of WAL files to the `archive_path` in the same manner as done for full backups. + + The default `archive_path` is the BART backup catalog (`//archived_wals`). Using the `` parameter in the server section of the BART configuration file, you can specify the location where WAL files will be archived. + + For more information about the `archive_path` parameter and configuring BART, see the EDB Backup and Recovery Installation and Upgrade Guide available at the [EDB website](/bart/latest/bart_inst/). + +2. Take an initial full backup with the `BACKUP` subcommand. This full backup establishes the parent of the first incremental backup. + +3. Scan all WAL files produced by database servers on which incremental backups are to be taken. These WAL files are scanned once they have been archived to the `archive_path`. + + Each scanned WAL file results in a modified block map (MBM) file that records the location of modified blocks obtained from the corresponding WAL file. The BART WAL scanner program `bart-scanner` performs this process. + +4. Take incremental backups using the `BACKUP` subcommand with the `--parent` option to specify the backup identifier or name of a previous, full backup or an incremental backup. Any previous backup may be chosen as the parent as long as all backups belong to the same timeline. + +5. The incremental backup process identifies which WAL files may contain changes from when the parent backup was taken to the starting point of the incremental backup. The corresponding MBM files are used to locate and copy the modified blocks to the incremental backup directory along with other database cluster directories and files. Instead of backing up all, full relation files, only the modified blocks are copied and saved. In addition, the relevant MBM files are condensed into one consolidated block map (CBM) file that is stored with the incremental backup. + + Multiple block copier threads can be used to copy the modified blocks to the incremental backup directory. See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/latest/bart_inst/) for information about setting the `thread_count` parameter in the BART configuration file. See [Backup](../../03_using_bart/03_basic_bart_subcommand_usage/03_backup/#backup) for information about using the `--thread-count` option with the `BACKUP` subcommand. + +6. Invoke the restore process for an incremental backup using the `RESTORE` subcommand in the same manner as restoring a full backup. The `-i` option specifies the backup identifier or name of the incremental backup to restore. The restore process begins by going back through the chain of past, parent incremental backups until the initial full backup starting the chain is identified. This full backup provides the initial set of directories and files to be restored to the location specified with the `-p` option. Each subsequent incremental backup in the chain is then restored. Restoration of an incremental backup uses its CBM file to restore the modified blocks from the incremental backup. + +The following sections provide some additional information on these procedures. diff --git a/product_docs/docs/bart/2.6.1/bart_user/02_overview/01_block-level_incremental_backup/03_wal_scanning_preparation_for_an_incremental_backup.mdx b/product_docs/docs/bart/2.6.1/bart_user/02_overview/01_block-level_incremental_backup/03_wal_scanning_preparation_for_an_incremental_backup.mdx new file mode 100644 index 00000000000..5264499e13e --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_user/02_overview/01_block-level_incremental_backup/03_wal_scanning_preparation_for_an_incremental_backup.mdx @@ -0,0 +1,54 @@ +--- +title: "WAL Scanning – Preparation for an Incremental Backup" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/wal_scanning_preparation_for_an_incremental_backup.html" +--- + + + +The WAL scanner program (`bart-scanner`) scans the WAL files created from the time of the parent backup up to the start of the incremental backup to determine which blocks have modified since the parent backup, and records the information in a file called the *modified block map (MBM) file*. One MBM file is created for each WAL file. + +The MBM file is stored in the directory where archived_wals will be stored, as specified in the `archive_path` parameter in the `bart.cfg` file. If the `archive_path` is not specified, the default `archived_wals` directory is: + +`//` + +Where: + +`` is the BART backup catalog parent directory specified in the global section of the BART configuration file. + +`` is the lowercase conversion of the database server name specified in the server section of the BART configuration file. + +The following code snippet is the content of the archive path showing the MBM files created for the WAL files. (The user name and group name of the files have been removed from the example to list the WAL files and MBM files in a more comparable manner): + +```text +[root@localhost archived_wals]# pwd +/opt/backup/acctg/archived_wals +[root@localhost archived_wals]# ls -l +total 131104 +-rw------- 1 ... ... 16777216 Oct 12 09:38 000000010000000100000078 +-rw------- 1 ... ... 16777216 Oct 12 09:38 000000010000000100000079 +-rw------- 1 ... ... 16777216 Oct 12 09:38 00000001000000010000007A +-rw------- 1 ... ... 16777216 Oct 12 09:35 00000001000000010000007B +-rw------- 1 ... ... 16777216 Oct 12 09:38 00000001000000010000007C +-rw------- 1 ... ... 16777216 Oct 12 09:39 00000001000000010000007D +-rw------- 1 ... ... 16777216 Oct 12 09:42 00000001000000010000007E +-rw------- 1 ... ... 16777216 Oct 12 09:47 00000001000000010000007F +-rw-rw-r-- 1 ... ... 161 Oct 12 09:49 0000000100000001780000280000000179000000.mbm +-rw-rw-r-- 1 ... ... 684 Oct 12 09:49 000000010000000179000028000000017A000000.mbm +-rw-rw-r-- 1 ... ... 161 Oct 12 09:49 00000001000000017A000028000000017B000000.mbm +-rw-rw-r-- 1 ... ... 161 Oct 12 09:49 00000001000000017B000028000000017C000000.mbm +-rw-rw-r-- 1 ... ...1524 Oct 12 09:49 00000001000000017C000028000000017D000000.mbm +-rw-rw-r-- 1 ... ... 161 Oct 12 09:49 00000001000000017D000028000000017E000000.mbm +-rw-rw-r-- 1 ... ... 161 Oct 12 09:49 00000001000000017E000028000000017F000000.mbm +-rw-rw-r-- 1 ... ... 161 Oct 12 09:49 00000001000000017F0000280000000180000000.mbm +``` + +MBM files have the suffix, `.mbm`. + +In preparation for any incremental backup, the WAL files should be scanned as soon as they are copied to the `archive_path`. Thus, the WAL scanner should be running as soon as the WAL files from the database cluster are archived to the `archive_path`. If the `archive_path` contains WAL files that have not yet been scanned, starting the WAL scanner begins scanning these files. If WAL file fails to be scanned (resulting in a missing MBM file), you can use the WAL scanner to specify an individual WAL file. + +Under certain conditions such as when the Network File System (NFS) is used to copy WAL files to the `archive_path`, the WAL files may have been missed by the WAL scanner program for scanning and creation of MBM files. Use the `scan_interval` parameter in the BART configuration file to initiate force scanning of WAL files in the `archive_path` to ensure MBM files are generated. See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/latest/bart_inst/) for more information about the `scan_interval` parameter. + +See [Running the BART WAL Scanner](../../03_using_bart/04_running_the_bart_wal_scanner/#running_the_bart_wal_scanner) for information about using the WAL scanner. diff --git a/product_docs/docs/bart/2.6.1/bart_user/02_overview/01_block-level_incremental_backup/04_performing_an_incremental_backup.mdx b/product_docs/docs/bart/2.6.1/bart_user/02_overview/01_block-level_incremental_backup/04_performing_an_incremental_backup.mdx new file mode 100644 index 00000000000..8198f0f6400 --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_user/02_overview/01_block-level_incremental_backup/04_performing_an_incremental_backup.mdx @@ -0,0 +1,78 @@ +--- +title: "Performing an Incremental Backup" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/performing_an_incremental_backup.html" +--- + + + +The WAL files produced at the time of the parent backup up to the start of the incremental backup contain information about which blocks were modified during that time interval. That information is consolidated into an MBM file for each WAL file by the WAL scanner. + +The MBM files for the relevant WAL files are read, and the information is used to copy the modified blocks from the database cluster to the `archived_wals` directory as specified in the `archive_path` parameter in the `bart.cfg` file. When compared to a full backup, the number and sizes of relation files can be significantly less for an incremental backup. + +For comparison, the following is an abbreviated list of the files copied to the archived `base` subdirectory of a full backup for one database: + +```text +[root@localhost 14845]# pwd +/opt/backup/acctg/1476301238969/base/base/14845 +[root@localhost 14845]# ls +112 13182_vm 14740 16467 16615 2608_vm 2655 2699 2995 ... +113 13184 14742 16471 174 2609 2656 2701 2995_vm ... +1247 13186 14745 16473 175 2609_fsm 2657 2702 2996 ... +1247_fsm 13187 14747 16474 2187 2609_vm 2658 2703 2998 ... +1247_vm 13187_fsm 14748 16476 2328 2610 2659 2704 2998_vm ... +1249 13187_vm 14749 16477 2328_fsm 2610_fsm 2660 2753 2999 ... +1249_fsm 13189 14752 16479 2328_vm 2610_vm 2661 2753_fsm 2999_vm ... +1249_vm 13191 14754 16488 2336 2611 2662 2753_vm 3079 ... +1255 13192 14755 16490 2336_vm 2611_vm 2663 2754 3079_fsm ... + . + . + . +13182_fsm 14739 16465 16603 2608_fsm 2654 2696 2893_vm 3501_vm ... +``` + +In contrast, the following is the content of the archived `base` subdirectory of the same database from a subsequent incremental backup: + +```text +[root@localhost 14845]# pwd +/opt/backup/acctg/1476301835391/base/base/14845 +[root@localhost 14845]# ls +1247 1249 1259 16384 17006 2608 2610 2658 2663 2678 ... +1247_fsm 1249_fsm 1259_fsm 16387 17009 2608_fsm 2610_fsm 2659 2673 2679 ... +1247_vm 1249_vm 1259_vm 16389 17011 2608_vm 2610_vm 2662 2674 2703 ... +``` + +The information from the MBM files are consolidated into one file called a *consolidated block map* (CBM) file. During the restore operation for the incremental backup, the CBM file is used to identify the modified blocks to be restored for that backup. In addition, the incremental backup also stores other required subdirectories and files from the database cluster as is done for full backups. + +Before taking an incremental backup, an initial full backup must be taken with the `BACKUP` subcommand. This full backup establishes the parent of the first incremental backup. + +The syntax for taking a full backup is: + +```text +bart BACKUP –s { | all } [ -F { p | t } ] + [ -z ] [ –c ] + [ --backup-name ] + [ --thread-count ] + [ { --with-pg_basebackup | --no-pg_basebackup } ] + [--checksum-algorithm ] +``` + +The syntax for taking an incremental backup is: + +```text +bart BACKUP –s { | all } [ -F p] + [ --parent { | } ] + [ --backup-name ] + [ --thread-count ] + [ --check ] + [--checksum-algorithm ] +``` + +You must specify the following before taking an incremental backup: + +- `-Fp` option for plain text format as incremental backup can only be taken in the plain text format. +- `--check` option to verify if the required MBM files are present in the `archived_wals` directory. The `--parent` option must be specified when the `--check` option is used. + +See [BACKUP](../../03_using_bart/03_basic_bart_subcommand_usage/03_backup/#backup) for more information about using the `BACKUP` subcommand. diff --git a/product_docs/docs/bart/2.6.1/bart_user/02_overview/01_block-level_incremental_backup/05_restoring_an_incremental_backup.mdx b/product_docs/docs/bart/2.6.1/bart_user/02_overview/01_block-level_incremental_backup/05_restoring_an_incremental_backup.mdx new file mode 100644 index 00000000000..b3dcf583e31 --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_user/02_overview/01_block-level_incremental_backup/05_restoring_an_incremental_backup.mdx @@ -0,0 +1,48 @@ +--- +title: "Restoring an Incremental Backup" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/restoring_an_incremental_backup.html" +--- + + + +Restoring an incremental backup may require additional steps depending upon the host on which the incremental backup is to be restored: + +- [Restoring an Incremental Backup on a BART Host](#restoring-an-incremental-backup-on-a-bart-host) - This section outlines restoring an incremental backup onto the same host where BART has been installed. +- [Restoring an Incremental Backup on a Remote Host](#restoring-an-incremental-backup-on-a-remote-host) - This section outlines restoring an incremental backup onto a remote host where BART has not been installed. + + + +## Restoring an Incremental Backup on a BART Host + +Specify a backup identifier or name, and include the `-i` option when invoking the `RESTORE` subcommand to restore an incremental backup. All `RESTORE` options may be used in the same manner as when restoring a full backup. See [RESTORE](../../03_using_bart/03_basic_bart_subcommand_usage/08_restore/#restore) command for more details. + +First, all files from the full backup from the beginning of the backup chain are restored. For each incremental backup, the CBM file is used to identify and restore blocks from the incremental backup. If there are new relations or databases identified in the CBM file, then relevant relation files are copied. If consolidated block map information is found indicating the drop of a relation or a database, then the relevant files are removed from the restore directory. Similarly, if there is any indication of a table truncation, then the related files are truncated. + +Also note that you can use the `-w` option of the `RESTORE` subcommand to specify a multiple number of parallel worker processes to stream the modified blocks to the restore host. + +!!! Note + If you set the [BART scanner](../../03_using_bart/04_running_the_bart_wal_scanner/#running_the_bart_wal_scanner) or [backup](../../03_using_bart/03_basic_bart_subcommand_usage/03_backup/#backup) with the `--checksum-algorithm=NONE` option, then you must specify the `--disable checksum` option while restoring an incremental backup. + + + +## Restoring an Incremental Backup on a Remote Host + +Ensure the `bart` program is available on the remote host when restoring an incremental backup on a remote host; the invocation of the `RESTORE` subcommand for an incremental backup results in the execution of the `bart` program on the remote host to restore the modified blocks to their proper location. + +To restore an incremental backup onto a remote host where BART has not been installed, perform the following steps: + +**Step 1:** Install `BART` on the remote host to which an incremental backup is to be restored. + +No editing is needed in the `bart.cfg` file installed on the remote host. + +**Step 2:** Determine the Linux operating system user account on the remote host to be used as the remote user. This user is specified by the `remote_host` parameter in the BART configuration file or by the `-r` option when using the `RESTORE` subcommand to restore the incremental backup. The remote user must be the owner of the directory where the incremental backup is to be restored on the remote host. By default, the user account is `enterprisedb` for Advanced Server or `postgres` for PostgreSQL. + +**Step 3:** Ensure a passwordless SSH/SCP connection is established from the BART user on the BART host to the remote user on the remote host. For information about creating a passwordless SSH/SCP connection, see the *EDB Backup and Recovery Installation and Upgrade Guide*, available at the [EDB website](/bart/latest/bart_inst/). + +When restoring an incremental backup, specify the backup identifier or name of the incremental backup that will be restored. See the [RESTORE](../../03_using_bart/03_basic_bart_subcommand_usage/08_restore/#restore) documentation for more details. To view an example of restoring an incremental backup, see the *EDB Backup and Recovery Reference Guide* available at the [EDB website](/bart/latest/bart_ref/). + +!!! Note + If you set the [BART scanner](../../03_using_bart/04_running_the_bart_wal_scanner/#running_the_bart_wal_scanner) or [backup](../../03_using_bart/03_basic_bart_subcommand_usage/03_backup/#backup) with the `--checksum-algorithm=NONE` option, then you must specify the `--disable checksum` option while restoring an incremental backup. diff --git a/product_docs/docs/bart/2.6.1/bart_user/02_overview/01_block-level_incremental_backup/index.mdx b/product_docs/docs/bart/2.6.1/bart_user/02_overview/01_block-level_incremental_backup/index.mdx new file mode 100644 index 00000000000..3e65e3b0056 --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_user/02_overview/01_block-level_incremental_backup/index.mdx @@ -0,0 +1,24 @@ +--- +title: "Block-Level Incremental Backup" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/block-level_incremental_backup.html" +--- + + + +This section describes the basic concepts of a block-level incremental backup (referred to as an incremental backup). An incremental backup is a unique functionality of BART. + +An incremental backup provides a number of advantages when compared to using a full backup: + +- The amount of time required to produce an incremental backup is generally less than a full backup, as modified relation blocks are saved instead of all full relation files of the database cluster. +- An incremental backup uses less disk space than a full backup. + +Generally, all BART features (such as retention policy management) apply to incremental backups and full backups. See [Managing Incremental Backups](../../03_using_bart/02_managing_backups_using_a_retention_policy/05_managing_incremental_backups/#managing_incremental_backups) for more information. + +
+ +incremental_backup_limitations_and_requirements concept_overview wal_scanning_preparation_for_an_incremental_backup performing_an_incremental_backup restoring_an_incremental_backup + +
diff --git a/product_docs/docs/bart/2.6.1/bart_user/02_overview/02_creating_a_backup_chain.mdx b/product_docs/docs/bart/2.6.1/bart_user/02_overview/02_creating_a_backup_chain.mdx new file mode 100644 index 00000000000..644040d87f1 --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_user/02_overview/02_creating_a_backup_chain.mdx @@ -0,0 +1,22 @@ +--- +title: "Creating a Backup Chain" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/creating_a_backup_chain.html" +--- + + + +A *backup chain* is the set of backups consisting of a full backup and all of its successive incremental backups. Tracing back on the parent backups of all incremental backups in the chain eventually leads back to that single, full backup. + +It is possible to have a *multi-forked* backup chain, which is two or more successive lines of incremental backups, all of which begin with the same, full backup. Thus, within the chain there is a backup that serves as the parent of more than one incremental backup. + +Since restoration of an incremental backup is dependent upon first restoring the full backup, then all successive incremental backups up to, and including the incremental backup specified by the `RESTORE` subcommand, it is crucial to note the following: + +- Deletion or corruption of the full backup destroys the entire backup chain. It is not possible to restore any of the incremental backups that were part of that chain. +- Deletion or corruption of an incremental backup within the chain results in the inability to restore any incremental backup that was added to that successive line of backups following the deleted or corrupted backup. The full backup and incremental backups prior to the deleted or corrupted backup can still be restored. + +The actions of retention policy management are applied to the full backup and all of its successive incremental backups within the chain in an identical manner as if they were one backup. Thus, use of retention policy management does not result in the breakup of a backup chain. + +See the *EDB Backup and Recovery Reference Guide*, available at the [EDB website](/bart/latest/bart_ref/) for examples of creating a backup chain and restoring an incremental backup. diff --git a/product_docs/docs/bart/2.6.1/bart_user/02_overview/index.mdx b/product_docs/docs/bart/2.6.1/bart_user/02_overview/index.mdx new file mode 100644 index 00000000000..7b5b7e92fb3 --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_user/02_overview/index.mdx @@ -0,0 +1,97 @@ +--- +title: "Overview" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/overview.html" +--- + + + +BART provides a simplified interface for the continuous archiving and point-in-time recovery method provided with Postgres database servers. This consists of the following processes: + +- Capturing a complete image of a database cluster as a full base backup or referred to simply as a *full backup*. +- Capturing a modified image of a database cluster called a *block-level incremental backup* or referred as *incremental backup*, which is similar to a full backup, but contains the modified blocks of the relation files that have been changed since a previous backup. +- Archiving the `Write-Ahead Log segments` (WAL files), which continuously record changes to be made to the database files. +- Performing *Point-In-Time Recovery* (PITR) to a specified transaction ID or timestamp with respect to a timeline using a full backup along with successive, [block-level incremental backups](01_block-level_incremental_backup/#block-level_incremental_backup) that reside in the same backup chain, and the WAL files. + +Detailed information regarding WAL files and point-in-time recovery is documented in the [PostgreSQL Core Documentation](https://www.postgresql.org/docs/current/static/continuous-archiving.html). + +The general term *backup* refers to both full backups and incremental backups. + +When taking a full backup of a standby server, BART uses the PostgreSQL `pg_basebackup` utility program. However, it must be noted that for standby servers, you can only take a full backup, but cannot take an incremental or parallel backups. For information about standby servers, see the [PostgreSQL Documentation](https://www.postgresql.org/docs/current/static/high-availability.html). + +BART uses a centralized backup catalog, a single configuration file, and a command line interface controlling the necessary operations to simplify the management process. Reasonable defaults are automatically used for various backup and restore options. BART also performs the necessary recovery file configuration required for point-in-time recovery using its command line interface. + +BART also provides the following features to enhance backup management: + +- Automation of the WAL archiving command configuration. +- Usage of retention policies to evaluate, categorize, and delete obsolete backups. +- Compression of WAL files to conserve disk space. +- Customizable naming of backups to ease their usage. +- Easy access to comprehensive information about each backup. + +The key components of a BART installation are: + +- **BART Host.** The host system on which BART is installed. BART operations are invoked from this host system. The database server backups and archived WAL files are stored on this host as well. +- **BART User Account.** Linux operating system user account you choose to run BART. The BART user account owns the BART backup catalog directory. +- **BART Configuration File.** File in editable text format containing the configuration information that BART uses. +- **BART Backup Catalog.** File system directory structure containing all of the backups for the database servers that BART manages. It is also the default `archive_path` to store archived WAL files. +- **BART Backupinfo File.** File in text format containing information for a BART backup. A `backupinfo` file resides in each backup subdirectory within the BART backup catalog. +- **BART Command Line Utility Program.** Single, executable file named `bart`, which is used to manage all BART operations. +- **BART WAL Scanner Program.** Single, executable file named `bart-scanner`, which is used to scan WAL files to locate and record the modified blocks for incremental backups. + +Other concepts and terms referred to in this document include the following: + +- **Postgres Database Cluster.** Also commonly called the *data directory*, this is the file system directory where all of the data files related to a particular Postgres database server instance are stored. (Each specific running instance is identified by its host and port number when connecting to a database.) The database cluster is identified by the `–D` option when it is created, started, stopped, etc. by the `Postgres initdb` and `pg_ctl` commands. A full backup is a copy of a database cluster. + + The terms database cluster and database server are used somewhat interchangeably throughout this document, though a single database server can run multiple database clusters. + +- **Postgres User Account.** Linux operating system user account that runs the Advanced Server or PostgreSQL database server and owns the database cluster directory. + + - By default, the database user account is `enterprisedb` when Advanced Server is installed to support compatibility with Oracle databases. + + - By default, the database user account is `postgres` when Advanced Server is installed in PostgreSQL compatible mode. For a PostgreSQL database server, the default database user account is also `postgres`. + + The BART configuration parameter `cluster_owner` must be set to the database user account for each database server. + +- **Replication Database User.** For each database server that BART manages, a database superuser must be selected to act as the replication database user. This database user is used to connect to the database server when backups are taken. The database superusers created with an initial Postgres database server installation (`enterprisedb` or `postgres`) may be used for this purpose. The BART configuration parameter `user` must be set to this replication database user for each database server. + +- **Secure Shell (SSH)/Secure Copy (SCP).** Linux utility programs used to log into hosts (SSH) and copy files (SCP) between hosts. A valid user account must be specified that exists on the target host and in fact is the user account under which the SSH or SCP operations occur. + +For information on how all of these components are configured and used with BART, see the EDB Backup and Recovery Installation and Upgrade Guide available at the [EDB website](/bart/latest/bart_inst/). + +**Supported BART Operations** + +The following tables are not a conclusive list of the scenarios supported by BART, but instead provides an overview of some of the most common scenarios in both `pg_basebackup` (thread count=1) as well as parallel backup mode (thread count greater than 1). + +| | -Fp-xlog-method=fetch | -Fp-xlog-method=stream | -Ft-xlog-method=fetch | -Ft-xlog-method=stream | +| -------------------------------------------- | --------------------- | ---------------------- | --------------------- | ---------------------- | +| `Primary Database Server/Full backup` | Supported | Supported | Supported | Supported | +| `Primary Database Server/Incremental backup` | Supported | Supported | Not Supported | Not Supported | +| `Standby Database Server/Full backup` | Supported | Supported | Supported | Supported | +| `Standby Database Server/Incremental backup` | Not Supported | Not Supported | Not Supported | Not Supported | + +Backup + +| | Wal compression by BART | WAL scanner | +| -------------------------------------------- | ----------------------- | ----------- | +| `Primary Database Server/Full backup` | Supported | N/A | +| `Primary Database Server/Incremental backup` | Not Supported | N/A | +| `Standby Database Server/Full backup` | Supported | N/A | +| `Standby Database Server/Incremental backup` | Not Supported | N/A | + +Wal Archiving + +| | Wal compression = enabled | Wal compression = disabled | +| ------------------ | ------------------------- | -------------------------- | +| `Restore` | Supported | Supported | +| `Parallel restore` | Supported | Supported | + +Restore + +
+ +block-level_incremental_backup creating_a_backup_chain + +
diff --git a/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/01_bart_management_overview/01_performing_a_restore_operation.mdx b/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/01_bart_management_overview/01_performing_a_restore_operation.mdx new file mode 100644 index 00000000000..06edb0b5afb --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/01_bart_management_overview/01_performing_a_restore_operation.mdx @@ -0,0 +1,60 @@ +--- +title: "Performing a Restore Operation" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/performing_a_restore_operation.html" +--- + + + +The following steps describe the process of restoring a backup: + +**Step 1:** Use your system-specific command to shut down the database server. + +**Step 2:** Inspect the `pg_wal` subdirectory (inspect the `pg_xlog` subdirectory if you are using server 9.6 version) of the data directory and save any WAL files that have not yet been archived to the `archive_path`. If there are files that have not been archived, save them to a temporary location. + +**Step 3:** If you want to restore to current data directory, it is recommended to make a copy of the current data directory and then delete all files and subdirectories under the data directory if you have enough extra space. If there is not enough space, then make a copy of `pg_wal` directory (or `pg_xlog` if you are using server 9.6 version) until the server is successfully restored. + +If you want to restore to a new, empty directory, create the directory on which you want to restore the backed up database cluster. Ensure the data directory can be written to by the BART user account or by the user account specified by the `remote_host` configuration parameter, or by the `--remote-host` option of the `RESTORE` subcommand (if these are to be used). + +**Step 4:** Perform the same process for tablespaces as described in Step 3. The `tablespace_path` parameter in the BART configuration file must contain the tablespace directory paths to which the tablespace data files are to be restored. See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/latest/bart_inst/) for more information about this parameter. + +**Step 5:** Identify the backup to use for the restore operation and obtain the backup ID or backup name. + +To use the latest backup, omit the `-i` option; the `RESTORE` subcommand uses that backup by default. The backups can be listed with the `SHOW-BACKUPS` subcommand. + +**Step 6:** Run the BART `RESTORE` subcommand. + +- Minimal recovery settings will be saved in the `postgresql.auto.conf` file and archive recovery will proceed only until consistency is reached, with no restoration of files from the archive. See [Restore](../03_basic_bart_subcommand_usage/08_restore/#restore) for detailed information about `Restore` subcommand. + +- If the `-c` option is specified or if the `copy_wals_during_restore` BART configuration parameter is enabled for this database server, then the following actions occur: + + - In addition to restoring the database cluster to the directory specified by the `-p restore_path` option, the archived WAL files of the backup are copied from the BART backup catalog to the subdirectory `restore_path/archived_wals`. + - If recovery settings are saved in the `postgresql.auto.conf` file, the command string set in the `restore_command` parameter retrieves the WAL files from this `archived_wals` subdirectory relative to the `restore_path` parent directory as: `restore_command = cp archived_wals/%f %p` + +You must ensure that valid options are specified when using the `RESTORE` subcommand. BART will not generate an error message if invalid option values or invalid option combinations are provided. BART will accept the invalid options and pass them to the `postgresql.auto.conf` file, which will then be processed by the database server when it is restarted. + +**Step 7:** Copy any saved WAL files from Step 2 to the `restore_path/pg_xlog` subdirectory. + +**Step 8:** Inspect the restored directories and data files of the restored database cluster in directory `restore_path`. + +All files and directories must be owned by the user account that you intend to use to start the database server. Recursively change the user and group ownership of the `restore_path` directory, its files, and its subdirectories if necessary. There must only be directory access privileges for the user account that will start the database server. No other groups or users can have access to the directory. + +**Step 9:** The `postgresql.auto.conf` file should be configured to recover only until the cluster reaches consistency. In either case, the settings may be modified as desired. + +**Step 10:** Disable WAL archiving at this point. The BART `RESTORE` subcommand adds `archive_mode = off` to the end of the `postgresql.conf` file. + +- If you want to restart the database server with WAL archiving enabled, ensure that this additional parameter is deleted. +- The original `archive_mode` parameter still resides in the `postgresql.conf` file in its initial location with its last setting. + +**Step 11:** Start the database server to initiate recovery. After completion, check the database server log file to ensure the recovery was successful. + +If the backup is restored to a different location than where the original database cluster resided, operations dependent upon the database cluster location may fail if supporting service scripts are not updated to reflect the location where the backup has been restored. For information about the use and modification of service scripts, see the EDB Advanced Server Installation Guide available at the [EDB website](/epas/latest/). + +See [Restore](../03_basic_bart_subcommand_usage/08_restore/#restore) for more information about using the BART `Restore` subcommand. + +An example of a restore operation is documented in the EDB Backup and Recovery Reference Guide available at the [EDB website](/bart/latest/bart_ref/). + +!!! Note + If you set the [backup](../03_basic_bart_subcommand_usage/03_backup/#backup) `--checksum-algorithm=NONE` option, then you must specify the `--disable checksum` option while restoring a backup. diff --git a/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/01_bart_management_overview/02_point_in_time_recovery_operation.mdx b/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/01_bart_management_overview/02_point_in_time_recovery_operation.mdx new file mode 100644 index 00000000000..5d85c80281b --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/01_bart_management_overview/02_point_in_time_recovery_operation.mdx @@ -0,0 +1,51 @@ +--- +title: "Point-In-Time Recovery Operation" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/point_in_time_recovery_operation.html" +--- + + + +The following steps outline how to perform a point-in-time recovery operation for a database cluster: + +1. Use your system-specific command to shut down the database server. + +2. If you want to: + a. restore the database cluster and tablespace files to new, empty directories, create the new directories with the appropriate directory ownership and permissions. + b. reuse the existing database cluster directories, delete all the files and subdirectories in the existing directories. We strongly recommend that you make a copy of this data before deleting it. Be sure to save any recent WAL files in the `pg_wal` subdirectory ( `pg_xlog` subdirectory if you are using server 9.6 version) that have not been archived to `archive_path`. + +3. Run the BART `SHOW-BACKUPS -s ` subcommand to list the backup IDs and backup names of the backups for the database server. You will need to provide the appropriate backup ID or backup name with the BART `RESTORE` subcommand, unless you intend to restore the latest backup in which case the `-i` option of the `RESTORE` subcommand for specifying the backup ID or backup name may be omitted. + +4. Run the BART `RESTORE` subcommand with the appropriate options. + + - The backup is restored to the directory specified by the `-p restore_path` option. + + - In addition, if the `RESTORE` subcommand `-c` option is specified or if the enabled setting of the `copy_wals_during_restore` BART configuration parameter is applicable to the database server, then the required archived WAL files from the `archive_path` are copied to the `restore_path/archived_wals` subdirectory. + + - Ensure the `restore_path` directory and all subdirectories and files in the `restore_path` are owned by the proper Postgres user account (for example, `enterprisedb` or `postgres`). Also ensure that only the Postgres user account has access permission to the `restore_path` directory. + + Use the `chown` command to make the appropriate adjustments to file permissions; for example, the following command changes the ownership of `restore_path` to `enterprisedb`: + + `chown -R enterprisedb:enterprisedb restore_path` + + The following command restricts access to `restore_path`: + + `chmod 700 restore_path` + +5. Copy any saved WAL files from Step 2 that were not archived to the BART backup catalog to the `restore_path/pg_wal` subdirectory (`pg_xlog` subdirectory if you are using server 9.6 version). + +6. Identify the timeline ID you wish to use to perform the restore operation. + + The available timeline IDs can be identified by the first non-zero digit of the WAL file names reading from left to right. + +7. Verify that the `postgresql.auto.conf` file created in the directory specified with the `RESTORE` subcommand’s `-p ` option was generated with the correct recovery parameter settings. + + If the `RESTORE` subcommand `-c` option is specified or if the enabled setting of the `copy_wals_during_restore` BART configuration parameter is applicable to the database server, then the `restore_command` parameter retrieves the archived WAL files from the `/archived_wals` subdirectory that was created by the `RESTORE` subcommand, otherwise the `restore_command` retrieves the archived WAL files from the BART backup catalog. + +8. The BART `RESTORE` subcommand disables WAL archiving in the restored database cluster. If you want to immediately enable WAL archiving, modify the `postgresql.conf` file by deleting the `archive_mode = off` parameter that BART appends to the end of the file. + +9. Start the database server, which will then perform the point-in-time recovery operation if recovery settings are saved in the `postgresql.auto.conf` file. + +For a detailed description of the `RESTORE` subcommand, see [Basic BART Subcommand Usage](../03_basic_bart_subcommand_usage/#basic_bart_subcommand_usage). An example of a Point-in-Time Recovery operation is documented in the *EDB Backup and Recovery Reference Guide* available at the [EDB website](/bart/latest/bart_ref/). See [Restore](../03_basic_bart_subcommand_usage/08_restore/#restore) for more information about using the `Restore` subcommand. diff --git a/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/01_bart_management_overview/index.mdx b/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/01_bart_management_overview/index.mdx new file mode 100644 index 00000000000..4cb9c779397 --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/01_bart_management_overview/index.mdx @@ -0,0 +1,34 @@ +--- +title: "BART Management Overview" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/bart_management_overview.html" +--- + + + +After configuring BART, you can begin the backup and recovery management process. The following steps will help you get started: + +1. Run the `CHECK-CONFIG` subcommand without the `-s` option. When the `CHECK-CONFIG` subcommand is used without specifying the `-s` option, it checks the parameters in the global section of the BART configuration file. +2. Run the `INIT` subcommand (if you have not already done so) to finish creation of the BART backup catalog, which results in the complete directory structure to which backups and WAL files are saved. This step must be done before restarting the database servers with enabled WAL archiving, otherwise the copy operation in the `archive_command` parameter of the `postgresql.conf` file or the `postgresql.auto.conf` file fails due to the absence of the target archive directory. When the directory structure is complete, the `archived_wals` subdirectory should exist for each database server. +3. Start the Postgres database servers with archiving enabled. Verify that the WAL files are appearing in the `archive_path`. The archiving frequency is dependent upon other `postgresql.conf` configuration parameters. Check the Postgres database server log files to ensure there are no archiving errors. Archiving should be operational before taking a backup in order to ensure that the WAL files that may be created during the backup process are archived. +4. Start the WAL scanner if you intend to take incremental backups. Since the WAL scanner processes the WAL files copied to the `archive path`, it is advantageous to commence the WAL scanning as soon as the WAL files begin to appear in the `archive_path` in order to keep the scanning in pace with the WAL archiving. +5. Run the BART `CHECK-CONFIG` subcommand for each database server with the `-s` option specifying the server name. This ensures the database server is properly configured for taking backups. +6. Create a full backup for each database server. The full backup establishes the starting point of when point-in-time recovery can begin and also establishes the initial parent backup for any incremental backups to be taken. + +There are now a number of other BART management processes you may perform: + +- Execute the `BACKUP` subcommand to create additional full backups or incremental backups. +- Use the `VERIFY-CHKSUM` subcommand to verify the checksum of the full backups. +- Display database server information with the `SHOW-SERVERS` subcommand. +- Display backup information with the `SHOW-BACKUPS` subcommand. +- Compress the archived WAL files in the `archive_path` by enabling WAL compression in the BART configuration file and then invoking the `MANAGE` subcommand. +- Determine and set the retention policy for backups in the BART configuration file. +- Establish the procedure for using the `MANAGE` subcommand to enforce the retention policy for backups. This may include using `cron` jobs to schedule the `MANAGE` subcommand. + +
+ +performing_a_restore_operation point_in_time_recovery_operation + +
diff --git a/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/01_overview_managing_backups_using_a_retention_policy.mdx b/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/01_overview_managing_backups_using_a_retention_policy.mdx new file mode 100644 index 00000000000..7169d6f7bb6 --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/01_overview_managing_backups_using_a_retention_policy.mdx @@ -0,0 +1,23 @@ +--- +title: "Overview - Managing Backups Using a Retention Policy" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/overview_managing_backups_using_a_retention_policy.html" +--- + + + +The BART retention policy results in the categorization of each backup in one of three statuses – *active*, *obsolete*, and *keep*. + +- **Active.** The backup satisfies the retention policy applicable to its server. Such backups would be considered necessary to ensure the recovery safety for the server and thus should be retained. +- **Obsolete.** The backup does not satisfy the retention policy applicable to its server. The backup is no longer considered necessary for the recovery safety of the server and thus can be deleted. +- **Keep.** The backup is to be retained regardless of the retention policy applicable to its server. The backup is considered vital to the recovery safety for the server and thus should not be deleted for an indefinite period of time. + +There are two types of retention policies - redundancy retention policy and recovery window retention policy. + +- **Redundancy Retention Policy** - The [redundancy retention policy](03_setting_the_retention_policy/#redundancy-retention-policy) relies on a specified, maximum number of most recent backups to retain for a given server. When the number of backups exceeds that maximum number, the oldest backups are considered obsolete (except for backups marked as keep). +- **Recovery Window Retention Policy** - The [recovery window retention policy](03_setting_the_retention_policy/#recovery-window-retention-policy) relies on a time frame (the recovery window) for when a backup should be considered active. The boundaries defining the recovery window are the current date/time (the ending boundary of the recovery window) and the date/time going back in the past for a specified length of time (the starting boundary of the recovery window). + - If the date/time the backup was taken is within the recovery window (that is, the backup date/time is on or after the starting date/time of the recovery window), then the backup is considered active, otherwise it is considered obsolete (except for backups marked as keep). + - Thus, for the recovery window retention policy, the recovery window time frame dynamically shifts, so the end of the recovery window is always the current date/time when the `MANAGE` subcommand is run. As you run the `MANAGE` subcommand at future points in time, the starting boundary of the recovery window moves forward in time. At some future point, the date/time of when a backup was taken will be earlier than the starting boundary of the recovery window. This is when an active backup’s status will be considered obsolete. + - You can see the starting boundary of the recovery window at any point in time by running the `SHOW-SERVERS` subcommand. The `RETENTION POLICY` field of the `SHOW-SERVERS` subcommand displays the starting boundary of the recovery window. diff --git a/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/02_marking_the_backup_status.mdx b/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/02_marking_the_backup_status.mdx new file mode 100644 index 00000000000..047552d0a9e --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/02_marking_the_backup_status.mdx @@ -0,0 +1,25 @@ +--- +title: "Marking the Backup Status" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/marking_the_backup_status.html" +--- + + + +When a backup is initially created with the `BACKUP` subcommand, it is always recorded with active status. Use the `MANAGE` subcommand to evaluate if the backup status should be changed to obsolete in accordance with the retention policy. You can review the current status of your backups with the `SHOW-BACKUPS` subcommand. + +Active backups are evaluated and also marked (that is, internally recorded by BART) as obsolete only when the `MANAGE` subcommand is invoked either with no options or with only the `-s` option. + +Once a backup has been marked as obsolete, you cannot change it back to active unless you perform the following steps: + +- Use the `MANAGE` subcommand with the `-c` option along with the backup identifier or name with the `-i` option. To keep this particular backup indefinitely, use `-c keep`, otherwise use `-c nokeep`. +- If you use the `-c nokeep` option, the backup status is changed back to active. When the `MANAGE` subcommand is used the next time, the backup is re-evaluated to determine if its status needs to be changed back to obsolete based on the current retention policy in the BART configuration file. + +After setting the `retention_policy` parameter and running the `MANAGE` subcommand if you change the `retention_policy` parameter, the current, marked status of the backups are probably inconsistent with the new `retention_policy` setting. To modify the backup status to be consistent with the new `retention_policy` setting, you need to run the `MANAGE` subcommand with: + +- the `-c nokeep` option to change the obsolete status to active status if there are backups currently marked as obsolete that would no longer be considered obsolete under a new retention policy. You can also specify the `-i all` option to change all backups back to active status, including those currently marked as keep. +- no options or with only the `-s` option to reset the marked status based on the new `retention_policy` setting in the BART configuration file. + +See [MANAGE](../03_basic_bart_subcommand_usage/07_manage/#manage) for usage information for the `MANAGE` subcommand. diff --git a/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/03_setting_the_retention_policy.mdx b/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/03_setting_the_retention_policy.mdx new file mode 100644 index 00000000000..a4396239bfe --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/03_setting_the_retention_policy.mdx @@ -0,0 +1,82 @@ +--- +title: "Setting the Retention Policy" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/setting_the_retention_policy.html" +--- + + + +The retention policy is determined by the `retention_policy` parameter in the BART configuration file. It can be applied globally to all servers, but each server can override the global retention policy with its own. For information about creating a global retention policy and an individual database server retention policy, see the EDB Backup and Recovery Installation and Upgrade Guide available at the [EDB website](/bart/latest/bart_inst/). + +There are two types of retention policies - redundancy retention policy and the recovery window retention policy as described in the following sections. + + + +## Redundancy Retention Policy + +To use the redundancy retention policy, set `retention_policy = max_number BACKUPS` where `max_number` is a positive integer designating the maximum number of most recent backups. + +**Additional Restrictions:** + +- The keyword `BACKUPS` must always be specified in plural form (for example, `1 BACKUPS`). +- BART will accept a maximum integer value of 2,147,483,647 for `max_number`; however, you should use a realistic, practical value based on your system environment. + +The redundancy retention policy is the default type of retention policy if all keywords `BACKUPS`, `DAYS`, `WEEKS`, and `MONTHS` following the `max_number` integer are omitted as shown by the following example: + +`retention_policy = 3` + +In the following example, the redundancy retention policy setting considers the three most recent backups as the active backups. Any older backups, except those marked as `keep`, are considered obsolete: + +```text +[ACCTG] +host = 127.0.0.1 +port = 5444 +user = enterprisedb +archive_command = 'cp %p %a/%f' +retention_policy = 3 BACKUPS +description = "Accounting" +``` + +The `SHOW-SERVERS` subcommand displays the `3 Backups` redundancy retention policy in the `RETENTION POLICY` field: + +```bash +-bash-4.1$ bart SHOW-SERVERS -s acctg +SERVER NAME : acctg +HOST NAME : 127.0.0.1 +USER NAME : enterprisedb +PORT : 5444 +REMOTE HOST : +RETENTION POLICY : 3 Backups +DISK UTILIZATION : 627.04 MB +NUMBER OF ARCHIVES : 25 +ARCHIVE PATH : /opt/backup/acctg/archived_wals +ARCHIVE COMMAND : cp %p /opt/backup/acctg/archived_wals/%f +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +DESCRIPTION : "Accounting" +``` + + + +## Recovery Window Retention Policy + +To use the recovery window retention policy, set the `retention_policy` parameter to the desired length of time for the recovery window in one of the following ways: + +- Set to `max_number DAYS` to define the start date/time recovery window boundary as the number of days specified by `max_number` going back in time from the current date/time. +- Set to `max_number WEEKS` to define the start date/time recovery window boundary as the number of weeks specified by `max_number` going back in time from the current date/time. +- Set to `max_number MONTHS` to define the start date/time recovery window boundary as the number of months specified by `max_number` going back in time from the current date/time. + +**Additional Restrictions:** + +- The keywords `DAYS`, `WEEKS`, and `MONTHS` must always be specified in plural form (for example, `1 DAYS`, `1 WEEKS`, or `1 MONTHS`). +- BART will accept a maximum integer value of `2,147,483,647` for `max_number`, however, a realistic, practical value based on your system environment must always be used. + +A backup is considered active if the date/time of the backup is equal to or greater than the start of the recovery window date/time. + +You can view the actual, calculated recovery window by: + +- Invoking the `MANAGE` subcommand in debug mode, along with the `-n` option. +- Using the `SHOW-SERVERS` subcommand. diff --git a/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/04_managing_the_backups_based_on_the_retention_policy.mdx b/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/04_managing_the_backups_based_on_the_retention_policy.mdx new file mode 100644 index 00000000000..def779a4026 --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/04_managing_the_backups_based_on_the_retention_policy.mdx @@ -0,0 +1,147 @@ +--- +title: "Managing the Backups Based on the Retention Policy" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/managing_the_backups_based_on_the_retention_policy.html" +--- + + + +The [MANAGE](../03_basic_bart_subcommand_usage/07_manage/#manage) subcommand is used to evaluate and categorize backups according to the retention policy set in the BART configuration file. When a backup is first created with the `BACKUP` subcommand, it is `active`. You can use the `MANAGE` subcommand to change the status of an active backup to `obsolete`. Obsolete backups can then be deleted. + +This section covers following aspects of backup management: + +- The rules for [deleting backups](#deletions_permitted_under_retention_policy) depending upon the backup status and the subcommand used. +- The process to retain a backup indefinitely by [marking it as keep](#marking-backups-for-indefinite-keep-status). This section also provides information about resetting backups status (that are marked as `obsolete` and `keep`) back to active status. +- The general process for [evaluating, marking, and then deleting obsolete backups](#evaluating-marking-and-deleting-obsolete-backups). + + + +## Deletions Permitted Under a Retention Policy + +This section describes how and under what conditions backups may be deleted under a retention policy. + +You must use the `MANAGE` subcommand to delete obsolete backups. Use the `DELETE` subcommand only for special administrative purposes. + +The deletion behavior of the `MANAGE` subcommand and the `DELETE` subcommand are based on different aspects of the retention policy. + +- The `MANAGE` subcommand deletion relies solely upon how a backup status is currently marked (that is, internally recorded by BART). The current setting of the `retention_policy` parameter in the BART configuration file is ignored. +- The `DELETE` subcommand relies solely upon the current setting of the `retention_policy` parameter in the BART configuration file. The current active, obsolete, or keep status of a backup is ignored. + +The specific deletion rules for the `MANAGE` and `DELETE` subcommands are as follows: + +- `MANAGE` subcommand: The `MANAGE` subcommand with the `-d` option can only delete backups marked as obsolete. This deletion occurs regardless of the current `retention_policy` setting in the BART configuration file. The deletion of backups relies on the last occasion when the backups have been marked. +- `DELETE` subcommand: + + - Under a redundancy retention policy currently set with the `retention_policy` parameter in the BART configuration file, any backup regardless of its marked status, can be deleted with the `DELETE` subcommand when the backup identifier or name is specified with the `-i` option and if the current total number of backups for the specified database server is greater than the maximum number of redundancy backups currently specified with the `retention_policy` parameter. + + If the total number of backups is less than or equal to the specified, maximum number of redundancy backups, then no additional backups can be deleted using `DELETE` with the `-i backup` option. + + - Under a recovery window retention policy currently set with the `retention_policy` parameter in the BART configuration file, any backup regardless of its marked status, can be deleted with the `DELETE` subcommand when the backup identifier or name is specified with the `-i` option, and if the backup date/time is not within the recovery window currently specified with the `retention_policy` parameter. If the backup date/time is within the recovery window, then it cannot be deleted using `DELETE` with the `-i backup` option. + + - Invoking the `DELETE` subcommand with the `-i all` option results in the deletion of all backups regardless of the retention policy and regardless of whether the status is marked as active, obsolete, or keep. + +The following table summarizes the deletion rules of backups according to their marked status. An entry of `Yes` indicates the backup may be deleted under the specified circumstances. An entry of `No` indicates that the backup may not be deleted. + + ++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
OperationRedundancy Retention PolicyRecovery Window Retention Policy
ActiveObsoleteKeepActiveObsoleteKeep
MANAGE –dNoYesNoNoYesNo
DELETE –i *backup* +

Yes

+

(see Note 1)

+
+

Yes

+

(see Note 1)

+
+

Yes

+

(see Note 1_)

+
+

Yes

+

(see Note 2

+
+

Yes

(see Note 2 +
+

Yes

(see Note 2) +
DELETE –i allYesYesYesYesYesYes
+ + + +!!! Note + Redundancy Retention Policy (Note 1) : Deletion occurs only if the total number of backups for the specified database server is greater than the specified, maximum number of redundancy backups currently set with the `redundancy_policy` parameter in the BART configuration file. + + + +!!! Note + Recovery Window Retention Policy (Note 2): Deletion occurs only if the backup is not within the recovery window currently set with the `redundancy_policy` parameter in the BART configuration file. + + + +## Marking Backups for Indefinite Keep Status + +There may be certain backups that you wish to keep for an indefinite period of time and do not wish to delete based upon the retention policy applied to the database server. Such backups can be marked as `keep` to exclude them from being marked as obsolete. Use the `MANAGE` subcommand with the `-c keep` option to retain such backups indefinitely. + + + +## Evaluating, Marking, and Deleting Obsolete Backups + +When the `MANAGE` subcommand is invoked, BART evaluates active backups: + +- If you include the `-s` option when invoking the `MANAGE` subcommand, BART evaluates backups for the database server. +- If you include the `-s all` option when invoking the `MANAGE` subcommand, BART evaluates backups for all database servers. +- If the `-s` option is omitted, the command evaluates the current number of backups for the database server based on the redundancy retention policy or the current date/time for a recovery window retention policy. + +!!! Note + The status of backups currently marked as `obsolete` or `keep` is not changed. To re-evaluate such backups and then classify them, their status must first be reset to `active` with the `MANAGE -c nokeep` option. See [Marking the Backup Status](02_marking_the_backup_status/#marking_the_backup_status) for more information. + +See the *EDB Backup and Recovery Reference Guide* available at the [EDB website](/bart/latest/bart_ref/) to review examples of how to evaluate, mark, and delete backups using a redundancy retention policy and recovery window retention policy, as well as examples of `MANAGE` subcommand. diff --git a/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/05_managing_incremental_backups.mdx b/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/05_managing_incremental_backups.mdx new file mode 100644 index 00000000000..c69f6b09086 --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/05_managing_incremental_backups.mdx @@ -0,0 +1,51 @@ +--- +title: "Managing Incremental Backups" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/managing_incremental_backups.html" +--- + + + +The following section summarizes how retention policy management affects incremental backups. + +- The retention policy rules are applied to full backups. + - A redundancy retention policy uses the number of full backups to determine if a backup is obsolete. Incremental backups are excluded from the comparison count against the `retention_policy` setting for the maximum number of backups. + - A recovery window retention policy uses the backup date/time of any full backups to determine if a backup is obsolete. The backup date/time of any successive incremental backups in the chain are ignored when comparing with the recovery window. +- The retention status of all incremental backups in a chain is set to the same status applied to the full backup of the chain. +- The actions applied by the `MANAGE` and `DELETE` subcommands on a full backup are applied to all incremental backups in the chain in the same manner. +- Thus, a backup chain (that is, the full backup and all its successive incremental backups) are treated by retention policy management as if they are all one, single backup. + - The status setting applied to the full backup is also applied to all incremental backups in its chain. + - If a full backup is marked as obsolete and then deleted according to the retention policy, all incremental backups in the chain are also marked obsolete and then deleted as well. + +The following are some specific points regarding the `MANAGE` and `DELETE` subcommands on incremental backups. + +- `MANAGE` subcommand: + - When the `MANAGE` subcommand is invoked, the status applied to the full backup is also applied to all successive incremental backups in the chain. + - The `MANAGE` subcommand with the `-c { keep | nokeep}` option cannot specify the backup identifier or backup name of an incremental backup with `-i` backup option. The `-i` backup option can only specify the backup identifier or backup name of a full backup. + - You can also use the `-i` all option to take a backup of all backups. When the `MANAGE` subcommand with the `-c { keep | nokeep }` option is applied to a full backup, the same status change is made to all incremental backups in the chain. +- `DELETE` subcommand: + - The `DELETE` subcommand with the `-s server -i` backup option specifies the backup identifier or backup name of an incremental backup in which case that incremental backup along with all its successive incremental backups are deleted, thus shortening that backup chain. + +## Using a Redundancy Retention Policy with Incremental Backups + +When a [redundancy retention policy](03_setting_the_retention_policy/#redundancy-retention-policy) is used and the `MANAGE` subcommand is invoked, the status of the oldest `active` full backup is changed to `obsolete` if the number of full backups exceeds the maximum number specified by the `retention_policy` parameter in the BART configuration file. + +!!! Note + When a full backup is changed from `active` to `obsolete`, all successive incremental backups in the chain of the full backup are also changed from `active` to `obsolete`. + +When determining the number of backups that exceeds the number specified by the `retention_policy` parameter, only full backups are counted for the comparison. Incremental backups are not included in the count for the comparison against the `retention_policy` parameter setting. + +See the *EDB Backup and Recovery Reference Guide* available at the [EDB website](/bart/latest/bart_ref/) for examples demonstrating use of the `MANAGE` and `DELETE` subcommands when a redundancy retention policy is in effect. + +## Using a Recovery Window Retention Policy with Incremental Backups + +If the `MANAGE` command is invoked when BART is configured to use a [recovery window retention policy](03_setting_the_retention_policy/#recovery-window-retention-policy), the status of `active` full backups are changed to `obsolete` if the date/time of the full backup is outside of the recovery window. + +!!! Note + If a full backup is changed from `active` to `obsolete`, all successive incremental backups in the chain of the full backup are also changed from `active` to `obsolete`. + +The status of an incremental backup is changed to `obsolete` regardless of whether or not the date/time of when the incremental backup was taken still lies within the recovery window. + +See the *EDB Backup and Recovery Reference Guide* available at the [EDB website](/bart/latest/bart_ref/) for examples demonstrating use of the `MANAGE` and `DELETE` subcommands when a recovery window retention policy is in effect. diff --git a/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/index.mdx b/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/index.mdx new file mode 100644 index 00000000000..aff92bbd6a5 --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/index.mdx @@ -0,0 +1,27 @@ +--- +title: "Managing Backups Using a Retention Policy" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/managing_backups_using_a_retention_policy.html" +--- + + + +Over the course of time when using BART, the number of backups can grow significantly. This ultimately leads to a large consumption of disk space unless an administrator periodically performs the process of deleting the oldest backups that are no longer needed. This process of determining when a backup is old enough to be deleted and then actually deleting such backups can be done and automated with the following basic steps: + +1. Determine and set a retention policy in the BART configuration file. A *retention policy* is a rule that determines when a backup is considered obsolete. The retention policy can be applied globally to all servers, but each server can override the global retention policy with its own. + +2. Use the `MANAGE` subcommand to categorize and manage backups according to the retention policy. + +3. Create a cron job to periodically run the `MANAGE` subcommand to evaluate the backups and then list and/or delete the obsolete backups. + + Retention policy management applies differently to incremental backups than to full backups. See [Managing Incremental Backups](05_managing_incremental_backups/#managing_incremental_backups) for information about how retention policy management is applied to each backup type. + + The following sections describe how retention policy management generally applies to backups, and its specific usage and effect on full backups. + +
+ +overview_managing_backups_using_a_retention_policy marking_the_backup_status setting_the_retention_policy managing_the_backups_based_on_the_retention_policy managing_incremental_backups + +
diff --git a/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/03_basic_bart_subcommand_usage/01_check_config.mdx b/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/03_basic_bart_subcommand_usage/01_check_config.mdx new file mode 100644 index 00000000000..f12dd038edd --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/03_basic_bart_subcommand_usage/01_check_config.mdx @@ -0,0 +1,35 @@ +--- +title: "CHECK-CONFIG" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/check_config.html" +--- + + + +The `CHECK-CONFIG` subcommand checks the parameter settings in the BART configuration file as well as the database server configuration for which the `-s` option is specified. + +**Syntax:** + +`bart CHECK-CONFIG [ –s server_name ]` + +The following table describes the option. + +| Options | Description | +| ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s ` or `--server ` | `server_name` is the name of the database server to be checked for proper configuration. If the option is omitted, the settings of the global section of the BART configuration file are checked. | + +- When the `-s` option is omitted, the global section \[BART] parameters including `bart_host`, `backup_path`, and `pg_basebackup_path` are checked. +- When the `-s` option is specified, the server section parameters are checked. In addition, certain database server `postgresql.conf` parameters are also checked, which include the following: + - The `cluster_owner` parameter must be set to the user account owning the database cluster directory. + - A passwordless SSH/SCP connection must be set between the BART user and the user account specified by the `cluster_owner` parameter. + - A database superuser must be specified by the BART `user` parameter. + - The `pg_hba.conf` file must contain a replication entry for the database superuser specified by the BART `user` parameter. + - The `archive_mode` parameter in the `postgresql.conf` file must be enabled. + - The `archive_command` parameter in the `postgresql.auto.conf` or the `postgresql.conf` file must be set. + - The `allow_incremental_backups` parameter in the BART configuration file must be enabled for database servers for which incremental backups are to be taken. + - Archiving of WAL files to the `archive_path` must be in process. + - The WAL scanner program must be running. + +The `CHECK-CONFIG` subcommand displays an error message if the required configuration is not properly set. diff --git a/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/03_basic_bart_subcommand_usage/02_init.mdx b/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/03_basic_bart_subcommand_usage/02_init.mdx new file mode 100644 index 00000000000..d8cdeed8126 --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/03_basic_bart_subcommand_usage/02_init.mdx @@ -0,0 +1,41 @@ +--- +title: "INIT" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/init.html" +--- + + + +The `INIT` subcommand is used to create the BART backup catalog directory, rebuild the BART `backupinfo` file, and set the `archive_command` in the PostgreSQL server based on the `archive_command` setting in the `bart.cfg` file. + +!!! Note + If the `archive_mode` configuration parameter is set to `off`, then the `-o` option must be used to set the Postgres `archive_command` using the BART `archive_command` parameter in the BART configuration file even if the `archive_command` is not currently set in `postgresql.conf` nor in `postgresql.auto.conf` file. + +**Syntax:** + +```text +bart INIT [ –s { | all } ] [ -o ] + [ -r [ -i { | | all } ] ] + [--no-configure] +``` + +All subcommand options are generally specified in lowercase. The following table describes the command options: + +| Options | Description | +| ------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { \| all }`

`--server { \| all }` | `server_name` is the name of the database server to which the `INIT` actions are to be applied. If `all` is specified or if the option is omitted, the actions are applied to all servers. | +| `-o`

`--override` | Overrides the existing, active Postgres `archive_command` configuration parameter setting in the `postgresql.conf` file or the `postgresql.auto.conf` file using the BART `archive_command` parameter in the BART configuration file. The `INIT` generated archive command string is written to the `postgresql.auto.conf` file. | +| `-r`

`--rebuild` | Rebuilds the backupinfo file (a text file named `backupinfo`) located in each backup subdirectory. This option is only intended for recovering from a situation where the backupinfo file has become corrupt.
If the backup was initially created with a user-defined backup name, and then the `INIT -r` option is invoked to rebuild that `backupinfo` file, the user-defined backup name is no longer available. Thus, future references to the backup must use the backup identifier. | +| `-i { \| \| all }`

`--backupid { \| \| all }` | `` is an integer, backup identifier and `` is the user-defined alphanumeric name for the backup. If `all` is specified or if the option is omitted, the backupinfo files of all backups for the database servers specified by the `-s` option are recreated. The `-i` option can only be used with the `-r` option. | +| `--no-configure` | Prevents the `archive_command` from being set in the PostgreSQL server. | + +**Archive Command Setting** + +After the `archive_command` is set, you need to either restart the PostgreSQL server or reload the configuration file in the PostgreSQL server based on the following conditions. + +- If the `archive_mode` is set to `off` and `archive_command` is not set in the PostgreSQL server, the `archive_command` is set based on the `archive_command` setting in the `bart.cfg` and also sets the `archive_mode` to `on`. In this case, you need to restart the PostgreSQL server using `pg_ctl restart` +- If the `archive_mode` is set to `on` and `archive_command` is not set in the PostgreSQL server, the `archive_command` is set based on the `archive_command` setting in the `bart.cfg`. In this case, you need to reload the configuration in the PostgreSQL server using `pg_reload_conf()` or `pg_ctl reload`. +- If the `archive_mode` is set to `off` and `archive_command` is already set in the PostgreSQL server, the `archive_mode` is set to on. In this case, you need to restart the PostgreSQL server using `pg_ctl restart` +- If the `archive_mode` is set to `on` and `archive_command` is already set in the PostgreSQL server, then the `archive_command` is not set unless `-o` option is specified. diff --git a/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/03_basic_bart_subcommand_usage/03_backup.mdx b/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/03_basic_bart_subcommand_usage/03_backup.mdx new file mode 100644 index 00000000000..0189291fe44 --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/03_basic_bart_subcommand_usage/03_backup.mdx @@ -0,0 +1,106 @@ +--- +title: "BACKUP" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/backup.html" +--- + + + +The `BACKUP` subcommand is used to create a full backup or an incremental backup. + +**Syntax for full backup:** + +```text +bart BACKUP –s { | all } [ -F { p | t } ] + [ -z ] [ –c ] + [ --backup-name ] + [ --thread-count ] + [ { --with-pg_basebackup | --no-pg_basebackup } ] +``` + +!!! Note + While taking a backup, if a file (for example, database server log file) exceeding 1 GB size is stored in the `$PGDATA` directory, the backup will fail. To avoid such backup failure, you need to store large files (exceeding 1 GB) outside the `$PGDATA` directory. + +**Syntax for incremental Backup:** + +```text +bart BACKUP –s { | all } [ -F p] + [ --parent { | } ] + [ --backup-name ] + [ --thread-count ] + [ --check ] + [--checksum-algorithm ] +``` + +!!! Note + To take an [incremental backup](../../02_overview/01_block-level_incremental_backup/#block-level_incremental_backup), you must take a full backup first followed by incremental backup. + +**Please Note:** + +- While a `BACKUP` subcommand is in progress, no other subcommands must be invoked. Any subcommands invoked while a backup is in progress will skip and ignore the backups. + +- For full backup, the target default format is a tar file, whereas for incremental backup, only plain format must be specified. + +- The backup is saved in the `//` directory, where `` is the value assigned to the `` parameter in the BART configuration file, `` is the lowercase name of the database server as listed in the configuration file, and `` is a backup identifier assigned by BART to the particular backup. + +- MD5 checksums of the full backup and any user-defined tablespaces are saved as well for tar backups. + +- Before performing the backup, BART checks to ensure if there is enough disk space to completely store the backup in the BART backup catalog. + +- In the `postgresql.conf` file, ensure the `wal_keep_segments` configuration parameter is set to a sufficiently large value. A low setting of the `wal_keep_segments` configuration parameter may result in the deletion of some WAL files before the BART `BACKUP` subcommand saves them to the `archive_path`. For information about the `wal_keep_segments` parameter, see the [PostgreSQL Core Documentation](https://www.postgresql.org/docs/current/static/runtime-config-replication.html). + +- In the BART configuration file, setting `xlog_method=stream` will instruct the server to stream the transaction log in parallel with creation of the backup for a specific database server; otherwise the transaction log files are collected upon completion of the backup. See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/latest/bart_inst/) for details about database server setting. + + !!! Note + If the transaction log streaming method is used, the `-Fp` option for a plain text backup format must be specified with the `BACKUP` subcommand. + +- When you use BART to take a backup of PostgreSQL server, multiple backups can be taken simultaneously and if a backup is interrupted, the backup mode is terminated automatically without the need to run `pg_stop_backup()` command manually to terminate the backup. + +**Options** + +Along with the `BACKUP` subcommand, specify the following option: + +| Options | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { server_name \| all }`
`--server { server_name \| all }` | `server_name` is the database server name to be backed up as specified in the BART configuration file. If `all` is specified, all servers are backed up. This option is mandatory.
If `all` is specified, and a connection to a database server listed in the BART configuration file cannot be opened, the backup for that database server is skipped, but the backup operation continues for the other database servers. | + +Specify the following options as required. If you do not specify any of the following options, the backup is created using default settings. + +| Options | Description | +| -------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-F { p \| t }`
`--format { p \| t }` | Specify this option to provide the backup file format. Use `p` for plain text or `t` for tar. If the option is omitted, the default is tar format.
For taking incremental backups, the option `-Fp` must be specified. | +| `-z`
`--gzip` | This is applicable only for full backup. Specify this option to use gzip compression on the tar file output using the default compression level. This option is applicable only for the tar format. | +| `-c `
`--compress-level ` | This is applicable only for full backup. Specify this option to use the gzip compression level on the tar file output. `compression_level` is a digit from 1 through 9, with 9 being the best compression. This option is applicable only for the tar format. | +| `--parent { backup_id \| backup_name }` | Specify this option to take an incremental backup. `` is the backup identifier of a parent backup. `` is the user-defined alphanumeric name of a parent backup.
The parent is a backup taken prior to the incremental backup. The parent backup can be either a full backup or an incremental backup.
The option `–Fp` must be specified since an incremental backup can only be taken in plain text format.
An incremental backup cannot be taken on a standby database server. See [Block-Level Incremental Backup](../../02_overview/01_block-level_incremental_backup/#block-level_incremental_backup) for additional information on incremental backups. | +| `--backup-name ` | Specify this option to assign a user-defined, alphanumeric friendly name to the backup. The maximum permitted length of backup name is 49 characters.
The backup name may include the following variables to be substituted by the timestamp values when the backup is taken: 1) `%year` – 4-digit year, 2) `%month` – 2-digit month, 3) `%day` – 2-digit day, 4) `%hour` 2-digit hour, 5) `%minute` – 2-digit minute, and 6) `%second` – 2-digit second.
To include the percent sign (`%`) as a character in the backup name, specify `%%` in the alphanumeric string.
If the backup name contains space characters (i.e. more than one word) or when referenced with the option `-i` by other subcommands (such as `restore`), enclose the string in single quotes or double quotes. See [backup name examples](#backup_name_examples).
If the `--backup-name` option is not specified, and the `backup_name` parameter is not set for this database server in the BART configuration file, then the backup can only be referenced in other BART subcommands by the BART assigned backup identifier. | +| `--thread-count ` | Use this option to use the number of worker threads to run in parallel to copy blocks for a backup.
If the option `--thread-count` is omitted, then the `thread_count` parameter in the BART configuration file applicable to this database server is used.
If the option `--thread-count` is not enabled for this database server, then the `thread_count` setting in the global section of the BART configuration file is used.
If the option `--thread-count` is not set in the global section as well, the default number of threads is 1.
If parallel backup is run with N number of worker threads, then it will initiate N+ 1 concurrent connections with the server.
Thread count will not be effective if backup is taken on a standby server.
For more information about the `--thread-count` parameter, see the EDB Backup and Recovery Installation and Upgrade Guide available at the [EDB website](/bart/latest/bart_inst/) | +| `--with-pg_basebackup` | This is applicable only for full backup. Specify this option to use `pg_basebackup` to take a full backup. The number of thread counts in effect is ignored as given by the `thread_count` parameter in the BART configuration file.
When taking a full backup, if the thread count in effect is greater than `1`, then the `pg_basebackup` utility is not used to take the full backup (parallel worker threads are used) unless the option `--with-pg_basebackup` is specified with the `BACKUP` subcommand. | +| `--no-pg_basebackup` | This is applicable only for full backup. Specify this option if you do not want `pg_basebackup` to be used to take a full backup.
When taking a full backup, if the thread count in effect is only `1`, then the `pg_basebackup` utility is used to take the full backup unless the option `--no-pg_basebackup` is specified with the `BACKUP` subcommand. | +| `--check` | This is applicable only for incremental backup. Specify this option to verify if the required MBM files are present in the `archived_wals` directory as specified in the `archive_path` parameter in the `bart.cfg` file before taking an incremental backup. The option `--parent` must be specified when the option `--check` is used. An actual incremental backup is not taken when the option `--check` is specified. | +| `--checksum-algorithm` | While taking a backup, you can specify one of the following values with the `--checksum-algorithm` option:
`--checksum-algorithm=MD5` (default) to generate MD5 checksum files.
`--checksum-algorithm=SHA256` to generate SHA256 checksum files.
`--checksum-algorithm=NONE` to skip generating checksum files. | + + + +**Backup Name Examples** + +The following examples demonstrate using the `--backup-name` clause: + +```text +./bart backup -s ppas12 -Ft --backup-name "YEAR = %year +MONTH = %month DAY = %day" +./bart backup -s ppas12 -Ft --backup-name "YEAR = %year +MONTH = %month DAY = %day %%" +./bart show-backups -s ppas12 -i "test backup" +``` + +**Error messages** + +The following table lists the error messages that may be encountered when using the `BACKUP` subcommand: + +| error message | Cause | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `edb@localhost bin]$ ./bart backup -s mktg -Ft`

`WARNING: xlog_method is empty, defaulting to global policy`

`ERROR: backup failed for server 'mktg'`

`free disk space is not enough to backup the server 'mktg'`

`space available 13.35 GB, approximately required 14.65 GB` | Insufficient free disk space. | +| `ERROR: backup failed for server 'mktg'`

`command failed with exit code 1`

`pg_basebackup: could not get transaction log end position from server: ERROR: requested WAL segment 00000001000000D50000006B has already been removed` | The wal_keep_segments configuration parameter is not set to a sufficiently large value in the postgresql.conf file. | +| `ERROR: backup failed for server 'mktg'`

`connection to the server failed: could not connect to server: Connection refused`

`Is the server running on host "172.16.114.132" and accepting`

`TCP/IP connections on port 5444?` | A connection to a database server listed in the BART configuration file fails. As a result the backup for that database server is skipped, but the backup operation continues for other database servers | diff --git a/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/03_basic_bart_subcommand_usage/04_show_servers.mdx b/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/03_basic_bart_subcommand_usage/04_show_servers.mdx new file mode 100644 index 00000000000..778efd3d4d6 --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/03_basic_bart_subcommand_usage/04_show_servers.mdx @@ -0,0 +1,21 @@ +--- +title: "SHOW-SERVERS" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/show_servers.html" +--- + + + +The `SHOW-SERVERS` subcommand displays the information for the managed database servers listed in the BART configuration file. + +**Syntax:** + +`bart SHOW-SERVERS [ –s { | all } ]` + +The following table describes the command options. + +| Options | Description | +| ---------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { \| all }`
`--server { \| all }` | `` is the name of the database server whose BART configuration information is to be displayed. If `all` is specified or if the option is omitted, information for all database servers is displayed. | diff --git a/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/03_basic_bart_subcommand_usage/05_show_backups.mdx b/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/03_basic_bart_subcommand_usage/05_show_backups.mdx new file mode 100644 index 00000000000..d006df69db1 --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/03_basic_bart_subcommand_usage/05_show_backups.mdx @@ -0,0 +1,25 @@ +--- +title: "SHOW-BACKUPS" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/show_backups.html" +--- + +The `SHOW-BACKUPS` subcommand displays the backup information for the managed database servers. + +**Syntax:** + +```text +bart SHOW-BACKUPS [ –s { | all } ] + [ -i { | | all } ] + [ -t ] +``` + +The following table describes the command options: + +| Options | Description | +| ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { \| all }`
`--server { \| all }` | `` is the name of the database server whose backup information is to be displayed.
If `all` is specified or if the option is omitted, the backup information for all database servers is displayed with the exception as described by the following note:
If `SHOW-BACKUPS` is invoked while the BART `BACKUP` subcommand is in progress, backups affected by the backup process are shown in progress status in the displayed backup information. | +| `-i { \| \| all }`
`--backupid { \| \| all }` | `` is a backup identifier and `` is the user-defined alphanumeric name for the backup.
If `all` is specified or if the option is omitted, all backup information for the relevant database server is displayed. | +| `-t`
`--toggle` | Displays more backup information in a list format. If the option is omitted, the default is a tabular format. | diff --git a/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/03_basic_bart_subcommand_usage/06_verify_chksum.mdx b/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/03_basic_bart_subcommand_usage/06_verify_chksum.mdx new file mode 100644 index 00000000000..4ec79d52d62 --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/03_basic_bart_subcommand_usage/06_verify_chksum.mdx @@ -0,0 +1,29 @@ +--- +title: "VERIFY-CHKSUM" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/verify_chksum.html" +--- + + + +The `VERIFY-CHKSUM` subcommand verifies the MD5 checksums of the full backups and any user-defined tablespaces for the specified database server or for all database servers. The checksum is verified by comparing the current checksum of the backup against the checksum when the backup was taken. + +!!! Note + The `VERIFY-CHKSUM` subcommand is only used for tar format backups. It is not applicable to plain format backups. + +**Syntax:** + +```text +bart VERIFY-CHKSUM + [ -s { | all } ] + [ -i { | | all } ] +``` + +The following table describes the command options: + +| Options | Description | +| ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { \| all }`

`--server { \| all }` | `` is the name of the database server whose tar backup checksums are to be verified. If `all` is specified or if the `-s` option is omitted, the checksums are verified for all database servers. | +| `-i { \| \| all }`

`--backupid { \| \| all }` | `` is the backup identifier of a tar format full backup whose checksum is to be verified along with any user-defined tablespaces.
`` is the user-defined alphanumeric name for the full backup.
If `all` is specified or if the `-i` option is omitted, the checksums of all tar backups for the relevant database server are verified. | diff --git a/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/03_basic_bart_subcommand_usage/07_manage.mdx b/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/03_basic_bart_subcommand_usage/07_manage.mdx new file mode 100644 index 00000000000..52a74badaa7 --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/03_basic_bart_subcommand_usage/07_manage.mdx @@ -0,0 +1,62 @@ +--- +title: "MANAGE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/manage.html" +--- + + + +The `MANAGE` subcommand can be invoked to: + +- Evaluate backups, mark their status, and delete obsolete backups based on the `retention_policy` parameter in the BART configuration file (See [Managing Backups Using a Retention Policy](../02_managing_backups_using_a_retention_policy/#managing_backups_using_a_retention_policy) for information about retention policy management). + +- Compress the archived WAL files based on the `wal_compression` parameter in the BART configuration file (See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/latest/bart_inst/) for information about setting this parameter). + + **Syntax:** + + ```text + bart MANAGE [ –s { | all} ] + [ -l ] [ -d ] + [ -c { keep | nokeep } + -i { | | all } ] + [ -n ] + ``` + +The following summarizes the actions performed when the `MANAGE` subcommand is invoked: + +- When the `MANAGE` subcommand is invoked with no options or with only the `-s ` or `-s all` option, the following actions are performed: + - For the server specified by the `-s` option, or for all servers (if `-s all` is specified or the `-s` option is omitted), active backups are marked as `obsolete` in accordance with the retention policy. + - All backups that were marked `obsolete` or `keep` prior to invoking the `MANAGE` subcommand remain marked with the same prior status. + - If WAL compression is enabled for the database server, then any uncompressed, archived WAL files in the BART backup catalog of the database server are compressed with gzip. +- When the `MANAGE` subcommand is invoked with any other option besides the `-s` option, the following actions are performed: + - For the server specified by the `-s` option, or for all servers, the action performed is determined by the other specified options (that is, `-l` to list obsolete backups, `-d` to delete obsolete backups, `-c` to keep or to return backups to `active` status, or `-n` to perform a dry run of any action). + - No marking of `active` backups to `obsolete` status is performed regardless of the retention policy. + - All backups that were marked `obsolete` or `keep` prior to invoking the `MANAGE` subcommand remain marked with the same prior status unless the `-c` option (without the `-n` option) is specified to change the backup status of the particular backup or all backups referenced with the `-i` option. + - No compression is applied to any uncompressed, archived WAL file in the BART backup catalog regardless of whether or not WAL compression is enabled. + +The following are additional considerations when using WAL compression: + +- Compression of archived WAL files is not permitted for database servers on which incremental backups are to be taken. +- The gzip compression program must be installed on the BART host and be accessible in the `PATH` of the BART user account. +- When the `RESTORE` subcommand is invoked, if the `-c` option is specified or if the `copy_wals_during_restore` BART configuration parameter is enabled for the database server, then the following actions occur: + + - If compressed, archived WAL files are stored in the BART backup catalog and the location to which the WAL files are to be restored is on a remote host relative to the BART host: + + - the archived WAL files are transmitted across the network to the remote host in compressed format only if the gzip compression program is accessible in the `PATH` of the remote user account that is used to log into the remote host when performing the `RESTORE` operation. + - This remote user is specified with either the `remote_host` parameter in the BART configuration file or the `RESTORE -r` option (see [RESTORE](08_restore/#restore)). + - Transmission of compressed WAL files results in less network traffic. After the compressed WAL files are transmitted across the network, the `RESTORE` subcommand uncompresses the files for the point-in-time recovery operation. + - If the gzip program is not accessible on the remote host in the manner described in the previous bullet point, then the compressed, archived WAL files are first uncompressed while on the BART host, then transmitted across the network to the remote host in uncompressed format. +- When the `RESTORE` subcommand is invoked without the `-c` option and the `copy_wals_during_restore` BART configuration parameter is disabled for the database server, then any compressed, archived WAL files needed for the `RESTORE` operation are uncompressed in the BART backup catalog. The uncompressed WAL files can then be saved to the remote host by the `restore_command` in the `postgresql.auto.conf` file when the database server archive recovery begins. + +The following table describes the command options: + +| Options | Description | +| ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `s { \| all }`
`--server { \| all }` | `` is the name of the database server to which the actions are to be applied. If `all` is specified or if the `-s` option is omitted, the actions are applied to all database servers. | +| `-l`
`--list-obsolete` | Lists the backups marked as obsolete. | +| `-d`
`--delete-obsolete` | Delete the backups marked as `obsolete`. This action physically deletes the backup along with its archived WAL files and any MBM files for incremental backups. | +| `-c { keep \| nokeep }`

`--change-status { keep \| nokeep }` | Specify `keep` to change the status of a backup to `keep` to retain it indefinitely.
Specify `nokeep` to change the status of any backup back to active status. The backup can then be re-evaluated and possibly be marked to `obsolete` according to the retention policy by subsequent usage of the `MANAGE` subcommand.
The `–i` option must be included when using the `-c` option. | +| `-i { \| \| all }`

`--backupid { \| \| all }` | `` is a backup identifier and `` is the user-defined alphanumeric name for the backup.
If `all` is specified, then actions are applied to all backups.
The `–c` option must be included when using the `-i` option. | +| `-n`
`--dry-run` | Performs the test run and displays the results prior to actually implementing the actions as if the operation was performed, however, no changes are actually made.
If `-n` is specified with the `-d` option, it displays which backups would be deleted, but does not actually delete the backups.
If `-n` is specified with the `-c` option, it displays the keep or nokeep action, but does not actually change the backup from its current status.
If `-n` is specified alone with no other options, or with only the `-s` option, it displays which active backups would be marked as obsolete, but does not actually change the backup status. In addition, no compression is performed on uncompressed, archived WAL files even if WAL compression is enabled for the database server. | diff --git a/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/03_basic_bart_subcommand_usage/08_restore.mdx b/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/03_basic_bart_subcommand_usage/08_restore.mdx new file mode 100644 index 00000000000..a7fc6fc64ab --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/03_basic_bart_subcommand_usage/08_restore.mdx @@ -0,0 +1,48 @@ +--- +title: "RESTORE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/restore.html" +--- + + + +The `RESTORE` subcommand restores a backup and its archived WAL files for the designated database server to the specified directory location. If the appropriate `RESTORE` options are specified, all recovery settings will be saved in the `postgresql.auto.conf` file. + +**Syntax:** + +```text +bart RESTORE –s -p + [ –i { | } ] + [ -r ] + [ -w ] + [ -t ] + [ { -x | -g } ] + [ -c ] + [ --disable-checksum ] +``` + +For information about using a continuous archive backup for recovery, see the [PostgreSQL Core Documentation](https://www.postgresql.org/docs/13/static/continuous-archiving.html). This reference material provides detailed information about the underlying point-in-time recovery process and the meaning and usage of the restore options that are generated into the `postgresql.auto.conf` file by BART. + +**Please note**: + +- For special requirements when restoring an incremental backup to a remote database server, see [Restoring an Incremental Backup on a Remote Host](../../02_overview/01_block-level_incremental_backup/05_restoring_an_incremental_backup/#restoring_an_incremental_backup_on_a_remote_host). +- Check to ensure that the host where the backup is to be restored contains enough disk space for the backup and its archived WAL files. The `RESTORE` subcommand may result in an error while copying files if there is not enough disk space available. +- See [Performing a Restore Operation](../01_bart_management_overview/01_performing_a_restore_operation/#performing_a_restore_operation) to view steps on how to perform a restore operation and see [Point-In-Time Recovery Operation](../01_bart_management_overview/02_point_in_time_recovery_operation/#point_in_time_recovery_operation) to view steps on how to perform a point-in-time recovery operation. +- If the backup is restored to a different database cluster directory than where the original database cluster resided, certain operations dependent upon the database cluster location may fail. This happens if their supporting service scripts are not updated to reflect the new directory location of restored backup. For information about the usage and modification of service scripts, see the *EDB Advanced Server Installation Guide* available at the [EDB website](/epas/latest/). + +The following table describes the command options: + +| Options | Description | +| ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s `
`--server ` | `` is the name of the database server to be restored. | +| `-p `
`--restore-path ` | `` is the directory path where the backup of the database server is to be restored. The directory must be empty and have the proper ownership and privileges assigned to it. | +| `-i { \| }`

`--backupid { \| }` | `` is the backup identifier of the backup to be used for the restoration and `` is the user-defined alphanumeric name for the backup.
If the option is omitted, the default is to use the latest backup. | +| `-r or --remote-host ` | `` is the user account on the remote database server host that accepts a passwordless SSH/SCP login connection and is the owner of the directory where the backup is to be restored and `` is the IP address of the remote host to which the backup is to be restored. This option must be specified if the `` parameter for this database server is not set in the BART configuration file.
If the BART user account is not the same as the operating system account owning the `` directory given with the `-p` option, use the `` BART configuration parameter or the `RESTORE` subcommand `-r` option to specify the `` directory owner even when restoring to a directory on the same host as the BART host.
See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/latest/bart_inst/) for information about the `` parameter. | +| `-w `
`--workers ` | `` is the specification of the number of worker processes to run in parallel to stream the modified blocks of an incremental backup to the restore location.
For example, if 4 worker processes are specified, 4 receiver processes on the restore host and 4 streamer processes on the BART host are used. The output of each streamer process is connected to the input of a receiver process. When the receiver gets to the point where it needs a modified block file, it obtains those modified blocks from its input. With this method, the modified block files are never written to the restore host disk. If the `-w` option is omitted, the default is `1` \| worker process. | +| `-t `
`--target-tli ` | `` is the integer identifier of the timeline to be used for replaying the archived WAL files for point-in-time recovery. | +| `-x `
`--target-xid ` | `` is the integer identifier of the transaction ID that determines the transaction up to and including, which point-in-time recovery encompasses. Include either the `-x ` or the `--target-xid ` option if point-in-time recovery is desired. | +| `-g `

`--target-timestamp ` | `` is the timestamp that determines the point in time up to and including, which point-in-time recovery encompasses. Include either the `--target-timestamp ` or the `-g ` option if point-in-time recovery is desired. | +| `-c`
`--copy-wals` | Specify this option to copy archived WAL files from the BART backup catalog to `/archived_wals` directory.
If recovery settings are saved in the `postgresql.auto.conf` file for point-in-time recovery, the `restore_command` retrieves the WAL files from `/archived_wals` for the database server archive recovery.
If the `-c` option is omitted and the `copy_wals_during_restore` parameter in the BART configuration file is not enabled in a manner applicable to this database server, the `restore_command` in the `postgresql.auto.conf` file is generated by default to retrieve the archived WAL files directly from the BART backup catalog. See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/latest/bart_inst/) for information about the `copy_wals_during_restore` parameter. | +| `--disable-checksum` | While restoring a backup, specify this option to skip verifying the MD5 or SHA256 checksum files.
If you set the `--checksum-algorithm=NONE` option with the [BART scanner](../04_running_the_bart_wal_scanner/#running_the_bart_wal_scanner) or while taking a [backup](03_backup/#backup), you must specify the `--disable checksum` option while restoring an incremental backup. | diff --git a/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/03_basic_bart_subcommand_usage/09_delete.mdx b/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/03_basic_bart_subcommand_usage/09_delete.mdx new file mode 100644 index 00000000000..7f9836ad724 --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/03_basic_bart_subcommand_usage/09_delete.mdx @@ -0,0 +1,34 @@ +--- +title: "DELETE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/delete.html" +--- + + + +The `DELETE` subcommand removes the subdirectory and data files from the BART backup catalog for the specified backups along with its archived WAL files. + +**Syntax:** + +```text +bart DELETE –s + -i { all | + [']{ | },... }['] + } + [ -n ] +``` + +!!! Note + While invoking the `DELETE` subcommand, you must specify a specific database server. + +For database servers under a retention policy, there are conditions where certain backups may not be deleted. See [Deletions Permitted Under a Retention Policy](../02_managing_backups_using_a_retention_policy/04_managing_the_backups_based_on_the_retention_policy/#deletions_permitted_under_retention_policy) for information about permitted backup deletions. + +The following table describes the command options: + +| Options | Description | +| -------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s `

`--server ` | `` is the name of the database server whose backups are to be deleted. | +| `-i { all \| [']{ \| },... }['] }`

`--backupid { all \| [']{ \| },... }['] }` | `` is the backup identifier of the backup to be deleted and `` is the user-defined alphanumeric name for the backup.
Multiple backup identifiers and backup names may be specified in a comma-separated list. The list must be enclosed within single quotes if there is any white space appearing before or after each comma.
If `all` is specified, all of the backups and their archived WAL files for the specified database server are deleted. | +| `-n`
`--dry-run` | Displays the results as if the deletions were done, however, no physical removal of the files are actually performed. In other words, a test run is performed so that you can see the potential results prior to actually initiating the action.
After the deletion, the BART backup catalog for the database server no longer contains the corresponding directory for the deleted backup ID. The `archived_wals` subdirectory no longer contains the WAL files of the backup. | diff --git a/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/03_basic_bart_subcommand_usage/index.mdx b/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/03_basic_bart_subcommand_usage/index.mdx new file mode 100644 index 00000000000..e7d51affa18 --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/03_basic_bart_subcommand_usage/index.mdx @@ -0,0 +1,50 @@ +--- +title: "Basic BART Subcommand Usage" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/basic_bart_subcommand_usage.html" +--- + + + +This section briefly describes the BART subcommands and options. You can invoke the `bart` program (located in the `/bin` directory) with the desired options and subcommands to manage your BART installation. + +To view examples of BART subcommands, see the *EDB Backup and Recovery Reference Guide* available at the [EDB website](/bart/latest/bart_ref/). + +**Syntax for invoking BART**: + + `bart [ general_option ]... [ subcommand ] [subcommand_option ]...` + +- When invoking a subcommand, the subcommand name is not case-sensitive (that is, the subcommand can be specified in uppercase, lowercase, or mixed case). +- Each subcommand has a number of its own applicable options that are specified following the subcommand. All options are available in both single-character and multi-character forms. +- Keywords are case-sensitive; options are generally specified in lowercase unless specified otherwise in this section. +- When invoking BART, the current user must be the BART user account (operating system user account used to run the BART command line program). For example, enterprisedb or postgres can be selected as the BART user account when the managed database servers are Advanced Server or PostgreSQL respectively. +- The chosen operating system user account must own the BART backup catalog directory, be able to run the `bart` program and the `bart scanner` program, and have a passwordless SSH/SCP connection established between database servers managed by BART. + +You can specify one or more of the following general options: + +| Options | Description | +| ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-h` `--help` | Displays general syntax and information on BART usage. All subcommands support a help option (`-h`, `--help`). If the help option is specified, information is displayed regarding that particular subcommand. The subcommand, itself, is not executed. | +| `-v` `--version` | Displays the BART version information. | +| `-d` `--debug` | Displays debugging output while executing BART subcommands. | +| `-c ` `--config-path ` | Specifies `config_file_path` as the full directory path to a BART configuration file. Use this option if you do not want to use the default BART configuration file `/etc/bart.cfg`. | + +**Troubleshooting: Setting Path Environment Variable** + +If execution of BART subcommands fails with the following error message, then you need to set the `LD_LIBRARY_PATH` to include the `libpq` library directory: + + `./bart: symbol lookup error: ./bart: undefined symbol: PQping` + +**Workaround:** Set the `LD_LIBRARY_PATH` environment variable for the BART user account to include the directory containing the `libpq` library. This directory is `POSTGRES_INSTALL_HOME/lib`. + +It is suggested that the `PATH` and the `LD_LIBRARY_PATH` environment variable settings be placed in the BART user account’s profile. See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/latest/bart_inst/) for details. + +In the following sections, the `help` option is omitted from the syntax diagrams for the purpose of providing readability for the subcommand options. + +
+ +check_config init backup show_servers show_backups verify_chksum manage restore delete + +
diff --git a/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/04_running_the_bart_wal_scanner.mdx b/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/04_running_the_bart_wal_scanner.mdx new file mode 100644 index 00000000000..afd4360481c --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/04_running_the_bart_wal_scanner.mdx @@ -0,0 +1,61 @@ +--- +title: "Running the BART WAL Scanner" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/running_the_bart_wal_scanner.html" +--- + + + +Use the BART WAL scanner to invoke the `bart-scanner` program located in the `BART_HOME/bin` directory. When invoking the WAL scanner, the current user must be the BART user account. + +**Syntax:** + +```text +bart-scanner + [ -d ] + [ -c ] + { –h | + -v | + --daemon | + -p | + | + RELOAD | + STOP + --checksum-algorithm } +``` + +!!! Note + For clarity, the syntax diagram shows only the single-character option form (for example, `-d`), but the multi-character option form (for example, `--debug`) is supported as well. + +The WAL scanner processes each WAL file to find and record modified blocks in a corresponding modified block map (MBM) file. The default approach is that the WAL scanner gets notified whenever a new WAL file is added to the `archived_wals` directory specified in the `archive_path` parameter of the configuration file. It then scans the WAL file and produces the MBM file. + +The default approach does not work in some cases; for example when the WAL files are shipped to the `archive_path` using the Network File System (NFS) and also in case of some specific platforms. This results in the WAL files being copied to the `archived_wals` directory, but the WAL scanner does not scan them (as WAL scanner is not aware of WAL file) and produce the MBM files. This results in the failure of an incremental backup. This can be avoided by using the timer-based WAL scanning approach, which is done by using the `scan_interval` parameter in the BART configuration file. The value for `scan_interval` is the number of seconds after which the WAL scanner will initiate force scanning of the new WAL files. See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/latest/bart_inst/) for more information about `scan_interval` parameter. + +!!! Note + After upgrading to BART 2.6.1, users who have set this parameter to a non-default value may see increased CPU consumption on the part of bart-scanner. If this is an issue, consider increasing the configured value of scan_interval parameter, or removing the setting if it is not required. + +When the `bart-scanner` program is invoked, it forks a separate process for each database server enabled with the `allow_incremental_backups` parameter. + +The WAL scanner processes can run in either the foreground or background depending upon usage of the `--daemon` option. Use the `--daemon` option to run the WAL scanner process in the background so that all output messages can be viewed in the BART log file. If the `--daemon` option is omitted, the WAL scanner process runs in the foreground and all output messages can be viewed from the terminal running the program as well as in the BART log file. + +See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/latest/bart_inst/) for additional information about WAL scanning, `allow_incremental_backups`, and `logfile` parameters. + +!!! Note + The BART user account’s `LD_LIBRARY_PATH` environment variable may need to be set to include the directory containing the `libpq` library if invocation of the WAL scanner program fails. See [Basic BART Subcommand Usage](03_basic_bart_subcommand_usage/#basic_bart_subcommand_usage) for information about setting the `LD_LIBRARY_PATH` environment variable. + +The following table describes the scanner options: + +| Options | Description | +| ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-h` `--help` | Displays general syntax and information on WAL scanner usage. | +| `-v` `--version` | Displays the WAL scanner version information. | +| `-d` `--debug` | Displays debugging output while executing the WAL scanner with any of its options. | +| `-c ` `--config-path ` | Use this option to specify the `config_file_path` of a BART configuration file if you do not want to use the default BART configuration file path `BART_HOME/etc/bart.cfg`. | +| `--daemon` | Runs the WAL scanner as a background process. | +| `-p ` `--print ` | Use this option to specify the full directory path to an MBM file whose content is to be printed. The directory specified in the `archive_path` parameter in the `bart.cfg` file contains the MBM files. | +| `` | Specify the full directory path to a WAL file to be scanned. The directory specified in the `archive_path` parameter in the `bart.cfg` file contains the WAL files. Use this option if a WAL file in the archive path is missing its MBM file. This option is to be used for assisting the EnterpriseDB support team for debugging problems that may have been encountered. | +| `RELOAD` | Reloads the BART configuration file. The keyword `RELOAD` is not case-sensitive. The `RELOAD` option is useful if you make changes to the configuration file after the WAL scanner has been started. It will reload the configuration file and adjust the WAL scanners accordingly. For example, if a server section allowing incremental backups is removed from the BART configuration file, then the process attached to that server will stop. Similarly, if a server allowing incremental backups is added, a new WAL scanner process will be launched to scan the WAL files of that server. | +| `STOP` | Stops the WAL scanner. The keyword `STOP` is not case-sensitive. | +| `--checksum-algorithm` | While invoking the WAL scanner, you can specify one of the following values with the `--checksum-algorithm` option: `--checksum-algorithm=MD5` (default) to generate MD5 checksum files. `--checksum-algorithm=SHA256` to generate SHA256 checksum files. `--checksum-algorithm=NONE` to skip generating checksum files. | diff --git a/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/index.mdx b/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/index.mdx new file mode 100644 index 00000000000..a076b82b5e9 --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_user/03_using_bart/index.mdx @@ -0,0 +1,19 @@ +--- +title: "Using BART" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/using_bart.html" +--- + + + +After installing and configuring the BART host and the database servers, you can start using BART. + +This section describes how to perform backup and recovery management operations using BART. Review the sections that follow before proceeding with any BART operation. + +
+ +bart_management_overview managing_backups_using_a_retention_policy basic_bart_subcommand_usage running_the_bart_wal_scanner + +
diff --git a/product_docs/docs/bart/2.6.1/bart_user/04_using_tablespaces.mdx b/product_docs/docs/bart/2.6.1/bart_user/04_using_tablespaces.mdx new file mode 100644 index 00000000000..94d5450778a --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_user/04_using_tablespaces.mdx @@ -0,0 +1,59 @@ +--- +title: "Using Tablespaces" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/using_tablespaces.html" +--- + + + +If the database cluster contains user-defined tablespaces (that is, tablespaces created with the `CREATE TABLESPACE` command): + +- You can take full backups with the `BACKUP` subcommand in either tar (`-Ft`) or plain text (`-Fp`) backup file format. +- You must take incremental backups in the plain text (`-Fp`) backup file format. +- You can take full backups using the transaction log streaming method (xlog_method = stream in the BART configuration file) `--with-pg_basebackup` and the `BACKUP` subcommand in either tar (`-Ft`) or plain text (`-Fp`) backup file format. + +!!! Note + If the particular database cluster you plan to back up contains tablespaces created by the `CREATE TABLESPACE` command, then you must set the `tablespace_path` parameter in the BART configuration file before you perform a BART `RESTORE` operation. + +The `tablespace_path` parameter specifies the directory paths to which you want the tablespaces to be restored. It takes the following format: + + `OID_1=tablespace_path_1;OID_2=tablespace_path_2 ...` + +Where `OID_1`, `OID_2`, … are the Object Identifiers of the tablespaces. You can find the OIDs of the tablespaces and their corresponding soft links to the directories by listing the contents of the `POSTGRES_INSTALL_HOME/data/pg_tblspc` subdirectory as shown in the following example: + +```text +[root@localhost pg_tblspc ]# pwd +/opt/PostgresPlus/9.6AS/data/pg_tblspc +[root@localhost pg_tblspc]# ls -l +total 0 +lrwxrwxrwx 1 enterprisedb enterprisedb 17 Aug 22 16:38 16644 -> /mnt/tablespace_1 +lrwxrwxrwx 1 enterprisedb enterprisedb 17 Aug 22 16:38 16645 -> /mnt/tablespace_2 +``` + +The OIDs are `16644` and `16645` to directories `/mnt/tablespace_1` and `/mnt/tablespace_2`, respectively. + +If you later wish to restore the tablespaces to the same locations as indicated in the preceding example, the BART configuration file must contain the following entry: + +```text +[ACCTG] +host = 127.0.0.1 +port = 5444 +user = enterprisedb +cluster_owner = enterprisedb +tablespace_path = 16644=/mnt/tablespace_1;16645=/mnt/tablespace_2 +description = "Accounting" +``` + +If you later wish to restore the tablespaces to different locations, specify the new directory locations in the `tablespace_path` parameter. + +In either case, the directories specified in the `tablespace_path` parameter must exist and be empty at the time you perform the `BART RESTORE` operation. + +If the database server is running on a remote host (in other words you are also using the `remote_host` configuration parameter or will specify the `--remote-host` option with the `RESTORE` subcommand), the specified tablespace directories must exist on the specified remote host. + +To view example of backing up and restoring a database cluster on a remote host containing tablespaces, see the *EDB Backup and Recovery Reference Guide* available at the [EDB website](/bart/latest/bart_ref/). + +The directories must be owned by the user account with which you intend to start the database server (typically the Postgres user account) with no access by other users or groups as is required for the directory path to which the main full backup is to be restored. + +To view a sample BART managed backup and recovery system consisting of both local and remote database servers, see the *EDB Backup and Recovery Reference Guide* available at the [EDB website](/bart/latest/bart_ref/). diff --git a/product_docs/docs/bart/2.6.1/bart_user/images/EDB_logo.png b/product_docs/docs/bart/2.6.1/bart_user/images/EDB_logo.png new file mode 100644 index 00000000000..39a54822d85 Binary files /dev/null and b/product_docs/docs/bart/2.6.1/bart_user/images/EDB_logo.png differ diff --git a/product_docs/docs/bart/2.6.1/bart_user/images/copy_1.png b/product_docs/docs/bart/2.6.1/bart_user/images/copy_1.png new file mode 100644 index 00000000000..b15833dc37d Binary files /dev/null and b/product_docs/docs/bart/2.6.1/bart_user/images/copy_1.png differ diff --git a/product_docs/docs/bart/2.6.1/bart_user/images/edb.png b/product_docs/docs/bart/2.6.1/bart_user/images/edb.png new file mode 100644 index 00000000000..71e5bdde787 Binary files /dev/null and b/product_docs/docs/bart/2.6.1/bart_user/images/edb.png differ diff --git a/product_docs/docs/bart/2.6.1/bart_user/images/edb_logo.svg b/product_docs/docs/bart/2.6.1/bart_user/images/edb_logo.svg new file mode 100644 index 00000000000..f24d1dfefee --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_user/images/edb_logo.svg @@ -0,0 +1,19 @@ + + + edb-logo-disc-dark + + + + \ No newline at end of file diff --git a/product_docs/docs/bart/2.6.1/bart_user/index.mdx b/product_docs/docs/bart/2.6.1/bart_user/index.mdx new file mode 100644 index 00000000000..50504d9e3db --- /dev/null +++ b/product_docs/docs/bart/2.6.1/bart_user/index.mdx @@ -0,0 +1,17 @@ +--- +navTitle: Backup and Recovery Guide +title: "EDB Postgres Backup and Recovery User Guide" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/genindex.html" + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/introduction.html" + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/conclusion.html" + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/index.html" +--- + +
+ +introduction overview using_bart using_tablespaces conclusion + +
diff --git a/product_docs/docs/bart/2.6.1/bart_v2.6.1_documentation.pdf b/product_docs/docs/bart/2.6.1/bart_v2.6.1_documentation.pdf new file mode 100644 index 00000000000..3bbc8e6158a Binary files /dev/null and b/product_docs/docs/bart/2.6.1/bart_v2.6.1_documentation.pdf differ diff --git a/product_docs/docs/bart/2.6.1/index.mdx b/product_docs/docs/bart/2.6.1/index.mdx new file mode 100644 index 00000000000..8993f4a09fd --- /dev/null +++ b/product_docs/docs/bart/2.6.1/index.mdx @@ -0,0 +1,16 @@ +--- +title: Backup and Recovery Tool +directoryDefaults: + description: "EDB Backup and Recovery Tool Version 2.6.1 Documentation and release notes. A tool to manage and configure PostgreSQL backups and disaster recovery." +navigation: + - "#Getting Started" + - bart_inst + - bart_qs_7 + - bart_qs_8 + - "#Guides" + - bart_user + - bart_ref +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/p/edb-backup-and-recovery-tool/2.6.1" +--- diff --git a/product_docs/docs/bart/2.6.2/bart_inst/02_installing_bart.mdx b/product_docs/docs/bart/2.6.2/bart_inst/02_installing_bart.mdx new file mode 100644 index 00000000000..20b4b7e19e5 --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_inst/02_installing_bart.mdx @@ -0,0 +1,429 @@ +--- +title: 'Installing BART' + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/installation-getting-started/installation-upgrade-guide/2.6.1/installing_bart.html" +--- + +This section will walk you through performing a fresh installation of BART on a host. Installation instructions are organized into the following platform/installer specific sections: + +- [Installing BART on a CentOS](#installing-bart-on-a-centos-host) +- [Installing BART on a RHEL Host](#installing-bart-on-a-rhel-host) +- [Installing BART on a CentOS or RHEL Host](#installing-bart-on-a-rhelcentos-7-ppcle-host) +- [Installing BART on a Debian or Ubuntu Host](#installing-bart-on-a-debian-or-ubuntu-host) +- [Installing BART on an SLES 12 Host](#installing-bart-on-an-sles-12-host) + +!!! Note + If you are using the pdf version of this document, using cut/paste to copy command may result in extra spaces or carriage returns in the pasted command. If a command fails, check the command carefully for additional characters. + +## Installing BART on a CentOS Host + +The following section demonstrates installing BART on a CentOS host using an RPM package.  This section assumes that the user has some knowledge of installation and system administration procedures, and has administrative privileges on the host. + +1. To install the repository configuration, assume superuser privileges and invoke one of the following platform-specific commands: + + On CentOS 7: + + ```text + yum -y install https://yum.enterprisedb.com/edbrepos/edb-repo-latest.noarch.rpm + ``` + + On CentOS 8: + + ```text + dnf -y install https://yum.enterprisedb.com/edbrepos/edb-repo-latest.noarch.rpm + ``` + +2. Replace the `USERNAME:PASSWORD` in the following command with the username and password of a registered EnterpriseDB user: + + ```text + sed -i "s@:@USERNAME:PASSWORD@" /etc/yum.repos.d/edb.repo + ``` + + To request credentials for the repository, visit the [EDB website](https://www.enterprisedb.com/user). + +3. Before installing BART, execute the following command to install the Extra Packages for Enterprise Linux (EPEL) release package: + + On CentOS 7: + + ```text + yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm + ``` + + On CentOS 8: + + ```text + dnf -y install epel-release + ``` + +4. For CentOS 8, enable the PowerTools repository to satisfy EPEL package dependencies: + + ```text + dnf config-manager --set-enabled PowerTools + ``` + +5. For CentOS 8, disable the built-in PostgreSQL module: + + ```text + dnf -qy module disable postgresql + ``` + +6. Optionally, install the `pg_basebackup` utility program using the server client package. If you do not already have the `pg_basebackup` program installed on the BART host, you can install a limited number of files that include the `pg_basebackup` program by invoking the following command: + + On CentOS 7: + + ```text + yum install edb-as-server-client + ``` + + On CentOS 8: + + ```text + dnf install edb-as-server-client + ``` + + In the above command, replace `` with the required Advanced Server version. The `pg_basebackup` version must be the same or more recent than the database server to be backed up. For example, `pg_basebackup` version 10 can be used to back up database server version 10, but cannot be used to back up database server version 11. + +7. Use the following command to install BART: + + On CentOS 7: + + ```text + yum -y install edb-bart + ``` + + On CentOS 8: + + ```text + dnf -y install edb-bart + ``` + + Repeat the installation process described in this section to install BART on each remote host on which an incremental backup is to be restored. + + To verify the BART installation, navigate to the `/usr/edb/bart/bin` directory and execute the following command: + + ```text + bart --version + ``` + + The `bart --version` command should return the current BART version. If the `bart --version` command returns an error stating the PATH is not available after switching from the root user to another BART user account, adjust the setting of the `PATH` environment variable to include the directory location of the BART `bin` subdirectory in the `~/.bashrc` or `~/.bash_profile` files of the following user accounts: + + - The BART user account on the BART host. See [Configuring BART](03_configuring_bart/#path) for details. + - The remote user account on the remote host to which incremental backups are to be restored. For details, see the *EDB Backup and Recovery User Guide* available at the [EDB website](/bart/latest/bart_user/). + + Upon successful installation, BART is installed in the `BART_HOME` directory: + + `/usr/edb/bart` + + The installation includes the following files: + +| File Name | Location | Description | +| ------------------- | ----------------- | ------------------------------------- | +| bart | ``/bin | BART command line, executable program | +| bart-scanner | ``/bin | BART WAL scanner program | +| bart.cfg.sample | ``/etc | Sample BART configuration file | +| xlogreader_ident.so | ``/lib | Libraries supporting WAL versions | +| bart_license.txt | `` | License agreement | + +After BART is installed successfully, you need to [configure the installation](03_configuring_bart/#configuration). + +## Installing BART on a RHEL Host + +The following section demonstrates installing BART on a RHEL host using an RPM package.  This section assumes that the user has some knowledge of installation and system administration procedures, and has administrative privileges on the host. + +1. To install the repository configuration, assume superuser privileges and invoke one of the following platform-specific commands: + + On RHEL 7: + + ```text + yum -y install https://yum.enterprisedb.com/edbrepos/edb-repo-latest.noarch.rpm + ``` + + On RHEL 8: + + ```text + dnf -y install https://yum.enterprisedb.com/edbrepos/edb-repo-latest.noarch.rpm + ``` + +2. Replace the `USERNAME:PASSWORD` in the following command with the username and password of a registered EnterpriseDB user: + + ```text + sed -i "s@:@USERNAME:PASSWORD@" /etc/yum.repos.d/edb.repo + ``` + + To request credentials for the repository, visit the [EDB website](https://www.enterprisedb.com/user). + +3. Before installing BART, execute the following command to install the Extra Packages for Enterprise Linux (EPEL) release package: + + On RHEL 7: + + ```text + yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm + ``` + + On RHEL 8: + + ```text + dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm + ``` + +4. Enable the repository: + + On RHEL 7, enable the `optional, extras`, and `HA` repositories to satisfy EPEL package dependencies: + + ```text + subscription-manager repos --enable "rhel-*-optional-rpms" --enable "rhel-*-extras-rpms" --enable "rhel-ha-for-rhel-*-server-rpms" + ``` + + On RHEL 8, enable the `codeready-builder-for-rhel-8-*-rpms` repository to satisfy EPEL packages dependency: + + ```text + ARCH=$( /bin/arch ) + + subscription-manager repos --enable "codeready-builder-for-rhel-8-${ARCH}-rpms" + ``` + +5. For RHEL 8, disable the built-in PostgreSQL module: + + ```text + dnf -qy module disable postgresql + ``` + +6. Optionally, install the `pg_basebackup` utility program using the server client package. If you do not already have the `pg_basebackup` program installed on the BART host, you can install a limited number of files that include the `pg_basebackup` program by invoking the following command: + + On RHEL 7: + + ```text + yum install edb-as-server-client + ``` + + On RHEL 8: + + ```text + dnf install edb-as-server-client + ``` + + In the above command, replace `` with the required Advanced Server version. The `pg_basebackup` version must be the same or more recent than the database server to be backed up. For example, `pg_basebackup` version 10 can be used to back up database server version 10, but cannot be used to back up database server version 11. + +7. Use the following command to install the BART: + + On RHEL 7: + + ```text + yum -y install edb-bart + ``` + + On RHEL 8: + + ```text + dnf -y install edb-bart + ``` + + Repeat the installation process described in this section to install BART on each remote host on which an incremental backup is to be restored. + + To verify the BART installation, navigate to the `/usr/edb/bart/bin` directory and execute the following command: + + ```text + bart --version + ``` + + The `bart --version` command should return the current BART version. If the `bart --version` command returns an error stating the PATH is not available after switching from the root user to another BART user account, adjust the setting of the `PATH` environment variable to include the directory location of the BART `bin` subdirectory in the `~/.bashrc` or `~/.bash_profile` files of the following user accounts: + + - The BART user account on the BART host. See [Configuring BART](03_configuring_bart/#path) for details. + - The remote user account on the remote host to which incremental backups are to be restored. For details, see the *EDB Backup and Recovery User Guide* available at the [EDB website](/bart/latest/bart_user/). + + Upon successful installation, BART is installed in the `BART_HOME` directory: + + `/usr/edb/bart` + + The installation includes the following files: + +| File Name | Location | Description | +| ------------------- | ----------------- | ------------------------------------- | +| bart | ``/bin | BART command line, executable program | +| bart-scanner | ``/bin | BART WAL scanner program | +| bart.cfg.sample | ``/etc | Sample BART configuration file | +| xlogreader_ident.so | ``/lib | Libraries supporting WAL versions | +| bart_license.txt | `` | License agreement | + +After BART is installed successfully, you need to [configure the installation](03_configuring_bart/#configuration). + + + +## Installing BART on a RHEL/CentOS 7 PPCLE Host + +The following section demonstrates installing BART on a RHEL host using an RPM package.  This section assumes that the user has some knowledge of installation and system administration procedures, and has administrative privileges on the host. + +1. Install Advance Toolchain: + + ```text + rpm --import https://public.dhe.ibm.com/software/server/POWER/Linux/toolchain/at/redhat/RHEL7/gpg-pubkey-6976a827-5164221b + + cat > /etc/yum.repos.d/advance-toolchain.repo <:@USERNAME:PASSWORD@" /etc/yum.repos.d/edb.repo + ``` + + To request credentials for the repository, visit the [EDB website](https://www.enterprisedb.com/user). + +4. Before installing BART, execute the following command to install the Extra Packages for Enterprise Linux (EPEL) release package: + + ```text + yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm + ``` + +5. On RHEL 7, enable the `optional, extras`, and `HA` repositories to satisfy EPEL package dependencies: + + ```text + subscription-manager repos --enable "rhel-*-optional-rpms" --enable "rhel-*-extras-rpms" --enable "rhel-ha-for-rhel-*-server-rpms" + ``` + +6. Invoke the following command to install BART: + + ```text + yum -y install edb-bart + ``` + + + +## Installing BART on a Debian or Ubuntu Host + +Perform the following steps to install a Debian package using the EnterpriseDB apt repository. + +To request credentials for the repository, visit the [EDB website](https://www.enterprisedb.com/repository-access-request). + +1. Assume the superuser privileges. + + ```text + sudo su - + ``` + +2. To configure the EnterpriseDB repository on Debian 9, Ubuntu 18, and Ubuntu 20: + + ```text + sh -c 'echo "deb https://username:password@apt.enterprisedb.com/$(lsb_release -cs)-edb/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/edb-$(lsb_release -cs).list' + ``` + + On Debian 10: + + a. Set up the EnterpriseDB repository: + + ```text + sh -c 'echo "deb [arch=amd64] https://apt.enterprisedb.com/$(lsb_release -cs)-edb/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/edb-$(lsb_release -cs).list' + ``` + + b. Substitute your EnterpriseDB credentials for the `username` and `password` placeholders in the following command: + + ```text + sh -c 'echo "machine apt.enterprisedb.com login password " > /etc/apt/auth.conf.d/edb.conf' + ``` + +3. Add support to your system for secure APT repositories. + + ```text + apt-get install apt-transport-https + ``` + +4. Add the EDB signing key; When invoking the command, replace the `username` and `password` with the credentials provided by EnterpriseDB. + + ```text + wget -q -O - https://apt.enterprisedb.com/edb-deb.gpg.key | apt-key add – + ``` + +5. Update the repository metadata. + + ```text + apt-get update + ``` + +6. Install the Debian package. + + ```text + apt-get install edb-bart + ``` + + + +## Installing BART on an SLES 12 Host + +This section provides instructions for installing BART on an SLES 12 SP4 host using the zypper package manager. BART is supported on SLES SP4 and SP5 versions. + +1. Assume superuser privileges. + + ```text + sudo su - + ``` + +2. Use the following command to add the EDB repository to your SLES host: + + ```text + zypper addrepo https://zypp.enterprisedb.com/suse/edb-sles.repo + ``` + +3. Invoke the following command to refresh the metadata: + + ```text + zypper refresh + ``` + +4. Install `SUSEConnect` to register the host with SUSE to allow access to SUSE repositories: + + ```text + zypper install SUSEConnect + ``` + +5. Register the host with SUSE to allow access to SUSE repositories and replace `'REGISTRATION_CODE'` and `'EMAIL'` with your SUSE registration information: + + ```text + SUSEConnect -r 'REGISTRATION_CODE' -e 'EMAIL' + ``` + + ```text + SUSEConnect -p PackageHub/12.4/x86_64 + ``` + + ```text + SUSEConnect -p sle-sdk/12.4/x86_64 + ``` + +6. Install the following repository for PEM dependencies: + + ```text + zypper addrepo https://download.opensuse.org/repositories/Apache:/Modules/SLE_12_SP4/Apache:Modules.repo + ``` + +7. Refresh the metadata: + + ```text + zypper refresh + ``` + +8. Then, use the zypper utility to install BART: + + ```text + zypper -n install edb-bart + ``` diff --git a/product_docs/docs/bart/2.6.2/bart_inst/03_configuring_bart.mdx b/product_docs/docs/bart/2.6.2/bart_inst/03_configuring_bart.mdx new file mode 100644 index 00000000000..0201f230692 --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_inst/03_configuring_bart.mdx @@ -0,0 +1,643 @@ +--- +title: "Configuring BART" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/installation-getting-started/installation-upgrade-guide/2.6.1/configuring_bart.html" +--- + + + +To configure BART, you must establish the BART user account, [configure the BART host](#configuring-the-bart-host), and [configure the database server](#configuring_database_server) that will be backed up. + + + +## Establishing the BART User Account + +The BART user account is an operating system user that will run the BART command line program. The BART user account must: + +- own the BART backup catalog. +- be able to run the `bart` program and the `bart-scanner` program. +- be able to establish a SSH/SCP connection to and from each database server managed by BART. + +You can optionally use the `enterprisedb` database user as the BART user account for an Advanced Server database and `postgres` database user as the BART user account for a PostgreSQL server. If you do not wish to use an existing database user as the BART user account, you must create an operating system user to assume the role. + + + +## Configuring BART and Database Server + +As stated earlier, to configure BART, you must [configure the BART host](#configuring-the-bart-host) as well as the [database server](#configuring_database_server). The following table acts as a configuration parameter reference listing the mandatory and optional parameters with default values for `[SERVER]` as well as `[BART]` sections. + +- Parameters set in the `[BART]` section are applicable to all BART managed database servers. +- Parameters set in the `Server` section are applicable only to the specific server; the `Server` parameter setting overrides the `[BART]` section setting. + +For information about configuring BART host parameters, see the [BART Host Parameter Reference](#bart) and for information about configuring the database server parameters, see the [Database Server Parameter Reference](#server). + +| **Parameter** | **Type** | **Default** | **\[SERVER]** | **\[BART]** | +| -------------------------- | --------- | ------------------------------------------------------------ | ------------- | ----------- | +| `[BART]` | Mandatory | N/A | N/A | Yes | +| `` | Mandatory | N/A | N/A | Yes | +| `` | Mandatory | N/A | N/A | Yes | +| `` | Mandatory | N/A | N/A | Yes | +| `retention_policy` | Optional | `BACKUPS` | Yes | Yes | +| `wal_compression` | Optional | `Disabled` | Yes | Yes | +| `copy_wals_during_restore` | Optional | `Disabled` | Yes | Yes | +| `xlog_method` | Optional | `fetch` | Yes | Yes | +| `logfile` | Optional | `/tmp/bart.log` | N/A | Yes | +| `scanner_logfile` | Optional | `/tmp/bart_scanner.log` | N/A | Yes | +| `` | Optional | `/tmp` | N/A | Yes | +| `` | Optional | `` | N/A | Yes | +| `` | Optional | `1` | Yes | Yes | +| `` | Optional | `49152` | Yes | Yes | +| `` | Optional | `0` | Yes | Yes | +| `` | Optional | `20 seconds` | Yes | Yes | +| `` | Optional | `1` | Yes | Yes | +| `[Server Name]` | Mandatory | N/A | Yes | N/A | +| `` | Optional | N/A | Yes | N/A | +| `host` | Mandatory | N/A | Yes | N/A | +| `port` | Mandatory | `5444` for EPAS; `5432` for Postgres | Yes | N/A | +| `user` | Mandatory | N/A | Yes | N/A | +| `` | Optional | `BART backup catalog` | Yes | N/A | +| `` | Optional | N/A | Yes | N/A | +| `` | Mandatory | `enterprisedb` for EPAS

`postgres` for PostgreSQL | Yes | N/A | +| `` | Optional | N/A | Yes | N/A | +| `` | Optional | N/A | Yes | N/A | +| `allow_incremental_backup` | Optional | `Disabled` | Yes | N/A | +| `description` | Optional | N/A | Yes | N/A | + + + +### Configuring the BART Host + +To configure the BART host, perform the following steps on the BART host as a root user: + +**Step 1.** Navigate to the `usr/edb/bart/etc` directory and make a copy of the `bart.cfg.sample` file to create the `bart.cfg` file that will contain the parameter settings. + +**Step 2.** Confirm that the Postgres `pg_basebackup` utility program is installed on the BART host. The `pg_basebackup` utility resides in the `bin` directory under your Postgres installation. + + + +**Step 3.** Ensure the `LD_LIBRARY_PATH` environment variable includes the location of the `libpq` library. If your `libpq` library does not reside in the default location (`POSTGRES_INSTALL_HOME/lib`), you must add the library path to the `LD_LIBRARY_PATH` environment variable in the BART user account’s profile (`bash_profile`) located in `/home/`: + +```text +# .bash_profile +# Get the aliases and functions +if [ -f ~/.bashrc ]; then +. ~/.bashrc +fi +# User specific environment and startup programs +export LD_LIBRARY_PATH=/usr/edb/as11/lib:$LD_LIBRARY_PATH +``` + +**Step 4.** Create the BART backup catalog and ensure the BART user account holds privileges on the BART backup catalog. In the following example, the BART configuration file specifies `/opt/backup` as the parent directory for the BART backup catalog in the `` parameter: + +```text +[BART] + +bart_host = bartuser@192.168.2.22 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log +``` + +In the following example, `bartuser` is the BART user account. The example creates and sets the ownership and permissions on the BART backup catalog: + +```text +su root +mkdir /opt/backup +chown bartuser /opt/backup +chgrp bartuser /opt/backup +chmod 700 /opt/backup +``` + +If the subdirectory does not exist, BART creates a subdirectory for each database server listed in the configuration file when you invoke the `bart` command line program. + +**Step 5.** Use your choice of editor to open the BART configuration file (located in the `usr/edb/bart/etc` directory) and edit the configuration as required. You must add the mandatory parameters to the `[BART]` section. Default values may be used for optional parameters. + +The following table describes the `[BART]` host parameters. + + + +| **Parameters/Placeholder** | **Type** | **Description** | +| -------------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `[BART}` | Mandatory | Identifies the global section of the configuration file. It must be named BART. | +| `bart_host` | Mandatory | Specify the bart user name and the IP address of the bart host on which the BART utility resides. You must specify it in the form of <bart_user>@<bart_host_address>. | +| `backup_path` | Mandatory | Specify the path to the file system parent directory where all BART backups are stored. | +| `pg_basebackup_path` | Mandatory | Specify the path to the `pg_basebackup` program that you installed on the BART host. For information about `pg_basebackup` version-specific restrictions, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/latest/bart_user/). | +| `wal_compression` | Optional | Set this parameter to `enabled` to compress the archived WAL files in gzip format in the BART backup catalog when the `MANAGE` subcommand is invoked. By default it is set to `disabled`. The gzip compression program must be in the BART user account’s `PATH` and the WAL compression setting must not be enabled for those database servers where you need to take incremental backups. | +| `copy_wals_during_restore` | Optional | Set this parameter to `enabled` to copy the archived WAL files from the BART backup catalog to the `restore_path/archived_wals` directory prior to the database server archive recovery. Enabling this option helps you save time during the restore operation. Set this parameter to `disabled` (default) to retrieve the archived WAL files directly from the BART backup catalog during the database server archive recovery. During the restore operation, recovery settings will be saved in the `postgresql.auto.conf` file. The `restore_command` in the `postgresql.auto.conf` file will be determined by the value specified in the `copy_wals_during_restore` parameter. If the `RESTORE` subcommand is invoked with the `-c` option, the archived WAL files are copied from the BART backup catalog to the `restore_path/archived_wals` directory, thus overriding any setting of the `copy_wals_during_restore` parameter. If the `RESTORE` subcommand is invoked without the `-c` option, the value specified by the `copy_wals_during_restore` parameter is used. | +| `xlog_method` | Optional | Specify how the transaction log is collected during the execution of `pg_basebackup` through the `BACKUP` subcommand. Set `xlog_method` to `fetch` (default) to collect the transaction log files after the backup is completed. Set to `stream` to stream the transaction log in parallel with the full backup creation. | +| `retention_policy` | Optional | Set this parameter to determine when an active backup should be marked as `obsolete` when the `MANAGE` subcommand is used. You can specify the retention policy either in terms of number of backups or duration (days, weeks, or months). ` BACKUPS` (default), ` DAYS`, ` WEEKS`, or ` MONTHS` where `` is a positive integer. For information about managing backups using a retention policy, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/latest/bart_user/). | +| `logfile` | Optional | Use this parameter to specify the path to the BART log file. The default log file location is `/tmp/bart.log`. The log file will be created the first time you invoke the `bart` command line program using the sample configuration file value. To change the default setting, you must delete the `bart.log` file from the `/tmp` directory and create a new log file in another directory so that a new log file will be created and owned by the new BART user account. If no path to a log file is specified, BART does not create a log file. | +| `scanner_logfile` | Optional | Use this parameter to specify the path to the XLOG/WAL scanner log file. The default location is `/tmp/bart_scanner.log`. The scanner log file will be created the first time you invoke the `bart_scanner` program using the sample configuration file value. To change the default setting, you must delete the `bart_scanner.log` file from the `/tmp` directory and create a new log file in another directory so that a new log file will be created and owned by the new BART user account. If no path to a log file is specified, BART does not create a WAL scanner log file. | +| `` | Optional | Specify the socket directory path where all BART sockets will be stored. The default directory is `/tmp`. While specifying the `bart_socket_directory` path, you must ensure that the directory exists and the BART user has the required access permissions to the directory. | +| `` | Optional | Specify a user-friendly BART socket file name. Using this option overrides the default BART socket name generated using MD5 checksum. You must shut down the bart-scanner before setting this option. You can view the `` in the `sockPath` field after starting the bart-scanner in the debug mode. This option helps in preventing the use of MD5 during the bart-scanner startup, thus making BART more compliant in FIPS mode. | +| `` | Optional | Specify the number of worker threads for copying blocks (for incremental backups) or data files (for full backup) from the database server to the `archive_path` when the `BACKUP` subcommand is invoked. The default value is `1`. The same set of worker threads are used for the compression operation when taking full backups in order to provide parallel, compressed backups when the `BACKUP` subcommand is specified with the `-z` or `-c` options. The compression operation does not apply to incremental backups. See [thread count](#thread_count) for more information. | +| `` | Optional | Specify the number of blocks of memory used for copying modified blocks from the database server to the `archive_path` when the `BACKUP` subcommand is invoked for incremental backups. The default value is 49152 blocks; each block is 8192 bytes. The maximum permitted value is 131072 blocks and the minimum permitted value is 1 block. Reduce the `` setting if the server runs out of memory while executing the `pg_read_binary_file()`. | +| `` | Optional | Specify the number of seconds after which the WAL scanner should initiate force scanning of the new WAL files. The default value is 0, which means no brute-force scanning will be started. After upgrading to the latest version of BART, users who have set this parameter to a non-default value may see increased CPU consumption on the part of bart-scanner. If this is an issue, consider increasing the configured value of `scan_interval` parameter, or removing the setting if it is not required. | +| `` | Optional | Specify the number of seconds to wait for MBM files before timing out; this parameter is applicable only for incremental backup. You must set the `scan_interval` to a value significantly less than the MBM scan timeout. The default value is 20 seconds. The `mbm_scan_timeout` parameter value must be greater than 0. If the value is 0 or negative, then an error will be displayed during an incremental backup. | +| `` | Optional | Specify the number of parallel worker processes required to stream the modified blocks of an incremental backup to the restore host. The default value is 1. | + + + +**Thread Count** + +If the `BACKUP` subcommand is invoked with the `--thread-count` option, then the number of worker threads specified by this option overrides any setting of the `thread_count` parameter in the BART configuration file. If the `BACKUP` subcommand is invoked without the `--thread-count` option, then the following determines the number of worker threads used: + +- The setting of the `thread_count` parameter in the server section of the BART configuration file overrides the setting of `thread_count` in the global section for that particular database server. +- If omitted in the server section, the setting of `thread_count` in the global section is used. +- If the `thread_count` parameter is not specified in either section, the default is 1. +- When taking a full backup, if the `thread count` in effect is only 1, then the `pg_basebackup` utility is used to take the full backup unless the `--no-pg_basebackup` option is specified with the `BACKUP` subcommand. + +`` will not be effective if the backup is taken on a standby server. + +If parallel backup is run with `N` number of worker threads, then it will initiate `N + 1` concurrent connections with the server. + +**Step 6** Invoke the `CHECK-CONFIG` subcommand, omitting the `-s` option to check the parameter settings in the BART configuration file. It should return the current BART version. + +```text +bart CHECK-CONFIG +``` + +The `CHECK-CONFIG` subcommand displays an error message if the required configuration is not properly set. You need to check the logfile to fix this. + + + +### Configuring the Database Server + +To configure the database server, you must: + +1. [Authorize SSH/SCP access without a password prompt](#authorizing_ssh_scp_access). +2. [Create and configure a replication database user](#setting_up_a_replication_database_user). +3. [Adding the database server to the configuration file (server section)](#adding_a_database_server). +4. [Enable WAL archiving of the server](#enabling_wal_archiving). +5. [Verify the server configuration settings](#verifying_configuration_settings). + +The following section will walk you through the configuration process. + +!!! Note + You must authorize SSH/SCP access and set up a replication database user before restarting the database server with WAL archiving enabled. + + + +**Authorizing SSH/SCP Access** + +BART uses the Secure Shell (`ssh`) and Secure Copy (`scp`) Linux utility programs to copy the backup and WAL files from the BART managed database servers to the BART host as well as to restore backups. + +- The client/server `ssh` and `scp` commands must not prompt for a password when establishing a connection with the target server (the server to which a passwordless connection is being made). +- A passwordless connection uses *authorized public keys* (public key of a client user account) to authenticate with the target server. +- You must add the public key of each client user account to the target user account’s authorized public keys list on the target server. + +For BART usage, there are two scenarios that require a passwordless SSH/SCP connection: + +- When connecting from each BART managed database server (SSH/SCP client) to the BART host (target SSH/SCP server) to support WAL archiving as implemented by the `archive_command` parameter. + - In this case, the database server user account should generate the public key file (`id_rsa.pub`) with the `ssh-keygen –t rsa` command on the database server host. + - The public key file name should be appended to the `~/.ssh/authorized_keys` file on the BART host. The `authorized_keys` file is in the BART user account’s home directory. +- When connecting from the BART host (SSH/SCP client) to each BART managed database server (target SSH/SCP server) for taking incremental backups and for supporting restoration of the full backup, the archived WAL files, and the modified blocks, which occurs when the BART `RESTORE` subcommand is given. + - In this case, the BART user account should generate the public key file (`id_rsa.pub`) with the `ssh-keygen –t rsa` command on the BART host. + - The public key file name should be appended to the `~/.ssh/authorized_keys` file on the database server host. The `authorized_keys` file is in the home directory of the user account that owns the directory where the database backup is to be restored. +- If backups are to be taken from a given database server host, but restored to a different database server host, the passwordless SSH/SCP connections must be configured from the BART host to the database server host from which the backup is to be taken as well as from the BART host to the database server host to which the backup is to be restored. + +See the EDB Backup and Recovery Reference Guide available at the [EDB website](/bart/latest/bart_ref/) to view examples of creating a passwordless connection. + +**Enabling Public Key Authentication** + +The following example enables SSH/SCP access on a CentOS 7.x host; similar (platform-specific) steps will apply to other platforms/versions. + +1. In the SSH server daemon configuration file (`sshd_config`) located in the `/etc/ssh`, set the `PubkeyAuthentication` parameter to `yes`. +2. Reload the configuration file: + +```text +service sshd reload +``` + +If you get any SSH or SCP errors, examine the `/var/log/secure` log file. + +**Creating a Passwordless Connection** + +The following general instructions will walk you through generating a client’s public key file, creating the target server’s authorized public keys file, and creating a passwordless connection. + +**Step 1.** On the client system, log in as the user account that will be initiating the SSH or SCP connection. + +**Step 2.** Navigate to the user account’s home directory and check for an existing `.ssh` subdirectory. If the `.ssh` directory does not exist, create one and assign the required privileges to the user. + +**Step 3.** Generate the public key file with the following command. Accept all prompted defaults and do not specify a passphrase when prompted for one. + +```text +ssh-keygen –t rsa +``` + +The public key file named `id_rsa.pub` is created in the `.ssh` subdirectory. + +**Step 4.** While logged into the client where you just generated the public key file, use `SCP` to make a temporary copy of it on the target server: + +```text +scp ~/.ssh/id_rsa.pub @:tmp.pub +``` + +**Step 5.** Navigate into the target user account’s home directory and check for an existing `.ssh` subdirectory. If it does not exist, create one and assign the required privileges to the user. + +**Step 6.** Append the temporary, client’s public key file, `tmp.pub`, to the `authorized_keys` file. If an `authorized keys` file does not exist, create a new file, but do not completely replace any existing `authorized keys` file. + +```text +cat tmp.pub >> ~/.ssh/authorized_keys +``` + +Make sure the `authorized_keys` file is only accessible by the file owner and not by groups or other users. If the `authorized_keys` file does not have the required permission setting or it was newly created, change the file permissions as follows: + +```text +chmod 600 ~/.ssh/authorized_keys +``` + +**Step 7.** Delete the temporary public key file: + +```text +rm tmp.pub +``` + +Now, when logged into the client system as `user` there should be no prompt for a password when commands such as the following is given: + +```text +ssh target_user@host_address +``` + + + +**Setting up a Replication Database User** + +For each database server that is to be managed by BART, a database user must be chosen to serve as the *replication database user*. The replication database user sets the Postgres `archive_command` configuration parameter when the `INIT` subcommand in invoked and creates backups when the `BACKUP` subcommand is invoked. The replication database user must be a `superuser`. + +When executed with the PSQL client, the following PostgreSQL command creates a superuser to be the replication database user: + +`CREATE ROLE repuser WITH LOGIN SUPERUSER PASSWORD 'password';` + +The `pg_hba.conf` file must minimally permit the replication database user to have access to the database. + +In the following example, the `pg_hba.conf` file permits the `repuser` (replication database user) to have access to the `template1` database. The IP address from which `repuser` has access to `template1` database is the location of the BART host: + +**For pg_basebackup only:** If `pg_basebackup` is to be used for taking any backups (such as for standby servers), the replication database user must also be included in the `pg_hba.conf` file as a `replication` database connection as shown by the last entry in the following example. + +```text +# TYPE DATABASE USER ADDRESS METHOD +# "local" is for Unix domain socket connections only +local all all md5 +# IPv4 local connections: +host template1 repuser 192.168.2.22/32 md5 +host all enterprisedb 127.0.0.1/32 md5 +# IPv6 local connections: +host all all ::1/128 md5 +# Allow replication connections from localhost, by a user with the +# replication privilege. +host replication repuser 192.168.2.22/32 md5 +``` + +The replication database user must be specified for the `user` parameter in the BART configuration file for the database server as shown in the following example: + +```text +[ACCTG] +host = 192.168.2.24 +port = 5444 +user = repuser +cluster_owner = enterprisedb +remote_host = enterprisedb@192.168.2.24 +description = "Accounting" +``` + +There must be no password prompt when connecting to the database server with the replication database user. There are several ways to permit this; one recommended method is to use a `.pgpass` file located in the BART user account’s home directory. + +For example, if `bartuser` is the BART user account, then the `.pgpass` file located in the `/home/bartuser` directory must contain the following entry: + +`192.168.2.24:5444::repuser:password` + +When `bartuser` invokes a BART backup, the password for the replication database user, `repuser`, is obtained from the `.pgpass` file of `bartuser` to connect to the database server running at `192.168.2.24` on `port 5444`. + +The `.pgpass` file must contain an entry for each BART managed database server and its corresponding replication database user and password. + + + +**Adding a Database Server to the BART Configuration File** + +To manage the backup and recovery of a database server, you must add entries to the `[SERVER]` section of the BART configuration file, which is located in `/etc` directory. + + + +*Database Server Parameter Reference* + +Set the following parameters in the \[`SERVER`] section of the BART configuration file. The parameter setting in the \[`SERVER`] section overrides the setting in the global \[`BART`] section for that particular database server. If omitted, the default value will be used. + +For each cluster serviced by BART, the following parameters are mandatory: + +```text +[HR] + +host = 192.168.2.24 +port = 5432 +user = postgres +cluster_owner = postgres +``` + +!!! Note + The port parameter setting is required only if the database server listens on a port other than the default (for example if Postgres listens on a port other than 5432). + +The following table describes the database server parameters. + + + + + + + + + +| **Parameters/Placeholder** | Type | **Description** | +| --------------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `[ServerName]` | Mandatory | Specify the server name that you want to backup using BART. It is not case-sensitive when referenced with BART subcommand options. A lowercase conversion of this name is used to create a subdirectory in the BART backup catalog for storing the backups and WAL files for this database server (for eg., epas12). | +| `` | Optional | Specify a [template](#backup_name_template) for user-defined, friendly names that will be assigned to the backups of the database server. The maximum permitted length of backup name is 49 characters. The `` parameter can be overridden by the `--backup-name` option of the `BACKUP` subcommand. If this parameter is omitted from the BART configuration file, and the `--backup-name` option with a user-defined name is not specified with the `BACKUP` subcommand, then the backup can only be referenced in BART subcommands by the BART assigned, integer backup identifier. | +| `host` | Mandatory | Specify the IP address of the database server to be configured for backup. | +| `port` | Mandatory | Specify the port number identifying the database server instance (that is, the relevant database cluster) to be backed up. The default port number for EPAS is `5444` and for Postgres it is `5432`. The port parameter setting is only required if the database server listens on a port other than the default value. | +| `User` | Mandatory | Specify the replication database user name used by BART to establish the connection to the database server for full backups. See [Setting up a Replication Database User](#setting_up_a_replication_database_user) for more information. | +| `` | Optional | Specify the path where archived WAL files will be stored. The default location is the BART backup catalog (`//archived_wals`). | +| `` | Optional | When the `INIT` subcommand is used, the content and variables specified in the BART `` result in the archive command string to be generated into the `Postgres archive_command` parameter in the `postgresql.auto.conf` file. To configure the BART `` parameter, enclose the command string within single quotes ('). If you do not specify the `` parameter in the configuration file, the default setting is taken as `'scp %p %h:%a/%f'`. See [Archive Command Auto Configuration](#archive_command_auto_configuration) for information about variables. The BART `` parameter in the BART configuration file, and the Postgres `` parameter in the `postgresql.conf` file (or the `postgresql.auto.conf` file) refer to two different parameters that are to be set in different manner. | +| `` | Mandatory | Specify the Linux operating system user account that owns the database cluster. This is typically `enterprisedb` for Advanced Server database clusters installed in the Oracle compatible mode, or `postgres` for Advanced Server database clusters installed in the PostgreSQL compatible mode and PostgreSQL database clusters. | +| `` | Optional | Specify the IP address of the remote server to which a backup is to be restored. Specify this parameter in the form of `@`. `` is the user account on the target database server host that accepts a passwordless SSH/SCP login connection and owns the directory where the backup is to be restored. `` is the IP address of the remote host. For restoring a backup to a remote host or for restoring any backup where `` and the BART user account are not the same users, either this parameter must be set or it may be specified with the `-r` option with the BART `RESTORE` subcommand. | +| `` | Optional | Specify path to which tablespaces are to be restored in the format `OID = `; If the backup is to be restored to a remote host specified by the `` parameter, then the tablespace paths must exist on the remote host. | +| `allow_incremental_backups` | Optional | Set this parameter to `enabled` to enable use of the WAL scanner and permit taking incremental backups when the `BACKUP` subcommand is invoked with the `--parent` option. Set it to `disabled` (default) to disallow incremental backups and thus permit only full backups. For information about using the `BACKUP` subcommand and running the WAL scanner, please see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/latest/bart_user/). | +| `Description` | Optional | Specify the description that will be used to identify the database server. | + +For information regarding the following parameters, see [configuring the BART host](#configuring-the-bart-host). + +- `retention_policy` +- `xlog_method` +- `wal_compression` +- `copy_wals_during_restore`. +- `thread_count`. +- `batch_size`. +- `scan_interval`. +- `mbm_scan_timeout`. +- `workers` + + + +**Backup Name Template** + +- The template is an alphanumeric string that may include the following variables that will be replaced with the timestamp values when the backup is taken: + + - `%year` to be replaced by 4-digit year + - `%month` to be replaced by 2-digit month + - `%day` to be replaced by 2-digit day + - `%hour` to be replaced by 2-digit hour + - `%minute` to be replaced by 2-digit minute + - `%second` to be replaced by 2-digit second + +- To include a percent sign (`%`) as a character in the backup name, specify `%%` in the template. + +- Do not enclose the template string in quotes even if you want the template to include space characters, otherwise the enclosing quotes are stored as part of the backup name. However, when referenced with the `-i` option by BART subcommands use of space characters in the backup name requires enclosing the backup name in quotes. + +The following example shows the configuration settings of three database servers: + +```text +[ACCTG] + +host = 127.0.0.1 +port = 5444 +user = enterprisedb +cluster_owner = enterprisedb +backup_name = acctg_%year-%month-%dayT%hour:%minute:%second +archive_command = 'cp %p %a/%f' +allow_incremental_backups = enabled +retention_policy = 8 BACKUPS +description = "Accounting" + +[MKTG] + +host = 192.168.2.24 +port = 5444 +user = repuser +cluster_owner = enterprisedb +remote_host = enterprisedb@192.168.2.24 +allow_incremental_backups = enabled +description = "Marketing" + +[HR] + +host = 127.0.0.1 +port = 5432 +user = postgres +cluster_owner = postgres +retention_policy = 4 DAYS +description = "Human Resources" +``` + + + +**Enabling WAL Archiving** + +WAL archiving must be enabled for the database server for which BART is to perform backup and recovery management. + +- The WAL Archiving Configuration section describes the manual WAL archiving configuration process. +- The Archive Command Auto Configuration section describes an automated WAL archiving process. + +*WAL Archiving Configuration* + +Set the following configuration parameters in the `postgresql.conf` file to enable WAL archiving + +- Set `wal_level` to `replica` or higher. +- Set `archive_mode` to `on`. +- Set the PostgreSQL `archive_command` parameter to copy the WAL files to the `archive_path`. The `archive_command` configuration parameter mentioned here is located in the `postgresql.conf` file; the PostgreSQL `archive_command` parameter is used in a different manner than the BART [archive_command](#archive_command). +- Set `max_wal_senders` to a value high enough to leave at least one session available for the backup. If the `xlog_method=stream` parameter setting is to be used by this database server, the `max_wal_senders` setting must account for an additional session for the transaction log streaming (the setting must be a minimum of 2). See [Configuring the BART host](#configuring-the-bart-host) for information about the `xlog_method` parameter. + +For detailed information about WAL archiving, see the [PostgreSQL Core Documentation](https://www.postgresql.org/docs/current/static/continuous-archiving.html). + +The `ARCHIVE PATH` field displayed by the BART `SHOW-SERVERS` subcommand displays the full directory path where the WAL files should be copied as specified in the `archive_command` configuration parameter in the `postgresql.conf` file: + +```text +-bash-4.1$ bart SHOW-SERVERS -s acctg +SERVER NAME : acctg +HOST NAME : 192.168.2.24 +USER NAME : repuser +PORT : 5444 +REMOTE HOST : +RETENTION POLICY : none +DISK UTILIZATION : 0.00 bytes +NUMBER OF ARCHIVES : 0 +ARCHIVE PATH : /opt/backup/acctg/archived_wals +ARCHIVE COMMAND : (disabled) +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +INCREMENTAL BACKUP : DISABLED +DESCRIPTION : "Accounting" +``` + +The parameter settings in the following example will copy the WAL files to a directory named `/opt/backup/acctg/archived_wals` on the BART host located at `192.168.2.22` as the `bartuser` user account. Using the `bartuser` account ensures that the operation will have sufficient permissions to copy to the BART backup catalog owned by `bartuser`. + +```text +archive_mode = on # allows archiving to be done + # (change requires restart) +archive_command = 'scp %p bartuser@192.168.2.22:/opt/backup/acctg/archived_wals/%f' + # command to use to archive a logfile segment + # placeholders: %p = path of file to archive + # %f = file name only +... + +max_wal_senders = 1 # max number of walsender processes + # (change requires restart) +``` + +The database server must be restarted in order to initiate WAL archiving, but do not do so until you have verified that the full path of the BART backup catalog has been created by a prior BART subcommand or the archive operation will fail. + +Start the WAL scanner by executing the following command: + +```text +./bart-scanner +``` + + + +*Archive Command Auto Configuration* + +To enable WAL archiving: + +- In the `postgresql.conf` file, set the `wal_level` to `replica` or higher, `archive_mode` to `on`, and `max_wal_senders` to a value high enough to leave at least one session available for the backup. If the `xlog_method=stream` parameter setting is to be used by this database server as determined in the BART configuration file, the `max_wal_senders` setting must account for an additional session for the transaction log streaming (that is, the setting must be a minimum of `2`). See [Configuring the BART host](#configuring-the-bart-host) for information on the `xlog_method` parameter. + +- Configure the Postgres `archive_command` parameter automatically with the `INIT` subcommand and restart the database server when you are ready to initiate WAL archiving. The `INIT` subcommand invokes the Postgres `ALTER SYSTEM` command to set the Postgres `archive_command` configuration parameter in the `postgresql.auto.conf` file located in the managed database server’s `POSTGRES_INSTALL_HOME data directory`. For additional information about the `INIT` subcommand, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/latest/bart_user/). + + The archive command string that the `INIT` subcommand generates into the `postgresql.auto.conf` file is determined by the parameter setting of the BART `archive_command` parameter in the server section of the BART configuration file. If the BART `archive_command` parameter is not set in the server section for a given database server, the command string that is configured uses the following default format: + + `'scp %p %h:%a/%f'` + + The following table describes these variables: + +| **Variable** | **Description** | +| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `%p` | The path of the file to archive used by the Postgres archiving process. | +| `%h` | Will be replaced by the `@` as specified in the <bart_host> parameter setting. | +| `%a` | Will be replaced by the BART `archived_wals` directory as specified in the [archive path](#archive_path) parameter setting. If the `` is not specified, then the default directory is `//archived_wals`. `` is the lowercase conversion of the database server name. | +| `%f` | The archived file name used by the Postgres archiving process. | + +The placeholders `%h` and `%a` are replaced by the `INIT` subcommand when creating the archive command string. The placeholders `%p` and `%f` are not replaced by the `INIT` subcommand, but are kept as given to be used by the Postgres archiving process. + +For example, to use the default archive command format, the BART configuration file contains the following settings where the BART `archive_command` parameter is omitted from the server section for `ACCTG`: + +```text +[BART] + +bart_host= bartuser@192.168.2.22 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log + +[ACCTG] + +host = 127.0.0.1 +port = 5444 +user = repuser +cluster_owner = enterprisedb +description = "Accounting" +``` + +The `INIT` subcommand is invoked by BART user account `bartuser` as follows: + +```text +[bartuser@localhost ~]$ bart INIT -s acctg -o +INFO: setting archive_command for server 'acctg' +WARNING: archive_command is set. server restart is required +``` + +If the BART backup catalog directory is not already complete, it will be completed. + +The resulting archive command string in the `postgresql.auto.conf` file located in the managed database server’s `POSTGRES_INSTALL_HOME/data directory` appears as follows: + +```text +# Do not edit this file manually! +# It will be overwritten by ALTER SYSTEM command. +archive_command = 'scp %p +bartuser@192.168.2.22:/opt/backup/acctg/archived_wals/%f' +``` + +Run the `INIT` subcommand with the `-o` option to override any existing `archive_command` setting in the `postgresql.conf` or the `postgresql.auto.conf` file. In addition, the `-o` option must be used to generate the command string if the `archive_mode` is set to off even if there are no existing settings of the `archive_command` in the `postgresql.conf` or `postgresql.auto.conf` files. + +In this example, the following BART configuration file is used with an explicit setting of the BART `archive_command` parameter: + +```text +[BART] + +bart_host= enterprisedb@192.168.2.22 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log + +[ACCTG] + +host = 127.0.0.1 +port = 5444 +user = repuser +cluster_owner = enterprisedb +archive_command = 'cp %p %a/%f' +description = "Accounting" +``` + +The `INIT` subcommand is invoked by BART user account `enterprisedb` as follows: + +```text +-bash-4.1$ bart INIT -s acctg -o +INFO: setting archive_command for server 'acctg' +WARNING: archive_command is set. server restart is required +``` + +The resulting Postgres `archive_command` parameter in the `postgresql.auto.conf` file appears as follows: + +```text +# Do not edit this file manually! +# It will be overwritten by ALTER SYSTEM command. +archive_command = 'cp %p /opt/backup/acctg/archived_wals/%f' +``` + +When the database server has been restarted, the `ARCHIVE COMMAND` field of the `SHOW-SERVERS` subcommand displays the active Postgres archive command as shown by the following example: + +```text +-bash-4.1$ bart SHOW-SERVERS -s acctg +SERVER NAME : acctg +HOST NAME : 127.0.0.1 +USER NAME : repuser +PORT : 5444 +REMOTE HOST : +RETENTION POLICY : none +DISK UTILIZATION : 48.00 MB +NUMBER OF ARCHIVES : 0 +ARCHIVE PATH : /opt/backup/acctg/archived_wals +ARCHIVE SCOMMAND : `cp %p /opt/backup/acctg/archived_wals/%f` +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +INCREMENTAL BACKUP : DISABLED +DESCRIPTION : "Accounting" +``` + + + +**Verifying Configuration Settings** + +To verify the parameter settings of the database server specified, execute tthe `CHECK-CONFIG` subcommand with the `–s` option: + +```text +bart CHECK-CONFIG [ –s server_name ] +``` + +The `CHECK-CONFIG` subcommand confirms the following: + +- The `cluster_owner` parameter is set to the user account owning the database cluster directory. +- A passwordless SSH/SCP connection is set between the BART user and the user account specified by the `cluster_owner` parameter. +- The BART `user` parameter specifies a database superuser. +- The BART `user` has access to the backup directory catalog. +- The `pg_hba.conf` file contains a replication entry for the database superuser specified by the BART `user` parameter. +- The `archive_mode` parameter in the `postgresql.conf` file is enabled. +- The `archive_command` parameter in the `postgresql.auto.conf` or the `postgresql.conf` file is set. +- The `allow_incremental_backups` parameter in the BART configuration file is enabled for database servers for which incremental backups are to be taken. +- Archiving of WAL files to the `archive_path` is in process. +- The WAL scanner program is running. + +After configuring the BART host and the database server(s), you can start using BART. For information about using BART, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/latest/bart_user/). diff --git a/product_docs/docs/bart/2.6.2/bart_inst/04_upgrading_bart.mdx b/product_docs/docs/bart/2.6.2/bart_inst/04_upgrading_bart.mdx new file mode 100644 index 00000000000..7ea815ecd15 --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_inst/04_upgrading_bart.mdx @@ -0,0 +1,76 @@ +--- +title: "Upgrading BART" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/installation-getting-started/installation-upgrade-guide/2.6.1/upgrading_bart.html" +--- + + + +This section outlines the process of upgrading BART from an existing version to the latest version. + +**Upgrade Restrictions** + +The following restrictions apply with regard to previous BART versions. + +- You can take incremental backups using the latest version only when the parent backup (full or incremental backup) has also been taken with the latest version. +- Using the latest version, you can restore incremental backups that are taken only with the latest version of BART. However, using the latest version you can restore full backups that were taken with older versions. + + + +## Upgrading from Older Versions of BART + +Perform the following steps to upgrade from older versions of BART to the latest version: + +**Step 1:** Assume the identity of the BART user account and invoke the following command to stop the BART WAL scanner program (`bart-scanner`): + +```text +bart-scanner STOP +``` + +**Step 2:** As the `root` user, upgrade to the latest BART version with the `yum upgrade` command. + +- To upgrade the BART RPM package directly from the *EDB Yum Repository* website, specify only the package name: + + On CentOS 7: + + ```text + yum upgrade edb-bart + ``` + + You can also use a downloaded RPM package file to upgrade. To use a downloaded BART RPM package file to upgrade, use the `yum` command, specifying the complete RPM package file name: + + ```text + yum upgrade edb-bart-x.y.z rhel7.x86_64.rpm + ``` + + Where x denotes the major version of BART, and y and z denotes the minor version. + + On a Debian or Ubuntu Host: + + ```text + apt-get upgrade edb-bart + ``` + + On a SLES Host: + + ```text + zypper update edb-bart + ``` + +**Step 3:** Repeat the process described in this section to upgrade to the latest BART version on each remote hosts where an incremental backup will be restored. + +For additional information about restoration of incremental backups on remote hosts, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/latest/bart_user/). + +**Step 4:** If the `bart --version` command returns an error stating the `PATH` is not available after switching from `root` user to another BART user account, adjust the setting of the `PATH` environment variable to include the location of the BART x.y.z (x denotes the major version of BART, and y and z denotes the minor version) executable (the `bin` subdirectory) in the `~/.bashrc` or `~/.bash_profile` files of the following user accounts: + +- The BART user account on the BART host. +- The remote user account on the remote host to which incremental backups are to be restored. For details, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/latest/bart_user/). + +The `PATH` setting should be the same as set for BART x.y.z since all versions use `/usr/edb/bart/bin`. + +!!! Note + After upgrading to the latest BART version, you must take a new full backup of your system before performing an incremental backup. + + \ No newline at end of file diff --git a/product_docs/docs/bart/2.6.2/bart_inst/05_uninstalling_bart.mdx b/product_docs/docs/bart/2.6.2/bart_inst/05_uninstalling_bart.mdx new file mode 100644 index 00000000000..8374221ef88 --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_inst/05_uninstalling_bart.mdx @@ -0,0 +1,50 @@ +--- +title: "Uninstalling BART" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/installation-getting-started/installation-upgrade-guide/2.6.1/uninstalling_bart.html" +--- + + + +This section walks you through uninstalling BART. + +## Uninstalling BART on a RHEL/CentOS Host + +To uninstall BART on a RHEL/CentOS host, assume the identity of the `root` user and invoke the following command: + +On RHEL/CentOS 7: + +```text +yum remove edb-bart +``` + +On RHEL/CentOS 8: + +```text +dnf remove edb-bart +``` + +Uninstalling BART does not delete the backup files and archived WAL files that reside in the BART backup catalog. To permanently delete the backup files and archived WAL files in the BART backup catalog (`/opt/backup`), use one of the following commands: + +- `rm –rf /opt/backup` +- BART `DELETE` subcommand + +For information about the BART `DELETE` subcommand, see the *EDB Backup and Recovery User Guide* available at the [EDB website](/bart/latest/bart_user/). + +## Uninstalling BART on an SLES 12 Host + +To uninstall BART on an SLES 12 host, assume the identity of the `root` user and invoke the following command: + +```text +zypper remove edb-bart +``` + +## Uninstalling BART on a Debian/Ubuntu Host + +To uninstall BART on a Debian or Ubuntu host, invoke the following command: + +```text +apt-get remove edb-bart +``` diff --git a/product_docs/docs/bart/2.6.2/bart_inst/images/EDB_logo.png b/product_docs/docs/bart/2.6.2/bart_inst/images/EDB_logo.png new file mode 100644 index 00000000000..39a54822d85 Binary files /dev/null and b/product_docs/docs/bart/2.6.2/bart_inst/images/EDB_logo.png differ diff --git a/product_docs/docs/bart/2.6.2/bart_inst/images/edb.png b/product_docs/docs/bart/2.6.2/bart_inst/images/edb.png new file mode 100644 index 00000000000..71e5bdde787 Binary files /dev/null and b/product_docs/docs/bart/2.6.2/bart_inst/images/edb.png differ diff --git a/product_docs/docs/bart/2.6.2/bart_inst/images/edb_logo.svg b/product_docs/docs/bart/2.6.2/bart_inst/images/edb_logo.svg new file mode 100644 index 00000000000..f24d1dfefee --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_inst/images/edb_logo.svg @@ -0,0 +1,19 @@ + + + edb-logo-disc-dark + + + + \ No newline at end of file diff --git a/product_docs/docs/bart/2.6.2/bart_inst/images/edblogo.png b/product_docs/docs/bart/2.6.2/bart_inst/images/edblogo.png new file mode 100644 index 00000000000..71e5bdde787 Binary files /dev/null and b/product_docs/docs/bart/2.6.2/bart_inst/images/edblogo.png differ diff --git a/product_docs/docs/bart/2.6.2/bart_inst/index.mdx b/product_docs/docs/bart/2.6.2/bart_inst/index.mdx new file mode 100644 index 00000000000..d1abcfedd20 --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_inst/index.mdx @@ -0,0 +1,45 @@ +--- +navTitle: Installation Guide +title: "EDB Postgres Backup and Recovery Installation Guide" +legacyRedirects: + - "/edb-docs/d/edb-backup-and-recovery-tool/installation-getting-started/installation-upgrade-guide/2.6.1/requirements_overview.html" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/installation-getting-started/installation-upgrade-guide/2.6.1/conclusion.html" + - "/edb-docs/d/edb-backup-and-recovery-tool/installation-getting-started/installation-upgrade-guide/2.6.1/genindex.html" + - "/edb-docs/d/edb-backup-and-recovery-tool/installation-getting-started/installation-upgrade-guide/2.6.1/index.html" +--- + +This guide provides information about how to install and configure the EDB Backup and Recovery Tool (BART) 2.6. + + + +## Requirements Overview + +### Supported Platforms and Database Versions + +- To view a complete list of supported platforms, visit the [EDB website.](https://www.enterprisedb.com/services-support/edb-supported-products-and-platforms) + +!!! Note + BART 2.6 is no longer supported on CentOS/RHEL/OEL 6.x platforms. It is strongly recommended that EDB products running on these platforms be migrated to a supported platform. + +- BART supports the following database versions: + + - Advanced Server versions 9.6, 10, 11, 12, and 13. + - PostgreSQL versions 9.6, 10, 11, 12, and 13. + +### Software Requirements + +You require the following components to install BART. + +- BART Host Components - Use EDB packages to add BART host components; see [Installing BART](02_installing_bart/#installing-bart) for information about how to install these components. + +- Additional Components - In addition to the BART host components, the following components are required: + + - The [Secure Shell (SSH) server daemon and Secure Copy (SCP) client programs](03_configuring_bart/#authorizing_ssh_scp_access) must be enabled and activated on the BART host as well as on the remote database server hosts on which BART will be managing backup and recovery. + - BART uses the `pg_basebackup` utility program when taking full backups. + +### Limitation + +BART supports taking only a full backup of standby servers; it does not support taking incremental or parallel backups of standby servers. diff --git a/product_docs/docs/bart/2.6.2/bart_qs_7/images/EDB_logo.png b/product_docs/docs/bart/2.6.2/bart_qs_7/images/EDB_logo.png new file mode 100644 index 00000000000..39a54822d85 Binary files /dev/null and b/product_docs/docs/bart/2.6.2/bart_qs_7/images/EDB_logo.png differ diff --git a/product_docs/docs/bart/2.6.2/bart_qs_7/images/edb.png b/product_docs/docs/bart/2.6.2/bart_qs_7/images/edb.png new file mode 100644 index 00000000000..71e5bdde787 Binary files /dev/null and b/product_docs/docs/bart/2.6.2/bart_qs_7/images/edb.png differ diff --git a/product_docs/docs/bart/2.6.2/bart_qs_7/images/edb_logo.svg b/product_docs/docs/bart/2.6.2/bart_qs_7/images/edb_logo.svg new file mode 100644 index 00000000000..f24d1dfefee --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_qs_7/images/edb_logo.svg @@ -0,0 +1,19 @@ + + + edb-logo-disc-dark + + + + \ No newline at end of file diff --git a/product_docs/docs/bart/2.6.2/bart_qs_7/images/image2.png b/product_docs/docs/bart/2.6.2/bart_qs_7/images/image2.png new file mode 100644 index 00000000000..4eba2e7efa7 Binary files /dev/null and b/product_docs/docs/bart/2.6.2/bart_qs_7/images/image2.png differ diff --git a/product_docs/docs/bart/2.6.2/bart_qs_7/index.mdx b/product_docs/docs/bart/2.6.2/bart_qs_7/index.mdx new file mode 100644 index 00000000000..204cd9ebc2a --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_qs_7/index.mdx @@ -0,0 +1,321 @@ +--- +title: "Quick Start Guide for RHEL/CentOS 7" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/quick-start/quick-start-guide-for-rhelcentos-7/2.6.1/genindex.html" + - "/edb-docs/d/edb-backup-and-recovery-tool/quick-start/quick-start-guide-for-rhelcentos-7/2.6.1/index.html" +--- + +This tutorial demonstrates using `yum` to [install](#installing) and [configure](../bart_qs_8/#configuring) Backup and Recovery Tool (BART) 2.6 on a CentOS 7 host with minimal configuration settings.  The tutorial assumes that the user has some knowledge of installation and system administration procedures, and has administrative privileges on the host. + +For detailed information about BART installation and configuration, see the *BART Installation and Upgrade Guide*, available at the [EDB website](/bart/latest/bart_inst/). + +- BART is tested with the following database versions: + + - Advanced Server - 9.6, 10, 11, 12, and 13. + - PostgreSQL - 9.6, 10, 11, 12, and 13. + + + +**Installing BART** + +The following steps describe installing BART on CentOS 7.x OS using `yum`. + +1. Assume superuser privileges and use `yum` to create the repository configuration file: + + ```text + yum install -y https://yum.enterprisedb.com/edbrepos/edb-repo-latest.noarch.rpm + ``` + +2. Create an EDB user account to request credentials to the EDB repository; for a user account visit the [EnterpriseDB website](https://www.enterprisedb.com/repository-access-request). + +3. Use your choice of editor to open the repository configuration file (named `edb.repo`, located in `/etc/yum.repos.d`), and set the `enabled` parameter value to `1`, and replace the `username` and `password` placeholders in the `baseurl` specification with the username and password of a registered EnterpriseDB user. + +4. Update the cache: + + ```text + yum makecache + ``` + +5. Install an Advanced Server or PostgreSQL database server. + + To install Advanced Server, execute the following command: + + ```text + yum -y install edb-as12-server + ``` + + Use sudo to assume the identity of the `enterprisedb` database superuser + + ```text + sudo su - enterprisedb + ``` + + Create an Advanced Server cluster named `acctg` on listener port `5444`: + + ```text + /usr/edb/as12/bin/initdb -D /var/lib/edb/as12/acctg + ``` + + As the `enterprisedb` user, start the cluster: + + ```text + /usr/edb/as12/bin/pg_ctl start -D /var/lib/edb/as12/acctg + ``` + + You can check the status of the cluster with the following command: + + ```text + /usr/edb/as12/bin/pg_ctl status -D /var/lib/edb/as12/acctg + ``` + + !!! Note + The BART host server is not required to have an Advanced Server or PostgreSQL installation, but must include a copy of the Postgres `libpq` library, the `pg_basebackup` utility program, and Boost Libraries 1.53 version for CentOS 7. + +6. If you do not already have the `pg_basebackup` program installed on the BART host, you can use the following command to install a limited number of files that include the `pg_basebackup` program: + + ```text + yum install edb-as-server-client + ``` + + Where <xx> is the Advanced Server version. + +7. As a root user, execute the following command to install BART: + + ```text + yum install edb-bart + ``` + +BART (the bart program and bart-scanner) is installed in the `/usr/edb/bart/bin` directory, referred to as ``. Repeat the installation process described in this section to install BART on all remote hosts where incremental backups are to be restored. + + + +**Configuring BART** + +Before configuring BART, establish the BART user account (the operating system user) that will run the BART command line program. Then, to configure the BART host and each database server that is to be managed by BART, perform the following steps: + +1. Assume superuser privileges, create the directory that will hold the BART backup catalog, and assign its ownership (with restrictive privileges) to the BART user account: + + In this example, `bartuser` is the BART user account and `/opt/backup` is the BART backup catalog. + + ```text + su root + mkdir /opt/backup + chown bartuser /opt/backup + chgrp bartuser /opt/backup + chmod 700 /opt/backup + ``` + +2. Navigate to the `/usr/edb/bart/etc` directory and copy the `bart.cfg.sample` file to create the BART configuration file (`bart.cfg`): + + ```text + cp bart.cfg.sample bart.cfg + ``` + +3. Open the BART configuration file (`bart.cfg`) using an editor of your choice and scroll through the BART configuration file to edit the file as required; sample settings are included for your reference. You must add the mandatory parameters to the `[BART]` and `[ServerName]` sections. Default values may be used for optional parameters. For detailed information about parameter settings, see the *BART Installation and Upgrade Guide*, available at the [EDB website](/bart/latest/bart_inst/). + + Parameters set in the `[BART]` section are applicable to all BART managed database servers, while parameters set in the `[ServerName]` section are applicable only to the specific server; `[ServerName]` settings override `[BART]` section settings. + + In the following example, only mandatory parameters are set: + + ```text + [BART] + bart_host= bartuser@192.168.169.199 + backup_path = /opt/backup + pg_basebackup_path = /usr/edb/as12/bin/pg_basebackup + + [EPAS12] + host = 127.0.0.1 + user = repuser + cluster_owner = enterprisedb + ``` + +The following table describes only mandatory parameters: + +| **Parameters/Placeholder** | **Section** | **Description** | +| -------------------------- | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `bart_host` | `[BART]` | Use this field to specify the BART user and the IP address of the host on which the BART utility is installed. Specify the value in the form of `@`. | +| `backup_path` | `[BART]` | Use this field to specify the path where all BART backups and archived WAL files will be stored. Ensure the BART user account holds privileges to create subdirectories and files within the location specified in the `backup_path` parameter. The default `backup_path` is BART backup catalog (`/opt/backup`). | +| `pg_basebackup_path` | `[BART]` | Use this field to specify the path to the pg_basebackup utility (`/usr/edb/as/bin/pg_basebackup`). | +| `[ServerName]` | `[ServerName]` | Specify the name of the database server to be backed up (for example, \[EPAS12]). | +| `host` | `[ServerName]` | Specify the IP address of the database server to be configured for backup. | +| `user` | `[ServerName]` | Specify the replication database user name used by BART to establish the connection to the database server for full backups. | +| `cluster_owner` | `[ServerName]` | Specify the Linux operating system user account that owns the database cluster. | + +4. As a BART user, navigate to `/usr/edb/bart/bin` and invoke the following subcommand (omitting the `-s` option) to verify the \[BART] section parameter settings: + + ```text + bart CHECK-CONFIG + ``` + +5. Authorize [SSH/SCP access](../bart_qs_8/#passwordless) between the server and the BART host without a password prompt. + +6. Create a [replication database user](../bart_qs_8/#replication) for each database server that BART manages. + +7. To enable continuous WAL archiving for any database server for which BART is to perform a backup, modify the `postgresql.conf` file, setting: + + - `wal_level` to `replica` or higher (for Postgres 9.6 or later) + - `archive_mode` to `on` + - `archive_command` (if it is not set in the `bart.cfg` file) + - `max_wal_senders` to a value high enough to leave at least one session available for the backup. + + After setting the parameters, restart the database server. + +8. To start the WAL scanner, navigate to `/usr/edb/bart/bin` as a BART user and execute the following command: + + ```text + ./bart-scanner + ``` + +9. If you are using the default `archive_command`, then navigate to `/usr/edb/bart/bin` as a BART user, run the `INIT` subcommand without the `-o` option, and restart the database server: + + ```text + bart INIT [ -s { | all } ] + ``` + + Where `` is the name of the database server to be backed up. + + If you have customized the `archive_command` setting in the `bart.cfg` file, run the `INIT` subcommand with the `-o` option to override any existing Postgresql `archive_command` setting in the `postgresql.conf` or the `postgresql.auto.conf` file, and restart the database server. + + ```text + bart INIT [ -s { | all } ] [ -o ] + ``` + +10. To verify the database server parameter settings, as a BART user navigate to `/usr/edb/bart/bin` and invoke the `CHECK-CONFIG` subcommand with the -s option: + + ```text + bart CHECK-CONFIG [ -s ] + ``` + + BART is now configured successfully. For detailed information about using BART, see the *EDB Backup and Recovery Tool User Guide*, available at the [EDB website](/bart/latest/bart_user/). + + + +**Creating a Passwordless Connection** + +The following example enables SSH/SCP access on a CentOS 7.x host; similar (platform-specific) steps will apply to other platforms/versions. You must create a passwordless connection between the BART host (SSH/SCP client) and the database server (target SSH/SCP server), as well as a passwordless connection between the database server (SSH/SCP client) and the BART host (target SSH/SCP server). + +1. Log in as the user account on the BART host that will be initiating the SSH or SCP connection and navigate to the user account’s home directory and check for an existing `.ssh` subdirectory. If the `.ssh` directory does not exist, create one with the required privileges. + +2. As a root user navigate to `/usr/edb/bart`, open the `/etc/ssh/sshd_config` file and set the `PubkeyAuthentication` parameter to `yes`. + +3. Reload the configuration file: + + ```text + service sshd reload + ``` + + If you get any SSH or SCP errors, examine the log file (`/var/log/secure`). + +4. As a BART user, use the following command to generate the public key file; you can accept the default responses: + + ```text + ssh-keygen -t rsa + ``` + + The public key file named `id_rsa.pub` is created in the `.ssh` subdirectory. + +5. Use `SCP` to make a temporary copy of the public key file on the target server: + + ```text + scp ~/.ssh/id_rsa.pub target_user@host_address:tmp.pub + ``` + +6. As a `target_user`, log into the target server using `ssh target_user@host_address` command and navigate to the user account’s home directory to check if there is an existing `.ssh` subdirectory. If it does not exist, create one with the required privileges. + +7. Append the client’s temporary public key file, `tmp.pub`, to the `authorized_keys` file: + + ```text + cat tmp.pub >> ~/.ssh/authorized_keys + ``` + + If an `authorized_keys` file does not exist, create a new file, but be careful not to completely replace any existing `authorized_keys` file. + +8. Ensure only the file owner (and not other groups or users) has access to `authorized_keys` file: + + ```text + chmod 600 ~/.ssh/authorized_keys + ``` + +9. Delete the temporary public key file: + + ```text + rm tmp.pub + ``` + + Now, when logged into the BART host as a user, there should be no prompt for a password when you are connecting to the target database server: + + ```text + ssh target_user@database_server_address + ``` + +**Creating a Passwordless Connection Between the Database Server and the BART Host** + +If backups are to be taken from a given database server host, but restored to a different database server host, the passwordless SSH/SCP connections must be configured from the BART host to the database server host from which the backup is to be taken as well as from the BART host to the database server host to which the backup is to be restored. + +An example of how to create a passwordless connection is documented in the *EDB Backup and Recovery Reference Guide*, available at the [EDB website](/bart/latest/bart_ref/). + +Even when the Advanced Server database is on the same host as BART, and the Advanced Server database cluster owner is also the BART user account, a passwordless SSH/SCP connection must be established from the same user account to itself. + +1. On the database server, navigate into the target user account’s home directory to check for an existing `.ssh` subdirectory. If it does does not exist, create one in the user account’s home directory with the required privileges. + +2. As a database server user, generate the public key file: + + ```text + ssh-keygen -t rsa + ``` + +3. Create a temporary copy of the public key file: + + ```text + scp ~/.ssh/id_rsa.pub target_user@host_address:tmp.pub + ``` + +4. As a target user, log into the BART host and navigate to the user account’s home directory to check if there is an existing `.ssh` subdirectory. If it does not exist, create one with the required privileges: + + ```text + ssh target_user@host_address + ``` + +5. Append the temporary, client’s public key file to the `authorized_keys` file: + + ```text + cat tmp.pub >> ~/.ssh/authorized_keys + ``` + +If an `authorized_keys` file does not exist, create a new file, but do not completely replace any existing `authorized_keys` file. + +6. Ensure only the file owner (and not other groups or users) has access to `authorized_keys` file: + + ```text + chmod 600 ~/.ssh/authorized_keys + ``` + +7. Delete the temporary public key file: + + ```text + rm tmp.pub + ``` + + Now, when logged into the database server as a user, there should be no prompt for a password when you are connecting to the BART host: + + ```text + ssh bart_user@bartip_address + ``` + + + +**Creating a Replication Database User** + +1. To create a replication database user (a superuser), connect to the database server with the psql client, and invoke the following PostgreSQL command: + + ```text + CREATE ROLE WITH LOGIN SUPERUSER PASSWORD ''; + ``` + +2. Specify this replication database user in the `user` parameter of the `bart.cfg` file. + +3. The [pg_hba.conf](https://www.postgresql.org/docs/current/auth-pg-hba-conf.html) file must minimally permit the replication database user to have access to the database. The IP address from which the replication database user has access to the database is the BART host location. The replication database user must also be included in the `pg_hba.conf` file as a replication database connection if `pg_basebackup` is to be used for taking any backups. + +4. To ensure there is no password prompt when connecting to the database server with the replication database user, a recommended method is to use the `.pgpass` file located in the BART user account’s home directory (if it does not exist, you need to create the `.pgpass` file with the required privileges). The `.pgpass` file must contain an entry for each BART managed database server, and its corresponding replication database user and password. diff --git a/product_docs/docs/bart/2.6.2/bart_qs_8/images/EDB_logo.png b/product_docs/docs/bart/2.6.2/bart_qs_8/images/EDB_logo.png new file mode 100644 index 00000000000..39a54822d85 Binary files /dev/null and b/product_docs/docs/bart/2.6.2/bart_qs_8/images/EDB_logo.png differ diff --git a/product_docs/docs/bart/2.6.2/bart_qs_8/images/edb.png b/product_docs/docs/bart/2.6.2/bart_qs_8/images/edb.png new file mode 100644 index 00000000000..71e5bdde787 Binary files /dev/null and b/product_docs/docs/bart/2.6.2/bart_qs_8/images/edb.png differ diff --git a/product_docs/docs/bart/2.6.2/bart_qs_8/images/edb_logo.svg b/product_docs/docs/bart/2.6.2/bart_qs_8/images/edb_logo.svg new file mode 100644 index 00000000000..f24d1dfefee --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_qs_8/images/edb_logo.svg @@ -0,0 +1,19 @@ + + + edb-logo-disc-dark + + + + \ No newline at end of file diff --git a/product_docs/docs/bart/2.6.2/bart_qs_8/images/image2.png b/product_docs/docs/bart/2.6.2/bart_qs_8/images/image2.png new file mode 100644 index 00000000000..4eba2e7efa7 Binary files /dev/null and b/product_docs/docs/bart/2.6.2/bart_qs_8/images/image2.png differ diff --git a/product_docs/docs/bart/2.6.2/bart_qs_8/index.mdx b/product_docs/docs/bart/2.6.2/bart_qs_8/index.mdx new file mode 100644 index 00000000000..66f1039827d --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_qs_8/index.mdx @@ -0,0 +1,317 @@ +--- +title: "Quick Start Guide for RHEL/CentOS 8" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/quick-start/quick-start-guide-for-rhelcentos-8/2.6.1/genindex.html" + - "/edb-docs/d/edb-backup-and-recovery-tool/quick-start/quick-start-guide-for-rhelcentos-8/2.6.1/index.html" +--- + +This tutorial demonstrates using the `dnf` command to install and configure the EDB Backup and Recovery Tool (BART) 2.6 on a CentOS 8 host with minimal configuration settings.  The tutorial assumes that the user has some knowledge of installation and system administration procedures and has administrative privileges on the host. + +For detailed information about BART installation and configuration, see the *BART Installation and Upgrade Guide* available at the [EDB website](/bart/latest/bart_inst/). + +- BART is tested with the following database versions: + + - Advanced Server - 9.6, 10, 11, 12, and 13. + - PostgreSQL - 9.6, 10, 11, 12, and 13. + +**Installing BART** + +The following steps describe installing BART on CentOS 8.x OS. + +1. Assume superuser privileges and use `dnf` to create the repository configuration file: + + ```text + dnf install -y https://yum.enterprisedb.com/edbrepos/edb-repo-latest.noarch.rpm + ``` + +2. Create an EDB user account to request credentials to the EDB repository; for a user account visit the [EnterpriseDB website](https://www.enterprisedb.com/repository-access-request). + +3. Use your choice of editor to open the repository configuration file (named `edb.repo`, located in `/etc/yum.repos.d`), set the `enabled` parameter value to `1`, and replace the `username` and `password` placeholders in the `baseurl` specification with the username and password of a registered EnterpriseDB user. + +4. Update the cache: + + ```text + dnf makecache + ``` + +5. Install an Advanced Server or PostgreSQL database server. + + To install Advanced Server, execute the following command: + + ```text + dnf -y install edb-as12-server + ``` + + Use sudo to assume the identity of the `enterprisedb` database superuser: + + ```text + sudo su - enterprisedb + ``` + + Create an Advanced Server cluster named `acctg` on listener port `5444`: + + ```text + /usr/edb/as12/bin/initdb -D /var/lib/edb/as12/acctg + ``` + + As the `enterprisedb` user, start the cluster: + + ```text + /usr/edb/as12/bin/pg_ctl start -D /var/lib/edb/as12/acctg + ``` + + You can check the status of the cluster with the following command: + + ```text + /usr/edb/as12/bin/pg_ctl status -D /var/lib/edb/as12/acctg + ``` + + !!! Note + The BART host server is not required to have an Advanced Server or PostgreSQL installation, but must include a copy of the Postgres `libpq` library, the `pg_basebackup` utility program, and Boost Libraries 1.66 version for CentOS 8. + +6. If you do not already have the `pg_basebackup` program installed on the BART host, you can use the following command to install a limited number of files that include the `pg_basebackup` program: + + ```text + dnf install edb-asxx-server-client + ``` + +7. As a root user, use the following command to install the BART RPM package: + + ```text + dnf install edb-bart + ``` + +BART (the `bart` program and `bart-scanner`) is installed in the `/usr/edb/bart/bin` directory, referred to as ``. Repeat the installation process described in this section to install BART on all remote hosts where incremental backups are to be restored. + + + +**Configuring BART** + +Before configuring BART, establish the BART user account (the operating system user) to run the BART command line program. Then, to configure the BART host and each database server that is to be managed by BART, perform the following steps: + +1. Assume superuser privileges, create the directory that will hold the BART backup catalog, and assign its ownership (with restrictive privileges) to the BART user account: + + In this example, `bartuser` is the BART user account and `/opt/backup` is the BART backup catalog. + + ```text + su root + mkdir /opt/backup + chown bartuser /opt/backup + chgrp bartuser /opt/backup + chmod 700 /opt/backup + ``` + +2. Navigate to the `/usr/edb/bart/etc` directory and copy the `bart.cfg.sample` file to create the BART configuration file (`bart.cfg`): + + ```text + cp bart.cfg.sample bart.cfg + ``` + +3. Open the BART configuration file (`bart.cfg`) using an editor of your choice and scroll through the BART configuration file to edit the file as required; sample settings are included for your reference. You must add the mandatory parameters to the `[BART]` and `[ServerName]` sections. Default values may be used for optional parameters. For detailed information about parameter settings, see the *BART Installation and Upgrade Guide*, available at the [EDB website](/bart/latest/bart_inst/). + + Parameters set in the `[BART]` section are applicable to all BART managed database servers, while parameters set in the `[ServerName]` section are applicable only to the specific server; `[ServerName]` settings override `[BART]` section settings. + + In the following example, only mandatory parameters are set: + + ```text + [BART] + bart_host= bartuser@192.168.169.199 + backup_path = /opt/backup + pg_basebackup_path = /usr/edb/as12/bin/pg_basebackup + + [EPAS12] + host = 127.0.0.1 + user = repuser + cluster_owner = enterprisedb + ``` + +The following table describes only mandatory parameters: + +| **Parameters/Placeholder** | **Section** | **Description** | +| -------------------------- | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `bart_host` | `[BART]` | Use this field to specify the BART user and the IP address of the host on which the BART utility is installed. Specify the value in the form of `@`. | +| `backup_path` | `[BART]` | Use this field to specify the path where all BART backups and archived WAL files will be stored. Ensure the BART user account holds privileges to create subdirectories and files within the location specified in the `backup_path` parameter. The default `backup_path` is BART backup catalog (`/opt/backup`). | +| `pg_basebackup_path` | `[BART]` | Use this field to specify the path to the pg_basebackup utility (`/usr/edb/as/bin/pg_basebackup`). | +| `[ServerName]` | `[ServerName]` | Specify the name of the database server to be backed up (for example, \[EPAS12]). | +| `host` | `[ServerName]` | Specify the IP address of the database server to be configured for backup. | +| `user` | `[ServerName]` | Specify the replication database user name used by BART to establish the connection to the database server for full backups. | +| `cluster_owner` | `[ServerName]` | Specify the Linux operating system user account that owns the database cluster. | + +4. As a BART user, navigate to `/usr/edb/bart/bin` and invoke the following subcommand (omitting the `-s` option) to verify the \[BART] section parameter settings: + + ```text + bart CHECK-CONFIG + ``` + +5. Authorize [SSH/SCP access](#passwordless) between the server and the BART host without a password prompt. + +6. Create a [replication database user](#replication) for each database server that BART manages. + +7. To enable continuous WAL archiving for any database server for which BART is to perform a backup, modify the `postgresql.conf` file, setting: + + - `wal_level` to `replica` or higher (for Postgres 9.6 or later) + - `archive_mode` to `on` + - `archive_command` (if it is not set in the `bart.cfg` file) + - `max_wal_senders` to a value high enough to leave at least one session available for the backup. + + After setting the parameters, restart the database server. + +8. To start the WAL scanner, navigate to `/usr/edb/bart/bin` as a BART user and execute the following command: + + ```text + ./bart-scanner + ``` + +9. If you are using the default `archive_command`, then navigate to `/usr/edb/bart/bin` as a BART user, run the `INIT` subcommand without the `-o` option, and restart the database server: + + ```text + bart INIT [ -s { | all } ] + ``` + + Where `` is the name of the database server to be backed up. + + If you have customized the `archive_command` setting in the `bart.cfg` file, run the `INIT` subcommand with the `-o` option to override any existing Postgresql `archive_command` setting in the `postgresql.conf` or the `postgresql.auto.conf` file, and restart the database server. + + ```text + bart INIT [ -s { | all } ] [ -o ] + ``` + +10. To verify the database server parameter settings, as a BART user navigate to `/usr/edb/bart/bin` and invoke the `CHECK-CONFIG` subcommand with the -s option: + + ```text + bart CHECK-CONFIG [ -s ] + ``` + + BART is now configured successfully. For detailed information about using BART, see the *EDB Backup and Recovery Tool User Guide* available at the [EDB website](/bart/latest/bart_user/). + + + +**Creating a Passwordless Connection** + +The following example enables SSH/SCP access on a CentOS 7.x host; similar (platform-specific) steps will apply to other platforms/versions. You must create a passwordless connection between the BART host (SSH/SCP client) and the database server (target SSH/SCP server), as well as a passwordless connection between the database server (SSH/SCP client) and the BART host (target SSH/SCP server). + +1. Log in as the user account on the BART host that will be initiating the SSH or SCP connection and navigate to the user account’s home directory and check for an existing `.ssh` subdirectory. If the `.ssh` directory does not exist, create one with the required privileges. + +2. As a root user navigate to `/usr/edb/bart`, open the `/etc/ssh/sshd_config` file and set the `PubkeyAuthentication` parameter to `yes`. + +3. Reload the configuration file: + + ```text + service sshd reload + ``` + + If you get any SSH or SCP errors, examine the log file (`/var/log/secure`). + +4. As a BART user, use the following command to generate the public key file; you can accept the default responses: + + ```text + ssh-keygen -t rsa + ``` + + The public key file named `id_rsa.pub` is created in the `.ssh` subdirectory. + +5. Use `SCP` to make a temporary copy of the public key file on the target server: + + ```text + scp ~/.ssh/id_rsa.pub target_user@host_address:tmp.pub + ``` + +6. As a `target_user`, log into the target server using `ssh target_user@host_address` command and navigate to the user account’s home directory to check if there is an existing `.ssh` subdirectory. If it does not exist, create one with the required privileges. + +7. Append the temporary client’s public key file, `tmp.pub`, to the `authorized_keys` file: + + ```text + cat tmp.pub >> ~/.ssh/authorized_keys + ``` + + If an `authorized_keys` file does not exist, create a new file, but be careful not to completely replace any existing `authorized_keys` file. + +8. Ensure only the file owner (and not other groups or users) has access to `authorized_keys` file: + + ```text + chmod 600 ~/.ssh/authorized_keys + ``` + +9. Delete the temporary public key file: + + ```text + rm tmp.pub + ``` + + Now, when logged into the BART host as a user, there should be no prompt for a password when you are connecting to the target database server: + + ```text + ssh target_user@database_server_address + ``` + +**Creating a Passwordless Connection Between the Database Server and the BART Host** + +If backups are to be taken from a given database server host, but restored to a different database server host, the passwordless SSH/SCP connections must be configured from the BART host to the database server host from which the backup is to be taken as well as from the BART host to the database server host to which the backup is to be restored. + +An example of how to create a passwordless connection is documented in the *EDB Backup and Recovery Reference Guide*, available at the [EDB website](/bart/latest/bart_ref/). + +Even when the Advanced Server database is on the same host as BART, and the Advanced Server database cluster owner is also the BART user account, a passwordless SSH/SCP connection must be established from the same user account to itself. + +1. On the database server, navigate into the target user account’s home directory to check for an existing `.ssh` subdirectory. If it does does not exist, create one in the user account’s home directory with the required privileges. + +2. As a database server user, generate the public key file: + + ```text + ssh-keygen -t rsa + ``` + +3. Create a temporary copy of the public key file: + + ```text + scp ~/.ssh/id_rsa.pub target_user@host_address:tmp.pub + ``` + +4. As a target user, log into the BART host and navigate to the user account’s home directory to check if there is an existing `.ssh` subdirectory. If it does not exist, create one with the required privileges: + + ```text + ssh target_user@host_address + ``` + +5. Append the client’s temporary public key file to the `authorized_keys` file: + + ```text + cat tmp.pub >> ~/.ssh/authorized_keys + ``` + +If the `authorized_keys file` does not exist, create a new file, but do not completely replace any existing `authorized_keys` file. + +6. Ensure that only the file owner (and not other groups or users) has access to `authorized_keys` file: + + ```text + chmod 600 ~/.ssh/authorized_keys + ``` + +7. Delete the temporary public key file: + + ```text + rm tmp.pub + ``` + + Now, when logged into the database server as a user, there should be no prompt for a password when you are connecting to the BART host: + + ```text + ssh bart_user@bartip_address + ``` + + + +**Creating a Replication Database User** + +1. To create a replication database user (a superuser), connect to the database server with the psql client, and invoke the following PostgreSQL command: + + ```text + CREATE ROLE WITH LOGIN SUPERUSER PASSWORD ''; + ``` + +2. Specify this replication database user in the `user` parameter of the `bart.cfg` file. + +3. The [pg_hba.conf](https://www.postgresql.org/docs/current/auth-pg-hba-conf.html) file must minimally permit the replication database user to have access to the database. The IP address from which the replication database user has access to the database is the BART host location. The replication database user must also be included in the `pg_hba.conf` file as a replication database connection if `pg_basebackup` is to be used for taking any backups. + +4. To ensure there is no password prompt when connecting to the database server with the replication database user, a recommended method is to use the `.pgpass` file located in the BART user account’s home directory (if it does not exist, you need to create the `.pgpass` file with the required privileges). The `.pgpass` file must contain an entry for each BART managed database server, and its corresponding replication database user and password. diff --git a/product_docs/docs/bart/2.6.2/bart_ref/01_bart_subcommands_examples/01_backup.mdx b/product_docs/docs/bart/2.6.2/bart_ref/01_bart_subcommands_examples/01_backup.mdx new file mode 100644 index 00000000000..8b8f85eb4d0 --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_ref/01_bart_subcommands_examples/01_backup.mdx @@ -0,0 +1,271 @@ +--- +title: "BACKUP" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/backup.html" +--- + +Use the `BACKUP` subcommand to create a full or incremental backup. + +**Syntax for a Full Backup:** + +```text +bart BACKUP –s { | all } [ -F { p | t } ] + +[ -z ] [ –c ] + +[ --backup-name ] + +[ --thread-count ] + +[ { --with-pg_basebackup | --no-pg_basebackup } ] +``` + +**Syntax for an Incremental Backup:** + +```text +bart BACKUP –s [-Fp] + +[ --parent { | } ] + +[ --backup-name ] + +[ --thread-count ] + +[ { --checksum-algorithm } ] +``` + +Before performing an incremental backup, you must take a full backup. For more details about incremental backup, refer to *Block-Level Incremental Backup* in the *EDB Backup and Recovery User Guide* available at the [EDB website](/bart/latest/bart_user/). + +The following table describes the `BACKUP` options: + +| Options | Description | +| ---------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { \| all }`
`--server { \| all }` | Use this option to specify the database server to be backed up.
Specify `` to take a backup of the database server (as specified in the BART configuration file).
Specify `all` to take a backup of all servers. | +| `-F { p \| t }`
`--format { p \| t }` | Use this option to specify the backup file format.
Specify `p` option to take backup in plain text format and specify `t` option to take backup in tar format. If the `p` or `t` option is omitted, the default is tar format.
Use `p` option with the `BACKUP` subcommand when streaming is used as a backup method.
An incremental backup can only be taken in plain text format (`p`). | +| `-z`
`(--gzip)` | This option is applicable only for full backup and `tar` format. Use this option to enable gzip compression of tar files using the default compression level (typically 6). | +| `-c `
`--compress-level ` | This is applicable only for full backup and tar format. Use this option to specify the gzip compression level on the tar file output. `` is a digit from 1 through 9, with 9 being the best compression. | +| `--backup-name ` | Use this option to assign a user-defined, alphanumeric friendly name to the backup. The maximum permitted length of backup name is 49 characters.
For detailed information about this parameter, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/latest/bart_user/).
If the option `--backup-name` is not specified and the `backup_name` parameter is not set for this database server in the BART configuration file, then the backup can only be referenced in other BART subcommands by the BART assigned backup identifier. | +| `--thread-count ` | Use this option to specify the number of worker threads to run in parallel to copy blocks for a backup.
For detailed information about the `--thread-count` parameter, see the EDB Backup and Recovery Installation and Upgrade Guide available at the [EDB website](/bart/latest/bart_inst/). | +| `--with-pg_basebackup` | This is applicable only for full backup. Use this option to specify the use of `pg_basebackup` to take a full backup. The number of thread counts in effect is ignored as given by the `thread_count` parameter in the BART configuration file.
When taking a full backup, if the thread count in effect is greater than `1`, then the `pg_basebackup` utility is not used to take the full backup (parallel worker threads are used) unless the `--with-pg_basebackup` option is specified with the `BACKUP` subcommand. | +| `--no-pg_basebackup` | This is applicable only for full backup. Use this option to specify that `pg_basebackup` is not to be used to take a full backup.
When taking a full backup, if the thread count in effect is only `1`, then the `pg_basebackup` utility is used to take the full backup unless the `--no-pg_basebackup` option is specified with the `BACKUP` subcommand. | +| `--parent { \| }` | Use this option to take an incremental backup. The parent backup is a backup taken prior to the incremental backup; it can be either a full backup or an incremental backup. `` is the backup identifier of a parent backup and `` is the user-defined alphanumeric name of a parent backup. | +| `--check` | This is applicable only for incremental backup. Use this option to verify if the required MBM files are present in the BART backup catalog before taking an incremental backup. However, an actual incremental backup is not taken when the `--check` option is specified.
The `--parent` option must be used along with the `--check` option. | +| `--checksum-algorithm` | While taking a backup, you can specify one of the following values with the `--checksum-algorithm` option:
`--checksum-algorithm=MD5` (default) to generate MD5 checksum files.
`--checksum-algorithm=SHA256` to generate SHA256 checksum files.
`--checksum-algorithm=NONE` to skip generating checksum files. | + +**Examples** + +The following code sample demonstrates using variables with the `BACKUP` subcommand: + +```text +./bart backup -s ppas12 -Ft --backup-name "YEAR = %year MONTH = +%month DAY = %day" +``` + +```text +./bart backup -s ppas12 -Ft --backup-name "YEAR = %year MONTH = +%month DAY = %day %%" +``` + +```text +./bart show-backups -s ppas12 -i "test backup" +``` + +The following code sample displays the result of creating a full backup in the default tar format with gzip compression when the `BACKUP` subcommand was invoked. Note that checksums are generated for the full backup and user-defined tablespaces for the tar format backup: + +```text +[edb@localhost bin]$ ./bart BACKUP -s hr -z +INFO: DebugTarget - getVar(checkDiskSpace.bytesAvailable) +INFO: new backup identifier generated 1567591909098 +INFO: creating 5 harvester threads +NOTICE: all required WAL segments have been archived +INFO: backup completed successfully +INFO: +BART VERSION: 2.5 +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1567591909098 +BACKUP NAME: none +BACKUP PARENT: none +BACKUP LOCATION: /home/edb/bkup_new/hr/1567591909098 +BACKUP SIZE: 13.91 MB +BACKUP FORMAT: tar.gz +BACKUP TIMEZONE: America/New_York +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 0 +TABLESPACE(s): 3 +Oid Name Location +16387 test1 /home/edb/tbl1 +16388 test2 /home/edb/tbl2 +16389 test3 /home/edb/tbl3 + +START WAL LOCATION: 000000010000000000000025 +STOP WAL LOCATION: 000000010000000000000026 +BACKUP METHOD: streamed +BACKUP FROM: master +START TIME: 2019-09-04 06:11:49 EDT +STOP TIME: 2019-09-04 06:11:53 EDT +TOTAL DURATION: 4 sec(s) +``` + +The following code sample displays information about the directory containing the full backup: + +```text +[edb@localhost bin]$number_of_threads> +[edb@localhost bin]$ ls -l /home/edb/bkup_new/hr/ +total 8 +drwxrwxr-x. 3 edb edb 34 Aug 27 05:57 1566899819709 +drwxrwxr-x. 3 edb edb 58 Aug 27 05:57 1566899827751 +drwxrwxr-x. 3 edb edb 4096 Sep 4 06:11 1567591909098 +drwxrwxr-x. 2 edb edb 4096 Sep 4 06:11 archived_wals +[edb@localhost bin]$ +``` + +The following code sample displays information about the creation of a full backup while streaming the transaction log. Note that the `-Fp` option must be specified with the `BACKUP` subcommand when streaming is used as a backup method. + +```text +[edb@localhost bin]$ ./bart BACKUP -s ACCTG -Fp +INFO: DebugTarget - getVar(checkDiskSpace.bytesAvailable) +INFO: new backup identifier generated 1566898964200 +INFO: creating 5 harvester threads +NOTICE: pg_stop_backup complete, all required WAL segments have been archived +INFO: backup completed successfully +INFO: +BART VERSION: 2.5 +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1566898964200 +BACKUP NAME: none +BACKUP PARENT: none +BACKUP LOCATION: /home/edb/bkup_new/acctg/1566898964200 +BACKUP SIZE: 46.03 MB +BACKUP FORMAT: plain +BACKUP TIMEZONE: US/Eastern +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 0 +TABLESPACE(s): 0 +START WAL LOCATION: 000000010000000000000017 +BACKUP METHOD: streamed +BACKUP FROM: master +START TIME: 2019-08-27 05:42:44 EDT +STOP TIME: 2019-08-27 05:42:46 EDT +TOTAL DURATION: 2 sec(s) +``` + +The following code sample displays the assignment of a user-defined backup name with the `--backup-name` option: + +```text +[edb@localhost bin]$ ./bart BACKUP -s acctg --backup-name acctg_%year-%month-%day +INFO: DebugTarget - getVar(checkDiskSpace.bytesAvailable) +INFO: new backup identifier generated 1566899004804 +INFO: creating 5 harvester threads +NOTICE: pg_stop_backup complete, all required WAL segments have been archived +INFO: backup completed successfully +INFO: +BART VERSION: 2.5 +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1566899004804 +BACKUP NAME: acctg_2019-08-27 +BACKUP PARENT: none +BACKUP LOCATION: /home/edb/bkup_new/acctg/1566899004804 +BACKUP SIZE: 46.86 MB +BACKUP FORMAT: tar +BACKUP TIMEZONE: US/Eastern +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 0 +TABLESPACE(s): 0 +START WAL LOCATION: 00000001000000000000001A +BACKUP METHOD: streamed +BACKUP FROM: master +START TIME: 2019-08-27 05:43:24 EDT +STOP TIME: 2019-08-27 05:43:24 EDT +TOTAL DURATION: 0 sec(s) +``` + +The following code sample displays an incremental backup taken by specifying the `--parent` option. The option `-Fp` must be specified while taking an incremental backup as incremental backup can be taken only in plain text format. + +```text +[edb@localhost bin]$ ./bart BACKUP -s hr -Fp --parent hr_full_1 --backup-name +hr_incr_1 +INFO: DebugTarget - getVar(checkDiskSpace.bytesAvailable) +INFO: checking /home/edb/bkup_new/hr/archived_wals for MBM files from 0/20000028 to +0/22000000 +INFO: new backup identifier generated 1566899827751 +INFO: creating 5 harvester threads +NOTICE: all required WAL segments have been archived +INFO: backup completed successfully +INFO: +BART VERSION: 2.5 +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1566899827751 +BACKUP NAME: hr_incr_1 +BACKUP PARENT: 1566899819709 +BACKUP LOCATION: /home/edb/bkup_new/hr/1566899827751 +BACKUP SIZE: 7.19 MB +BACKUP FORMAT: plain +BACKUP TIMEZONE: America/New_York +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 0 +TABLESPACE(s): 0 +START WAL LOCATION: 000000010000000000000022 +STOP WAL LOCATION: 000000010000000000000023 +BACKUP METHOD: streamed +BACKUP FROM: master +START TIME: 2019-08-27 05:57:07 EDT +STOP TIME: 2019-08-27 05:57:08 EDT +TOTAL DURATION: 1 sec(s) +``` + + + +The following code sample displays an incremental backup taken by specifying the `--checksum-algorithm=NONE` option to skip generating checksum files. + +First, the bart-scanner is started. + +```text +edb@localhost bin]$ +[edb@localhost bin]$ ./bart-scanner -d --checksum-algorithm=NONE +DEBUG: sockPath = /tmp/fc557c1c8853d75f1cb52a8a578f371a +INFO: process created for server 'ppas11', pid = 19012 +DEBUG: could not load XLogReaderLibrary at this time, archived_wals is empty +``` + +Then, an incremental backup is taken with the `--checksum-algorithm=NONE` option to skip generating checksum files. + +```text +[edb@localhost bin]$ ./bart backup -s ppas11 -Fp --parent 1593506709152 --checksum-algorithm=NONE +INFO: DebugTarget - getVar(checkDiskSpace.bytesAvailable) +INFO: checking /home/edb/bkup/ppas11/archived_wals for MBM files from 1/D3000028 to 1/D9000000 +INFO: new backup identifier generated 1593507779811 +INFO: creating 5 harvester threads +NOTICE: pg_stop_backup complete, all required WAL segments have been archived +INFO: backup completed successfully +INFO: +BART VERSION: 2.6devel +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1593507779811 +BACKUP NAME: none +BACKUP PARENT: 1593506709152 +BACKUP LOCATION: /home/edb/bkup/ppas11/1593507779811 +BACKUP SIZE: 7.30 MB +BACKUP FORMAT: plain +BACKUP TIMEZONE: US/Eastern +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 0 +TABLESPACE(s): 0 +START WAL LOCATION: 0000000100000001000000D9 +BACKUP METHOD: streamed +BACKUP FROM: master +START TIME: 2020-06-30 05:02:59 EDT +STOP TIME: 2020-06-30 05:03:05 EDT +TOTAL DURATION: 6 sec(s) +``` + +!!! Note + To restore an incremental backup taken with the `--checksum-algorithm=NONE` option, you must specify [--disable-checksum while restoring](06_restore/#restoring_an_incremental_backup_using_disable_checksum). + +Similarly, you can specify `--checksum-algorithm=MD5` or `--checksum-algorithm=SHA256` while taking an incremental backup if you want to generate MD5 or SHAD256 checksum files. diff --git a/product_docs/docs/bart/2.6.2/bart_ref/01_bart_subcommands_examples/02_check_config.mdx b/product_docs/docs/bart/2.6.2/bart_ref/01_bart_subcommands_examples/02_check_config.mdx new file mode 100644 index 00000000000..69c51d5249e --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_ref/01_bart_subcommands_examples/02_check_config.mdx @@ -0,0 +1,65 @@ +--- +title: "CHECK-CONFIG" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/check_config.html" +--- + +The `CHECK-CONFIG` subcommand checks the global parameter settings as well as the database server configuration in the BART configuration file. + +The following syntax is used to check the BART configuration file global section settings. + +```text +bart CHECK-CONFIG +``` + +The following syntax is used to check the database server configuration settings. + +```text +bart CHECK-CONFIG [ –s ] +``` + +The following table describes the `CHECK-CONFIG` option: + +| Option | Description | +| ------------------------------------------- | ------------------------------------------------------------------------------------------------------------ | +| `-s ` `--server ` | `` is the name of the database server whose configuration parameter settings are to be checked. | + +**Example** + +The following code sample demonstrates successfully checking the BART configuration file global parameters with the `bart CHECK-CONFIG` command: + +```text +bash-4.1$ bart CHECK-CONFIG +INFO: Verifying that pg_basebackup is executable +INFO: success - +INFO: success - pg_basebackup(/usr/edb/as11/bin/pg_basebackup) returns +version 11.400000 +``` + +The following code sample demonstrates successfully checking the BART configuration file database server parameters with the `bart CHECK-CONFIG` command with the `–s` option: + +```text +[edb@localhost bin]$ ./bart check-config -s hr +INFO: Checking server hr +INFO: Verifying cluster_owner and ssh/scp connectivity +INFO: success +INFO: Verifying user, host, and replication connectivity +INFO: success +INFO: Verifying that user is a database superuser +INFO: success +INFO: Verifying that cluster_owner can read cluster data files +INFO: success +INFO: Verifying that you have permission to write to vault +INFO: success +INFO: /home/edb/bkup_new/hr +INFO: Verifying database server configuration +INFO: success +INFO: Verifying that WAL archiving is working +INFO: waiting 30 seconds for +/home/edb/bkup_new/hr/archived_wals/00000001000000000000001E +INFO: success +INFO: Verifying that bart-scanner is configured and running +INFO: success +``` diff --git a/product_docs/docs/bart/2.6.2/bart_ref/01_bart_subcommands_examples/03_delete.mdx b/product_docs/docs/bart/2.6.2/bart_ref/01_bart_subcommands_examples/03_delete.mdx new file mode 100644 index 00000000000..a148c571880 --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_ref/01_bart_subcommands_examples/03_delete.mdx @@ -0,0 +1,141 @@ +--- +title: "DELETE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/delete.html" +--- + +The `DELETE` subcommand removes the subdirectory and data files from the BART backup catalog for the specified backups along with archived WAL files. + +**Syntax:** + +```text +bart DELETE –s +-i { all | [']{ | },... }['] } +[ -n ] +``` + +Note that when invoking the `DELETE` subcommand, you must specify a database server. + +For database servers under a retention policy, there are conditions where certain backups may not be deleted. For more information, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/latest/bart_user/). + +The following table describes the `DELETE` options: + +| Options | Description | +| -------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s `
`--server ` | `` is the name of the database server whose backups are to be deleted. | +| ``-i { all \| [']{ \| }',... }[`] }``

``--backupid { all \| [']{ \| }',... }[`] }`` | `` is the backup identifier of the backup to be deleted. `` is the user-defined alphanumeric name for the backup.
Multiple backup identifiers and backup names may be specified in a comma-separated list. The list must be enclosed within single quotes if there is any white space appearing before or after each comma (see [Example](#deleting_multiple_backups_with_space_characters)).
If `all` is specified, all backups and their archived WAL files for the specified database server are deleted. | +| `-n`
`--dry-run` | Performs the test run and displays the results prior to physically removing files; no files are actually deleted. | + +**Example** + +The following code sample demonstrates deleting a backup from the specified database server: + +```text +[edb@localhost bin]$ ./bart DELETE -s acctg -i acctg_2019-08-27 +INFO: deleting backup 'acctg_2019-08-27' of server 'acctg' +INFO: deleting backup '1566900093665' +INFO: WALs of deleted backup(s) will belong to prior backup(if any), or will +be marked unused +WARNING: not marking any WALs as unused WALs, the WAL file +'/home/edb/bkup_new/acctg/archived_wals/000000010000000000000025' +is required, yet not available in archived_wals directory +INFO: backup(s) deleted +[edb@localhost bin]$ +``` + +After the deletion, the BART backup catalog for the database server no longer contains the corresponding directory for the deleted `backup ID`. The following code sample displays information about `archived_wals` subdirectory that no longer contains the backup WAL files: + +```text +[edb@localhost acctg]$ ls -l +total 16 +drwxrwxr-x. 3 edb edb 4096 Aug 27 06:03 1566900199604 +drwxrwxr-x. 3 edb edb 4096 Aug 27 06:03 1566900204377 +drwxrwxr-x. 3 edb edb 4096 Aug 27 06:03 1566900209087 +drwxrwxr-x. 3 edb edb 4096 Aug 27 06:05 1566900321228 +drwxrwxr-x. 2 edb edb 6 Aug 27 06:01 archived_wals +``` + +The following code sample demonstrates deleting multiple backups from the database server. + +```text +[edb@localhost bin]$ ./bart DELETE -s acctg -i `1566988095633,1566988100760, +acctg_2019-08-28` +INFO: deleting backup `1566988095633` of server `acctg` +INFO: deleting backup `1566988095633` +INFO: WALs of deleted backup(s) will belong to prior backup(if any), or will +be marked unused +WARNING: not marking any WALs as unused WALs, the WAL file +`/home/edb/bkup_new/acctg/archived_wals/000000010000000000000037` is required, +yet not available in archived_wals directory +INFO: backup(s) deleted +INFO: deleting backup `1566988100760` of server `acctg` +INFO: deleting backup `1566988100760` +INFO: WALs of deleted backup(s) will belong to prior backup(if any), or will +be marked unused +WARNING: not marking any WALs as unused WALs, the WAL file +`/home/edb/bkup_new/acctg/archived_wals/000000010000000000000039` is +required, yet not available in archived_wals directory +INFO: backup(s) deleted +INFO: deleting backup `acctg_2019-08-28` of server `acctg` +INFO: deleting backup `1566988115512` +INFO: WALs of deleted backup(s) will belong to prior backup(if any), or will +be marked unused +WARNING: not marking any WALs as unused WALs, the WAL file +`/home/edb/bkup_new/acctg/archived_wals/00000001000000000000003C` is required, +yet not available in archived_wals directory +INFO: backup(s) deleted +[edb@localhost bin]$ +[edb@localhost bin]$ +[edb@localhost bin]$ +[edb@localhost acctg]$ +[edb@localhost acctg]$ ls -l +total 8 +drwxrwxr-x. 3 edb edb 4096 Aug 28 06:28 1566988105086 +drwxrwxr-x. 3 edb edb 4096 Aug 28 06:28 1566988109477 +drwxrwxr-x. 2 edb edb 6 Aug 28 06:09 archived_wals +[edb@localhost acctg]$ +``` + + + +**Deleting Multiple Backups with Space Characters** + +The following code sample demonstrates deleting multiple backups; since there are space characters in the comma-separated list, the entire list must be enclosed within single quotes: + +```text +[edb@localhost bin]$ ./bart DELETE -s acctg -i +`1566900199604,1566900204377,1566900209087`; +INFO: deleting backup `1566900199604` of server `acctg` +INFO: deleting backup `1566900199604` +INFO: WALs of deleted backup(s) will belong to prior backup(if any), or will +be marked unused +WARNING: not marking any WALs as unused WALs, the WAL file +`/home/edb/bkup_new/acctg/archived_wals/000000010000000000000028` is required, +yet not available in archived_wals directory +INFO: backup(s) deleted +INFO: deleting backup `1566900204377` of server `acctg` +INFO: deleting backup `1566900204377` +INFO: WALs of deleted backup(s) will belong to prior backup(if any), or will +be marked unused +WARNING: not marking any WALs as unused WALs, the WAL file +`/home/edb/bkup_new/acctg/archived_wals/00000001000000000000002A` is required, +yet not available in archived_wals directory +INFO: backup(s) deleted +INFO: deleting backup `1566900209087` of server `acctg` +INFO: deleting backup `1566900209087` +INFO: WALs of deleted backup(s) will belong to prior backup(if any), or will +be marked unused +WARNING: not marking any WALs as unused WALs, the WAL file +`/home/edb/bkup_new/acctg/archived_wals/00000001000000000000002C` is required, +yet not available in archived_wals directory +INFO: backup(s) deleted +[edb@localhost bin]$ +[edb@localhost bin]$ +[edb@localhost acctg]$ ls -l +total 4 +drwxrwxr-x. 3 edb edb 4096 Aug 27 06:05 1566900321228 +drwxrwxr-x. 2 edb edb 6 Aug 27 06:01 archived_wals +[edb@localhost acctg]$ +``` diff --git a/product_docs/docs/bart/2.6.2/bart_ref/01_bart_subcommands_examples/04_init.mdx b/product_docs/docs/bart/2.6.2/bart_ref/01_bart_subcommands_examples/04_init.mdx new file mode 100644 index 00000000000..9f8b020ac03 --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_ref/01_bart_subcommands_examples/04_init.mdx @@ -0,0 +1,276 @@ +--- +title: "INIT" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/init.html" +--- + + + +The `INIT` subcommand is used to create the BART backup catalog directory, rebuild the BART `backupinfo` file, and set the `archive_command` in the server based on the `archive_command` setting in the `bart.cfg` file. + +**Syntax:** + +```text +bart INIT [ –s { | all } ] [ -o ] + +[ -r [ -i { | | all } ] ] + +[--no-configure] +``` + +The following table describes the `INIT` options: + +| Options | Description | +| ------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { \| all }`
`--server { \| all }` | `` is the name of the database server to which the `INIT` actions are to be applied. If `all` is specified or if the option is omitted, actions are applied to all servers. | +| `-o`
`--override` | Overrides the existing Postgres `archive_command` configuration parameter setting in the `postgresql.conf` file or the `postgresql.auto.conf` file using the BART `archive_command` parameter in the BART configuration file. The `INIT` generated `archive command` string is written to the `postgresql.auto.conf` file. | +| `-r`
`--rebuild` | Rebuilds the `backupinfo` file located in each backup subdirectory. If `all` is specified or if the option is omitted, the `backupinfo` files of all backups for the database servers specified by the `-s` option are recreated. This option is only intended for recovering from a situation where the backupinfo file has become corrupt.
If the backup was initially created with a user-defined backup name, and then the `INIT -r` option is invoked to rebuild that `backupinfo` file, the user-defined backup name is no longer available. Thus, future references to the backup must use the backup identifier. | +| `-i { \| \| all }`
`--backupid { \| \| all }` | `` is an integer, backup identifier and `` is the user-defined alphanumeric name for the backup. The `-i` option can only be used with the `-r` option. | +| `--no-configure` | Prevents the `archive_command` from being set in the PostgreSQL server. | + +**Examples** + +In the following code sample, you can see that `archive_mode = off` and `archive_command` is not set. After invoking the BART `INIT` subcommand, `archive_mode` is set to `on` and `archive_command` is set: + +```text +archive_mode = off # enables archiving; off, on, or always +# (change requires restart) +archive_command = '' +# command to use to archive a logfile segment +[edb@localhost bin]$ ./bart init -s ppas11 +INFO: setting archive_mode/archive_command for server 'ppas11' +WARNING: archive_mode/archive_command is set. Restart the PostgreSQL +server using 'pg_ctl restart' +[edb@localhost bin]$ +# Do not edit this file manually! +# It will be overwritten by the ALTER SYSTEM command. +archive_mode = 'on' +archive_command = 'scp %p +edb@127.0.0.1:/home/edb/bkup/ppas11/archived_wals/%f' +``` + +In the following code sample, you can see that `archive_mode = on`, and `archive_command` is not set. After invoking the `INIT` subcommand, `archive_command` is set: + +```text +archive_mode = on # enables archiving; off, on, or always +# (change requires restart) +archive_command = '' # command to use to archive a logfile segment +[edb@localhost bin]$ ./bart init -s ppas11 +INFO: setting archive_mode/archive_command for server 'ppas11' +WARNING: archive_command is set. Reload the configuration in the +PostgreSQL server using pg_reload_conf() or 'pg_ctl reload' +[edb@localhost bin]$ +# Do not edit this file manually! +# It will be overwritten by the ALTER SYSTEM command. +archive_command = 'scp %p +edb@127.0.0.1:/home/edb/bkup/ppas11/archived_wals/%f' +``` + +In the following code sample, you can see that `archive_mode = on` and `archive_command` are already set. After invoking the `INIT` subcommand, there is no change in their settings. Note that to override the existing `archive_command`, you must include the `-o` option. + +```text +archive_mode = on # enables archiving; off, on, or always +# (change requires restart) +archive_command = 'scp %p +edb@127.0.0.1:/home/edb/bkup/ppas11/archived_wals/%f' # command to use +to archive a logfile segment +# placeholders: %p = path of file to archive +[edb@localhost bin]$ ./bart init -s ppas11 +INFO: setting archive_mode/archive_command for server 'ppas11' +WARNING: archive_command is not set for server 'ppas11' +[edb@localhost bin]$ +# Do not edit this file manually! +# It will be overwritten by the ALTER SYSTEM command. +``` + +In the following code sample, you can see that `archive_mode = off` and `archive_command` is already set. After invoking the `INIT` subcommand `archive_mode` is set to `on`: + +```text +archive_mode = off # enables archiving; off, on, or always +# (change requires restart) +archive_command = 'scp %p +edb@127.0.0.1:/home/edb/bkup/ppas11/archived_wals/%f' # command to use +to archive a log file segment +[edb@localhost bin]$ ./bart init -s ppas11 +INFO: setting archive_mode/archive_command for server 'ppas11' +WARNING: archive_mode/archive_command is set. Restart the PostgreSQL +server using 'pg_ctl restart' +# Do not edit this file manually! +# It will be overwritten by the ALTER SYSTEM command. +archive_mode = 'on' +archive_command = 'scp %p +edb@127.0.0.1:/home/edb/bkup/ppas11/archived_wals/%f' +``` + +In the following code sample an existing `archive command` setting is overridden by resetting the `archive_command` in the PostgreSQL server with the `archive_command = 'cp %p %a/%f'` parameter from the `bart.cfg` file: + +```text +[BART] + +bart_host= enterprisedb@192.168.2.22 +backup_path = /opt/backup_edb +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log + +[ACCTG] + +host = 127.0.0.1 +port = 5444 +user = repuser +cluster_owner = enterprisedb +archive_command = 'cp %p %a/%f' +description = "Accounting" +``` + +The `archive_mode` and `archive_command` parameters in the database server are set as follows: + +```text +edb=# SHOW archive_mode; +archive_mode +-------------- +on +(1 row) +edb=# SHOW archive_command; +archive_command +------------------------------------------------------------------ +scp %p bartuser@192.168.2.22:/opt/backup/acctg/archived_wals/%f + +(1 row) +``` + +Invoke the `INIT` subcommand with the `-o` option to override the current `archive_command` setting in the PostgreSQL server: + +```text +-bash-4.1$ bart INIT -s acctg -o +INFO: setting archive_mode/archive_command for server 'acctg' +WARNING: archive_command is set. Reload the configuration in the +PostgreSQL server using pg_reload_conf() or 'pg_ctl reload' +``` + +Reload the database server configuration; a restart of the database server is not necessary to reset only the `archive_command` parameter: + +```text +[root@localhost tmp]# service ppas11 reload +``` + +The `archive_command` in the PostgreSQL server is now set as follows: + +```text +edb=# SHOW archive_command; + archive_command +----------------------------------------------- +cp %p /opt/backup_edb/acctg/archived_wals/%f +(1 row) +``` + +The new command string is written to the `postgresql.auto.conf` file: + +```text +# Do not edit this file manually! +# It will be overwritten by ALTER SYSTEM command. +archive_command = 'cp %p /opt/backup_edb/acctg/archived_wals/%f' +``` + +When you invoke the BART `INIT` command with the `-r` option, BART rebuilds the `backupinfo` file using the content of the backup directory for the server specified or for all servers. The BART `backupinfo` file is initially created by the `BACKUP` subcommand and contains the backup information used by BART. + +!!! Note + If the backup was initially created with a user-defined backup name, and then the `INIT -r` option is invoked to rebuild the `backupinfo` file, the user-defined backup name is no longer available. Thus, future references to the backup must use the backup identifier. + +The following code sample shows the `backupinfo` file location in a backup subdirectory: + +```text +[root@localhost acctg]# pwd +/opt/backup/acctg +[root@localhost acctg]# ls -l +total 4 +drwx------ 2 enterprisedb enterprisedb 38 Oct 26 10:21 1477491569966 +drwxrwxr-x 2 enterprisedb enterprisedb 4096 Oct 26 10:19 archived_wals +[root@localhost acctg]# ls -l 1477491569966 +total 61144 +-rw-rw-r-- 1 enterprisedb enterprisedb 703 Oct 26 10:19 backupinfo +-rw-rw-r-- 1 enterprisedb enterprisedb 62603776 Oct 26 10:19 base.tar +``` + +The following code sample displays the `backupinfo` file content: + +```text +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1477491569966 +BACKUP NAME: none +BACKUP PARENT: none +BACKUP LOCATION: /opt/backup/acctg/1477491569966 +BACKUP SIZE: 59.70 MB +BACKUP FORMAT: tar +BACKUP TIMEZONE: +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 1 +ChkSum File +84b3eeb1e3f7b3e75c2f689570d04f10 base.tar +TABLESPACE(s): 0 +START WAL LOCATION: 2/A5000028 (file 0000000100000002000000A5) +STOP WAL LOCATION: 2/A50000C0 (file 0000000100000002000000A5) +CHECKPOINT LOCATION: 2/A5000028 +BACKUP METHOD: streamed +BACKUP FROM: master +START TIME: 2016-10-26 10:19:30 EDT +LABEL: pg_basebackup base backup +STOP TIME: 2016-10-26 10:19:30 EDT +TOTAL DURATION: 0 sec(s) +``` + +The following code sample displays an error message if the `backupinfo` file is missing when invoking a BART subcommand: + +```text +-bash-4.2$ bart SHOW-BACKUPS +ERROR: 'backupinfo' file does not exist for backup '1477491569966' +please use 'INIT -r' to generate the file +``` + +The `backupinfo` file may be missing if the `BACKUP` subcommand did not complete successfully. + +The following code sample displays information about rebuilding the `backupinfo` file of the specified backup for database server `acctg`: + +```text +-bash-4.1$ bart INIT -s acctg -r -i 1428346620427 +INFO: rebuilding BACKUPINFO for backup '1428346620427' of server 'acctg' +INFO: backup checksum: ced59b72a7846ff8fb8afb6922c70649 of base.tar +``` + +The following code sample displays information about how the `backupinfo` files of all backups are rebuilt for all database servers: + +```text +-bash-4.1$ bart INIT -r + +INFO: rebuilding BACKUPINFO for backup '1428347191544' of server 'acctg' +INFO: backup checksum: 1ac5c61f055c910db314783212f2544f of base.tar +INFO: rebuilding BACKUPINFO for backup '1428346620427' of server 'acctg' +INFO: backup checksum: ced59b72a7846ff8fb8afb6922c70649 of base.tar +INFO: rebuilding BACKUPINFO for backup '1428347198335' of server 'dev' +INFO: backup checksum: a8890dd8ab7e6be5d5bc0f38028a237b of base.tar +INFO: rebuilding BACKUPINFO for backup '1428346957515' of server 'dev' +INFO: backup checksum: ea62549cf090573625d4adeb7d919700 of base.tar +``` + +The following code sample displays information about invoking `BART INIT` with the `-r - i` option: + +```text +edb@localhost bin]$ ./bart init -s ppas11 -i 1551778898392 -r +INFO: rebuilding BACKUPINFO for backup '1551778898392' of server +'ppas11' +[edb@localhost bin]$ ls /home/edb/bkup/ppas11/1551778898392/ +backupinfo backup_label base base-1.tar base-2.tar base-3.tar +base-4.tar base-5.tar base.tar +``` + +The following code sample displays information about invoking the `BART INIT` command with the `--no-configure` option. You can use the `--no-configure` option with the `INIT` subcommand to prevent the `archive_command` option from being set in the PostgreSQL server. + +```text +[edb@localhost bin]$ ./bart init -s ppas11 -o --no-configure +[edb@localhost bin]$ +# Do not edit this file manually! +# It will be overwritten by the ALTER SYSTEM command. +``` diff --git a/product_docs/docs/bart/2.6.2/bart_ref/01_bart_subcommands_examples/05_manage.mdx b/product_docs/docs/bart/2.6.2/bart_ref/01_bart_subcommands_examples/05_manage.mdx new file mode 100644 index 00000000000..75e63130a8e --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_ref/01_bart_subcommands_examples/05_manage.mdx @@ -0,0 +1,228 @@ +--- +title: "MANAGE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/manage.html" +--- + +The `MANAGE` subcommand can be invoked to: + +- Evaluate backups, mark their status, and delete obsolete backups based on the `retention_policy` parameter in the BART configuration file. +- Compress the archived WAL files based on the `wal_compression` parameter in the BART configuration file. + +**Syntax:** + +```text +bart MANAGE [ –s { | all} ] +[ -l ] [ -d ] +[ -c { keep | nokeep } +-i { | | all } ] +[ -n ] +``` + +To view detailed information about the `MANAGE` subcommand and retention policy management, see *the EDB Backup and Recovery User Guide*. For information about setting the `wal_compression` parameter, see the *EDB Backup and Recovery Installation and Upgrade Guide*. These guides are available at the [EDB website](/bart/latest/bart_user/). + +The following table describes the `MANAGE` options: + +| Options | Description | +| ---------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `-s [ \| all ]`
`--server [ \| all ]` | `` is the name of the database server to which the `MANAGE` actions are to be applied.
If `all` is specified or if the `-s` option is omitted, actions are applied to all database servers. | +| `-l`
`--list-obsolete` | Lists the backups marked as obsolete. | +| `-d`
`--delete-obsolete` | Deletes the backups marked as obsolete. This action physically deletes the backup along with its archived WAL files and any MBM files for incremental backups. | +| `-c { keep \| nokeep }`
`--change-status { keep \| nokeep }` | Specify `keep` to change the backup status to `keep` to retain the backup indefinitely.

Specify `nokeep` to change the backup status back to `active`. You can then re-evaluate and possibly mark the backup as `obsolete` (according to the retention policy) using the `MANAGE` subcommand.

The `-c` option can only be used with the `-i` option. | +| `-i { \| \| all` }

`--backupid { \| \| all` } | `` is a backup identifier and `` is the user-defined alphanumeric name for the backup.
If `all` is specified, actions are applied to all backups.
The `-i` option can only be used with the `-c` option. | +| `-n`
`--dry-run` | Performs the test run and displays the results prior to actually implementing the actions as if the operation was performed, however, no changes are actually made.
If you specify `-n` with the `-d` option, it displays which backups would be deleted, but does not actually delete the backups.
If you specify `-n` with the `-c` option, it displays the keep or nokeep action, but does not actually change the backup status.
If you specify `-n` alone with no other options or if you specify `-n` with only the `-s` option, it displays which active backups would be marked as obsolete, but does not actually change the backup status. In addition, no compression is performed on uncompressed, archived WAL files even if WAL compression is enabled for the database server. | + +**Example** + +The following code sample performs a dry run for the specified database server displaying which active backups are evaluated as obsolete according to the retention policy, but does not actually change the backup status: + +```text +-bash-4.2$ bart MANAGE -s acctg -n +INFO: processing server 'acctg', backup '1482770807519' +INFO: processing server 'acctg', backup '1482770803000' +INFO: marking backup '1482770803000' as obsolete +INFO: 1 WAL file(s) marked obsolete +INFO: processing server 'acctg', backup '1482770735155' +INFO: marking backup '1482770735155' as obsolete +INFO: 2 incremental(s) of backup '1482770735155' will be marked obsolete +INFO: marking incremental backup '1482770780423' as obsolete +INFO: marking incremental backup '1482770763227' as obsolete +INFO: 3 WAL file(s) marked obsolete +INFO: 1 Unused WAL file(s) present +INFO: 2 Unused file(s) (WALs included) present, use 'MANAGE -l' for the +list +``` + +The following code sample marks active backups as obsolete according to the retention policy for the specified database server: + +```text +-bash-4.2$ bart MANAGE -s acctg +INFO: processing server 'acctg', backup '1482770807519' +INFO: processing server 'acctg', backup '1482770803000' +INFO: marking backup '1482770803000' as obsolete +INFO: 1 WAL file(s) marked obsolete +INFO: processing server 'acctg', backup '1482770735155' +INFO: marking backup '1482770735155' as obsolete +INFO: 2 incremental(s) of backup '1482770735155' will be marked obsolete +INFO: marking incremental backup '1482770780423' as obsolete +INFO: marking incremental backup '1482770763227' as obsolete +INFO: 3 WAL file(s) marked obsolete +INFO: 1 Unused WAL file(s) present +INFO: 2 Unused file(s) (WALs included) present, use 'MANAGE -l' for the +list +``` + +The following code sample lists backups marked as obsolete for the specified database server: + +```text +-bash-4.2$ bart MANAGE -s acctg -l +SERVER NAME: acctg +BACKUP ID: 1482770803000 +BACKUP STATUS: obsolete +BACKUP TIME: 2016-12-26 11:46:43 EST +BACKUP SIZE: 59.52 MB +WAL FILE(s): 1 +WAL FILE: 000000010000000100000055 +SERVER NAME: acctg +BACKUP ID: 1482770735155 +BACKUP STATUS: obsolete +BACKUP TIME: 2016-12-26 11:45:35 EST +BACKUP SIZE: 59.52 MB +INCREMENTAL BACKUP(s): 2 +BACKUP ID: 1482770780423 +BACKUP PARENT: 1482770735155 +BACKUP STATUS: obsolete +BACKUP TIME: 2016-12-26 11:45:35 EST +BACKUP SIZE: 59.52 MB +BACKUP ID: 1482770763227 +BACKUP PARENT: 1482770735155 +BACKUP STATUS: obsolete +BACKUP TIME: 2016-12-26 11:45:35 EST +BACKUP SIZE: 59.52 MB +WAL FILE(s): 3 +WAL FILE: 000000010000000100000054 +WAL FILE: 000000010000000100000053 +WAL FILE: 000000010000000100000052 +UNUSED FILE(s): 2 +UNUSED FILE: 000000010000000100000051 +UNUSED FILE: 0000000100000001510000280000000152000000.mbm +``` + +The following code sample deletes the obsolete backups for the specified database server: + +```text +-bash-4.2$ bart MANAGE -s acctg -d +INFO: removing all obsolete backups of server 'acctg' +INFO: removing obsolete backup '1482770803000' +INFO: 1 WAL file(s) will be removed +INFO: removing WAL file '000000010000000100000055' +INFO: removing obsolete backup '1482770735155' +INFO: 3 WAL file(s) will be removed +INFO: 2 incremental(s) of backup '1482770735155' will be removed +INFO: removing obsolete incremental backup '1482770780423' +INFO: removing obsolete incremental backup '1482770763227' +INFO: removing WAL file '000000010000000100000054' +INFO: removing WAL file '000000010000000100000053' +INFO: removing WAL file '000000010000000100000052' +INFO: 8 Unused file(s) will be removed +INFO: removing (unused) file '000000010000000100000056.00000028.backup' +INFO: removing (unused) file '000000010000000100000056' +INFO: removing (unused) file '000000010000000100000055.00000028.backup' +INFO: removing (unused) file '000000010000000100000054.00000028.backup' +INFO: removing (unused) file '000000010000000100000053.00000028.backup' +INFO: removing (unused) file '000000010000000100000052.00000028.backup' +INFO: removing (unused) file '000000010000000100000051' +INFO: removing (unused) file +'0000000100000001510000280000000152000000.mbm' +``` + +The following code sample changes the specified backup to keep status to retain it indefinitely: + +```text +-bash-4.2$ bart MANAGE -s acctg -c keep -i 1482770807519 +INFO: changing status of backup '1482770807519' of server 'acctg' from +'active' to 'keep' +INFO: 1 WAL file(s) changed +-bash-4.2$ bart SHOW-BACKUPS -s acctg -i 1482770807519 -t +SERVER NAME : acctg +BACKUP ID : 1482770807519 +BACKUP NAME : none +BACKUP PARENT : none +BACKUP STATUS : keep +BACKUP TIME : 2016-12-26 11:46:47 EST +BACKUP SIZE : 59.52 MB +WAL(S) SIZE : 16.00 MB +NO. OF WALS : 1 +FIRST WAL FILE : 000000010000000100000057 +CREATION TIME : 2016-12-26 11:52:47 EST +LAST WAL FILE : 000000010000000100000057 +CREATION TIME : 2016-12-26 11:52:47 EST +``` + +The following code sample resets the specified backup to active status: + +```text +-bash-4.2$ bart MANAGE -s acctg -c nokeep -i 1482770807519 +INFO: changing status of backup '1482770807519' of server 'acctg' from +'keep' to 'active' +INFO: 1 WAL file(s) changed +-bash-4.2$ bart SHOW-BACKUPS -s acctg -i 1482770807519 -t +SERVER NAME : acctg +BACKUP ID : 1482770807519 +BACKUP NAME : none +BACKUP PARENT : none +BACKUP STATUS : active +BACKUP TIME : 2016-12-26 11:46:47 EST +BACKUP SIZE : 59.52 MB +WAL(S) SIZE : 16.00 MB +NO. OF WALS : 1 +FIRST WAL FILE : 000000010000000100000057 +CREATION TIME : 2016-12-26 11:52:47 EST +LAST WAL FILE : 000000010000000100000057 +CREATION TIME : 2016-12-26 11:52:47 EST +``` + +The following code sample uses the enabled `wal_compression` parameter in the BART configuration file as shown by the following: + +```text +[ACCTG] + +host = 127.0.0.1 +port = 5445 +user = enterprisedb +cluster_owner = enterprisedb +allow_incremental_backups = disabled +wal_compression = enabled +description = "Accounting" +``` + +When the `MANAGE` subcommand is invoked, the following message is displayed indicating that WAL file compression is performed: + +```text +-bash-4.2$ bart MANAGE -s acctg +INFO: 4 WAL file(s) compressed +WARNING: 'retention_policy' is not set for server 'acctg' +``` + +The following code sample shows the archived WAL files in compressed format: + +```text +-bash-4.2$ pwd +/opt/backup/acctg +-bash-4.2$ ls -l archived_wals +total 160 +-rw------- 1 enterprisedb enterprisedb 27089 Dec 26 12:16 +00000001000000010000005B.gz +-rw------- 1 enterprisedb enterprisedb 305 Dec 26 12:17 +00000001000000010000005C.00000028.backup +-rw------- 1 enterprisedb enterprisedb 27112 Dec 26 12:17 +00000001000000010000005C.gz +-rw------- 1 enterprisedb enterprisedb 65995 Dec 26 12:18 +00000001000000010000005D.gz +-rw------- 1 enterprisedb enterprisedb 305 Dec 26 12:18 +00000001000000010000005E.00000028.backup +-rw------- 1 enterprisedb enterprisedb 27117 Dec 26 12:18 +00000001000000010000005E.gz +``` diff --git a/product_docs/docs/bart/2.6.2/bart_ref/01_bart_subcommands_examples/06_restore.mdx b/product_docs/docs/bart/2.6.2/bart_ref/01_bart_subcommands_examples/06_restore.mdx new file mode 100644 index 00000000000..52490745796 --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_ref/01_bart_subcommands_examples/06_restore.mdx @@ -0,0 +1,175 @@ +--- +title: "RESTORE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/restore.html" +--- + +The `RESTORE` subcommand restores a backup and its archived WAL files for the designated database server to the specified directory location. + +**Syntax for Restore**: + +```text +bart RESTORE –s -p +[ –i { | } ] +[ -r @ ] +[ -w ] +[ -t ] +[ { -x | -g } ] +[ -c ] +[ --disable-checksum ] +``` + +To view detailed information about the `RESTORE` subcommand, see the *EDB Backup and Recovery User Guide* available at the [EDB website](/bart/latest/bart_user/). + +If the backup is restored to a different database cluster directory than where the original database cluster resided, then some operations dependent upon the database cluster location may fail. This happens if the supporting service scripts are not updated to reflect the new directory location of restored backup. + +For information about the use and modification of service scripts, see the EDB Advanced Server Installation Guide available at the [EDB website](/epas/latest/). + +The following table describes the `RESTORE` options: + +| Options | Description | +| --------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s `
`--server ` | `` is the name of the database server to be restored. | +| `-p --restore-path `
`--restore-path ` | `` is the directory path where the backup of the database server is to be restored. The directory must be empty and have the proper ownership and privileges assigned to it. | +| `-i { \| }`

`--backupid { \| }` | `backup_id` is the backup identifier of the backup to be used for the restoration and `` is the user-defined alphanumeric name for the backup.
If the option is omitted, the latest backup is restored by default. | +| `-r `

`--remote-host ` | `` is the user account on the remote database server host that accepts a passwordless SSH/SCP login connection and is the owner of the directory where the backup is to be restored.
`` is the IP address of the remote host to which the backup is to be restored. This option must be specified if the `remote_host` parameter for this database server is not set in the BART configuration file.
For information about the `remote_host` parameter, see the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/latest/bart_inst/). | +| `-w `
`--workers ` | `` is the number of worker processes to run in parallel to stream the modified blocks of an incremental backup to the restore location. If the `-w` option is omitted, the default is `1` worker process.
For example, if four worker processes are specified, four receiver processes on the restore host and four streamer processes on the BART host are used. The output of each streamer process is connected to the input of a receiver process.
When the receiver gets to the point where it needs a modified block file, it obtains those modified blocks from its input. With this method, the modified block files are never written to the restore host disk. | +| `-t `
`--target-tli ` | `` is the integer identifier of the timeline to be used for replaying the archived WAL files for point-in-time recovery. | +| `-x `
`--target-xid ` | `` is the integer identifier of the transaction ID that determines the transaction up to and including, which point-in-time recovery encompasses. | +| `-g `

`--target-timestamp ` | `` is the timestamp that determines the point in time up to and including, which point-in-time recovery encompasses. | +| `-c`

`--copy-wals` | Specify this option to copy archived WAL files from the BART backup catalog to `/archived_wals` directory.
The `restore_command` retrieves the WAL files from `/archived_wals` for the database server archive recovery.
If the `-c` option is omitted and the `copy_wals_during_restore` parameter in the BART configuration file is not enabled in a manner applicable to this database server, then the `restore_command` in the `postgresql.conf` retrieves the archived WAL files directly from the BART backup catalog.
For information about the `copy_wals_during_restore` parameter, see the EDB Backup and Recovery Installation and Upgrade Guide available at the [EDB website](/bart/latest/bart_inst/). | +| `--disable-checksum` | While restoring a backup, specify this option to skip verifying the MD5 or SHA256 checksum files.
If you set the `--checksum-algorithm=NONE` option with the BART scanner or while taking a backup, you also need to specify the `--disable checksum` option while restoring an incremental backup. | + +**Examples** + +The following code sample restores a database server(named `mktg`) to the `/opt/restore` directory up to timestamp `2015-12-15 10:47:00`: + +```text +-bash-4.1$ bart RESTORE -s mktg -i 1450194208824 -p /opt/restore -t 1 -g +'2015-12-15 10:47:00' +INFO: restoring backup '1450194208824' of server 'mktg' +INFO: restoring backup to enterprisedb@192.168.2.24:/opt/restore +INFO: base backup restored +INFO: WAL file(s) will be streamed from the BART host +INFO: writing recovery settings to postgresql.auto.conf file +INFO: archiving is disabled +INFO: tablespace(s) restored +``` + +The following parameters are set in the `postgresql.auto.conf` file: + +```text +restore_command = 'scp -o BatchMode=yes -o PasswordAuthentication=no +enterprisedb@192.168.2.22:/opt/backup/mktg/archived_wals/%f %p' +recovery_target_time = '2015-12-15 10:47:00' +recovery_target_timeline = 1 +``` + +The following is a list of the restored files and subdirectories: + +```text +[root@localhost restore]# pwd +/opt/restore +[root@localhost restore]# ls -l +total 108 +-rw------- 1 enterprisedb enterprisedb 208 Dec 15 10:43 backup_label +drwx------ 6 enterprisedb enterprisedb 4096 Dec 2 10:38 base +drwx------ 2 enterprisedb enterprisedb 4096 Dec 15 10:42 dbms_pipe +drwx------ 2 enterprisedb enterprisedb 4096 Dec 15 11:00 global +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_clog\ +-rw------- 1 enterprisedb enterprisedb 4438 Dec 2 10:38 pg_hba.conf +-rw------- 1 enterprisedb enterprisedb 1636 Nov 10 15:38 pg_ident.conf +drwxr-xr-x 2 enterprisedb enterprisedb 4096 Dec 15 10:42 pg_log +drwx------ 4 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_multixact +drwx------ 2 enterprisedb enterprisedb 4096 Dec 15 10:42 pg_notify +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_serial +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_snapshots +drwx------ 2 enterprisedb enterprisedb 4096 Dec 15 10:42 pg_stat +drwx------ 2 enterprisedb enterprisedb 4096 Dec 15 10:43 pg_stat_tmp +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_subtrans +drwx------ 2 enterprisedb enterprisedb 4096 Dec 15 11:00 pg_tblspc +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_twophase +-rw------- 1 enterprisedb enterprisedb 4 Nov 10 15:38 PG_VERSION +drwx------ 2 enterprisedb enterprisedb 4096 Dec 15 11:00 pg_xlog +-rw------- 1 enterprisedb enterprisedb 23906 Dec 15 11:00 +postgresql.conf +-rw-r--r-- 1 enterprisedb enterprisedb 217 Dec 15 11:00 +postgresql.auto.conf +``` + +**Example** + +The following code sample performs a `RESTORE` operation with the `copy_wals_during_restore` parameter enabled to copy the archived WAL files to the local `/archived_wals` directory: + +```text +-bash-4.1$ bart RESTORE -s hr -i hr_2017-03-29T13:50 -p +/opt/restore_pg96 -t 1 -g '2017-03-29 14:01:00' +INFO: restoring backup 'hr_2017-03-29T13:50' of server 'hr' +INFO: base backup restored +INFO: copying WAL file(s) to +postgres@192.168.2.24:/opt/restore_pg96/archived_wals +INFO: writing recovery settings to postgresql.auto.conf file +INFO: archiving is disabled +INFO: permissions set on $PGDATA +INFO: restore completed successfully +``` + +The following parameters are set in the `postgresql.auto.conf` file: + +```text +restore_command = 'cp archived_wals/%f %p' +recovery_target_time = '2017-03-29 14:01:00' +recovery_target_timeline = 1 +``` + +The following is a list of the restored files and subdirectories: + +```text +-bash-4.1$ pwd +/opt/restore_pg96 +-bash-4.1$ ls -l +total 128 +drwxr-xr-x 2 postgres postgres 4096 Mar 29 14:27 archived_wals +-rw------- 1 postgres postgres 206 Mar 29 13:50 backup_label +drwx------ 5 postgres postgres 4096 Mar 29 12:25 base +drwx------ 2 postgres postgres 4096 Mar 29 14:27 global +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_clog +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_commit_ts +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_dynshmem +-rw------- 1 postgres postgres 4212 Mar 29 13:18 pg_hba.conf +-rw------- 1 postgres postgres 1636 Mar 29 12:25 pg_ident.conf +drwxr-xr-x 2 postgres postgres 4096 Mar 29 13:45 pg_log +drwx------ 4 postgres postgres 4096 Mar 29 12:25 pg_logical +drwx------ 4 postgres postgres 4096 Mar 29 12:25 pg_multixact +drwx------ 2 postgres postgres 4096 Mar 29 13:43 pg_notify +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_replslot +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_serial +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_snapshots +drwx------ 2 postgres postgres 4096 Mar 29 13:43 pg_stat +drwx------ 2 postgres postgres 4096 Mar 29 13:50 pg_stat_tmp +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_subtrans +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_tblspc +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_twophase +-rw------- 1 postgres postgres 4 Mar 29 12:25 PG_VERSION +drwx------ 3 postgres postgres 4096 Mar 29 14:27 pg_xlog +-rw------- 1 postgres postgres 169 Mar 29 13:24 postgresql.auto.conf +-rw-r--r-- 1 postgres postgres 21458 Mar 29 14:27 postgresql.conf +-rw-r--r-- 1 postgres postgres 118 Mar 29 14:27 postgresql.auto.conf +``` + + + +The following code sample displays restoring an [incremental backup](01_backup/#incremental_backup_using_checksum_algorithm) taken using `--checksum-algorithm=NONE` option. To restore this incremental backup, you must specify the `--disable-checksum` option to skip verifying MD5 or SHA256 checksum files. + +```text +[edb@localhost bin]$ ./bart restore -s ppas11 -i 1593507779811 -p /home/edb/RESTORE/ --disable-checksum +INFO: restoring incremental backup '1593507779811' of server 'ppas11' +INFO: base backup restored +INFO: writing recovery.conf file +INFO: WAL file(s) will be streamed from the BART host +INFO: archiving is disabled +INFO: permissions set on $PGDATA +INFO: incremental restore completed successfully +``` diff --git a/product_docs/docs/bart/2.6.2/bart_ref/01_bart_subcommands_examples/07_show_servers.mdx b/product_docs/docs/bart/2.6.2/bart_ref/01_bart_subcommands_examples/07_show_servers.mdx new file mode 100644 index 00000000000..8ada69b5622 --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_ref/01_bart_subcommands_examples/07_show_servers.mdx @@ -0,0 +1,77 @@ +--- +title: "SHOW-SERVERS" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/show_servers.html" +--- + +The `SHOW-SERVERS` subcommand displays information for the managed database servers listed in the BART configuration file. + +**Syntax:** + +```text +bart SHOW-SERVERS [ –s { | all } ] +``` + +The following table describes the `SHOW-SERVERS` option: + +| Option | Description | +| ---------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { \| all` }
`--server { \| all` } | `` is the name of the database server to which the `SHOW-SERVERS` actions are to be applied.
If `all` is specified or if the `-s` option is omitted, the actions are applied to all database servers. | + +**Example** + +The following code sample shows all the database servers managed by BART as returned by the `SHOW-SERVERS` subcommand: + +```text +-bash-4.2$ bart SHOW-SERVERS +SERVER NAME : acctg +BACKUP FRIENDLY NAME: acctg_%year-%month-%dayT%hour:%minute +HOST NAME : 127.0.0.1 +USER NAME : enterprisedb +PORT : 5444 +REMOTE HOST : +RETENTION POLICY : 6 Backups +DISK UTILIZATION : 0.00 bytes +NUMBER OF ARCHIVES : 0 +ARCHIVE PATH : /opt/backup/acctg/archived_wals +ARCHIVE COMMAND : (disabled) +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +INCREMENTAL BACKUP : DISABLED +DESCRIPTION : "Accounting" +SERVER NAME : hr +BACKUP FRIENDLY NAME: hr_%year-%month-%dayT%hour:%minute +HOST NAME : 192.168.2.24 +USER NAME : postgres +PORT : 5432 +REMOTE HOST : postgres@192.168.2.24 +RETENTION POLICY : 6 Backups +DISK UTILIZATION : 0.00 bytes +NUMBER OF ARCHIVES : 0 +ARCHIVE PATH : /opt/backup/hr/archived_wals +ARCHIVE COMMAND : (disabled) +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +INCREMENTAL BACKUP : DISABLED +DESCRIPTION : "Human Resources" +SERVER NAME : mktg +BACKUP FRIENDLY NAME: mktg_%year-%month-%dayT%hour:%minute +HOST NAME : 192.168.2.24 +USER NAME : repuser +PORT : 5444 +REMOTE HOST : enterprisedb@192.168.2.24 +RETENTION POLICY : 6 Backups +DISK UTILIZATION : 0.00 bytes +NUMBER OF ARCHIVES : 0 +ARCHIVE PATH : /opt/backup/mktg/archived_wals +ARCHIVE COMMAND : (disabled) +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +INCREMENTAL BACKUP : DISABLED\ +DESCRIPTION : "Marketing" +``` diff --git a/product_docs/docs/bart/2.6.2/bart_ref/01_bart_subcommands_examples/08_show_backups.mdx b/product_docs/docs/bart/2.6.2/bart_ref/01_bart_subcommands_examples/08_show_backups.mdx new file mode 100644 index 00000000000..03b7727add3 --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_ref/01_bart_subcommands_examples/08_show_backups.mdx @@ -0,0 +1,100 @@ +--- +title: "SHOW-BACKUPS" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/show_backups.html" +--- + +The `SHOW-BACKUPS` subcommand displays the backup information for the managed database servers. + +**Syntax:** + +```text +bart SHOW-BACKUPS [ –s { | all } ] +[ -i { | | all } ] +[ -t ] +``` + +The following table describes the `SHOW-BACKUPS` options: + +| Options | Description | +| ------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { \| all` }

`--server { \| all` } | `` is the name of the database server whose backup information is to be displayed.
If `all` is specified or if the option is omitted, the backup information for all database servers is displayed. | +| `-i { \| \| all }`

`--backupid { \| \| all }` | `` is a backup identifier and `` is the user-defined alphanumeric name for the backup.
If `all` is specified or if the option is omitted, all backup information for the relevant database server is displayed. | +| `-t`
`--toggle` | Displays detailed backup information in list format. If the option is omitted, the default is a tabular format. | + +**Example** + +The following code sample shows the backup from database server `dev`: + +```text +-bash-4.2$ bart SHOW-BACKUPS -s dev +SERVER NAME BACKUP ID BACKUP NAME BACKUP PARENT +BACKUP TIME BACKUP SIZE WAL(s) SIZE WAL FILES STATUS +dev 1477579596637 dev_2016-10-27T10:46:36 none +2016-10-27 10:46:37 EDT 54.50 MB 96.00 MB 6 active +``` + +The following code sample shows detailed information using the `-t` option: + +```text +-bash-4.2$ bart SHOW-BACKUPS -s dev -i 1477579596637 -t +SERVER NAME : dev +BACKUP ID : 1477579596637 +BACKUP NAME : dev_2016-10-27T10:46:36 +BACKUP PARENT : none +BACKUP STATUS : active +BACKUP TIME : 2016-10-27 10:46:37 EDT +BACKUP SIZE : 54.50 MB +WAL(S) SIZE : 80.00 MB +NO. OF WALS : 5 +FIRST WAL FILE : 0000000100000001000000EC +CREATION TIME : 2016-10-27 10:46:37 EDT +LAST WAL FILE : 0000000100000001000000F0 +CREATION TIME : 2016-10-27 11:22:01 EDT +``` + +The following code sample shows a listing of an incremental backup along with its parent backup: + +```text +-bash-4.2$ bart SHOW-BACKUPS +SERVER NAME BACKUP ID BACKUP NAME BACKUP PARENT +BACKUP TIME BACKUP SIZE WAL(s) SIZE WAL FILES STATUS +acctg 1477580293193 acctg_2016-10-27 none +2016-10-27 10:58:13 EDT 16.45 MB 16.00 MB 1 active +acctg 1477580111358 acctg_2016-10-27 none 2016-10-27 10:55:11 EDT 59.71 +MB 16.00 MB 1 active +``` + +The following code sample shows the complete, detailed information of the incremental backup and the parent backup: + +```text +-bash-4.2$ bart SHOW-BACKUPS -t +SERVER NAME : acctg +BACKUP ID : 1477580293193 +BACKUP NAME : none +BACKUP PARENT : acctg_2016-10-27 +BACKUP STATUS : active +BACKUP TIME : 2016-10-27 10:58:13 EDT +BACKUP SIZE : 16.45 MB +WAL(S) SIZE : 16.00 MB +NO. OF WALS : 1 +FIRST WAL FILE : 0000000100000002000000D9 +CREATION TIME : 2016-10-27 10:58:13 EDT +LAST WAL FILE : 0000000100000002000000D9 +CREATION TIME : 2016-10-27 10:58:13 EDT +SERVER NAME : acctg +BACKUP ID : 1477580111358 +BACKUP NAME : acctg_2016-10-27 +BACKUP PARENT : none +BACKUP STATUS : active +BACKUP TIME : 2016-10-27 10:55:11 EDT +BACKUP SIZE : 59.71 MB +WAL(S) SIZE : 16.00 MB +NO. OF WALS : 1 +FIRST WAL FILE : 0000000100000002000000D8 +CREATION TIME : 2016-10-27 10:55:12 EDT +LAST WAL FILE : 0000000100000002000000D8 +CREATION TIME : 2016-10-27 10:55:12 EDT +``` diff --git a/product_docs/docs/bart/2.6.2/bart_ref/01_bart_subcommands_examples/09_verify_chksum.mdx b/product_docs/docs/bart/2.6.2/bart_ref/01_bart_subcommands_examples/09_verify_chksum.mdx new file mode 100644 index 00000000000..973ae05dc7d --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_ref/01_bart_subcommands_examples/09_verify_chksum.mdx @@ -0,0 +1,41 @@ +--- +title: "VERIFY-CHKSUM" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/verify_chksum.html" +--- + +The `VERIFY-CHKSUM` subcommand verifies the MD5 checksums of the full backups and any user-defined tablespaces for the specified database server or for all database servers. The checksum is verified by comparing the current checksum of the backup against the checksum when the backup was taken. + +!!! Note + The `VERIFY-CHKSUM` subcommand is only used for tar format backups. + +**Syntax:** + +```text +bart VERIFY-CHKSUM +[ –s { | all } ] +[ -i { | | all } ] +``` + +The following table describes the `VERIFY-CHKSUM` options: + +| Options | Description | +| ---------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { \| all }`
`--server { \| all` } | `` is the name of the database server whose tar backup checksums are to be verified.
If `all` is specified or if the `-s` option is omitted, the checksums of all tar backups are verified for all database servers. | +| `-i { \| \| all` }

`--backupid { \| \| all` } | `` is the backup identifier of a tar format full backup whose checksum is to be verified along with any user-defined tablespaces. `` is the user-defined alphanumeric name for the full backup.
If `all` is specified or if the `-i` option is omitted, the checksums of all tar backups for the relevant database server are verified. | + +**Example** + +The following code sample verifies the checksum of all tar format backups of the specified database server: + +```text +-bash-4.1$ bart VERIFY-CHKSUM -s acctg -i all +SERVER NAME BACKUP ID VERIFY +acctg 1430239348243 OK +acctg 1430232284202 OK +acctg 1430232016284 OK +acctg 1430231949065 OK +acctg 1429821844271 OK +``` diff --git a/product_docs/docs/bart/2.6.2/bart_ref/01_bart_subcommands_examples/10_running_the_bart_wal_scanner.mdx b/product_docs/docs/bart/2.6.2/bart_ref/01_bart_subcommands_examples/10_running_the_bart_wal_scanner.mdx new file mode 100644 index 00000000000..12305fb7733 --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_ref/01_bart_subcommands_examples/10_running_the_bart_wal_scanner.mdx @@ -0,0 +1,168 @@ +--- +title: "Running the BART WAL Scanner" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/running_the_bart_wal_scanner.html" +--- + +The BART WAL scanner is used to process each WAL file to find and record modified blocks in a corresponding MBM file. As a BART account user, use the BART WAL scanner to invoke the `bart-scanner` program located in the `/bin` directory. + +For detailed information about the WAL scanner and its usage, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/latest/bart_user/). + +**Syntax:** + +```text +bart-scanner +[ -d ] +[ -c ] +{ –h | +-v | +--daemon | +-p | + | +RELOAD | +STOP +--checksum-algorithm } +``` + +When the `bart-scanner` program is invoked, it forks a separate process for each database server enabled with the `allow_incremental_backups` parameter. + +The WAL scanner processes can run in either the foreground or background depending upon usage of the `--daemon` option: + +- If the `--daemon` option is specified, the WAL scanner process runs in the background. All output messages can be viewed in the BART log file. +- If the `--daemon` option is omitted, the WAL scanner process runs in the foreground. All output messages can be viewed from the terminal running the program as well as in the BART log file. + +The following table describes the `VERIFY-CHKSUM` options. + +| Options | Description | +| ---------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-h` `--help` | Displays general syntax and information on WAL scanner usage. | +| `-v` `--version` | Displays the WAL scanner version information. | +| `-d` `--debug` | Displays debugging output while executing the WAL scanner with any of its options. | +| `-c ` `--config-path ` | Specifies `` as the full directory path to a BART configuration file. Use this option if you do not want to use the default BART configuration file `/etc/bart.cfg` | +| `--daemon` | Runs the WAL scanner as a background process. | +| `-p ` `--print ` | Specifies the full directory path to an MBM file whose content is to be printed. The `archived_wals` directory as specified in the the `archive_path` parameter in the `bart.cfg` file contains the MBM files. | +| `` | Specifies the full directory path to a WAL file to be scanned. The archive path directory contains the WAL files. Use it if a WAL file in the archive path is missing its MBM file. This option is to be used for assisting the EnterpriseDB support team for debugging problems that may have been encountered. | +| `RELOAD` | Reloads the BART configuration file. The keyword `RELOAD` is case-insensitive. The `RELOAD` option is useful if you make changes to the configuration file after the WAL scanner has been started. It will reload the configuration file and adjust the WAL scanners accordingly. For example, if a server section allowing incremental backups is removed from the BART configuration file, then the process attached to that server will stop. Similarly, if a server allowing incremental backups is added, a new WAL scanner process will be launched to scan the WAL files of that server. | +| `STOP` | Stops the WAL scanner. The keyword `STOP` is not case-sensitive. | +| `--checksum-algorithm` | While invoking the WAL scanner, you can specify one of the following values with the `--checksum-algorithm` option: `--checksum-algorithm=MD5` (default) to generate MD5 checksum files. `--checksum-algorithm=SHA256` to generate SHA256 checksum files. `--checksum-algorithm=NONE` to skip generating checksum files. | + +**Example** + +The following code sample demonstrates starting the WAL scanner to run interactively. The WAL scanner begins scanning existing WAL files in the archive path that have not yet been scanned (that is, there is no corresponding MBM file for the WAL file): + +```text +-bash-4.2$ bart-scanner +INFO: process created for server 'acctg', pid = 5287 +INFO: going to parse backlog of WALs, if any. +INFO: WAL file to be processed: 0000000100000000000000ED +INFO: WAL file to be processed: 0000000100000000000000EE +INFO: WAL file to be processed: 0000000100000000000000EF +INFO: WAL file to be processed: 0000000100000000000000F0 +INFO: WAL file to be processed: 0000000100000000000000F1 +``` + +The following code sample is the content of the archive path showing the MBM files created for the WAL files. (The user name and group name of the files have been removed from the example to list the WAL files and MBM files in a more readable manner): + +```text +[root@localhost archived_wals]# pwd +/opt/backup/acctg/archived_wals +[root@localhost archived_wals]# ls -l +total 81944 +-rw------- 1 ... ... 16777216 Dec 20 09:10 0000000100000000000000ED +-rw------- 1 ... ... 16777216 Dec 20 09:06 0000000100000000000000EE +-rw------- 1 ... ... 16777216 Dec 20 09:11 0000000100000000000000EF +-rw------- 1 ... ... 16777216 Dec 20 09:15 0000000100000000000000F0 +-rw------- 1 ... ... 16777216 Dec 20 09:16 0000000100000000000000F1 +-rw------- 1 ... ... 305 Dec 20 09:16 0000000100000000000000F1.00000028.backup +-rw-rw-r-- 1 ... ... 161 Dec 20 09:18 +0000000100000000ED00002800000000EE000000.mbm +-rw-rw-r-- 1 ... ... 161 Dec 20 09:18 +0000000100000000EE00002800000000EF000000.mbm +-rw-rw-r-- 1 ... ... 161 Dec 20 09:18 +0000000100000000EF00002800000000F0000000.mbm +-rw-rw-r-- 1 ... ... 161 Dec 20 09:18 +0000000100000000F000002800000000F1000000.mbm +-rw-rw-r-- 1 ... ... 161 Dec 20 09:18 +0000000100000000F100002800000000F2000000.mbm +``` + +To stop the interactively running WAL scanner, either enter `ctrl-C` at the terminal running the WAL scanner or invoke the `bart-scanner` program from another terminal with the `STOP` option: + +```text +-bash-4.2$ bart-scanner STOP +-bash-4.2$ +``` + +The terminal on which the WAL scanner was running interactively appears as follows after it has been stopped: + +```text +-bash-4.2$ bart-scanner +INFO: process created for server 'acctg', pid = 5287 +INFO: going to parse backlog of WALs, if any. +INFO: WAL file to be processed: 0000000100000000000000ED +INFO: WAL file to be processed: 0000000100000000000000EE +INFO: WAL file to be processed: 0000000100000000000000EF +INFO: WAL file to be processed: 0000000100000000000000F0 +INFO: WAL file to be processed: 0000000100000000000000F1 +INFO: bart-scanner stopped +-bash-4.2$ +``` + +The following code sample demonstrates invoking the WAL scanner to run as a background process with the `--daemon` option: + +```text +-bash-4.2$ bart-scanner --daemon +-bash-4.2$ +``` + +The WAL scanner runs as a background process. There is also a separate background process for each database server that has been enabled for WAL scanning with the `allow_incremental_backups` parameter in the BART configuration file: + +```text +-bash-4.2$ ps -ef | grep bart + enterpr+ 4340 1 0 09:48 ? 00:00:00 bart-scanner --daemon + enterpr+ 4341 4340 0 09:48 ? 00:00:00 bart-scanner --daemon + enterpr+ 4415 3673 0 09:50 pts/0 00:00:00 grep --color=auto bart +``` + +To stop the WAL scanner processes, invoke the WAL scanner with the `STOP` option: + +```text +-bash-4.2$ bart-scanner STOP +-bash-4.2$ +``` + +The following command demonstrates scanning an individual WAL file: + +```text +-bash-4.2$ bart-scanner /opt/backup/acctg/archived_wals/0000000100000000000000FF +-bash-4.2$ +``` + +To print the content of an MBM file for assisting the EnterpriseDB support team for debugging problems that may have been encountered, use the `-p` option to specify the file as shown in the following code sample: + +```text +-bash-4.2$ bart-scanner -p +/opt/backup/acctg/archived_wals/0000000100000000FF0000280000000100000000.mbm + +Header: +Version: 1.0:90500:1.2.0 +Scan Start: 2016-12-20 10:02:11 EST, Scan End: 2016-12-20 10:02:11 EST, Diff: 0 sec(s) +Start LSN: ff000028, End LSN: 100000000, TLI: 1 +flags: 0, Check Sum: f9cfe66ae2569894d6746b61503a767d + +Path: base/14845/16384 +NodeTag: BLOCK_CHANGE +Relation: relPath base/14845/16384, isTSNode 0, Blocks +*............................................................................. +First modified block: 0 +Total modified blocks: 1 + +Path: base/14845/16391 +NodeTag: BLOCK_CHANGE +Relation: relPath base/14845/16391, isTSNode 0, Blocks +*.............................................................................. +First modified block: 0 +Total modified blocks: 1 +``` diff --git a/product_docs/docs/bart/2.6.2/bart_ref/01_bart_subcommands_examples/index.mdx b/product_docs/docs/bart/2.6.2/bart_ref/01_bart_subcommands_examples/index.mdx new file mode 100644 index 00000000000..20c71192ef2 --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_ref/01_bart_subcommands_examples/index.mdx @@ -0,0 +1,115 @@ +--- +title: "BART Subcommand Syntax and Examples" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/bart_subcommands_examples.html" +--- + + + +This section briefly describes each BART subcommand and provides an example. + +**Invoking BART** + +BART subcommands are invoked at the Linux command line as a BART user. You can invoke the `bart` program (located in the `/bin` directory) with the desired options to manage your BART installation. + +The following examples demonstrate ways of invoking BART. In these examples, the BART user account is named `bartuser`. + +```text +$ su bartuser +Password: +$ export +LD_LIBRARY_PATH=/opt/PostgresPlus/9.6AS/lib/:$LD_LIBRARY_PATH +$ ./bart SHOW-SERVERS +``` + +To run BART from any current working directory: + +```text +$ su bartuser +Password: +$ export +LD_LIBRARY_PATH=/opt/PostgresPlus/9.6AS/lib/:$LD_LIBRARY_PATH +$ bart SHOW-SERVERS +``` + +**Syntax for invoking BART** + +```text +bart [ ]... [ ] []... +``` + +You can use either abbreviated or long option forms on the command line (for example `-h` or `--help`). + +**General Options** + +You can specify the following general options with `bart`. + +`-h` or (`--help`) + +- Displays general syntax and information about BART usage. +- All subcommands support a help option (`-h, --help`). If the help option is specified, information is displayed regarding that particular subcommand. The subcommand, itself, is not executed. + +The following code sample displays the result of invoking the `--help` option for the `BACKUP` subcommand: + +```text +-bash-4.2$ bart BACKUP --help +bart: backup and recovery tool + +Usage: +bart BACKUP [OPTION]... + +Options: +-h, --help Show this help message and exit +-s, --server Name of the server or 'all' (full backups only) to specify all servers +-F, --format=p|t Backup output format (tar (default) or plain) +-z, --gzip Enables gzip compression of tar files +-c, --compress-level Specifies the compression level (1 through 9, 9 being + best compression) +--backup-name Specify a friendly name for the current backup +--parent Specify parent backup for incremental backup +--check Verify checksum of required mbm files +``` + +`-v` (or `--version`) + +The following code sample displays information returned by the `bart --version` subcommand: + +```text +[edb@localhost bin]$ bart --version +bart (EnterpriseDB) 2.5.2 +[edb@localhost bin]$ +``` + +`-d` (or `--debug`) + +The following code sample displays debugging output returned by the `bart MANAGE` subcommand: + +```text +-bash-4.1$ bart -d MANAGE -n +DEBUG: Server: acctg, Now: 2015-04-17 16:34:03 EDT, RetentionWindow: +259200 (secs) ==> 72 hour(s) +DEBUG: Server: dev, Now: 2015-04-17 16:34:03 EDT, RetentionWindow: +1814400 (secs) ==> 504 hour(s) +DEBUG: Server: hr, Now: 2015-04-17 16:34:03 EDT, RetentionWindow: +7776000 (secs) ==> 2160 hour(s) +``` + +`-c` (or `--config-path) ` + +The following code sample demonstrates using the `-c` option to specify a non-default configuration file name and installation location: + +```text +$ su bartuser +Password: +$ export +LD_LIBRARY_PATH=/opt/PostgresPlus/9.6AS/lib/:$LD_LIBRARY_PATH +$ bart -c /home/bartuser/bart.cfg SHOW-SERVERS +``` + +
+ +backup check_config delete init manage restore show_servers show_backups verify_chksum running_the_bart_wal_scanner + +
diff --git a/product_docs/docs/bart/2.6.2/bart_ref/02_additional_examples.mdx b/product_docs/docs/bart/2.6.2/bart_ref/02_additional_examples.mdx new file mode 100644 index 00000000000..38a519f727d --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_ref/02_additional_examples.mdx @@ -0,0 +1,1473 @@ +--- +title: "Additional Examples" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/additional_examples.html" +--- + + + +This section lists examples of the following BART operations. + +- Restoring a database cluster with tablespaces. +- Restoring an incremental backup. +- Managing backups. +- Managing incremental backups. + +## Restoring a Database Cluster with Tablespaces + +The following code sample illustrates taking a backup and restoring a database cluster on a remote host containing tablespaces. For detailed information regarding using tablespaces, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/latest/bart_user/). + +On an Advanced Server database running on a remote host, the following tablespaces are created for use by two tables: + +```text +edb=# CREATE TABLESPACE tblspc_1 LOCATION '/mnt/tablespace_1'; +CREATE TABLESPACE +edb=# CREATE TABLESPACE tblspc_2 LOCATION '/mnt/tablespace_2'; +CREATE TABLESPACE +edb=# \db + List of tablespaces +Name | Owner | Location +------------+-----------------+------------------- +pg_default | enterprisedb | +pg_global | enterprisedb | +tblspc_1 | enterprisedb | /mnt/tablespace_1 +tblspc_2 | enterprisedb | /mnt/tablespace_2 +(4 rows) + +edb=# CREATE TABLE tbl_tblspc_1 (c1 TEXT) TABLESPACE tblspc_1; +CREATE TABLE +edb=# CREATE TABLE tbl_tblspc_2 (c1 TEXT) TABLESPACE tblspc_2; +CREATE TABLE +edb=# \d tbl_tblspc_1 +Table "enterprisedb.tbl_tblspc_1" +Column | Type | Modifiers +-------+------+----------- +c1 | text | +Tablespace: "tblspc_1" + +edb=# \d tbl_tblspc_2 +Table "enterprisedb.tbl_tblspc_2" +Column | Type | Modifiers +-------+------+----------- +c1 | text | +Tablespace: "tblspc_2" +``` + +The following code sample shows the OIDs assigned to the tablespaces and the symbolic links to the tablespace directories: + +```text +-bash-4.1$ pwd +/opt/PostgresPlus/9.6AS/data/pg_tblspc +-bash-4.1$ ls -l +total 0 +lrwxrwxrwx 1 enterprisedb enterprisedb 17 Nov 16 16:17 16587 ->/mnt/tablespace_1 +lrwxrwxrwx 1 enterprisedb enterprisedb 17 Nov 16 16:17 16588 ->/mnt/tablespace_2 +``` + +The BART configuration file contains the following settings. Note that the `tablespace_path` parameter does not have to be set at this point. + +```text +[BART] +bart_host= enterprisedb@192.168.2.22 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log + +[ACCTG] +host = 192.168.2.24 +port = 5444 +user = repuser +cluster_owner = enterprisedb +remote_host = enterprisedb@192.168.2.24 +tablespace_path = +description = "Accounting" +``` + +After the necessary configuration steps are performed to ensure BART manages the remote database server, a full backup is taken as shown in the following code sample: + +```text +-bash-4.1$ bart BACKUP -s acctg + +INFO: creating backup for server 'acctg' +INFO: backup identifier: '1447709811516' +54521/54521 kB (100%), 3/3 tablespaces + +INFO: backup completed successfully +INFO: backup checksum: 594f69fe7d26af991d4173d3823e174f of 16587.tar +INFO: backup checksum: 7a5507567729a21c98a15c948ff6c015 of base.tar +INFO: backup checksum: ae8c62604c409635c9d9e82b29cc0399 of 16588.tar +INFO: +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1447709811516 +BACKUP NAME: none +BACKUP LOCATION: /opt/backup/acctg/1447709811516 +BACKUP SIZE: 53.25 MB +BACKUP FORMAT: tar +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 3 +ChkSum File +594f69fe7d26af991d4173d3823e174f 16587.tar +7a5507567729a21c98a15c948ff6c015 base.tar +ae8c62604c409635c9d9e82b29cc0399 16588.tar + +TABLESPACE(s): 2 +Oid Name Location +16587 tblspc_1 /mnt/tablespace_1 +16588 tblspc_2 /mnt/tablespace_2 +START WAL LOCATION: 00000001000000000000000F +BACKUP METHOD: streamed +BACKUP FROM: master +START TIME: 2015-11-16 16:36:51 EST +STOP TIME: 2015-11-16 16:36:52 EST +TOTAL DURATION: 1 sec(s) +``` + +Note that in the output from the preceding example, checksums are generated for the tablespaces as well as the full backup. + +Within the backup subdirectory `1447709811516` of the BART backup catalog, the tablespace data is stored with file names `16587.tar.gz` and `16588.tar.gz` as shown below: + +```text +-bash-4.1$ pwd +/opt/backup/acctg +-bash-4.1$ ls -l +total 8 +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 16:36 1447709811516 +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 16:43 archived_wals +-bash-4.1$ ls -l 1447709811516 +total 54536 +-rw-rw-r-- 1 enterprisedb enterprisedb 19968 Nov 16 16:36 16587.tar +-rw-rw-r-- 1 enterprisedb enterprisedb 19968 Nov 16 16:36 16588.tar +-rw-rw-r-- 1 enterprisedb enterprisedb 949 Nov 16 17:05 backupinfo +-rw-rw-r-- 1 enterprisedb enterprisedb 55792640 Nov 16 16:36 base.tar +``` + +When you are ready to restore the backup, in addition to creating the directory to which the main database cluster is to be restored, you must prepare the directories to which the tablespaces are to be restored. + +On the remote host, directories `/opt/restore_tblspc_1` and `/opt/restore_tblspc_2` are created and assigned the proper ownership and permissions as shown by the following example. The main database cluster is to be restored to `/opt/restore`. + +```text +[root@localhost opt]# mkdir restore_tblspc_1 +[root@localhost opt]# chown enterprisedb restore_tblspc_1 +[root@localhost opt]# chgrp enterprisedb restore_tblspc_1 +[root@localhost opt]# chmod 700 restore_tblspc_1 + +[root@localhost opt]# mkdir restore_tblspc_2 +[root@localhost opt]# chown enterprisedb restore_tblspc_2 +[root@localhost opt]# chgrp enterprisedb restore_tblspc_2 +[root@localhost opt]# chmod 700 restore_tblspc_2 +[root@localhost opt]# ls -l +total 20 +drwxr-xr-x 3 root daemon 4096 Nov 10 15:38 PostgresPlus +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 17:40 restore +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 17:40 +restore_tblspc_1 +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 17:41 +restore_tblspc_2 +drwxr-xr-x. 2 root root 4096 Nov 22 2013 rh +``` + +Set the `tablespace_path` parameter in the BART configuration file to specify the tablespace directories. The remote host user and IP address are specified by the `remote_host` configuration parameter. + +```text +[ACCTG] + +host = 192.168.2.24 +port = 5444 +user = repuser +cluster_owner = enterprisedb +remote_host = enterprisedb@192.168.2.24 +tablespace_path = +16587=/opt/restore_tblspc_1;16588=/opt/restore_tblspc_2 + +description = "Accounting" +``` + +The following code sample demonstrates invoking the `RESTORE` subcommand: + +```text +-bash-4.1$ bart RESTORE -s acctg -i 1447709811516 -p /opt/restore +INFO: restoring backup '1447709811516' of server 'acctg' +INFO: restoring backup to enterprisedb@192.168.2.24:/opt/restore +INFO: base backup restored +INFO: archiving is disabled +INFO: tablespace(s) restored +``` + +The following code sample shows the restored full backup (including the restored tablespaces): + +```text +bash-4.1$ pwd +/opt +-bash-4.1$ ls -l restore +total 104 +-rw------- 1 enterprisedb enterprisedb 206 Nov 16 16:36 backup_label.old +drwx------ 6 enterprisedb enterprisedb 4096 Nov 10 15:38 base +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 17:46 global +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_clog +-rw------- 1 enterprisedb enterprisedb 4438 Nov 10 16:23 pg_hba.conf +-rw------- 1 enterprisedb enterprisedb 1636 Nov 10 15:38 pg_ident.conf +drwxr-xr-x 2 enterprisedb enterprisedb 4096 Nov 16 17:45 pg_log +drwx------ 4 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_multixact +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 17:45 pg_notify +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_serial +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_snapshots +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 17:47 pg_stat +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 17:47 pg_stat_tmp +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_subtrans +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 17:42 pg_tblspc +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_twophase +-rw------- 1 enterprisedb enterprisedb 4 Nov 10 15:38 PG_VERSION +drwx------ 3 enterprisedb enterprisedb 4096 Nov 16 17:47 pg_xlog +-rw------- 1 enterprisedb enterprisedb 23906 Nov 16 17:42 postgresql.conf +-rw------- 1 enterprisedb enterprisedb 61 Nov 16 17:45 postmaster.opts +-bash-4.1$ +-bash-4.1$ ls -l restore_tblspc_1 +total 4 +drwx------ 3 enterprisedb enterprisedb 4096 Nov 16 16:18 +PG_9.6_201306121 +-bash-4.1$ ls -l restore_tblspc_2 +total 4 +drwx------ 3 enterprisedb enterprisedb 4096 Nov 16 16:18 +PG_9.6_201306121 +``` + +The symbolic links in the `pg_tblspc` subdirectory point to the restored directory location: + +```text +bash-4.1$ pwd +/opt/restore/pg_tblspc +-bash-4.1$ ls -l +total 0 +lrwxrwxrwx 1 enterprisedb enterprisedb 21 Nov 16 17:42 16587 -> +/opt/restore_tblspc_1 +lrwxrwxrwx 1 enterprisedb enterprisedb 21 Nov 16 17:42 16588 -> +/opt/restore_tblspc_2 +``` + +`psql` queries also show the restored tablespaces: + +```text +edb=# \db + + List of tablespaces +Name | Owner | Location +------------+--------------+----------------------- +pg_default | enterprisedb | +pg_global | enterprisedb | +tblspc_1 | enterprisedb | /opt/restore_tblspc_1 +tblspc_2 | enterprisedb | /opt/restore_tblspc_2 +``` + +## Restoring an Incremental Backup + +Restoring an incremental backup may require additional setup steps depending upon the host on which the incremental backup is to be restored. For more information, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/latest/bart_user/). + +This section provides an example of creating backup chains and then restoring an incremental backup. + +**Creating a Backup Chain** + +A *backup chain* is the set of backups consisting of a full backup and all of its successive incremental backups. Tracing back on the parent backups of all incremental backups in the chain eventually leads back to that single, full backup. + +In the following example, the `allow_incremental_backups` parameter is set to `enabled` in the BART configuration file to permit incremental backups on the listed database server: + +```text +[BART] + +bart_host= enterprisedb@192.168.2.27 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log + +[ACCTG] + +host = 127.0.0.1 +port = 5445 +user = enterprisedb +cluster_owner = enterprisedb +allow_incremental_backups = enabled +description = "Accounting" +``` + +After the database server has been started with WAL archiving enabled to the BART backup catalog, the WAL scanner is started: + +```text +-bash-4.2$ bart-scanner --daemon +``` + +First, a full backup is taken. + +```text +-bash-4.2$ bart BACKUP -s acctg --backup-name full_1 +INFO: creating backup for server 'acctg' +INFO: backup identifier: '1490649204327'\ +63364/63364 kB (100%), 1/1 tablespace +INFO: backup completed successfully +INFO: backup checksum: aae27d4a7c09dffc82f423221154db7e of base.tar +INFO: +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1490649204327 +BACKUP NAME: full_1 +BACKUP PARENT: none +BACKUP LOCATION: /opt/backup/acctg/1490649204327 +BACKUP SIZE: 61.88 MB +BACKUP FORMAT: tar +BACKUP TIMEZONE: US/Eastern +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 1 +ChkSum File +aae27d4a7c09dffc82f423221154db7e base.tar +TABLESPACE(s): 0 +START WAL LOCATION: 00000001000000000000000E +BACKUP METHOD: streamed +BACKUP FROM: master +START TIME: 2017-03-27 17:13:24 EDT +STOP TIME: 2017-03-27 17:13:25 EDT +TOTAL DURATION: 1 sec(s) +``` + +A series of incremental backups are taken. The first incremental backup specifies the full backup as the parent. Each successive incremental backup then uses the preceding incremental backup as its parent. + +```text +-bash-4.2$ bart BACKUP -s acctg -F p --parent full_1 --backup-name +incr_1-a +INFO: creating incremental backup for server 'acctg' +INFO: checking mbm files /opt/backup/acctg/archived_wals +INFO: new backup identifier generated 1490649255649 +INFO: reading directory /opt/backup/acctg/archived_wals +INFO: all files processed +NOTICE: pg_stop_backup complete, all required WAL segments have been +archived +INFO: incremental backup completed successfully +INFO: +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1490649255649 +BACKUP NAME: incr_1-a +BACKUP PARENT: 1490649204327 +BACKUP LOCATION: /opt/backup/acctg/1490649255649 +BACKUP SIZE: 16.56 MB +BACKUP FORMAT: plain +BACKUP TIMEZONE: US/Eastern +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 0 +TABLESPACE(s): 0 +START WAL LOCATION: 000000010000000000000010 +STOP WAL LOCATION: 000000010000000000000010 +BACKUP METHOD: pg_start_backup +BACKUP FROM: master +START TIME: 2017-03-27 17:14:15 EDT +STOP TIME: 2017-03-27 17:14:16 EDT +TOTAL DURATION: 1 sec(s) +-bash-4.2$ bart BACKUP -s acctg -F p --parent incr_1-a --backup-name +incr_1-b +INFO: creating incremental backup for server 'acctg' +INFO: checking mbm files /opt/backup/acctg/archived_wals +INFO: new backup identifier generated 1490649336845 +INFO: reading directory /opt/backup/acctg/archived_wals +INFO: all files processed +NOTICE: pg_stop_backup complete, all required WAL segments have been +archived +INFO: incremental backup completed successfully +. +. +. +-bash-4.2$ bart BACKUP -s acctg -F p --parent incr_1-b --backup-name +incr_1-c +INFO: creating incremental backup for server 'acctg' +INFO: checking mbm files /opt/backup/acctg/archived_wals +INFO: new backup identifier generated 1490649414316 +INFO: reading directory /opt/backup/acctg/archived_wals +INFO: all files processed +NOTICE: pg_stop_backup complete, all required WAL segments have been +archived +INFO: incremental backup completed successfully +. +. +. +``` + +The following output of the `SHOW-BACKUPS` subcommand lists the backup chain, which are backups `full_1, incr_1-a, incr_1-b, and incr_1-c`. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID BACKUP NAME BACKUP PARENT BACKUP TIME ... +acctg 1490649414316 incr_1-c incr_1-b 2017-03-27 17:16:55 ... +acctg 1490649336845 incr_1-b incr_1-a 2017-03-27 17:15:37 ... +acctg 1490649255649 incr_1-a full_1 2017-03-27 17:14:16 ... +acctg 1490649204327 full_1 none 2017-03-27 17:13:25 ... +``` + +For the `full backup full_1`, the `BACKUP PARENT` field contains `none`. For each incremental backup, the `BACKUP PARENT` field contains the backup identifier or name of its parent backup. + +A second backup chain is created in the same manner with the `BACKUP` subcommand. The following example shows the addition of the resulting, second backup chain consisting of full backup `full_2` and incremental backups `incr_2-a` and `incr_2-b`. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID BACKUP NAME BACKUP PARENT BACKUP TIME ... +acctg 1490649605607 incr_2-b incr_2-a 2017-03-27 17:20:06 ... +acctg 1490649587702 incr_2-a full_2 2017-03-27 17:19:48 ... +acctg 1490649528633 full_2 none 2017-03-27 17:18:49 ... +acctg 1490649414316 incr_1-c incr_1-b 2017-03-27 17:16:55 ... +acctg 1490649336845 incr_1-b incr_1-a 2017-03-27 17:15:37 ... +acctg 1490649255649 incr_1-a full_1 2017-03-27 17:14:16 ... +acctg 1490649204327 full_1 none 2017-03-27 17:13:25 ... +``` + +The following additional incremental backups starting with `incr_1-b-1`, which designates `incr_1-b` as the parent, results in the forking from that backup into a second line of backups in the chain consisting of `full_1, incr_1-a, incr_1-b, incr_1-b-1, incr_1-b-2`, and `incr_1-b-3` as shown in the following list: + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID BACKUP NAME BACKUP PARENT BACKUP TIME ... +acctg 1490649791430 incr_1-b-3 incr_1-b-2 2017-03-27 17:23:12 ... +acctg 1490649763929 incr_1-b-2 incr_1-b-1 2017-03-27 17:22:44 ... +acctg 1490649731672 incr_1-b-1 incr_1-b 2017-03-27 17:22:12 ... +acctg 1490649605607 incr_2-b incr_2-a 2017-03-27 17:20:06 ... +acctg 1490649587702 incr_2-a full_2 2017-03-27 17:19:48 ... +acctg 1490649528633 full_2 none 2017-03-27 17:18:49 ... +acctg 1490649414316 incr_1-c incr_1-b 2017-03-27 17:16:55 ... +acctg 1490649336845 incr_1-b incr_1-a 2017-03-27 17:15:37 ... +acctg 1490649255649 incr_1-a full_1 2017-03-27 17:14:16 ... +acctg 1490649204327 full_1 none 2017-03-27 17:13:25 ... +``` + +**Restoring an Incremental Backup** + +Restoring an incremental backup is done with the `RESTORE` subcommand in the same manner as for restoring a full backup. Specify the backup identifier or backup name of the incremental backup to be restored as shown in the following example. + +```text +-bash-4.2$ bart RESTORE -s acctg -p /opt/restore -i incr_1-b +INFO: restoring incremental backup 'incr_1-b' of server 'acctg' +INFO: base backup restored +INFO: archiving is disabled +INFO: permissions set on $PGDATA +INFO: incremental restore completed successfully +``` + +Restoring incremental backup `incr_1-b` as shown by the preceding example results in the restoration of full backup `full_1`, then incremental backups `incr_1-a` and finally, `incr_1-b`. + +## Managing Backups + +This section illustrates evaluating, marking, and deleting backups using the `MANAGE` subcommand using a redundancy retention policy and a recovery window retention policy. For detailed information about the `MANAGE` subcommand, see the *EDB Backup and Recovery User Guide* available at the [EDB website](/bart/latest/bart_user/). + + + +### Using a Redundancy Retention Policy + +The following code sample uses a redundancy retention policy to evaluate, mark, and delete backups as shown by the following server configuration: + +```text +[ACCTG] +host = 127.0.0.1 +port = 5444 +user = enterprisedb +archive_command = 'cp %p %a/%f' +retention_policy = 3 BACKUPS +description = "Accounting" +``` + +The following list is the set of backups. Note that the last backup in the list has been marked as `keep`. + +```text +-bash-4.1$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID BACKUP TIME BACKUP SIZE WAL(s) SIZE +WAL FILES STATUS +acctg 1428768344061 2015-04-11 12:05:46 EDT 5.72 MB 48.00 MB +3 active +acctg 1428684537299 2015-04-10 12:49:00 EDT 5.72 MB 272.00 MB +17 active +acctg 1428589759899 2015-04-09 10:29:27 EDT 5.65 MB 96.00 MB +6 active +acctg 1428502049836 2015-04-08 10:07:30 EDT 55.25 MB 96.00 MB +6 active +acctg 1428422324880 2015-04-07 11:58:45 EDT 54.53 MB 32.00 MB +2 active +acctg 1428355371389 2015-04-06 17:22:53 EDT 5.71 MB 16.00 MB +1 keep +``` + +Invoke the `MANAGE` subcommand with the `-n` option to perform a dry run to observe which active backups would be changed to obsolete according to the retention policy as shown in the following code sample: + +```text +-bash-4.1$ bart MANAGE -s acctg -n +INFO: processing server 'acctg', backup '1428768344061' +INFO: processing server 'acctg', backup '1428684537299' +INFO: processing server 'acctg', backup '1428589759899' +INFO: processing server 'acctg', backup '1428502049836' +INFO: marking backup '1428502049836' as obsolete +INFO: 6 WAL file(s) marked obsolete +INFO: processing server 'acctg', backup '1428422324880' +INFO: marking backup '1428422324880' as obsolete +INFO: 2 WAL file(s) marked obsolete +INFO: processing server 'acctg', backup '1428355371389' +``` + +The dry run shows that backups `1428502049836` and `1428422324880` would be marked as `obsolete`. + +!!! Note + A dry run does not change the backup status. The two backups that would be considered obsolete are still marked as `active`: + +```text +-bash-4.1$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID BACKUP TIME BACKUP SIZE WAL(s) SIZE +WAL FILES STATUS +acctg 1428768344061 2015-04-11 12:05:46 EDT 5.72 MB 48.00 MB +3 active +acctg 1428684537299 2015-04-10 12:49:00 EDT 5.72 MB 272.00 MB +17 active +acctg 1428589759899 2015-04-09 10:29:27 EDT 5.65 MB 96.00 MB +6 active +acctg 1428502049836 2015-04-08 10:07:30 EDT 55.25 MB 96.00 MB +6 active +acctg 1428422324880 2015-04-07 11:58:45 EDT 54.53 MB 32.00 MB +2 active +acctg 1428355371389 2015-04-06 17:22:53 EDT 5.71 MB 16.00 MB +1 keep +``` + +Invoke the `MANAGE` subcommand omitting the `-n` option to change and mark the status of the backups as `obsolete`: + +```text +-bash-4.1$ bart MANAGE -s acctg +INFO: processing server 'acctg', backup '1428768344061' +INFO: processing server 'acctg', backup '1428684537299' +INFO: processing server 'acctg', backup '1428589759899' +INFO: processing server 'acctg', backup '1428502049836' +INFO: marking backup '1428502049836' as obsolete +INFO: 6 WAL file(s) marked obsolete +INFO: processing server 'acctg', backup '1428422324880' +INFO: marking backup '1428422324880' as obsolete +INFO: 2 WAL file(s) marked obsolete +INFO: processing server 'acctg', backup '1428355371389' +``` + +The obsolete backups can be observed in a number of ways. Use the `MANAGE` subcommand with the `-l` option to list the `obsolete` backups: + +```text +-bash-4.1$ bart MANAGE -s acctg -l +INFO: 6 WAL file(s) will be removed +SERVER NAME: acctg +BACKUP ID: 1428502049836 +BACKUP STATUS: obsolete +BACKUP TIME: 2015-04-08 10:07:30 EDT +BACKUP SIZE: 55.25 MB +WAL FILE(s): 6 +WAL FILE: 000000010000000100000003 +WAL FILE: 000000010000000100000002 +WAL FILE: 000000010000000100000001 +WAL FILE: 000000010000000100000000 +WAL FILE: 0000000100000000000000E3 +WAL FILE: 0000000100000000000000E2 +INFO: 2 WAL file(s) will be removed +SERVER NAME: acctg +BACKUP ID: 1428422324880 +BACKUP STATUS: obsolete +BACKUP TIME: 2015-04-07 11:58:45 EDT +BACKUP SIZE: 54.53 MB +WAL FILE(s): 2 +WAL FILE: 0000000100000000000000E1 +WAL FILE: 0000000100000000000000E0 +``` + +The `STATUS` field of the `SHOW-BACKUPS` subcommand displays the current status: + +```text +-bash-4.1$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID BACKUP TIME BACKUP SIZE WAL(s) SIZE +WAL FILES STATUS +acctg 1428768344061 2015-04-11 12:05:46 EDT 5.72 MB 48.00 MB +3 active +acctg 1428684537299 2015-04-10 12:49:00 EDT 5.72 MB 272.00 MB +17 active +acctg 1428589759899 2015-04-09 10:29:27 EDT 5.65 MB 96.00 MB +6 active +acctg 1428502049836 2015-04-08 10:07:30 EDT 55.25 MB 96.00 MB +6 obsolete +acctg 1428422324880 2015-04-07 11:58:45 EDT 54.53 MB 32.00 MB +2 obsolete +acctg 1428355371389 2015-04-06 17:22:53 EDT 5.71 MB 16.00 MB +1 keep +``` + +The details of an individual backup can be displayed using the `SHOW-BACKUPS` subcommand with the `-t` option. Note the status in the `BACKUP STATUS` field. + +```text +-bash-4.1$ bart SHOW-BACKUPS -s acctg -i 1428502049836 -t +SERVER NAME : acctg +BACKUP ID : 1428502049836 +BACKUP NAME : none +BACKUP STATUS : obsolete +BACKUP TIME : 2015-04-08 10:07:30 EDT +BACKUP SIZE : 55.25 MB +WAL(S) SIZE : 96.00 MB +NO. OF WALS : 6 +FIRST WAL FILE : 0000000100000000000000E2 +CREATION TIME : 2015-04-08 10:07:30 EDT +LAST WAL FILE : 000000010000000100000003 +CREATION TIME : 2015-04-09 10:25:46 EDT +``` + +Use the `MANAGE` subcommand with the `-d` option to physically delete the `obsolete` backups including the unneeded WAL files. + +```text +-bash-4.1$ bart MANAGE -s acctg -d +INFO: removing all obsolete backups of server 'acctg' +INFO: removing obsolete backup '1428502049836' +INFO: 6 WAL file(s) will be removed +INFO: removing WAL file '000000010000000100000003' +INFO: removing WAL file '000000010000000100000002' +INFO: removing WAL file '000000010000000100000001' +INFO: removing WAL file '000000010000000100000000' +INFO: removing WAL file '0000000100000000000000E3' +INFO: removing WAL file '0000000100000000000000E2' +INFO: removing obsolete backup '1428422324880' +INFO: 2 WAL file(s) will be removed +INFO: removing WAL file '0000000100000000000000E1' +INFO: removing WAL file '0000000100000000000000E0' +``` + +The `SHOW-BACKUPS` subcommand now displays the remaining backups marked as `active` or `keep`: + +```text +-bash-4.1$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID BACKUP TIME BACKUP SIZE WAL(s) SIZE +WAL FILES STATUS +acctg 1428768344061 2015-04-11 12:05:46 EDT 5.72 MB 48.00 MB +3 active +acctg 1428684537299 2015-04-10 12:49:00 EDT 5.72 MB 272.00 MB +17 active +acctg 1428589759899 2015-04-09 10:29:27 EDT 5.65 MB 96.00 MB +6 active +acctg 1428355371389 2015-04-06 17:22:53 EDT 5.71 MB 16.00 MB +1 keep +``` + + + +### Using a Recovery Window Retention Policy + +This section illustrates the evaluation, marking, and deletion of backup using a recovery window retention policy. To use the recovery window retention policy, set the `retention_policy` parameter to the desired length of time for the recovery window. + +This section provides examples of the following: + +- How to view the calculated recovery window. +- How to evaluate, mark, and delete backup using a recovery window retention policy. + +#### Viewing the Recovery Window + +You can view the actual, calculated recovery window by invoking any of the following subcommands: + +- `MANAGE` subcommand in debug mode (along with the `-n` option). +- `SHOW-SERVERS` subcommand. + +##### Viewing the Recovery Window Using the Manage Subcommand + +When invoking BART in debug mode with the `MANAGE` subcommand and the `-n` option, the length of the recovery window is calculated based on the `retention_policy` setting and the current date/time. + +For example, using the following `retention_policy` settings: + +```text +[ACCTG] + +host = 127.0.0.1 +port = 5444 +user = enterprisedb +archive_command = 'cp %p %a/%f' +retention_policy = 3 DAYS +backup-name = acctg_%year-%month-%dayT%hour:%minute:%second +description = "Accounting" + +[DEV] + +host = 127.0.0.1 +port = 5445 +user = enterprisedb +archive_command = 'cp %p %a/%f' +retention_policy = 3 WEEKS +description = "Development" + +[HR] + +host = 127.0.0.1 +port = 5432 +user = postgres +retention_policy = 3 MONTHS +description = "Human Resources" +``` + +If the `MANAGE` subcommand is invoked in debug mode along with the `-n` option on 2015-04-17, the following results are displayed: + +```text +-bash-4.1$ bart -d MANAGE -n +DEBUG: Server: acctg, Now: 2015-04-17 16:34:03 EDT, RetentionWindow: +259200 (secs) ==> 72 hour(s) +DEBUG: Server: dev, Now: 2015-04-17 16:34:03 EDT, RetentionWindow: +1814400 (secs) ==> 504 hour(s) +DEBUG: Server: hr, Now: 2015-04-17 16:34:03 EDT, RetentionWindow: +7776000 (secs) ==> 2160 hour(s) +``` + +For server `acctg`, 72 hours translates to a recovery window of 3 days. + +For server `dev`, 504 hours translates to a recovery window of 21 days (3 weeks). + +For server `hr`, 2160 hours translates to a recovery window of 90 days (3 months). + +For a setting of ` MONTHS`, the calculated total number of days for the recovery window is dependent upon the actual number of days in the preceding months from the current date/time. Thus, ` MONTHS` is not always exactly equivalent to ` x 30 DAYS`. For example, if the current date/time is in the month of March, a 1-month recovery window would be equivalent to only 28 days because the preceding month is February. Thus, for a current date of March 31, a 1-month recovery window would start on March 3. However, the typical result is that the day of the month of the starting recovery window boundary will be the same day of the month of when the `MANAGE` subcommand is invoked. + +##### Viewing the Recovery Window Using the Show-Servers Subcommand + +This section provides an example of viewing the recovery window using the `SHOW-SERVERS` subcommand; the `RETENTION POLICY` field displays the start of the recovery window. + +In the following code sample, the recovery window retention policy setting considers the backups taken within a 3-day recovery window as the active backups. + +```text +[ACCTG] +host = 127.0.0.1 +port = 5444 +user = enterprisedb +archive_command = 'cp %p %a/%f' +retention_policy = 3 DAYS +description = "Accounting" +``` + +The start of the 3-day recovery window displayed in the `RETENTION POLICY` field is `2015-04-07 14:57:36 EDT` when the `SHOW-SERVERS` subcommand is invoked on `2015-04-10`. + +At this current point in time, backups taken on or after `2015-04-07 14:57:36 EDT` would be considered active. Backups taken prior to `2015-04-07 14:57:36 EDT` would be considered obsolete except for backups marked as `keep`. + +```text +-bash-4.1$ date +Fri Apr 10 14:57:33 EDT 2015 +-bash-4.1$ +-bash-4.1$ bart SHOW-SERVERS -s acctg +SERVER NAME : acctg +HOST NAME : 127.0.0.1 +USER NAME : enterprisedb +PORT : 5444 +REMOTE HOST : +RETENTION POLICY : 2015-04-07 14:57:36 EDT +DISK UTILIZATION : 824.77 MB +NUMBER OF ARCHIVES : 37 +ARCHIVE PATH : /opt/backup/acctg/archived_wals +ARCHIVE COMMAND : cp %p /opt/backup/acctg/archived_wals/%f +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +DESCRIPTION : "Accounting" +``` + +In the following code sample, the recovery window retention policy setting considers the backups taken within a 3-week recovery window as the `active` backups. + +```text +[DEV] +host = 127.0.0.1 +port = 5445 +user = enterprisedb +archive_command = 'cp %p %a/%f' +retention_policy = 3 WEEKS +description = "Development" +``` + +The start of the 3-week recovery window displayed in the `RETENTION POLICY` field is `2015-03-20 14:59:42 EDT` when the `SHOW-SERVERS` subcommand is invoked on `2015-04-10`. + +At this current point in time, backups taken on or after `2015-03-20 14:59:42 EDT` would be considered `active`. Backups taken prior to `2015-03-20 14:59:42 EDT` would be considered `obsolete` except for backups marked as `keep`. + +```text +-bash-4.1$ date +Fri Apr 10 14:59:39 EDT 2015 +-bash-4.1$ +-bash-4.1$ bart SHOW-SERVERS -s dev +SERVER NAME : dev +HOST NAME : 127.0.0.1 +USER NAME : enterprisedb +PORT : 5445 +REMOTE HOST : +RETENTION POLICY : 2015-03-20 14:59:42 EDT +DISK UTILIZATION : 434.53 MB +NUMBER OF ARCHIVES : 22 +ARCHIVE PATH : /opt/backup/dev/archived_wals +ARCHIVE COMMAND : cp %p /opt/backup/dev/archived_wals/%f +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +DESCRIPTION : "Development" +``` + +In the following code sample, the recovery window retention policy setting considers the backups taken within a 3-month recovery window as the `active` backups. + +```text +[HR] +host = 127.0.0.1 +port = 5432 +user = postgres +retention_policy = 3 MONTHS +description = "Human Resources" +``` + +The start of the 3-month recovery window displayed in the `RETENTION POLICY` field is `2015-01-10 14:04:23 EST` when the `SHOW-SERVERS` subcommand is invoked on `2015-04-10`. + +At this current point in time, backups taken on or after `2015-01-10 14:04:23 EST` would be considered `active`. Backups taken prior to `2015-01-10 14:04:23 EST` would be considered `obsolete`, except for backups marked as `keep`. + +```text +-bash-4.1$ date +Fri Apr 10 15:04:19 EDT 2015 +-bash-4.1$ +-bash-4.1$ bart SHOW-SERVERS -s hr +SERVER NAME : hr +HOST NAME : 127.0.0.1 +USER NAME : postgres +PORT : 5432 +REMOTE HOST : +RETENTION POLICY : 2015-01-10 14:04:23 EST +DISK UTILIZATION : 480.76 MB +NUMBER OF ARCHIVES : 26 +ARCHIVE PATH : /opt/backup/hr/archived_wals +ARCHIVE COMMAND : scp %p +enterprisedb@192.168.2.22:/opt/backup/hr/archived_wals/%f +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +DESCRIPTION : "Human Resources" +``` + +#### Evaluating, Marking, and Deleting Backup Using a Recovery Window Retention Policy + +The following code sample uses a recovery window retention policy to evaluate, mark, and delete backups as shown by the following server configuration: + +```text +[DEV] +host = 127.0.0.1 +port = 5445 +user = enterprisedb +archive_command = 'cp %p %a/%f' +retention_policy = 3 DAYS +description = "Development" +``` + +The following is the current set of backups. Note that the last backup in the list has been marked as `keep`. + +```text +-bash-4.1$ bart SHOW-BACKUPS -s dev +SERVER NAME BACKUP ID BACKUP TIME BACKUP SIZE WAL(s) SIZE +WAL FILES STATUS +dev 1428933278236 2015-04-13 09:54:40 EDT 5.65 MB 16.00 MB +1 active +dev 1428862187757 2015-04-12 14:09:50 EDT 5.65 MB 32.00 MB +2 active +dev 1428768351638 2015-04-11 12:05:54 EDT 5.65 MB 32.00 MB +2 active +dev 1428684544008 2015-04-10 12:49:06 EDT 5.65 MB 224.00 MB +14 active +dev 1428590536488 2015-04-09 10:42:18 EDT 5.65 MB 48.00 MB +3 active +dev 1428502171990 2015-04-08 10:09:34 EDT 5.65 MB 80.00 MB +5 keep +``` + +The current date and time is `2015-04-13 16:46:35 EDT` as shown below: + +```text +-bash-4.1$ date +Mon Apr 13 16:46:35 EDT 2015 +``` + +Thus, a 3-day recovery window would evaluate backups prior to `2015-04-10 16:46:35 EDT` as `obsolete` except for those marked as `keep`. + +Invoke the `MANAGE` subcommand with the `-n` option to perform a dry run to observe which active backups would be changed to `obsolete` according to the retention policy. + +```text +-bash-4.1$ bart MANAGE -s dev -n +INFO: processing server 'dev', backup '1428933278236' +INFO: processing server 'dev', backup '1428862187757' +INFO: processing server 'dev', backup '1428768351638' +INFO: processing server 'dev', backup '1428684544008' +INFO: marking backup '1428684544008' as obsolete +INFO: 14 WAL file(s) marked obsolete +INFO: 1 Unused WAL file(s) present +INFO: processing server 'dev', backup '1428590536488' +INFO: marking backup '1428590536488' as obsolete +INFO: 3 WAL file(s) marked obsolete +INFO: 1 Unused WAL file(s) present +INFO: processing server 'dev', backup '1428502171990' +``` + +The dry run shows that backups `1428684544008` and `1428590536488` would be marked as `obsolete`. + +Also note that a dry run does not change the backup status. The two backups that would be considered obsolete are still marked as `active`: + +```text +-bash-4.1$ bart SHOW-BACKUPS -s dev\ + SERVER NAME BACKUP ID BACKUP TIME BACKUP SIZE WAL(s) SIZE + WAL FILES STATUS + dev 1428933278236 2015-04-13 09:54:40 EDT 5.65 MB 16.00 MB + 1 active + dev 1428862187757 2015-04-12 14:09:50 EDT 5.65 MB 32.00 MB + 2 active + dev 1428768351638 2015-04-11 12:05:54 EDT 5.65 MB 32.00 MB + 2 active + dev 1428684544008 2015-04-10 12:49:06 EDT 5.65 MB 224.00 MB + 14 active + dev 1428590536488 2015-04-09 10:42:18 EDT 5.65 MB 48.00 MB + 3 active + dev 1428502171990 2015-04-08 10:09:34 EDT 5.65 MB 80.00 MB + 5 keep +``` + +Invoke the `MANAGE` subcommand omitting the `-n` option to change and mark the status of the backups as `obsolete`: + +```text +-bash-4.1$ bart MANAGE -s dev +INFO: processing server 'dev', backup '1428933278236' +INFO: processing server 'dev', backup '1428862187757' +INFO: processing server 'dev', backup '1428768351638' +INFO: processing server 'dev', backup '1428684544008' +INFO: marking backup '1428684544008' as obsolete +INFO: 14 WAL file(s) marked obsolete +INFO: 1 Unused WAL file(s) present +INFO: processing server 'dev', backup '1428590536488' +INFO: marking backup '1428590536488' as obsolete +INFO: 3 WAL file(s) marked obsolete +INFO: 1 Unused WAL file(s) present +INFO: processing server 'dev', backup '1428502171990' +``` + +The obsolete backups can be observed in a number of ways. Use the `MANAGE` subcommand with the `-l` option to list the `obsolete` backups: + +```text +-bash-4.1$ bart MANAGE -s dev -l +INFO: 14 WAL file(s) will be removed +INFO: 1 Unused WAL file(s) will be removed +SERVER NAME: dev +BACKUP ID: 1428684544008 +BACKUP STATUS: obsolete +BACKUP TIME: 2015-04-10 12:49:06 EDT +BACKUP SIZE: 5.65 MB +WAL FILE(s): 14 +UNUSED WAL FILE(s): 1 +WAL FILE: 00000001000000000000002E +WAL FILE: 00000001000000000000002D +WAL FILE: 00000001000000000000002C +WAL FILE: 00000001000000000000002B +WAL FILE: 00000001000000000000002A +WAL FILE: 000000010000000000000029 +WAL FILE: 000000010000000000000028 +WAL FILE: 000000010000000000000027 +WAL FILE: 000000010000000000000026 +WAL FILE: 000000010000000000000025 +WAL FILE: 000000010000000000000024 +WAL FILE: 000000010000000000000023 +WAL FILE: 000000010000000000000022 +WAL FILE: 000000010000000000000021 +UNUSED WAL FILE: 00000001000000000000000F.00000028 +INFO: 3 WAL file(s) will be removed +INFO: 1 Unused WAL file(s) will be removed +SERVER NAME: dev +BACKUP ID: 1428590536488 +BACKUP STATUS: obsolete +BACKUP TIME: 2015-04-09 10:42:18 EDT\ +BACKUP SIZE: 5.65 MB +WAL FILE(s): 3 +UNUSED WAL FILE(s): 1 +WAL FILE: 000000010000000000000020 +WAL FILE: 00000001000000000000001F +WAL FILE: 00000001000000000000001E +UNUSED WAL FILE: 00000001000000000000000F.00000028 +``` + +The `STATUS` field of the `SHOW-BACKUPS` subcommand displays the current status: + +```text +-bash-4.1$ bart SHOW-BACKUPS -s dev +SERVER NAME BACKUP ID BACKUP TIME BACKUP SIZE WAL(s) SIZE +WAL FILES STATUS +dev 1428933278236 2015-04-13 09:54:40 EDT 5.65 MB 16.00 MB +1 active +dev 1428862187757 2015-04-12 14:09:50 EDT 5.65 MB 32.00 MB +2 active +dev 1428768351638 2015-04-11 12:05:54 EDT 5.65 MB 32.00 MB +2 active +dev 1428684544008 2015-04-10 12:49:06 EDT 5.65 MB 224.00 MB +14 obsolete +dev 1428590536488 2015-04-09 10:42:18 EDT 5.65 MB 48.00 MB +3 obsolete +dev 1428502171990 2015-04-08 10:09:34 EDT 5.65 MB 80.00 MB +5 keep +``` + +The details of an individual backup can be displayed using the `SHOW-BACKUPS` subcommand with the `-t` option. Note the status in the `BACKUP STATUS` field. + +```text +-bash-4.1$ bart SHOW-BACKUPS -s dev -i 1428684544008 -t +SERVER NAME : dev +BACKUP ID : 1428684544008 +BACKUP NAME : none +BACKUP STATUS : obsolete +BACKUP TIME : 2015-04-10 12:49:06 EDT +BACKUP SIZE : 5.65 MB +WAL(S) SIZE : 224.00 MB +NO. OF WALS : 14 +FIRST WAL FILE : 000000010000000000000021 +CREATION TIME : 2015-04-10 12:49:06 EDT +LAST WAL FILE : 00000001000000000000002E +CREATION TIME : 2015-04-11 12:02:15 EDT +``` + +Use the `MANAGE` subcommand with the `-d` option to physically delete the obsolete backups including the unneeded WAL files. + +```text +-bash-4.1$ bart MANAGE -s dev -d +INFO: removing all obsolete backups of server 'dev' +INFO: removing obsolete backup '1428684544008' +INFO: 14 WAL file(s) will be removed +INFO: 1 Unused WAL file(s) will be removed +INFO: removing WAL file '00000001000000000000002E' +INFO: removing WAL file '00000001000000000000002D' +INFO: removing WAL file '00000001000000000000002C' +INFO: removing WAL file '00000001000000000000002B' +INFO: removing WAL file '00000001000000000000002A' +INFO: removing WAL file '000000010000000000000029' +INFO: removing WAL file '000000010000000000000028' +INFO: removing WAL file '000000010000000000000027' +INFO: removing WAL file '000000010000000000000026' +INFO: removing WAL file '000000010000000000000025' +INFO: removing WAL file '000000010000000000000024' +INFO: removing WAL file '000000010000000000000023' +INFO: removing WAL file '000000010000000000000022' +INFO: removing WAL file '000000010000000000000021' +INFO: removing (unused) WAL file '00000001000000000000000F.00000028' +INFO: removing obsolete backup '1428590536488' +INFO: 3 WAL file(s) will be removed +INFO: removing WAL file '000000010000000000000020' +INFO: removing WAL file '00000001000000000000001F' +INFO: removing WAL file '00000001000000000000001E' +``` + +The `SHOW-BACKUPS` subcommand now displays the remaining backups marked as `active` or `keep`: + +```text +-bash-4.1$ bart SHOW-BACKUPS -s dev +SERVER NAME BACKUP ID BACKUP TIME BACKUP SIZE WAL(s) SIZE +WAL FILES STATUS +dev 1428933278236 2015-04-13 09:54:40 EDT 5.65 MB 16.00 MB +1 active +dev 1428862187757 2015-04-12 14:09:50 EDT 5.65 MB 32.00 MB +2 active +dev 1428768351638 2015-04-11 12:05:54 EDT 5.65 MB 32.00 MB +2 active +dev 1428502171990 2015-04-08 10:09:34 EDT 5.65 MB 80.00 MB +5 keep +``` + +## Managing Incremental Backups + +This section illustrates evaluating, marking, and deleting incremental backups using the `MANAGE` and `DELETE` subcommands utilizing redundancy retention policy and recovery window retention policy. For detailed information about the `MANAGE` and `DELETE` subcommands, as well as the redundancy retention and recovery window retention policy, see the *EDB Backup and Recovery User Guide* available at the [EDB website](/bart/latest/bart_user/). + +- [Using a Redundancy Retention Policy](#redundancy_retention_policy) provides an example of using the `MANAGE` and `DELETE` subcommands when a 3 backup redundancy retention policy is in effect. +- [Using a Recovery Window Retention Policy](#recovery_window_retention_policy) provides an example of using the `MANAGE` and `DELETE` subcommands when a 1-day recovery window retention policy is in effect. + + + +### Using a Redundancy Retention Policy + +The following code sample uses the `MANAGE` and `DELETE` subcommands to evaluate, mark, and delete incremental backups when a 3 backup redundancy retention policy is in effect. The example uses the following server configuration: + +```text +[ACCTG] + +host = 192.168.2.24 +port = 5445 +user = enterprisedb +cluster_owner = enterprisedb +remote_host = enterprisedb@192.168.2.24 +allow_incremental_backups = enabled +retention_policy = 3 BACKUPS +description = "Accounting" +``` + +The example uses the following set of backups. In these code samples, some columns have been omitted from the `SHOW-BACKUPS` output to display the relevant information in a more observable manner. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME ... STATUS +acctg 1481749696905 ... 1481749673603 2016-12-14 16:08:17 EST ... active +acctg 1481749673603 ... 1481749651927 2016-12-14 16:07:53 EST ... active +acctg 1481749651927 ... 1481749619582 2016-12-14 16:07:32 EST ... active +acctg 1481749619582 ... none 2016-12-14 16:07:00 EST ... active +``` + +There is one backup chain. The first backup is the initial full backup. + +Backup chain: `1481749619582 => 1481749651927 => 1481749673603 => 1481749696905` + +The `MANAGE` subcommand is invoked as shown by the following: + +```text +-bash-4.2$ bart MANAGE -s acctg +INFO: processing server 'acctg', backup '1481749619582' +INFO: 2 Unused WAL file(s) present +INFO: 4 Unused file(s) (WALs included) present, use 'MANAGE -l' for the +list +``` + +The following code sample shows the resulting status of the backups: + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME ... STATUS +acctg 1481749696905 ... 1481749673603 2016-12-14 16:08:17 EST ... active +acctg 1481749673603 ... 1481749651927 2016-12-14 16:07:53 EST ... active +acctg 1481749651927 ... 1481749619582 2016-12-14 16:07:32 EST ... active +acctg 1481749619582 ... none 2016-12-14 16:07:00 EST ... active +``` + +The status remains active for all backups. Even though the total number of backups exceeds the 3 backup redundancy retention policy, it is only the total number of full backups that is used to determine if the redundancy retention policy has been exceeded. Additional full backups are added including a second backup chain. The following example shows the resulting list of backups: + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME ... STATUS +acctg 1481750365397 ... none 2016-12-14 16:19:26 EST ... active +acctg 1481750098924 ... 1481749997807 2016-12-14 16:14:59 EST ... active +acctg 1481749997807 ... none 2016-12-14 16:13:18 EST ... active +acctg 1481749992003 ... none 2016-12-14 16:13:12 EST ... active +acctg 1481749696905 ... 1481749673603 2016-12-14 16:08:17 EST ... active +acctg 1481749673603 ... 1481749651927 2016-12-14 16:07:53 EST ... active +acctg 1481749651927 ... 1481749619582 2016-12-14 16:07:32 EST ... active +acctg 1481749619582 ... none 2016-12-14 16:07:00 EST ... active +``` + +Second backup chain: `1481749997807 => 1481750098924` + +The `MANAGE` subcommand is invoked, but now with a total of four active full backups. + +```text +-bash-4.2$ bart MANAGE -s acctg +INFO: processing server 'acctg', backup '1481750365397' +INFO: processing server 'acctg', backup '1481749997807' +INFO: processing server 'acctg', backup '1481749992003' +INFO: processing server 'acctg', backup '1481749619582' +INFO: marking backup '1481749619582' as obsolete +INFO: 3 incremental(s) of backup '1481749619582' will be marked obsolete +INFO: marking incremental backup '1481749696905' as obsolete +INFO: marking incremental backup '1481749673603' as obsolete +INFO: marking incremental backup '1481749651927' as obsolete +INFO: 4 WAL file(s) marked obsolete +INFO: 2 Unused WAL file(s) present +INFO: 4 Unused file(s) (WALs included) present, use 'MANAGE -l' for the +list +``` + +The oldest full backup and its chain of incremental backups are now marked as obsolete. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME ... STATUS +acctg 1481750365397 ... none 2016-12-14 16:19:26 EST ... active +acctg 1481750098924 ... 1481749997807 2016-12-14 16:14:59 EST ... active +acctg 1481749997807 ... none 2016-12-14 16:13:18 EST ... active +acctg 1481749992003 ... none 2016-12-14 16:13:12 EST ... active +acctg 1481749696905 ... 1481749673603 2016-12-14 16:08:17 EST ... obsolete +acctg 1481749673603 ... 1481749651927 2016-12-14 16:07:53 EST ... obsolete +acctg 1481749651927 ... 1481749619582 2016-12-14 16:07:32 EST ... obsolete +acctg 1481749619582 ... none 2016-12-14 16:07:00 EST ... obsolete +``` + +Invoking the `MANAGE` subcommand with the `-d` option deletes the entire obsolete backup chain. + +```text +-bash-4.2$ bart MANAGE -s acctg -d +INFO: removing all obsolete backups of server 'acctg' +INFO: removing obsolete backup '1481749619582' +INFO: 4 WAL file(s) will be removed +INFO: 3 incremental(s) of backup '1481749619582' will be removed +INFO: removing obsolete incremental backup '1481749696905' +INFO: removing obsolete incremental backup '1481749673603' +INFO: removing obsolete incremental backup '1481749651927' +INFO: removing WAL file '000000010000000100000000' +INFO: removing WAL file '0000000100000000000000FF' +INFO: removing WAL file '0000000100000000000000FE' +INFO: removing WAL file '0000000100000000000000FD' +INFO: 16 Unused file(s) will be removed +INFO: removing (unused) file '000000010000000100000004.00000028.backup' +. +. +. +INFO: removing (unused) file +'0000000100000000FB00002800000000FC000000.mbm' +``` + +The following code sample shows the remaining full backups and the second backup chain. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME ... STATUS +acctg 1481750365397 ... none 2016-12-14 16:19:26 EST ... active +acctg 1481750098924 ... 1481749997807 2016-12-14 16:14:59 EST ... active +acctg 1481749997807 ... none 2016-12-14 16:13:18 EST ... active +acctg 1481749992003 ... none 2016-12-14 16:13:12 EST ... active +``` + + + +### Using a Recovery Window Retention Policy + +The following example demonstrates using the `MANAGE` and `DELETE` subcommands to evaluate, mark, and delete incremental backups when a 1-day recovery window retention policy is in effect. The example uses the following server configuration: + +```text +[ACCTG] + +host = 192.168.2.24 +port = 5445 +user = enterprisedb +cluster_owner = enterprisedb +remote_host = enterprisedb@192.168.2.24 +allow_incremental_backups = enabled +retention_policy = 1 DAYS +description = "Accounting" +``` + +The example uses the following set of backups. In the samples, some columns have been omitted from the `SHOW-BACKUPS` output to display the relevant information in a more observable manner. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME ... STATUS +acctg 1481559303348 ... 1481554203288 2016-12-12 11:15:03 EST ... active +acctg 1481559014359 ... 1481554802918 2016-12-12 11:10:14 EST ... active +acctg 1481554802918 ... 1481553914533 2016-12-12 10:00:03 EST ... active +acctg 1481554203288 ... 1481553651165 2016-12-12 09:50:03 EST ... active +acctg 1481553914533 ... 1481553088053 2016-12-12 09:45:14 EST ... active +acctg 1481553651165 ... none 2016-12-12 09:40:51 EST ... active +acctg 1481553088053 ... 1481552078404 2016-12-12 09:31:28 EST ... active +acctg 1481552078404 ... none 2016-12-12 09:14:39 EST ... active +``` + +There are two backup chains. In each of the following chains, the first backup is the initial full backup. + +First backup chain: `1481552078404 => 1481553088053 => 1481553914533 => 1481554802918 => 1481559014359` + +Second backup chain: `1481553651165 => 1481554203288 => 1481559303348` + +The `MANAGE` subcommand is invoked when the first full backup `1481552078404` falls out of the recovery window. When the `MANAGE` subcommand is invoked, it is `2016-12-13 09:20:03 EST`, thus making the start of the 1-day recovery window at `2016-12-12 09:20:03 EST` exactly one day earlier. This backup was taken at `2016-12-12 09:14:39 EST`, which is about 5 ½ minutes before the start of the recovery window, thus making the backup obsolete. + +```text +-bash-4.2$ date +Tue Dec 13 09:20:03 EST 2016 +-bash-4.2$ bart MANAGE -s acctg +INFO: processing server 'acctg', backup '1481553651165' +INFO: processing server 'acctg', backup '1481552078404' +INFO: marking backup '1481552078404' as obsolete +INFO: 4 incremental(s) of backup '1481552078404' will be marked obsolete +INFO: marking incremental backup '1481559014359' as obsolete +INFO: marking incremental backup '1481554802918' as obsolete +INFO: marking incremental backup '1481553914533' as obsolete +INFO: marking incremental backup '1481553088053' as obsolete +INFO: 7 WAL file(s) marked obsolete +INFO: 1 Unused WAL file(s) present +INFO: 2 Unused file(s) (WALs included) present, use 'MANAGE -l' for the list +``` + +The incremental backup date and time are within the recovery window since they were taken after the start of the recovery window of `2016-12-12 09:20:03 EST`, but all backups in the chain are marked as `obsolete`. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg\ +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME +... STATUS +acctg 1481559303348 ... 1481554203288 2016-12-12 11:15:03 EST +... active +acctg 1481559014359 ... 1481554802918 2016-12-12 11:10:14 EST +... obsolete +acctg 1481554802918 ... 1481553914533 2016-12-12 10:00:03 EST +... obsolete +acctg 1481554203288 ... 1481553651165 2016-12-12 09:50:03 EST +... active +acctg 1481553914533 ... 1481553088053 2016-12-12 09:45:14 EST +... obsolete +acctg 1481553651165 ... none 2016-12-12 09:40:51 EST +... active +acctg 1481553088053 ... 1481552078404 2016-12-12 09:31:28 EST +... obsolete +acctg 1481552078404 ... none 2016-12-12 09:14:39 EST +... obsolete +``` + +The following code sample shows how the entire backup chain is changed back to active status by invoking the `MANAGE` subcommand with the `-c nokeep` option on the full backup of the chain. + +```text +-bash-4.2$ bart MANAGE -s acctg -c nokeep -i 1481552078404 +INFO: changing status of backup '1481552078404' of server 'acctg' from +'obsolete' to 'active' +INFO: status of 4 incremental(s) of backup '1481552078404' will be +changed +INFO: changing status of incremental backup '1481559014359' of server +'acctg' from 'obsolete' to 'active' +INFO: changing status of incremental backup '1481554802918' of server +'acctg' from 'obsolete' to 'active' +INFO: changing status of incremental backup '1481553914533' of server +'acctg' from 'obsolete' to 'active' +INFO: changing status of incremental backup '1481553088053' of server +'acctg' from 'obsolete' to 'active' +INFO: 7 WAL file(s) changed +``` + +The backup chain has now been reset to active status. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME ... STATUS +acctg 1481559303348 ... 1481554203288 2016-12-12 11:15:03 EST ... active +acctg 1481559014359 ... 1481554802918 2016-12-12 11:10:14 EST ... active +acctg 1481554802918 ... 1481553914533 2016-12-12 10:00:03 EST ... active +acctg 1481554203288 ... 1481553651165 2016-12-12 09:50:03 EST ... active +acctg 1481553914533 ... 1481553088053 2016-12-12 09:45:14 EST ... active +acctg 1481553651165 ... none 2016-12-12 09:40:51 EST ... active +acctg 1481553088053 ... 1481552078404 2016-12-12 09:31:28 EST ... active +acctg 1481552078404 ... none 2016-12-12 09:14:39 EST ... active +``` + +The following code sample shows usage of the `DELETE` subcommand on an incremental backup. The specified incremental backup `1481554802918` in the first backup chain as well as its successive incremental backup `1481559014359` are deleted. + +```text +-bash-4.2$ bart DELETE -s acctg -i 1481554802918 +INFO: deleting backup '1481554802918' of server 'acctg' +INFO: deleting backup '1481554802918' +INFO: 1 incremental backup(s) will be deleted +INFO: deleting incremental backup '1481559014359' +INFO: WALs of deleted backup(s) will belong to prior backup(if any), or +will be marked unused +INFO: 2 Unused file(s) will be removed +INFO: removing (unused) file '0000000100000000000000BA' +INFO: removing (unused) file +'0000000100000000BA00002800000000BB000000.mbm' +INFO: backup(s) deleted +``` + +The results show that the backups `1481554802918` and `1481559014359` are no longer listed by the `SHOW-BACKUPS` subcommand. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME ... STATUS +acctg 1481559303348 ... 1481554203288 2016-12-12 11:15:03 EST ... active +acctg 1481554203288 ... 1481553651165 2016-12-12 09:50:03 EST ... active +acctg 1481553914533 ... 1481553088053 2016-12-12 09:45:14 EST ... active +acctg 1481553651165 ... none 2016-12-12 09:40:51 EST ... active +acctg 1481553088053 ... 1481552078404 2016-12-12 09:31:28 EST ... active +acctg 1481552078404 ... none 2016-12-12 09:14:39 EST ... active +``` + +The `MANAGE` subcommand is invoked again. This time both backup chains are marked `obsolete` since the full backups of both chains fall out of the start of the recovery window, which is now `2016-12-12 09:55:03 EST`. + +```text +-bash-4.2$ date +Tue Dec 13 09:55:03 EST 2016 +-bash-4.2$ bart MANAGE -s acctg +INFO: processing server 'acctg', backup '1481553651165' +INFO: marking backup '1481553651165' as obsolete +INFO: 2 incremental(s) of backup '1481553651165' will be marked obsolete +INFO: marking incremental backup '1481559303348' as obsolete +INFO: marking incremental backup '1481554203288' as obsolete +INFO: 38 WAL file(s) marked obsolete +INFO: processing server 'acctg', backup '1481552078404' +INFO: marking backup '1481552078404' as obsolete +INFO: 2 incremental(s) of backup '1481552078404' will be marked obsolete +INFO: marking incremental backup '1481553914533' as obsolete +INFO: marking incremental backup '1481553088053' as obsolete +INFO: 7 WAL file(s) marked obsolete +``` + +The following code sample shows both backup chains marked as `obsolete`. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME +... STATUS +acctg 1481559303348 ... 1481554203288 2016-12-12 11:15:03 EST +... obsolete +acctg 1481554203288 ... 1481553651165 2016-12-12 09:50:03 EST +... obsolete +acctg 1481553914533 ... 1481553088053 2016-12-12 09:45:14 EST +... obsolete +acctg 1481553651165 ... none 2016-12-12 09:40:51 EST +... obsolete +acctg 1481553088053 ... 1481552078404 2016-12-12 09:31:28 EST +... obsolete +acctg 1481552078404 ... none 2016-12-12 09:14:39 EST +... obsolete +``` + +The following code sample demonstrates using the `MANAGE` subcommand with the `-c keep` option to keep a backup chain indefinitely. The `MANAGE` subcommand with the `-c keep` option must specify the backup identifier or backup name of the full backup of the chain, and not any incremental backup. + +```text +-bash-4.2$ bart MANAGE -s acctg -c keep -i 1481553651165 +INFO: changing status of backup '1481553651165' of server 'acctg' from +'obsolete' to 'keep' +INFO: status of 2 incremental(s) of backup '1481553651165' will be +changed +INFO: changing status of incremental backup '1481559303348' of server +'acctg' from 'obsolete' to 'keep' +INFO: changing status of incremental backup '1481554203288' of server +'acctg' from 'obsolete' to 'keep' +INFO: 38 WAL file(s) changed +``` + +The full backup `1481553651165` and its successive incremental backups `1481554203288` and `1481559303348` have been changed to `keep` status: + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME +... STATUS +acctg 1481559303348 ... 1481554203288 2016-12-12 11:15:03 EST +... keep +acctg 1481554203288 ... 1481553651165 2016-12-12 09:50:03 EST +... keep +acctg 1481553914533 ... 1481553088053 2016-12-12 09:45:14 EST +... obsolete +acctg 1481553651165 ... none 2016-12-12 09:40:51 EST +... keep +acctg 1481553088053 ... 1481552078404 2016-12-12 09:31:28 EST +... obsolete +acctg 1481552078404 ... none 2016-12-12 09:14:39 EST +... obsolete +``` + +Finally, the `MANAGE` subcommand with the `-d` option is used to delete the `obsolete` backup chain: + +```text +-bash-4.2$ bart MANAGE -s acctg -d +INFO: removing all obsolete backups of server 'acctg' +INFO: removing obsolete backup '1481552078404' +INFO: 7 WAL file(s) will be removed +INFO: 2 incremental(s) of backup '1481552078404' will be removed +INFO: removing obsolete incremental backup '1481553914533' +INFO: removing obsolete incremental backup '1481553088053' +INFO: removing WAL file '0000000100000000000000C1' +INFO: removing WAL file '0000000100000000000000C0' +INFO: removing WAL file '0000000100000000000000BF' +INFO: removing WAL file '0000000100000000000000BE' +INFO: removing WAL file '0000000100000000000000BD' +INFO: removing WAL file '0000000100000000000000BC' +INFO: removing WAL file '0000000100000000000000BB' +INFO: 48 Unused file(s) will be removed +INFO: removing (unused) file '0000000100000000000000FA' +. +. +. +INFO: removing (unused) file '0000000100000000000000BB.00000028.backup' +``` + +Only the backup chain with the `keep` status remains as shown below: + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME +... STATUS +acctg 1481559303348 ... 1481554203288 2016-12-12 11:15:03 EST +... keep +acctg 1481554203288 ... 1481553651165 2016-12-12 09:50:03 EST +... keep +acctg 1481553651165 ... none 2016-12-12 09:40:51 EST +... keep +``` diff --git a/product_docs/docs/bart/2.6.2/bart_ref/03_sample_bart_system_with_local_and_remote_database_servers.mdx b/product_docs/docs/bart/2.6.2/bart_ref/03_sample_bart_system_with_local_and_remote_database_servers.mdx new file mode 100644 index 00000000000..b1527216806 --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_ref/03_sample_bart_system_with_local_and_remote_database_servers.mdx @@ -0,0 +1,1385 @@ +--- +title: "Sample BART System with Local and Remote Database Servers" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/sample_bart_system_with_local_and_remote_database_servers.html" +--- + + + +This section describes a sample BART managed backup and recovery system consisting of both local and remote database servers. The complete steps to configure and operate the system are provided. + +For detailed information about configuring a BART system, see the *EDB Backup and Recovery Installation and Upgrade Guide*. For detailed information about the operational procedures and BART subcommands, see the *EDB Backup and Recovery User Guide*. These guides are available at the [EDB website](/bart/latest/bart_inst/). + +The environment for this sample system is as follows: + +- BART on host `192.168.2.22` running with BART user account `enterprisedb` +- Local Advanced Server on host `192.168.2.22` running with user account `enterprisedb` +- Remote Advanced Server on host `192.168.2.24` running with user account `enterprisedb` +- Remote PostgreSQL server on host `192.168.2.24` running with user account `postgres` + +Passwordless SSH/SCP connections are required between the following: + +- BART on host `192.168.2.22` and the local Advanced Server on the same host `192.168.2.22` +- BART on host `192.168.2.22` and the remote Advanced Server on host `192.168.2.24` +- BART on host `192.168.2.22` and the remote PostgreSQL server on host `192.168.2.24` + +The following sections demonstrate configuring and taking full backups only. To support incremental backups as well, enable the `allow_incremental_backups` parameter for the desired database servers and use the `WAL scanner` program. + +- [The BART Configuration File](#bart_configuration_file) shows the settings used in the BART configuration file. +- [Establishing SSH/SCP Passwordless Connections](#establishing-sshscp-passwordless-connections) provides an example of how to establish an SSH/SCP passwordless connection. +- [Configuring a Replication Database User](#configuring-a-replication-database-user) provides an example of how to configure the replication database user. +- [WAL Archiving Configuration Parameters](#wal-archiving-configuration-parameters) provides an example of how to configure WAL archiving. +- [Creating the BART Backup Catalog](#creating-the-bart-backup-catalog-backup_path) provides information about creating a BART Backup Catalog. +- [Starting the Database Servers with WAL Archiving](#starting-the-database-servers-with-wal-archiving) provides example of starting the database servers with WAL archiving. +- [Taking a Full Backup](#taking-a-full-backup) illustrates taking the first full backup of the database servers. +- [Using Point-In-Time Recovery](#using-point-in-time-recovery) demonstrates the point-in-time recovery operation on the remote PostgreSQL database server. + + + +## The BART Configuration File + +The following code sample shows the settings used in the BART configuration file for the examples that follow: + +```text +[BART] +bart_host= enterprisedb@192.168.2.22 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +retention_policy = 6 BACKUPS +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log + +[ACCTG] +host = 127.0.0.1 +port = 5444 +user = enterprisedb +cluster_owner = enterprisedb +backup_name = acctg_%year-%month-%dayT%hour:%minute +archive_command = 'cp %p %a/%f' +description = "Accounting" + +[MKTG] + +host = 192.168.2.24 +port = 5444 +user = repuser +cluster_owner = enterprisedb +backup_name = mktg_%year-%month-%dayT%hour:%minute +remote_host = enterprisedb@192.168.2.24 +description = "Marketing" + +[HR] + +host = 192.168.2.24 +port = 5432 +user = postgres +cluster_owner = postgres +backup_name = hr_%year-%month-%dayT%hour:%minute +remote_host = postgres@192.168.2.24 +copy_wals_during_restore = enabled +description = "Human Resources" +``` + + + +## Establishing SSH/SCP Passwordless Connections + +This section demonstrates how passwordless SSH/SCP connections are established with the authorized public keys files. + + + +### Generating a Public Key File for the BART User Account + +The BART user account is `enterprisedb` with a home directory of `/opt/PostgresPlus/9.6AS`. + +To generate the public key file, as a root user, first create the `.ssh` subdirectory in the BART user’s home directory and assign ownership of this directory to the `enterprisedb` user, ensuring there are no groups or other users that can access the `.ssh` directory. + +```text +[root@localhost 9.6AS]# pwd +/opt/PostgresPlus/9.6AS +[root@localhost 9.6AS]# mkdir .ssh +[root@localhost 9.6AS]# chown enterprisedb .ssh +[root@localhost 9.6AS]# chgrp enterprisedb .ssh +[root@localhost 9.6AS]# chmod 700 .ssh +[root@localhost 9.6AS]# ls -la | grep ssh +drwx------ 2 enterprisedb enterprisedb 4096 Apr 23 13:02 .ssh +``` + +Generate the public key file: + +```text +[user@localhost ~]$ su - enterprisedb +Password: +-bash-4.1$ pwd +/opt/PostgresPlus/9.6AS +-bash-4.1$ ssh-keygen -t rsa +Generating public/private rsa key pair. +Enter file in which to save the key +(/opt/PostgresPlus/9.6AS/.ssh/id_rsa): +Enter passphrase (empty for no passphrase): +Enter same passphrase again: +Your identification has been saved in +/opt/PostgresPlus/9.6AS/.ssh/id_rsa. +Your public key has been saved in +/opt/PostgresPlus/9.6AS/.ssh/id_rsa.pub. +The key fingerprint is: +de:65:34:d6:b1:d2:32:3c:b0:43:c6:a3:c0:9f:f4:64 +enterprisedb@localhost.localdomain +The key's randomart image is: ++----[ RSA 2048]----+ +| . .+ . | +| o .oE+ o o | +| + * o.X + | +| + .+ * | +| S o | +| . . o | +| . . | +| + | +| | ++-------------------+ +``` + +The following are the resulting files. `id_rsa.pub` is the public key file of BART user account `enterprisedb`. + +```text +-bash-4.1$ ls -l .ssh +total 8 +-rw------- 1 enterprisedb enterprisedb 1675 Apr 23 13:04 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Apr 23 13:04 id_rsa.pub +``` + +### Configuring Access between Local Advanced Server and the BART Host + +Even when the Advanced Server database is on the same host as the BART user account, and the Advanced Server database cluster owner is also the BART user account (`enterprisedb` is this case), a passwordless SSH/SCP connection must be established from the same user account to itself. + +On the BART host where the public key file was just generated (as shown in [Generating a Public Key File for the BART User Account](#generating-a-public-key-file-for-the-bart-user-account)), create the authorized keys file by appending the public key file to any existing authorized keys file. + +Log into the BART host as the BART user account and append the public key file, `id_rsa.pub` onto the `authorized_keys` file in the same `.ssh` directory. + +```text +[user@localhost ~]$ su - enterprisedb +Password: +Last login: Thu Mar 23 10:27:35 EDT 2017 on pts/0 +-bash-4.2$ pwd +/opt/PostgresPlus/9.6AS +-bash-4.2$ ls -l .ssh +total 12 +-rw------- 1 enterprisedb enterprisedb 1675 Mar 23 09:54 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Mar 23 09:54 id_rsa.pub +-rw-r--r-- 1 enterprisedb enterprisedb 345 Mar 23 10:05 known_hosts +-bash-4.2$ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys +-bash-4.2$ ls -l .ssh +total 16 +-rw-rw-r-- 1 enterprisedb enterprisedb 416 Mar 23 10:33 authorized_keys +-rw------- 1 enterprisedb enterprisedb 1675 Mar 23 09:54 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Mar 23 09:54 id_rsa.pub +-rw-r--r-- 1 enterprisedb enterprisedb 345 Mar 23 10:05 known_hosts +``` + +The `authorized_keys` file must have file permission `600` as set by the following `chmod 600` command, or the passwordless connection will fail: + +```text +-bash-4.2$ chmod 600 ~/.ssh/authorized_keys +-bash-4.2$ ls -l .ssh +total 16 +-rw------- 1 enterprisedb enterprisedb 416 Mar 23 10:33 authorized_keys +-rw------- 1 enterprisedb enterprisedb 1675 Mar 23 09:54 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Mar 23 09:54 id_rsa.pub +-rw-r--r-- 1 enterprisedb enterprisedb 345 Mar 23 10:05 known_hosts +``` + +Test the passwordless connection. Use the `ssh` command to verify that you can access the same user account as you are currently logged in as (`enterprisedb`) without being prompted for a password: + +```text +-bash-4.2$ ssh enterprisedb@127.0.0.1 +Last login: Thu Mar 23 10:27:50 2017 +-bash-4.2$ exit +logout +Connection to 127.0.0.1 closed. +``` + +### Configuring Access from Remote Advanced Server to BART Host + +On the remote host `192.168.2.24`, create the public key file for the remote database server user account, `enterprisedb`, for access to the BART user account, `enterprisedb`, on the BART host 192.168.2.22. + +Create the `.ssh` directory for user account `enterprisedb` on the remote host: + +```text +[root@localhost 9.6AS]# pwd +/opt/PostgresPlus/9.6AS +[root@localhost 9.6AS]# mkdir .ssh +[root@localhost 9.6AS]# chown enterprisedb .ssh +[root@localhost 9.6AS]# chgrp enterprisedb .ssh +[root@localhost 9.6AS]# chmod 700 .ssh +[root@localhost 9.6AS]# ls -la | grep ssh +drwx------ 2 enterprisedb enterprisedb 4096 Apr 23 13:08 .ssh +``` + +Generate the public key file on the remote host for user account `enterprisedb`: + +```text +[user@localhost ~]$ su - enterprisedb +Password: +-bash-4.1$ ssh-keygen -t rsa +Generating public/private rsa key pair. +Enter file in which to save the key +(/opt/PostgresPlus/9.6AS/.ssh/id_rsa): +Enter passphrase (empty for no passphrase): +Enter same passphrase again: +Your identification has been saved in +/opt/PostgresPlus/9.6AS/.ssh/id_rsa. +Your public key has been saved in +/opt/PostgresPlus/9.6AS/.ssh/id_rsa.pub. +The key fingerprint is: +15:27:1e:1e:61:4b:48:66:67:0b:b2:be:fc:ea:ea:e6 +enterprisedb@localhost.localdomain +The key's randomart image is: ++--[ RSA 2048]---+ +| ..=.@.. | +| =.O O | +| . * | +| . . | +| . S | +| . . | +| o | +| . . | +| +Eoo.. | ++----------------+ +``` + +Copy the generated public key file, `id_rsa.pub`, to the BART user account, `enterprisedb`, on the BART host, `192.168.2.22`: + +```text +-bash-4.1$ scp ~/.ssh/id_rsa.pub enterprisedb@192.168.2.22:/tmp/tmp.pub +The authenticity of host '192.168.2.22 (192.168.2.22)' can't be +established. +RSA key fingerprint is b8:a9:97:31:79:16:b8:2b:b0:60:5a:91:38:d7:68:22. +Are you sure you want to continue connecting (yes/no)? yes +Warning: Permanently added '192.168.2.22' (RSA) to the list of known hosts. +enterprisedb@192.168.2.22's password: +id_rsa.pub +``` + +Log into the BART host as the BART user account and append the temporary public key file, `/tmp/tmp.pub` onto the `authorized_keys` file owned by the BART user account. + +```text +-bash-4.1$ ssh enterprisedb@192.168.2.22 +enterprisedb@192.168.2.22's password: +Last login: Tue Apr 21 17:03:24 2015 from 192.168.2.22 +-bash-4.1$ pwd +/opt/PostgresPlus/9.6AS +-bash-4.1$ cat /tmp/tmp.pub >> ~/.ssh/authorized_keys +-bash-4.1$ ls -l .ssh +total 12 +-rw-rw-r-- 1 enterprisedb enterprisedb 416 Apr 23 13:15 authorized_keys +-rw------- 1 enterprisedb enterprisedb 1675 Apr 23 13:04 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Apr 23 13:04 id_rsa.pub +``` + +The `authorized_keys` file must have file permission `600` as set by the following `chmod 600` command, otherwise the passwordless connection fails: + +```text +-bash-4.1$ chmod 600 ~/.ssh/authorized_keys +-bash-4.1$ ls -l .ssh +total 12 +-rw------- 1 enterprisedb enterprisedb 416 Apr 23 13:15 authorized_keys +-rw------- 1 enterprisedb enterprisedb 1675 Apr 23 13:04 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Apr 23 13:04 id_rsa.pub +-bash-4.1$ rm /tmp/tmp.pub +-bash-4.1$ exit +logout +Connection to 192.168.2.22 closed. +``` + +Test the passwordless connection. From the remote host, verify that you can log into the BART host with the BART user account without being prompted for a password: + +```text +-bash-4.1$ ssh enterprisedb@192.168.2.22 +Last login: Thu Apr 23 13:14:48 2015 from 192.168.2.24 +-bash-4.1$ exit +logout +Connection to 192.168.2.22 closed. +``` + +### Configuring Access from the BART Host to a Remote Advanced Server + +On the BART host `192.168.2.22`, copy the public key file for the BART user account, `enterprisedb`, for access to the remote database server user account, `enterprisedb`, on the remote host `192.168.2.24`. + +The following lists the current SSH keys files in the BART user’s `.ssh` directory on the BART host: + +```text +[user@localhost ~]$ su - enterprisedb +Password: +-bash-4.1$ pwd +/opt/PostgresPlus/9.6AS +-bash-4.1$ ls -l .ssh +total 12 +-rw------- 1 enterprisedb enterprisedb 416 Apr 23 13:15 authorized_keys +-rw------- 1 enterprisedb enterprisedb 1675 Apr 23 13:04 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Apr 23 13:04 id_rsa.pub +``` + +The public key file, `id_rsa.pub`, for BART user account `enterprisedb` on the BART host that was earlier generated in [Generating a Public Key File for the BART User Account](#generating-a-public-key-file-for-the-bart-user-account), is now copied to the remote Advanced Server host on `192.168.2.24`: + +```text +-bash-4.1$ scp ~/.ssh/id_rsa.pub enterprisedb@192.168.2.24:/tmp/tmp.pub +The authenticity of host '192.168.2.24 (192.168.2.24)' can't be +established. +RSA key fingerprint is 59:41:fb:0c:ae:64:3d:3f:a2:d9:90:95:cf:2c:99:f2. +Are you sure you want to continue connecting (yes/no)? yes +Warning: Permanently added '192.168.2.24' (RSA) to the list of known +hosts. +enterprisedb@192.168.2.24's password: +id_rsa.pub +``` + +Log into the `enterprisedb` user account on the remote host and copy the public key file onto the `authorized_keys` file of the remote `enterprisedb` user account under its `.ssh` directory: + +```text +-bash-4.1$ ssh enterprisedb@192.168.2.24 +enterprisedb@192.168.2.24's password: +Last login: Tue Apr 21 09:53:18 2015 from 192.168.2.22 +-bash-4.1$ pwd +/opt/PostgresPlus/9.6AS +-bash-4.1$ ls -l .ssh +total 12 +-rw------- 1 enterprisedb enterprisedb 1675 Apr 23 13:11 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Apr 23 13:11 id_rsa.pub +-rw-r--r-- 1 enterprisedb enterprisedb 394 Apr 23 13:12 known_hosts +-bash-4.1$ cat /tmp/tmp.pub >> ~/.ssh/authorized_keys +``` + +Adjust the file permission on `authorized_keys`: + +```text +-bash-4.1$ chmod 600 ~/.ssh/authorized_keys +-bash-4.1$ ls -l .ssh +total 16 +-rw------- 1 enterprisedb enterprisedb 416 Apr 23 13:26 authorized_keys +-rw------- 1 enterprisedb enterprisedb 1675 Apr 23 13:11 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Apr 23 13:11 id_rsa.pub +-rw-r--r-- 1 enterprisedb enterprisedb 394 Apr 23 13:12 known_hosts +-bash-4.1$ rm /tmp/tmp.pub +-bash-4.1$ exit +logout +Connection to 192.168.2.24 closed. +``` + +While logged into the BART host, test the passwordless connection from the BART host to the remote Advanced Server host: + +```text +-bash-4.1$ ssh enterprisedb@192.168.2.24 +Last login: Thu Apr 23 13:25:53 2015 from 192.168.2.22 +-bash-4.1$ exit +logout +Connection to 192.168.2.24 closed. +``` + +### Configuring Access from a Remote PostgreSQL Server to a BART Host + +On the remote host (192.168.2.24), create a public key file owned by the database server user account (`postgres`), allowing access to the BART user account (`enterprisedb`) on the BART host (192.168.2.22). + +Create the `.ssh` directory for the `postgres` user account on the remote host: + +```text +[root@localhost 9.6]# cd /opt/PostgreSQL/9.6 +[root@localhost 9.6]# mkdir .ssh +[root@localhost 9.6]# chown postgres .ssh +[root@localhost 9.6]# chgrp postgres .ssh +[root@localhost 9.6]# chmod 700 .ssh +[root@localhost 9.6]# ls -la | grep ssh +drwx------ 2 postgres postgres 4096 Apr 23 13:32 .ssh +``` + +Create and copy the generated public key file, `id_rsa.pub`, to the BART user account (`enterprisedb`), on the BART host (`192.168.2.22`): + +```text +[user@localhost ~]$ su - postgres +Password: +-bash-4.1$ pwd +/opt/PostgreSQL/9.6 +-bash-4.1$ ssh-keygen -t rsa +Generating public/private rsa key pair. +Enter file in which to save the key (/opt/PostgreSQL/9.6/.ssh/id_rsa): +Enter passphrase (empty for no passphrase): +Enter same passphrase again: +Your identification has been saved in /opt/PostgreSQL/9.6/.ssh/id_rsa. +Your public key has been saved in /opt/PostgreSQL/9.6/.ssh/id_rsa.pub. +The key fingerprint is: +1f:f8:76:d6:fc:a5:1a:c5:5a:66:66:01:d0:a0:ca:ba +postgres@localhost.localdomain +The key's randomart image is: ++--[ RSA 2048]----+ +| o+. | +| . .. | +| . . | +| . . . . . | +| o S . O | +| . o . @ | +| . + = o .| +| . . o . o.| +| E ... .| ++-----------------+ +-bash-4.1$ ls -l .ssh +total 8 +-rw------- 1 postgres postgres 1671 Apr 23 13:36 id_rsa +-rw-r--r-- 1 postgres postgres 412 Apr 23 13:36 id_rsa.pub +-bash-4.1$ scp ~/.ssh/id_rsa.pub enterprisedb@192.168.2.22:/tmp/tmp.pub +The authenticity of host '192.168.2.22 (192.168.2.22)' can't be +established. +RSA key fingerprint is b8:a9:97:31:79:16:b8:2b:b0:60:5a:91:38:d7:68:22. +Are you sure you want to continue connecting (yes/no)? yes +Warning: Permanently added '192.168.2.22' (RSA) to the list of known +hosts. +enterprisedb@192.168.2.22's password: +id_rsa.pub +``` + +Log into the BART host as the BART user account and append the temporary public key file, `/tmp/tmp.pub`, onto the `authorized_keys` file owned by the BART user account. + +```text +-bash-4.1$ ssh enterprisedb@192.168.2.22 +enterprisedb@192.168.2.22's password: +Last login: Thu Apr 23 13:19:25 2015 from 192.168.2.24 +-bash-4.1$ pwd +/opt/PostgresPlus/9.6AS +-bash-4.1$ cat /tmp/tmp.pub >> ~/.ssh/authorized_keys +-bash-4.1$ ls -l .ssh +total 16 +-rw------- 1 enterprisedb enterprisedb 828 Apr 23 13:40 authorized_keys +-rw------- 1 enterprisedb enterprisedb 1675 Apr 23 13:04 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Apr 23 13:04 id_rsa.pub +-rw-r--r-- 1 enterprisedb enterprisedb 394 Apr 23 13:24 known_hosts +-bash-4.1$ rm /tmp/tmp.pub +-bash-4.1$ exit +logout +Connection to 192.168.2.22 closed. +``` + +Make sure the `authorized_keys` file has file permission 600 as shown, or the passwordless connection will fail. Test the passwordless connection; from the remote host, while logged in as user account `postgres`, verify that you can log into the BART host with the BART user account without being prompted for a password: + +```text +-bash-4.1$ pwd +/opt/PostgreSQL/9.6 +-bash-4.1$ ssh enterprisedb@192.168.2.22 +Last login: Thu Apr 23 13:40:10 2015 from 192.168.2.24 +-bash-4.1$ exit +logout +Connection to 192.168.2.22 closed. +``` + +### Configuring Access from the BART Host to Remote PostgreSQL + +Copy the public key file on the BART host that is owned by the BART user account (`enterprisedb`) to the remote database server user account (`postgres`), on the remote host (192.168.2.24). + +The following lists the current SSH keys files in the BART user’s `.ssh` directory on the BART host: + +```text +[user@localhost ~]$ su - enterprisedb +Password: +-bash-4.1$ ls -l .ssh +total 16 +-rw------- 1 enterprisedb enterprisedb 828 Apr 23 13:40 authorized_keys +-rw------- 1 enterprisedb enterprisedb 1675 Apr 23 13:04 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Apr 23 13:04 id_rsa.pub +-rw-r--r-- 1 enterprisedb enterprisedb 394 Apr 23 13:24 known_hosts +``` + +The public key file, `id_rsa.pub`, for BART user account `enterprisedb` on the BART host that was earlier generated in [Generating a Public Key File for the BART User Account](#generating-a-public-key-file-for-the-bart-user-account), now resides on the remote PostgreSQL host: + +```text +-bash-4.1$ scp ~/.ssh/id_rsa.pub postgres@192.168.2.24:/tmp/tmp.pub +postgres@192.168.2.24's password: +id_rsa.pub +``` + +Log into the `postgres` user account on the remote host and copy the public key file onto the `authorized_keys` file of `postgres` under its `.ssh` directory: + +```text +-bash-4.1$ ssh postgres@192.168.2.24 +postgres@192.168.2.24's password: +Last login: Mon Jan 26 18:08:36 2015 from 192.168.2.19 +-bash-4.1$ pwd +/opt/PostgreSQL/9.6 +-bash-4.1$ cat /tmp/tmp.pub >> ~/.ssh/authorized_keys +``` + +Adjust the file permissions on `authorized_keys`: + +```text +-bash-4.1$ ls -l .ssh +total 16 +-rw-rw-r-- 1 postgres postgres 416 Apr 23 13:52 authorized_keys +-rw------- 1 postgres postgres 1671 Apr 23 13:36 id_rsa +-rw-r--r-- 1 postgres postgres 412 Apr 23 13:36 id_rsa.pub +-rw-r--r-- 1 postgres postgres 394 Apr 23 13:36 known_hosts +-bash-4.1$ chmod 600 ~/.ssh/authorized_keys +-bash-4.1$ ls -l .ssh +total 16 +-rw------- 1 postgres postgres 416 Apr 23 13:52 authorized_keys +-rw------- 1 postgres postgres 1671 Apr 23 13:36 id_rsa +-rw-r--r-- 1 postgres postgres 412 Apr 23 13:36 id_rsa.pub +-rw-r--r-- 1 postgres postgres 394 Apr 23 13:36 known_hosts +-bash-4.1$ rm /tmp/tmp.pub +-bash-4.1$ exit +logout +Connection to 192.168.2.24 closed. +``` + +Test the passwordless connection from the BART host to the remote PostgreSQL host: + +```text +[user@localhost ~]$ su - enterprisedb +Password: +-bash-4.1$ ssh postgres@192.168.2.24 +Last login: Thu Apr 23 13:52:25 2015 from 192.168.2.22 +-bash-4.1$ exit +logout +Connection to 192.168.2.24 closed. +``` + + + +## Configuring a Replication Database User + +This section demonstrates how a replication database user is established. + +**All database servers must use a superuser as the replication database user.** + +The replication database user for each database server is specified by the `user` parameter in the BART configuration file as shown by the following: + +```text +[ACCTG] + +host = 127.0.0.1 +port = 5444 +user = enterprisedb <=== Replication Database User +cluster_owner = enterprisedb +backup_name = acctg_%year-%month-%dayT%hour:%minute +archive_command = 'cp %p %a/%f' +description = "Accounting" + +[MKTG] +host = 192.168.2.24 +port = 5444 +user = repuser <=== Replication Database User +cluster_owner = enterprisedb +backup_name = mktg_%year-%month-%dayT%hour:%minute +remote_host = enterprisedb@192.168.2.24 +description = "Marketing" + +[HR] + +host = 192.168.2.24 +port = 5432 +user = postgres <=== Replication Database User +cluster_owner = enterprisedb +backup_name = hr_%year-%month-%dayT%hour:%minute +remote_host = postgres@192.168.2.24 +copy_wals_during_restore = enabled +description = "Human Resources" +``` + +Add entries to the `.pgpass` file on each server to allow the BART user account to initiate a backup without being prompted for credentials. The `.pgpass` file is located in `/opt/PostgresPlus/9.6AS/.pgpass`: + +```text +127.0.0.1:5444:*:enterprisedb:password +192.168.2.24:5444:*:repuser:password +192.168.2.24:5432:*:postgres:password +``` + +For more information about using a `.pgpass` file, please see the [PostgreSQL documentation](https://www.postgresql.org/docs/current/libpq-pgpass.html). + +While connected to `MKTG` on 192.168.2.24, execute the following `CREATE ROLE` command to create the replication database superuser: + +```text +CREATE ROLE repuser WITH LOGIN SUPERUSER PASSWORD 'password'; +``` + +Access is granted in the `pg_hba.conf` file for the local Advanced Server: + +```text +# TYPE DATABASE USER ADDRESS METHOD +# "local" is for Unix domain socket connections only +local all all md5 +# IPv4 local connections: +host template1 enterprisedb 127.0.0.1/32 md5 +host edb enterprisedb 127.0.0.1/32 md5 +#host all all 127.0.0.1/32 md5 +# IPv6 local connections: +host all all ::1/128 md5 +# Allow replication connections from localhost, by a user with the +# replication privilege. +#local replication enterprisedb md5 +host replication enterprisedb 127.0.0.1/32 md5 +``` + +Similarly, access is granted in the `pg_hba.conf` file for the remote Advanced Server installation: + +```text +# TYPE DATABASE USER ADDRESS METHOD +# "local" is for Unix domain socket connections only +local all all md5 +# IPv4 local connections: +host template1 repuser 192.168.2.22/32 md5 +host all enterprisedb 127.0.0.1/32 md5 +#host all all 127.0.0.1/32 md5 +# IPv6 local connections: +host all all ::1/128 md5 +# Allow replication connections from localhost, by a user with the +# replication privilege. +#local replication enterprisedb md5 +host replication repuser 192.168.2.22/32 md5 +``` + +Access is also granted in the `pg_hba.conf` file for the remote PostgreSQL server: + +```text +# TYPE DATABASE USER ADDRESS METHOD +# "local" is for Unix domain socket connections only +local all all md5 +# IPv4 local connections: +host template1 postgres 192.168.2.22/32 md5 +host all all 127.0.0.1/32 md5 +# IPv6 local connections: +host all all ::1/128 md5 +# Allow replication connections from localhost, by a user with the +q# replication privilege. +#local replication postgres md5 +host replication postgres 192.168.2.22/32 md5 +``` + + + +## WAL Archiving Configuration Parameters + +Use the following parameters in the `postgresql.conf` file to enable WAL archiving. The `postgresql.conf` file for the local Advanced Server database (`ACCTG`) is set as follows: + +```text +wal_level = archive +archive_mode = on # allows archiving to be done + # (change requires restart) +#archive_command = '' # command to use to archive + a logfile segment + # placeholders: %p = path of + file to archive + # %f = file name only +max_wal_senders = 3 +``` + +When the `INIT` subcommand is invoked, the Postgres `archive_command` configuration parameter in the `postgresql.auto.conf` file will be set based on the BART `archive_command` parameter located in the BART configuration file. + +!!! Note + If the Postgres `archive_command` is already set, invoke the `INIT` subcommand with the `-- no-configure` option to prevent the `archive_command` from being reset. For details, see [INIT](../bart_user/03_using_bart/03_basic_bart_subcommand_usage/02_init/#init). + +```text +[BART] +bart_host= enterprisedb@192.168.2.22 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +retention_policy = 6 BACKUPS +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log + +[ACCTG] +host = 127.0.0.1 +port = 5444 +user = enterprisedb +cluster_owner = enterprisedb +backup_name = acctg_%year-%month-%dayT%hour:%minute +archive_command = 'cp %p %a/%f' +description = "Accounting" +``` + +When the `INIT` subcommand is invoked, the `postgresql.auto.conf` file contains the following: + +```text +# Do not edit this file manually! +# It will be overwritten by ALTER SYSTEM command. +archive_command = 'cp %p /opt/backup/acctg/archived_wals/%f' +``` + +The `archive_command` uses the `cp` command instead of `scp` since the BART backup catalog is local to this database cluster and the BART user account (the account that owns the backup catalog, `enterprisedb`), is the same user account running Advanced Server. The result is that there is no directory permission conflict during the archive operation. + +The `postgresql.conf` file for the remote Advanced Server, `MKTG` is set as follows: + +```text +wal_level = archive +archive_mode = on # allows archiving to be done + # (change requires restart) +archive_command = '' # command to use to archive a + logfile segment + # placeholders: %p = path of + file to archive + # %f = file name only +max_wal_senders = 3 +``` + +When the `INIT` subcommand is invoked, the Postgres `archive_command` configuration parameter in the `postgresql.auto.conf` file will be set by the default BART format of the BART `archive_command` parameter (since it is not explicitly set for this database server in the BART configuration file). + +```text +[BART] +bart_host= enterprisedb@192.168.2.22 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +retention_policy = 6 BACKUPS +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log +. +. +. +[MKTG] + +host = 192.168.2.24 +port = 5444 +user = repuser +cluster_owner = enterprisedb +backup_name = mktg_%year-%month-%dayT%hour:%minute +remote_host = enterprisedb@192.168.2.24 +description = "Marketing" +``` + +The default BART `archive_command` format is: + +```text +archive_command = 'scp %p %h:%a/%f' +``` + +The `postgresql.auto.conf` file contains the following after the `INIT` subcommand is invoked: + +```text +# Do not edit this file manually! +# It will be overwritten by ALTER SYSTEM command. +archive_command = 'scp %p +enterprisedb@192.168.2.22:/opt/backup/hr/archived_wals/%f' +``` + +The `archive_command` uses the `scp` command since the BART backup catalog is remote relative to this database cluster. The BART user account, `enterprisedb`, is specified on the `scp` command since this is the user account owning the BART backup catalog where the archived WAL files are to be copied. The result is that there is no directory permission conflict during the archive operation. + +The `postgresql.conf` file for the remote PostgreSQL server (`HR`) is set as follows: + +```text +wal_level = archive +archive_mode = on # allows archiving to be done + # (change requires restart) +#archive_command = '' # command to use to archive a + logfile segment + # placeholders: %p = path of + file to archive + # %f = file name only +max_wal_senders = 3 +``` + +When the `INIT` subcommand is invoked, the Postgres `archive_command` configuration parameter in the `postgresql.auto.conf` file will be set by the default BART format of the BART `archive_command` parameter (since it is not explicitly set for this database server in the BART configuration file): + +```text +[BART] + +bart_host= enterprisedb@192.168.2.22 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +retention_policy = 6 BACKUPS +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log +. +. +. +[HR] + +host = 192.168.2.24 +port = 5432 +user = postgres +cluster_owner = postgres +backup_name = hr_%year-%month-%dayT%hour:%minute +remote_host = postgres@192.168.2.24 +copy_wals_during_restore = enabled +description = "Human Resources" +``` + +The default BART `archive_command` format is: + +```text +archive_command = 'scp %p %h:%a/%f' +``` + +The `postgresql.auto.conf` file contains the following after the `INIT` subcommand is invoked: + +```text +# Do not edit this file manually! +# It will be overwritten by ALTER SYSTEM command. +archive_command = 'scp %p +enterprisedb@192.168.2.22:/opt/backup/hr/archived_wals/%f' +``` + +The `archive_command` uses the `scp` command since the BART backup catalog is remote relative to this database cluster. The BART user account, `enterprisedb`, is specified on the `scp` command since this is the user account owning the BART backup catalog where the archived WAL files are to be copied. The result is that there is no directory permission conflict during the archive operation. + + + +## Creating the BART Backup Catalog (backup_path) + +Create the directory specified by the `backup_path` configuration parameter. + +```text +[BART] + +bart_host= enterprisedb@192.168.2.22 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +retention_policy = 6 BACKUPS +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log +``` + +Ensure that the directory is owned by the BART user account: + +```text +[root@localhost opt]# pwd +/opt +[root@localhost opt]# mkdir backup +[root@localhost opt]# chown enterprisedb backup +[root@localhost opt]# chgrp enterprisedb backup +[root@localhost opt]# chmod 700 backup +[root@localhost opt]# ls -l | grep backup +drwx------ 2 enterprisedb enterprisedb 4096 Apr 23 15:36 backup +``` + +Use the BART `INIT` subcommand to complete the directory structure and set the Postgres `archive_command` configuration parameter. + +Before invoking any BART subcommands, set up a profile under the BART user account’s home directory to set the `LD_LIBRARY_PATH` and `PATH` environment variables. For more information regarding setting this variable, see the EDB Backup and Recovery Installation and Upgrade Guide available at the [EDB website](/bart/latest/bart_inst/). + +The `-o` option is specified with the `INIT` subcommand to force the setting of the Postgres `archive_command` configuration parameter when `archive_mode` is `off` or if the Postgres `archive_command` parameter is already set and needs to be overridden. + +```text +[user@localhost ~]$ su - enterprisedb +Password: +-bash-4.1$ bart INIT -o +INFO: setting archive_command for server 'acctg' +WARNING: archive_command is set. server restart is required +INFO: setting archive_command for server 'hr' +WARNING: archive_command is set. server restart is required +INFO: setting archive_command for server 'mktg' +WARNING: archive_command is set. server restart is required +``` + +The BART `SHOW-SERVERS` subcommand displays the following: + +```text +-bash-4.1$ bart SHOW-SERVERS +SERVER NAME : acctg +BACKUP FRIENDLY NAME: acctg_%year-%month-%dayT%hour:%minute +HOST NAME : 127.0.0.1 +USER NAME : enterprisedb +PORT : 5444 +REMOTE HOST : +RETENTION POLICY : 6 Backups +DISK UTILIZATION : 0.00 bytes +NUMBER OF ARCHIVES : 0 +ARCHIVE PATH : /opt/backup/acctg/archived_wals +ARCHIVE COMMAND : (disabled) +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +INCREMENTAL BACKUP : DISABLED +DESCRIPTION : "Accounting" +SERVER NAME : hr +BACKUP FRIENDLY NAME: hr_%year-%month-%dayT%hour:%minute +HOST NAME : 192.168.2.24 +USER NAME : postgres +PORT : 5432 +REMOTE HOST : postgres@192.168.2.24 +RETENTION POLICY : 6 Backups +DISK UTILIZATION : 0.00 bytes +NUMBER OF ARCHIVES : 0 +ARCHIVE PATH : /opt/backup/hr/archived_wals +ARCHIVE COMMAND : (disabled) +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +INCREMENTAL BACKUP : DISABLED +DESCRIPTION : "Human Resources" +SERVER NAME : mktg +BACKUP FRIENDLY NAME: mktg_%year-%month-%dayT%hour:%minute +HOST NAME : 192.168.2.24 +USER NAME : repuser +PORT : 5444 +REMOTE HOST : enterprisedb@192.168.2.24 +RETENTION POLICY : 6 Backups +DISK UTILIZATION : 0.00 bytes +NUMBER OF ARCHIVES : 0 +ARCHIVE PATH : /opt/backup/mktg/archived_wals +ARCHIVE COMMAND : (disabled) +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +INCREMENTAL BACKUP : DISABLED +DESCRIPTION : "Marketing" +-bash-4.1$ cd /opt/backup +-bash-4.1$ pwd +/opt/backup +-bash-4.1$ ls -l +total 12 +drwxrwxr-x 3 enterprisedb enterprisedb 4096 Mar 29 13:16 acctg +drwxrwxr-x 3 enterprisedb enterprisedb 4096 Mar 29 13:16 hr +drwxrwxr-x 3 enterprisedb enterprisedb 4096 Mar 29 13:16 mktg +-bash-4.1$ ls -l acctg +total 4 +drwxrwxr-x 2 enterprisedb enterprisedb 4096 Mar 29 13:16 archived_wals +-bash-4.1$ ls -l hr +total 4 +drwxrwxr-x 2 enterprisedb enterprisedb 4096 Mar 29 13:16 archived_wals +-bash-4.1$ ls -l mktg +total 4 +drwxrwxr-x 2 enterprisedb enterprisedb 4096 Mar 29 13:16 archived_wals +``` + +The `ARCHIVE PATH` field displays the full directory path to where the WAL files are copied. This directory path must match the directory path specified in the Postgres `archive_command` parameter of the `postgresql.conf` file or the `postgresql.auto.conf` file of each database server. + + + +### Starting the Database Servers with WAL Archiving + +After the BART backup catalog directory structure has been configured, start the archiving of WAL files from the database servers by restarting each database server. + +On BART host 192.168.2.22: + +```text +[root@localhost data]# service ppas-9.6 restart +``` + +On remote host 192.168.2.24: + +```text +[root@localhost data]# service ppas-9.6 restart + +[root@localhost data]# service postgresql-9.6 restart +``` + +In the BART backup catalog, verify that the WAL files are archiving. + +Archived WAL files may not appear very frequently depending upon how often WAL archiving is set to switch to a new segment file with the `archive_timeout` parameter in your database server configuration settings. + +Verify that there are no archiving-related errors in the database server log files. + +## Taking a Full Backup + +The following code sample shows the first full backup of the database servers. + +```text +-bash-4.1$ bart BACKUP -s acctg -z +INFO: creating backup for server 'acctg' +INFO: backup identifier: '1490809695281' +60776/60776 kB (100%), 1/1 tablespace + +INFO: backup completed successfully +INFO: backup checksum: 37f3defb98ca88dcf05079815555dfc2 of base.tar.gz +INFO: +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1490809695281 +BACKUP NAME: acctg_2017-03-29T13:48 +BACKUP PARENT: none +BACKUP LOCATION: /opt/backup/acctg/1490809695281 +BACKUP SIZE: 6.10 MB +BACKUP FORMAT: tar.gz +BACKUP TIMEZONE: US/Eastern +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 1 +ChkSum File +37f3defb98ca88dcf05079815555dfc2 base.tar.gz + +TABLESPACE(s): 0 +START WAL LOCATION: 000000010000000000000004 +STOP WAL LOCATION: 000000010000000000000004 +BACKUP METHOD: streamed +BACKUP FROM: primary +START TIME: 2017-03-29 13:48:15 EDT +STOP TIME: 2017-03-29 13:48:17 EDT +TOTAL DURATION: 2 sec(s) + +-bash-4.1$ bart BACKUP -s mktg -z +INFO: creating backup for server 'mktg' +INFO: backup identifier: '1490809751193' +61016/61016 kB (100%), 1/1 tablespace + +INFO: backup completed successfully +INFO: backup checksum: 8b010e130a105e76d01346bb56dfcf14 of base.tar.gz +INFO: +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1490809751193 +BACKUP NAME: mktg_2017-03-29T13:49 +BACKUP PARENT: none +BACKUP LOCATION: /opt/backup/mktg/1490809751193 +BACKUP SIZE: 6.13 MB +BACKUP FORMAT: tar.gz +BACKUP TIMEZONE: US/Eastern +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 1 +ChkSum File +8b010e130a105e76d01346bb56dfcf14 base.tar.gz + +TABLESPACE(s): 0 +START WAL LOCATION: 000000010000000100000085 +BACKUP METHOD: streamed +BACKUP FROM: primary +START TIME: 2017-03-29 13:49:11 EDT +STOP TIME: 2017-03-29 13:49:14 EDT +TOTAL DURATION: 3 sec(s) + +-bash-4.1$ bart BACKUP -s hr -z +INFO: creating backup for server 'hr' +INFO: backup identifier: '1490809824946' +38991/38991 kB (100%), 1/1 tablespace +INFO: backup completed successfully +INFO: backup checksum: 277e8a1a80ba3474f541eb316a417c9a of base.tar.gz +INFO: +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1490809824946 +BACKUP NAME: hr_2017-03-29T13:50 +BACKUP PARENT: none +BACKUP LOCATION: /opt/backup/hr/1490809824946 +BACKUP SIZE: 2.59 MB +BACKUP FORMAT: tar.gz +BACKUP TIMEZONE: US/Eastern +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 1 +ChkSum File +277e8a1a80ba3474f541eb316a417c9a base.tar.gz + +TABLESPACE(s): 0 +START WAL LOCATION: 000000010000000000000002 +BACKUP METHOD: streamed +BACKUP FROM: primary +START TIME: 2017-03-29 13:50:25 EDT +STOP TIME: 2017-03-29 13:50:26 EDT +TOTAL DURATION: 1 sec(s) +``` + +The following code sample shows the backup directories created for each backup of each database server. The backup ID is used as the backup directory name. + +```text +-bash-4.1$ cd /opt/backup +-bash-4.1$ ls -l +total 12 +drwxrwxr-x 4 enterprisedb enterprisedb 4096 Mar 29 13:48 acctg +drwxrwxr-x 4 enterprisedb enterprisedb 4096 Mar 29 13:50 hr +drwxrwxr-x 4 enterprisedb enterprisedb 4096 Mar 29 13:49 mktg +-bash-4.1$ ls -l acctg +total 8 +drwx------ 2 enterprisedb enterprisedb 4096 Mar 29 13:48 1490809695281 +drwxrwxr-x 2 enterprisedb enterprisedb 4096 Mar 29 13:48 archived_wals +-bash-4.1$ ls -l hr +total 8 +drwx------ 2 enterprisedb enterprisedb 4096 Mar 29 13:50 1490809824946 +drwxrwxr-x 2 enterprisedb enterprisedb 4096 Mar 29 13:50 archived_wals +-bash-4.1$ ls -l mktg +total 8 +drwx------ 2 enterprisedb enterprisedb 4096 Mar 29 13:49 1490809751193 +drwxrwxr-x 2 enterprisedb enterprisedb 4096 Mar 29 13:49 archived_wals +``` + + + +## Using Point-In-Time Recovery + +This section demonstrates using the point-in-time recovery operation on the remote PostgreSQL database server. + +The following tables were created about two minutes apart with WAL archiving enabled: + +```text +postgres=# \dt + + List of relations +Schema | Name | Type | Owner + +--------+----------------+---------+--------- +public | hr_rmt_t1_1356 | table | postgres +public | hr_rmt_t1_1358 | table | postgres +public | hr_rmt_t1_1400 | table | postgres +public | hr_rmt_t1_1402 | table | postgres +public | hr_rmt_t1_1404 | table | postgres +public | hr_rmt_t1_1406 | table | postgres +(6 rows) +``` + +In the table name `hr_rmt_t_, n` represents the active timeline. `` is the approximate time the table was created. For example, `hr_rmt_t1_1356` was created at approximately 1:56 PM while timeline #1 is active. + +The PostgreSQL database server was then stopped. WAL files that have been created, but not yet archived must be identified, and then saved. The following archived WAL files are in the BART backup catalog: + +```text +-bash-4.1$ ls -l hr/archived_wals +total 49156 +-rw------- 1 enterprisedb enterprisedb 16777216 Mar 29 13:50 +000000010000000000000001 +-rw------- 1 enterprisedb enterprisedb 16777216 Mar 29 13:50 +000000010000000000000002 +-rw------- 1 enterprisedb enterprisedb 302 Mar 29 13:50 +000000010000000000000002.00000028.backup +-rw------- 1 enterprisedb enterprisedb 16777216 Mar 29 14:07 +000000010000000000000003 +``` + +The following sample lists the current PostgreSQL server WAL files. The unarchived WAL files are marked with two stars (\*\*). + +```text +-bash-4.1$ cd /opt/PostgreSQL/9.6/data/pg_xlog +-bash-4.1$ pwd +/opt/PostgreSQL/9.6/data/pg_xlog +-bash-4.1$ ls -l +total 49160 +-rw------- 1 postgres postgres 302 Mar 29 13:50 +000000010000000000000002.00000028.backup +-rw------- 1 postgres postgres 16777216 Mar 29 14:07 +000000010000000000000003 +-rw------- 1 postgres postgres 16777216 Mar 29 14:07 +**000000010000000000000004** +-rw------- 1 postgres postgres 16777216 Mar 29 13:50 +**000000010000000000000005** +drwx------ 2 postgres postgres 4096 Mar 29 14:07 archive_status +``` + +Copies of the unarchived WAL files are saved to a temporary location: + +```text +-bash-4.1$ mkdir /tmp/unarchived_pg96_wals +-bash-4.1$ pwd +/opt/PostgreSQL/9.6/data/pg_xlog +bash-4.1$ cp -p 000000010000000000000004 /tmp/unarchived_pg96_wals +bash-4.1$ cp -p 000000010000000000000005 /tmp/unarchived_pg96_wals +bash-4.1$ ls -l /tmp/unarchived_pg96_wals +total 32768 +-rw------- 1 postgres postgres 16777216 Mar 29 14:07 000000010000000000000004 +-rw------- 1 postgres postgres 16777216 Mar 29 13:50 000000010000000000000005 +``` + +On the remote host, a directory is created to which the PostgreSQL database cluster is to be restored. This restore path is named `/opt/restore_pg96` and is owned by user account `postgres`. + +```text +[user@localhost ~]$ su root +Password: +[root@localhost user]# cd /opt +[root@localhost opt]# mkdir restore_pg96 +[root@localhost opt]# chown postgres restore_pg96 +[root@localhost opt]# chgrp postgres restore_pg96 +[root@localhost opt]# chmod 700 restore_pg96 +[root@localhost opt]# ls -l +total 16 +drwxr-xr-x 4 root daemon 4096 Mar 29 12:10 PostgresPlus +drwxr-xr-x 3 root daemon 4096 Mar 29 12:25 PostgreSQL +drwx------ 2 postgres postgres 4096 Mar 29 14:15 restore_pg96 +drwxr-xr-x. 2 root root 4096 Nov 22 2013 rh +``` + +In the BART configuration file, the remote user and remote host IP address, `postgres@192.168.2.24`, have been set with the `remote_host` parameter. If not given in the BART configuration file, this information must then be specified by the `--remote-host` option when giving the `RESTORE` subcommand (for example, `bart RESTORE --remote-host postgres@192.168.2.24 …`). + +```text +[HR] + +host = 192.168.2.24 +port = 5432 +user = postgres +cluster_owner = postgres +backup_name = hr_%year-%month-%dayT%hour:%minute +remote_host = postgres@192.168.2.24 +copy_wals_during_restore = enabled +description = "Human Resources" +``` + +Use the `SHOW-BACKUPS` subcommand to identify the backup to use with the `RESTORE` subcommand. + +```text +SERVER NAME BACKUP ID BACKUP NAME BACKUP PARENT +BACKUP TIME +BACKUP SIZE WAL(s) SIZE WAL FILES STATUS +acctg 1490809695281 acctg_2017-03-29T13:48 none +2017-03-29 13:48:17 EDT +6.10 MB 32.00 MB 2 active +hr 1490809824946 hr_2017-03-29T13:50 none +2017-03-29 13:50:26 EDT +2.59 MB 32.00 MB 2 active +mktg 1490809751193 mktg_2017-03-29T13:49 none +2017-03-29 13:49:14 EDT +6.13 MB 64.00 MB 4 active +``` + +The `-t` option with the `SHOW-BACKUPS` subcommand displays additional backup information: + +```text +-bash-4.1$ bart SHOW-BACKUPS -s hr -i 1490809824946 -t +SERVER NAME : hr +BACKUP ID : 1490809824946 +BACKUP NAME : hr_2017-03-29T13:50 +BACKUP PARENT : none +BACKUP STATUS : active +BACKUP TIME : 2017-03-29 13:50:26 EDT +BACKUP SIZE : 2.59 MB +WAL(S) SIZE : 32.00 MB +NO. OF WALS : 2 +FIRST WAL FILE : 000000010000000000000002 +CREATION TIME : 2017-03-29 13:50:31 EDT +LAST WAL FILE : 000000010000000000000003 +CREATION TIME : 2017-03-29 14:07:35 EDT +``` + +A recovery is made using timeline `1` to `2017-03-29 14:01:00`. + +```text +-bash-4.1$ bart RESTORE -s hr -i hr_2017-03-29T13:50 -p +/opt/restore_pg96 -t 1 -g '2017-03-29 14:01:00' +INFO: restoring backup 'hr_2017-03-29T13:50' of server 'hr' +INFO: base backup restored +INFO: copying WAL file(s) to +postgres@192.168.2.24:/opt/restore_pg96/archived_wals +INFO: writing recovery settings to postgresql.auto.conf file +INFO: archiving is disabled +INFO: permissions set on $PGDATA +INFO: restore completed successfully +``` + +The following example shows the restored backup files in the restore path directory, `/opt/restore_pg96`: + +```text +-bash-4.1$ pwd +/opt/restore_pg96 +-bash-4.1$ ls -l +total 128 +drwxr-xr-x 2 postgres postgres 4096 Mar 29 14:27 archived_wals +-rw------- 1 postgres postgres 206 Mar 29 13:50 backup_label +drwx------ 5 postgres postgres 4096 Mar 29 12:25 base +drwx------ 2 postgres postgres 4096 Mar 29 14:27 global +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_clog +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_commit_ts +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_dynshmem +-rw------- 1 postgres postgres 4212 Mar 29 13:18 pg_hba.conf +-rw------- 1 postgres postgres 1636 Mar 29 12:25 pg_ident.conf +drwxr-xr-x 2 postgres postgres 4096 Mar 29 13:45 pg_log +drwx------ 4 postgres postgres 4096 Mar 29 12:25 pg_logical +drwx------ 4 postgres postgres 4096 Mar 29 12:25 pg_multixact +drwx------ 2 postgres postgres 4096 Mar 29 13:43 pg_notify +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_replslot +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_serial +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_snapshots +drwx------ 2 postgres postgres 4096 Mar 29 13:43 pg_stat +drwx------ 2 postgres postgres 4096 Mar 29 13:50 pg_stat_tmp +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_subtrans +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_tblspc +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_twophase +-rw------- 1 postgres postgres 4 Mar 29 12:25 PG_VERSION +drwx------ 3 postgres postgres 4096 Mar 29 14:27 pg_xlog +-rw------- 1 postgres postgres 169 Mar 29 13:24 postgresql.auto.conf +-rw-r--r-- 1 postgres postgres 21458 Mar 29 14:27 postgresql.conf +-rw-r--r-- 1 postgres postgres 118 Mar 29 14:27 postgresql.auto.conf +``` + +Copy the saved, unarchived WAL files to the restore path `pg_xlog` subdirectory (`/opt/restore_pg96/pg_xlog`): + +```text +-bash-4.1$ pwd +/opt/restore_pg96/pg_xlog +-bash-4.1$ ls -l +total 16388 +-rw------- 1 postgres postgres 16777216 Mar 29 13:50 +000000010000000000000002 +drwx------ 2 postgres postgres 4096 Mar 29 14:27 archive_status +-bash-4.1$ ls -l /tmp/unarchived_pg96_wals +total 32768 +-rw------- 1 postgres postgres 16777216 Mar 29 14:07 +000000010000000000000004 +-rw------- 1 postgres postgres 16777216 Mar 29 13:50 +000000010000000000000005 +-bash-4.1$ cp -p /tmp/unarchived_pg96_wals/* . +-bash-4.1$ ls -l +total 49156 +-rw------- 1 postgres postgres 16777216 Mar 29 13:50 +000000010000000000000002 +-rw------- 1 postgres postgres 16777216 Mar 29 14:07 +000000010000000000000004 +-rw------- 1 postgres postgres 16777216 Mar 29 13:50 +000000010000000000000005 +drwx------ 2 postgres postgres 4096 Mar 29 14:27 archive_status +``` + +Inspect the `/opt/restore_pg96/postgresql.auto.conf` file to verify that it contains the correct recovery settings: + +```text +restore_command = 'cp archived_wals/%f %p' +recovery_target_time = '2017-03-29 14:01:00' +recovery_target_timeline = 1 +``` + +Note that the command restores from the `archived_wals` subdirectory of `/opt/restore_pg96` since the `copy_wals_during_restore` parameter in the BART configuration file is set to `enabled` for database server `hr`. + +Start the database server to initiate the point-in-time recovery operation: + +```text +[user@localhost ~]$ su postgres +Password: +bash-4.1$ cd /opt/restore_pg96 +bash-4.1$ /opt/PostgreSQL/9.6/bin/pg_ctl start -D /opt/restore_pg96 -l +/opt/restore_pg96/pg_log/logfile +server starting +``` + +Inspect the database server log file to ensure the operation did not result in any errors: + +```text +2017-03-29 14:33:23 EDT LOG: database system was interrupted; last known +up at 2017-03-29 13:50:25 EDT +2017-03-29 14:33:23 EDT LOG: starting point-in-time recovery to +2017-03-29 14:01:00-04 +2017-03-29 14:33:23 EDT LOG: restored log file +"000000010000000000000002" from archive +2017-03-29 14:33:23 EDT LOG: redo starts at 0/2000098 +2017-03-29 14:33:23 EDT LOG: consistent recovery state reached at +0/20000C0 +2017-03-29 14:33:23 EDT LOG: restored log file +"000000010000000000000003" from archive +2017-03-29 14:33:23 EDT LOG: recovery stopping before commit of +transaction 1762, time 2017-03-29 14:02:28.100072-04 +2017-03-29 14:33:23 EDT LOG: redo done at 0/303F390 +2017-03-29 14:33:23 EDT LOG: last completed transaction was at log time +2017-03-29 14:00:43.351333-04 +cp: cannot stat `archived_wals/00000002.history': No such file or +directory +2017-03-29 14:33:23 EDT LOG: selected new timeline ID: 2 +cp: cannot stat `archived_wals/00000001.history': No such file or +directory +2017-03-29 14:33:23 EDT LOG: archive recovery complete +2017-03-29 14:33:23 EDT LOG: MultiXact member wraparound protections are +now enabled +2017-03-29 14:33:23 EDT LOG: database system is ready to accept +connections +2017-03-29 14:33:23 EDT LOG: autovacuum launcher started +``` + +The tables that exist in the recovered database cluster are: + +```text +postgres=# \dt + List of relations +Schema | Name | Type | Owner +--------+----------------+-------+---------- +public | hr_rmt_t1_1356 | table | postgres +public | hr_rmt_t1_1358 | table | postgres +public | hr_rmt_t1_1400 | table | postgres +(3 rows) +``` + +Since recovery was up to and including 2017-03-29 14:01:00, the following tables created after 14:01 are not present: + +```text +public | hr_rmt_t1_1402 | table | postgres +public | hr_rmt_t1_1404 | table | postgres +public | hr_rmt_t1_1406 | table | postgres +``` + +The BART `RESTORE` operation stops WAL archiving by adding an `archive_mode = off` parameter at the very end of the `postgresql.conf` file. This last parameter in the file overrides any other previous setting of the same parameter in the file. Delete the last setting and restart the database server to start WAL archiving. + +```text +# Add settings for extensions here +archive_mode = off +``` diff --git a/product_docs/docs/bart/2.6.2/bart_ref/images/EDB_logo.png b/product_docs/docs/bart/2.6.2/bart_ref/images/EDB_logo.png new file mode 100755 index 00000000000..39a54822d85 Binary files /dev/null and b/product_docs/docs/bart/2.6.2/bart_ref/images/EDB_logo.png differ diff --git a/product_docs/docs/bart/2.6.2/bart_ref/images/edb.png b/product_docs/docs/bart/2.6.2/bart_ref/images/edb.png new file mode 100755 index 00000000000..71e5bdde787 Binary files /dev/null and b/product_docs/docs/bart/2.6.2/bart_ref/images/edb.png differ diff --git a/product_docs/docs/bart/2.6.2/bart_ref/images/edb_logo.svg b/product_docs/docs/bart/2.6.2/bart_ref/images/edb_logo.svg new file mode 100755 index 00000000000..f24d1dfefee --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_ref/images/edb_logo.svg @@ -0,0 +1,19 @@ + + + edb-logo-disc-dark + + + + \ No newline at end of file diff --git a/product_docs/docs/bart/2.6.2/bart_ref/images/image2.png b/product_docs/docs/bart/2.6.2/bart_ref/images/image2.png new file mode 100755 index 00000000000..4eba2e7efa7 Binary files /dev/null and b/product_docs/docs/bart/2.6.2/bart_ref/images/image2.png differ diff --git a/product_docs/docs/bart/2.6.2/bart_ref/index.mdx b/product_docs/docs/bart/2.6.2/bart_ref/index.mdx new file mode 100644 index 00000000000..6a8817bd039 --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_ref/index.mdx @@ -0,0 +1,33 @@ +--- +navTitle: Reference Guide +title: "EDB Postgres Backup and Recovery Reference Guide" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/genindex.html" + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/conclusion.html" + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/index.html" +--- + +This guide acts as a quick reference for BART subcommands and provides comprehensive examples of the following BART operations: + +- Performing a full backup of database servers +- Performing a point-in-time recovery (PITR) on a remote PostgreSQL database server +- Restoring an incremental backup +- Restoring a database cluster with tablespaces +- Evaluating, marking, and deleting backups and incremental backups +- Configuring and operating local and remote database servers + +For detailed information about BART subcommands and operations, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/latest/bart_user/). + +The document is organized as follows: + +- See [Subcommands](01_bart_subcommands_examples/#using_bart_subcommands) to view BART subcommand examples. +- See [Examples](02_additional_examples/#examples) to view BART operations examples. +- See [Sample BART System](03_sample_bart_system_with_local_and_remote_database_servers/#a_sample_bart_system_with_local_and_remote_database_servers) to view examples of both local and remote database server configuration and operation. + +
+ +bart_subcommands_examples additional_examples sample_bart_system_with_local_and_remote_database_servers conclusion + +
diff --git a/product_docs/docs/bart/2.6.2/bart_user/01_introduction.mdx b/product_docs/docs/bart/2.6.2/bart_user/01_introduction.mdx new file mode 100644 index 00000000000..1212b2847bf --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_user/01_introduction.mdx @@ -0,0 +1,55 @@ +--- +title: "Introduction" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/introduction.html" +--- + +The EDB Backup and Recovery Tool (BART) is an administrative utility that provides simplified backup and recovery management for multiple local or remote EDB Advanced Server and PostgreSQL database servers. + +BART provides the following features: + +- Support for complete, hot, physical backups of multiple Advanced Servers and PostgreSQL database servers +- Support for two types of backups – full base backups and block-level incremental backups +- Backup and recovery management of database servers on local or remote hosts +- A single, centralized catalog for backup data +- Retention policy support for defining and managing how long backups should be kept +- The capability to store the backup data in compressed format +- Verified backup data with checksums +- Backup information displayed in an easy-to-read format +- A simplified point-in-time recovery process + +This guide provides the following information about using BART: + +- an [overview](02_overview/#overview) of the BART components and concepts. +- [backup and recovery management process](03_using_bart/#using_bart). +- [using tablespaces](04_using_tablespaces/#using_tablespaces). + +For information about installing BART, see the *EDB Backup and Recovery Installation and Upgrade Guide*; for examples of BART operations and subcommand usage, see the *EDB Backup and Recovery Reference Guide*. These guides are available at the [EDB website](/bart/latest/bart_inst/). + + + +## Conventions Used in this Guide + +The following is a list of conventions used throughout this document. + +- Much of the information in this document applies interchangeably to the PostgreSQL and EDB Advanced Server database systems. The term *Advanced Server* is used to refer to EDB Advanced Server. The term *Postgres* is used to generically refer to both PostgreSQL and Advanced Server. When a distinction needs to be made between these two database systems, the specific names, PostgreSQL or Advanced Server are used. + +- The installation directory of the PostgreSQL or Advanced Server products is referred to as `POSTGRES_INSTALL_HOME`: + + - For PostgreSQL Linux installations, this defaults to `/opt/PostgreSQL/` for version 10 and earlier. For later versions, the installation directory is `/var/lib/pgsql/`. + - For Advanced Server Linux installations performed using the interactive installer for version 10 and earlier, this defaults to `/opt/PostgresPlus/AS` or `/opt/edb/as`. For Advanced Server Linux installations performed with an RPM package, this defaults to `/usr/ppas-` or `/usr/edb/as`. For Advanced Server Linux installations performed with an RPM package for version 11 or later, this defaults to `/usr/edb/as`. + +## Restrictions on pg_basebackup + +BART takes full backups using the `pg_basebackup` utility program under the following conditions: + +- The backup is taken on a standby server. +- The `--with-pg_basebackup` option is specified with the `BACKUP` subcommand (see [Backup](03_using_bart/03_basic_bart_subcommand_usage/03_backup/#backup)). +- The number of thread count in effect is 1, and the `with-pg_basebackup` option is not specified with the `BACKUP` subcommand. +- Database servers can only be backed up using `pg_basebackup` utility program of the same or later version than the database server version. + +In the global section of the BART configuration file, the `pg_basebackup_path` parameter specifies the complete directory path to the `pg_basebackup` program. For information about the `pg_basebackup_path` parameter and the `thread_count`, see the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/latest/bart_inst/). + +For information about `pg_basebackup`, see the [PostgreSQL Core Documentation](https://postgresql.org/docs/current/static/app-pgbasebackup.html). diff --git a/product_docs/docs/bart/2.6.2/bart_user/02_overview/01_block-level_incremental_backup/01_incremental_backup_limitations_and_requirements.mdx b/product_docs/docs/bart/2.6.2/bart_user/02_overview/01_block-level_incremental_backup/01_incremental_backup_limitations_and_requirements.mdx new file mode 100644 index 00000000000..a3fe8894d09 --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_user/02_overview/01_block-level_incremental_backup/01_incremental_backup_limitations_and_requirements.mdx @@ -0,0 +1,42 @@ +--- +title: "Incremental Backup Limitations and Requirements" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/incremental_backup_limitations_and_requirements.html" +--- + + + +The following limitations apply to incremental backup: + +- If you have restored a full or incremental backup, you must take a full backup before enabling incremental backup. +- If a standby node has been promoted to the role of a primary node, you must take a full backup before enabling incremental backup on the cluster. +- On a standby database server, you cannot take an incremental backup. + +You must meet the following requirements before implementing incremental backup: + +- You must create or select an operating system account to be used as the BART user account. + +- You must create or select the replication database user, which must be a superuser. + +- In the BART configuration file: + + - You must set the `cluster_owner` parameter to the Linux operating system user account that owns the database cluster directory from which incremental backups are to be taken. + - You must enable the `allow_incremental_backups` parameter. + +- A passwordless SSH/SCP connection must be established between the BART user account on the BART host and the `cluster_owner` user account on the database server. + + It must be noted that a passwordless SSH/SCP connection must be established even if BART and the database server are running on the same host and the BART user account and the `cluster_owner` user account are the same account. + +- In addition to the BART host (where the BART backup catalog resides), the BART package must also be installed on every remote database server on which incremental backups are to be restored. To restore an incremental backup, the `bart` program must be executable on the remote host by the remote user (the remote user is specified by the `remote_host` parameter in the BART configuration file or by the `-r` option when using the `RESTORE` subcommand to restore the incremental backup). + +- When [restoring incremental backups on a remote database server](05_restoring_an_incremental_backup/#restoring-an-incremental-backup-on-a-remote-host), a passwordless SSH/SCP connection must be established from the BART user account on the BART host to the remote user on the remote host (the remote user is specified by the `remote_host` parameter in the BART configuration file or by the `-r` option when using the `RESTORE` subcommand to restore the incremental backup). + +- Compression of archived WAL files in the BART backup catalog is not permitted for database servers on which incremental backups are to be taken. The `wal_compression` setting in the BART configuration file must be disabled for those database servers. + +- The incremental backup must be on the same timeline as the parent backup. The timeline changes after each recovery operation so an incremental backup cannot use a parent backup from an earlier timeline. + +For information about configuring these requirements, see the EDB Backup and Recovery Installation and Upgrade Guide available at the [EDB website](/bart/latest/bart_inst/). + +The following section provides an overview of the basic incremental backup concepts. diff --git a/product_docs/docs/bart/2.6.2/bart_user/02_overview/01_block-level_incremental_backup/02_concept_overview.mdx b/product_docs/docs/bart/2.6.2/bart_user/02_overview/01_block-level_incremental_backup/02_concept_overview.mdx new file mode 100644 index 00000000000..8183d4802bd --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_user/02_overview/01_block-level_incremental_backup/02_concept_overview.mdx @@ -0,0 +1,33 @@ +--- +title: "Concept Overview" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/concept_overview.html" +--- + + + +Using incremental backups involves the following sequence of steps: + +1. Configure BART, and enable and initiate archiving of WAL files to the `archive_path` in the same manner as done for full backups. + + The default `archive_path` is the BART backup catalog (`//archived_wals`). Using the `` parameter in the server section of the BART configuration file, you can specify the location where WAL files will be archived. + + For more information about the `archive_path` parameter and configuring BART, see the EDB Backup and Recovery Installation and Upgrade Guide available at the [EDB website](/bart/latest/bart_inst/). + +2. Take an initial full backup with the `BACKUP` subcommand. This full backup establishes the parent of the first incremental backup. + +3. Scan all WAL files produced by database servers on which incremental backups are to be taken. These WAL files are scanned once they have been archived to the `archive_path`. + + Each scanned WAL file results in a modified block map (MBM) file that records the location of modified blocks obtained from the corresponding WAL file. The BART WAL scanner program `bart-scanner` performs this process. + +4. Take incremental backups using the `BACKUP` subcommand with the `--parent` option to specify the backup identifier or name of a previous, full backup or an incremental backup. Any previous backup may be chosen as the parent as long as all backups belong to the same timeline. + +5. The incremental backup process identifies which WAL files may contain changes from when the parent backup was taken to the starting point of the incremental backup. The corresponding MBM files are used to locate and copy the modified blocks to the incremental backup directory along with other database cluster directories and files. Instead of backing up all, full relation files, only the modified blocks are copied and saved. In addition, the relevant MBM files are condensed into one consolidated block map (CBM) file that is stored with the incremental backup. + + Multiple block copier threads can be used to copy the modified blocks to the incremental backup directory. See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/latest/bart_inst/) for information about setting the `thread_count` parameter in the BART configuration file. See [Backup](../../03_using_bart/03_basic_bart_subcommand_usage/03_backup/#backup) for information about using the `--thread-count` option with the `BACKUP` subcommand. + +6. Invoke the restore process for an incremental backup using the `RESTORE` subcommand in the same manner as restoring a full backup. The `-i` option specifies the backup identifier or name of the incremental backup to restore. The restore process begins by going back through the chain of past, parent incremental backups until the initial full backup starting the chain is identified. This full backup provides the initial set of directories and files to be restored to the location specified with the `-p` option. Each subsequent incremental backup in the chain is then restored. Restoration of an incremental backup uses its CBM file to restore the modified blocks from the incremental backup. + +The following sections provide some additional information on these procedures. diff --git a/product_docs/docs/bart/2.6.2/bart_user/02_overview/01_block-level_incremental_backup/03_wal_scanning_preparation_for_an_incremental_backup.mdx b/product_docs/docs/bart/2.6.2/bart_user/02_overview/01_block-level_incremental_backup/03_wal_scanning_preparation_for_an_incremental_backup.mdx new file mode 100644 index 00000000000..5264499e13e --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_user/02_overview/01_block-level_incremental_backup/03_wal_scanning_preparation_for_an_incremental_backup.mdx @@ -0,0 +1,54 @@ +--- +title: "WAL Scanning – Preparation for an Incremental Backup" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/wal_scanning_preparation_for_an_incremental_backup.html" +--- + + + +The WAL scanner program (`bart-scanner`) scans the WAL files created from the time of the parent backup up to the start of the incremental backup to determine which blocks have modified since the parent backup, and records the information in a file called the *modified block map (MBM) file*. One MBM file is created for each WAL file. + +The MBM file is stored in the directory where archived_wals will be stored, as specified in the `archive_path` parameter in the `bart.cfg` file. If the `archive_path` is not specified, the default `archived_wals` directory is: + +`//` + +Where: + +`` is the BART backup catalog parent directory specified in the global section of the BART configuration file. + +`` is the lowercase conversion of the database server name specified in the server section of the BART configuration file. + +The following code snippet is the content of the archive path showing the MBM files created for the WAL files. (The user name and group name of the files have been removed from the example to list the WAL files and MBM files in a more comparable manner): + +```text +[root@localhost archived_wals]# pwd +/opt/backup/acctg/archived_wals +[root@localhost archived_wals]# ls -l +total 131104 +-rw------- 1 ... ... 16777216 Oct 12 09:38 000000010000000100000078 +-rw------- 1 ... ... 16777216 Oct 12 09:38 000000010000000100000079 +-rw------- 1 ... ... 16777216 Oct 12 09:38 00000001000000010000007A +-rw------- 1 ... ... 16777216 Oct 12 09:35 00000001000000010000007B +-rw------- 1 ... ... 16777216 Oct 12 09:38 00000001000000010000007C +-rw------- 1 ... ... 16777216 Oct 12 09:39 00000001000000010000007D +-rw------- 1 ... ... 16777216 Oct 12 09:42 00000001000000010000007E +-rw------- 1 ... ... 16777216 Oct 12 09:47 00000001000000010000007F +-rw-rw-r-- 1 ... ... 161 Oct 12 09:49 0000000100000001780000280000000179000000.mbm +-rw-rw-r-- 1 ... ... 684 Oct 12 09:49 000000010000000179000028000000017A000000.mbm +-rw-rw-r-- 1 ... ... 161 Oct 12 09:49 00000001000000017A000028000000017B000000.mbm +-rw-rw-r-- 1 ... ... 161 Oct 12 09:49 00000001000000017B000028000000017C000000.mbm +-rw-rw-r-- 1 ... ...1524 Oct 12 09:49 00000001000000017C000028000000017D000000.mbm +-rw-rw-r-- 1 ... ... 161 Oct 12 09:49 00000001000000017D000028000000017E000000.mbm +-rw-rw-r-- 1 ... ... 161 Oct 12 09:49 00000001000000017E000028000000017F000000.mbm +-rw-rw-r-- 1 ... ... 161 Oct 12 09:49 00000001000000017F0000280000000180000000.mbm +``` + +MBM files have the suffix, `.mbm`. + +In preparation for any incremental backup, the WAL files should be scanned as soon as they are copied to the `archive_path`. Thus, the WAL scanner should be running as soon as the WAL files from the database cluster are archived to the `archive_path`. If the `archive_path` contains WAL files that have not yet been scanned, starting the WAL scanner begins scanning these files. If WAL file fails to be scanned (resulting in a missing MBM file), you can use the WAL scanner to specify an individual WAL file. + +Under certain conditions such as when the Network File System (NFS) is used to copy WAL files to the `archive_path`, the WAL files may have been missed by the WAL scanner program for scanning and creation of MBM files. Use the `scan_interval` parameter in the BART configuration file to initiate force scanning of WAL files in the `archive_path` to ensure MBM files are generated. See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/latest/bart_inst/) for more information about the `scan_interval` parameter. + +See [Running the BART WAL Scanner](../../03_using_bart/04_running_the_bart_wal_scanner/#running_the_bart_wal_scanner) for information about using the WAL scanner. diff --git a/product_docs/docs/bart/2.6.2/bart_user/02_overview/01_block-level_incremental_backup/04_performing_an_incremental_backup.mdx b/product_docs/docs/bart/2.6.2/bart_user/02_overview/01_block-level_incremental_backup/04_performing_an_incremental_backup.mdx new file mode 100644 index 00000000000..8198f0f6400 --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_user/02_overview/01_block-level_incremental_backup/04_performing_an_incremental_backup.mdx @@ -0,0 +1,78 @@ +--- +title: "Performing an Incremental Backup" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/performing_an_incremental_backup.html" +--- + + + +The WAL files produced at the time of the parent backup up to the start of the incremental backup contain information about which blocks were modified during that time interval. That information is consolidated into an MBM file for each WAL file by the WAL scanner. + +The MBM files for the relevant WAL files are read, and the information is used to copy the modified blocks from the database cluster to the `archived_wals` directory as specified in the `archive_path` parameter in the `bart.cfg` file. When compared to a full backup, the number and sizes of relation files can be significantly less for an incremental backup. + +For comparison, the following is an abbreviated list of the files copied to the archived `base` subdirectory of a full backup for one database: + +```text +[root@localhost 14845]# pwd +/opt/backup/acctg/1476301238969/base/base/14845 +[root@localhost 14845]# ls +112 13182_vm 14740 16467 16615 2608_vm 2655 2699 2995 ... +113 13184 14742 16471 174 2609 2656 2701 2995_vm ... +1247 13186 14745 16473 175 2609_fsm 2657 2702 2996 ... +1247_fsm 13187 14747 16474 2187 2609_vm 2658 2703 2998 ... +1247_vm 13187_fsm 14748 16476 2328 2610 2659 2704 2998_vm ... +1249 13187_vm 14749 16477 2328_fsm 2610_fsm 2660 2753 2999 ... +1249_fsm 13189 14752 16479 2328_vm 2610_vm 2661 2753_fsm 2999_vm ... +1249_vm 13191 14754 16488 2336 2611 2662 2753_vm 3079 ... +1255 13192 14755 16490 2336_vm 2611_vm 2663 2754 3079_fsm ... + . + . + . +13182_fsm 14739 16465 16603 2608_fsm 2654 2696 2893_vm 3501_vm ... +``` + +In contrast, the following is the content of the archived `base` subdirectory of the same database from a subsequent incremental backup: + +```text +[root@localhost 14845]# pwd +/opt/backup/acctg/1476301835391/base/base/14845 +[root@localhost 14845]# ls +1247 1249 1259 16384 17006 2608 2610 2658 2663 2678 ... +1247_fsm 1249_fsm 1259_fsm 16387 17009 2608_fsm 2610_fsm 2659 2673 2679 ... +1247_vm 1249_vm 1259_vm 16389 17011 2608_vm 2610_vm 2662 2674 2703 ... +``` + +The information from the MBM files are consolidated into one file called a *consolidated block map* (CBM) file. During the restore operation for the incremental backup, the CBM file is used to identify the modified blocks to be restored for that backup. In addition, the incremental backup also stores other required subdirectories and files from the database cluster as is done for full backups. + +Before taking an incremental backup, an initial full backup must be taken with the `BACKUP` subcommand. This full backup establishes the parent of the first incremental backup. + +The syntax for taking a full backup is: + +```text +bart BACKUP –s { | all } [ -F { p | t } ] + [ -z ] [ –c ] + [ --backup-name ] + [ --thread-count ] + [ { --with-pg_basebackup | --no-pg_basebackup } ] + [--checksum-algorithm ] +``` + +The syntax for taking an incremental backup is: + +```text +bart BACKUP –s { | all } [ -F p] + [ --parent { | } ] + [ --backup-name ] + [ --thread-count ] + [ --check ] + [--checksum-algorithm ] +``` + +You must specify the following before taking an incremental backup: + +- `-Fp` option for plain text format as incremental backup can only be taken in the plain text format. +- `--check` option to verify if the required MBM files are present in the `archived_wals` directory. The `--parent` option must be specified when the `--check` option is used. + +See [BACKUP](../../03_using_bart/03_basic_bart_subcommand_usage/03_backup/#backup) for more information about using the `BACKUP` subcommand. diff --git a/product_docs/docs/bart/2.6.2/bart_user/02_overview/01_block-level_incremental_backup/05_restoring_an_incremental_backup.mdx b/product_docs/docs/bart/2.6.2/bart_user/02_overview/01_block-level_incremental_backup/05_restoring_an_incremental_backup.mdx new file mode 100644 index 00000000000..b3dcf583e31 --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_user/02_overview/01_block-level_incremental_backup/05_restoring_an_incremental_backup.mdx @@ -0,0 +1,48 @@ +--- +title: "Restoring an Incremental Backup" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/restoring_an_incremental_backup.html" +--- + + + +Restoring an incremental backup may require additional steps depending upon the host on which the incremental backup is to be restored: + +- [Restoring an Incremental Backup on a BART Host](#restoring-an-incremental-backup-on-a-bart-host) - This section outlines restoring an incremental backup onto the same host where BART has been installed. +- [Restoring an Incremental Backup on a Remote Host](#restoring-an-incremental-backup-on-a-remote-host) - This section outlines restoring an incremental backup onto a remote host where BART has not been installed. + + + +## Restoring an Incremental Backup on a BART Host + +Specify a backup identifier or name, and include the `-i` option when invoking the `RESTORE` subcommand to restore an incremental backup. All `RESTORE` options may be used in the same manner as when restoring a full backup. See [RESTORE](../../03_using_bart/03_basic_bart_subcommand_usage/08_restore/#restore) command for more details. + +First, all files from the full backup from the beginning of the backup chain are restored. For each incremental backup, the CBM file is used to identify and restore blocks from the incremental backup. If there are new relations or databases identified in the CBM file, then relevant relation files are copied. If consolidated block map information is found indicating the drop of a relation or a database, then the relevant files are removed from the restore directory. Similarly, if there is any indication of a table truncation, then the related files are truncated. + +Also note that you can use the `-w` option of the `RESTORE` subcommand to specify a multiple number of parallel worker processes to stream the modified blocks to the restore host. + +!!! Note + If you set the [BART scanner](../../03_using_bart/04_running_the_bart_wal_scanner/#running_the_bart_wal_scanner) or [backup](../../03_using_bart/03_basic_bart_subcommand_usage/03_backup/#backup) with the `--checksum-algorithm=NONE` option, then you must specify the `--disable checksum` option while restoring an incremental backup. + + + +## Restoring an Incremental Backup on a Remote Host + +Ensure the `bart` program is available on the remote host when restoring an incremental backup on a remote host; the invocation of the `RESTORE` subcommand for an incremental backup results in the execution of the `bart` program on the remote host to restore the modified blocks to their proper location. + +To restore an incremental backup onto a remote host where BART has not been installed, perform the following steps: + +**Step 1:** Install `BART` on the remote host to which an incremental backup is to be restored. + +No editing is needed in the `bart.cfg` file installed on the remote host. + +**Step 2:** Determine the Linux operating system user account on the remote host to be used as the remote user. This user is specified by the `remote_host` parameter in the BART configuration file or by the `-r` option when using the `RESTORE` subcommand to restore the incremental backup. The remote user must be the owner of the directory where the incremental backup is to be restored on the remote host. By default, the user account is `enterprisedb` for Advanced Server or `postgres` for PostgreSQL. + +**Step 3:** Ensure a passwordless SSH/SCP connection is established from the BART user on the BART host to the remote user on the remote host. For information about creating a passwordless SSH/SCP connection, see the *EDB Backup and Recovery Installation and Upgrade Guide*, available at the [EDB website](/bart/latest/bart_inst/). + +When restoring an incremental backup, specify the backup identifier or name of the incremental backup that will be restored. See the [RESTORE](../../03_using_bart/03_basic_bart_subcommand_usage/08_restore/#restore) documentation for more details. To view an example of restoring an incremental backup, see the *EDB Backup and Recovery Reference Guide* available at the [EDB website](/bart/latest/bart_ref/). + +!!! Note + If you set the [BART scanner](../../03_using_bart/04_running_the_bart_wal_scanner/#running_the_bart_wal_scanner) or [backup](../../03_using_bart/03_basic_bart_subcommand_usage/03_backup/#backup) with the `--checksum-algorithm=NONE` option, then you must specify the `--disable checksum` option while restoring an incremental backup. diff --git a/product_docs/docs/bart/2.6.2/bart_user/02_overview/01_block-level_incremental_backup/index.mdx b/product_docs/docs/bart/2.6.2/bart_user/02_overview/01_block-level_incremental_backup/index.mdx new file mode 100644 index 00000000000..3e65e3b0056 --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_user/02_overview/01_block-level_incremental_backup/index.mdx @@ -0,0 +1,24 @@ +--- +title: "Block-Level Incremental Backup" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/block-level_incremental_backup.html" +--- + + + +This section describes the basic concepts of a block-level incremental backup (referred to as an incremental backup). An incremental backup is a unique functionality of BART. + +An incremental backup provides a number of advantages when compared to using a full backup: + +- The amount of time required to produce an incremental backup is generally less than a full backup, as modified relation blocks are saved instead of all full relation files of the database cluster. +- An incremental backup uses less disk space than a full backup. + +Generally, all BART features (such as retention policy management) apply to incremental backups and full backups. See [Managing Incremental Backups](../../03_using_bart/02_managing_backups_using_a_retention_policy/05_managing_incremental_backups/#managing_incremental_backups) for more information. + +
+ +incremental_backup_limitations_and_requirements concept_overview wal_scanning_preparation_for_an_incremental_backup performing_an_incremental_backup restoring_an_incremental_backup + +
diff --git a/product_docs/docs/bart/2.6.2/bart_user/02_overview/02_creating_a_backup_chain.mdx b/product_docs/docs/bart/2.6.2/bart_user/02_overview/02_creating_a_backup_chain.mdx new file mode 100644 index 00000000000..644040d87f1 --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_user/02_overview/02_creating_a_backup_chain.mdx @@ -0,0 +1,22 @@ +--- +title: "Creating a Backup Chain" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/creating_a_backup_chain.html" +--- + + + +A *backup chain* is the set of backups consisting of a full backup and all of its successive incremental backups. Tracing back on the parent backups of all incremental backups in the chain eventually leads back to that single, full backup. + +It is possible to have a *multi-forked* backup chain, which is two or more successive lines of incremental backups, all of which begin with the same, full backup. Thus, within the chain there is a backup that serves as the parent of more than one incremental backup. + +Since restoration of an incremental backup is dependent upon first restoring the full backup, then all successive incremental backups up to, and including the incremental backup specified by the `RESTORE` subcommand, it is crucial to note the following: + +- Deletion or corruption of the full backup destroys the entire backup chain. It is not possible to restore any of the incremental backups that were part of that chain. +- Deletion or corruption of an incremental backup within the chain results in the inability to restore any incremental backup that was added to that successive line of backups following the deleted or corrupted backup. The full backup and incremental backups prior to the deleted or corrupted backup can still be restored. + +The actions of retention policy management are applied to the full backup and all of its successive incremental backups within the chain in an identical manner as if they were one backup. Thus, use of retention policy management does not result in the breakup of a backup chain. + +See the *EDB Backup and Recovery Reference Guide*, available at the [EDB website](/bart/latest/bart_ref/) for examples of creating a backup chain and restoring an incremental backup. diff --git a/product_docs/docs/bart/2.6.2/bart_user/02_overview/index.mdx b/product_docs/docs/bart/2.6.2/bart_user/02_overview/index.mdx new file mode 100644 index 00000000000..7b5b7e92fb3 --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_user/02_overview/index.mdx @@ -0,0 +1,97 @@ +--- +title: "Overview" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/overview.html" +--- + + + +BART provides a simplified interface for the continuous archiving and point-in-time recovery method provided with Postgres database servers. This consists of the following processes: + +- Capturing a complete image of a database cluster as a full base backup or referred to simply as a *full backup*. +- Capturing a modified image of a database cluster called a *block-level incremental backup* or referred as *incremental backup*, which is similar to a full backup, but contains the modified blocks of the relation files that have been changed since a previous backup. +- Archiving the `Write-Ahead Log segments` (WAL files), which continuously record changes to be made to the database files. +- Performing *Point-In-Time Recovery* (PITR) to a specified transaction ID or timestamp with respect to a timeline using a full backup along with successive, [block-level incremental backups](01_block-level_incremental_backup/#block-level_incremental_backup) that reside in the same backup chain, and the WAL files. + +Detailed information regarding WAL files and point-in-time recovery is documented in the [PostgreSQL Core Documentation](https://www.postgresql.org/docs/current/static/continuous-archiving.html). + +The general term *backup* refers to both full backups and incremental backups. + +When taking a full backup of a standby server, BART uses the PostgreSQL `pg_basebackup` utility program. However, it must be noted that for standby servers, you can only take a full backup, but cannot take an incremental or parallel backups. For information about standby servers, see the [PostgreSQL Documentation](https://www.postgresql.org/docs/current/static/high-availability.html). + +BART uses a centralized backup catalog, a single configuration file, and a command line interface controlling the necessary operations to simplify the management process. Reasonable defaults are automatically used for various backup and restore options. BART also performs the necessary recovery file configuration required for point-in-time recovery using its command line interface. + +BART also provides the following features to enhance backup management: + +- Automation of the WAL archiving command configuration. +- Usage of retention policies to evaluate, categorize, and delete obsolete backups. +- Compression of WAL files to conserve disk space. +- Customizable naming of backups to ease their usage. +- Easy access to comprehensive information about each backup. + +The key components of a BART installation are: + +- **BART Host.** The host system on which BART is installed. BART operations are invoked from this host system. The database server backups and archived WAL files are stored on this host as well. +- **BART User Account.** Linux operating system user account you choose to run BART. The BART user account owns the BART backup catalog directory. +- **BART Configuration File.** File in editable text format containing the configuration information that BART uses. +- **BART Backup Catalog.** File system directory structure containing all of the backups for the database servers that BART manages. It is also the default `archive_path` to store archived WAL files. +- **BART Backupinfo File.** File in text format containing information for a BART backup. A `backupinfo` file resides in each backup subdirectory within the BART backup catalog. +- **BART Command Line Utility Program.** Single, executable file named `bart`, which is used to manage all BART operations. +- **BART WAL Scanner Program.** Single, executable file named `bart-scanner`, which is used to scan WAL files to locate and record the modified blocks for incremental backups. + +Other concepts and terms referred to in this document include the following: + +- **Postgres Database Cluster.** Also commonly called the *data directory*, this is the file system directory where all of the data files related to a particular Postgres database server instance are stored. (Each specific running instance is identified by its host and port number when connecting to a database.) The database cluster is identified by the `–D` option when it is created, started, stopped, etc. by the `Postgres initdb` and `pg_ctl` commands. A full backup is a copy of a database cluster. + + The terms database cluster and database server are used somewhat interchangeably throughout this document, though a single database server can run multiple database clusters. + +- **Postgres User Account.** Linux operating system user account that runs the Advanced Server or PostgreSQL database server and owns the database cluster directory. + + - By default, the database user account is `enterprisedb` when Advanced Server is installed to support compatibility with Oracle databases. + + - By default, the database user account is `postgres` when Advanced Server is installed in PostgreSQL compatible mode. For a PostgreSQL database server, the default database user account is also `postgres`. + + The BART configuration parameter `cluster_owner` must be set to the database user account for each database server. + +- **Replication Database User.** For each database server that BART manages, a database superuser must be selected to act as the replication database user. This database user is used to connect to the database server when backups are taken. The database superusers created with an initial Postgres database server installation (`enterprisedb` or `postgres`) may be used for this purpose. The BART configuration parameter `user` must be set to this replication database user for each database server. + +- **Secure Shell (SSH)/Secure Copy (SCP).** Linux utility programs used to log into hosts (SSH) and copy files (SCP) between hosts. A valid user account must be specified that exists on the target host and in fact is the user account under which the SSH or SCP operations occur. + +For information on how all of these components are configured and used with BART, see the EDB Backup and Recovery Installation and Upgrade Guide available at the [EDB website](/bart/latest/bart_inst/). + +**Supported BART Operations** + +The following tables are not a conclusive list of the scenarios supported by BART, but instead provides an overview of some of the most common scenarios in both `pg_basebackup` (thread count=1) as well as parallel backup mode (thread count greater than 1). + +| | -Fp-xlog-method=fetch | -Fp-xlog-method=stream | -Ft-xlog-method=fetch | -Ft-xlog-method=stream | +| -------------------------------------------- | --------------------- | ---------------------- | --------------------- | ---------------------- | +| `Primary Database Server/Full backup` | Supported | Supported | Supported | Supported | +| `Primary Database Server/Incremental backup` | Supported | Supported | Not Supported | Not Supported | +| `Standby Database Server/Full backup` | Supported | Supported | Supported | Supported | +| `Standby Database Server/Incremental backup` | Not Supported | Not Supported | Not Supported | Not Supported | + +Backup + +| | Wal compression by BART | WAL scanner | +| -------------------------------------------- | ----------------------- | ----------- | +| `Primary Database Server/Full backup` | Supported | N/A | +| `Primary Database Server/Incremental backup` | Not Supported | N/A | +| `Standby Database Server/Full backup` | Supported | N/A | +| `Standby Database Server/Incremental backup` | Not Supported | N/A | + +Wal Archiving + +| | Wal compression = enabled | Wal compression = disabled | +| ------------------ | ------------------------- | -------------------------- | +| `Restore` | Supported | Supported | +| `Parallel restore` | Supported | Supported | + +Restore + +
+ +block-level_incremental_backup creating_a_backup_chain + +
diff --git a/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/01_bart_management_overview/01_performing_a_restore_operation.mdx b/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/01_bart_management_overview/01_performing_a_restore_operation.mdx new file mode 100644 index 00000000000..06edb0b5afb --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/01_bart_management_overview/01_performing_a_restore_operation.mdx @@ -0,0 +1,60 @@ +--- +title: "Performing a Restore Operation" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/performing_a_restore_operation.html" +--- + + + +The following steps describe the process of restoring a backup: + +**Step 1:** Use your system-specific command to shut down the database server. + +**Step 2:** Inspect the `pg_wal` subdirectory (inspect the `pg_xlog` subdirectory if you are using server 9.6 version) of the data directory and save any WAL files that have not yet been archived to the `archive_path`. If there are files that have not been archived, save them to a temporary location. + +**Step 3:** If you want to restore to current data directory, it is recommended to make a copy of the current data directory and then delete all files and subdirectories under the data directory if you have enough extra space. If there is not enough space, then make a copy of `pg_wal` directory (or `pg_xlog` if you are using server 9.6 version) until the server is successfully restored. + +If you want to restore to a new, empty directory, create the directory on which you want to restore the backed up database cluster. Ensure the data directory can be written to by the BART user account or by the user account specified by the `remote_host` configuration parameter, or by the `--remote-host` option of the `RESTORE` subcommand (if these are to be used). + +**Step 4:** Perform the same process for tablespaces as described in Step 3. The `tablespace_path` parameter in the BART configuration file must contain the tablespace directory paths to which the tablespace data files are to be restored. See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/latest/bart_inst/) for more information about this parameter. + +**Step 5:** Identify the backup to use for the restore operation and obtain the backup ID or backup name. + +To use the latest backup, omit the `-i` option; the `RESTORE` subcommand uses that backup by default. The backups can be listed with the `SHOW-BACKUPS` subcommand. + +**Step 6:** Run the BART `RESTORE` subcommand. + +- Minimal recovery settings will be saved in the `postgresql.auto.conf` file and archive recovery will proceed only until consistency is reached, with no restoration of files from the archive. See [Restore](../03_basic_bart_subcommand_usage/08_restore/#restore) for detailed information about `Restore` subcommand. + +- If the `-c` option is specified or if the `copy_wals_during_restore` BART configuration parameter is enabled for this database server, then the following actions occur: + + - In addition to restoring the database cluster to the directory specified by the `-p restore_path` option, the archived WAL files of the backup are copied from the BART backup catalog to the subdirectory `restore_path/archived_wals`. + - If recovery settings are saved in the `postgresql.auto.conf` file, the command string set in the `restore_command` parameter retrieves the WAL files from this `archived_wals` subdirectory relative to the `restore_path` parent directory as: `restore_command = cp archived_wals/%f %p` + +You must ensure that valid options are specified when using the `RESTORE` subcommand. BART will not generate an error message if invalid option values or invalid option combinations are provided. BART will accept the invalid options and pass them to the `postgresql.auto.conf` file, which will then be processed by the database server when it is restarted. + +**Step 7:** Copy any saved WAL files from Step 2 to the `restore_path/pg_xlog` subdirectory. + +**Step 8:** Inspect the restored directories and data files of the restored database cluster in directory `restore_path`. + +All files and directories must be owned by the user account that you intend to use to start the database server. Recursively change the user and group ownership of the `restore_path` directory, its files, and its subdirectories if necessary. There must only be directory access privileges for the user account that will start the database server. No other groups or users can have access to the directory. + +**Step 9:** The `postgresql.auto.conf` file should be configured to recover only until the cluster reaches consistency. In either case, the settings may be modified as desired. + +**Step 10:** Disable WAL archiving at this point. The BART `RESTORE` subcommand adds `archive_mode = off` to the end of the `postgresql.conf` file. + +- If you want to restart the database server with WAL archiving enabled, ensure that this additional parameter is deleted. +- The original `archive_mode` parameter still resides in the `postgresql.conf` file in its initial location with its last setting. + +**Step 11:** Start the database server to initiate recovery. After completion, check the database server log file to ensure the recovery was successful. + +If the backup is restored to a different location than where the original database cluster resided, operations dependent upon the database cluster location may fail if supporting service scripts are not updated to reflect the location where the backup has been restored. For information about the use and modification of service scripts, see the EDB Advanced Server Installation Guide available at the [EDB website](/epas/latest/). + +See [Restore](../03_basic_bart_subcommand_usage/08_restore/#restore) for more information about using the BART `Restore` subcommand. + +An example of a restore operation is documented in the EDB Backup and Recovery Reference Guide available at the [EDB website](/bart/latest/bart_ref/). + +!!! Note + If you set the [backup](../03_basic_bart_subcommand_usage/03_backup/#backup) `--checksum-algorithm=NONE` option, then you must specify the `--disable checksum` option while restoring a backup. diff --git a/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/01_bart_management_overview/02_point_in_time_recovery_operation.mdx b/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/01_bart_management_overview/02_point_in_time_recovery_operation.mdx new file mode 100644 index 00000000000..5d85c80281b --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/01_bart_management_overview/02_point_in_time_recovery_operation.mdx @@ -0,0 +1,51 @@ +--- +title: "Point-In-Time Recovery Operation" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/point_in_time_recovery_operation.html" +--- + + + +The following steps outline how to perform a point-in-time recovery operation for a database cluster: + +1. Use your system-specific command to shut down the database server. + +2. If you want to: + a. restore the database cluster and tablespace files to new, empty directories, create the new directories with the appropriate directory ownership and permissions. + b. reuse the existing database cluster directories, delete all the files and subdirectories in the existing directories. We strongly recommend that you make a copy of this data before deleting it. Be sure to save any recent WAL files in the `pg_wal` subdirectory ( `pg_xlog` subdirectory if you are using server 9.6 version) that have not been archived to `archive_path`. + +3. Run the BART `SHOW-BACKUPS -s ` subcommand to list the backup IDs and backup names of the backups for the database server. You will need to provide the appropriate backup ID or backup name with the BART `RESTORE` subcommand, unless you intend to restore the latest backup in which case the `-i` option of the `RESTORE` subcommand for specifying the backup ID or backup name may be omitted. + +4. Run the BART `RESTORE` subcommand with the appropriate options. + + - The backup is restored to the directory specified by the `-p restore_path` option. + + - In addition, if the `RESTORE` subcommand `-c` option is specified or if the enabled setting of the `copy_wals_during_restore` BART configuration parameter is applicable to the database server, then the required archived WAL files from the `archive_path` are copied to the `restore_path/archived_wals` subdirectory. + + - Ensure the `restore_path` directory and all subdirectories and files in the `restore_path` are owned by the proper Postgres user account (for example, `enterprisedb` or `postgres`). Also ensure that only the Postgres user account has access permission to the `restore_path` directory. + + Use the `chown` command to make the appropriate adjustments to file permissions; for example, the following command changes the ownership of `restore_path` to `enterprisedb`: + + `chown -R enterprisedb:enterprisedb restore_path` + + The following command restricts access to `restore_path`: + + `chmod 700 restore_path` + +5. Copy any saved WAL files from Step 2 that were not archived to the BART backup catalog to the `restore_path/pg_wal` subdirectory (`pg_xlog` subdirectory if you are using server 9.6 version). + +6. Identify the timeline ID you wish to use to perform the restore operation. + + The available timeline IDs can be identified by the first non-zero digit of the WAL file names reading from left to right. + +7. Verify that the `postgresql.auto.conf` file created in the directory specified with the `RESTORE` subcommand’s `-p ` option was generated with the correct recovery parameter settings. + + If the `RESTORE` subcommand `-c` option is specified or if the enabled setting of the `copy_wals_during_restore` BART configuration parameter is applicable to the database server, then the `restore_command` parameter retrieves the archived WAL files from the `/archived_wals` subdirectory that was created by the `RESTORE` subcommand, otherwise the `restore_command` retrieves the archived WAL files from the BART backup catalog. + +8. The BART `RESTORE` subcommand disables WAL archiving in the restored database cluster. If you want to immediately enable WAL archiving, modify the `postgresql.conf` file by deleting the `archive_mode = off` parameter that BART appends to the end of the file. + +9. Start the database server, which will then perform the point-in-time recovery operation if recovery settings are saved in the `postgresql.auto.conf` file. + +For a detailed description of the `RESTORE` subcommand, see [Basic BART Subcommand Usage](../03_basic_bart_subcommand_usage/#basic_bart_subcommand_usage). An example of a Point-in-Time Recovery operation is documented in the *EDB Backup and Recovery Reference Guide* available at the [EDB website](/bart/latest/bart_ref/). See [Restore](../03_basic_bart_subcommand_usage/08_restore/#restore) for more information about using the `Restore` subcommand. diff --git a/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/01_bart_management_overview/index.mdx b/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/01_bart_management_overview/index.mdx new file mode 100644 index 00000000000..4cb9c779397 --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/01_bart_management_overview/index.mdx @@ -0,0 +1,34 @@ +--- +title: "BART Management Overview" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/bart_management_overview.html" +--- + + + +After configuring BART, you can begin the backup and recovery management process. The following steps will help you get started: + +1. Run the `CHECK-CONFIG` subcommand without the `-s` option. When the `CHECK-CONFIG` subcommand is used without specifying the `-s` option, it checks the parameters in the global section of the BART configuration file. +2. Run the `INIT` subcommand (if you have not already done so) to finish creation of the BART backup catalog, which results in the complete directory structure to which backups and WAL files are saved. This step must be done before restarting the database servers with enabled WAL archiving, otherwise the copy operation in the `archive_command` parameter of the `postgresql.conf` file or the `postgresql.auto.conf` file fails due to the absence of the target archive directory. When the directory structure is complete, the `archived_wals` subdirectory should exist for each database server. +3. Start the Postgres database servers with archiving enabled. Verify that the WAL files are appearing in the `archive_path`. The archiving frequency is dependent upon other `postgresql.conf` configuration parameters. Check the Postgres database server log files to ensure there are no archiving errors. Archiving should be operational before taking a backup in order to ensure that the WAL files that may be created during the backup process are archived. +4. Start the WAL scanner if you intend to take incremental backups. Since the WAL scanner processes the WAL files copied to the `archive path`, it is advantageous to commence the WAL scanning as soon as the WAL files begin to appear in the `archive_path` in order to keep the scanning in pace with the WAL archiving. +5. Run the BART `CHECK-CONFIG` subcommand for each database server with the `-s` option specifying the server name. This ensures the database server is properly configured for taking backups. +6. Create a full backup for each database server. The full backup establishes the starting point of when point-in-time recovery can begin and also establishes the initial parent backup for any incremental backups to be taken. + +There are now a number of other BART management processes you may perform: + +- Execute the `BACKUP` subcommand to create additional full backups or incremental backups. +- Use the `VERIFY-CHKSUM` subcommand to verify the checksum of the full backups. +- Display database server information with the `SHOW-SERVERS` subcommand. +- Display backup information with the `SHOW-BACKUPS` subcommand. +- Compress the archived WAL files in the `archive_path` by enabling WAL compression in the BART configuration file and then invoking the `MANAGE` subcommand. +- Determine and set the retention policy for backups in the BART configuration file. +- Establish the procedure for using the `MANAGE` subcommand to enforce the retention policy for backups. This may include using `cron` jobs to schedule the `MANAGE` subcommand. + +
+ +performing_a_restore_operation point_in_time_recovery_operation + +
diff --git a/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/01_overview_managing_backups_using_a_retention_policy.mdx b/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/01_overview_managing_backups_using_a_retention_policy.mdx new file mode 100644 index 00000000000..7169d6f7bb6 --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/01_overview_managing_backups_using_a_retention_policy.mdx @@ -0,0 +1,23 @@ +--- +title: "Overview - Managing Backups Using a Retention Policy" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/overview_managing_backups_using_a_retention_policy.html" +--- + + + +The BART retention policy results in the categorization of each backup in one of three statuses – *active*, *obsolete*, and *keep*. + +- **Active.** The backup satisfies the retention policy applicable to its server. Such backups would be considered necessary to ensure the recovery safety for the server and thus should be retained. +- **Obsolete.** The backup does not satisfy the retention policy applicable to its server. The backup is no longer considered necessary for the recovery safety of the server and thus can be deleted. +- **Keep.** The backup is to be retained regardless of the retention policy applicable to its server. The backup is considered vital to the recovery safety for the server and thus should not be deleted for an indefinite period of time. + +There are two types of retention policies - redundancy retention policy and recovery window retention policy. + +- **Redundancy Retention Policy** - The [redundancy retention policy](03_setting_the_retention_policy/#redundancy-retention-policy) relies on a specified, maximum number of most recent backups to retain for a given server. When the number of backups exceeds that maximum number, the oldest backups are considered obsolete (except for backups marked as keep). +- **Recovery Window Retention Policy** - The [recovery window retention policy](03_setting_the_retention_policy/#recovery-window-retention-policy) relies on a time frame (the recovery window) for when a backup should be considered active. The boundaries defining the recovery window are the current date/time (the ending boundary of the recovery window) and the date/time going back in the past for a specified length of time (the starting boundary of the recovery window). + - If the date/time the backup was taken is within the recovery window (that is, the backup date/time is on or after the starting date/time of the recovery window), then the backup is considered active, otherwise it is considered obsolete (except for backups marked as keep). + - Thus, for the recovery window retention policy, the recovery window time frame dynamically shifts, so the end of the recovery window is always the current date/time when the `MANAGE` subcommand is run. As you run the `MANAGE` subcommand at future points in time, the starting boundary of the recovery window moves forward in time. At some future point, the date/time of when a backup was taken will be earlier than the starting boundary of the recovery window. This is when an active backup’s status will be considered obsolete. + - You can see the starting boundary of the recovery window at any point in time by running the `SHOW-SERVERS` subcommand. The `RETENTION POLICY` field of the `SHOW-SERVERS` subcommand displays the starting boundary of the recovery window. diff --git a/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/02_marking_the_backup_status.mdx b/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/02_marking_the_backup_status.mdx new file mode 100644 index 00000000000..047552d0a9e --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/02_marking_the_backup_status.mdx @@ -0,0 +1,25 @@ +--- +title: "Marking the Backup Status" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/marking_the_backup_status.html" +--- + + + +When a backup is initially created with the `BACKUP` subcommand, it is always recorded with active status. Use the `MANAGE` subcommand to evaluate if the backup status should be changed to obsolete in accordance with the retention policy. You can review the current status of your backups with the `SHOW-BACKUPS` subcommand. + +Active backups are evaluated and also marked (that is, internally recorded by BART) as obsolete only when the `MANAGE` subcommand is invoked either with no options or with only the `-s` option. + +Once a backup has been marked as obsolete, you cannot change it back to active unless you perform the following steps: + +- Use the `MANAGE` subcommand with the `-c` option along with the backup identifier or name with the `-i` option. To keep this particular backup indefinitely, use `-c keep`, otherwise use `-c nokeep`. +- If you use the `-c nokeep` option, the backup status is changed back to active. When the `MANAGE` subcommand is used the next time, the backup is re-evaluated to determine if its status needs to be changed back to obsolete based on the current retention policy in the BART configuration file. + +After setting the `retention_policy` parameter and running the `MANAGE` subcommand if you change the `retention_policy` parameter, the current, marked status of the backups are probably inconsistent with the new `retention_policy` setting. To modify the backup status to be consistent with the new `retention_policy` setting, you need to run the `MANAGE` subcommand with: + +- the `-c nokeep` option to change the obsolete status to active status if there are backups currently marked as obsolete that would no longer be considered obsolete under a new retention policy. You can also specify the `-i all` option to change all backups back to active status, including those currently marked as keep. +- no options or with only the `-s` option to reset the marked status based on the new `retention_policy` setting in the BART configuration file. + +See [MANAGE](../03_basic_bart_subcommand_usage/07_manage/#manage) for usage information for the `MANAGE` subcommand. diff --git a/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/03_setting_the_retention_policy.mdx b/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/03_setting_the_retention_policy.mdx new file mode 100644 index 00000000000..a4396239bfe --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/03_setting_the_retention_policy.mdx @@ -0,0 +1,82 @@ +--- +title: "Setting the Retention Policy" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/setting_the_retention_policy.html" +--- + + + +The retention policy is determined by the `retention_policy` parameter in the BART configuration file. It can be applied globally to all servers, but each server can override the global retention policy with its own. For information about creating a global retention policy and an individual database server retention policy, see the EDB Backup and Recovery Installation and Upgrade Guide available at the [EDB website](/bart/latest/bart_inst/). + +There are two types of retention policies - redundancy retention policy and the recovery window retention policy as described in the following sections. + + + +## Redundancy Retention Policy + +To use the redundancy retention policy, set `retention_policy = max_number BACKUPS` where `max_number` is a positive integer designating the maximum number of most recent backups. + +**Additional Restrictions:** + +- The keyword `BACKUPS` must always be specified in plural form (for example, `1 BACKUPS`). +- BART will accept a maximum integer value of 2,147,483,647 for `max_number`; however, you should use a realistic, practical value based on your system environment. + +The redundancy retention policy is the default type of retention policy if all keywords `BACKUPS`, `DAYS`, `WEEKS`, and `MONTHS` following the `max_number` integer are omitted as shown by the following example: + +`retention_policy = 3` + +In the following example, the redundancy retention policy setting considers the three most recent backups as the active backups. Any older backups, except those marked as `keep`, are considered obsolete: + +```text +[ACCTG] +host = 127.0.0.1 +port = 5444 +user = enterprisedb +archive_command = 'cp %p %a/%f' +retention_policy = 3 BACKUPS +description = "Accounting" +``` + +The `SHOW-SERVERS` subcommand displays the `3 Backups` redundancy retention policy in the `RETENTION POLICY` field: + +```bash +-bash-4.1$ bart SHOW-SERVERS -s acctg +SERVER NAME : acctg +HOST NAME : 127.0.0.1 +USER NAME : enterprisedb +PORT : 5444 +REMOTE HOST : +RETENTION POLICY : 3 Backups +DISK UTILIZATION : 627.04 MB +NUMBER OF ARCHIVES : 25 +ARCHIVE PATH : /opt/backup/acctg/archived_wals +ARCHIVE COMMAND : cp %p /opt/backup/acctg/archived_wals/%f +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +DESCRIPTION : "Accounting" +``` + + + +## Recovery Window Retention Policy + +To use the recovery window retention policy, set the `retention_policy` parameter to the desired length of time for the recovery window in one of the following ways: + +- Set to `max_number DAYS` to define the start date/time recovery window boundary as the number of days specified by `max_number` going back in time from the current date/time. +- Set to `max_number WEEKS` to define the start date/time recovery window boundary as the number of weeks specified by `max_number` going back in time from the current date/time. +- Set to `max_number MONTHS` to define the start date/time recovery window boundary as the number of months specified by `max_number` going back in time from the current date/time. + +**Additional Restrictions:** + +- The keywords `DAYS`, `WEEKS`, and `MONTHS` must always be specified in plural form (for example, `1 DAYS`, `1 WEEKS`, or `1 MONTHS`). +- BART will accept a maximum integer value of `2,147,483,647` for `max_number`, however, a realistic, practical value based on your system environment must always be used. + +A backup is considered active if the date/time of the backup is equal to or greater than the start of the recovery window date/time. + +You can view the actual, calculated recovery window by: + +- Invoking the `MANAGE` subcommand in debug mode, along with the `-n` option. +- Using the `SHOW-SERVERS` subcommand. diff --git a/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/04_managing_the_backups_based_on_the_retention_policy.mdx b/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/04_managing_the_backups_based_on_the_retention_policy.mdx new file mode 100644 index 00000000000..def779a4026 --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/04_managing_the_backups_based_on_the_retention_policy.mdx @@ -0,0 +1,147 @@ +--- +title: "Managing the Backups Based on the Retention Policy" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/managing_the_backups_based_on_the_retention_policy.html" +--- + + + +The [MANAGE](../03_basic_bart_subcommand_usage/07_manage/#manage) subcommand is used to evaluate and categorize backups according to the retention policy set in the BART configuration file. When a backup is first created with the `BACKUP` subcommand, it is `active`. You can use the `MANAGE` subcommand to change the status of an active backup to `obsolete`. Obsolete backups can then be deleted. + +This section covers following aspects of backup management: + +- The rules for [deleting backups](#deletions_permitted_under_retention_policy) depending upon the backup status and the subcommand used. +- The process to retain a backup indefinitely by [marking it as keep](#marking-backups-for-indefinite-keep-status). This section also provides information about resetting backups status (that are marked as `obsolete` and `keep`) back to active status. +- The general process for [evaluating, marking, and then deleting obsolete backups](#evaluating-marking-and-deleting-obsolete-backups). + + + +## Deletions Permitted Under a Retention Policy + +This section describes how and under what conditions backups may be deleted under a retention policy. + +You must use the `MANAGE` subcommand to delete obsolete backups. Use the `DELETE` subcommand only for special administrative purposes. + +The deletion behavior of the `MANAGE` subcommand and the `DELETE` subcommand are based on different aspects of the retention policy. + +- The `MANAGE` subcommand deletion relies solely upon how a backup status is currently marked (that is, internally recorded by BART). The current setting of the `retention_policy` parameter in the BART configuration file is ignored. +- The `DELETE` subcommand relies solely upon the current setting of the `retention_policy` parameter in the BART configuration file. The current active, obsolete, or keep status of a backup is ignored. + +The specific deletion rules for the `MANAGE` and `DELETE` subcommands are as follows: + +- `MANAGE` subcommand: The `MANAGE` subcommand with the `-d` option can only delete backups marked as obsolete. This deletion occurs regardless of the current `retention_policy` setting in the BART configuration file. The deletion of backups relies on the last occasion when the backups have been marked. +- `DELETE` subcommand: + + - Under a redundancy retention policy currently set with the `retention_policy` parameter in the BART configuration file, any backup regardless of its marked status, can be deleted with the `DELETE` subcommand when the backup identifier or name is specified with the `-i` option and if the current total number of backups for the specified database server is greater than the maximum number of redundancy backups currently specified with the `retention_policy` parameter. + + If the total number of backups is less than or equal to the specified, maximum number of redundancy backups, then no additional backups can be deleted using `DELETE` with the `-i backup` option. + + - Under a recovery window retention policy currently set with the `retention_policy` parameter in the BART configuration file, any backup regardless of its marked status, can be deleted with the `DELETE` subcommand when the backup identifier or name is specified with the `-i` option, and if the backup date/time is not within the recovery window currently specified with the `retention_policy` parameter. If the backup date/time is within the recovery window, then it cannot be deleted using `DELETE` with the `-i backup` option. + + - Invoking the `DELETE` subcommand with the `-i all` option results in the deletion of all backups regardless of the retention policy and regardless of whether the status is marked as active, obsolete, or keep. + +The following table summarizes the deletion rules of backups according to their marked status. An entry of `Yes` indicates the backup may be deleted under the specified circumstances. An entry of `No` indicates that the backup may not be deleted. + + ++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
OperationRedundancy Retention PolicyRecovery Window Retention Policy
ActiveObsoleteKeepActiveObsoleteKeep
MANAGE –dNoYesNoNoYesNo
DELETE –i *backup* +

Yes

+

(see Note 1)

+
+

Yes

+

(see Note 1)

+
+

Yes

+

(see Note 1_)

+
+

Yes

+

(see Note 2

+
+

Yes

(see Note 2 +
+

Yes

(see Note 2) +
DELETE –i allYesYesYesYesYesYes
+ + + +!!! Note + Redundancy Retention Policy (Note 1) : Deletion occurs only if the total number of backups for the specified database server is greater than the specified, maximum number of redundancy backups currently set with the `redundancy_policy` parameter in the BART configuration file. + + + +!!! Note + Recovery Window Retention Policy (Note 2): Deletion occurs only if the backup is not within the recovery window currently set with the `redundancy_policy` parameter in the BART configuration file. + + + +## Marking Backups for Indefinite Keep Status + +There may be certain backups that you wish to keep for an indefinite period of time and do not wish to delete based upon the retention policy applied to the database server. Such backups can be marked as `keep` to exclude them from being marked as obsolete. Use the `MANAGE` subcommand with the `-c keep` option to retain such backups indefinitely. + + + +## Evaluating, Marking, and Deleting Obsolete Backups + +When the `MANAGE` subcommand is invoked, BART evaluates active backups: + +- If you include the `-s` option when invoking the `MANAGE` subcommand, BART evaluates backups for the database server. +- If you include the `-s all` option when invoking the `MANAGE` subcommand, BART evaluates backups for all database servers. +- If the `-s` option is omitted, the command evaluates the current number of backups for the database server based on the redundancy retention policy or the current date/time for a recovery window retention policy. + +!!! Note + The status of backups currently marked as `obsolete` or `keep` is not changed. To re-evaluate such backups and then classify them, their status must first be reset to `active` with the `MANAGE -c nokeep` option. See [Marking the Backup Status](02_marking_the_backup_status/#marking_the_backup_status) for more information. + +See the *EDB Backup and Recovery Reference Guide* available at the [EDB website](/bart/latest/bart_ref/) to review examples of how to evaluate, mark, and delete backups using a redundancy retention policy and recovery window retention policy, as well as examples of `MANAGE` subcommand. diff --git a/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/05_managing_incremental_backups.mdx b/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/05_managing_incremental_backups.mdx new file mode 100644 index 00000000000..c69f6b09086 --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/05_managing_incremental_backups.mdx @@ -0,0 +1,51 @@ +--- +title: "Managing Incremental Backups" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/managing_incremental_backups.html" +--- + + + +The following section summarizes how retention policy management affects incremental backups. + +- The retention policy rules are applied to full backups. + - A redundancy retention policy uses the number of full backups to determine if a backup is obsolete. Incremental backups are excluded from the comparison count against the `retention_policy` setting for the maximum number of backups. + - A recovery window retention policy uses the backup date/time of any full backups to determine if a backup is obsolete. The backup date/time of any successive incremental backups in the chain are ignored when comparing with the recovery window. +- The retention status of all incremental backups in a chain is set to the same status applied to the full backup of the chain. +- The actions applied by the `MANAGE` and `DELETE` subcommands on a full backup are applied to all incremental backups in the chain in the same manner. +- Thus, a backup chain (that is, the full backup and all its successive incremental backups) are treated by retention policy management as if they are all one, single backup. + - The status setting applied to the full backup is also applied to all incremental backups in its chain. + - If a full backup is marked as obsolete and then deleted according to the retention policy, all incremental backups in the chain are also marked obsolete and then deleted as well. + +The following are some specific points regarding the `MANAGE` and `DELETE` subcommands on incremental backups. + +- `MANAGE` subcommand: + - When the `MANAGE` subcommand is invoked, the status applied to the full backup is also applied to all successive incremental backups in the chain. + - The `MANAGE` subcommand with the `-c { keep | nokeep}` option cannot specify the backup identifier or backup name of an incremental backup with `-i` backup option. The `-i` backup option can only specify the backup identifier or backup name of a full backup. + - You can also use the `-i` all option to take a backup of all backups. When the `MANAGE` subcommand with the `-c { keep | nokeep }` option is applied to a full backup, the same status change is made to all incremental backups in the chain. +- `DELETE` subcommand: + - The `DELETE` subcommand with the `-s server -i` backup option specifies the backup identifier or backup name of an incremental backup in which case that incremental backup along with all its successive incremental backups are deleted, thus shortening that backup chain. + +## Using a Redundancy Retention Policy with Incremental Backups + +When a [redundancy retention policy](03_setting_the_retention_policy/#redundancy-retention-policy) is used and the `MANAGE` subcommand is invoked, the status of the oldest `active` full backup is changed to `obsolete` if the number of full backups exceeds the maximum number specified by the `retention_policy` parameter in the BART configuration file. + +!!! Note + When a full backup is changed from `active` to `obsolete`, all successive incremental backups in the chain of the full backup are also changed from `active` to `obsolete`. + +When determining the number of backups that exceeds the number specified by the `retention_policy` parameter, only full backups are counted for the comparison. Incremental backups are not included in the count for the comparison against the `retention_policy` parameter setting. + +See the *EDB Backup and Recovery Reference Guide* available at the [EDB website](/bart/latest/bart_ref/) for examples demonstrating use of the `MANAGE` and `DELETE` subcommands when a redundancy retention policy is in effect. + +## Using a Recovery Window Retention Policy with Incremental Backups + +If the `MANAGE` command is invoked when BART is configured to use a [recovery window retention policy](03_setting_the_retention_policy/#recovery-window-retention-policy), the status of `active` full backups are changed to `obsolete` if the date/time of the full backup is outside of the recovery window. + +!!! Note + If a full backup is changed from `active` to `obsolete`, all successive incremental backups in the chain of the full backup are also changed from `active` to `obsolete`. + +The status of an incremental backup is changed to `obsolete` regardless of whether or not the date/time of when the incremental backup was taken still lies within the recovery window. + +See the *EDB Backup and Recovery Reference Guide* available at the [EDB website](/bart/latest/bart_ref/) for examples demonstrating use of the `MANAGE` and `DELETE` subcommands when a recovery window retention policy is in effect. diff --git a/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/index.mdx b/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/index.mdx new file mode 100644 index 00000000000..aff92bbd6a5 --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/index.mdx @@ -0,0 +1,27 @@ +--- +title: "Managing Backups Using a Retention Policy" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/managing_backups_using_a_retention_policy.html" +--- + + + +Over the course of time when using BART, the number of backups can grow significantly. This ultimately leads to a large consumption of disk space unless an administrator periodically performs the process of deleting the oldest backups that are no longer needed. This process of determining when a backup is old enough to be deleted and then actually deleting such backups can be done and automated with the following basic steps: + +1. Determine and set a retention policy in the BART configuration file. A *retention policy* is a rule that determines when a backup is considered obsolete. The retention policy can be applied globally to all servers, but each server can override the global retention policy with its own. + +2. Use the `MANAGE` subcommand to categorize and manage backups according to the retention policy. + +3. Create a cron job to periodically run the `MANAGE` subcommand to evaluate the backups and then list and/or delete the obsolete backups. + + Retention policy management applies differently to incremental backups than to full backups. See [Managing Incremental Backups](05_managing_incremental_backups/#managing_incremental_backups) for information about how retention policy management is applied to each backup type. + + The following sections describe how retention policy management generally applies to backups, and its specific usage and effect on full backups. + +
+ +overview_managing_backups_using_a_retention_policy marking_the_backup_status setting_the_retention_policy managing_the_backups_based_on_the_retention_policy managing_incremental_backups + +
diff --git a/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/03_basic_bart_subcommand_usage/01_check_config.mdx b/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/03_basic_bart_subcommand_usage/01_check_config.mdx new file mode 100644 index 00000000000..f12dd038edd --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/03_basic_bart_subcommand_usage/01_check_config.mdx @@ -0,0 +1,35 @@ +--- +title: "CHECK-CONFIG" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/check_config.html" +--- + + + +The `CHECK-CONFIG` subcommand checks the parameter settings in the BART configuration file as well as the database server configuration for which the `-s` option is specified. + +**Syntax:** + +`bart CHECK-CONFIG [ –s server_name ]` + +The following table describes the option. + +| Options | Description | +| ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s ` or `--server ` | `server_name` is the name of the database server to be checked for proper configuration. If the option is omitted, the settings of the global section of the BART configuration file are checked. | + +- When the `-s` option is omitted, the global section \[BART] parameters including `bart_host`, `backup_path`, and `pg_basebackup_path` are checked. +- When the `-s` option is specified, the server section parameters are checked. In addition, certain database server `postgresql.conf` parameters are also checked, which include the following: + - The `cluster_owner` parameter must be set to the user account owning the database cluster directory. + - A passwordless SSH/SCP connection must be set between the BART user and the user account specified by the `cluster_owner` parameter. + - A database superuser must be specified by the BART `user` parameter. + - The `pg_hba.conf` file must contain a replication entry for the database superuser specified by the BART `user` parameter. + - The `archive_mode` parameter in the `postgresql.conf` file must be enabled. + - The `archive_command` parameter in the `postgresql.auto.conf` or the `postgresql.conf` file must be set. + - The `allow_incremental_backups` parameter in the BART configuration file must be enabled for database servers for which incremental backups are to be taken. + - Archiving of WAL files to the `archive_path` must be in process. + - The WAL scanner program must be running. + +The `CHECK-CONFIG` subcommand displays an error message if the required configuration is not properly set. diff --git a/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/03_basic_bart_subcommand_usage/02_init.mdx b/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/03_basic_bart_subcommand_usage/02_init.mdx new file mode 100644 index 00000000000..d8cdeed8126 --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/03_basic_bart_subcommand_usage/02_init.mdx @@ -0,0 +1,41 @@ +--- +title: "INIT" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/init.html" +--- + + + +The `INIT` subcommand is used to create the BART backup catalog directory, rebuild the BART `backupinfo` file, and set the `archive_command` in the PostgreSQL server based on the `archive_command` setting in the `bart.cfg` file. + +!!! Note + If the `archive_mode` configuration parameter is set to `off`, then the `-o` option must be used to set the Postgres `archive_command` using the BART `archive_command` parameter in the BART configuration file even if the `archive_command` is not currently set in `postgresql.conf` nor in `postgresql.auto.conf` file. + +**Syntax:** + +```text +bart INIT [ –s { | all } ] [ -o ] + [ -r [ -i { | | all } ] ] + [--no-configure] +``` + +All subcommand options are generally specified in lowercase. The following table describes the command options: + +| Options | Description | +| ------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { \| all }`

`--server { \| all }` | `server_name` is the name of the database server to which the `INIT` actions are to be applied. If `all` is specified or if the option is omitted, the actions are applied to all servers. | +| `-o`

`--override` | Overrides the existing, active Postgres `archive_command` configuration parameter setting in the `postgresql.conf` file or the `postgresql.auto.conf` file using the BART `archive_command` parameter in the BART configuration file. The `INIT` generated archive command string is written to the `postgresql.auto.conf` file. | +| `-r`

`--rebuild` | Rebuilds the backupinfo file (a text file named `backupinfo`) located in each backup subdirectory. This option is only intended for recovering from a situation where the backupinfo file has become corrupt.
If the backup was initially created with a user-defined backup name, and then the `INIT -r` option is invoked to rebuild that `backupinfo` file, the user-defined backup name is no longer available. Thus, future references to the backup must use the backup identifier. | +| `-i { \| \| all }`

`--backupid { \| \| all }` | `` is an integer, backup identifier and `` is the user-defined alphanumeric name for the backup. If `all` is specified or if the option is omitted, the backupinfo files of all backups for the database servers specified by the `-s` option are recreated. The `-i` option can only be used with the `-r` option. | +| `--no-configure` | Prevents the `archive_command` from being set in the PostgreSQL server. | + +**Archive Command Setting** + +After the `archive_command` is set, you need to either restart the PostgreSQL server or reload the configuration file in the PostgreSQL server based on the following conditions. + +- If the `archive_mode` is set to `off` and `archive_command` is not set in the PostgreSQL server, the `archive_command` is set based on the `archive_command` setting in the `bart.cfg` and also sets the `archive_mode` to `on`. In this case, you need to restart the PostgreSQL server using `pg_ctl restart` +- If the `archive_mode` is set to `on` and `archive_command` is not set in the PostgreSQL server, the `archive_command` is set based on the `archive_command` setting in the `bart.cfg`. In this case, you need to reload the configuration in the PostgreSQL server using `pg_reload_conf()` or `pg_ctl reload`. +- If the `archive_mode` is set to `off` and `archive_command` is already set in the PostgreSQL server, the `archive_mode` is set to on. In this case, you need to restart the PostgreSQL server using `pg_ctl restart` +- If the `archive_mode` is set to `on` and `archive_command` is already set in the PostgreSQL server, then the `archive_command` is not set unless `-o` option is specified. diff --git a/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/03_basic_bart_subcommand_usage/03_backup.mdx b/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/03_basic_bart_subcommand_usage/03_backup.mdx new file mode 100644 index 00000000000..0189291fe44 --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/03_basic_bart_subcommand_usage/03_backup.mdx @@ -0,0 +1,106 @@ +--- +title: "BACKUP" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/backup.html" +--- + + + +The `BACKUP` subcommand is used to create a full backup or an incremental backup. + +**Syntax for full backup:** + +```text +bart BACKUP –s { | all } [ -F { p | t } ] + [ -z ] [ –c ] + [ --backup-name ] + [ --thread-count ] + [ { --with-pg_basebackup | --no-pg_basebackup } ] +``` + +!!! Note + While taking a backup, if a file (for example, database server log file) exceeding 1 GB size is stored in the `$PGDATA` directory, the backup will fail. To avoid such backup failure, you need to store large files (exceeding 1 GB) outside the `$PGDATA` directory. + +**Syntax for incremental Backup:** + +```text +bart BACKUP –s { | all } [ -F p] + [ --parent { | } ] + [ --backup-name ] + [ --thread-count ] + [ --check ] + [--checksum-algorithm ] +``` + +!!! Note + To take an [incremental backup](../../02_overview/01_block-level_incremental_backup/#block-level_incremental_backup), you must take a full backup first followed by incremental backup. + +**Please Note:** + +- While a `BACKUP` subcommand is in progress, no other subcommands must be invoked. Any subcommands invoked while a backup is in progress will skip and ignore the backups. + +- For full backup, the target default format is a tar file, whereas for incremental backup, only plain format must be specified. + +- The backup is saved in the `//` directory, where `` is the value assigned to the `` parameter in the BART configuration file, `` is the lowercase name of the database server as listed in the configuration file, and `` is a backup identifier assigned by BART to the particular backup. + +- MD5 checksums of the full backup and any user-defined tablespaces are saved as well for tar backups. + +- Before performing the backup, BART checks to ensure if there is enough disk space to completely store the backup in the BART backup catalog. + +- In the `postgresql.conf` file, ensure the `wal_keep_segments` configuration parameter is set to a sufficiently large value. A low setting of the `wal_keep_segments` configuration parameter may result in the deletion of some WAL files before the BART `BACKUP` subcommand saves them to the `archive_path`. For information about the `wal_keep_segments` parameter, see the [PostgreSQL Core Documentation](https://www.postgresql.org/docs/current/static/runtime-config-replication.html). + +- In the BART configuration file, setting `xlog_method=stream` will instruct the server to stream the transaction log in parallel with creation of the backup for a specific database server; otherwise the transaction log files are collected upon completion of the backup. See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/latest/bart_inst/) for details about database server setting. + + !!! Note + If the transaction log streaming method is used, the `-Fp` option for a plain text backup format must be specified with the `BACKUP` subcommand. + +- When you use BART to take a backup of PostgreSQL server, multiple backups can be taken simultaneously and if a backup is interrupted, the backup mode is terminated automatically without the need to run `pg_stop_backup()` command manually to terminate the backup. + +**Options** + +Along with the `BACKUP` subcommand, specify the following option: + +| Options | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { server_name \| all }`
`--server { server_name \| all }` | `server_name` is the database server name to be backed up as specified in the BART configuration file. If `all` is specified, all servers are backed up. This option is mandatory.
If `all` is specified, and a connection to a database server listed in the BART configuration file cannot be opened, the backup for that database server is skipped, but the backup operation continues for the other database servers. | + +Specify the following options as required. If you do not specify any of the following options, the backup is created using default settings. + +| Options | Description | +| -------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-F { p \| t }`
`--format { p \| t }` | Specify this option to provide the backup file format. Use `p` for plain text or `t` for tar. If the option is omitted, the default is tar format.
For taking incremental backups, the option `-Fp` must be specified. | +| `-z`
`--gzip` | This is applicable only for full backup. Specify this option to use gzip compression on the tar file output using the default compression level. This option is applicable only for the tar format. | +| `-c `
`--compress-level ` | This is applicable only for full backup. Specify this option to use the gzip compression level on the tar file output. `compression_level` is a digit from 1 through 9, with 9 being the best compression. This option is applicable only for the tar format. | +| `--parent { backup_id \| backup_name }` | Specify this option to take an incremental backup. `` is the backup identifier of a parent backup. `` is the user-defined alphanumeric name of a parent backup.
The parent is a backup taken prior to the incremental backup. The parent backup can be either a full backup or an incremental backup.
The option `–Fp` must be specified since an incremental backup can only be taken in plain text format.
An incremental backup cannot be taken on a standby database server. See [Block-Level Incremental Backup](../../02_overview/01_block-level_incremental_backup/#block-level_incremental_backup) for additional information on incremental backups. | +| `--backup-name ` | Specify this option to assign a user-defined, alphanumeric friendly name to the backup. The maximum permitted length of backup name is 49 characters.
The backup name may include the following variables to be substituted by the timestamp values when the backup is taken: 1) `%year` – 4-digit year, 2) `%month` – 2-digit month, 3) `%day` – 2-digit day, 4) `%hour` 2-digit hour, 5) `%minute` – 2-digit minute, and 6) `%second` – 2-digit second.
To include the percent sign (`%`) as a character in the backup name, specify `%%` in the alphanumeric string.
If the backup name contains space characters (i.e. more than one word) or when referenced with the option `-i` by other subcommands (such as `restore`), enclose the string in single quotes or double quotes. See [backup name examples](#backup_name_examples).
If the `--backup-name` option is not specified, and the `backup_name` parameter is not set for this database server in the BART configuration file, then the backup can only be referenced in other BART subcommands by the BART assigned backup identifier. | +| `--thread-count ` | Use this option to use the number of worker threads to run in parallel to copy blocks for a backup.
If the option `--thread-count` is omitted, then the `thread_count` parameter in the BART configuration file applicable to this database server is used.
If the option `--thread-count` is not enabled for this database server, then the `thread_count` setting in the global section of the BART configuration file is used.
If the option `--thread-count` is not set in the global section as well, the default number of threads is 1.
If parallel backup is run with N number of worker threads, then it will initiate N+ 1 concurrent connections with the server.
Thread count will not be effective if backup is taken on a standby server.
For more information about the `--thread-count` parameter, see the EDB Backup and Recovery Installation and Upgrade Guide available at the [EDB website](/bart/latest/bart_inst/) | +| `--with-pg_basebackup` | This is applicable only for full backup. Specify this option to use `pg_basebackup` to take a full backup. The number of thread counts in effect is ignored as given by the `thread_count` parameter in the BART configuration file.
When taking a full backup, if the thread count in effect is greater than `1`, then the `pg_basebackup` utility is not used to take the full backup (parallel worker threads are used) unless the option `--with-pg_basebackup` is specified with the `BACKUP` subcommand. | +| `--no-pg_basebackup` | This is applicable only for full backup. Specify this option if you do not want `pg_basebackup` to be used to take a full backup.
When taking a full backup, if the thread count in effect is only `1`, then the `pg_basebackup` utility is used to take the full backup unless the option `--no-pg_basebackup` is specified with the `BACKUP` subcommand. | +| `--check` | This is applicable only for incremental backup. Specify this option to verify if the required MBM files are present in the `archived_wals` directory as specified in the `archive_path` parameter in the `bart.cfg` file before taking an incremental backup. The option `--parent` must be specified when the option `--check` is used. An actual incremental backup is not taken when the option `--check` is specified. | +| `--checksum-algorithm` | While taking a backup, you can specify one of the following values with the `--checksum-algorithm` option:
`--checksum-algorithm=MD5` (default) to generate MD5 checksum files.
`--checksum-algorithm=SHA256` to generate SHA256 checksum files.
`--checksum-algorithm=NONE` to skip generating checksum files. | + + + +**Backup Name Examples** + +The following examples demonstrate using the `--backup-name` clause: + +```text +./bart backup -s ppas12 -Ft --backup-name "YEAR = %year +MONTH = %month DAY = %day" +./bart backup -s ppas12 -Ft --backup-name "YEAR = %year +MONTH = %month DAY = %day %%" +./bart show-backups -s ppas12 -i "test backup" +``` + +**Error messages** + +The following table lists the error messages that may be encountered when using the `BACKUP` subcommand: + +| error message | Cause | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `edb@localhost bin]$ ./bart backup -s mktg -Ft`

`WARNING: xlog_method is empty, defaulting to global policy`

`ERROR: backup failed for server 'mktg'`

`free disk space is not enough to backup the server 'mktg'`

`space available 13.35 GB, approximately required 14.65 GB` | Insufficient free disk space. | +| `ERROR: backup failed for server 'mktg'`

`command failed with exit code 1`

`pg_basebackup: could not get transaction log end position from server: ERROR: requested WAL segment 00000001000000D50000006B has already been removed` | The wal_keep_segments configuration parameter is not set to a sufficiently large value in the postgresql.conf file. | +| `ERROR: backup failed for server 'mktg'`

`connection to the server failed: could not connect to server: Connection refused`

`Is the server running on host "172.16.114.132" and accepting`

`TCP/IP connections on port 5444?` | A connection to a database server listed in the BART configuration file fails. As a result the backup for that database server is skipped, but the backup operation continues for other database servers | diff --git a/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/03_basic_bart_subcommand_usage/04_show_servers.mdx b/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/03_basic_bart_subcommand_usage/04_show_servers.mdx new file mode 100644 index 00000000000..778efd3d4d6 --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/03_basic_bart_subcommand_usage/04_show_servers.mdx @@ -0,0 +1,21 @@ +--- +title: "SHOW-SERVERS" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/show_servers.html" +--- + + + +The `SHOW-SERVERS` subcommand displays the information for the managed database servers listed in the BART configuration file. + +**Syntax:** + +`bart SHOW-SERVERS [ –s { | all } ]` + +The following table describes the command options. + +| Options | Description | +| ---------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { \| all }`
`--server { \| all }` | `` is the name of the database server whose BART configuration information is to be displayed. If `all` is specified or if the option is omitted, information for all database servers is displayed. | diff --git a/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/03_basic_bart_subcommand_usage/05_show_backups.mdx b/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/03_basic_bart_subcommand_usage/05_show_backups.mdx new file mode 100644 index 00000000000..d006df69db1 --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/03_basic_bart_subcommand_usage/05_show_backups.mdx @@ -0,0 +1,25 @@ +--- +title: "SHOW-BACKUPS" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/show_backups.html" +--- + +The `SHOW-BACKUPS` subcommand displays the backup information for the managed database servers. + +**Syntax:** + +```text +bart SHOW-BACKUPS [ –s { | all } ] + [ -i { | | all } ] + [ -t ] +``` + +The following table describes the command options: + +| Options | Description | +| ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { \| all }`
`--server { \| all }` | `` is the name of the database server whose backup information is to be displayed.
If `all` is specified or if the option is omitted, the backup information for all database servers is displayed with the exception as described by the following note:
If `SHOW-BACKUPS` is invoked while the BART `BACKUP` subcommand is in progress, backups affected by the backup process are shown in progress status in the displayed backup information. | +| `-i { \| \| all }`
`--backupid { \| \| all }` | `` is a backup identifier and `` is the user-defined alphanumeric name for the backup.
If `all` is specified or if the option is omitted, all backup information for the relevant database server is displayed. | +| `-t`
`--toggle` | Displays more backup information in a list format. If the option is omitted, the default is a tabular format. | diff --git a/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/03_basic_bart_subcommand_usage/06_verify_chksum.mdx b/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/03_basic_bart_subcommand_usage/06_verify_chksum.mdx new file mode 100644 index 00000000000..4ec79d52d62 --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/03_basic_bart_subcommand_usage/06_verify_chksum.mdx @@ -0,0 +1,29 @@ +--- +title: "VERIFY-CHKSUM" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/verify_chksum.html" +--- + + + +The `VERIFY-CHKSUM` subcommand verifies the MD5 checksums of the full backups and any user-defined tablespaces for the specified database server or for all database servers. The checksum is verified by comparing the current checksum of the backup against the checksum when the backup was taken. + +!!! Note + The `VERIFY-CHKSUM` subcommand is only used for tar format backups. It is not applicable to plain format backups. + +**Syntax:** + +```text +bart VERIFY-CHKSUM + [ -s { | all } ] + [ -i { | | all } ] +``` + +The following table describes the command options: + +| Options | Description | +| ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { \| all }`

`--server { \| all }` | `` is the name of the database server whose tar backup checksums are to be verified. If `all` is specified or if the `-s` option is omitted, the checksums are verified for all database servers. | +| `-i { \| \| all }`

`--backupid { \| \| all }` | `` is the backup identifier of a tar format full backup whose checksum is to be verified along with any user-defined tablespaces.
`` is the user-defined alphanumeric name for the full backup.
If `all` is specified or if the `-i` option is omitted, the checksums of all tar backups for the relevant database server are verified. | diff --git a/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/03_basic_bart_subcommand_usage/07_manage.mdx b/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/03_basic_bart_subcommand_usage/07_manage.mdx new file mode 100644 index 00000000000..52a74badaa7 --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/03_basic_bart_subcommand_usage/07_manage.mdx @@ -0,0 +1,62 @@ +--- +title: "MANAGE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/manage.html" +--- + + + +The `MANAGE` subcommand can be invoked to: + +- Evaluate backups, mark their status, and delete obsolete backups based on the `retention_policy` parameter in the BART configuration file (See [Managing Backups Using a Retention Policy](../02_managing_backups_using_a_retention_policy/#managing_backups_using_a_retention_policy) for information about retention policy management). + +- Compress the archived WAL files based on the `wal_compression` parameter in the BART configuration file (See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/latest/bart_inst/) for information about setting this parameter). + + **Syntax:** + + ```text + bart MANAGE [ –s { | all} ] + [ -l ] [ -d ] + [ -c { keep | nokeep } + -i { | | all } ] + [ -n ] + ``` + +The following summarizes the actions performed when the `MANAGE` subcommand is invoked: + +- When the `MANAGE` subcommand is invoked with no options or with only the `-s ` or `-s all` option, the following actions are performed: + - For the server specified by the `-s` option, or for all servers (if `-s all` is specified or the `-s` option is omitted), active backups are marked as `obsolete` in accordance with the retention policy. + - All backups that were marked `obsolete` or `keep` prior to invoking the `MANAGE` subcommand remain marked with the same prior status. + - If WAL compression is enabled for the database server, then any uncompressed, archived WAL files in the BART backup catalog of the database server are compressed with gzip. +- When the `MANAGE` subcommand is invoked with any other option besides the `-s` option, the following actions are performed: + - For the server specified by the `-s` option, or for all servers, the action performed is determined by the other specified options (that is, `-l` to list obsolete backups, `-d` to delete obsolete backups, `-c` to keep or to return backups to `active` status, or `-n` to perform a dry run of any action). + - No marking of `active` backups to `obsolete` status is performed regardless of the retention policy. + - All backups that were marked `obsolete` or `keep` prior to invoking the `MANAGE` subcommand remain marked with the same prior status unless the `-c` option (without the `-n` option) is specified to change the backup status of the particular backup or all backups referenced with the `-i` option. + - No compression is applied to any uncompressed, archived WAL file in the BART backup catalog regardless of whether or not WAL compression is enabled. + +The following are additional considerations when using WAL compression: + +- Compression of archived WAL files is not permitted for database servers on which incremental backups are to be taken. +- The gzip compression program must be installed on the BART host and be accessible in the `PATH` of the BART user account. +- When the `RESTORE` subcommand is invoked, if the `-c` option is specified or if the `copy_wals_during_restore` BART configuration parameter is enabled for the database server, then the following actions occur: + + - If compressed, archived WAL files are stored in the BART backup catalog and the location to which the WAL files are to be restored is on a remote host relative to the BART host: + + - the archived WAL files are transmitted across the network to the remote host in compressed format only if the gzip compression program is accessible in the `PATH` of the remote user account that is used to log into the remote host when performing the `RESTORE` operation. + - This remote user is specified with either the `remote_host` parameter in the BART configuration file or the `RESTORE -r` option (see [RESTORE](08_restore/#restore)). + - Transmission of compressed WAL files results in less network traffic. After the compressed WAL files are transmitted across the network, the `RESTORE` subcommand uncompresses the files for the point-in-time recovery operation. + - If the gzip program is not accessible on the remote host in the manner described in the previous bullet point, then the compressed, archived WAL files are first uncompressed while on the BART host, then transmitted across the network to the remote host in uncompressed format. +- When the `RESTORE` subcommand is invoked without the `-c` option and the `copy_wals_during_restore` BART configuration parameter is disabled for the database server, then any compressed, archived WAL files needed for the `RESTORE` operation are uncompressed in the BART backup catalog. The uncompressed WAL files can then be saved to the remote host by the `restore_command` in the `postgresql.auto.conf` file when the database server archive recovery begins. + +The following table describes the command options: + +| Options | Description | +| ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `s { \| all }`
`--server { \| all }` | `` is the name of the database server to which the actions are to be applied. If `all` is specified or if the `-s` option is omitted, the actions are applied to all database servers. | +| `-l`
`--list-obsolete` | Lists the backups marked as obsolete. | +| `-d`
`--delete-obsolete` | Delete the backups marked as `obsolete`. This action physically deletes the backup along with its archived WAL files and any MBM files for incremental backups. | +| `-c { keep \| nokeep }`

`--change-status { keep \| nokeep }` | Specify `keep` to change the status of a backup to `keep` to retain it indefinitely.
Specify `nokeep` to change the status of any backup back to active status. The backup can then be re-evaluated and possibly be marked to `obsolete` according to the retention policy by subsequent usage of the `MANAGE` subcommand.
The `–i` option must be included when using the `-c` option. | +| `-i { \| \| all }`

`--backupid { \| \| all }` | `` is a backup identifier and `` is the user-defined alphanumeric name for the backup.
If `all` is specified, then actions are applied to all backups.
The `–c` option must be included when using the `-i` option. | +| `-n`
`--dry-run` | Performs the test run and displays the results prior to actually implementing the actions as if the operation was performed, however, no changes are actually made.
If `-n` is specified with the `-d` option, it displays which backups would be deleted, but does not actually delete the backups.
If `-n` is specified with the `-c` option, it displays the keep or nokeep action, but does not actually change the backup from its current status.
If `-n` is specified alone with no other options, or with only the `-s` option, it displays which active backups would be marked as obsolete, but does not actually change the backup status. In addition, no compression is performed on uncompressed, archived WAL files even if WAL compression is enabled for the database server. | diff --git a/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/03_basic_bart_subcommand_usage/08_restore.mdx b/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/03_basic_bart_subcommand_usage/08_restore.mdx new file mode 100644 index 00000000000..a7fc6fc64ab --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/03_basic_bart_subcommand_usage/08_restore.mdx @@ -0,0 +1,48 @@ +--- +title: "RESTORE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/restore.html" +--- + + + +The `RESTORE` subcommand restores a backup and its archived WAL files for the designated database server to the specified directory location. If the appropriate `RESTORE` options are specified, all recovery settings will be saved in the `postgresql.auto.conf` file. + +**Syntax:** + +```text +bart RESTORE –s -p + [ –i { | } ] + [ -r ] + [ -w ] + [ -t ] + [ { -x | -g } ] + [ -c ] + [ --disable-checksum ] +``` + +For information about using a continuous archive backup for recovery, see the [PostgreSQL Core Documentation](https://www.postgresql.org/docs/13/static/continuous-archiving.html). This reference material provides detailed information about the underlying point-in-time recovery process and the meaning and usage of the restore options that are generated into the `postgresql.auto.conf` file by BART. + +**Please note**: + +- For special requirements when restoring an incremental backup to a remote database server, see [Restoring an Incremental Backup on a Remote Host](../../02_overview/01_block-level_incremental_backup/05_restoring_an_incremental_backup/#restoring_an_incremental_backup_on_a_remote_host). +- Check to ensure that the host where the backup is to be restored contains enough disk space for the backup and its archived WAL files. The `RESTORE` subcommand may result in an error while copying files if there is not enough disk space available. +- See [Performing a Restore Operation](../01_bart_management_overview/01_performing_a_restore_operation/#performing_a_restore_operation) to view steps on how to perform a restore operation and see [Point-In-Time Recovery Operation](../01_bart_management_overview/02_point_in_time_recovery_operation/#point_in_time_recovery_operation) to view steps on how to perform a point-in-time recovery operation. +- If the backup is restored to a different database cluster directory than where the original database cluster resided, certain operations dependent upon the database cluster location may fail. This happens if their supporting service scripts are not updated to reflect the new directory location of restored backup. For information about the usage and modification of service scripts, see the *EDB Advanced Server Installation Guide* available at the [EDB website](/epas/latest/). + +The following table describes the command options: + +| Options | Description | +| ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s `
`--server ` | `` is the name of the database server to be restored. | +| `-p `
`--restore-path ` | `` is the directory path where the backup of the database server is to be restored. The directory must be empty and have the proper ownership and privileges assigned to it. | +| `-i { \| }`

`--backupid { \| }` | `` is the backup identifier of the backup to be used for the restoration and `` is the user-defined alphanumeric name for the backup.
If the option is omitted, the default is to use the latest backup. | +| `-r or --remote-host ` | `` is the user account on the remote database server host that accepts a passwordless SSH/SCP login connection and is the owner of the directory where the backup is to be restored and `` is the IP address of the remote host to which the backup is to be restored. This option must be specified if the `` parameter for this database server is not set in the BART configuration file.
If the BART user account is not the same as the operating system account owning the `` directory given with the `-p` option, use the `` BART configuration parameter or the `RESTORE` subcommand `-r` option to specify the `` directory owner even when restoring to a directory on the same host as the BART host.
See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/latest/bart_inst/) for information about the `` parameter. | +| `-w `
`--workers ` | `` is the specification of the number of worker processes to run in parallel to stream the modified blocks of an incremental backup to the restore location.
For example, if 4 worker processes are specified, 4 receiver processes on the restore host and 4 streamer processes on the BART host are used. The output of each streamer process is connected to the input of a receiver process. When the receiver gets to the point where it needs a modified block file, it obtains those modified blocks from its input. With this method, the modified block files are never written to the restore host disk. If the `-w` option is omitted, the default is `1` \| worker process. | +| `-t `
`--target-tli ` | `` is the integer identifier of the timeline to be used for replaying the archived WAL files for point-in-time recovery. | +| `-x `
`--target-xid ` | `` is the integer identifier of the transaction ID that determines the transaction up to and including, which point-in-time recovery encompasses. Include either the `-x ` or the `--target-xid ` option if point-in-time recovery is desired. | +| `-g `

`--target-timestamp ` | `` is the timestamp that determines the point in time up to and including, which point-in-time recovery encompasses. Include either the `--target-timestamp ` or the `-g ` option if point-in-time recovery is desired. | +| `-c`
`--copy-wals` | Specify this option to copy archived WAL files from the BART backup catalog to `/archived_wals` directory.
If recovery settings are saved in the `postgresql.auto.conf` file for point-in-time recovery, the `restore_command` retrieves the WAL files from `/archived_wals` for the database server archive recovery.
If the `-c` option is omitted and the `copy_wals_during_restore` parameter in the BART configuration file is not enabled in a manner applicable to this database server, the `restore_command` in the `postgresql.auto.conf` file is generated by default to retrieve the archived WAL files directly from the BART backup catalog. See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/latest/bart_inst/) for information about the `copy_wals_during_restore` parameter. | +| `--disable-checksum` | While restoring a backup, specify this option to skip verifying the MD5 or SHA256 checksum files.
If you set the `--checksum-algorithm=NONE` option with the [BART scanner](../04_running_the_bart_wal_scanner/#running_the_bart_wal_scanner) or while taking a [backup](03_backup/#backup), you must specify the `--disable checksum` option while restoring an incremental backup. | diff --git a/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/03_basic_bart_subcommand_usage/09_delete.mdx b/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/03_basic_bart_subcommand_usage/09_delete.mdx new file mode 100644 index 00000000000..7f9836ad724 --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/03_basic_bart_subcommand_usage/09_delete.mdx @@ -0,0 +1,34 @@ +--- +title: "DELETE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/delete.html" +--- + + + +The `DELETE` subcommand removes the subdirectory and data files from the BART backup catalog for the specified backups along with its archived WAL files. + +**Syntax:** + +```text +bart DELETE –s + -i { all | + [']{ | },... }['] + } + [ -n ] +``` + +!!! Note + While invoking the `DELETE` subcommand, you must specify a specific database server. + +For database servers under a retention policy, there are conditions where certain backups may not be deleted. See [Deletions Permitted Under a Retention Policy](../02_managing_backups_using_a_retention_policy/04_managing_the_backups_based_on_the_retention_policy/#deletions_permitted_under_retention_policy) for information about permitted backup deletions. + +The following table describes the command options: + +| Options | Description | +| -------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s `

`--server ` | `` is the name of the database server whose backups are to be deleted. | +| `-i { all \| [']{ \| },... }['] }`

`--backupid { all \| [']{ \| },... }['] }` | `` is the backup identifier of the backup to be deleted and `` is the user-defined alphanumeric name for the backup.
Multiple backup identifiers and backup names may be specified in a comma-separated list. The list must be enclosed within single quotes if there is any white space appearing before or after each comma.
If `all` is specified, all of the backups and their archived WAL files for the specified database server are deleted. | +| `-n`
`--dry-run` | Displays the results as if the deletions were done, however, no physical removal of the files are actually performed. In other words, a test run is performed so that you can see the potential results prior to actually initiating the action.
After the deletion, the BART backup catalog for the database server no longer contains the corresponding directory for the deleted backup ID. The `archived_wals` subdirectory no longer contains the WAL files of the backup. | diff --git a/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/03_basic_bart_subcommand_usage/index.mdx b/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/03_basic_bart_subcommand_usage/index.mdx new file mode 100644 index 00000000000..e7d51affa18 --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/03_basic_bart_subcommand_usage/index.mdx @@ -0,0 +1,50 @@ +--- +title: "Basic BART Subcommand Usage" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/basic_bart_subcommand_usage.html" +--- + + + +This section briefly describes the BART subcommands and options. You can invoke the `bart` program (located in the `/bin` directory) with the desired options and subcommands to manage your BART installation. + +To view examples of BART subcommands, see the *EDB Backup and Recovery Reference Guide* available at the [EDB website](/bart/latest/bart_ref/). + +**Syntax for invoking BART**: + + `bart [ general_option ]... [ subcommand ] [subcommand_option ]...` + +- When invoking a subcommand, the subcommand name is not case-sensitive (that is, the subcommand can be specified in uppercase, lowercase, or mixed case). +- Each subcommand has a number of its own applicable options that are specified following the subcommand. All options are available in both single-character and multi-character forms. +- Keywords are case-sensitive; options are generally specified in lowercase unless specified otherwise in this section. +- When invoking BART, the current user must be the BART user account (operating system user account used to run the BART command line program). For example, enterprisedb or postgres can be selected as the BART user account when the managed database servers are Advanced Server or PostgreSQL respectively. +- The chosen operating system user account must own the BART backup catalog directory, be able to run the `bart` program and the `bart scanner` program, and have a passwordless SSH/SCP connection established between database servers managed by BART. + +You can specify one or more of the following general options: + +| Options | Description | +| ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-h` `--help` | Displays general syntax and information on BART usage. All subcommands support a help option (`-h`, `--help`). If the help option is specified, information is displayed regarding that particular subcommand. The subcommand, itself, is not executed. | +| `-v` `--version` | Displays the BART version information. | +| `-d` `--debug` | Displays debugging output while executing BART subcommands. | +| `-c ` `--config-path ` | Specifies `config_file_path` as the full directory path to a BART configuration file. Use this option if you do not want to use the default BART configuration file `/etc/bart.cfg`. | + +**Troubleshooting: Setting Path Environment Variable** + +If execution of BART subcommands fails with the following error message, then you need to set the `LD_LIBRARY_PATH` to include the `libpq` library directory: + + `./bart: symbol lookup error: ./bart: undefined symbol: PQping` + +**Workaround:** Set the `LD_LIBRARY_PATH` environment variable for the BART user account to include the directory containing the `libpq` library. This directory is `POSTGRES_INSTALL_HOME/lib`. + +It is suggested that the `PATH` and the `LD_LIBRARY_PATH` environment variable settings be placed in the BART user account’s profile. See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/latest/bart_inst/) for details. + +In the following sections, the `help` option is omitted from the syntax diagrams for the purpose of providing readability for the subcommand options. + +
+ +check_config init backup show_servers show_backups verify_chksum manage restore delete + +
diff --git a/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/04_running_the_bart_wal_scanner.mdx b/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/04_running_the_bart_wal_scanner.mdx new file mode 100644 index 00000000000..f4a4a6e5cbd --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/04_running_the_bart_wal_scanner.mdx @@ -0,0 +1,61 @@ +--- +title: "Running the BART WAL Scanner" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/running_the_bart_wal_scanner.html" +--- + + + +Use the BART WAL scanner to invoke the `bart-scanner` program located in the `BART_HOME/bin` directory. When invoking the WAL scanner, the current user must be the BART user account. + +**Syntax:** + +```text +bart-scanner + [ -d ] + [ -c ] + { –h | + -v | + --daemon | + -p | + | + RELOAD | + STOP + --checksum-algorithm } +``` + +!!! Note + For clarity, the syntax diagram shows only the single-character option form (for example, `-d`), but the multi-character option form (for example, `--debug`) is supported as well. + +The WAL scanner processes each WAL file to find and record modified blocks in a corresponding modified block map (MBM) file. The default approach is that the WAL scanner gets notified whenever a new WAL file is added to the `archived_wals` directory specified in the `archive_path` parameter of the configuration file. It then scans the WAL file and produces the MBM file. + +The default approach does not work in some cases; for example when the WAL files are shipped to the `archive_path` using the Network File System (NFS) and also in case of some specific platforms. This results in the WAL files being copied to the `archived_wals` directory, but the WAL scanner does not scan them (as WAL scanner is not aware of WAL file) and produce the MBM files. This results in the failure of an incremental backup. This can be avoided by using the timer-based WAL scanning approach, which is done by using the `scan_interval` parameter in the BART configuration file. The value for `scan_interval` is the number of seconds after which the WAL scanner will initiate force scanning of the new WAL files. See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/latest/bart_inst/) for more information about `scan_interval` parameter. + +!!! Note + After upgrading to BART 2.6, users who have set this parameter to a non-default value may see increased CPU consumption on the part of bart-scanner. If this is an issue, consider increasing the configured value of scan_interval parameter, or removing the setting if it is not required. + +When the `bart-scanner` program is invoked, it forks a separate process for each database server enabled with the `allow_incremental_backups` parameter. + +The WAL scanner processes can run in either the foreground or background depending upon usage of the `--daemon` option. Use the `--daemon` option to run the WAL scanner process in the background so that all output messages can be viewed in the BART log file. If the `--daemon` option is omitted, the WAL scanner process runs in the foreground and all output messages can be viewed from the terminal running the program as well as in the BART log file. + +See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/latest/bart_inst/) for additional information about WAL scanning, `allow_incremental_backups`, and `logfile` parameters. + +!!! Note + The BART user account’s `LD_LIBRARY_PATH` environment variable may need to be set to include the directory containing the `libpq` library if invocation of the WAL scanner program fails. See [Basic BART Subcommand Usage](03_basic_bart_subcommand_usage/#basic_bart_subcommand_usage) for information about setting the `LD_LIBRARY_PATH` environment variable. + +The following table describes the scanner options: + +| Options | Description | +| ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-h` `--help` | Displays general syntax and information on WAL scanner usage. | +| `-v` `--version` | Displays the WAL scanner version information. | +| `-d` `--debug` | Displays debugging output while executing the WAL scanner with any of its options. | +| `-c ` `--config-path ` | Use this option to specify the `config_file_path` of a BART configuration file if you do not want to use the default BART configuration file path `BART_HOME/etc/bart.cfg`. | +| `--daemon` | Runs the WAL scanner as a background process. | +| `-p ` `--print ` | Use this option to specify the full directory path to an MBM file whose content is to be printed. The directory specified in the `archive_path` parameter in the `bart.cfg` file contains the MBM files. | +| `` | Specify the full directory path to a WAL file to be scanned. The directory specified in the `archive_path` parameter in the `bart.cfg` file contains the WAL files. Use this option if a WAL file in the archive path is missing its MBM file. This option is to be used for assisting the EnterpriseDB support team for debugging problems that may have been encountered. | +| `RELOAD` | Reloads the BART configuration file. The keyword `RELOAD` is not case-sensitive. The `RELOAD` option is useful if you make changes to the configuration file after the WAL scanner has been started. It will reload the configuration file and adjust the WAL scanners accordingly. For example, if a server section allowing incremental backups is removed from the BART configuration file, then the process attached to that server will stop. Similarly, if a server allowing incremental backups is added, a new WAL scanner process will be launched to scan the WAL files of that server. | +| `STOP` | Stops the WAL scanner. The keyword `STOP` is not case-sensitive. | +| `--checksum-algorithm` | While invoking the WAL scanner, you can specify one of the following values with the `--checksum-algorithm` option: `--checksum-algorithm=MD5` (default) to generate MD5 checksum files. `--checksum-algorithm=SHA256` to generate SHA256 checksum files. `--checksum-algorithm=NONE` to skip generating checksum files. | diff --git a/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/index.mdx b/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/index.mdx new file mode 100644 index 00000000000..a076b82b5e9 --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_user/03_using_bart/index.mdx @@ -0,0 +1,19 @@ +--- +title: "Using BART" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/using_bart.html" +--- + + + +After installing and configuring the BART host and the database servers, you can start using BART. + +This section describes how to perform backup and recovery management operations using BART. Review the sections that follow before proceeding with any BART operation. + +
+ +bart_management_overview managing_backups_using_a_retention_policy basic_bart_subcommand_usage running_the_bart_wal_scanner + +
diff --git a/product_docs/docs/bart/2.6.2/bart_user/04_using_tablespaces.mdx b/product_docs/docs/bart/2.6.2/bart_user/04_using_tablespaces.mdx new file mode 100644 index 00000000000..94d5450778a --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_user/04_using_tablespaces.mdx @@ -0,0 +1,59 @@ +--- +title: "Using Tablespaces" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/using_tablespaces.html" +--- + + + +If the database cluster contains user-defined tablespaces (that is, tablespaces created with the `CREATE TABLESPACE` command): + +- You can take full backups with the `BACKUP` subcommand in either tar (`-Ft`) or plain text (`-Fp`) backup file format. +- You must take incremental backups in the plain text (`-Fp`) backup file format. +- You can take full backups using the transaction log streaming method (xlog_method = stream in the BART configuration file) `--with-pg_basebackup` and the `BACKUP` subcommand in either tar (`-Ft`) or plain text (`-Fp`) backup file format. + +!!! Note + If the particular database cluster you plan to back up contains tablespaces created by the `CREATE TABLESPACE` command, then you must set the `tablespace_path` parameter in the BART configuration file before you perform a BART `RESTORE` operation. + +The `tablespace_path` parameter specifies the directory paths to which you want the tablespaces to be restored. It takes the following format: + + `OID_1=tablespace_path_1;OID_2=tablespace_path_2 ...` + +Where `OID_1`, `OID_2`, … are the Object Identifiers of the tablespaces. You can find the OIDs of the tablespaces and their corresponding soft links to the directories by listing the contents of the `POSTGRES_INSTALL_HOME/data/pg_tblspc` subdirectory as shown in the following example: + +```text +[root@localhost pg_tblspc ]# pwd +/opt/PostgresPlus/9.6AS/data/pg_tblspc +[root@localhost pg_tblspc]# ls -l +total 0 +lrwxrwxrwx 1 enterprisedb enterprisedb 17 Aug 22 16:38 16644 -> /mnt/tablespace_1 +lrwxrwxrwx 1 enterprisedb enterprisedb 17 Aug 22 16:38 16645 -> /mnt/tablespace_2 +``` + +The OIDs are `16644` and `16645` to directories `/mnt/tablespace_1` and `/mnt/tablespace_2`, respectively. + +If you later wish to restore the tablespaces to the same locations as indicated in the preceding example, the BART configuration file must contain the following entry: + +```text +[ACCTG] +host = 127.0.0.1 +port = 5444 +user = enterprisedb +cluster_owner = enterprisedb +tablespace_path = 16644=/mnt/tablespace_1;16645=/mnt/tablespace_2 +description = "Accounting" +``` + +If you later wish to restore the tablespaces to different locations, specify the new directory locations in the `tablespace_path` parameter. + +In either case, the directories specified in the `tablespace_path` parameter must exist and be empty at the time you perform the `BART RESTORE` operation. + +If the database server is running on a remote host (in other words you are also using the `remote_host` configuration parameter or will specify the `--remote-host` option with the `RESTORE` subcommand), the specified tablespace directories must exist on the specified remote host. + +To view example of backing up and restoring a database cluster on a remote host containing tablespaces, see the *EDB Backup and Recovery Reference Guide* available at the [EDB website](/bart/latest/bart_ref/). + +The directories must be owned by the user account with which you intend to start the database server (typically the Postgres user account) with no access by other users or groups as is required for the directory path to which the main full backup is to be restored. + +To view a sample BART managed backup and recovery system consisting of both local and remote database servers, see the *EDB Backup and Recovery Reference Guide* available at the [EDB website](/bart/latest/bart_ref/). diff --git a/product_docs/docs/bart/2.6.2/bart_user/images/EDB_logo.png b/product_docs/docs/bart/2.6.2/bart_user/images/EDB_logo.png new file mode 100644 index 00000000000..39a54822d85 Binary files /dev/null and b/product_docs/docs/bart/2.6.2/bart_user/images/EDB_logo.png differ diff --git a/product_docs/docs/bart/2.6.2/bart_user/images/copy_1.png b/product_docs/docs/bart/2.6.2/bart_user/images/copy_1.png new file mode 100644 index 00000000000..b15833dc37d Binary files /dev/null and b/product_docs/docs/bart/2.6.2/bart_user/images/copy_1.png differ diff --git a/product_docs/docs/bart/2.6.2/bart_user/images/edb.png b/product_docs/docs/bart/2.6.2/bart_user/images/edb.png new file mode 100644 index 00000000000..71e5bdde787 Binary files /dev/null and b/product_docs/docs/bart/2.6.2/bart_user/images/edb.png differ diff --git a/product_docs/docs/bart/2.6.2/bart_user/images/edb_logo.svg b/product_docs/docs/bart/2.6.2/bart_user/images/edb_logo.svg new file mode 100644 index 00000000000..f24d1dfefee --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_user/images/edb_logo.svg @@ -0,0 +1,19 @@ + + + edb-logo-disc-dark + + + + \ No newline at end of file diff --git a/product_docs/docs/bart/2.6.2/bart_user/index.mdx b/product_docs/docs/bart/2.6.2/bart_user/index.mdx new file mode 100644 index 00000000000..50504d9e3db --- /dev/null +++ b/product_docs/docs/bart/2.6.2/bart_user/index.mdx @@ -0,0 +1,17 @@ +--- +navTitle: Backup and Recovery Guide +title: "EDB Postgres Backup and Recovery User Guide" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/genindex.html" + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/introduction.html" + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/conclusion.html" + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/index.html" +--- + +
+ +introduction overview using_bart using_tablespaces conclusion + +
diff --git a/product_docs/docs/bart/2.6.2/bart_v2.6.2_documentation.pdf b/product_docs/docs/bart/2.6.2/bart_v2.6.2_documentation.pdf new file mode 100644 index 00000000000..d1c309023b4 Binary files /dev/null and b/product_docs/docs/bart/2.6.2/bart_v2.6.2_documentation.pdf differ diff --git a/product_docs/docs/bart/2.6.2/index.mdx b/product_docs/docs/bart/2.6.2/index.mdx new file mode 100644 index 00000000000..8993f4a09fd --- /dev/null +++ b/product_docs/docs/bart/2.6.2/index.mdx @@ -0,0 +1,16 @@ +--- +title: Backup and Recovery Tool +directoryDefaults: + description: "EDB Backup and Recovery Tool Version 2.6.1 Documentation and release notes. A tool to manage and configure PostgreSQL backups and disaster recovery." +navigation: + - "#Getting Started" + - bart_inst + - bart_qs_7 + - bart_qs_8 + - "#Guides" + - bart_user + - bart_ref +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/p/edb-backup-and-recovery-tool/2.6.1" +--- diff --git a/product_docs/docs/bart/2.6/bart_inst/02_installing_bart.mdx b/product_docs/docs/bart/2.6/bart_inst/02_installing_bart.mdx new file mode 100644 index 00000000000..710e39d9228 --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_inst/02_installing_bart.mdx @@ -0,0 +1,429 @@ +--- +title: 'Installing BART' + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/installation-getting-started/installation-upgrade-guide/2.6.1/installing_bart.html" +--- + +This section will walk you through performing a fresh installation of BART on a host. Installation instructions are organized into the following platform/installer specific sections: + +- [Installing BART on a CentOS](#installing-bart-on-a-centos-host) +- [Installing BART on a RHEL Host](#installing-bart-on-a-rhel-host) +- [Installing BART on a CentOS or RHEL Host](#installing-bart-on-a-rhelcentos-7-ppcle-host) +- [Installing BART on a Debian or Ubuntu Host](#installing-bart-on-a-debian-or-ubuntu-host) +- [Installing BART on an SLES 12 Host](#installing-bart-on-an-sles-12-host) + +!!! Note + If you are using the pdf version of this document, using cut/paste to copy command may result in extra spaces or carriage returns in the pasted command. If a command fails, check the command carefully for additional characters. + +## Installing BART on a CentOS Host + +The following section demonstrates installing BART on a CentOS host using an RPM package.  This section assumes that the user has some knowledge of installation and system administration procedures, and has administrative privileges on the host. + +1. To install the repository configuration, assume superuser privileges and invoke one of the following platform-specific commands: + + On CentOS 7: + + ```text + yum -y install https://yum.enterprisedb.com/edbrepos/edb-repo-latest.noarch.rpm + ``` + + On CentOS 8: + + ```text + dnf -y install https://yum.enterprisedb.com/edbrepos/edb-repo-latest.noarch.rpm + ``` + +2. Replace the `USERNAME:PASSWORD` in the following command with the username and password of a registered EnterpriseDB user: + + ```text + sed -i "s@:@USERNAME:PASSWORD@" /etc/yum.repos.d/edb.repo + ``` + + To request credentials for the repository, visit the [EDB website](https://www.enterprisedb.com/user). + +3. Before installing BART, execute the following command to install the Extra Packages for Enterprise Linux (EPEL) release package: + + On CentOS 7: + + ```text + yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm + ``` + + On CentOS 8: + + ```text + dnf -y install epel-release + ``` + +4. For CentOS 8, enable the PowerTools repository to satisfy EPEL package dependencies: + + ```text + dnf config-manager --set-enabled PowerTools + ``` + +5. For CentOS 8, disable the built-in PostgreSQL module: + + ```text + dnf -qy module disable postgresql + ``` + +6. Optionally, install the `pg_basebackup` utility program using the server client package. If you do not already have the `pg_basebackup` program installed on the BART host, you can install a limited number of files that include the `pg_basebackup` program by invoking the following command: + + On CentOS 7: + + ```text + yum install edb-as-server-client + ``` + + On CentOS 8: + + ```text + dnf install edb-as-server-client + ``` + + In the above command, replace `` with the required Advanced Server version. The `pg_basebackup` version must be the same or more recent than the database server to be backed up. For example, `pg_basebackup` version 10 can be used to back up database server version 10, but cannot be used to back up database server version 11. + +7. Use the following command to install BART: + + On CentOS 7: + + ```text + yum -y install edb-bart + ``` + + On CentOS 8: + + ```text + dnf -y install edb-bart + ``` + + Repeat the installation process described in this section to install BART on each remote host on which an incremental backup is to be restored. + + To verify the BART installation, navigate to the `/usr/edb/bart/bin` directory and execute the following command: + + ```text + bart --version + ``` + + The `bart --version` command should return the current BART version. If the `bart --version` command returns an error stating the PATH is not available after switching from the root user to another BART user account, adjust the setting of the `PATH` environment variable to include the directory location of the BART `bin` subdirectory in the `~/.bashrc` or `~/.bash_profile` files of the following user accounts: + + - The BART user account on the BART host. See [Configuring BART](03_configuring_bart/#path) for details. + - The remote user account on the remote host to which incremental backups are to be restored. For details, see the *EDB Backup and Recovery User Guide* available at the [EDB website](/bart/2.6/bart_user/). + + Upon successful installation, BART is installed in the `BART_HOME` directory: + + `/usr/edb/bart` + + The installation includes the following files: + +| File Name | Location | Description | +| ------------------- | ----------------- | ------------------------------------- | +| bart | ``/bin | BART command line, executable program | +| bart-scanner | ``/bin | BART WAL scanner program | +| bart.cfg.sample | ``/etc | Sample BART configuration file | +| xlogreader_ident.so | ``/lib | Libraries supporting WAL versions | +| bart_license.txt | `` | License agreement | + +After BART is installed successfully, you need to [configure the installation](03_configuring_bart/#configuration). + +## Installing BART on a RHEL Host + +The following section demonstrates installing BART on a RHEL host using an RPM package.  This section assumes that the user has some knowledge of installation and system administration procedures, and has administrative privileges on the host. + +1. To install the repository configuration, assume superuser privileges and invoke one of the following platform-specific commands: + + On RHEL 7: + + ```text + yum -y install https://yum.enterprisedb.com/edbrepos/edb-repo-latest.noarch.rpm + ``` + + On RHEL 8: + + ```text + dnf -y install https://yum.enterprisedb.com/edbrepos/edb-repo-latest.noarch.rpm + ``` + +2. Replace the `USERNAME:PASSWORD` in the following command with the username and password of a registered EnterpriseDB user: + + ```text + sed -i "s@:@USERNAME:PASSWORD@" /etc/yum.repos.d/edb.repo + ``` + + To request credentials for the repository, visit the [EDB website](https://www.enterprisedb.com/user). + +3. Before installing BART, execute the following command to install the Extra Packages for Enterprise Linux (EPEL) release package: + + On RHEL 7: + + ```text + yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm + ``` + + On RHEL 8: + + ```text + dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm + ``` + +4. Enable the repository: + + On RHEL 7, enable the `optional, extras`, and `HA` repositories to satisfy EPEL package dependencies: + + ```text + subscription-manager repos --enable "rhel-*-optional-rpms" --enable "rhel-*-extras-rpms" --enable "rhel-ha-for-rhel-*-server-rpms" + ``` + + On RHEL 8, enable the `codeready-builder-for-rhel-8-*-rpms` repository to satisfy EPEL packages dependency: + + ```text + ARCH=$( /bin/arch ) + + subscription-manager repos --enable "codeready-builder-for-rhel-8-${ARCH}-rpms" + ``` + +5. For RHEL 8, disable the built-in PostgreSQL module: + + ```text + dnf -qy module disable postgresql + ``` + +6. Optionally, install the `pg_basebackup` utility program using the server client package. If you do not already have the `pg_basebackup` program installed on the BART host, you can install a limited number of files that include the `pg_basebackup` program by invoking the following command: + + On RHEL 7: + + ```text + yum install edb-as-server-client + ``` + + On RHEL 8: + + ```text + dnf install edb-as-server-client + ``` + + In the above command, replace `` with the required Advanced Server version. The `pg_basebackup` version must be the same or more recent than the database server to be backed up. For example, `pg_basebackup` version 10 can be used to back up database server version 10, but cannot be used to back up database server version 11. + +7. Use the following command to install the BART: + + On RHEL 7: + + ```text + yum -y install edb-bart + ``` + + On RHEL 8: + + ```text + dnf -y install edb-bart + ``` + + Repeat the installation process described in this section to install BART on each remote host on which an incremental backup is to be restored. + + To verify the BART installation, navigate to the `/usr/edb/bart/bin` directory and execute the following command: + + ```text + bart --version + ``` + + The `bart --version` command should return the current BART version. If the `bart --version` command returns an error stating the PATH is not available after switching from the root user to another BART user account, adjust the setting of the `PATH` environment variable to include the directory location of the BART `bin` subdirectory in the `~/.bashrc` or `~/.bash_profile` files of the following user accounts: + + - The BART user account on the BART host. See [Configuring BART](03_configuring_bart/#path) for details. + - The remote user account on the remote host to which incremental backups are to be restored. For details, see the *EDB Backup and Recovery User Guide* available at the [EDB website](/bart/2.6/bart_user/). + + Upon successful installation, BART is installed in the `BART_HOME` directory: + + `/usr/edb/bart` + + The installation includes the following files: + +| File Name | Location | Description | +| ------------------- | ----------------- | ------------------------------------- | +| bart | ``/bin | BART command line, executable program | +| bart-scanner | ``/bin | BART WAL scanner program | +| bart.cfg.sample | ``/etc | Sample BART configuration file | +| xlogreader_ident.so | ``/lib | Libraries supporting WAL versions | +| bart_license.txt | `` | License agreement | + +After BART is installed successfully, you need to [configure the installation](03_configuring_bart/#configuration). + + + +## Installing BART on a RHEL/CentOS 7 PPCLE Host + +The following section demonstrates installing BART on a RHEL host using an RPM package.  This section assumes that the user has some knowledge of installation and system administration procedures, and has administrative privileges on the host. + +1. Install Advance Toolchain: + + ```text + rpm --import https://public.dhe.ibm.com/software/server/POWER/Linux/toolchain/at/redhat/RHEL7/gpg-pubkey-6976a827-5164221b + + cat > /etc/yum.repos.d/advance-toolchain.repo <:@USERNAME:PASSWORD@" /etc/yum.repos.d/edb.repo + ``` + + To request credentials for the repository, visit the [EDB website](https://www.enterprisedb.com/user). + +4. Before installing BART, execute the following command to install the Extra Packages for Enterprise Linux (EPEL) release package: + + ```text + yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm + ``` + +5. On RHEL 7, enable the `optional, extras`, and `HA` repositories to satisfy EPEL package dependencies: + + ```text + subscription-manager repos --enable "rhel-*-optional-rpms" --enable "rhel-*-extras-rpms" --enable "rhel-ha-for-rhel-*-server-rpms" + ``` + +6. Invoke the following command to install BART: + + ```text + yum -y install edb-bart + ``` + + + +## Installing BART on a Debian or Ubuntu Host + +Perform the following steps to install a Debian package using the EnterpriseDB apt repository. + +To request credentials for the repository, visit the [EDB website](https://www.enterprisedb.com/repository-access-request). + +1. Assume the superuser privileges. + + ```text + sudo su - + ``` + +2. To configure the EnterpriseDB repository on Debian 9, Ubuntu 18, and Ubuntu 20: + + ```text + sh -c 'echo "deb https://username:password@apt.enterprisedb.com/$(lsb_release -cs)-edb/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/edb-$(lsb_release -cs).list' + ``` + + On Debian 10: + + a. Set up the EnterpriseDB repository: + + ```text + sh -c 'echo "deb [arch=amd64] https://apt.enterprisedb.com/$(lsb_release -cs)-edb/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/edb-$(lsb_release -cs).list' + ``` + + b. Substitute your EnterpriseDB credentials for the `username` and `password` placeholders in the following command: + + ```text + sh -c 'echo "machine apt.enterprisedb.com login password " > /etc/apt/auth.conf.d/edb.conf' + ``` + +3. Add support to your system for secure APT repositories. + + ```text + apt-get install apt-transport-https + ``` + +4. Add the EDB signing key; When invoking the command, replace the `username` and `password` with the credentials provided by EnterpriseDB. + + ```text + wget -q -O - https://apt.enterprisedb.com/edb-deb.gpg.key | apt-key add – + ``` + +5. Update the repository metadata. + + ```text + apt-get update + ``` + +6. Install the Debian package. + + ```text + apt-get install edb-bart + ``` + + + +## Installing BART on an SLES 12 Host + +This section provides instructions for installing BART on an SLES 12 SP4 host using the zypper package manager. BART is supported on SLES SP4 and SP5 versions. + +1. Assume superuser privileges. + + ```text + sudo su - + ``` + +2. Use the following command to add the EDB repository to your SLES host: + + ```text + zypper addrepo https://zypp.enterprisedb.com/suse/edb-sles.repo + ``` + +3. Invoke the following command to refresh the metadata: + + ```text + zypper refresh + ``` + +4. Install `SUSEConnect` to register the host with SUSE to allow access to SUSE repositories: + + ```text + zypper install SUSEConnect + ``` + +5. Register the host with SUSE to allow access to SUSE repositories and replace `'REGISTRATION_CODE'` and `'EMAIL'` with your SUSE registration information: + + ```text + SUSEConnect -r 'REGISTRATION_CODE' -e 'EMAIL' + ``` + + ```text + SUSEConnect -p PackageHub/12.4/x86_64 + ``` + + ```text + SUSEConnect -p sle-sdk/12.4/x86_64 + ``` + +6. Install the following repository for PEM dependencies: + + ```text + zypper addrepo https://download.opensuse.org/repositories/Apache:/Modules/SLE_12_SP4/Apache:Modules.repo + ``` + +7. Refresh the metadata: + + ```text + zypper refresh + ``` + +8. Then, use the zypper utility to install BART: + + ```text + zypper -n install edb-bart + ``` diff --git a/product_docs/docs/bart/2.6/bart_inst/03_configuring_bart.mdx b/product_docs/docs/bart/2.6/bart_inst/03_configuring_bart.mdx new file mode 100644 index 00000000000..29ca4a2c1a8 --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_inst/03_configuring_bart.mdx @@ -0,0 +1,643 @@ +--- +title: "Configuring BART" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/installation-getting-started/installation-upgrade-guide/2.6.1/configuring_bart.html" +--- + + + +To configure BART, you must establish the BART user account, [configure the BART host](#configuring-the-bart-host), and [configure the database server](#configuring_database_server) that will be backed up. + + + +## Establishing the BART User Account + +The BART user account is an operating system user that will run the BART command line program. The BART user account must: + +- own the BART backup catalog. +- be able to run the `bart` program and the `bart-scanner` program. +- be able to establish a SSH/SCP connection to and from each database server managed by BART. + +You can optionally use the `enterprisedb` database user as the BART user account for an Advanced Server database and `postgres` database user as the BART user account for a PostgreSQL server. If you do not wish to use an existing database user as the BART user account, you must create an operating system user to assume the role. + + + +## Configuring BART and Database Server + +As stated earlier, to configure BART, you must [configure the BART host](#configuring-the-bart-host) as well as the [database server](#configuring_database_server). The following table acts as a configuration parameter reference listing the mandatory and optional parameters with default values for `[SERVER]` as well as `[BART]` sections. + +- Parameters set in the `[BART]` section are applicable to all BART managed database servers. +- Parameters set in the `Server` section are applicable only to the specific server; the `Server` parameter setting overrides the `[BART]` section setting. + +For information about configuring BART host parameters, see the [BART Host Parameter Reference](#bart) and for information about configuring the database server parameters, see the [Database Server Parameter Reference](#server). + +| **Parameter** | **Type** | **Default** | **\[SERVER]** | **\[BART]** | +| -------------------------- | --------- | ------------------------------------------------------------ | ------------- | ----------- | +| `[BART]` | Mandatory | N/A | N/A | Yes | +| `` | Mandatory | N/A | N/A | Yes | +| `` | Mandatory | N/A | N/A | Yes | +| `` | Mandatory | N/A | N/A | Yes | +| `retention_policy` | Optional | `BACKUPS` | Yes | Yes | +| `wal_compression` | Optional | `Disabled` | Yes | Yes | +| `copy_wals_during_restore` | Optional | `Disabled` | Yes | Yes | +| `xlog_method` | Optional | `fetch` | Yes | Yes | +| `logfile` | Optional | `/tmp/bart.log` | N/A | Yes | +| `scanner_logfile` | Optional | `/tmp/bart_scanner.log` | N/A | Yes | +| `` | Optional | `/tmp` | N/A | Yes | +| `` | Optional | `` | N/A | Yes | +| `` | Optional | `1` | Yes | Yes | +| `` | Optional | `49152` | Yes | Yes | +| `` | Optional | `0` | Yes | Yes | +| `` | Optional | `20 seconds` | Yes | Yes | +| `` | Optional | `1` | Yes | Yes | +| `[Server Name]` | Mandatory | N/A | Yes | N/A | +| `` | Optional | N/A | Yes | N/A | +| `host` | Mandatory | N/A | Yes | N/A | +| `port` | Mandatory | `5444` for EPAS; `5432` for Postgres | Yes | N/A | +| `user` | Mandatory | N/A | Yes | N/A | +| `` | Optional | `BART backup catalog` | Yes | N/A | +| `` | Optional | N/A | Yes | N/A | +| `` | Mandatory | `enterprisedb` for EPAS

`postgres` for PostgreSQL | Yes | N/A | +| `` | Optional | N/A | Yes | N/A | +| `` | Optional | N/A | Yes | N/A | +| `allow_incremental_backup` | Optional | `Disabled` | Yes | N/A | +| `description` | Optional | N/A | Yes | N/A | + + + +### Configuring the BART Host + +To configure the BART host, perform the following steps on the BART host as a root user: + +**Step 1.** Navigate to the `usr/edb/bart/etc` directory and make a copy of the `bart.cfg.sample` file to create the `bart.cfg` file that will contain the parameter settings. + +**Step 2.** Confirm that the Postgres `pg_basebackup` utility program is installed on the BART host. The `pg_basebackup` utility resides in the `bin` directory under your Postgres installation. + + + +**Step 3.** Ensure the `LD_LIBRARY_PATH` environment variable includes the location of the `libpq` library. If your `libpq` library does not reside in the default location (`POSTGRES_INSTALL_HOME/lib`), you must add the library path to the `LD_LIBRARY_PATH` environment variable in the BART user account’s profile (`bash_profile`) located in `/home/`: + +```text +# .bash_profile +# Get the aliases and functions +if [ -f ~/.bashrc ]; then +. ~/.bashrc +fi +# User specific environment and startup programs +export LD_LIBRARY_PATH=/usr/edb/as11/lib:$LD_LIBRARY_PATH +``` + +**Step 4.** Create the BART backup catalog and ensure the BART user account holds privileges on the BART backup catalog. In the following example, the BART configuration file specifies `/opt/backup` as the parent directory for the BART backup catalog in the `` parameter: + +```text +[BART] + +bart_host = bartuser@192.168.2.22 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log +``` + +In the following example, `bartuser` is the BART user account. The example creates and sets the ownership and permissions on the BART backup catalog: + +```text +su root +mkdir /opt/backup +chown bartuser /opt/backup +chgrp bartuser /opt/backup +chmod 700 /opt/backup +``` + +If the subdirectory does not exist, BART creates a subdirectory for each database server listed in the configuration file when you invoke the `bart` command line program. + +**Step 5.** Use your choice of editor to open the BART configuration file (located in the `usr/edb/bart/etc` directory) and edit the configuration as required. You must add the mandatory parameters to the `[BART]` section. Default values may be used for optional parameters. + +The following table describes the `[BART]` host parameters. + + + +| **Parameters/Placeholder** | **Type** | **Description** | +| -------------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `[BART}` | Mandatory | Identifies the global section of the configuration file. It must be named BART. | +| `bart_host` | Mandatory | Specify the bart user name and the IP address of the bart host on which the BART utility resides. You must specify it in the form of <bart_user>@<bart_host_address>. | +| `backup_path` | Mandatory | Specify the path to the file system parent directory where all BART backups are stored. | +| `pg_basebackup_path` | Mandatory | Specify the path to the `pg_basebackup` program that you installed on the BART host. For information about `pg_basebackup` version-specific restrictions, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/2.6/bart_user/). | +| `wal_compression` | Optional | Set this parameter to `enabled` to compress the archived WAL files in gzip format in the BART backup catalog when the `MANAGE` subcommand is invoked. By default it is set to `disabled`. The gzip compression program must be in the BART user account’s `PATH` and the WAL compression setting must not be enabled for those database servers where you need to take incremental backups. | +| `copy_wals_during_restore` | Optional | Set this parameter to `enabled` to copy the archived WAL files from the BART backup catalog to the `restore_path/archived_wals` directory prior to the database server archive recovery. Enabling this option helps you save time during the restore operation. Set this parameter to `disabled` (default) to retrieve the archived WAL files directly from the BART backup catalog during the database server archive recovery. During the restore operation, recovery settings will be saved in the `postgresql.auto.conf` file. The `restore_command` in the `postgresql.auto.conf` file will be determined by the value specified in the `copy_wals_during_restore` parameter. If the `RESTORE` subcommand is invoked with the `-c` option, the archived WAL files are copied from the BART backup catalog to the `restore_path/archived_wals` directory, thus overriding any setting of the `copy_wals_during_restore` parameter. If the `RESTORE` subcommand is invoked without the `-c` option, the value specified by the `copy_wals_during_restore` parameter is used. | +| `xlog_method` | Optional | Specify how the transaction log is collected during the execution of `pg_basebackup` through the `BACKUP` subcommand. Set `xlog_method` to `fetch` (default) to collect the transaction log files after the backup is completed. Set to `stream` to stream the transaction log in parallel with the full backup creation. | +| `retention_policy` | Optional | Set this parameter to determine when an active backup should be marked as `obsolete` when the `MANAGE` subcommand is used. You can specify the retention policy either in terms of number of backups or duration (days, weeks, or months). ` BACKUPS` (default), ` DAYS`, ` WEEKS`, or ` MONTHS` where `` is a positive integer. For information about managing backups using a retention policy, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/2.6/bart_user/). | +| `logfile` | Optional | Use this parameter to specify the path to the BART log file. The default log file location is `/tmp/bart.log`. The log file will be created the first time you invoke the `bart` command line program using the sample configuration file value. To change the default setting, you must delete the `bart.log` file from the `/tmp` directory and create a new log file in another directory so that a new log file will be created and owned by the new BART user account. If no path to a log file is specified, BART does not create a log file. | +| `scanner_logfile` | Optional | Use this parameter to specify the path to the XLOG/WAL scanner log file. The default location is `/tmp/bart_scanner.log`. The scanner log file will be created the first time you invoke the `bart_scanner` program using the sample configuration file value. To change the default setting, you must delete the `bart_scanner.log` file from the `/tmp` directory and create a new log file in another directory so that a new log file will be created and owned by the new BART user account. If no path to a log file is specified, BART does not create a WAL scanner log file. | +| `` | Optional | Specify the socket directory path where all BART sockets will be stored. The default directory is `/tmp`. While specifying the `bart_socket_directory` path, you must ensure that the directory exists and the BART user has the required access permissions to the directory. | +| `` | Optional | Specify a user-friendly BART socket file name. Using this option overrides the default BART socket name generated using MD5 checksum. You must shut down the bart-scanner before setting this option. You can view the `` in the `sockPath` field after starting the bart-scanner in the debug mode. This option helps in preventing the use of MD5 during the bart-scanner startup, thus making BART more compliant in FIPS mode. | +| `` | Optional | Specify the number of worker threads for copying blocks (for incremental backups) or data files (for full backup) from the database server to the `archive_path` when the `BACKUP` subcommand is invoked. The default value is `1`. The same set of worker threads are used for the compression operation when taking full backups in order to provide parallel, compressed backups when the `BACKUP` subcommand is specified with the `-z` or `-c` options. The compression operation does not apply to incremental backups. See [thread count](#thread_count) for more information. | +| `` | Optional | Specify the number of blocks of memory used for copying modified blocks from the database server to the `archive_path` when the `BACKUP` subcommand is invoked for incremental backups. The default value is 49152 blocks; each block is 8192 bytes. The maximum permitted value is 131072 blocks and the minimum permitted value is 1 block. Reduce the `` setting if the server runs out of memory while executing the `pg_read_binary_file()`. | +| `` | Optional | Specify the number of seconds after which the WAL scanner should initiate force scanning of the new WAL files. The default value is 0, which means no brute-force scanning will be started. After upgrading to the latest version of BART, users who have set this parameter to a non-default value may see increased CPU consumption on the part of bart-scanner. If this is an issue, consider increasing the configured value of `scan_interval` parameter, or removing the setting if it is not required. | +| `` | Optional | Specify the number of seconds to wait for MBM files before timing out; this parameter is applicable only for incremental backup. You must set the `scan_interval` to a value significantly less than the MBM scan timeout. The default value is 20 seconds. The `mbm_scan_timeout` parameter value must be greater than 0. If the value is 0 or negative, then an error will be displayed during an incremental backup. | +| `` | Optional | Specify the number of parallel worker processes required to stream the modified blocks of an incremental backup to the restore host. The default value is 1. | + + + +**Thread Count** + +If the `BACKUP` subcommand is invoked with the `--thread-count` option, then the number of worker threads specified by this option overrides any setting of the `thread_count` parameter in the BART configuration file. If the `BACKUP` subcommand is invoked without the `--thread-count` option, then the following determines the number of worker threads used: + +- The setting of the `thread_count` parameter in the server section of the BART configuration file overrides the setting of `thread_count` in the global section for that particular database server. +- If omitted in the server section, the setting of `thread_count` in the global section is used. +- If the `thread_count` parameter is not specified in either section, the default is 1. +- When taking a full backup, if the `thread count` in effect is only 1, then the `pg_basebackup` utility is used to take the full backup unless the `--no-pg_basebackup` option is specified with the `BACKUP` subcommand. + +`` will not be effective if the backup is taken on a standby server. + +If parallel backup is run with `N` number of worker threads, then it will initiate `N + 1` concurrent connections with the server. + +**Step 6** Invoke the `CHECK-CONFIG` subcommand, omitting the `-s` option to check the parameter settings in the BART configuration file. It should return the current BART version. + +```text +bart CHECK-CONFIG +``` + +The `CHECK-CONFIG` subcommand displays an error message if the required configuration is not properly set. You need to check the logfile to fix this. + + + +### Configuring the Database Server + +To configure the database server, you must: + +1. [Authorize SSH/SCP access without a password prompt](#authorizing_ssh_scp_access). +2. [Create and configure a replication database user](#setting_up_a_replication_database_user). +3. [Adding the database server to the configuration file (server section)](#adding_a_database_server). +4. [Enable WAL archiving of the server](#enabling_wal_archiving). +5. [Verify the server configuration settings](#verifying_configuration_settings). + +The following section will walk you through the configuration process. + +!!! Note + You must authorize SSH/SCP access and set up a replication database user before restarting the database server with WAL archiving enabled. + + + +**Authorizing SSH/SCP Access** + +BART uses the Secure Shell (`ssh`) and Secure Copy (`scp`) Linux utility programs to copy the backup and WAL files from the BART managed database servers to the BART host as well as to restore backups. + +- The client/server `ssh` and `scp` commands must not prompt for a password when establishing a connection with the target server (the server to which a passwordless connection is being made). +- A passwordless connection uses *authorized public keys* (public key of a client user account) to authenticate with the target server. +- You must add the public key of each client user account to the target user account’s authorized public keys list on the target server. + +For BART usage, there are two scenarios that require a passwordless SSH/SCP connection: + +- When connecting from each BART managed database server (SSH/SCP client) to the BART host (target SSH/SCP server) to support WAL archiving as implemented by the `archive_command` parameter. + - In this case, the database server user account should generate the public key file (`id_rsa.pub`) with the `ssh-keygen –t rsa` command on the database server host. + - The public key file name should be appended to the `~/.ssh/authorized_keys` file on the BART host. The `authorized_keys` file is in the BART user account’s home directory. +- When connecting from the BART host (SSH/SCP client) to each BART managed database server (target SSH/SCP server) for taking incremental backups and for supporting restoration of the full backup, the archived WAL files, and the modified blocks, which occurs when the BART `RESTORE` subcommand is given. + - In this case, the BART user account should generate the public key file (`id_rsa.pub`) with the `ssh-keygen –t rsa` command on the BART host. + - The public key file name should be appended to the `~/.ssh/authorized_keys` file on the database server host. The `authorized_keys` file is in the home directory of the user account that owns the directory where the database backup is to be restored. +- If backups are to be taken from a given database server host, but restored to a different database server host, the passwordless SSH/SCP connections must be configured from the BART host to the database server host from which the backup is to be taken as well as from the BART host to the database server host to which the backup is to be restored. + +See the EDB Backup and Recovery Reference Guide available at the [EDB website](/bart/2.6/bart_ref/) to view examples of creating a passwordless connection. + +**Enabling Public Key Authentication** + +The following example enables SSH/SCP access on a CentOS 7.x host; similar (platform-specific) steps will apply to other platforms/versions. + +1. In the SSH server daemon configuration file (`sshd_config`) located in the `/etc/ssh`, set the `PubkeyAuthentication` parameter to `yes`. +2. Reload the configuration file: + +```text +service sshd reload +``` + +If you get any SSH or SCP errors, examine the `/var/log/secure` log file. + +**Creating a Passwordless Connection** + +The following general instructions will walk you through generating a client’s public key file, creating the target server’s authorized public keys file, and creating a passwordless connection. + +**Step 1.** On the client system, log in as the user account that will be initiating the SSH or SCP connection. + +**Step 2.** Navigate to the user account’s home directory and check for an existing `.ssh` subdirectory. If the `.ssh` directory does not exist, create one and assign the required privileges to the user. + +**Step 3.** Generate the public key file with the following command. Accept all prompted defaults and do not specify a passphrase when prompted for one. + +```text +ssh-keygen –t rsa +``` + +The public key file named `id_rsa.pub` is created in the `.ssh` subdirectory. + +**Step 4.** While logged into the client where you just generated the public key file, use `SCP` to make a temporary copy of it on the target server: + +```text +scp ~/.ssh/id_rsa.pub @:tmp.pub +``` + +**Step 5.** Navigate into the target user account’s home directory and check for an existing `.ssh` subdirectory. If it does not exist, create one and assign the required privileges to the user. + +**Step 6.** Append the temporary, client’s public key file, `tmp.pub`, to the `authorized_keys` file. If an `authorized keys` file does not exist, create a new file, but do not completely replace any existing `authorized keys` file. + +```text +cat tmp.pub >> ~/.ssh/authorized_keys +``` + +Make sure the `authorized_keys` file is only accessible by the file owner and not by groups or other users. If the `authorized_keys` file does not have the required permission setting or it was newly created, change the file permissions as follows: + +```text +chmod 600 ~/.ssh/authorized_keys +``` + +**Step 7.** Delete the temporary public key file: + +```text +rm tmp.pub +``` + +Now, when logged into the client system as `user` there should be no prompt for a password when commands such as the following is given: + +```text +ssh target_user@host_address +``` + + + +**Setting up a Replication Database User** + +For each database server that is to be managed by BART, a database user must be chosen to serve as the *replication database user*. The replication database user sets the Postgres `archive_command` configuration parameter when the `INIT` subcommand in invoked and creates backups when the `BACKUP` subcommand is invoked. The replication database user must be a `superuser`. + +When executed with the PSQL client, the following PostgreSQL command creates a superuser to be the replication database user: + +`CREATE ROLE repuser WITH LOGIN SUPERUSER PASSWORD 'password';` + +The `pg_hba.conf` file must minimally permit the replication database user to have access to the database. + +In the following example, the `pg_hba.conf` file permits the `repuser` (replication database user) to have access to the `template1` database. The IP address from which `repuser` has access to `template1` database is the location of the BART host: + +**For pg_basebackup only:** If `pg_basebackup` is to be used for taking any backups (such as for standby servers), the replication database user must also be included in the `pg_hba.conf` file as a `replication` database connection as shown by the last entry in the following example. + +```text +# TYPE DATABASE USER ADDRESS METHOD +# "local" is for Unix domain socket connections only +local all all md5 +# IPv4 local connections: +host template1 repuser 192.168.2.22/32 md5 +host all enterprisedb 127.0.0.1/32 md5 +# IPv6 local connections: +host all all ::1/128 md5 +# Allow replication connections from localhost, by a user with the +# replication privilege. +host replication repuser 192.168.2.22/32 md5 +``` + +The replication database user must be specified for the `user` parameter in the BART configuration file for the database server as shown in the following example: + +```text +[ACCTG] +host = 192.168.2.24 +port = 5444 +user = repuser +cluster_owner = enterprisedb +remote_host = enterprisedb@192.168.2.24 +description = "Accounting" +``` + +There must be no password prompt when connecting to the database server with the replication database user. There are several ways to permit this; one recommended method is to use a `.pgpass` file located in the BART user account’s home directory. + +For example, if `bartuser` is the BART user account, then the `.pgpass` file located in the `/home/bartuser` directory must contain the following entry: + +`192.168.2.24:5444::repuser:password` + +When `bartuser` invokes a BART backup, the password for the replication database user, `repuser`, is obtained from the `.pgpass` file of `bartuser` to connect to the database server running at `192.168.2.24` on `port 5444`. + +The `.pgpass` file must contain an entry for each BART managed database server and its corresponding replication database user and password. + + + +**Adding a Database Server to the BART Configuration File** + +To manage the backup and recovery of a database server, you must add entries to the `[SERVER]` section of the BART configuration file, which is located in `/etc` directory. + + + +*Database Server Parameter Reference* + +Set the following parameters in the \[`SERVER`] section of the BART configuration file. The parameter setting in the \[`SERVER`] section overrides the setting in the global \[`BART`] section for that particular database server. If omitted, the default value will be used. + +For each cluster serviced by BART, the following parameters are mandatory: + +```text +[HR] + +host = 192.168.2.24 +port = 5432 +user = postgres +cluster_owner = postgres +``` + +!!! Note + The port parameter setting is required only if the database server listens on a port other than the default (for example if Postgres listens on a port other than 5432). + +The following table describes the database server parameters. + + + + + + + + + +| **Parameters/Placeholder** | Type | **Description** | +| --------------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `[ServerName]` | Mandatory | Specify the server name that you want to backup using BART. It is not case-sensitive when referenced with BART subcommand options. A lowercase conversion of this name is used to create a subdirectory in the BART backup catalog for storing the backups and WAL files for this database server (for eg., epas12). | +| `` | Optional | Specify a [template](#backup_name_template) for user-defined, friendly names that will be assigned to the backups of the database server. The maximum permitted length of backup name is 49 characters. The `` parameter can be overridden by the `--backup-name` option of the `BACKUP` subcommand. If this parameter is omitted from the BART configuration file, and the `--backup-name` option with a user-defined name is not specified with the `BACKUP` subcommand, then the backup can only be referenced in BART subcommands by the BART assigned, integer backup identifier. | +| `host` | Mandatory | Specify the IP address of the database server to be configured for backup. | +| `port` | Mandatory | Specify the port number identifying the database server instance (that is, the relevant database cluster) to be backed up. The default port number for EPAS is `5444` and for Postgres it is `5432`. The port parameter setting is only required if the database server listens on a port other than the default value. | +| `User` | Mandatory | Specify the replication database user name used by BART to establish the connection to the database server for full backups. See [Setting up a Replication Database User](#setting_up_a_replication_database_user) for more information. | +| `` | Optional | Specify the path where archived WAL files will be stored. The default location is the BART backup catalog (`//archived_wals`). | +| `` | Optional | When the `INIT` subcommand is used, the content and variables specified in the BART `` result in the archive command string to be generated into the `Postgres archive_command` parameter in the `postgresql.auto.conf` file. To configure the BART `` parameter, enclose the command string within single quotes ('). If you do not specify the `` parameter in the configuration file, the default setting is taken as `'scp %p %h:%a/%f'`. See [Archive Command Auto Configuration](#archive_command_auto_configuration) for information about variables. The BART `` parameter in the BART configuration file, and the Postgres `` parameter in the `postgresql.conf` file (or the `postgresql.auto.conf` file) refer to two different parameters that are to be set in different manner. | +| `` | Mandatory | Specify the Linux operating system user account that owns the database cluster. This is typically `enterprisedb` for Advanced Server database clusters installed in the Oracle compatible mode, or `postgres` for Advanced Server database clusters installed in the PostgreSQL compatible mode and PostgreSQL database clusters. | +| `` | Optional | Specify the IP address of the remote server to which a backup is to be restored. Specify this parameter in the form of `@`. `` is the user account on the target database server host that accepts a passwordless SSH/SCP login connection and owns the directory where the backup is to be restored. `` is the IP address of the remote host. For restoring a backup to a remote host or for restoring any backup where `` and the BART user account are not the same users, either this parameter must be set or it may be specified with the `-r` option with the BART `RESTORE` subcommand. | +| `` | Optional | Specify path to which tablespaces are to be restored in the format `OID = `; If the backup is to be restored to a remote host specified by the `` parameter, then the tablespace paths must exist on the remote host. | +| `allow_incremental_backups` | Optional | Set this parameter to `enabled` to enable use of the WAL scanner and permit taking incremental backups when the `BACKUP` subcommand is invoked with the `--parent` option. Set it to `disabled` (default) to disallow incremental backups and thus permit only full backups. For information about using the `BACKUP` subcommand and running the WAL scanner, please see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/2.6/bart_user/). | +| `Description` | Optional | Specify the description that will be used to identify the database server. | + +For information regarding the following parameters, see [configuring the BART host](#configuring-the-bart-host). + +- `retention_policy` +- `xlog_method` +- `wal_compression` +- `copy_wals_during_restore`. +- `thread_count`. +- `batch_size`. +- `scan_interval`. +- `mbm_scan_timeout`. +- `workers` + + + +**Backup Name Template** + +- The template is an alphanumeric string that may include the following variables that will be replaced with the timestamp values when the backup is taken: + + - `%year` to be replaced by 4-digit year + - `%month` to be replaced by 2-digit month + - `%day` to be replaced by 2-digit day + - `%hour` to be replaced by 2-digit hour + - `%minute` to be replaced by 2-digit minute + - `%second` to be replaced by 2-digit second + +- To include a percent sign (`%`) as a character in the backup name, specify `%%` in the template. + +- Do not enclose the template string in quotes even if you want the template to include space characters, otherwise the enclosing quotes are stored as part of the backup name. However, when referenced with the `-i` option by BART subcommands use of space characters in the backup name requires enclosing the backup name in quotes. + +The following example shows the configuration settings of three database servers: + +```text +[ACCTG] + +host = 127.0.0.1 +port = 5444 +user = enterprisedb +cluster_owner = enterprisedb +backup_name = acctg_%year-%month-%dayT%hour:%minute:%second +archive_command = 'cp %p %a/%f' +allow_incremental_backups = enabled +retention_policy = 8 BACKUPS +description = "Accounting" + +[MKTG] + +host = 192.168.2.24 +port = 5444 +user = repuser +cluster_owner = enterprisedb +remote_host = enterprisedb@192.168.2.24 +allow_incremental_backups = enabled +description = "Marketing" + +[HR] + +host = 127.0.0.1 +port = 5432 +user = postgres +cluster_owner = postgres +retention_policy = 4 DAYS +description = "Human Resources" +``` + + + +**Enabling WAL Archiving** + +WAL archiving must be enabled for the database server for which BART is to perform backup and recovery management. + +- The WAL Archiving Configuration section describes the manual WAL archiving configuration process. +- The Archive Command Auto Configuration section describes an automated WAL archiving process. + +*WAL Archiving Configuration* + +Set the following configuration parameters in the `postgresql.conf` file to enable WAL archiving + +- Set `wal_level` to `replica` or higher. +- Set `archive_mode` to `on`. +- Set the PostgreSQL `archive_command` parameter to copy the WAL files to the `archive_path`. The `archive_command` configuration parameter mentioned here is located in the `postgresql.conf` file; the PostgreSQL `archive_command` parameter is used in a different manner than the BART [archive_command](#archive_command). +- Set `max_wal_senders` to a value high enough to leave at least one session available for the backup. If the `xlog_method=stream` parameter setting is to be used by this database server, the `max_wal_senders` setting must account for an additional session for the transaction log streaming (the setting must be a minimum of 2). See [Configuring the BART host](#configuring-the-bart-host) for information about the `xlog_method` parameter. + +For detailed information about WAL archiving, see the [PostgreSQL Core Documentation](https://www.postgresql.org/docs/current/static/continuous-archiving.html). + +The `ARCHIVE PATH` field displayed by the BART `SHOW-SERVERS` subcommand displays the full directory path where the WAL files should be copied as specified in the `archive_command` configuration parameter in the `postgresql.conf` file: + +```text +-bash-4.1$ bart SHOW-SERVERS -s acctg +SERVER NAME : acctg +HOST NAME : 192.168.2.24 +USER NAME : repuser +PORT : 5444 +REMOTE HOST : +RETENTION POLICY : none +DISK UTILIZATION : 0.00 bytes +NUMBER OF ARCHIVES : 0 +ARCHIVE PATH : /opt/backup/acctg/archived_wals +ARCHIVE COMMAND : (disabled) +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +INCREMENTAL BACKUP : DISABLED +DESCRIPTION : "Accounting" +``` + +The parameter settings in the following example will copy the WAL files to a directory named `/opt/backup/acctg/archived_wals` on the BART host located at `192.168.2.22` as the `bartuser` user account. Using the `bartuser` account ensures that the operation will have sufficient permissions to copy to the BART backup catalog owned by `bartuser`. + +```text +archive_mode = on # allows archiving to be done + # (change requires restart) +archive_command = 'scp %p bartuser@192.168.2.22:/opt/backup/acctg/archived_wals/%f' + # command to use to archive a logfile segment + # placeholders: %p = path of file to archive + # %f = file name only +... + +max_wal_senders = 1 # max number of walsender processes + # (change requires restart) +``` + +The database server must be restarted in order to initiate WAL archiving, but do not do so until you have verified that the full path of the BART backup catalog has been created by a prior BART subcommand or the archive operation will fail. + +Start the WAL scanner by executing the following command: + +```text +./bart-scanner +``` + + + +*Archive Command Auto Configuration* + +To enable WAL archiving: + +- In the `postgresql.conf` file, set the `wal_level` to `replica` or higher, `archive_mode` to `on`, and `max_wal_senders` to a value high enough to leave at least one session available for the backup. If the `xlog_method=stream` parameter setting is to be used by this database server as determined in the BART configuration file, the `max_wal_senders` setting must account for an additional session for the transaction log streaming (that is, the setting must be a minimum of `2`). See [Configuring the BART host](#configuring-the-bart-host) for information on the `xlog_method` parameter. + +- Configure the Postgres `archive_command` parameter automatically with the `INIT` subcommand and restart the database server when you are ready to initiate WAL archiving. The `INIT` subcommand invokes the Postgres `ALTER SYSTEM` command to set the Postgres `archive_command` configuration parameter in the `postgresql.auto.conf` file located in the managed database server’s `POSTGRES_INSTALL_HOME data directory`. For additional information about the `INIT` subcommand, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/2.6/bart_user/). + + The archive command string that the `INIT` subcommand generates into the `postgresql.auto.conf` file is determined by the parameter setting of the BART `archive_command` parameter in the server section of the BART configuration file. If the BART `archive_command` parameter is not set in the server section for a given database server, the command string that is configured uses the following default format: + + `'scp %p %h:%a/%f'` + + The following table describes these variables: + +| **Variable** | **Description** | +| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `%p` | The path of the file to archive used by the Postgres archiving process. | +| `%h` | Will be replaced by the `@` as specified in the <bart_host> parameter setting. | +| `%a` | Will be replaced by the BART `archived_wals` directory as specified in the [archive path](#archive_path) parameter setting. If the `` is not specified, then the default directory is `//archived_wals`. `` is the lowercase conversion of the database server name. | +| `%f` | The archived file name used by the Postgres archiving process. | + +The placeholders `%h` and `%a` are replaced by the `INIT` subcommand when creating the archive command string. The placeholders `%p` and `%f` are not replaced by the `INIT` subcommand, but are kept as given to be used by the Postgres archiving process. + +For example, to use the default archive command format, the BART configuration file contains the following settings where the BART `archive_command` parameter is omitted from the server section for `ACCTG`: + +```text +[BART] + +bart_host= bartuser@192.168.2.22 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log + +[ACCTG] + +host = 127.0.0.1 +port = 5444 +user = repuser +cluster_owner = enterprisedb +description = "Accounting" +``` + +The `INIT` subcommand is invoked by BART user account `bartuser` as follows: + +```text +[bartuser@localhost ~]$ bart INIT -s acctg -o +INFO: setting archive_command for server 'acctg' +WARNING: archive_command is set. server restart is required +``` + +If the BART backup catalog directory is not already complete, it will be completed. + +The resulting archive command string in the `postgresql.auto.conf` file located in the managed database server’s `POSTGRES_INSTALL_HOME/data directory` appears as follows: + +```text +# Do not edit this file manually! +# It will be overwritten by ALTER SYSTEM command. +archive_command = 'scp %p +bartuser@192.168.2.22:/opt/backup/acctg/archived_wals/%f' +``` + +Run the `INIT` subcommand with the `-o` option to override any existing `archive_command` setting in the `postgresql.conf` or the `postgresql.auto.conf` file. In addition, the `-o` option must be used to generate the command string if the `archive_mode` is set to off even if there are no existing settings of the `archive_command` in the `postgresql.conf` or `postgresql.auto.conf` files. + +In this example, the following BART configuration file is used with an explicit setting of the BART `archive_command` parameter: + +```text +[BART] + +bart_host= enterprisedb@192.168.2.22 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log + +[ACCTG] + +host = 127.0.0.1 +port = 5444 +user = repuser +cluster_owner = enterprisedb +archive_command = 'cp %p %a/%f' +description = "Accounting" +``` + +The `INIT` subcommand is invoked by BART user account `enterprisedb` as follows: + +```text +-bash-4.1$ bart INIT -s acctg -o +INFO: setting archive_command for server 'acctg' +WARNING: archive_command is set. server restart is required +``` + +The resulting Postgres `archive_command` parameter in the `postgresql.auto.conf` file appears as follows: + +```text +# Do not edit this file manually! +# It will be overwritten by ALTER SYSTEM command. +archive_command = 'cp %p /opt/backup/acctg/archived_wals/%f' +``` + +When the database server has been restarted, the `ARCHIVE COMMAND` field of the `SHOW-SERVERS` subcommand displays the active Postgres archive command as shown by the following example: + +```text +-bash-4.1$ bart SHOW-SERVERS -s acctg +SERVER NAME : acctg +HOST NAME : 127.0.0.1 +USER NAME : repuser +PORT : 5444 +REMOTE HOST : +RETENTION POLICY : none +DISK UTILIZATION : 48.00 MB +NUMBER OF ARCHIVES : 0 +ARCHIVE PATH : /opt/backup/acctg/archived_wals +ARCHIVE SCOMMAND : `cp %p /opt/backup/acctg/archived_wals/%f` +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +INCREMENTAL BACKUP : DISABLED +DESCRIPTION : "Accounting" +``` + + + +**Verifying Configuration Settings** + +To verify the parameter settings of the database server specified, execute tthe `CHECK-CONFIG` subcommand with the `–s` option: + +```text +bart CHECK-CONFIG [ –s server_name ] +``` + +The `CHECK-CONFIG` subcommand confirms the following: + +- The `cluster_owner` parameter is set to the user account owning the database cluster directory. +- A passwordless SSH/SCP connection is set between the BART user and the user account specified by the `cluster_owner` parameter. +- The BART `user` parameter specifies a database superuser. +- The BART `user` has access to the backup directory catalog. +- The `pg_hba.conf` file contains a replication entry for the database superuser specified by the BART `user` parameter. +- The `archive_mode` parameter in the `postgresql.conf` file is enabled. +- The `archive_command` parameter in the `postgresql.auto.conf` or the `postgresql.conf` file is set. +- The `allow_incremental_backups` parameter in the BART configuration file is enabled for database servers for which incremental backups are to be taken. +- Archiving of WAL files to the `archive_path` is in process. +- The WAL scanner program is running. + +After configuring the BART host and the database server(s), you can start using BART. For information about using BART, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/2.6/bart_user/). diff --git a/product_docs/docs/bart/2.6/bart_inst/04_upgrading_bart.mdx b/product_docs/docs/bart/2.6/bart_inst/04_upgrading_bart.mdx new file mode 100644 index 00000000000..7bd85d1d19c --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_inst/04_upgrading_bart.mdx @@ -0,0 +1,76 @@ +--- +title: "Upgrading BART" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/installation-getting-started/installation-upgrade-guide/2.6.1/upgrading_bart.html" +--- + + + +This section outlines the process of upgrading BART from an existing version to the latest version. + +**Upgrade Restrictions** + +The following restrictions apply with regard to previous BART versions. + +- You can take incremental backups using the latest version only when the parent backup (full or incremental backup) has also been taken with the latest version. +- Using the latest version, you can restore incremental backups that are taken only with the latest version of BART. However, using the latest version you can restore full backups that were taken with older versions. + + + +## Upgrading from Older Versions of BART + +Perform the following steps to upgrade from older versions of BART to the latest version: + +**Step 1:** Assume the identity of the BART user account and invoke the following command to stop the BART WAL scanner program (`bart-scanner`): + +```text +bart-scanner STOP +``` + +**Step 2:** As the `root` user, upgrade to the latest BART version with the `yum upgrade` command. + +- To upgrade the BART RPM package directly from the *EDB Yum Repository* website, specify only the package name: + + On CentOS 7: + + ```text + yum upgrade edb-bart + ``` + + You can also use a downloaded RPM package file to upgrade. To use a downloaded BART RPM package file to upgrade, use the `yum` command, specifying the complete RPM package file name: + + ```text + yum upgrade edb-bart-x.y.z rhel7.x86_64.rpm + ``` + + Where x denotes the major version of BART, and y and z denotes the minor version. + + On a Debian or Ubuntu Host: + + ```text + apt-get upgrade edb-bart + ``` + + On a SLES Host: + + ```text + zypper update edb-bart + ``` + +**Step 3:** Repeat the process described in this section to upgrade to the latest BART version on each remote hosts where an incremental backup will be restored. + +For additional information about restoration of incremental backups on remote hosts, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/2.6/bart_user/). + +**Step 4:** If the `bart --version` command returns an error stating the `PATH` is not available after switching from `root` user to another BART user account, adjust the setting of the `PATH` environment variable to include the location of the BART x.y.z (x denotes the major version of BART, and y and z denotes the minor version) executable (the `bin` subdirectory) in the `~/.bashrc` or `~/.bash_profile` files of the following user accounts: + +- The BART user account on the BART host. +- The remote user account on the remote host to which incremental backups are to be restored. For details, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/2.6/bart_user/). + +The `PATH` setting should be the same as set for BART x.y.z since all versions use `/usr/edb/bart/bin`. + +!!! Note + After upgrading to the latest BART version, you must take a new full backup of your system before performing an incremental backup. + + \ No newline at end of file diff --git a/product_docs/docs/bart/2.6/bart_inst/05_uninstalling_bart.mdx b/product_docs/docs/bart/2.6/bart_inst/05_uninstalling_bart.mdx new file mode 100644 index 00000000000..78cb55f2aa3 --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_inst/05_uninstalling_bart.mdx @@ -0,0 +1,50 @@ +--- +title: "Uninstalling BART" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/installation-getting-started/installation-upgrade-guide/2.6.1/uninstalling_bart.html" +--- + + + +This section walks you through uninstalling BART. + +## Uninstalling BART on a RHEL/CentOS Host + +To uninstall BART on a RHEL/CentOS host, assume the identity of the `root` user and invoke the following command: + +On RHEL/CentOS 7: + +```text +yum remove edb-bart +``` + +On RHEL/CentOS 8: + +```text +dnf remove edb-bart +``` + +Uninstalling BART does not delete the backup files and archived WAL files that reside in the BART backup catalog. To permanently delete the backup files and archived WAL files in the BART backup catalog (`/opt/backup`), use one of the following commands: + +- `rm –rf /opt/backup` +- BART `DELETE` subcommand + +For information about the BART `DELETE` subcommand, see the *EDB Backup and Recovery User Guide* available at the [EDB website](/bart/2.6/bart_user/). + +## Uninstalling BART on an SLES 12 Host + +To uninstall BART on an SLES 12 host, assume the identity of the `root` user and invoke the following command: + +```text +zypper remove edb-bart +``` + +## Uninstalling BART on a Debian/Ubuntu Host + +To uninstall BART on a Debian or Ubuntu host, invoke the following command: + +```text +apt-get remove edb-bart +``` diff --git a/product_docs/docs/bart/2.6/bart_inst/images/EDB_logo.png b/product_docs/docs/bart/2.6/bart_inst/images/EDB_logo.png new file mode 100644 index 00000000000..39a54822d85 Binary files /dev/null and b/product_docs/docs/bart/2.6/bart_inst/images/EDB_logo.png differ diff --git a/product_docs/docs/bart/2.6/bart_inst/images/edb.png b/product_docs/docs/bart/2.6/bart_inst/images/edb.png new file mode 100644 index 00000000000..71e5bdde787 Binary files /dev/null and b/product_docs/docs/bart/2.6/bart_inst/images/edb.png differ diff --git a/product_docs/docs/bart/2.6/bart_inst/images/edb_logo.svg b/product_docs/docs/bart/2.6/bart_inst/images/edb_logo.svg new file mode 100644 index 00000000000..f24d1dfefee --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_inst/images/edb_logo.svg @@ -0,0 +1,19 @@ + + + edb-logo-disc-dark + + + + \ No newline at end of file diff --git a/product_docs/docs/bart/2.6/bart_inst/images/edblogo.png b/product_docs/docs/bart/2.6/bart_inst/images/edblogo.png new file mode 100644 index 00000000000..71e5bdde787 Binary files /dev/null and b/product_docs/docs/bart/2.6/bart_inst/images/edblogo.png differ diff --git a/product_docs/docs/bart/2.6/bart_inst/index.mdx b/product_docs/docs/bart/2.6/bart_inst/index.mdx new file mode 100644 index 00000000000..3f2963a4f4d --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_inst/index.mdx @@ -0,0 +1,45 @@ +--- +navTitle: Installation Guide +title: "EDB Postgres Backup and Recovery Installation Guide" +legacyRedirects: + - "/edb-docs/d/edb-backup-and-recovery-tool/installation-getting-started/installation-upgrade-guide/2.6.1/requirements_overview.html" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/installation-getting-started/installation-upgrade-guide/2.6.1/conclusion.html" + - "/edb-docs/d/edb-backup-and-recovery-tool/installation-getting-started/installation-upgrade-guide/2.6.1/genindex.html" + - "/edb-docs/d/edb-backup-and-recovery-tool/installation-getting-started/installation-upgrade-guide/2.6.1/index.html" +--- + +This guide provides information about how to install and configure the EDB Backup and Recovery Tool (BART) 2.6. + + + +## Requirements Overview + +### Supported Platforms and Database Versions + +- To view a complete list of supported platforms, visit the [EDB website.](https://www.enterprisedb.com/services-support/edb-supported-products-and-platforms) + +!!! Note + BART 2.6 does not support CentOS/RHEL/OEL 6.x platforms. It is strongly recommended that EDB products running on these platforms be migrated to a supported platform. + +- BART supports the following database versions: + + - Advanced Server versions 9.6, 10, 11, 12, and 13. + - PostgreSQL versions 9.6, 10, 11, 12, and 13. + +### Software Requirements + +You require the following components to install BART. + +- BART Host Components - Use EDB packages to add BART host components; see [Installing BART](02_installing_bart/#installing-bart) for information about how to install these components. + +- Additional Components - In addition to the BART host components, the following components are required: + + - The [Secure Shell (SSH) server daemon and Secure Copy (SCP) client programs](03_configuring_bart/#authorizing_ssh_scp_access) must be enabled and activated on the BART host as well as on the remote database server hosts on which BART will be managing backup and recovery. + - BART uses the `pg_basebackup` utility program when taking full backups. + +### Limitation + +BART supports taking only a full backup of standby servers; it does not support taking incremental or parallel backups of standby servers. diff --git a/product_docs/docs/bart/2.6/bart_qs_7/images/EDB_logo.png b/product_docs/docs/bart/2.6/bart_qs_7/images/EDB_logo.png new file mode 100644 index 00000000000..39a54822d85 Binary files /dev/null and b/product_docs/docs/bart/2.6/bart_qs_7/images/EDB_logo.png differ diff --git a/product_docs/docs/bart/2.6/bart_qs_7/images/edb.png b/product_docs/docs/bart/2.6/bart_qs_7/images/edb.png new file mode 100644 index 00000000000..71e5bdde787 Binary files /dev/null and b/product_docs/docs/bart/2.6/bart_qs_7/images/edb.png differ diff --git a/product_docs/docs/bart/2.6/bart_qs_7/images/edb_logo.svg b/product_docs/docs/bart/2.6/bart_qs_7/images/edb_logo.svg new file mode 100644 index 00000000000..f24d1dfefee --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_qs_7/images/edb_logo.svg @@ -0,0 +1,19 @@ + + + edb-logo-disc-dark + + + + \ No newline at end of file diff --git a/product_docs/docs/bart/2.6/bart_qs_7/images/image2.png b/product_docs/docs/bart/2.6/bart_qs_7/images/image2.png new file mode 100644 index 00000000000..4eba2e7efa7 Binary files /dev/null and b/product_docs/docs/bart/2.6/bart_qs_7/images/image2.png differ diff --git a/product_docs/docs/bart/2.6/bart_qs_7/index.mdx b/product_docs/docs/bart/2.6/bart_qs_7/index.mdx new file mode 100644 index 00000000000..9f98f080e56 --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_qs_7/index.mdx @@ -0,0 +1,321 @@ +--- +title: "Quick Start Guide for RHEL/CentOS 7" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/quick-start/quick-start-guide-for-rhelcentos-7/2.6.1/genindex.html" + - "/edb-docs/d/edb-backup-and-recovery-tool/quick-start/quick-start-guide-for-rhelcentos-7/2.6.1/index.html" +--- + +This tutorial demonstrates using `yum` to [install](#installing) and [configure](../bart_qs_8/#configuring) Backup and Recovery Tool (BART) 2.6 on a CentOS 7 host with minimal configuration settings.  The tutorial assumes that the user has some knowledge of installation and system administration procedures, and has administrative privileges on the host. + +For detailed information about BART installation and configuration, see the *BART Installation and Upgrade Guide*, available at the [EDB website](/bart/2.6/bart_inst/). + +- BART is tested with the following database versions: + + - Advanced Server - 9.6, 10, 11, 12, and 13. + - PostgreSQL - 9.6, 10, 11, 12, and 13. + + + +**Installing BART** + +The following steps describe installing BART on CentOS 7.x OS using `yum`. + +1. Assume superuser privileges and use `yum` to create the repository configuration file: + + ```text + yum install -y https://yum.enterprisedb.com/edbrepos/edb-repo-latest.noarch.rpm + ``` + +2. Create an EDB user account to request credentials to the EDB repository; for a user account visit the [EnterpriseDB website](https://www.enterprisedb.com/repository-access-request). + +3. Use your choice of editor to open the repository configuration file (named `edb.repo`, located in `/etc/yum.repos.d`), and set the `enabled` parameter value to `1`, and replace the `username` and `password` placeholders in the `baseurl` specification with the username and password of a registered EnterpriseDB user. + +4. Update the cache: + + ```text + yum makecache + ``` + +5. Install an Advanced Server or PostgreSQL database server. + + To install Advanced Server, execute the following command: + + ```text + yum -y install edb-as12-server + ``` + + Use sudo to assume the identity of the `enterprisedb` database superuser + + ```text + sudo su - enterprisedb + ``` + + Create an Advanced Server cluster named `acctg` on listener port `5444`: + + ```text + /usr/edb/as12/bin/initdb -D /var/lib/edb/as12/acctg + ``` + + As the `enterprisedb` user, start the cluster: + + ```text + /usr/edb/as12/bin/pg_ctl start -D /var/lib/edb/as12/acctg + ``` + + You can check the status of the cluster with the following command: + + ```text + /usr/edb/as12/bin/pg_ctl status -D /var/lib/edb/as12/acctg + ``` + + !!! Note + The BART host server is not required to have an Advanced Server or PostgreSQL installation, but must include a copy of the Postgres `libpq` library, the `pg_basebackup` utility program, and Boost Libraries 1.53 version for CentOS 7. + +6. If you do not already have the `pg_basebackup` program installed on the BART host, you can use the following command to install a limited number of files that include the `pg_basebackup` program: + + ```text + yum install edb-as-server-client + ``` + + Where <xx> is the Advanced Server version. + +7. As a root user, execute the following command to install BART: + + ```text + yum install edb-bart + ``` + +BART (the bart program and bart-scanner) is installed in the `/usr/edb/bart/bin` directory, referred to as ``. Repeat the installation process described in this section to install BART on all remote hosts where incremental backups are to be restored. + + + +**Configuring BART** + +Before configuring BART, establish the BART user account (the operating system user) that will run the BART command line program. Then, to configure the BART host and each database server that is to be managed by BART, perform the following steps: + +1. Assume superuser privileges, create the directory that will hold the BART backup catalog, and assign its ownership (with restrictive privileges) to the BART user account: + + In this example, `bartuser` is the BART user account and `/opt/backup` is the BART backup catalog. + + ```text + su root + mkdir /opt/backup + chown bartuser /opt/backup + chgrp bartuser /opt/backup + chmod 700 /opt/backup + ``` + +2. Navigate to the `/usr/edb/bart/etc` directory and copy the `bart.cfg.sample` file to create the BART configuration file (`bart.cfg`): + + ```text + cp bart.cfg.sample bart.cfg + ``` + +3. Open the BART configuration file (`bart.cfg`) using an editor of your choice and scroll through the BART configuration file to edit the file as required; sample settings are included for your reference. You must add the mandatory parameters to the `[BART]` and `[ServerName]` sections. Default values may be used for optional parameters. For detailed information about parameter settings, see the *BART Installation and Upgrade Guide*, available at the [EDB website](/bart/2.6/bart_inst/). + + Parameters set in the `[BART]` section are applicable to all BART managed database servers, while parameters set in the `[ServerName]` section are applicable only to the specific server; `[ServerName]` settings override `[BART]` section settings. + + In the following example, only mandatory parameters are set: + + ```text + [BART] + bart_host= bartuser@192.168.169.199 + backup_path = /opt/backup + pg_basebackup_path = /usr/edb/as12/bin/pg_basebackup + + [EPAS12] + host = 127.0.0.1 + user = repuser + cluster_owner = enterprisedb + ``` + +The following table describes only mandatory parameters: + +| **Parameters/Placeholder** | **Section** | **Description** | +| -------------------------- | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `bart_host` | `[BART]` | Use this field to specify the BART user and the IP address of the host on which the BART utility is installed. Specify the value in the form of `@`. | +| `backup_path` | `[BART]` | Use this field to specify the path where all BART backups and archived WAL files will be stored. Ensure the BART user account holds privileges to create subdirectories and files within the location specified in the `backup_path` parameter. The default `backup_path` is BART backup catalog (`/opt/backup`). | +| `pg_basebackup_path` | `[BART]` | Use this field to specify the path to the pg_basebackup utility (`/usr/edb/as/bin/pg_basebackup`). | +| `[ServerName]` | `[ServerName]` | Specify the name of the database server to be backed up (for example, \[EPAS12]). | +| `host` | `[ServerName]` | Specify the IP address of the database server to be configured for backup. | +| `user` | `[ServerName]` | Specify the replication database user name used by BART to establish the connection to the database server for full backups. | +| `cluster_owner` | `[ServerName]` | Specify the Linux operating system user account that owns the database cluster. | + +4. As a BART user, navigate to `/usr/edb/bart/bin` and invoke the following subcommand (omitting the `-s` option) to verify the \[BART] section parameter settings: + + ```text + bart CHECK-CONFIG + ``` + +5. Authorize [SSH/SCP access](../bart_qs_8/#passwordless) between the server and the BART host without a password prompt. + +6. Create a [replication database user](../bart_qs_8/#replication) for each database server that BART manages. + +7. To enable continuous WAL archiving for any database server for which BART is to perform a backup, modify the `postgresql.conf` file, setting: + + - `wal_level` to `replica` or higher (for Postgres 9.6 or later) + - `archive_mode` to `on` + - `archive_command` (if it is not set in the `bart.cfg` file) + - `max_wal_senders` to a value high enough to leave at least one session available for the backup. + + After setting the parameters, restart the database server. + +8. To start the WAL scanner, navigate to `/usr/edb/bart/bin` as a BART user and execute the following command: + + ```text + ./bart-scanner + ``` + +9. If you are using the default `archive_command`, then navigate to `/usr/edb/bart/bin` as a BART user, run the `INIT` subcommand without the `-o` option, and restart the database server: + + ```text + bart INIT [ -s { | all } ] + ``` + + Where `` is the name of the database server to be backed up. + + If you have customized the `archive_command` setting in the `bart.cfg` file, run the `INIT` subcommand with the `-o` option to override any existing Postgresql `archive_command` setting in the `postgresql.conf` or the `postgresql.auto.conf` file, and restart the database server. + + ```text + bart INIT [ -s { | all } ] [ -o ] + ``` + +10. To verify the database server parameter settings, as a BART user navigate to `/usr/edb/bart/bin` and invoke the `CHECK-CONFIG` subcommand with the -s option: + + ```text + bart CHECK-CONFIG [ -s ] + ``` + + BART is now configured successfully. For detailed information about using BART, see the *EDB Backup and Recovery Tool User Guide*, available at the [EDB website](/bart/2.6/bart_user/). + + + +**Creating a Passwordless Connection** + +The following example enables SSH/SCP access on a CentOS 7.x host; similar (platform-specific) steps will apply to other platforms/versions. You must create a passwordless connection between the BART host (SSH/SCP client) and the database server (target SSH/SCP server), as well as a passwordless connection between the database server (SSH/SCP client) and the BART host (target SSH/SCP server). + +1. Log in as the user account on the BART host that will be initiating the SSH or SCP connection and navigate to the user account’s home directory and check for an existing `.ssh` subdirectory. If the `.ssh` directory does not exist, create one with the required privileges. + +2. As a root user navigate to `/usr/edb/bart`, open the `/etc/ssh/sshd_config` file and set the `PubkeyAuthentication` parameter to `yes`. + +3. Reload the configuration file: + + ```text + service sshd reload + ``` + + If you get any SSH or SCP errors, examine the log file (`/var/log/secure`). + +4. As a BART user, use the following command to generate the public key file; you can accept the default responses: + + ```text + ssh-keygen -t rsa + ``` + + The public key file named `id_rsa.pub` is created in the `.ssh` subdirectory. + +5. Use `SCP` to make a temporary copy of the public key file on the target server: + + ```text + scp ~/.ssh/id_rsa.pub target_user@host_address:tmp.pub + ``` + +6. As a `target_user`, log into the target server using `ssh target_user@host_address` command and navigate to the user account’s home directory to check if there is an existing `.ssh` subdirectory. If it does not exist, create one with the required privileges. + +7. Append the client’s temporary public key file, `tmp.pub`, to the `authorized_keys` file: + + ```text + cat tmp.pub >> ~/.ssh/authorized_keys + ``` + + If an `authorized_keys` file does not exist, create a new file, but be careful not to completely replace any existing `authorized_keys` file. + +8. Ensure only the file owner (and not other groups or users) has access to `authorized_keys` file: + + ```text + chmod 600 ~/.ssh/authorized_keys + ``` + +9. Delete the temporary public key file: + + ```text + rm tmp.pub + ``` + + Now, when logged into the BART host as a user, there should be no prompt for a password when you are connecting to the target database server: + + ```text + ssh target_user@database_server_address + ``` + +**Creating a Passwordless Connection Between the Database Server and the BART Host** + +If backups are to be taken from a given database server host, but restored to a different database server host, the passwordless SSH/SCP connections must be configured from the BART host to the database server host from which the backup is to be taken as well as from the BART host to the database server host to which the backup is to be restored. + +An example of how to create a passwordless connection is documented in the *EDB Backup and Recovery Reference Guide*, available at the [EDB website](/bart/2.6/bart_ref/). + +Even when the Advanced Server database is on the same host as BART, and the Advanced Server database cluster owner is also the BART user account, a passwordless SSH/SCP connection must be established from the same user account to itself. + +1. On the database server, navigate into the target user account’s home directory to check for an existing `.ssh` subdirectory. If it does does not exist, create one in the user account’s home directory with the required privileges. + +2. As a database server user, generate the public key file: + + ```text + ssh-keygen -t rsa + ``` + +3. Create a temporary copy of the public key file: + + ```text + scp ~/.ssh/id_rsa.pub target_user@host_address:tmp.pub + ``` + +4. As a target user, log into the BART host and navigate to the user account’s home directory to check if there is an existing `.ssh` subdirectory. If it does not exist, create one with the required privileges: + + ```text + ssh target_user@host_address + ``` + +5. Append the temporary, client’s public key file to the `authorized_keys` file: + + ```text + cat tmp.pub >> ~/.ssh/authorized_keys + ``` + +If an `authorized_keys` file does not exist, create a new file, but do not completely replace any existing `authorized_keys` file. + +6. Ensure only the file owner (and not other groups or users) has access to `authorized_keys` file: + + ```text + chmod 600 ~/.ssh/authorized_keys + ``` + +7. Delete the temporary public key file: + + ```text + rm tmp.pub + ``` + + Now, when logged into the database server as a user, there should be no prompt for a password when you are connecting to the BART host: + + ```text + ssh bart_user@bartip_address + ``` + + + +**Creating a Replication Database User** + +1. To create a replication database user (a superuser), connect to the database server with the psql client, and invoke the following PostgreSQL command: + + ```text + CREATE ROLE WITH LOGIN SUPERUSER PASSWORD ''; + ``` + +2. Specify this replication database user in the `user` parameter of the `bart.cfg` file. + +3. The [pg_hba.conf](https://www.postgresql.org/docs/current/auth-pg-hba-conf.html) file must minimally permit the replication database user to have access to the database. The IP address from which the replication database user has access to the database is the BART host location. The replication database user must also be included in the `pg_hba.conf` file as a replication database connection if `pg_basebackup` is to be used for taking any backups. + +4. To ensure there is no password prompt when connecting to the database server with the replication database user, a recommended method is to use the `.pgpass` file located in the BART user account’s home directory (if it does not exist, you need to create the `.pgpass` file with the required privileges). The `.pgpass` file must contain an entry for each BART managed database server, and its corresponding replication database user and password. diff --git a/product_docs/docs/bart/2.6/bart_qs_8/images/EDB_logo.png b/product_docs/docs/bart/2.6/bart_qs_8/images/EDB_logo.png new file mode 100644 index 00000000000..39a54822d85 Binary files /dev/null and b/product_docs/docs/bart/2.6/bart_qs_8/images/EDB_logo.png differ diff --git a/product_docs/docs/bart/2.6/bart_qs_8/images/edb.png b/product_docs/docs/bart/2.6/bart_qs_8/images/edb.png new file mode 100644 index 00000000000..71e5bdde787 Binary files /dev/null and b/product_docs/docs/bart/2.6/bart_qs_8/images/edb.png differ diff --git a/product_docs/docs/bart/2.6/bart_qs_8/images/edb_logo.svg b/product_docs/docs/bart/2.6/bart_qs_8/images/edb_logo.svg new file mode 100644 index 00000000000..f24d1dfefee --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_qs_8/images/edb_logo.svg @@ -0,0 +1,19 @@ + + + edb-logo-disc-dark + + + + \ No newline at end of file diff --git a/product_docs/docs/bart/2.6/bart_qs_8/images/image2.png b/product_docs/docs/bart/2.6/bart_qs_8/images/image2.png new file mode 100644 index 00000000000..4eba2e7efa7 Binary files /dev/null and b/product_docs/docs/bart/2.6/bart_qs_8/images/image2.png differ diff --git a/product_docs/docs/bart/2.6/bart_qs_8/index.mdx b/product_docs/docs/bart/2.6/bart_qs_8/index.mdx new file mode 100644 index 00000000000..42bfc8daf38 --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_qs_8/index.mdx @@ -0,0 +1,317 @@ +--- +title: "Quick Start Guide for RHEL/CentOS 8" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/quick-start/quick-start-guide-for-rhelcentos-8/2.6.1/genindex.html" + - "/edb-docs/d/edb-backup-and-recovery-tool/quick-start/quick-start-guide-for-rhelcentos-8/2.6.1/index.html" +--- + +This tutorial demonstrates using the `dnf` command to install and configure the EDB Backup and Recovery Tool (BART) 2.6 on a CentOS 8 host with minimal configuration settings.  The tutorial assumes that the user has some knowledge of installation and system administration procedures and has administrative privileges on the host. + +For detailed information about BART installation and configuration, see the *BART Installation and Upgrade Guide* available at the [EDB website](/bart/2.6/bart_inst/). + +- BART is tested with the following database versions: + + - Advanced Server - 9.6, 10, 11, 12, and 13. + - PostgreSQL - 9.6, 10, 11, 12, and 13. + +**Installing BART** + +The following steps describe installing BART on CentOS 8.x OS. + +1. Assume superuser privileges and use `dnf` to create the repository configuration file: + + ```text + dnf install -y https://yum.enterprisedb.com/edbrepos/edb-repo-latest.noarch.rpm + ``` + +2. Create an EDB user account to request credentials to the EDB repository; for a user account visit the [EnterpriseDB website](https://www.enterprisedb.com/repository-access-request). + +3. Use your choice of editor to open the repository configuration file (named `edb.repo`, located in `/etc/yum.repos.d`), set the `enabled` parameter value to `1`, and replace the `username` and `password` placeholders in the `baseurl` specification with the username and password of a registered EnterpriseDB user. + +4. Update the cache: + + ```text + dnf makecache + ``` + +5. Install an Advanced Server or PostgreSQL database server. + + To install Advanced Server, execute the following command: + + ```text + dnf -y install edb-as12-server + ``` + + Use sudo to assume the identity of the `enterprisedb` database superuser: + + ```text + sudo su - enterprisedb + ``` + + Create an Advanced Server cluster named `acctg` on listener port `5444`: + + ```text + /usr/edb/as12/bin/initdb -D /var/lib/edb/as12/acctg + ``` + + As the `enterprisedb` user, start the cluster: + + ```text + /usr/edb/as12/bin/pg_ctl start -D /var/lib/edb/as12/acctg + ``` + + You can check the status of the cluster with the following command: + + ```text + /usr/edb/as12/bin/pg_ctl status -D /var/lib/edb/as12/acctg + ``` + + !!! Note + The BART host server is not required to have an Advanced Server or PostgreSQL installation, but must include a copy of the Postgres `libpq` library, the `pg_basebackup` utility program, and Boost Libraries 1.66 version for CentOS 8. + +6. If you do not already have the `pg_basebackup` program installed on the BART host, you can use the following command to install a limited number of files that include the `pg_basebackup` program: + + ```text + dnf install edb-asxx-server-client + ``` + +7. As a root user, use the following command to install the BART RPM package: + + ```text + dnf install edb-bart + ``` + +BART (the `bart` program and `bart-scanner`) is installed in the `/usr/edb/bart/bin` directory, referred to as ``. Repeat the installation process described in this section to install BART on all remote hosts where incremental backups are to be restored. + + + +**Configuring BART** + +Before configuring BART, establish the BART user account (the operating system user) to run the BART command line program. Then, to configure the BART host and each database server that is to be managed by BART, perform the following steps: + +1. Assume superuser privileges, create the directory that will hold the BART backup catalog, and assign its ownership (with restrictive privileges) to the BART user account: + + In this example, `bartuser` is the BART user account and `/opt/backup` is the BART backup catalog. + + ```text + su root + mkdir /opt/backup + chown bartuser /opt/backup + chgrp bartuser /opt/backup + chmod 700 /opt/backup + ``` + +2. Navigate to the `/usr/edb/bart/etc` directory and copy the `bart.cfg.sample` file to create the BART configuration file (`bart.cfg`): + + ```text + cp bart.cfg.sample bart.cfg + ``` + +3. Open the BART configuration file (`bart.cfg`) using an editor of your choice and scroll through the BART configuration file to edit the file as required; sample settings are included for your reference. You must add the mandatory parameters to the `[BART]` and `[ServerName]` sections. Default values may be used for optional parameters. For detailed information about parameter settings, see the *BART Installation and Upgrade Guide*, available at the [EDB website](/bart/2.6/bart_inst/). + + Parameters set in the `[BART]` section are applicable to all BART managed database servers, while parameters set in the `[ServerName]` section are applicable only to the specific server; `[ServerName]` settings override `[BART]` section settings. + + In the following example, only mandatory parameters are set: + + ```text + [BART] + bart_host= bartuser@192.168.169.199 + backup_path = /opt/backup + pg_basebackup_path = /usr/edb/as12/bin/pg_basebackup + + [EPAS12] + host = 127.0.0.1 + user = repuser + cluster_owner = enterprisedb + ``` + +The following table describes only mandatory parameters: + +| **Parameters/Placeholder** | **Section** | **Description** | +| -------------------------- | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `bart_host` | `[BART]` | Use this field to specify the BART user and the IP address of the host on which the BART utility is installed. Specify the value in the form of `@`. | +| `backup_path` | `[BART]` | Use this field to specify the path where all BART backups and archived WAL files will be stored. Ensure the BART user account holds privileges to create subdirectories and files within the location specified in the `backup_path` parameter. The default `backup_path` is BART backup catalog (`/opt/backup`). | +| `pg_basebackup_path` | `[BART]` | Use this field to specify the path to the pg_basebackup utility (`/usr/edb/as/bin/pg_basebackup`). | +| `[ServerName]` | `[ServerName]` | Specify the name of the database server to be backed up (for example, \[EPAS12]). | +| `host` | `[ServerName]` | Specify the IP address of the database server to be configured for backup. | +| `user` | `[ServerName]` | Specify the replication database user name used by BART to establish the connection to the database server for full backups. | +| `cluster_owner` | `[ServerName]` | Specify the Linux operating system user account that owns the database cluster. | + +4. As a BART user, navigate to `/usr/edb/bart/bin` and invoke the following subcommand (omitting the `-s` option) to verify the \[BART] section parameter settings: + + ```text + bart CHECK-CONFIG + ``` + +5. Authorize [SSH/SCP access](#passwordless) between the server and the BART host without a password prompt. + +6. Create a [replication database user](#replication) for each database server that BART manages. + +7. To enable continuous WAL archiving for any database server for which BART is to perform a backup, modify the `postgresql.conf` file, setting: + + - `wal_level` to `replica` or higher (for Postgres 9.6 or later) + - `archive_mode` to `on` + - `archive_command` (if it is not set in the `bart.cfg` file) + - `max_wal_senders` to a value high enough to leave at least one session available for the backup. + + After setting the parameters, restart the database server. + +8. To start the WAL scanner, navigate to `/usr/edb/bart/bin` as a BART user and execute the following command: + + ```text + ./bart-scanner + ``` + +9. If you are using the default `archive_command`, then navigate to `/usr/edb/bart/bin` as a BART user, run the `INIT` subcommand without the `-o` option, and restart the database server: + + ```text + bart INIT [ -s { | all } ] + ``` + + Where `` is the name of the database server to be backed up. + + If you have customized the `archive_command` setting in the `bart.cfg` file, run the `INIT` subcommand with the `-o` option to override any existing Postgresql `archive_command` setting in the `postgresql.conf` or the `postgresql.auto.conf` file, and restart the database server. + + ```text + bart INIT [ -s { | all } ] [ -o ] + ``` + +10. To verify the database server parameter settings, as a BART user navigate to `/usr/edb/bart/bin` and invoke the `CHECK-CONFIG` subcommand with the -s option: + + ```text + bart CHECK-CONFIG [ -s ] + ``` + + BART is now configured successfully. For detailed information about using BART, see the *EDB Backup and Recovery Tool User Guide* available at the [EDB website](/bart/2.6/bart_user/). + + + +**Creating a Passwordless Connection** + +The following example enables SSH/SCP access on a CentOS 7.x host; similar (platform-specific) steps will apply to other platforms/versions. You must create a passwordless connection between the BART host (SSH/SCP client) and the database server (target SSH/SCP server), as well as a passwordless connection between the database server (SSH/SCP client) and the BART host (target SSH/SCP server). + +1. Log in as the user account on the BART host that will be initiating the SSH or SCP connection and navigate to the user account’s home directory and check for an existing `.ssh` subdirectory. If the `.ssh` directory does not exist, create one with the required privileges. + +2. As a root user navigate to `/usr/edb/bart`, open the `/etc/ssh/sshd_config` file and set the `PubkeyAuthentication` parameter to `yes`. + +3. Reload the configuration file: + + ```text + service sshd reload + ``` + + If you get any SSH or SCP errors, examine the log file (`/var/log/secure`). + +4. As a BART user, use the following command to generate the public key file; you can accept the default responses: + + ```text + ssh-keygen -t rsa + ``` + + The public key file named `id_rsa.pub` is created in the `.ssh` subdirectory. + +5. Use `SCP` to make a temporary copy of the public key file on the target server: + + ```text + scp ~/.ssh/id_rsa.pub target_user@host_address:tmp.pub + ``` + +6. As a `target_user`, log into the target server using `ssh target_user@host_address` command and navigate to the user account’s home directory to check if there is an existing `.ssh` subdirectory. If it does not exist, create one with the required privileges. + +7. Append the temporary client’s public key file, `tmp.pub`, to the `authorized_keys` file: + + ```text + cat tmp.pub >> ~/.ssh/authorized_keys + ``` + + If an `authorized_keys` file does not exist, create a new file, but be careful not to completely replace any existing `authorized_keys` file. + +8. Ensure only the file owner (and not other groups or users) has access to `authorized_keys` file: + + ```text + chmod 600 ~/.ssh/authorized_keys + ``` + +9. Delete the temporary public key file: + + ```text + rm tmp.pub + ``` + + Now, when logged into the BART host as a user, there should be no prompt for a password when you are connecting to the target database server: + + ```text + ssh target_user@database_server_address + ``` + +**Creating a Passwordless Connection Between the Database Server and the BART Host** + +If backups are to be taken from a given database server host, but restored to a different database server host, the passwordless SSH/SCP connections must be configured from the BART host to the database server host from which the backup is to be taken as well as from the BART host to the database server host to which the backup is to be restored. + +An example of how to create a passwordless connection is documented in the *EDB Backup and Recovery Reference Guide*, available at the [EDB website](/bart/2.6/bart_ref/). + +Even when the Advanced Server database is on the same host as BART, and the Advanced Server database cluster owner is also the BART user account, a passwordless SSH/SCP connection must be established from the same user account to itself. + +1. On the database server, navigate into the target user account’s home directory to check for an existing `.ssh` subdirectory. If it does does not exist, create one in the user account’s home directory with the required privileges. + +2. As a database server user, generate the public key file: + + ```text + ssh-keygen -t rsa + ``` + +3. Create a temporary copy of the public key file: + + ```text + scp ~/.ssh/id_rsa.pub target_user@host_address:tmp.pub + ``` + +4. As a target user, log into the BART host and navigate to the user account’s home directory to check if there is an existing `.ssh` subdirectory. If it does not exist, create one with the required privileges: + + ```text + ssh target_user@host_address + ``` + +5. Append the client’s temporary public key file to the `authorized_keys` file: + + ```text + cat tmp.pub >> ~/.ssh/authorized_keys + ``` + +If the `authorized_keys file` does not exist, create a new file, but do not completely replace any existing `authorized_keys` file. + +6. Ensure that only the file owner (and not other groups or users) has access to `authorized_keys` file: + + ```text + chmod 600 ~/.ssh/authorized_keys + ``` + +7. Delete the temporary public key file: + + ```text + rm tmp.pub + ``` + + Now, when logged into the database server as a user, there should be no prompt for a password when you are connecting to the BART host: + + ```text + ssh bart_user@bartip_address + ``` + + + +**Creating a Replication Database User** + +1. To create a replication database user (a superuser), connect to the database server with the psql client, and invoke the following PostgreSQL command: + + ```text + CREATE ROLE WITH LOGIN SUPERUSER PASSWORD ''; + ``` + +2. Specify this replication database user in the `user` parameter of the `bart.cfg` file. + +3. The [pg_hba.conf](https://www.postgresql.org/docs/current/auth-pg-hba-conf.html) file must minimally permit the replication database user to have access to the database. The IP address from which the replication database user has access to the database is the BART host location. The replication database user must also be included in the `pg_hba.conf` file as a replication database connection if `pg_basebackup` is to be used for taking any backups. + +4. To ensure there is no password prompt when connecting to the database server with the replication database user, a recommended method is to use the `.pgpass` file located in the BART user account’s home directory (if it does not exist, you need to create the `.pgpass` file with the required privileges). The `.pgpass` file must contain an entry for each BART managed database server, and its corresponding replication database user and password. diff --git a/product_docs/docs/bart/2.6/bart_ref/01_bart_subcommands_examples/01_backup.mdx b/product_docs/docs/bart/2.6/bart_ref/01_bart_subcommands_examples/01_backup.mdx new file mode 100644 index 00000000000..bbebab0060e --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_ref/01_bart_subcommands_examples/01_backup.mdx @@ -0,0 +1,271 @@ +--- +title: "BACKUP" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/backup.html" +--- + +Use the `BACKUP` subcommand to create a full or incremental backup. + +**Syntax for a Full Backup:** + +```text +bart BACKUP –s { | all } [ -F { p | t } ] + +[ -z ] [ –c ] + +[ --backup-name ] + +[ --thread-count ] + +[ { --with-pg_basebackup | --no-pg_basebackup } ] +``` + +**Syntax for an Incremental Backup:** + +```text +bart BACKUP –s [-Fp] + +[ --parent { | } ] + +[ --backup-name ] + +[ --thread-count ] + +[ { --checksum-algorithm } ] +``` + +Before performing an incremental backup, you must take a full backup. For more details about incremental backup, refer to *Block-Level Incremental Backup* in the *EDB Backup and Recovery User Guide* available at the [EDB website](/bart/2.6/bart_user/). + +The following table describes the `BACKUP` options: + +| Options | Description | +| ---------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { \| all }`
`--server { \| all }` | Use this option to specify the database server to be backed up.
Specify `` to take a backup of the database server (as specified in the BART configuration file).
Specify `all` to take a backup of all servers. | +| `-F { p \| t }`
`--format { p \| t }` | Use this option to specify the backup file format.
Specify `p` option to take backup in plain text format and specify `t` option to take backup in tar format. If the `p` or `t` option is omitted, the default is tar format.
Use `p` option with the `BACKUP` subcommand when streaming is used as a backup method.
An incremental backup can only be taken in plain text format (`p`). | +| `-z`
`(--gzip)` | This option is applicable only for full backup and `tar` format. Use this option to enable gzip compression of tar files using the default compression level (typically 6). | +| `-c `
`--compress-level ` | This is applicable only for full backup and tar format. Use this option to specify the gzip compression level on the tar file output. `` is a digit from 1 through 9, with 9 being the best compression. | +| `--backup-name ` | Use this option to assign a user-defined, alphanumeric friendly name to the backup. The maximum permitted length of backup name is 49 characters.
For detailed information about this parameter, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/2.6/bart_user/).
If the option `--backup-name` is not specified and the `backup_name` parameter is not set for this database server in the BART configuration file, then the backup can only be referenced in other BART subcommands by the BART assigned backup identifier. | +| `--thread-count ` | Use this option to specify the number of worker threads to run in parallel to copy blocks for a backup.
For detailed information about the `--thread-count` parameter, see the EDB Backup and Recovery Installation and Upgrade Guide available at the [EDB website](/bart/2.6/bart_inst/). | +| `--with-pg_basebackup` | This is applicable only for full backup. Use this option to specify the use of `pg_basebackup` to take a full backup. The number of thread counts in effect is ignored as given by the `thread_count` parameter in the BART configuration file.
When taking a full backup, if the thread count in effect is greater than `1`, then the `pg_basebackup` utility is not used to take the full backup (parallel worker threads are used) unless the `--with-pg_basebackup` option is specified with the `BACKUP` subcommand. | +| `--no-pg_basebackup` | This is applicable only for full backup. Use this option to specify that `pg_basebackup` is not to be used to take a full backup.
When taking a full backup, if the thread count in effect is only `1`, then the `pg_basebackup` utility is used to take the full backup unless the `--no-pg_basebackup` option is specified with the `BACKUP` subcommand. | +| `--parent { \| }` | Use this option to take an incremental backup. The parent backup is a backup taken prior to the incremental backup; it can be either a full backup or an incremental backup. `` is the backup identifier of a parent backup and `` is the user-defined alphanumeric name of a parent backup. | +| `--check` | This is applicable only for incremental backup. Use this option to verify if the required MBM files are present in the BART backup catalog before taking an incremental backup. However, an actual incremental backup is not taken when the `--check` option is specified.
The `--parent` option must be used along with the `--check` option. | +| `--checksum-algorithm` | While taking a backup, you can specify one of the following values with the `--checksum-algorithm` option:
`--checksum-algorithm=MD5` (default) to generate MD5 checksum files.
`--checksum-algorithm=SHA256` to generate SHA256 checksum files.
`--checksum-algorithm=NONE` to skip generating checksum files. | + +**Examples** + +The following code sample demonstrates using variables with the `BACKUP` subcommand: + +```text +./bart backup -s ppas12 -Ft --backup-name "YEAR = %year MONTH = +%month DAY = %day" +``` + +```text +./bart backup -s ppas12 -Ft --backup-name "YEAR = %year MONTH = +%month DAY = %day %%" +``` + +```text +./bart show-backups -s ppas12 -i "test backup" +``` + +The following code sample displays the result of creating a full backup in the default tar format with gzip compression when the `BACKUP` subcommand was invoked. Note that checksums are generated for the full backup and user-defined tablespaces for the tar format backup: + +```text +[edb@localhost bin]$ ./bart BACKUP -s hr -z +INFO: DebugTarget - getVar(checkDiskSpace.bytesAvailable) +INFO: new backup identifier generated 1567591909098 +INFO: creating 5 harvester threads +NOTICE: all required WAL segments have been archived +INFO: backup completed successfully +INFO: +BART VERSION: 2.5 +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1567591909098 +BACKUP NAME: none +BACKUP PARENT: none +BACKUP LOCATION: /home/edb/bkup_new/hr/1567591909098 +BACKUP SIZE: 13.91 MB +BACKUP FORMAT: tar.gz +BACKUP TIMEZONE: America/New_York +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 0 +TABLESPACE(s): 3 +Oid Name Location +16387 test1 /home/edb/tbl1 +16388 test2 /home/edb/tbl2 +16389 test3 /home/edb/tbl3 + +START WAL LOCATION: 000000010000000000000025 +STOP WAL LOCATION: 000000010000000000000026 +BACKUP METHOD: streamed +BACKUP FROM: master +START TIME: 2019-09-04 06:11:49 EDT +STOP TIME: 2019-09-04 06:11:53 EDT +TOTAL DURATION: 4 sec(s) +``` + +The following code sample displays information about the directory containing the full backup: + +```text +[edb@localhost bin]$number_of_threads> +[edb@localhost bin]$ ls -l /home/edb/bkup_new/hr/ +total 8 +drwxrwxr-x. 3 edb edb 34 Aug 27 05:57 1566899819709 +drwxrwxr-x. 3 edb edb 58 Aug 27 05:57 1566899827751 +drwxrwxr-x. 3 edb edb 4096 Sep 4 06:11 1567591909098 +drwxrwxr-x. 2 edb edb 4096 Sep 4 06:11 archived_wals +[edb@localhost bin]$ +``` + +The following code sample displays information about the creation of a full backup while streaming the transaction log. Note that the `-Fp` option must be specified with the `BACKUP` subcommand when streaming is used as a backup method. + +```text +[edb@localhost bin]$ ./bart BACKUP -s ACCTG -Fp +INFO: DebugTarget - getVar(checkDiskSpace.bytesAvailable) +INFO: new backup identifier generated 1566898964200 +INFO: creating 5 harvester threads +NOTICE: pg_stop_backup complete, all required WAL segments have been archived +INFO: backup completed successfully +INFO: +BART VERSION: 2.5 +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1566898964200 +BACKUP NAME: none +BACKUP PARENT: none +BACKUP LOCATION: /home/edb/bkup_new/acctg/1566898964200 +BACKUP SIZE: 46.03 MB +BACKUP FORMAT: plain +BACKUP TIMEZONE: US/Eastern +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 0 +TABLESPACE(s): 0 +START WAL LOCATION: 000000010000000000000017 +BACKUP METHOD: streamed +BACKUP FROM: master +START TIME: 2019-08-27 05:42:44 EDT +STOP TIME: 2019-08-27 05:42:46 EDT +TOTAL DURATION: 2 sec(s) +``` + +The following code sample displays the assignment of a user-defined backup name with the `--backup-name` option: + +```text +[edb@localhost bin]$ ./bart BACKUP -s acctg --backup-name acctg_%year-%month-%day +INFO: DebugTarget - getVar(checkDiskSpace.bytesAvailable) +INFO: new backup identifier generated 1566899004804 +INFO: creating 5 harvester threads +NOTICE: pg_stop_backup complete, all required WAL segments have been archived +INFO: backup completed successfully +INFO: +BART VERSION: 2.5 +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1566899004804 +BACKUP NAME: acctg_2019-08-27 +BACKUP PARENT: none +BACKUP LOCATION: /home/edb/bkup_new/acctg/1566899004804 +BACKUP SIZE: 46.86 MB +BACKUP FORMAT: tar +BACKUP TIMEZONE: US/Eastern +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 0 +TABLESPACE(s): 0 +START WAL LOCATION: 00000001000000000000001A +BACKUP METHOD: streamed +BACKUP FROM: master +START TIME: 2019-08-27 05:43:24 EDT +STOP TIME: 2019-08-27 05:43:24 EDT +TOTAL DURATION: 0 sec(s) +``` + +The following code sample displays an incremental backup taken by specifying the `--parent` option. The option `-Fp` must be specified while taking an incremental backup as incremental backup can be taken only in plain text format. + +```text +[edb@localhost bin]$ ./bart BACKUP -s hr -Fp --parent hr_full_1 --backup-name +hr_incr_1 +INFO: DebugTarget - getVar(checkDiskSpace.bytesAvailable) +INFO: checking /home/edb/bkup_new/hr/archived_wals for MBM files from 0/20000028 to +0/22000000 +INFO: new backup identifier generated 1566899827751 +INFO: creating 5 harvester threads +NOTICE: all required WAL segments have been archived +INFO: backup completed successfully +INFO: +BART VERSION: 2.5 +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1566899827751 +BACKUP NAME: hr_incr_1 +BACKUP PARENT: 1566899819709 +BACKUP LOCATION: /home/edb/bkup_new/hr/1566899827751 +BACKUP SIZE: 7.19 MB +BACKUP FORMAT: plain +BACKUP TIMEZONE: America/New_York +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 0 +TABLESPACE(s): 0 +START WAL LOCATION: 000000010000000000000022 +STOP WAL LOCATION: 000000010000000000000023 +BACKUP METHOD: streamed +BACKUP FROM: master +START TIME: 2019-08-27 05:57:07 EDT +STOP TIME: 2019-08-27 05:57:08 EDT +TOTAL DURATION: 1 sec(s) +``` + + + +The following code sample displays an incremental backup taken by specifying the `--checksum-algorithm=NONE` option to skip generating checksum files. + +First, the bart-scanner is started. + +```text +edb@localhost bin]$ +[edb@localhost bin]$ ./bart-scanner -d --checksum-algorithm=NONE +DEBUG: sockPath = /tmp/fc557c1c8853d75f1cb52a8a578f371a +INFO: process created for server 'ppas11', pid = 19012 +DEBUG: could not load XLogReaderLibrary at this time, archived_wals is empty +``` + +Then, an incremental backup is taken with the `--checksum-algorithm=NONE` option to skip generating checksum files. + +```text +[edb@localhost bin]$ ./bart backup -s ppas11 -Fp --parent 1593506709152 --checksum-algorithm=NONE +INFO: DebugTarget - getVar(checkDiskSpace.bytesAvailable) +INFO: checking /home/edb/bkup/ppas11/archived_wals for MBM files from 1/D3000028 to 1/D9000000 +INFO: new backup identifier generated 1593507779811 +INFO: creating 5 harvester threads +NOTICE: pg_stop_backup complete, all required WAL segments have been archived +INFO: backup completed successfully +INFO: +BART VERSION: 2.6devel +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1593507779811 +BACKUP NAME: none +BACKUP PARENT: 1593506709152 +BACKUP LOCATION: /home/edb/bkup/ppas11/1593507779811 +BACKUP SIZE: 7.30 MB +BACKUP FORMAT: plain +BACKUP TIMEZONE: US/Eastern +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 0 +TABLESPACE(s): 0 +START WAL LOCATION: 0000000100000001000000D9 +BACKUP METHOD: streamed +BACKUP FROM: master +START TIME: 2020-06-30 05:02:59 EDT +STOP TIME: 2020-06-30 05:03:05 EDT +TOTAL DURATION: 6 sec(s) +``` + +!!! Note + To restore an incremental backup taken with the `--checksum-algorithm=NONE` option, you must specify [--disable-checksum while restoring](06_restore/#restoring_an_incremental_backup_using_disable_checksum). + +Similarly, you can specify `--checksum-algorithm=MD5` or `--checksum-algorithm=SHA256` while taking an incremental backup if you want to generate MD5 or SHAD256 checksum files. diff --git a/product_docs/docs/bart/2.6/bart_ref/01_bart_subcommands_examples/02_check_config.mdx b/product_docs/docs/bart/2.6/bart_ref/01_bart_subcommands_examples/02_check_config.mdx new file mode 100644 index 00000000000..69c51d5249e --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_ref/01_bart_subcommands_examples/02_check_config.mdx @@ -0,0 +1,65 @@ +--- +title: "CHECK-CONFIG" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/check_config.html" +--- + +The `CHECK-CONFIG` subcommand checks the global parameter settings as well as the database server configuration in the BART configuration file. + +The following syntax is used to check the BART configuration file global section settings. + +```text +bart CHECK-CONFIG +``` + +The following syntax is used to check the database server configuration settings. + +```text +bart CHECK-CONFIG [ –s ] +``` + +The following table describes the `CHECK-CONFIG` option: + +| Option | Description | +| ------------------------------------------- | ------------------------------------------------------------------------------------------------------------ | +| `-s ` `--server ` | `` is the name of the database server whose configuration parameter settings are to be checked. | + +**Example** + +The following code sample demonstrates successfully checking the BART configuration file global parameters with the `bart CHECK-CONFIG` command: + +```text +bash-4.1$ bart CHECK-CONFIG +INFO: Verifying that pg_basebackup is executable +INFO: success - +INFO: success - pg_basebackup(/usr/edb/as11/bin/pg_basebackup) returns +version 11.400000 +``` + +The following code sample demonstrates successfully checking the BART configuration file database server parameters with the `bart CHECK-CONFIG` command with the `–s` option: + +```text +[edb@localhost bin]$ ./bart check-config -s hr +INFO: Checking server hr +INFO: Verifying cluster_owner and ssh/scp connectivity +INFO: success +INFO: Verifying user, host, and replication connectivity +INFO: success +INFO: Verifying that user is a database superuser +INFO: success +INFO: Verifying that cluster_owner can read cluster data files +INFO: success +INFO: Verifying that you have permission to write to vault +INFO: success +INFO: /home/edb/bkup_new/hr +INFO: Verifying database server configuration +INFO: success +INFO: Verifying that WAL archiving is working +INFO: waiting 30 seconds for +/home/edb/bkup_new/hr/archived_wals/00000001000000000000001E +INFO: success +INFO: Verifying that bart-scanner is configured and running +INFO: success +``` diff --git a/product_docs/docs/bart/2.6/bart_ref/01_bart_subcommands_examples/03_delete.mdx b/product_docs/docs/bart/2.6/bart_ref/01_bart_subcommands_examples/03_delete.mdx new file mode 100644 index 00000000000..f440e10a66b --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_ref/01_bart_subcommands_examples/03_delete.mdx @@ -0,0 +1,141 @@ +--- +title: "DELETE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/delete.html" +--- + +The `DELETE` subcommand removes the subdirectory and data files from the BART backup catalog for the specified backups along with archived WAL files. + +**Syntax:** + +```text +bart DELETE –s +-i { all | [']{ | },... }['] } +[ -n ] +``` + +Note that when invoking the `DELETE` subcommand, you must specify a database server. + +For database servers under a retention policy, there are conditions where certain backups may not be deleted. For more information, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/2.6/bart_user/). + +The following table describes the `DELETE` options: + +| Options | Description | +| -------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s `
`--server ` | `` is the name of the database server whose backups are to be deleted. | +| ``-i { all \| [']{ \| }',... }[`] }``

``--backupid { all \| [']{ \| }',... }[`] }`` | `` is the backup identifier of the backup to be deleted. `` is the user-defined alphanumeric name for the backup.
Multiple backup identifiers and backup names may be specified in a comma-separated list. The list must be enclosed within single quotes if there is any white space appearing before or after each comma (see [Example](#deleting_multiple_backups_with_space_characters)).
If `all` is specified, all backups and their archived WAL files for the specified database server are deleted. | +| `-n`
`--dry-run` | Performs the test run and displays the results prior to physically removing files; no files are actually deleted. | + +**Example** + +The following code sample demonstrates deleting a backup from the specified database server: + +```text +[edb@localhost bin]$ ./bart DELETE -s acctg -i acctg_2019-08-27 +INFO: deleting backup 'acctg_2019-08-27' of server 'acctg' +INFO: deleting backup '1566900093665' +INFO: WALs of deleted backup(s) will belong to prior backup(if any), or will +be marked unused +WARNING: not marking any WALs as unused WALs, the WAL file +'/home/edb/bkup_new/acctg/archived_wals/000000010000000000000025' +is required, yet not available in archived_wals directory +INFO: backup(s) deleted +[edb@localhost bin]$ +``` + +After the deletion, the BART backup catalog for the database server no longer contains the corresponding directory for the deleted `backup ID`. The following code sample displays information about `archived_wals` subdirectory that no longer contains the backup WAL files: + +```text +[edb@localhost acctg]$ ls -l +total 16 +drwxrwxr-x. 3 edb edb 4096 Aug 27 06:03 1566900199604 +drwxrwxr-x. 3 edb edb 4096 Aug 27 06:03 1566900204377 +drwxrwxr-x. 3 edb edb 4096 Aug 27 06:03 1566900209087 +drwxrwxr-x. 3 edb edb 4096 Aug 27 06:05 1566900321228 +drwxrwxr-x. 2 edb edb 6 Aug 27 06:01 archived_wals +``` + +The following code sample demonstrates deleting multiple backups from the database server. + +```text +[edb@localhost bin]$ ./bart DELETE -s acctg -i `1566988095633,1566988100760, +acctg_2019-08-28` +INFO: deleting backup `1566988095633` of server `acctg` +INFO: deleting backup `1566988095633` +INFO: WALs of deleted backup(s) will belong to prior backup(if any), or will +be marked unused +WARNING: not marking any WALs as unused WALs, the WAL file +`/home/edb/bkup_new/acctg/archived_wals/000000010000000000000037` is required, +yet not available in archived_wals directory +INFO: backup(s) deleted +INFO: deleting backup `1566988100760` of server `acctg` +INFO: deleting backup `1566988100760` +INFO: WALs of deleted backup(s) will belong to prior backup(if any), or will +be marked unused +WARNING: not marking any WALs as unused WALs, the WAL file +`/home/edb/bkup_new/acctg/archived_wals/000000010000000000000039` is +required, yet not available in archived_wals directory +INFO: backup(s) deleted +INFO: deleting backup `acctg_2019-08-28` of server `acctg` +INFO: deleting backup `1566988115512` +INFO: WALs of deleted backup(s) will belong to prior backup(if any), or will +be marked unused +WARNING: not marking any WALs as unused WALs, the WAL file +`/home/edb/bkup_new/acctg/archived_wals/00000001000000000000003C` is required, +yet not available in archived_wals directory +INFO: backup(s) deleted +[edb@localhost bin]$ +[edb@localhost bin]$ +[edb@localhost bin]$ +[edb@localhost acctg]$ +[edb@localhost acctg]$ ls -l +total 8 +drwxrwxr-x. 3 edb edb 4096 Aug 28 06:28 1566988105086 +drwxrwxr-x. 3 edb edb 4096 Aug 28 06:28 1566988109477 +drwxrwxr-x. 2 edb edb 6 Aug 28 06:09 archived_wals +[edb@localhost acctg]$ +``` + + + +**Deleting Multiple Backups with Space Characters** + +The following code sample demonstrates deleting multiple backups; since there are space characters in the comma-separated list, the entire list must be enclosed within single quotes: + +```text +[edb@localhost bin]$ ./bart DELETE -s acctg -i +`1566900199604,1566900204377,1566900209087`; +INFO: deleting backup `1566900199604` of server `acctg` +INFO: deleting backup `1566900199604` +INFO: WALs of deleted backup(s) will belong to prior backup(if any), or will +be marked unused +WARNING: not marking any WALs as unused WALs, the WAL file +`/home/edb/bkup_new/acctg/archived_wals/000000010000000000000028` is required, +yet not available in archived_wals directory +INFO: backup(s) deleted +INFO: deleting backup `1566900204377` of server `acctg` +INFO: deleting backup `1566900204377` +INFO: WALs of deleted backup(s) will belong to prior backup(if any), or will +be marked unused +WARNING: not marking any WALs as unused WALs, the WAL file +`/home/edb/bkup_new/acctg/archived_wals/00000001000000000000002A` is required, +yet not available in archived_wals directory +INFO: backup(s) deleted +INFO: deleting backup `1566900209087` of server `acctg` +INFO: deleting backup `1566900209087` +INFO: WALs of deleted backup(s) will belong to prior backup(if any), or will +be marked unused +WARNING: not marking any WALs as unused WALs, the WAL file +`/home/edb/bkup_new/acctg/archived_wals/00000001000000000000002C` is required, +yet not available in archived_wals directory +INFO: backup(s) deleted +[edb@localhost bin]$ +[edb@localhost bin]$ +[edb@localhost acctg]$ ls -l +total 4 +drwxrwxr-x. 3 edb edb 4096 Aug 27 06:05 1566900321228 +drwxrwxr-x. 2 edb edb 6 Aug 27 06:01 archived_wals +[edb@localhost acctg]$ +``` diff --git a/product_docs/docs/bart/2.6/bart_ref/01_bart_subcommands_examples/04_init.mdx b/product_docs/docs/bart/2.6/bart_ref/01_bart_subcommands_examples/04_init.mdx new file mode 100644 index 00000000000..9f8b020ac03 --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_ref/01_bart_subcommands_examples/04_init.mdx @@ -0,0 +1,276 @@ +--- +title: "INIT" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/init.html" +--- + + + +The `INIT` subcommand is used to create the BART backup catalog directory, rebuild the BART `backupinfo` file, and set the `archive_command` in the server based on the `archive_command` setting in the `bart.cfg` file. + +**Syntax:** + +```text +bart INIT [ –s { | all } ] [ -o ] + +[ -r [ -i { | | all } ] ] + +[--no-configure] +``` + +The following table describes the `INIT` options: + +| Options | Description | +| ------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { \| all }`
`--server { \| all }` | `` is the name of the database server to which the `INIT` actions are to be applied. If `all` is specified or if the option is omitted, actions are applied to all servers. | +| `-o`
`--override` | Overrides the existing Postgres `archive_command` configuration parameter setting in the `postgresql.conf` file or the `postgresql.auto.conf` file using the BART `archive_command` parameter in the BART configuration file. The `INIT` generated `archive command` string is written to the `postgresql.auto.conf` file. | +| `-r`
`--rebuild` | Rebuilds the `backupinfo` file located in each backup subdirectory. If `all` is specified or if the option is omitted, the `backupinfo` files of all backups for the database servers specified by the `-s` option are recreated. This option is only intended for recovering from a situation where the backupinfo file has become corrupt.
If the backup was initially created with a user-defined backup name, and then the `INIT -r` option is invoked to rebuild that `backupinfo` file, the user-defined backup name is no longer available. Thus, future references to the backup must use the backup identifier. | +| `-i { \| \| all }`
`--backupid { \| \| all }` | `` is an integer, backup identifier and `` is the user-defined alphanumeric name for the backup. The `-i` option can only be used with the `-r` option. | +| `--no-configure` | Prevents the `archive_command` from being set in the PostgreSQL server. | + +**Examples** + +In the following code sample, you can see that `archive_mode = off` and `archive_command` is not set. After invoking the BART `INIT` subcommand, `archive_mode` is set to `on` and `archive_command` is set: + +```text +archive_mode = off # enables archiving; off, on, or always +# (change requires restart) +archive_command = '' +# command to use to archive a logfile segment +[edb@localhost bin]$ ./bart init -s ppas11 +INFO: setting archive_mode/archive_command for server 'ppas11' +WARNING: archive_mode/archive_command is set. Restart the PostgreSQL +server using 'pg_ctl restart' +[edb@localhost bin]$ +# Do not edit this file manually! +# It will be overwritten by the ALTER SYSTEM command. +archive_mode = 'on' +archive_command = 'scp %p +edb@127.0.0.1:/home/edb/bkup/ppas11/archived_wals/%f' +``` + +In the following code sample, you can see that `archive_mode = on`, and `archive_command` is not set. After invoking the `INIT` subcommand, `archive_command` is set: + +```text +archive_mode = on # enables archiving; off, on, or always +# (change requires restart) +archive_command = '' # command to use to archive a logfile segment +[edb@localhost bin]$ ./bart init -s ppas11 +INFO: setting archive_mode/archive_command for server 'ppas11' +WARNING: archive_command is set. Reload the configuration in the +PostgreSQL server using pg_reload_conf() or 'pg_ctl reload' +[edb@localhost bin]$ +# Do not edit this file manually! +# It will be overwritten by the ALTER SYSTEM command. +archive_command = 'scp %p +edb@127.0.0.1:/home/edb/bkup/ppas11/archived_wals/%f' +``` + +In the following code sample, you can see that `archive_mode = on` and `archive_command` are already set. After invoking the `INIT` subcommand, there is no change in their settings. Note that to override the existing `archive_command`, you must include the `-o` option. + +```text +archive_mode = on # enables archiving; off, on, or always +# (change requires restart) +archive_command = 'scp %p +edb@127.0.0.1:/home/edb/bkup/ppas11/archived_wals/%f' # command to use +to archive a logfile segment +# placeholders: %p = path of file to archive +[edb@localhost bin]$ ./bart init -s ppas11 +INFO: setting archive_mode/archive_command for server 'ppas11' +WARNING: archive_command is not set for server 'ppas11' +[edb@localhost bin]$ +# Do not edit this file manually! +# It will be overwritten by the ALTER SYSTEM command. +``` + +In the following code sample, you can see that `archive_mode = off` and `archive_command` is already set. After invoking the `INIT` subcommand `archive_mode` is set to `on`: + +```text +archive_mode = off # enables archiving; off, on, or always +# (change requires restart) +archive_command = 'scp %p +edb@127.0.0.1:/home/edb/bkup/ppas11/archived_wals/%f' # command to use +to archive a log file segment +[edb@localhost bin]$ ./bart init -s ppas11 +INFO: setting archive_mode/archive_command for server 'ppas11' +WARNING: archive_mode/archive_command is set. Restart the PostgreSQL +server using 'pg_ctl restart' +# Do not edit this file manually! +# It will be overwritten by the ALTER SYSTEM command. +archive_mode = 'on' +archive_command = 'scp %p +edb@127.0.0.1:/home/edb/bkup/ppas11/archived_wals/%f' +``` + +In the following code sample an existing `archive command` setting is overridden by resetting the `archive_command` in the PostgreSQL server with the `archive_command = 'cp %p %a/%f'` parameter from the `bart.cfg` file: + +```text +[BART] + +bart_host= enterprisedb@192.168.2.22 +backup_path = /opt/backup_edb +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log + +[ACCTG] + +host = 127.0.0.1 +port = 5444 +user = repuser +cluster_owner = enterprisedb +archive_command = 'cp %p %a/%f' +description = "Accounting" +``` + +The `archive_mode` and `archive_command` parameters in the database server are set as follows: + +```text +edb=# SHOW archive_mode; +archive_mode +-------------- +on +(1 row) +edb=# SHOW archive_command; +archive_command +------------------------------------------------------------------ +scp %p bartuser@192.168.2.22:/opt/backup/acctg/archived_wals/%f + +(1 row) +``` + +Invoke the `INIT` subcommand with the `-o` option to override the current `archive_command` setting in the PostgreSQL server: + +```text +-bash-4.1$ bart INIT -s acctg -o +INFO: setting archive_mode/archive_command for server 'acctg' +WARNING: archive_command is set. Reload the configuration in the +PostgreSQL server using pg_reload_conf() or 'pg_ctl reload' +``` + +Reload the database server configuration; a restart of the database server is not necessary to reset only the `archive_command` parameter: + +```text +[root@localhost tmp]# service ppas11 reload +``` + +The `archive_command` in the PostgreSQL server is now set as follows: + +```text +edb=# SHOW archive_command; + archive_command +----------------------------------------------- +cp %p /opt/backup_edb/acctg/archived_wals/%f +(1 row) +``` + +The new command string is written to the `postgresql.auto.conf` file: + +```text +# Do not edit this file manually! +# It will be overwritten by ALTER SYSTEM command. +archive_command = 'cp %p /opt/backup_edb/acctg/archived_wals/%f' +``` + +When you invoke the BART `INIT` command with the `-r` option, BART rebuilds the `backupinfo` file using the content of the backup directory for the server specified or for all servers. The BART `backupinfo` file is initially created by the `BACKUP` subcommand and contains the backup information used by BART. + +!!! Note + If the backup was initially created with a user-defined backup name, and then the `INIT -r` option is invoked to rebuild the `backupinfo` file, the user-defined backup name is no longer available. Thus, future references to the backup must use the backup identifier. + +The following code sample shows the `backupinfo` file location in a backup subdirectory: + +```text +[root@localhost acctg]# pwd +/opt/backup/acctg +[root@localhost acctg]# ls -l +total 4 +drwx------ 2 enterprisedb enterprisedb 38 Oct 26 10:21 1477491569966 +drwxrwxr-x 2 enterprisedb enterprisedb 4096 Oct 26 10:19 archived_wals +[root@localhost acctg]# ls -l 1477491569966 +total 61144 +-rw-rw-r-- 1 enterprisedb enterprisedb 703 Oct 26 10:19 backupinfo +-rw-rw-r-- 1 enterprisedb enterprisedb 62603776 Oct 26 10:19 base.tar +``` + +The following code sample displays the `backupinfo` file content: + +```text +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1477491569966 +BACKUP NAME: none +BACKUP PARENT: none +BACKUP LOCATION: /opt/backup/acctg/1477491569966 +BACKUP SIZE: 59.70 MB +BACKUP FORMAT: tar +BACKUP TIMEZONE: +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 1 +ChkSum File +84b3eeb1e3f7b3e75c2f689570d04f10 base.tar +TABLESPACE(s): 0 +START WAL LOCATION: 2/A5000028 (file 0000000100000002000000A5) +STOP WAL LOCATION: 2/A50000C0 (file 0000000100000002000000A5) +CHECKPOINT LOCATION: 2/A5000028 +BACKUP METHOD: streamed +BACKUP FROM: master +START TIME: 2016-10-26 10:19:30 EDT +LABEL: pg_basebackup base backup +STOP TIME: 2016-10-26 10:19:30 EDT +TOTAL DURATION: 0 sec(s) +``` + +The following code sample displays an error message if the `backupinfo` file is missing when invoking a BART subcommand: + +```text +-bash-4.2$ bart SHOW-BACKUPS +ERROR: 'backupinfo' file does not exist for backup '1477491569966' +please use 'INIT -r' to generate the file +``` + +The `backupinfo` file may be missing if the `BACKUP` subcommand did not complete successfully. + +The following code sample displays information about rebuilding the `backupinfo` file of the specified backup for database server `acctg`: + +```text +-bash-4.1$ bart INIT -s acctg -r -i 1428346620427 +INFO: rebuilding BACKUPINFO for backup '1428346620427' of server 'acctg' +INFO: backup checksum: ced59b72a7846ff8fb8afb6922c70649 of base.tar +``` + +The following code sample displays information about how the `backupinfo` files of all backups are rebuilt for all database servers: + +```text +-bash-4.1$ bart INIT -r + +INFO: rebuilding BACKUPINFO for backup '1428347191544' of server 'acctg' +INFO: backup checksum: 1ac5c61f055c910db314783212f2544f of base.tar +INFO: rebuilding BACKUPINFO for backup '1428346620427' of server 'acctg' +INFO: backup checksum: ced59b72a7846ff8fb8afb6922c70649 of base.tar +INFO: rebuilding BACKUPINFO for backup '1428347198335' of server 'dev' +INFO: backup checksum: a8890dd8ab7e6be5d5bc0f38028a237b of base.tar +INFO: rebuilding BACKUPINFO for backup '1428346957515' of server 'dev' +INFO: backup checksum: ea62549cf090573625d4adeb7d919700 of base.tar +``` + +The following code sample displays information about invoking `BART INIT` with the `-r - i` option: + +```text +edb@localhost bin]$ ./bart init -s ppas11 -i 1551778898392 -r +INFO: rebuilding BACKUPINFO for backup '1551778898392' of server +'ppas11' +[edb@localhost bin]$ ls /home/edb/bkup/ppas11/1551778898392/ +backupinfo backup_label base base-1.tar base-2.tar base-3.tar +base-4.tar base-5.tar base.tar +``` + +The following code sample displays information about invoking the `BART INIT` command with the `--no-configure` option. You can use the `--no-configure` option with the `INIT` subcommand to prevent the `archive_command` option from being set in the PostgreSQL server. + +```text +[edb@localhost bin]$ ./bart init -s ppas11 -o --no-configure +[edb@localhost bin]$ +# Do not edit this file manually! +# It will be overwritten by the ALTER SYSTEM command. +``` diff --git a/product_docs/docs/bart/2.6/bart_ref/01_bart_subcommands_examples/05_manage.mdx b/product_docs/docs/bart/2.6/bart_ref/01_bart_subcommands_examples/05_manage.mdx new file mode 100644 index 00000000000..79716d976ee --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_ref/01_bart_subcommands_examples/05_manage.mdx @@ -0,0 +1,228 @@ +--- +title: "MANAGE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/manage.html" +--- + +The `MANAGE` subcommand can be invoked to: + +- Evaluate backups, mark their status, and delete obsolete backups based on the `retention_policy` parameter in the BART configuration file. +- Compress the archived WAL files based on the `wal_compression` parameter in the BART configuration file. + +**Syntax:** + +```text +bart MANAGE [ –s { | all} ] +[ -l ] [ -d ] +[ -c { keep | nokeep } +-i { | | all } ] +[ -n ] +``` + +To view detailed information about the `MANAGE` subcommand and retention policy management, see *the EDB Backup and Recovery User Guide* available at the [EDB website](/bart/2.6/bart_user/). For information about setting the `wal_compression` parameter, see the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/2.6/bart_inst/). + +The following table describes the `MANAGE` options: + +| Options | Description | +| ---------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `-s [ \| all ]`
`--server [ \| all ]` | `` is the name of the database server to which the `MANAGE` actions are to be applied.
If `all` is specified or if the `-s` option is omitted, actions are applied to all database servers. | +| `-l`
`--list-obsolete` | Lists the backups marked as obsolete. | +| `-d`
`--delete-obsolete` | Deletes the backups marked as obsolete. This action physically deletes the backup along with its archived WAL files and any MBM files for incremental backups. | +| `-c { keep \| nokeep }`
`--change-status { keep \| nokeep }` | Specify `keep` to change the backup status to `keep` to retain the backup indefinitely.

Specify `nokeep` to change the backup status back to `active`. You can then re-evaluate and possibly mark the backup as `obsolete` (according to the retention policy) using the `MANAGE` subcommand.

The `-c` option can only be used with the `-i` option. | +| `-i { \| \| all` }

`--backupid { \| \| all` } | `` is a backup identifier and `` is the user-defined alphanumeric name for the backup.
If `all` is specified, actions are applied to all backups.
The `-i` option can only be used with the `-c` option. | +| `-n`
`--dry-run` | Performs the test run and displays the results prior to actually implementing the actions as if the operation was performed, however, no changes are actually made.
If you specify `-n` with the `-d` option, it displays which backups would be deleted, but does not actually delete the backups.
If you specify `-n` with the `-c` option, it displays the keep or nokeep action, but does not actually change the backup status.
If you specify `-n` alone with no other options or if you specify `-n` with only the `-s` option, it displays which active backups would be marked as obsolete, but does not actually change the backup status. In addition, no compression is performed on uncompressed, archived WAL files even if WAL compression is enabled for the database server. | + +**Example** + +The following code sample performs a dry run for the specified database server displaying which active backups are evaluated as obsolete according to the retention policy, but does not actually change the backup status: + +```text +-bash-4.2$ bart MANAGE -s acctg -n +INFO: processing server 'acctg', backup '1482770807519' +INFO: processing server 'acctg', backup '1482770803000' +INFO: marking backup '1482770803000' as obsolete +INFO: 1 WAL file(s) marked obsolete +INFO: processing server 'acctg', backup '1482770735155' +INFO: marking backup '1482770735155' as obsolete +INFO: 2 incremental(s) of backup '1482770735155' will be marked obsolete +INFO: marking incremental backup '1482770780423' as obsolete +INFO: marking incremental backup '1482770763227' as obsolete +INFO: 3 WAL file(s) marked obsolete +INFO: 1 Unused WAL file(s) present +INFO: 2 Unused file(s) (WALs included) present, use 'MANAGE -l' for the +list +``` + +The following code sample marks active backups as obsolete according to the retention policy for the specified database server: + +```text +-bash-4.2$ bart MANAGE -s acctg +INFO: processing server 'acctg', backup '1482770807519' +INFO: processing server 'acctg', backup '1482770803000' +INFO: marking backup '1482770803000' as obsolete +INFO: 1 WAL file(s) marked obsolete +INFO: processing server 'acctg', backup '1482770735155' +INFO: marking backup '1482770735155' as obsolete +INFO: 2 incremental(s) of backup '1482770735155' will be marked obsolete +INFO: marking incremental backup '1482770780423' as obsolete +INFO: marking incremental backup '1482770763227' as obsolete +INFO: 3 WAL file(s) marked obsolete +INFO: 1 Unused WAL file(s) present +INFO: 2 Unused file(s) (WALs included) present, use 'MANAGE -l' for the +list +``` + +The following code sample lists backups marked as obsolete for the specified database server: + +```text +-bash-4.2$ bart MANAGE -s acctg -l +SERVER NAME: acctg +BACKUP ID: 1482770803000 +BACKUP STATUS: obsolete +BACKUP TIME: 2016-12-26 11:46:43 EST +BACKUP SIZE: 59.52 MB +WAL FILE(s): 1 +WAL FILE: 000000010000000100000055 +SERVER NAME: acctg +BACKUP ID: 1482770735155 +BACKUP STATUS: obsolete +BACKUP TIME: 2016-12-26 11:45:35 EST +BACKUP SIZE: 59.52 MB +INCREMENTAL BACKUP(s): 2 +BACKUP ID: 1482770780423 +BACKUP PARENT: 1482770735155 +BACKUP STATUS: obsolete +BACKUP TIME: 2016-12-26 11:45:35 EST +BACKUP SIZE: 59.52 MB +BACKUP ID: 1482770763227 +BACKUP PARENT: 1482770735155 +BACKUP STATUS: obsolete +BACKUP TIME: 2016-12-26 11:45:35 EST +BACKUP SIZE: 59.52 MB +WAL FILE(s): 3 +WAL FILE: 000000010000000100000054 +WAL FILE: 000000010000000100000053 +WAL FILE: 000000010000000100000052 +UNUSED FILE(s): 2 +UNUSED FILE: 000000010000000100000051 +UNUSED FILE: 0000000100000001510000280000000152000000.mbm +``` + +The following code sample deletes the obsolete backups for the specified database server: + +```text +-bash-4.2$ bart MANAGE -s acctg -d +INFO: removing all obsolete backups of server 'acctg' +INFO: removing obsolete backup '1482770803000' +INFO: 1 WAL file(s) will be removed +INFO: removing WAL file '000000010000000100000055' +INFO: removing obsolete backup '1482770735155' +INFO: 3 WAL file(s) will be removed +INFO: 2 incremental(s) of backup '1482770735155' will be removed +INFO: removing obsolete incremental backup '1482770780423' +INFO: removing obsolete incremental backup '1482770763227' +INFO: removing WAL file '000000010000000100000054' +INFO: removing WAL file '000000010000000100000053' +INFO: removing WAL file '000000010000000100000052' +INFO: 8 Unused file(s) will be removed +INFO: removing (unused) file '000000010000000100000056.00000028.backup' +INFO: removing (unused) file '000000010000000100000056' +INFO: removing (unused) file '000000010000000100000055.00000028.backup' +INFO: removing (unused) file '000000010000000100000054.00000028.backup' +INFO: removing (unused) file '000000010000000100000053.00000028.backup' +INFO: removing (unused) file '000000010000000100000052.00000028.backup' +INFO: removing (unused) file '000000010000000100000051' +INFO: removing (unused) file +'0000000100000001510000280000000152000000.mbm' +``` + +The following code sample changes the specified backup to keep status to retain it indefinitely: + +```text +-bash-4.2$ bart MANAGE -s acctg -c keep -i 1482770807519 +INFO: changing status of backup '1482770807519' of server 'acctg' from +'active' to 'keep' +INFO: 1 WAL file(s) changed +-bash-4.2$ bart SHOW-BACKUPS -s acctg -i 1482770807519 -t +SERVER NAME : acctg +BACKUP ID : 1482770807519 +BACKUP NAME : none +BACKUP PARENT : none +BACKUP STATUS : keep +BACKUP TIME : 2016-12-26 11:46:47 EST +BACKUP SIZE : 59.52 MB +WAL(S) SIZE : 16.00 MB +NO. OF WALS : 1 +FIRST WAL FILE : 000000010000000100000057 +CREATION TIME : 2016-12-26 11:52:47 EST +LAST WAL FILE : 000000010000000100000057 +CREATION TIME : 2016-12-26 11:52:47 EST +``` + +The following code sample resets the specified backup to active status: + +```text +-bash-4.2$ bart MANAGE -s acctg -c nokeep -i 1482770807519 +INFO: changing status of backup '1482770807519' of server 'acctg' from +'keep' to 'active' +INFO: 1 WAL file(s) changed +-bash-4.2$ bart SHOW-BACKUPS -s acctg -i 1482770807519 -t +SERVER NAME : acctg +BACKUP ID : 1482770807519 +BACKUP NAME : none +BACKUP PARENT : none +BACKUP STATUS : active +BACKUP TIME : 2016-12-26 11:46:47 EST +BACKUP SIZE : 59.52 MB +WAL(S) SIZE : 16.00 MB +NO. OF WALS : 1 +FIRST WAL FILE : 000000010000000100000057 +CREATION TIME : 2016-12-26 11:52:47 EST +LAST WAL FILE : 000000010000000100000057 +CREATION TIME : 2016-12-26 11:52:47 EST +``` + +The following code sample uses the enabled `wal_compression` parameter in the BART configuration file as shown by the following: + +```text +[ACCTG] + +host = 127.0.0.1 +port = 5445 +user = enterprisedb +cluster_owner = enterprisedb +allow_incremental_backups = disabled +wal_compression = enabled +description = "Accounting" +``` + +When the `MANAGE` subcommand is invoked, the following message is displayed indicating that WAL file compression is performed: + +```text +-bash-4.2$ bart MANAGE -s acctg +INFO: 4 WAL file(s) compressed +WARNING: 'retention_policy' is not set for server 'acctg' +``` + +The following code sample shows the archived WAL files in compressed format: + +```text +-bash-4.2$ pwd +/opt/backup/acctg +-bash-4.2$ ls -l archived_wals +total 160 +-rw------- 1 enterprisedb enterprisedb 27089 Dec 26 12:16 +00000001000000010000005B.gz +-rw------- 1 enterprisedb enterprisedb 305 Dec 26 12:17 +00000001000000010000005C.00000028.backup +-rw------- 1 enterprisedb enterprisedb 27112 Dec 26 12:17 +00000001000000010000005C.gz +-rw------- 1 enterprisedb enterprisedb 65995 Dec 26 12:18 +00000001000000010000005D.gz +-rw------- 1 enterprisedb enterprisedb 305 Dec 26 12:18 +00000001000000010000005E.00000028.backup +-rw------- 1 enterprisedb enterprisedb 27117 Dec 26 12:18 +00000001000000010000005E.gz +``` diff --git a/product_docs/docs/bart/2.6/bart_ref/01_bart_subcommands_examples/06_restore.mdx b/product_docs/docs/bart/2.6/bart_ref/01_bart_subcommands_examples/06_restore.mdx new file mode 100644 index 00000000000..57f969b5b72 --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_ref/01_bart_subcommands_examples/06_restore.mdx @@ -0,0 +1,175 @@ +--- +title: "RESTORE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/restore.html" +--- + +The `RESTORE` subcommand restores a backup and its archived WAL files for the designated database server to the specified directory location. + +**Syntax for Restore**: + +```text +bart RESTORE –s -p +[ –i { | } ] +[ -r @ ] +[ -w ] +[ -t ] +[ { -x | -g } ] +[ -c ] +[ --disable-checksum ] +``` + +To view detailed information about the `RESTORE` subcommand, see the *EDB Backup and Recovery User Guide* available at the [EDB website](/bart/2.6/bart_user/). + +If the backup is restored to a different database cluster directory than where the original database cluster resided, then some operations dependent upon the database cluster location may fail. This happens if the supporting service scripts are not updated to reflect the new directory location of restored backup. + +For information about the use and modification of service scripts, see the EDB Advanced Server Installation Guide. + +The following table describes the `RESTORE` options: + +| Options | Description | +| --------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s `
`--server ` | `` is the name of the database server to be restored. | +| `-p --restore-path `
`--restore-path ` | `` is the directory path where the backup of the database server is to be restored. The directory must be empty and have the proper ownership and privileges assigned to it. | +| `-i { \| }`

`--backupid { \| }` | `backup_id` is the backup identifier of the backup to be used for the restoration and `` is the user-defined alphanumeric name for the backup.
If the option is omitted, the latest backup is restored by default. | +| `-r `

`--remote-host ` | `` is the user account on the remote database server host that accepts a passwordless SSH/SCP login connection and is the owner of the directory where the backup is to be restored.
`` is the IP address of the remote host to which the backup is to be restored. This option must be specified if the `remote_host` parameter for this database server is not set in the BART configuration file.
For information about the `remote_host` parameter, see the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/2.6/bart_inst/). | +| `-w `
`--workers ` | `` is the number of worker processes to run in parallel to stream the modified blocks of an incremental backup to the restore location. If the `-w` option is omitted, the default is `1` worker process.
For example, if four worker processes are specified, four receiver processes on the restore host and four streamer processes on the BART host are used. The output of each streamer process is connected to the input of a receiver process.
When the receiver gets to the point where it needs a modified block file, it obtains those modified blocks from its input. With this method, the modified block files are never written to the restore host disk. | +| `-t `
`--target-tli ` | `` is the integer identifier of the timeline to be used for replaying the archived WAL files for point-in-time recovery. | +| `-x `
`--target-xid ` | `` is the integer identifier of the transaction ID that determines the transaction up to and including, which point-in-time recovery encompasses. | +| `-g `

`--target-timestamp ` | `` is the timestamp that determines the point in time up to and including, which point-in-time recovery encompasses. | +| `-c`

`--copy-wals` | Specify this option to copy archived WAL files from the BART backup catalog to `/archived_wals` directory.
The `restore_command` retrieves the WAL files from `/archived_wals` for the database server archive recovery.
If the `-c` option is omitted and the `copy_wals_during_restore` parameter in the BART configuration file is not enabled in a manner applicable to this database server, then the `restore_command` in the `postgresql.conf` retrieves the archived WAL files directly from the BART backup catalog.
For information about the `copy_wals_during_restore` parameter, see the EDB Backup and Recovery Installation and Upgrade Guide available at the [EDB website](/bart/2.6/bart_inst/). | +| `--disable-checksum` | While restoring a backup, specify this option to skip verifying the MD5 or SHA256 checksum files.
If you set the `--checksum-algorithm=NONE` option with the BART scanner or while taking a backup, you also need to specify the `--disable checksum` option while restoring an incremental backup. | + +**Examples** + +The following code sample restores a database server(named `mktg`) to the `/opt/restore` directory up to timestamp `2015-12-15 10:47:00`: + +```text +-bash-4.1$ bart RESTORE -s mktg -i 1450194208824 -p /opt/restore -t 1 -g +'2015-12-15 10:47:00' +INFO: restoring backup '1450194208824' of server 'mktg' +INFO: restoring backup to enterprisedb@192.168.2.24:/opt/restore +INFO: base backup restored +INFO: WAL file(s) will be streamed from the BART host +INFO: writing recovery settings to postgresql.auto.conf file +INFO: archiving is disabled +INFO: tablespace(s) restored +``` + +The following parameters are set in the `postgresql.auto.conf` file: + +```text +restore_command = 'scp -o BatchMode=yes -o PasswordAuthentication=no +enterprisedb@192.168.2.22:/opt/backup/mktg/archived_wals/%f %p' +recovery_target_time = '2015-12-15 10:47:00' +recovery_target_timeline = 1 +``` + +The following is a list of the restored files and subdirectories: + +```text +[root@localhost restore]# pwd +/opt/restore +[root@localhost restore]# ls -l +total 108 +-rw------- 1 enterprisedb enterprisedb 208 Dec 15 10:43 backup_label +drwx------ 6 enterprisedb enterprisedb 4096 Dec 2 10:38 base +drwx------ 2 enterprisedb enterprisedb 4096 Dec 15 10:42 dbms_pipe +drwx------ 2 enterprisedb enterprisedb 4096 Dec 15 11:00 global +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_clog\ +-rw------- 1 enterprisedb enterprisedb 4438 Dec 2 10:38 pg_hba.conf +-rw------- 1 enterprisedb enterprisedb 1636 Nov 10 15:38 pg_ident.conf +drwxr-xr-x 2 enterprisedb enterprisedb 4096 Dec 15 10:42 pg_log +drwx------ 4 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_multixact +drwx------ 2 enterprisedb enterprisedb 4096 Dec 15 10:42 pg_notify +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_serial +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_snapshots +drwx------ 2 enterprisedb enterprisedb 4096 Dec 15 10:42 pg_stat +drwx------ 2 enterprisedb enterprisedb 4096 Dec 15 10:43 pg_stat_tmp +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_subtrans +drwx------ 2 enterprisedb enterprisedb 4096 Dec 15 11:00 pg_tblspc +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_twophase +-rw------- 1 enterprisedb enterprisedb 4 Nov 10 15:38 PG_VERSION +drwx------ 2 enterprisedb enterprisedb 4096 Dec 15 11:00 pg_xlog +-rw------- 1 enterprisedb enterprisedb 23906 Dec 15 11:00 +postgresql.conf +-rw-r--r-- 1 enterprisedb enterprisedb 217 Dec 15 11:00 +postgresql.auto.conf +``` + +**Example** + +The following code sample performs a `RESTORE` operation with the `copy_wals_during_restore` parameter enabled to copy the archived WAL files to the local `/archived_wals` directory: + +```text +-bash-4.1$ bart RESTORE -s hr -i hr_2017-03-29T13:50 -p +/opt/restore_pg96 -t 1 -g '2017-03-29 14:01:00' +INFO: restoring backup 'hr_2017-03-29T13:50' of server 'hr' +INFO: base backup restored +INFO: copying WAL file(s) to +postgres@192.168.2.24:/opt/restore_pg96/archived_wals +INFO: writing recovery settings to postgresql.auto.conf file +INFO: archiving is disabled +INFO: permissions set on $PGDATA +INFO: restore completed successfully +``` + +The following parameters are set in the `postgresql.auto.conf` file: + +```text +restore_command = 'cp archived_wals/%f %p' +recovery_target_time = '2017-03-29 14:01:00' +recovery_target_timeline = 1 +``` + +The following is a list of the restored files and subdirectories: + +```text +-bash-4.1$ pwd +/opt/restore_pg96 +-bash-4.1$ ls -l +total 128 +drwxr-xr-x 2 postgres postgres 4096 Mar 29 14:27 archived_wals +-rw------- 1 postgres postgres 206 Mar 29 13:50 backup_label +drwx------ 5 postgres postgres 4096 Mar 29 12:25 base +drwx------ 2 postgres postgres 4096 Mar 29 14:27 global +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_clog +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_commit_ts +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_dynshmem +-rw------- 1 postgres postgres 4212 Mar 29 13:18 pg_hba.conf +-rw------- 1 postgres postgres 1636 Mar 29 12:25 pg_ident.conf +drwxr-xr-x 2 postgres postgres 4096 Mar 29 13:45 pg_log +drwx------ 4 postgres postgres 4096 Mar 29 12:25 pg_logical +drwx------ 4 postgres postgres 4096 Mar 29 12:25 pg_multixact +drwx------ 2 postgres postgres 4096 Mar 29 13:43 pg_notify +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_replslot +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_serial +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_snapshots +drwx------ 2 postgres postgres 4096 Mar 29 13:43 pg_stat +drwx------ 2 postgres postgres 4096 Mar 29 13:50 pg_stat_tmp +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_subtrans +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_tblspc +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_twophase +-rw------- 1 postgres postgres 4 Mar 29 12:25 PG_VERSION +drwx------ 3 postgres postgres 4096 Mar 29 14:27 pg_xlog +-rw------- 1 postgres postgres 169 Mar 29 13:24 postgresql.auto.conf +-rw-r--r-- 1 postgres postgres 21458 Mar 29 14:27 postgresql.conf +-rw-r--r-- 1 postgres postgres 118 Mar 29 14:27 postgresql.auto.conf +``` + + + +The following code sample displays restoring an [incremental backup](01_backup/#incremental_backup_using_checksum_algorithm) taken using `--checksum-algorithm=NONE` option. To restore this incremental backup, you must specify the `--disable-checksum` option to skip verifying MD5 or SHA256 checksum files. + +```text +[edb@localhost bin]$ ./bart restore -s ppas11 -i 1593507779811 -p /home/edb/RESTORE/ --disable-checksum +INFO: restoring incremental backup '1593507779811' of server 'ppas11' +INFO: base backup restored +INFO: writing recovery.conf file +INFO: WAL file(s) will be streamed from the BART host +INFO: archiving is disabled +INFO: permissions set on $PGDATA +INFO: incremental restore completed successfully +``` diff --git a/product_docs/docs/bart/2.6/bart_ref/01_bart_subcommands_examples/07_show_servers.mdx b/product_docs/docs/bart/2.6/bart_ref/01_bart_subcommands_examples/07_show_servers.mdx new file mode 100644 index 00000000000..8ada69b5622 --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_ref/01_bart_subcommands_examples/07_show_servers.mdx @@ -0,0 +1,77 @@ +--- +title: "SHOW-SERVERS" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/show_servers.html" +--- + +The `SHOW-SERVERS` subcommand displays information for the managed database servers listed in the BART configuration file. + +**Syntax:** + +```text +bart SHOW-SERVERS [ –s { | all } ] +``` + +The following table describes the `SHOW-SERVERS` option: + +| Option | Description | +| ---------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { \| all` }
`--server { \| all` } | `` is the name of the database server to which the `SHOW-SERVERS` actions are to be applied.
If `all` is specified or if the `-s` option is omitted, the actions are applied to all database servers. | + +**Example** + +The following code sample shows all the database servers managed by BART as returned by the `SHOW-SERVERS` subcommand: + +```text +-bash-4.2$ bart SHOW-SERVERS +SERVER NAME : acctg +BACKUP FRIENDLY NAME: acctg_%year-%month-%dayT%hour:%minute +HOST NAME : 127.0.0.1 +USER NAME : enterprisedb +PORT : 5444 +REMOTE HOST : +RETENTION POLICY : 6 Backups +DISK UTILIZATION : 0.00 bytes +NUMBER OF ARCHIVES : 0 +ARCHIVE PATH : /opt/backup/acctg/archived_wals +ARCHIVE COMMAND : (disabled) +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +INCREMENTAL BACKUP : DISABLED +DESCRIPTION : "Accounting" +SERVER NAME : hr +BACKUP FRIENDLY NAME: hr_%year-%month-%dayT%hour:%minute +HOST NAME : 192.168.2.24 +USER NAME : postgres +PORT : 5432 +REMOTE HOST : postgres@192.168.2.24 +RETENTION POLICY : 6 Backups +DISK UTILIZATION : 0.00 bytes +NUMBER OF ARCHIVES : 0 +ARCHIVE PATH : /opt/backup/hr/archived_wals +ARCHIVE COMMAND : (disabled) +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +INCREMENTAL BACKUP : DISABLED +DESCRIPTION : "Human Resources" +SERVER NAME : mktg +BACKUP FRIENDLY NAME: mktg_%year-%month-%dayT%hour:%minute +HOST NAME : 192.168.2.24 +USER NAME : repuser +PORT : 5444 +REMOTE HOST : enterprisedb@192.168.2.24 +RETENTION POLICY : 6 Backups +DISK UTILIZATION : 0.00 bytes +NUMBER OF ARCHIVES : 0 +ARCHIVE PATH : /opt/backup/mktg/archived_wals +ARCHIVE COMMAND : (disabled) +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +INCREMENTAL BACKUP : DISABLED\ +DESCRIPTION : "Marketing" +``` diff --git a/product_docs/docs/bart/2.6/bart_ref/01_bart_subcommands_examples/08_show_backups.mdx b/product_docs/docs/bart/2.6/bart_ref/01_bart_subcommands_examples/08_show_backups.mdx new file mode 100644 index 00000000000..03b7727add3 --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_ref/01_bart_subcommands_examples/08_show_backups.mdx @@ -0,0 +1,100 @@ +--- +title: "SHOW-BACKUPS" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/show_backups.html" +--- + +The `SHOW-BACKUPS` subcommand displays the backup information for the managed database servers. + +**Syntax:** + +```text +bart SHOW-BACKUPS [ –s { | all } ] +[ -i { | | all } ] +[ -t ] +``` + +The following table describes the `SHOW-BACKUPS` options: + +| Options | Description | +| ------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { \| all` }

`--server { \| all` } | `` is the name of the database server whose backup information is to be displayed.
If `all` is specified or if the option is omitted, the backup information for all database servers is displayed. | +| `-i { \| \| all }`

`--backupid { \| \| all }` | `` is a backup identifier and `` is the user-defined alphanumeric name for the backup.
If `all` is specified or if the option is omitted, all backup information for the relevant database server is displayed. | +| `-t`
`--toggle` | Displays detailed backup information in list format. If the option is omitted, the default is a tabular format. | + +**Example** + +The following code sample shows the backup from database server `dev`: + +```text +-bash-4.2$ bart SHOW-BACKUPS -s dev +SERVER NAME BACKUP ID BACKUP NAME BACKUP PARENT +BACKUP TIME BACKUP SIZE WAL(s) SIZE WAL FILES STATUS +dev 1477579596637 dev_2016-10-27T10:46:36 none +2016-10-27 10:46:37 EDT 54.50 MB 96.00 MB 6 active +``` + +The following code sample shows detailed information using the `-t` option: + +```text +-bash-4.2$ bart SHOW-BACKUPS -s dev -i 1477579596637 -t +SERVER NAME : dev +BACKUP ID : 1477579596637 +BACKUP NAME : dev_2016-10-27T10:46:36 +BACKUP PARENT : none +BACKUP STATUS : active +BACKUP TIME : 2016-10-27 10:46:37 EDT +BACKUP SIZE : 54.50 MB +WAL(S) SIZE : 80.00 MB +NO. OF WALS : 5 +FIRST WAL FILE : 0000000100000001000000EC +CREATION TIME : 2016-10-27 10:46:37 EDT +LAST WAL FILE : 0000000100000001000000F0 +CREATION TIME : 2016-10-27 11:22:01 EDT +``` + +The following code sample shows a listing of an incremental backup along with its parent backup: + +```text +-bash-4.2$ bart SHOW-BACKUPS +SERVER NAME BACKUP ID BACKUP NAME BACKUP PARENT +BACKUP TIME BACKUP SIZE WAL(s) SIZE WAL FILES STATUS +acctg 1477580293193 acctg_2016-10-27 none +2016-10-27 10:58:13 EDT 16.45 MB 16.00 MB 1 active +acctg 1477580111358 acctg_2016-10-27 none 2016-10-27 10:55:11 EDT 59.71 +MB 16.00 MB 1 active +``` + +The following code sample shows the complete, detailed information of the incremental backup and the parent backup: + +```text +-bash-4.2$ bart SHOW-BACKUPS -t +SERVER NAME : acctg +BACKUP ID : 1477580293193 +BACKUP NAME : none +BACKUP PARENT : acctg_2016-10-27 +BACKUP STATUS : active +BACKUP TIME : 2016-10-27 10:58:13 EDT +BACKUP SIZE : 16.45 MB +WAL(S) SIZE : 16.00 MB +NO. OF WALS : 1 +FIRST WAL FILE : 0000000100000002000000D9 +CREATION TIME : 2016-10-27 10:58:13 EDT +LAST WAL FILE : 0000000100000002000000D9 +CREATION TIME : 2016-10-27 10:58:13 EDT +SERVER NAME : acctg +BACKUP ID : 1477580111358 +BACKUP NAME : acctg_2016-10-27 +BACKUP PARENT : none +BACKUP STATUS : active +BACKUP TIME : 2016-10-27 10:55:11 EDT +BACKUP SIZE : 59.71 MB +WAL(S) SIZE : 16.00 MB +NO. OF WALS : 1 +FIRST WAL FILE : 0000000100000002000000D8 +CREATION TIME : 2016-10-27 10:55:12 EDT +LAST WAL FILE : 0000000100000002000000D8 +CREATION TIME : 2016-10-27 10:55:12 EDT +``` diff --git a/product_docs/docs/bart/2.6/bart_ref/01_bart_subcommands_examples/09_verify_chksum.mdx b/product_docs/docs/bart/2.6/bart_ref/01_bart_subcommands_examples/09_verify_chksum.mdx new file mode 100644 index 00000000000..973ae05dc7d --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_ref/01_bart_subcommands_examples/09_verify_chksum.mdx @@ -0,0 +1,41 @@ +--- +title: "VERIFY-CHKSUM" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/verify_chksum.html" +--- + +The `VERIFY-CHKSUM` subcommand verifies the MD5 checksums of the full backups and any user-defined tablespaces for the specified database server or for all database servers. The checksum is verified by comparing the current checksum of the backup against the checksum when the backup was taken. + +!!! Note + The `VERIFY-CHKSUM` subcommand is only used for tar format backups. + +**Syntax:** + +```text +bart VERIFY-CHKSUM +[ –s { | all } ] +[ -i { | | all } ] +``` + +The following table describes the `VERIFY-CHKSUM` options: + +| Options | Description | +| ---------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { \| all }`
`--server { \| all` } | `` is the name of the database server whose tar backup checksums are to be verified.
If `all` is specified or if the `-s` option is omitted, the checksums of all tar backups are verified for all database servers. | +| `-i { \| \| all` }

`--backupid { \| \| all` } | `` is the backup identifier of a tar format full backup whose checksum is to be verified along with any user-defined tablespaces. `` is the user-defined alphanumeric name for the full backup.
If `all` is specified or if the `-i` option is omitted, the checksums of all tar backups for the relevant database server are verified. | + +**Example** + +The following code sample verifies the checksum of all tar format backups of the specified database server: + +```text +-bash-4.1$ bart VERIFY-CHKSUM -s acctg -i all +SERVER NAME BACKUP ID VERIFY +acctg 1430239348243 OK +acctg 1430232284202 OK +acctg 1430232016284 OK +acctg 1430231949065 OK +acctg 1429821844271 OK +``` diff --git a/product_docs/docs/bart/2.6/bart_ref/01_bart_subcommands_examples/10_running_the_bart_wal_scanner.mdx b/product_docs/docs/bart/2.6/bart_ref/01_bart_subcommands_examples/10_running_the_bart_wal_scanner.mdx new file mode 100644 index 00000000000..816b1ba397d --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_ref/01_bart_subcommands_examples/10_running_the_bart_wal_scanner.mdx @@ -0,0 +1,168 @@ +--- +title: "Running the BART WAL Scanner" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/running_the_bart_wal_scanner.html" +--- + +The BART WAL scanner is used to process each WAL file to find and record modified blocks in a corresponding MBM file. As a BART account user, use the BART WAL scanner to invoke the `bart-scanner` program located in the `/bin` directory. + +For detailed information about the WAL scanner and its usage, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/2.6/bart_user/). + +**Syntax:** + +```text +bart-scanner +[ -d ] +[ -c ] +{ –h | +-v | +--daemon | +-p | + | +RELOAD | +STOP +--checksum-algorithm } +``` + +When the `bart-scanner` program is invoked, it forks a separate process for each database server enabled with the `allow_incremental_backups` parameter. + +The WAL scanner processes can run in either the foreground or background depending upon usage of the `--daemon` option: + +- If the `--daemon` option is specified, the WAL scanner process runs in the background. All output messages can be viewed in the BART log file. +- If the `--daemon` option is omitted, the WAL scanner process runs in the foreground. All output messages can be viewed from the terminal running the program as well as in the BART log file. + +The following table describes the `VERIFY-CHKSUM` options. + +| Options | Description | +| ---------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-h` `--help` | Displays general syntax and information on WAL scanner usage. | +| `-v` `--version` | Displays the WAL scanner version information. | +| `-d` `--debug` | Displays debugging output while executing the WAL scanner with any of its options. | +| `-c ` `--config-path ` | Specifies `` as the full directory path to a BART configuration file. Use this option if you do not want to use the default BART configuration file `/etc/bart.cfg` | +| `--daemon` | Runs the WAL scanner as a background process. | +| `-p ` `--print ` | Specifies the full directory path to an MBM file whose content is to be printed. The `archived_wals` directory as specified in the the `archive_path` parameter in the `bart.cfg` file contains the MBM files. | +| `` | Specifies the full directory path to a WAL file to be scanned. The archive path directory contains the WAL files. Use it if a WAL file in the archive path is missing its MBM file. This option is to be used for assisting the EnterpriseDB support team for debugging problems that may have been encountered. | +| `RELOAD` | Reloads the BART configuration file. The keyword `RELOAD` is case-insensitive. The `RELOAD` option is useful if you make changes to the configuration file after the WAL scanner has been started. It will reload the configuration file and adjust the WAL scanners accordingly. For example, if a server section allowing incremental backups is removed from the BART configuration file, then the process attached to that server will stop. Similarly, if a server allowing incremental backups is added, a new WAL scanner process will be launched to scan the WAL files of that server. | +| `STOP` | Stops the WAL scanner. The keyword `STOP` is not case-sensitive. | +| `--checksum-algorithm` | While invoking the WAL scanner, you can specify one of the following values with the `--checksum-algorithm` option: `--checksum-algorithm=MD5` (default) to generate MD5 checksum files. `--checksum-algorithm=SHA256` to generate SHA256 checksum files. `--checksum-algorithm=NONE` to skip generating checksum files. | + +**Example** + +The following code sample demonstrates starting the WAL scanner to run interactively. The WAL scanner begins scanning existing WAL files in the archive path that have not yet been scanned (that is, there is no corresponding MBM file for the WAL file): + +```text +-bash-4.2$ bart-scanner +INFO: process created for server 'acctg', pid = 5287 +INFO: going to parse backlog of WALs, if any. +INFO: WAL file to be processed: 0000000100000000000000ED +INFO: WAL file to be processed: 0000000100000000000000EE +INFO: WAL file to be processed: 0000000100000000000000EF +INFO: WAL file to be processed: 0000000100000000000000F0 +INFO: WAL file to be processed: 0000000100000000000000F1 +``` + +The following code sample is the content of the archive path showing the MBM files created for the WAL files. (The user name and group name of the files have been removed from the example to list the WAL files and MBM files in a more readable manner): + +```text +[root@localhost archived_wals]# pwd +/opt/backup/acctg/archived_wals +[root@localhost archived_wals]# ls -l +total 81944 +-rw------- 1 ... ... 16777216 Dec 20 09:10 0000000100000000000000ED +-rw------- 1 ... ... 16777216 Dec 20 09:06 0000000100000000000000EE +-rw------- 1 ... ... 16777216 Dec 20 09:11 0000000100000000000000EF +-rw------- 1 ... ... 16777216 Dec 20 09:15 0000000100000000000000F0 +-rw------- 1 ... ... 16777216 Dec 20 09:16 0000000100000000000000F1 +-rw------- 1 ... ... 305 Dec 20 09:16 0000000100000000000000F1.00000028.backup +-rw-rw-r-- 1 ... ... 161 Dec 20 09:18 +0000000100000000ED00002800000000EE000000.mbm +-rw-rw-r-- 1 ... ... 161 Dec 20 09:18 +0000000100000000EE00002800000000EF000000.mbm +-rw-rw-r-- 1 ... ... 161 Dec 20 09:18 +0000000100000000EF00002800000000F0000000.mbm +-rw-rw-r-- 1 ... ... 161 Dec 20 09:18 +0000000100000000F000002800000000F1000000.mbm +-rw-rw-r-- 1 ... ... 161 Dec 20 09:18 +0000000100000000F100002800000000F2000000.mbm +``` + +To stop the interactively running WAL scanner, either enter `ctrl-C` at the terminal running the WAL scanner or invoke the `bart-scanner` program from another terminal with the `STOP` option: + +```text +-bash-4.2$ bart-scanner STOP +-bash-4.2$ +``` + +The terminal on which the WAL scanner was running interactively appears as follows after it has been stopped: + +```text +-bash-4.2$ bart-scanner +INFO: process created for server 'acctg', pid = 5287 +INFO: going to parse backlog of WALs, if any. +INFO: WAL file to be processed: 0000000100000000000000ED +INFO: WAL file to be processed: 0000000100000000000000EE +INFO: WAL file to be processed: 0000000100000000000000EF +INFO: WAL file to be processed: 0000000100000000000000F0 +INFO: WAL file to be processed: 0000000100000000000000F1 +INFO: bart-scanner stopped +-bash-4.2$ +``` + +The following code sample demonstrates invoking the WAL scanner to run as a background process with the `--daemon` option: + +```text +-bash-4.2$ bart-scanner --daemon +-bash-4.2$ +``` + +The WAL scanner runs as a background process. There is also a separate background process for each database server that has been enabled for WAL scanning with the `allow_incremental_backups` parameter in the BART configuration file: + +```text +-bash-4.2$ ps -ef | grep bart + enterpr+ 4340 1 0 09:48 ? 00:00:00 bart-scanner --daemon + enterpr+ 4341 4340 0 09:48 ? 00:00:00 bart-scanner --daemon + enterpr+ 4415 3673 0 09:50 pts/0 00:00:00 grep --color=auto bart +``` + +To stop the WAL scanner processes, invoke the WAL scanner with the `STOP` option: + +```text +-bash-4.2$ bart-scanner STOP +-bash-4.2$ +``` + +The following command demonstrates scanning an individual WAL file: + +```text +-bash-4.2$ bart-scanner /opt/backup/acctg/archived_wals/0000000100000000000000FF +-bash-4.2$ +``` + +To print the content of an MBM file for assisting the EnterpriseDB support team for debugging problems that may have been encountered, use the `-p` option to specify the file as shown in the following code sample: + +```text +-bash-4.2$ bart-scanner -p +/opt/backup/acctg/archived_wals/0000000100000000FF0000280000000100000000.mbm + +Header: +Version: 1.0:90500:1.2.0 +Scan Start: 2016-12-20 10:02:11 EST, Scan End: 2016-12-20 10:02:11 EST, Diff: 0 sec(s) +Start LSN: ff000028, End LSN: 100000000, TLI: 1 +flags: 0, Check Sum: f9cfe66ae2569894d6746b61503a767d + +Path: base/14845/16384 +NodeTag: BLOCK_CHANGE +Relation: relPath base/14845/16384, isTSNode 0, Blocks +*............................................................................. +First modified block: 0 +Total modified blocks: 1 + +Path: base/14845/16391 +NodeTag: BLOCK_CHANGE +Relation: relPath base/14845/16391, isTSNode 0, Blocks +*.............................................................................. +First modified block: 0 +Total modified blocks: 1 +``` diff --git a/product_docs/docs/bart/2.6/bart_ref/01_bart_subcommands_examples/index.mdx b/product_docs/docs/bart/2.6/bart_ref/01_bart_subcommands_examples/index.mdx new file mode 100644 index 00000000000..20c71192ef2 --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_ref/01_bart_subcommands_examples/index.mdx @@ -0,0 +1,115 @@ +--- +title: "BART Subcommand Syntax and Examples" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/bart_subcommands_examples.html" +--- + + + +This section briefly describes each BART subcommand and provides an example. + +**Invoking BART** + +BART subcommands are invoked at the Linux command line as a BART user. You can invoke the `bart` program (located in the `/bin` directory) with the desired options to manage your BART installation. + +The following examples demonstrate ways of invoking BART. In these examples, the BART user account is named `bartuser`. + +```text +$ su bartuser +Password: +$ export +LD_LIBRARY_PATH=/opt/PostgresPlus/9.6AS/lib/:$LD_LIBRARY_PATH +$ ./bart SHOW-SERVERS +``` + +To run BART from any current working directory: + +```text +$ su bartuser +Password: +$ export +LD_LIBRARY_PATH=/opt/PostgresPlus/9.6AS/lib/:$LD_LIBRARY_PATH +$ bart SHOW-SERVERS +``` + +**Syntax for invoking BART** + +```text +bart [ ]... [ ] []... +``` + +You can use either abbreviated or long option forms on the command line (for example `-h` or `--help`). + +**General Options** + +You can specify the following general options with `bart`. + +`-h` or (`--help`) + +- Displays general syntax and information about BART usage. +- All subcommands support a help option (`-h, --help`). If the help option is specified, information is displayed regarding that particular subcommand. The subcommand, itself, is not executed. + +The following code sample displays the result of invoking the `--help` option for the `BACKUP` subcommand: + +```text +-bash-4.2$ bart BACKUP --help +bart: backup and recovery tool + +Usage: +bart BACKUP [OPTION]... + +Options: +-h, --help Show this help message and exit +-s, --server Name of the server or 'all' (full backups only) to specify all servers +-F, --format=p|t Backup output format (tar (default) or plain) +-z, --gzip Enables gzip compression of tar files +-c, --compress-level Specifies the compression level (1 through 9, 9 being + best compression) +--backup-name Specify a friendly name for the current backup +--parent Specify parent backup for incremental backup +--check Verify checksum of required mbm files +``` + +`-v` (or `--version`) + +The following code sample displays information returned by the `bart --version` subcommand: + +```text +[edb@localhost bin]$ bart --version +bart (EnterpriseDB) 2.5.2 +[edb@localhost bin]$ +``` + +`-d` (or `--debug`) + +The following code sample displays debugging output returned by the `bart MANAGE` subcommand: + +```text +-bash-4.1$ bart -d MANAGE -n +DEBUG: Server: acctg, Now: 2015-04-17 16:34:03 EDT, RetentionWindow: +259200 (secs) ==> 72 hour(s) +DEBUG: Server: dev, Now: 2015-04-17 16:34:03 EDT, RetentionWindow: +1814400 (secs) ==> 504 hour(s) +DEBUG: Server: hr, Now: 2015-04-17 16:34:03 EDT, RetentionWindow: +7776000 (secs) ==> 2160 hour(s) +``` + +`-c` (or `--config-path) ` + +The following code sample demonstrates using the `-c` option to specify a non-default configuration file name and installation location: + +```text +$ su bartuser +Password: +$ export +LD_LIBRARY_PATH=/opt/PostgresPlus/9.6AS/lib/:$LD_LIBRARY_PATH +$ bart -c /home/bartuser/bart.cfg SHOW-SERVERS +``` + +
+ +backup check_config delete init manage restore show_servers show_backups verify_chksum running_the_bart_wal_scanner + +
diff --git a/product_docs/docs/bart/2.6/bart_ref/02_additional_examples.mdx b/product_docs/docs/bart/2.6/bart_ref/02_additional_examples.mdx new file mode 100644 index 00000000000..48fac9053fa --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_ref/02_additional_examples.mdx @@ -0,0 +1,1473 @@ +--- +title: "Additional Examples" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/additional_examples.html" +--- + + + +This section lists examples of the following BART operations. + +- Restoring a database cluster with tablespaces. +- Restoring an incremental backup. +- Managing backups. +- Managing incremental backups. + +## Restoring a Database Cluster with Tablespaces + +The following code sample illustrates taking a backup and restoring a database cluster on a remote host containing tablespaces. For detailed information regarding using tablespaces, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/2.6/bart_user/). + +On an Advanced Server database running on a remote host, the following tablespaces are created for use by two tables: + +```text +edb=# CREATE TABLESPACE tblspc_1 LOCATION '/mnt/tablespace_1'; +CREATE TABLESPACE +edb=# CREATE TABLESPACE tblspc_2 LOCATION '/mnt/tablespace_2'; +CREATE TABLESPACE +edb=# \db + List of tablespaces +Name | Owner | Location +------------+-----------------+------------------- +pg_default | enterprisedb | +pg_global | enterprisedb | +tblspc_1 | enterprisedb | /mnt/tablespace_1 +tblspc_2 | enterprisedb | /mnt/tablespace_2 +(4 rows) + +edb=# CREATE TABLE tbl_tblspc_1 (c1 TEXT) TABLESPACE tblspc_1; +CREATE TABLE +edb=# CREATE TABLE tbl_tblspc_2 (c1 TEXT) TABLESPACE tblspc_2; +CREATE TABLE +edb=# \d tbl_tblspc_1 +Table "enterprisedb.tbl_tblspc_1" +Column | Type | Modifiers +-------+------+----------- +c1 | text | +Tablespace: "tblspc_1" + +edb=# \d tbl_tblspc_2 +Table "enterprisedb.tbl_tblspc_2" +Column | Type | Modifiers +-------+------+----------- +c1 | text | +Tablespace: "tblspc_2" +``` + +The following code sample shows the OIDs assigned to the tablespaces and the symbolic links to the tablespace directories: + +```text +-bash-4.1$ pwd +/opt/PostgresPlus/9.6AS/data/pg_tblspc +-bash-4.1$ ls -l +total 0 +lrwxrwxrwx 1 enterprisedb enterprisedb 17 Nov 16 16:17 16587 ->/mnt/tablespace_1 +lrwxrwxrwx 1 enterprisedb enterprisedb 17 Nov 16 16:17 16588 ->/mnt/tablespace_2 +``` + +The BART configuration file contains the following settings. Note that the `tablespace_path` parameter does not have to be set at this point. + +```text +[BART] +bart_host= enterprisedb@192.168.2.22 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log + +[ACCTG] +host = 192.168.2.24 +port = 5444 +user = repuser +cluster_owner = enterprisedb +remote_host = enterprisedb@192.168.2.24 +tablespace_path = +description = "Accounting" +``` + +After the necessary configuration steps are performed to ensure BART manages the remote database server, a full backup is taken as shown in the following code sample: + +```text +-bash-4.1$ bart BACKUP -s acctg + +INFO: creating backup for server 'acctg' +INFO: backup identifier: '1447709811516' +54521/54521 kB (100%), 3/3 tablespaces + +INFO: backup completed successfully +INFO: backup checksum: 594f69fe7d26af991d4173d3823e174f of 16587.tar +INFO: backup checksum: 7a5507567729a21c98a15c948ff6c015 of base.tar +INFO: backup checksum: ae8c62604c409635c9d9e82b29cc0399 of 16588.tar +INFO: +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1447709811516 +BACKUP NAME: none +BACKUP LOCATION: /opt/backup/acctg/1447709811516 +BACKUP SIZE: 53.25 MB +BACKUP FORMAT: tar +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 3 +ChkSum File +594f69fe7d26af991d4173d3823e174f 16587.tar +7a5507567729a21c98a15c948ff6c015 base.tar +ae8c62604c409635c9d9e82b29cc0399 16588.tar + +TABLESPACE(s): 2 +Oid Name Location +16587 tblspc_1 /mnt/tablespace_1 +16588 tblspc_2 /mnt/tablespace_2 +START WAL LOCATION: 00000001000000000000000F +BACKUP METHOD: streamed +BACKUP FROM: master +START TIME: 2015-11-16 16:36:51 EST +STOP TIME: 2015-11-16 16:36:52 EST +TOTAL DURATION: 1 sec(s) +``` + +Note that in the output from the preceding example, checksums are generated for the tablespaces as well as the full backup. + +Within the backup subdirectory `1447709811516` of the BART backup catalog, the tablespace data is stored with file names `16587.tar.gz` and `16588.tar.gz` as shown below: + +```text +-bash-4.1$ pwd +/opt/backup/acctg +-bash-4.1$ ls -l +total 8 +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 16:36 1447709811516 +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 16:43 archived_wals +-bash-4.1$ ls -l 1447709811516 +total 54536 +-rw-rw-r-- 1 enterprisedb enterprisedb 19968 Nov 16 16:36 16587.tar +-rw-rw-r-- 1 enterprisedb enterprisedb 19968 Nov 16 16:36 16588.tar +-rw-rw-r-- 1 enterprisedb enterprisedb 949 Nov 16 17:05 backupinfo +-rw-rw-r-- 1 enterprisedb enterprisedb 55792640 Nov 16 16:36 base.tar +``` + +When you are ready to restore the backup, in addition to creating the directory to which the main database cluster is to be restored, you must prepare the directories to which the tablespaces are to be restored. + +On the remote host, directories `/opt/restore_tblspc_1` and `/opt/restore_tblspc_2` are created and assigned the proper ownership and permissions as shown by the following example. The main database cluster is to be restored to `/opt/restore`. + +```text +[root@localhost opt]# mkdir restore_tblspc_1 +[root@localhost opt]# chown enterprisedb restore_tblspc_1 +[root@localhost opt]# chgrp enterprisedb restore_tblspc_1 +[root@localhost opt]# chmod 700 restore_tblspc_1 + +[root@localhost opt]# mkdir restore_tblspc_2 +[root@localhost opt]# chown enterprisedb restore_tblspc_2 +[root@localhost opt]# chgrp enterprisedb restore_tblspc_2 +[root@localhost opt]# chmod 700 restore_tblspc_2 +[root@localhost opt]# ls -l +total 20 +drwxr-xr-x 3 root daemon 4096 Nov 10 15:38 PostgresPlus +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 17:40 restore +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 17:40 +restore_tblspc_1 +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 17:41 +restore_tblspc_2 +drwxr-xr-x. 2 root root 4096 Nov 22 2013 rh +``` + +Set the `tablespace_path` parameter in the BART configuration file to specify the tablespace directories. The remote host user and IP address are specified by the `remote_host` configuration parameter. + +```text +[ACCTG] + +host = 192.168.2.24 +port = 5444 +user = repuser +cluster_owner = enterprisedb +remote_host = enterprisedb@192.168.2.24 +tablespace_path = +16587=/opt/restore_tblspc_1;16588=/opt/restore_tblspc_2 + +description = "Accounting" +``` + +The following code sample demonstrates invoking the `RESTORE` subcommand: + +```text +-bash-4.1$ bart RESTORE -s acctg -i 1447709811516 -p /opt/restore +INFO: restoring backup '1447709811516' of server 'acctg' +INFO: restoring backup to enterprisedb@192.168.2.24:/opt/restore +INFO: base backup restored +INFO: archiving is disabled +INFO: tablespace(s) restored +``` + +The following code sample shows the restored full backup (including the restored tablespaces): + +```text +bash-4.1$ pwd +/opt +-bash-4.1$ ls -l restore +total 104 +-rw------- 1 enterprisedb enterprisedb 206 Nov 16 16:36 backup_label.old +drwx------ 6 enterprisedb enterprisedb 4096 Nov 10 15:38 base +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 17:46 global +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_clog +-rw------- 1 enterprisedb enterprisedb 4438 Nov 10 16:23 pg_hba.conf +-rw------- 1 enterprisedb enterprisedb 1636 Nov 10 15:38 pg_ident.conf +drwxr-xr-x 2 enterprisedb enterprisedb 4096 Nov 16 17:45 pg_log +drwx------ 4 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_multixact +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 17:45 pg_notify +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_serial +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_snapshots +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 17:47 pg_stat +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 17:47 pg_stat_tmp +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_subtrans +drwx------ 2 enterprisedb enterprisedb 4096 Nov 16 17:42 pg_tblspc +drwx------ 2 enterprisedb enterprisedb 4096 Nov 10 15:38 pg_twophase +-rw------- 1 enterprisedb enterprisedb 4 Nov 10 15:38 PG_VERSION +drwx------ 3 enterprisedb enterprisedb 4096 Nov 16 17:47 pg_xlog +-rw------- 1 enterprisedb enterprisedb 23906 Nov 16 17:42 postgresql.conf +-rw------- 1 enterprisedb enterprisedb 61 Nov 16 17:45 postmaster.opts +-bash-4.1$ +-bash-4.1$ ls -l restore_tblspc_1 +total 4 +drwx------ 3 enterprisedb enterprisedb 4096 Nov 16 16:18 +PG_9.6_201306121 +-bash-4.1$ ls -l restore_tblspc_2 +total 4 +drwx------ 3 enterprisedb enterprisedb 4096 Nov 16 16:18 +PG_9.6_201306121 +``` + +The symbolic links in the `pg_tblspc` subdirectory point to the restored directory location: + +```text +bash-4.1$ pwd +/opt/restore/pg_tblspc +-bash-4.1$ ls -l +total 0 +lrwxrwxrwx 1 enterprisedb enterprisedb 21 Nov 16 17:42 16587 -> +/opt/restore_tblspc_1 +lrwxrwxrwx 1 enterprisedb enterprisedb 21 Nov 16 17:42 16588 -> +/opt/restore_tblspc_2 +``` + +`psql` queries also show the restored tablespaces: + +```text +edb=# \db + + List of tablespaces +Name | Owner | Location +------------+--------------+----------------------- +pg_default | enterprisedb | +pg_global | enterprisedb | +tblspc_1 | enterprisedb | /opt/restore_tblspc_1 +tblspc_2 | enterprisedb | /opt/restore_tblspc_2 +``` + +## Restoring an Incremental Backup + +Restoring an incremental backup may require additional setup steps depending upon the host on which the incremental backup is to be restored. For more information, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/2.6/bart_user/). + +This section provides an example of creating backup chains and then restoring an incremental backup. + +**Creating a Backup Chain** + +A *backup chain* is the set of backups consisting of a full backup and all of its successive incremental backups. Tracing back on the parent backups of all incremental backups in the chain eventually leads back to that single, full backup. + +In the following example, the `allow_incremental_backups` parameter is set to `enabled` in the BART configuration file to permit incremental backups on the listed database server: + +```text +[BART] + +bart_host= enterprisedb@192.168.2.27 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log + +[ACCTG] + +host = 127.0.0.1 +port = 5445 +user = enterprisedb +cluster_owner = enterprisedb +allow_incremental_backups = enabled +description = "Accounting" +``` + +After the database server has been started with WAL archiving enabled to the BART backup catalog, the WAL scanner is started: + +```text +-bash-4.2$ bart-scanner --daemon +``` + +First, a full backup is taken. + +```text +-bash-4.2$ bart BACKUP -s acctg --backup-name full_1 +INFO: creating backup for server 'acctg' +INFO: backup identifier: '1490649204327'\ +63364/63364 kB (100%), 1/1 tablespace +INFO: backup completed successfully +INFO: backup checksum: aae27d4a7c09dffc82f423221154db7e of base.tar +INFO: +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1490649204327 +BACKUP NAME: full_1 +BACKUP PARENT: none +BACKUP LOCATION: /opt/backup/acctg/1490649204327 +BACKUP SIZE: 61.88 MB +BACKUP FORMAT: tar +BACKUP TIMEZONE: US/Eastern +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 1 +ChkSum File +aae27d4a7c09dffc82f423221154db7e base.tar +TABLESPACE(s): 0 +START WAL LOCATION: 00000001000000000000000E +BACKUP METHOD: streamed +BACKUP FROM: master +START TIME: 2017-03-27 17:13:24 EDT +STOP TIME: 2017-03-27 17:13:25 EDT +TOTAL DURATION: 1 sec(s) +``` + +A series of incremental backups are taken. The first incremental backup specifies the full backup as the parent. Each successive incremental backup then uses the preceding incremental backup as its parent. + +```text +-bash-4.2$ bart BACKUP -s acctg -F p --parent full_1 --backup-name +incr_1-a +INFO: creating incremental backup for server 'acctg' +INFO: checking mbm files /opt/backup/acctg/archived_wals +INFO: new backup identifier generated 1490649255649 +INFO: reading directory /opt/backup/acctg/archived_wals +INFO: all files processed +NOTICE: pg_stop_backup complete, all required WAL segments have been +archived +INFO: incremental backup completed successfully +INFO: +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1490649255649 +BACKUP NAME: incr_1-a +BACKUP PARENT: 1490649204327 +BACKUP LOCATION: /opt/backup/acctg/1490649255649 +BACKUP SIZE: 16.56 MB +BACKUP FORMAT: plain +BACKUP TIMEZONE: US/Eastern +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 0 +TABLESPACE(s): 0 +START WAL LOCATION: 000000010000000000000010 +STOP WAL LOCATION: 000000010000000000000010 +BACKUP METHOD: pg_start_backup +BACKUP FROM: master +START TIME: 2017-03-27 17:14:15 EDT +STOP TIME: 2017-03-27 17:14:16 EDT +TOTAL DURATION: 1 sec(s) +-bash-4.2$ bart BACKUP -s acctg -F p --parent incr_1-a --backup-name +incr_1-b +INFO: creating incremental backup for server 'acctg' +INFO: checking mbm files /opt/backup/acctg/archived_wals +INFO: new backup identifier generated 1490649336845 +INFO: reading directory /opt/backup/acctg/archived_wals +INFO: all files processed +NOTICE: pg_stop_backup complete, all required WAL segments have been +archived +INFO: incremental backup completed successfully +. +. +. +-bash-4.2$ bart BACKUP -s acctg -F p --parent incr_1-b --backup-name +incr_1-c +INFO: creating incremental backup for server 'acctg' +INFO: checking mbm files /opt/backup/acctg/archived_wals +INFO: new backup identifier generated 1490649414316 +INFO: reading directory /opt/backup/acctg/archived_wals +INFO: all files processed +NOTICE: pg_stop_backup complete, all required WAL segments have been +archived +INFO: incremental backup completed successfully +. +. +. +``` + +The following output of the `SHOW-BACKUPS` subcommand lists the backup chain, which are backups `full_1, incr_1-a, incr_1-b, and incr_1-c`. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID BACKUP NAME BACKUP PARENT BACKUP TIME ... +acctg 1490649414316 incr_1-c incr_1-b 2017-03-27 17:16:55 ... +acctg 1490649336845 incr_1-b incr_1-a 2017-03-27 17:15:37 ... +acctg 1490649255649 incr_1-a full_1 2017-03-27 17:14:16 ... +acctg 1490649204327 full_1 none 2017-03-27 17:13:25 ... +``` + +For the `full backup full_1`, the `BACKUP PARENT` field contains `none`. For each incremental backup, the `BACKUP PARENT` field contains the backup identifier or name of its parent backup. + +A second backup chain is created in the same manner with the `BACKUP` subcommand. The following example shows the addition of the resulting, second backup chain consisting of full backup `full_2` and incremental backups `incr_2-a` and `incr_2-b`. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID BACKUP NAME BACKUP PARENT BACKUP TIME ... +acctg 1490649605607 incr_2-b incr_2-a 2017-03-27 17:20:06 ... +acctg 1490649587702 incr_2-a full_2 2017-03-27 17:19:48 ... +acctg 1490649528633 full_2 none 2017-03-27 17:18:49 ... +acctg 1490649414316 incr_1-c incr_1-b 2017-03-27 17:16:55 ... +acctg 1490649336845 incr_1-b incr_1-a 2017-03-27 17:15:37 ... +acctg 1490649255649 incr_1-a full_1 2017-03-27 17:14:16 ... +acctg 1490649204327 full_1 none 2017-03-27 17:13:25 ... +``` + +The following additional incremental backups starting with `incr_1-b-1`, which designates `incr_1-b` as the parent, results in the forking from that backup into a second line of backups in the chain consisting of `full_1, incr_1-a, incr_1-b, incr_1-b-1, incr_1-b-2`, and `incr_1-b-3` as shown in the following list: + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID BACKUP NAME BACKUP PARENT BACKUP TIME ... +acctg 1490649791430 incr_1-b-3 incr_1-b-2 2017-03-27 17:23:12 ... +acctg 1490649763929 incr_1-b-2 incr_1-b-1 2017-03-27 17:22:44 ... +acctg 1490649731672 incr_1-b-1 incr_1-b 2017-03-27 17:22:12 ... +acctg 1490649605607 incr_2-b incr_2-a 2017-03-27 17:20:06 ... +acctg 1490649587702 incr_2-a full_2 2017-03-27 17:19:48 ... +acctg 1490649528633 full_2 none 2017-03-27 17:18:49 ... +acctg 1490649414316 incr_1-c incr_1-b 2017-03-27 17:16:55 ... +acctg 1490649336845 incr_1-b incr_1-a 2017-03-27 17:15:37 ... +acctg 1490649255649 incr_1-a full_1 2017-03-27 17:14:16 ... +acctg 1490649204327 full_1 none 2017-03-27 17:13:25 ... +``` + +**Restoring an Incremental Backup** + +Restoring an incremental backup is done with the `RESTORE` subcommand in the same manner as for restoring a full backup. Specify the backup identifier or backup name of the incremental backup to be restored as shown in the following example. + +```text +-bash-4.2$ bart RESTORE -s acctg -p /opt/restore -i incr_1-b +INFO: restoring incremental backup 'incr_1-b' of server 'acctg' +INFO: base backup restored +INFO: archiving is disabled +INFO: permissions set on $PGDATA +INFO: incremental restore completed successfully +``` + +Restoring incremental backup `incr_1-b` as shown by the preceding example results in the restoration of full backup `full_1`, then incremental backups `incr_1-a` and finally, `incr_1-b`. + +## Managing Backups + +This section illustrates evaluating, marking, and deleting backups using the `MANAGE` subcommand using a redundancy retention policy and a recovery window retention policy. For detailed information about the `MANAGE` subcommand, see the *EDB Backup and Recovery User Guide* available at the [EDB website](/bart/2.6/bart_user/). + + + +### Using a Redundancy Retention Policy + +The following code sample uses a redundancy retention policy to evaluate, mark, and delete backups as shown by the following server configuration: + +```text +[ACCTG] +host = 127.0.0.1 +port = 5444 +user = enterprisedb +archive_command = 'cp %p %a/%f' +retention_policy = 3 BACKUPS +description = "Accounting" +``` + +The following list is the set of backups. Note that the last backup in the list has been marked as `keep`. + +```text +-bash-4.1$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID BACKUP TIME BACKUP SIZE WAL(s) SIZE +WAL FILES STATUS +acctg 1428768344061 2015-04-11 12:05:46 EDT 5.72 MB 48.00 MB +3 active +acctg 1428684537299 2015-04-10 12:49:00 EDT 5.72 MB 272.00 MB +17 active +acctg 1428589759899 2015-04-09 10:29:27 EDT 5.65 MB 96.00 MB +6 active +acctg 1428502049836 2015-04-08 10:07:30 EDT 55.25 MB 96.00 MB +6 active +acctg 1428422324880 2015-04-07 11:58:45 EDT 54.53 MB 32.00 MB +2 active +acctg 1428355371389 2015-04-06 17:22:53 EDT 5.71 MB 16.00 MB +1 keep +``` + +Invoke the `MANAGE` subcommand with the `-n` option to perform a dry run to observe which active backups would be changed to obsolete according to the retention policy as shown in the following code sample: + +```text +-bash-4.1$ bart MANAGE -s acctg -n +INFO: processing server 'acctg', backup '1428768344061' +INFO: processing server 'acctg', backup '1428684537299' +INFO: processing server 'acctg', backup '1428589759899' +INFO: processing server 'acctg', backup '1428502049836' +INFO: marking backup '1428502049836' as obsolete +INFO: 6 WAL file(s) marked obsolete +INFO: processing server 'acctg', backup '1428422324880' +INFO: marking backup '1428422324880' as obsolete +INFO: 2 WAL file(s) marked obsolete +INFO: processing server 'acctg', backup '1428355371389' +``` + +The dry run shows that backups `1428502049836` and `1428422324880` would be marked as `obsolete`. + +!!! Note + A dry run does not change the backup status. The two backups that would be considered obsolete are still marked as `active`: + +```text +-bash-4.1$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID BACKUP TIME BACKUP SIZE WAL(s) SIZE +WAL FILES STATUS +acctg 1428768344061 2015-04-11 12:05:46 EDT 5.72 MB 48.00 MB +3 active +acctg 1428684537299 2015-04-10 12:49:00 EDT 5.72 MB 272.00 MB +17 active +acctg 1428589759899 2015-04-09 10:29:27 EDT 5.65 MB 96.00 MB +6 active +acctg 1428502049836 2015-04-08 10:07:30 EDT 55.25 MB 96.00 MB +6 active +acctg 1428422324880 2015-04-07 11:58:45 EDT 54.53 MB 32.00 MB +2 active +acctg 1428355371389 2015-04-06 17:22:53 EDT 5.71 MB 16.00 MB +1 keep +``` + +Invoke the `MANAGE` subcommand omitting the `-n` option to change and mark the status of the backups as `obsolete`: + +```text +-bash-4.1$ bart MANAGE -s acctg +INFO: processing server 'acctg', backup '1428768344061' +INFO: processing server 'acctg', backup '1428684537299' +INFO: processing server 'acctg', backup '1428589759899' +INFO: processing server 'acctg', backup '1428502049836' +INFO: marking backup '1428502049836' as obsolete +INFO: 6 WAL file(s) marked obsolete +INFO: processing server 'acctg', backup '1428422324880' +INFO: marking backup '1428422324880' as obsolete +INFO: 2 WAL file(s) marked obsolete +INFO: processing server 'acctg', backup '1428355371389' +``` + +The obsolete backups can be observed in a number of ways. Use the `MANAGE` subcommand with the `-l` option to list the `obsolete` backups: + +```text +-bash-4.1$ bart MANAGE -s acctg -l +INFO: 6 WAL file(s) will be removed +SERVER NAME: acctg +BACKUP ID: 1428502049836 +BACKUP STATUS: obsolete +BACKUP TIME: 2015-04-08 10:07:30 EDT +BACKUP SIZE: 55.25 MB +WAL FILE(s): 6 +WAL FILE: 000000010000000100000003 +WAL FILE: 000000010000000100000002 +WAL FILE: 000000010000000100000001 +WAL FILE: 000000010000000100000000 +WAL FILE: 0000000100000000000000E3 +WAL FILE: 0000000100000000000000E2 +INFO: 2 WAL file(s) will be removed +SERVER NAME: acctg +BACKUP ID: 1428422324880 +BACKUP STATUS: obsolete +BACKUP TIME: 2015-04-07 11:58:45 EDT +BACKUP SIZE: 54.53 MB +WAL FILE(s): 2 +WAL FILE: 0000000100000000000000E1 +WAL FILE: 0000000100000000000000E0 +``` + +The `STATUS` field of the `SHOW-BACKUPS` subcommand displays the current status: + +```text +-bash-4.1$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID BACKUP TIME BACKUP SIZE WAL(s) SIZE +WAL FILES STATUS +acctg 1428768344061 2015-04-11 12:05:46 EDT 5.72 MB 48.00 MB +3 active +acctg 1428684537299 2015-04-10 12:49:00 EDT 5.72 MB 272.00 MB +17 active +acctg 1428589759899 2015-04-09 10:29:27 EDT 5.65 MB 96.00 MB +6 active +acctg 1428502049836 2015-04-08 10:07:30 EDT 55.25 MB 96.00 MB +6 obsolete +acctg 1428422324880 2015-04-07 11:58:45 EDT 54.53 MB 32.00 MB +2 obsolete +acctg 1428355371389 2015-04-06 17:22:53 EDT 5.71 MB 16.00 MB +1 keep +``` + +The details of an individual backup can be displayed using the `SHOW-BACKUPS` subcommand with the `-t` option. Note the status in the `BACKUP STATUS` field. + +```text +-bash-4.1$ bart SHOW-BACKUPS -s acctg -i 1428502049836 -t +SERVER NAME : acctg +BACKUP ID : 1428502049836 +BACKUP NAME : none +BACKUP STATUS : obsolete +BACKUP TIME : 2015-04-08 10:07:30 EDT +BACKUP SIZE : 55.25 MB +WAL(S) SIZE : 96.00 MB +NO. OF WALS : 6 +FIRST WAL FILE : 0000000100000000000000E2 +CREATION TIME : 2015-04-08 10:07:30 EDT +LAST WAL FILE : 000000010000000100000003 +CREATION TIME : 2015-04-09 10:25:46 EDT +``` + +Use the `MANAGE` subcommand with the `-d` option to physically delete the `obsolete` backups including the unneeded WAL files. + +```text +-bash-4.1$ bart MANAGE -s acctg -d +INFO: removing all obsolete backups of server 'acctg' +INFO: removing obsolete backup '1428502049836' +INFO: 6 WAL file(s) will be removed +INFO: removing WAL file '000000010000000100000003' +INFO: removing WAL file '000000010000000100000002' +INFO: removing WAL file '000000010000000100000001' +INFO: removing WAL file '000000010000000100000000' +INFO: removing WAL file '0000000100000000000000E3' +INFO: removing WAL file '0000000100000000000000E2' +INFO: removing obsolete backup '1428422324880' +INFO: 2 WAL file(s) will be removed +INFO: removing WAL file '0000000100000000000000E1' +INFO: removing WAL file '0000000100000000000000E0' +``` + +The `SHOW-BACKUPS` subcommand now displays the remaining backups marked as `active` or `keep`: + +```text +-bash-4.1$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID BACKUP TIME BACKUP SIZE WAL(s) SIZE +WAL FILES STATUS +acctg 1428768344061 2015-04-11 12:05:46 EDT 5.72 MB 48.00 MB +3 active +acctg 1428684537299 2015-04-10 12:49:00 EDT 5.72 MB 272.00 MB +17 active +acctg 1428589759899 2015-04-09 10:29:27 EDT 5.65 MB 96.00 MB +6 active +acctg 1428355371389 2015-04-06 17:22:53 EDT 5.71 MB 16.00 MB +1 keep +``` + + + +### Using a Recovery Window Retention Policy + +This section illustrates the evaluation, marking, and deletion of backup using a recovery window retention policy. To use the recovery window retention policy, set the `retention_policy` parameter to the desired length of time for the recovery window. + +This section provides examples of the following: + +- How to view the calculated recovery window. +- How to evaluate, mark, and delete backup using a recovery window retention policy. + +#### Viewing the Recovery Window + +You can view the actual, calculated recovery window by invoking any of the following subcommands: + +- `MANAGE` subcommand in debug mode (along with the `-n` option). +- `SHOW-SERVERS` subcommand. + +##### Viewing the Recovery Window Using the Manage Subcommand + +When invoking BART in debug mode with the `MANAGE` subcommand and the `-n` option, the length of the recovery window is calculated based on the `retention_policy` setting and the current date/time. + +For example, using the following `retention_policy` settings: + +```text +[ACCTG] + +host = 127.0.0.1 +port = 5444 +user = enterprisedb +archive_command = 'cp %p %a/%f' +retention_policy = 3 DAYS +backup-name = acctg_%year-%month-%dayT%hour:%minute:%second +description = "Accounting" + +[DEV] + +host = 127.0.0.1 +port = 5445 +user = enterprisedb +archive_command = 'cp %p %a/%f' +retention_policy = 3 WEEKS +description = "Development" + +[HR] + +host = 127.0.0.1 +port = 5432 +user = postgres +retention_policy = 3 MONTHS +description = "Human Resources" +``` + +If the `MANAGE` subcommand is invoked in debug mode along with the `-n` option on 2015-04-17, the following results are displayed: + +```text +-bash-4.1$ bart -d MANAGE -n +DEBUG: Server: acctg, Now: 2015-04-17 16:34:03 EDT, RetentionWindow: +259200 (secs) ==> 72 hour(s) +DEBUG: Server: dev, Now: 2015-04-17 16:34:03 EDT, RetentionWindow: +1814400 (secs) ==> 504 hour(s) +DEBUG: Server: hr, Now: 2015-04-17 16:34:03 EDT, RetentionWindow: +7776000 (secs) ==> 2160 hour(s) +``` + +For server `acctg`, 72 hours translates to a recovery window of 3 days. + +For server `dev`, 504 hours translates to a recovery window of 21 days (3 weeks). + +For server `hr`, 2160 hours translates to a recovery window of 90 days (3 months). + +For a setting of ` MONTHS`, the calculated total number of days for the recovery window is dependent upon the actual number of days in the preceding months from the current date/time. Thus, ` MONTHS` is not always exactly equivalent to ` x 30 DAYS`. For example, if the current date/time is in the month of March, a 1-month recovery window would be equivalent to only 28 days because the preceding month is February. Thus, for a current date of March 31, a 1-month recovery window would start on March 3. However, the typical result is that the day of the month of the starting recovery window boundary will be the same day of the month of when the `MANAGE` subcommand is invoked. + +##### Viewing the Recovery Window Using the Show-Servers Subcommand + +This section provides an example of viewing the recovery window using the `SHOW-SERVERS` subcommand; the `RETENTION POLICY` field displays the start of the recovery window. + +In the following code sample, the recovery window retention policy setting considers the backups taken within a 3-day recovery window as the active backups. + +```text +[ACCTG] +host = 127.0.0.1 +port = 5444 +user = enterprisedb +archive_command = 'cp %p %a/%f' +retention_policy = 3 DAYS +description = "Accounting" +``` + +The start of the 3-day recovery window displayed in the `RETENTION POLICY` field is `2015-04-07 14:57:36 EDT` when the `SHOW-SERVERS` subcommand is invoked on `2015-04-10`. + +At this current point in time, backups taken on or after `2015-04-07 14:57:36 EDT` would be considered active. Backups taken prior to `2015-04-07 14:57:36 EDT` would be considered obsolete except for backups marked as `keep`. + +```text +-bash-4.1$ date +Fri Apr 10 14:57:33 EDT 2015 +-bash-4.1$ +-bash-4.1$ bart SHOW-SERVERS -s acctg +SERVER NAME : acctg +HOST NAME : 127.0.0.1 +USER NAME : enterprisedb +PORT : 5444 +REMOTE HOST : +RETENTION POLICY : 2015-04-07 14:57:36 EDT +DISK UTILIZATION : 824.77 MB +NUMBER OF ARCHIVES : 37 +ARCHIVE PATH : /opt/backup/acctg/archived_wals +ARCHIVE COMMAND : cp %p /opt/backup/acctg/archived_wals/%f +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +DESCRIPTION : "Accounting" +``` + +In the following code sample, the recovery window retention policy setting considers the backups taken within a 3-week recovery window as the `active` backups. + +```text +[DEV] +host = 127.0.0.1 +port = 5445 +user = enterprisedb +archive_command = 'cp %p %a/%f' +retention_policy = 3 WEEKS +description = "Development" +``` + +The start of the 3-week recovery window displayed in the `RETENTION POLICY` field is `2015-03-20 14:59:42 EDT` when the `SHOW-SERVERS` subcommand is invoked on `2015-04-10`. + +At this current point in time, backups taken on or after `2015-03-20 14:59:42 EDT` would be considered `active`. Backups taken prior to `2015-03-20 14:59:42 EDT` would be considered `obsolete` except for backups marked as `keep`. + +```text +-bash-4.1$ date +Fri Apr 10 14:59:39 EDT 2015 +-bash-4.1$ +-bash-4.1$ bart SHOW-SERVERS -s dev +SERVER NAME : dev +HOST NAME : 127.0.0.1 +USER NAME : enterprisedb +PORT : 5445 +REMOTE HOST : +RETENTION POLICY : 2015-03-20 14:59:42 EDT +DISK UTILIZATION : 434.53 MB +NUMBER OF ARCHIVES : 22 +ARCHIVE PATH : /opt/backup/dev/archived_wals +ARCHIVE COMMAND : cp %p /opt/backup/dev/archived_wals/%f +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +DESCRIPTION : "Development" +``` + +In the following code sample, the recovery window retention policy setting considers the backups taken within a 3-month recovery window as the `active` backups. + +```text +[HR] +host = 127.0.0.1 +port = 5432 +user = postgres +retention_policy = 3 MONTHS +description = "Human Resources" +``` + +The start of the 3-month recovery window displayed in the `RETENTION POLICY` field is `2015-01-10 14:04:23 EST` when the `SHOW-SERVERS` subcommand is invoked on `2015-04-10`. + +At this current point in time, backups taken on or after `2015-01-10 14:04:23 EST` would be considered `active`. Backups taken prior to `2015-01-10 14:04:23 EST` would be considered `obsolete`, except for backups marked as `keep`. + +```text +-bash-4.1$ date +Fri Apr 10 15:04:19 EDT 2015 +-bash-4.1$ +-bash-4.1$ bart SHOW-SERVERS -s hr +SERVER NAME : hr +HOST NAME : 127.0.0.1 +USER NAME : postgres +PORT : 5432 +REMOTE HOST : +RETENTION POLICY : 2015-01-10 14:04:23 EST +DISK UTILIZATION : 480.76 MB +NUMBER OF ARCHIVES : 26 +ARCHIVE PATH : /opt/backup/hr/archived_wals +ARCHIVE COMMAND : scp %p +enterprisedb@192.168.2.22:/opt/backup/hr/archived_wals/%f +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +DESCRIPTION : "Human Resources" +``` + +#### Evaluating, Marking, and Deleting Backup Using a Recovery Window Retention Policy + +The following code sample uses a recovery window retention policy to evaluate, mark, and delete backups as shown by the following server configuration: + +```text +[DEV] +host = 127.0.0.1 +port = 5445 +user = enterprisedb +archive_command = 'cp %p %a/%f' +retention_policy = 3 DAYS +description = "Development" +``` + +The following is the current set of backups. Note that the last backup in the list has been marked as `keep`. + +```text +-bash-4.1$ bart SHOW-BACKUPS -s dev +SERVER NAME BACKUP ID BACKUP TIME BACKUP SIZE WAL(s) SIZE +WAL FILES STATUS +dev 1428933278236 2015-04-13 09:54:40 EDT 5.65 MB 16.00 MB +1 active +dev 1428862187757 2015-04-12 14:09:50 EDT 5.65 MB 32.00 MB +2 active +dev 1428768351638 2015-04-11 12:05:54 EDT 5.65 MB 32.00 MB +2 active +dev 1428684544008 2015-04-10 12:49:06 EDT 5.65 MB 224.00 MB +14 active +dev 1428590536488 2015-04-09 10:42:18 EDT 5.65 MB 48.00 MB +3 active +dev 1428502171990 2015-04-08 10:09:34 EDT 5.65 MB 80.00 MB +5 keep +``` + +The current date and time is `2015-04-13 16:46:35 EDT` as shown below: + +```text +-bash-4.1$ date +Mon Apr 13 16:46:35 EDT 2015 +``` + +Thus, a 3-day recovery window would evaluate backups prior to `2015-04-10 16:46:35 EDT` as `obsolete` except for those marked as `keep`. + +Invoke the `MANAGE` subcommand with the `-n` option to perform a dry run to observe which active backups would be changed to `obsolete` according to the retention policy. + +```text +-bash-4.1$ bart MANAGE -s dev -n +INFO: processing server 'dev', backup '1428933278236' +INFO: processing server 'dev', backup '1428862187757' +INFO: processing server 'dev', backup '1428768351638' +INFO: processing server 'dev', backup '1428684544008' +INFO: marking backup '1428684544008' as obsolete +INFO: 14 WAL file(s) marked obsolete +INFO: 1 Unused WAL file(s) present +INFO: processing server 'dev', backup '1428590536488' +INFO: marking backup '1428590536488' as obsolete +INFO: 3 WAL file(s) marked obsolete +INFO: 1 Unused WAL file(s) present +INFO: processing server 'dev', backup '1428502171990' +``` + +The dry run shows that backups `1428684544008` and `1428590536488` would be marked as `obsolete`. + +Also note that a dry run does not change the backup status. The two backups that would be considered obsolete are still marked as `active`: + +```text +-bash-4.1$ bart SHOW-BACKUPS -s dev\ + SERVER NAME BACKUP ID BACKUP TIME BACKUP SIZE WAL(s) SIZE + WAL FILES STATUS + dev 1428933278236 2015-04-13 09:54:40 EDT 5.65 MB 16.00 MB + 1 active + dev 1428862187757 2015-04-12 14:09:50 EDT 5.65 MB 32.00 MB + 2 active + dev 1428768351638 2015-04-11 12:05:54 EDT 5.65 MB 32.00 MB + 2 active + dev 1428684544008 2015-04-10 12:49:06 EDT 5.65 MB 224.00 MB + 14 active + dev 1428590536488 2015-04-09 10:42:18 EDT 5.65 MB 48.00 MB + 3 active + dev 1428502171990 2015-04-08 10:09:34 EDT 5.65 MB 80.00 MB + 5 keep +``` + +Invoke the `MANAGE` subcommand omitting the `-n` option to change and mark the status of the backups as `obsolete`: + +```text +-bash-4.1$ bart MANAGE -s dev +INFO: processing server 'dev', backup '1428933278236' +INFO: processing server 'dev', backup '1428862187757' +INFO: processing server 'dev', backup '1428768351638' +INFO: processing server 'dev', backup '1428684544008' +INFO: marking backup '1428684544008' as obsolete +INFO: 14 WAL file(s) marked obsolete +INFO: 1 Unused WAL file(s) present +INFO: processing server 'dev', backup '1428590536488' +INFO: marking backup '1428590536488' as obsolete +INFO: 3 WAL file(s) marked obsolete +INFO: 1 Unused WAL file(s) present +INFO: processing server 'dev', backup '1428502171990' +``` + +The obsolete backups can be observed in a number of ways. Use the `MANAGE` subcommand with the `-l` option to list the `obsolete` backups: + +```text +-bash-4.1$ bart MANAGE -s dev -l +INFO: 14 WAL file(s) will be removed +INFO: 1 Unused WAL file(s) will be removed +SERVER NAME: dev +BACKUP ID: 1428684544008 +BACKUP STATUS: obsolete +BACKUP TIME: 2015-04-10 12:49:06 EDT +BACKUP SIZE: 5.65 MB +WAL FILE(s): 14 +UNUSED WAL FILE(s): 1 +WAL FILE: 00000001000000000000002E +WAL FILE: 00000001000000000000002D +WAL FILE: 00000001000000000000002C +WAL FILE: 00000001000000000000002B +WAL FILE: 00000001000000000000002A +WAL FILE: 000000010000000000000029 +WAL FILE: 000000010000000000000028 +WAL FILE: 000000010000000000000027 +WAL FILE: 000000010000000000000026 +WAL FILE: 000000010000000000000025 +WAL FILE: 000000010000000000000024 +WAL FILE: 000000010000000000000023 +WAL FILE: 000000010000000000000022 +WAL FILE: 000000010000000000000021 +UNUSED WAL FILE: 00000001000000000000000F.00000028 +INFO: 3 WAL file(s) will be removed +INFO: 1 Unused WAL file(s) will be removed +SERVER NAME: dev +BACKUP ID: 1428590536488 +BACKUP STATUS: obsolete +BACKUP TIME: 2015-04-09 10:42:18 EDT\ +BACKUP SIZE: 5.65 MB +WAL FILE(s): 3 +UNUSED WAL FILE(s): 1 +WAL FILE: 000000010000000000000020 +WAL FILE: 00000001000000000000001F +WAL FILE: 00000001000000000000001E +UNUSED WAL FILE: 00000001000000000000000F.00000028 +``` + +The `STATUS` field of the `SHOW-BACKUPS` subcommand displays the current status: + +```text +-bash-4.1$ bart SHOW-BACKUPS -s dev +SERVER NAME BACKUP ID BACKUP TIME BACKUP SIZE WAL(s) SIZE +WAL FILES STATUS +dev 1428933278236 2015-04-13 09:54:40 EDT 5.65 MB 16.00 MB +1 active +dev 1428862187757 2015-04-12 14:09:50 EDT 5.65 MB 32.00 MB +2 active +dev 1428768351638 2015-04-11 12:05:54 EDT 5.65 MB 32.00 MB +2 active +dev 1428684544008 2015-04-10 12:49:06 EDT 5.65 MB 224.00 MB +14 obsolete +dev 1428590536488 2015-04-09 10:42:18 EDT 5.65 MB 48.00 MB +3 obsolete +dev 1428502171990 2015-04-08 10:09:34 EDT 5.65 MB 80.00 MB +5 keep +``` + +The details of an individual backup can be displayed using the `SHOW-BACKUPS` subcommand with the `-t` option. Note the status in the `BACKUP STATUS` field. + +```text +-bash-4.1$ bart SHOW-BACKUPS -s dev -i 1428684544008 -t +SERVER NAME : dev +BACKUP ID : 1428684544008 +BACKUP NAME : none +BACKUP STATUS : obsolete +BACKUP TIME : 2015-04-10 12:49:06 EDT +BACKUP SIZE : 5.65 MB +WAL(S) SIZE : 224.00 MB +NO. OF WALS : 14 +FIRST WAL FILE : 000000010000000000000021 +CREATION TIME : 2015-04-10 12:49:06 EDT +LAST WAL FILE : 00000001000000000000002E +CREATION TIME : 2015-04-11 12:02:15 EDT +``` + +Use the `MANAGE` subcommand with the `-d` option to physically delete the obsolete backups including the unneeded WAL files. + +```text +-bash-4.1$ bart MANAGE -s dev -d +INFO: removing all obsolete backups of server 'dev' +INFO: removing obsolete backup '1428684544008' +INFO: 14 WAL file(s) will be removed +INFO: 1 Unused WAL file(s) will be removed +INFO: removing WAL file '00000001000000000000002E' +INFO: removing WAL file '00000001000000000000002D' +INFO: removing WAL file '00000001000000000000002C' +INFO: removing WAL file '00000001000000000000002B' +INFO: removing WAL file '00000001000000000000002A' +INFO: removing WAL file '000000010000000000000029' +INFO: removing WAL file '000000010000000000000028' +INFO: removing WAL file '000000010000000000000027' +INFO: removing WAL file '000000010000000000000026' +INFO: removing WAL file '000000010000000000000025' +INFO: removing WAL file '000000010000000000000024' +INFO: removing WAL file '000000010000000000000023' +INFO: removing WAL file '000000010000000000000022' +INFO: removing WAL file '000000010000000000000021' +INFO: removing (unused) WAL file '00000001000000000000000F.00000028' +INFO: removing obsolete backup '1428590536488' +INFO: 3 WAL file(s) will be removed +INFO: removing WAL file '000000010000000000000020' +INFO: removing WAL file '00000001000000000000001F' +INFO: removing WAL file '00000001000000000000001E' +``` + +The `SHOW-BACKUPS` subcommand now displays the remaining backups marked as `active` or `keep`: + +```text +-bash-4.1$ bart SHOW-BACKUPS -s dev +SERVER NAME BACKUP ID BACKUP TIME BACKUP SIZE WAL(s) SIZE +WAL FILES STATUS +dev 1428933278236 2015-04-13 09:54:40 EDT 5.65 MB 16.00 MB +1 active +dev 1428862187757 2015-04-12 14:09:50 EDT 5.65 MB 32.00 MB +2 active +dev 1428768351638 2015-04-11 12:05:54 EDT 5.65 MB 32.00 MB +2 active +dev 1428502171990 2015-04-08 10:09:34 EDT 5.65 MB 80.00 MB +5 keep +``` + +## Managing Incremental Backups + +This section illustrates evaluating, marking, and deleting incremental backups using the `MANAGE` and `DELETE` subcommands utilizing redundancy retention policy and recovery window retention policy. For detailed information about the `MANAGE` and `DELETE` subcommands, as well as the redundancy retention and recovery window retention policy, see the *EDB Backup and Recovery User Guide* available at the [EDB website](/bart/2.6/bart_user/). + +- [Using a Redundancy Retention Policy](#redundancy_retention_policy) provides an example of using the `MANAGE` and `DELETE` subcommands when a 3 backup redundancy retention policy is in effect. +- [Using a Recovery Window Retention Policy](#recovery_window_retention_policy) provides an example of using the `MANAGE` and `DELETE` subcommands when a 1-day recovery window retention policy is in effect. + + + +### Using a Redundancy Retention Policy + +The following code sample uses the `MANAGE` and `DELETE` subcommands to evaluate, mark, and delete incremental backups when a 3 backup redundancy retention policy is in effect. The example uses the following server configuration: + +```text +[ACCTG] + +host = 192.168.2.24 +port = 5445 +user = enterprisedb +cluster_owner = enterprisedb +remote_host = enterprisedb@192.168.2.24 +allow_incremental_backups = enabled +retention_policy = 3 BACKUPS +description = "Accounting" +``` + +The example uses the following set of backups. In these code samples, some columns have been omitted from the `SHOW-BACKUPS` output to display the relevant information in a more observable manner. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME ... STATUS +acctg 1481749696905 ... 1481749673603 2016-12-14 16:08:17 EST ... active +acctg 1481749673603 ... 1481749651927 2016-12-14 16:07:53 EST ... active +acctg 1481749651927 ... 1481749619582 2016-12-14 16:07:32 EST ... active +acctg 1481749619582 ... none 2016-12-14 16:07:00 EST ... active +``` + +There is one backup chain. The first backup is the initial full backup. + +Backup chain: `1481749619582 => 1481749651927 => 1481749673603 => 1481749696905` + +The `MANAGE` subcommand is invoked as shown by the following: + +```text +-bash-4.2$ bart MANAGE -s acctg +INFO: processing server 'acctg', backup '1481749619582' +INFO: 2 Unused WAL file(s) present +INFO: 4 Unused file(s) (WALs included) present, use 'MANAGE -l' for the +list +``` + +The following code sample shows the resulting status of the backups: + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME ... STATUS +acctg 1481749696905 ... 1481749673603 2016-12-14 16:08:17 EST ... active +acctg 1481749673603 ... 1481749651927 2016-12-14 16:07:53 EST ... active +acctg 1481749651927 ... 1481749619582 2016-12-14 16:07:32 EST ... active +acctg 1481749619582 ... none 2016-12-14 16:07:00 EST ... active +``` + +The status remains active for all backups. Even though the total number of backups exceeds the 3 backup redundancy retention policy, it is only the total number of full backups that is used to determine if the redundancy retention policy has been exceeded. Additional full backups are added including a second backup chain. The following example shows the resulting list of backups: + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME ... STATUS +acctg 1481750365397 ... none 2016-12-14 16:19:26 EST ... active +acctg 1481750098924 ... 1481749997807 2016-12-14 16:14:59 EST ... active +acctg 1481749997807 ... none 2016-12-14 16:13:18 EST ... active +acctg 1481749992003 ... none 2016-12-14 16:13:12 EST ... active +acctg 1481749696905 ... 1481749673603 2016-12-14 16:08:17 EST ... active +acctg 1481749673603 ... 1481749651927 2016-12-14 16:07:53 EST ... active +acctg 1481749651927 ... 1481749619582 2016-12-14 16:07:32 EST ... active +acctg 1481749619582 ... none 2016-12-14 16:07:00 EST ... active +``` + +Second backup chain: `1481749997807 => 1481750098924` + +The `MANAGE` subcommand is invoked, but now with a total of four active full backups. + +```text +-bash-4.2$ bart MANAGE -s acctg +INFO: processing server 'acctg', backup '1481750365397' +INFO: processing server 'acctg', backup '1481749997807' +INFO: processing server 'acctg', backup '1481749992003' +INFO: processing server 'acctg', backup '1481749619582' +INFO: marking backup '1481749619582' as obsolete +INFO: 3 incremental(s) of backup '1481749619582' will be marked obsolete +INFO: marking incremental backup '1481749696905' as obsolete +INFO: marking incremental backup '1481749673603' as obsolete +INFO: marking incremental backup '1481749651927' as obsolete +INFO: 4 WAL file(s) marked obsolete +INFO: 2 Unused WAL file(s) present +INFO: 4 Unused file(s) (WALs included) present, use 'MANAGE -l' for the +list +``` + +The oldest full backup and its chain of incremental backups are now marked as obsolete. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME ... STATUS +acctg 1481750365397 ... none 2016-12-14 16:19:26 EST ... active +acctg 1481750098924 ... 1481749997807 2016-12-14 16:14:59 EST ... active +acctg 1481749997807 ... none 2016-12-14 16:13:18 EST ... active +acctg 1481749992003 ... none 2016-12-14 16:13:12 EST ... active +acctg 1481749696905 ... 1481749673603 2016-12-14 16:08:17 EST ... obsolete +acctg 1481749673603 ... 1481749651927 2016-12-14 16:07:53 EST ... obsolete +acctg 1481749651927 ... 1481749619582 2016-12-14 16:07:32 EST ... obsolete +acctg 1481749619582 ... none 2016-12-14 16:07:00 EST ... obsolete +``` + +Invoking the `MANAGE` subcommand with the `-d` option deletes the entire obsolete backup chain. + +```text +-bash-4.2$ bart MANAGE -s acctg -d +INFO: removing all obsolete backups of server 'acctg' +INFO: removing obsolete backup '1481749619582' +INFO: 4 WAL file(s) will be removed +INFO: 3 incremental(s) of backup '1481749619582' will be removed +INFO: removing obsolete incremental backup '1481749696905' +INFO: removing obsolete incremental backup '1481749673603' +INFO: removing obsolete incremental backup '1481749651927' +INFO: removing WAL file '000000010000000100000000' +INFO: removing WAL file '0000000100000000000000FF' +INFO: removing WAL file '0000000100000000000000FE' +INFO: removing WAL file '0000000100000000000000FD' +INFO: 16 Unused file(s) will be removed +INFO: removing (unused) file '000000010000000100000004.00000028.backup' +. +. +. +INFO: removing (unused) file +'0000000100000000FB00002800000000FC000000.mbm' +``` + +The following code sample shows the remaining full backups and the second backup chain. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME ... STATUS +acctg 1481750365397 ... none 2016-12-14 16:19:26 EST ... active +acctg 1481750098924 ... 1481749997807 2016-12-14 16:14:59 EST ... active +acctg 1481749997807 ... none 2016-12-14 16:13:18 EST ... active +acctg 1481749992003 ... none 2016-12-14 16:13:12 EST ... active +``` + + + +### Using a Recovery Window Retention Policy + +The following example demonstrates using the `MANAGE` and `DELETE` subcommands to evaluate, mark, and delete incremental backups when a 1-day recovery window retention policy is in effect. The example uses the following server configuration: + +```text +[ACCTG] + +host = 192.168.2.24 +port = 5445 +user = enterprisedb +cluster_owner = enterprisedb +remote_host = enterprisedb@192.168.2.24 +allow_incremental_backups = enabled +retention_policy = 1 DAYS +description = "Accounting" +``` + +The example uses the following set of backups. In the samples, some columns have been omitted from the `SHOW-BACKUPS` output to display the relevant information in a more observable manner. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME ... STATUS +acctg 1481559303348 ... 1481554203288 2016-12-12 11:15:03 EST ... active +acctg 1481559014359 ... 1481554802918 2016-12-12 11:10:14 EST ... active +acctg 1481554802918 ... 1481553914533 2016-12-12 10:00:03 EST ... active +acctg 1481554203288 ... 1481553651165 2016-12-12 09:50:03 EST ... active +acctg 1481553914533 ... 1481553088053 2016-12-12 09:45:14 EST ... active +acctg 1481553651165 ... none 2016-12-12 09:40:51 EST ... active +acctg 1481553088053 ... 1481552078404 2016-12-12 09:31:28 EST ... active +acctg 1481552078404 ... none 2016-12-12 09:14:39 EST ... active +``` + +There are two backup chains. In each of the following chains, the first backup is the initial full backup. + +First backup chain: `1481552078404 => 1481553088053 => 1481553914533 => 1481554802918 => 1481559014359` + +Second backup chain: `1481553651165 => 1481554203288 => 1481559303348` + +The `MANAGE` subcommand is invoked when the first full backup `1481552078404` falls out of the recovery window. When the `MANAGE` subcommand is invoked, it is `2016-12-13 09:20:03 EST`, thus making the start of the 1-day recovery window at `2016-12-12 09:20:03 EST` exactly one day earlier. This backup was taken at `2016-12-12 09:14:39 EST`, which is about 5 ½ minutes before the start of the recovery window, thus making the backup obsolete. + +```text +-bash-4.2$ date +Tue Dec 13 09:20:03 EST 2016 +-bash-4.2$ bart MANAGE -s acctg +INFO: processing server 'acctg', backup '1481553651165' +INFO: processing server 'acctg', backup '1481552078404' +INFO: marking backup '1481552078404' as obsolete +INFO: 4 incremental(s) of backup '1481552078404' will be marked obsolete +INFO: marking incremental backup '1481559014359' as obsolete +INFO: marking incremental backup '1481554802918' as obsolete +INFO: marking incremental backup '1481553914533' as obsolete +INFO: marking incremental backup '1481553088053' as obsolete +INFO: 7 WAL file(s) marked obsolete +INFO: 1 Unused WAL file(s) present +INFO: 2 Unused file(s) (WALs included) present, use 'MANAGE -l' for the list +``` + +The incremental backup date and time are within the recovery window since they were taken after the start of the recovery window of `2016-12-12 09:20:03 EST`, but all backups in the chain are marked as `obsolete`. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg\ +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME +... STATUS +acctg 1481559303348 ... 1481554203288 2016-12-12 11:15:03 EST +... active +acctg 1481559014359 ... 1481554802918 2016-12-12 11:10:14 EST +... obsolete +acctg 1481554802918 ... 1481553914533 2016-12-12 10:00:03 EST +... obsolete +acctg 1481554203288 ... 1481553651165 2016-12-12 09:50:03 EST +... active +acctg 1481553914533 ... 1481553088053 2016-12-12 09:45:14 EST +... obsolete +acctg 1481553651165 ... none 2016-12-12 09:40:51 EST +... active +acctg 1481553088053 ... 1481552078404 2016-12-12 09:31:28 EST +... obsolete +acctg 1481552078404 ... none 2016-12-12 09:14:39 EST +... obsolete +``` + +The following code sample shows how the entire backup chain is changed back to active status by invoking the `MANAGE` subcommand with the `-c nokeep` option on the full backup of the chain. + +```text +-bash-4.2$ bart MANAGE -s acctg -c nokeep -i 1481552078404 +INFO: changing status of backup '1481552078404' of server 'acctg' from +'obsolete' to 'active' +INFO: status of 4 incremental(s) of backup '1481552078404' will be +changed +INFO: changing status of incremental backup '1481559014359' of server +'acctg' from 'obsolete' to 'active' +INFO: changing status of incremental backup '1481554802918' of server +'acctg' from 'obsolete' to 'active' +INFO: changing status of incremental backup '1481553914533' of server +'acctg' from 'obsolete' to 'active' +INFO: changing status of incremental backup '1481553088053' of server +'acctg' from 'obsolete' to 'active' +INFO: 7 WAL file(s) changed +``` + +The backup chain has now been reset to active status. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME ... STATUS +acctg 1481559303348 ... 1481554203288 2016-12-12 11:15:03 EST ... active +acctg 1481559014359 ... 1481554802918 2016-12-12 11:10:14 EST ... active +acctg 1481554802918 ... 1481553914533 2016-12-12 10:00:03 EST ... active +acctg 1481554203288 ... 1481553651165 2016-12-12 09:50:03 EST ... active +acctg 1481553914533 ... 1481553088053 2016-12-12 09:45:14 EST ... active +acctg 1481553651165 ... none 2016-12-12 09:40:51 EST ... active +acctg 1481553088053 ... 1481552078404 2016-12-12 09:31:28 EST ... active +acctg 1481552078404 ... none 2016-12-12 09:14:39 EST ... active +``` + +The following code sample shows usage of the `DELETE` subcommand on an incremental backup. The specified incremental backup `1481554802918` in the first backup chain as well as its successive incremental backup `1481559014359` are deleted. + +```text +-bash-4.2$ bart DELETE -s acctg -i 1481554802918 +INFO: deleting backup '1481554802918' of server 'acctg' +INFO: deleting backup '1481554802918' +INFO: 1 incremental backup(s) will be deleted +INFO: deleting incremental backup '1481559014359' +INFO: WALs of deleted backup(s) will belong to prior backup(if any), or +will be marked unused +INFO: 2 Unused file(s) will be removed +INFO: removing (unused) file '0000000100000000000000BA' +INFO: removing (unused) file +'0000000100000000BA00002800000000BB000000.mbm' +INFO: backup(s) deleted +``` + +The results show that the backups `1481554802918` and `1481559014359` are no longer listed by the `SHOW-BACKUPS` subcommand. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME ... STATUS +acctg 1481559303348 ... 1481554203288 2016-12-12 11:15:03 EST ... active +acctg 1481554203288 ... 1481553651165 2016-12-12 09:50:03 EST ... active +acctg 1481553914533 ... 1481553088053 2016-12-12 09:45:14 EST ... active +acctg 1481553651165 ... none 2016-12-12 09:40:51 EST ... active +acctg 1481553088053 ... 1481552078404 2016-12-12 09:31:28 EST ... active +acctg 1481552078404 ... none 2016-12-12 09:14:39 EST ... active +``` + +The `MANAGE` subcommand is invoked again. This time both backup chains are marked `obsolete` since the full backups of both chains fall out of the start of the recovery window, which is now `2016-12-12 09:55:03 EST`. + +```text +-bash-4.2$ date +Tue Dec 13 09:55:03 EST 2016 +-bash-4.2$ bart MANAGE -s acctg +INFO: processing server 'acctg', backup '1481553651165' +INFO: marking backup '1481553651165' as obsolete +INFO: 2 incremental(s) of backup '1481553651165' will be marked obsolete +INFO: marking incremental backup '1481559303348' as obsolete +INFO: marking incremental backup '1481554203288' as obsolete +INFO: 38 WAL file(s) marked obsolete +INFO: processing server 'acctg', backup '1481552078404' +INFO: marking backup '1481552078404' as obsolete +INFO: 2 incremental(s) of backup '1481552078404' will be marked obsolete +INFO: marking incremental backup '1481553914533' as obsolete +INFO: marking incremental backup '1481553088053' as obsolete +INFO: 7 WAL file(s) marked obsolete +``` + +The following code sample shows both backup chains marked as `obsolete`. + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME +... STATUS +acctg 1481559303348 ... 1481554203288 2016-12-12 11:15:03 EST +... obsolete +acctg 1481554203288 ... 1481553651165 2016-12-12 09:50:03 EST +... obsolete +acctg 1481553914533 ... 1481553088053 2016-12-12 09:45:14 EST +... obsolete +acctg 1481553651165 ... none 2016-12-12 09:40:51 EST +... obsolete +acctg 1481553088053 ... 1481552078404 2016-12-12 09:31:28 EST +... obsolete +acctg 1481552078404 ... none 2016-12-12 09:14:39 EST +... obsolete +``` + +The following code sample demonstrates using the `MANAGE` subcommand with the `-c keep` option to keep a backup chain indefinitely. The `MANAGE` subcommand with the `-c keep` option must specify the backup identifier or backup name of the full backup of the chain, and not any incremental backup. + +```text +-bash-4.2$ bart MANAGE -s acctg -c keep -i 1481553651165 +INFO: changing status of backup '1481553651165' of server 'acctg' from +'obsolete' to 'keep' +INFO: status of 2 incremental(s) of backup '1481553651165' will be +changed +INFO: changing status of incremental backup '1481559303348' of server +'acctg' from 'obsolete' to 'keep' +INFO: changing status of incremental backup '1481554203288' of server +'acctg' from 'obsolete' to 'keep' +INFO: 38 WAL file(s) changed +``` + +The full backup `1481553651165` and its successive incremental backups `1481554203288` and `1481559303348` have been changed to `keep` status: + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME +... STATUS +acctg 1481559303348 ... 1481554203288 2016-12-12 11:15:03 EST +... keep +acctg 1481554203288 ... 1481553651165 2016-12-12 09:50:03 EST +... keep +acctg 1481553914533 ... 1481553088053 2016-12-12 09:45:14 EST +... obsolete +acctg 1481553651165 ... none 2016-12-12 09:40:51 EST +... keep +acctg 1481553088053 ... 1481552078404 2016-12-12 09:31:28 EST +... obsolete +acctg 1481552078404 ... none 2016-12-12 09:14:39 EST +... obsolete +``` + +Finally, the `MANAGE` subcommand with the `-d` option is used to delete the `obsolete` backup chain: + +```text +-bash-4.2$ bart MANAGE -s acctg -d +INFO: removing all obsolete backups of server 'acctg' +INFO: removing obsolete backup '1481552078404' +INFO: 7 WAL file(s) will be removed +INFO: 2 incremental(s) of backup '1481552078404' will be removed +INFO: removing obsolete incremental backup '1481553914533' +INFO: removing obsolete incremental backup '1481553088053' +INFO: removing WAL file '0000000100000000000000C1' +INFO: removing WAL file '0000000100000000000000C0' +INFO: removing WAL file '0000000100000000000000BF' +INFO: removing WAL file '0000000100000000000000BE' +INFO: removing WAL file '0000000100000000000000BD' +INFO: removing WAL file '0000000100000000000000BC' +INFO: removing WAL file '0000000100000000000000BB' +INFO: 48 Unused file(s) will be removed +INFO: removing (unused) file '0000000100000000000000FA' +. +. +. +INFO: removing (unused) file '0000000100000000000000BB.00000028.backup' +``` + +Only the backup chain with the `keep` status remains as shown below: + +```text +-bash-4.2$ bart SHOW-BACKUPS -s acctg +SERVER NAME BACKUP ID ... BACKUP PARENT BACKUP TIME +... STATUS +acctg 1481559303348 ... 1481554203288 2016-12-12 11:15:03 EST +... keep +acctg 1481554203288 ... 1481553651165 2016-12-12 09:50:03 EST +... keep +acctg 1481553651165 ... none 2016-12-12 09:40:51 EST +... keep +``` diff --git a/product_docs/docs/bart/2.6/bart_ref/03_sample_bart_system_with_local_and_remote_database_servers.mdx b/product_docs/docs/bart/2.6/bart_ref/03_sample_bart_system_with_local_and_remote_database_servers.mdx new file mode 100644 index 00000000000..f8034584c1d --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_ref/03_sample_bart_system_with_local_and_remote_database_servers.mdx @@ -0,0 +1,1385 @@ +--- +title: "Sample BART System with Local and Remote Database Servers" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/sample_bart_system_with_local_and_remote_database_servers.html" +--- + + + +This section describes a sample BART managed backup and recovery system consisting of both local and remote database servers. The complete steps to configure and operate the system are provided. + +For detailed information about configuring a BART system, see the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/2.6/bart_inst/). For detailed information about the operational procedures and BART subcommands, see the *EDB Backup and Recovery User Guide* available at the [EDB website](/bart/2.6/bart_user/). + +The environment for this sample system is as follows: + +- BART on host `192.168.2.22` running with BART user account `enterprisedb` +- Local Advanced Server on host `192.168.2.22` running with user account `enterprisedb` +- Remote Advanced Server on host `192.168.2.24` running with user account `enterprisedb` +- Remote PostgreSQL server on host `192.168.2.24` running with user account `postgres` + +Passwordless SSH/SCP connections are required between the following: + +- BART on host `192.168.2.22` and the local Advanced Server on the same host `192.168.2.22` +- BART on host `192.168.2.22` and the remote Advanced Server on host `192.168.2.24` +- BART on host `192.168.2.22` and the remote PostgreSQL server on host `192.168.2.24` + +The following sections demonstrate configuring and taking full backups only. To support incremental backups as well, enable the `allow_incremental_backups` parameter for the desired database servers and use the `WAL scanner` program. + +- [The BART Configuration File](#bart_configuration_file) shows the settings used in the BART configuration file. +- [Establishing SSH/SCP Passwordless Connections](#establishing-sshscp-passwordless-connections) provides an example of how to establish an SSH/SCP passwordless connection. +- [Configuring a Replication Database User](#configuring-a-replication-database-user) provides an example of how to configure the replication database user. +- [WAL Archiving Configuration Parameters](#wal-archiving-configuration-parameters) provides an example of how to configure WAL archiving. +- [Creating the BART Backup Catalog](#creating-the-bart-backup-catalog-backup_path) provides information about creating a BART Backup Catalog. +- [Starting the Database Servers with WAL Archiving](#starting-the-database-servers-with-wal-archiving) provides example of starting the database servers with WAL archiving. +- [Taking a Full Backup](#taking-a-full-backup) illustrates taking the first full backup of the database servers. +- [Using Point-In-Time Recovery](#using-point-in-time-recovery) demonstrates the point-in-time recovery operation on the remote PostgreSQL database server. + + + +## The BART Configuration File + +The following code sample shows the settings used in the BART configuration file for the examples that follow: + +```text +[BART] +bart_host= enterprisedb@192.168.2.22 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +retention_policy = 6 BACKUPS +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log + +[ACCTG] +host = 127.0.0.1 +port = 5444 +user = enterprisedb +cluster_owner = enterprisedb +backup_name = acctg_%year-%month-%dayT%hour:%minute +archive_command = 'cp %p %a/%f' +description = "Accounting" + +[MKTG] + +host = 192.168.2.24 +port = 5444 +user = repuser +cluster_owner = enterprisedb +backup_name = mktg_%year-%month-%dayT%hour:%minute +remote_host = enterprisedb@192.168.2.24 +description = "Marketing" + +[HR] + +host = 192.168.2.24 +port = 5432 +user = postgres +cluster_owner = postgres +backup_name = hr_%year-%month-%dayT%hour:%minute +remote_host = postgres@192.168.2.24 +copy_wals_during_restore = enabled +description = "Human Resources" +``` + + + +## Establishing SSH/SCP Passwordless Connections + +This section demonstrates how passwordless SSH/SCP connections are established with the authorized public keys files. + + + +### Generating a Public Key File for the BART User Account + +The BART user account is `enterprisedb` with a home directory of `/opt/PostgresPlus/9.6AS`. + +To generate the public key file, as a root user, first create the `.ssh` subdirectory in the BART user’s home directory and assign ownership of this directory to the `enterprisedb` user, ensuring there are no groups or other users that can access the `.ssh` directory. + +```text +[root@localhost 9.6AS]# pwd +/opt/PostgresPlus/9.6AS +[root@localhost 9.6AS]# mkdir .ssh +[root@localhost 9.6AS]# chown enterprisedb .ssh +[root@localhost 9.6AS]# chgrp enterprisedb .ssh +[root@localhost 9.6AS]# chmod 700 .ssh +[root@localhost 9.6AS]# ls -la | grep ssh +drwx------ 2 enterprisedb enterprisedb 4096 Apr 23 13:02 .ssh +``` + +Generate the public key file: + +```text +[user@localhost ~]$ su - enterprisedb +Password: +-bash-4.1$ pwd +/opt/PostgresPlus/9.6AS +-bash-4.1$ ssh-keygen -t rsa +Generating public/private rsa key pair. +Enter file in which to save the key +(/opt/PostgresPlus/9.6AS/.ssh/id_rsa): +Enter passphrase (empty for no passphrase): +Enter same passphrase again: +Your identification has been saved in +/opt/PostgresPlus/9.6AS/.ssh/id_rsa. +Your public key has been saved in +/opt/PostgresPlus/9.6AS/.ssh/id_rsa.pub. +The key fingerprint is: +de:65:34:d6:b1:d2:32:3c:b0:43:c6:a3:c0:9f:f4:64 +enterprisedb@localhost.localdomain +The key's randomart image is: ++----[ RSA 2048]----+ +| . .+ . | +| o .oE+ o o | +| + * o.X + | +| + .+ * | +| S o | +| . . o | +| . . | +| + | +| | ++-------------------+ +``` + +The following are the resulting files. `id_rsa.pub` is the public key file of BART user account `enterprisedb`. + +```text +-bash-4.1$ ls -l .ssh +total 8 +-rw------- 1 enterprisedb enterprisedb 1675 Apr 23 13:04 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Apr 23 13:04 id_rsa.pub +``` + +### Configuring Access between Local Advanced Server and the BART Host + +Even when the Advanced Server database is on the same host as the BART user account, and the Advanced Server database cluster owner is also the BART user account (`enterprisedb` is this case), a passwordless SSH/SCP connection must be established from the same user account to itself. + +On the BART host where the public key file was just generated (as shown in [Generating a Public Key File for the BART User Account](#generating-a-public-key-file-for-the-bart-user-account)), create the authorized keys file by appending the public key file to any existing authorized keys file. + +Log into the BART host as the BART user account and append the public key file, `id_rsa.pub` onto the `authorized_keys` file in the same `.ssh` directory. + +```text +[user@localhost ~]$ su - enterprisedb +Password: +Last login: Thu Mar 23 10:27:35 EDT 2017 on pts/0 +-bash-4.2$ pwd +/opt/PostgresPlus/9.6AS +-bash-4.2$ ls -l .ssh +total 12 +-rw------- 1 enterprisedb enterprisedb 1675 Mar 23 09:54 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Mar 23 09:54 id_rsa.pub +-rw-r--r-- 1 enterprisedb enterprisedb 345 Mar 23 10:05 known_hosts +-bash-4.2$ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys +-bash-4.2$ ls -l .ssh +total 16 +-rw-rw-r-- 1 enterprisedb enterprisedb 416 Mar 23 10:33 authorized_keys +-rw------- 1 enterprisedb enterprisedb 1675 Mar 23 09:54 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Mar 23 09:54 id_rsa.pub +-rw-r--r-- 1 enterprisedb enterprisedb 345 Mar 23 10:05 known_hosts +``` + +The `authorized_keys` file must have file permission `600` as set by the following `chmod 600` command, or the passwordless connection will fail: + +```text +-bash-4.2$ chmod 600 ~/.ssh/authorized_keys +-bash-4.2$ ls -l .ssh +total 16 +-rw------- 1 enterprisedb enterprisedb 416 Mar 23 10:33 authorized_keys +-rw------- 1 enterprisedb enterprisedb 1675 Mar 23 09:54 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Mar 23 09:54 id_rsa.pub +-rw-r--r-- 1 enterprisedb enterprisedb 345 Mar 23 10:05 known_hosts +``` + +Test the passwordless connection. Use the `ssh` command to verify that you can access the same user account as you are currently logged in as (`enterprisedb`) without being prompted for a password: + +```text +-bash-4.2$ ssh enterprisedb@127.0.0.1 +Last login: Thu Mar 23 10:27:50 2017 +-bash-4.2$ exit +logout +Connection to 127.0.0.1 closed. +``` + +### Configuring Access from Remote Advanced Server to BART Host + +On the remote host `192.168.2.24`, create the public key file for the remote database server user account, `enterprisedb`, for access to the BART user account, `enterprisedb`, on the BART host 192.168.2.22. + +Create the `.ssh` directory for user account `enterprisedb` on the remote host: + +```text +[root@localhost 9.6AS]# pwd +/opt/PostgresPlus/9.6AS +[root@localhost 9.6AS]# mkdir .ssh +[root@localhost 9.6AS]# chown enterprisedb .ssh +[root@localhost 9.6AS]# chgrp enterprisedb .ssh +[root@localhost 9.6AS]# chmod 700 .ssh +[root@localhost 9.6AS]# ls -la | grep ssh +drwx------ 2 enterprisedb enterprisedb 4096 Apr 23 13:08 .ssh +``` + +Generate the public key file on the remote host for user account `enterprisedb`: + +```text +[user@localhost ~]$ su - enterprisedb +Password: +-bash-4.1$ ssh-keygen -t rsa +Generating public/private rsa key pair. +Enter file in which to save the key +(/opt/PostgresPlus/9.6AS/.ssh/id_rsa): +Enter passphrase (empty for no passphrase): +Enter same passphrase again: +Your identification has been saved in +/opt/PostgresPlus/9.6AS/.ssh/id_rsa. +Your public key has been saved in +/opt/PostgresPlus/9.6AS/.ssh/id_rsa.pub. +The key fingerprint is: +15:27:1e:1e:61:4b:48:66:67:0b:b2:be:fc:ea:ea:e6 +enterprisedb@localhost.localdomain +The key's randomart image is: ++--[ RSA 2048]---+ +| ..=.@.. | +| =.O O | +| . * | +| . . | +| . S | +| . . | +| o | +| . . | +| +Eoo.. | ++----------------+ +``` + +Copy the generated public key file, `id_rsa.pub`, to the BART user account, `enterprisedb`, on the BART host, `192.168.2.22`: + +```text +-bash-4.1$ scp ~/.ssh/id_rsa.pub enterprisedb@192.168.2.22:/tmp/tmp.pub +The authenticity of host '192.168.2.22 (192.168.2.22)' can't be +established. +RSA key fingerprint is b8:a9:97:31:79:16:b8:2b:b0:60:5a:91:38:d7:68:22. +Are you sure you want to continue connecting (yes/no)? yes +Warning: Permanently added '192.168.2.22' (RSA) to the list of known hosts. +enterprisedb@192.168.2.22's password: +id_rsa.pub +``` + +Log into the BART host as the BART user account and append the temporary public key file, `/tmp/tmp.pub` onto the `authorized_keys` file owned by the BART user account. + +```text +-bash-4.1$ ssh enterprisedb@192.168.2.22 +enterprisedb@192.168.2.22's password: +Last login: Tue Apr 21 17:03:24 2015 from 192.168.2.22 +-bash-4.1$ pwd +/opt/PostgresPlus/9.6AS +-bash-4.1$ cat /tmp/tmp.pub >> ~/.ssh/authorized_keys +-bash-4.1$ ls -l .ssh +total 12 +-rw-rw-r-- 1 enterprisedb enterprisedb 416 Apr 23 13:15 authorized_keys +-rw------- 1 enterprisedb enterprisedb 1675 Apr 23 13:04 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Apr 23 13:04 id_rsa.pub +``` + +The `authorized_keys` file must have file permission `600` as set by the following `chmod 600` command, otherwise the passwordless connection fails: + +```text +-bash-4.1$ chmod 600 ~/.ssh/authorized_keys +-bash-4.1$ ls -l .ssh +total 12 +-rw------- 1 enterprisedb enterprisedb 416 Apr 23 13:15 authorized_keys +-rw------- 1 enterprisedb enterprisedb 1675 Apr 23 13:04 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Apr 23 13:04 id_rsa.pub +-bash-4.1$ rm /tmp/tmp.pub +-bash-4.1$ exit +logout +Connection to 192.168.2.22 closed. +``` + +Test the passwordless connection. From the remote host, verify that you can log into the BART host with the BART user account without being prompted for a password: + +```text +-bash-4.1$ ssh enterprisedb@192.168.2.22 +Last login: Thu Apr 23 13:14:48 2015 from 192.168.2.24 +-bash-4.1$ exit +logout +Connection to 192.168.2.22 closed. +``` + +### Configuring Access from the BART Host to a Remote Advanced Server + +On the BART host `192.168.2.22`, copy the public key file for the BART user account, `enterprisedb`, for access to the remote database server user account, `enterprisedb`, on the remote host `192.168.2.24`. + +The following lists the current SSH keys files in the BART user’s `.ssh` directory on the BART host: + +```text +[user@localhost ~]$ su - enterprisedb +Password: +-bash-4.1$ pwd +/opt/PostgresPlus/9.6AS +-bash-4.1$ ls -l .ssh +total 12 +-rw------- 1 enterprisedb enterprisedb 416 Apr 23 13:15 authorized_keys +-rw------- 1 enterprisedb enterprisedb 1675 Apr 23 13:04 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Apr 23 13:04 id_rsa.pub +``` + +The public key file, `id_rsa.pub`, for BART user account `enterprisedb` on the BART host that was earlier generated in [Generating a Public Key File for the BART User Account](#generating-a-public-key-file-for-the-bart-user-account), is now copied to the remote Advanced Server host on `192.168.2.24`: + +```text +-bash-4.1$ scp ~/.ssh/id_rsa.pub enterprisedb@192.168.2.24:/tmp/tmp.pub +The authenticity of host '192.168.2.24 (192.168.2.24)' can't be +established. +RSA key fingerprint is 59:41:fb:0c:ae:64:3d:3f:a2:d9:90:95:cf:2c:99:f2. +Are you sure you want to continue connecting (yes/no)? yes +Warning: Permanently added '192.168.2.24' (RSA) to the list of known +hosts. +enterprisedb@192.168.2.24's password: +id_rsa.pub +``` + +Log into the `enterprisedb` user account on the remote host and copy the public key file onto the `authorized_keys` file of the remote `enterprisedb` user account under its `.ssh` directory: + +```text +-bash-4.1$ ssh enterprisedb@192.168.2.24 +enterprisedb@192.168.2.24's password: +Last login: Tue Apr 21 09:53:18 2015 from 192.168.2.22 +-bash-4.1$ pwd +/opt/PostgresPlus/9.6AS +-bash-4.1$ ls -l .ssh +total 12 +-rw------- 1 enterprisedb enterprisedb 1675 Apr 23 13:11 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Apr 23 13:11 id_rsa.pub +-rw-r--r-- 1 enterprisedb enterprisedb 394 Apr 23 13:12 known_hosts +-bash-4.1$ cat /tmp/tmp.pub >> ~/.ssh/authorized_keys +``` + +Adjust the file permission on `authorized_keys`: + +```text +-bash-4.1$ chmod 600 ~/.ssh/authorized_keys +-bash-4.1$ ls -l .ssh +total 16 +-rw------- 1 enterprisedb enterprisedb 416 Apr 23 13:26 authorized_keys +-rw------- 1 enterprisedb enterprisedb 1675 Apr 23 13:11 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Apr 23 13:11 id_rsa.pub +-rw-r--r-- 1 enterprisedb enterprisedb 394 Apr 23 13:12 known_hosts +-bash-4.1$ rm /tmp/tmp.pub +-bash-4.1$ exit +logout +Connection to 192.168.2.24 closed. +``` + +While logged into the BART host, test the passwordless connection from the BART host to the remote Advanced Server host: + +```text +-bash-4.1$ ssh enterprisedb@192.168.2.24 +Last login: Thu Apr 23 13:25:53 2015 from 192.168.2.22 +-bash-4.1$ exit +logout +Connection to 192.168.2.24 closed. +``` + +### Configuring Access from a Remote PostgreSQL Server to a BART Host + +On the remote host (192.168.2.24), create a public key file owned by the database server user account (`postgres`), allowing access to the BART user account (`enterprisedb`) on the BART host (192.168.2.22). + +Create the `.ssh` directory for the `postgres` user account on the remote host: + +```text +[root@localhost 9.6]# cd /opt/PostgreSQL/9.6 +[root@localhost 9.6]# mkdir .ssh +[root@localhost 9.6]# chown postgres .ssh +[root@localhost 9.6]# chgrp postgres .ssh +[root@localhost 9.6]# chmod 700 .ssh +[root@localhost 9.6]# ls -la | grep ssh +drwx------ 2 postgres postgres 4096 Apr 23 13:32 .ssh +``` + +Create and copy the generated public key file, `id_rsa.pub`, to the BART user account (`enterprisedb`), on the BART host (`192.168.2.22`): + +```text +[user@localhost ~]$ su - postgres +Password: +-bash-4.1$ pwd +/opt/PostgreSQL/9.6 +-bash-4.1$ ssh-keygen -t rsa +Generating public/private rsa key pair. +Enter file in which to save the key (/opt/PostgreSQL/9.6/.ssh/id_rsa): +Enter passphrase (empty for no passphrase): +Enter same passphrase again: +Your identification has been saved in /opt/PostgreSQL/9.6/.ssh/id_rsa. +Your public key has been saved in /opt/PostgreSQL/9.6/.ssh/id_rsa.pub. +The key fingerprint is: +1f:f8:76:d6:fc:a5:1a:c5:5a:66:66:01:d0:a0:ca:ba +postgres@localhost.localdomain +The key's randomart image is: ++--[ RSA 2048]----+ +| o+. | +| . .. | +| . . | +| . . . . . | +| o S . O | +| . o . @ | +| . + = o .| +| . . o . o.| +| E ... .| ++-----------------+ +-bash-4.1$ ls -l .ssh +total 8 +-rw------- 1 postgres postgres 1671 Apr 23 13:36 id_rsa +-rw-r--r-- 1 postgres postgres 412 Apr 23 13:36 id_rsa.pub +-bash-4.1$ scp ~/.ssh/id_rsa.pub enterprisedb@192.168.2.22:/tmp/tmp.pub +The authenticity of host '192.168.2.22 (192.168.2.22)' can't be +established. +RSA key fingerprint is b8:a9:97:31:79:16:b8:2b:b0:60:5a:91:38:d7:68:22. +Are you sure you want to continue connecting (yes/no)? yes +Warning: Permanently added '192.168.2.22' (RSA) to the list of known +hosts. +enterprisedb@192.168.2.22's password: +id_rsa.pub +``` + +Log into the BART host as the BART user account and append the temporary public key file, `/tmp/tmp.pub`, onto the `authorized_keys` file owned by the BART user account. + +```text +-bash-4.1$ ssh enterprisedb@192.168.2.22 +enterprisedb@192.168.2.22's password: +Last login: Thu Apr 23 13:19:25 2015 from 192.168.2.24 +-bash-4.1$ pwd +/opt/PostgresPlus/9.6AS +-bash-4.1$ cat /tmp/tmp.pub >> ~/.ssh/authorized_keys +-bash-4.1$ ls -l .ssh +total 16 +-rw------- 1 enterprisedb enterprisedb 828 Apr 23 13:40 authorized_keys +-rw------- 1 enterprisedb enterprisedb 1675 Apr 23 13:04 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Apr 23 13:04 id_rsa.pub +-rw-r--r-- 1 enterprisedb enterprisedb 394 Apr 23 13:24 known_hosts +-bash-4.1$ rm /tmp/tmp.pub +-bash-4.1$ exit +logout +Connection to 192.168.2.22 closed. +``` + +Make sure the `authorized_keys` file has file permission 600 as shown, or the passwordless connection will fail. Test the passwordless connection; from the remote host, while logged in as user account `postgres`, verify that you can log into the BART host with the BART user account without being prompted for a password: + +```text +-bash-4.1$ pwd +/opt/PostgreSQL/9.6 +-bash-4.1$ ssh enterprisedb@192.168.2.22 +Last login: Thu Apr 23 13:40:10 2015 from 192.168.2.24 +-bash-4.1$ exit +logout +Connection to 192.168.2.22 closed. +``` + +### Configuring Access from the BART Host to Remote PostgreSQL + +Copy the public key file on the BART host that is owned by the BART user account (`enterprisedb`) to the remote database server user account (`postgres`), on the remote host (192.168.2.24). + +The following lists the current SSH keys files in the BART user’s `.ssh` directory on the BART host: + +```text +[user@localhost ~]$ su - enterprisedb +Password: +-bash-4.1$ ls -l .ssh +total 16 +-rw------- 1 enterprisedb enterprisedb 828 Apr 23 13:40 authorized_keys +-rw------- 1 enterprisedb enterprisedb 1675 Apr 23 13:04 id_rsa +-rw-r--r-- 1 enterprisedb enterprisedb 416 Apr 23 13:04 id_rsa.pub +-rw-r--r-- 1 enterprisedb enterprisedb 394 Apr 23 13:24 known_hosts +``` + +The public key file, `id_rsa.pub`, for BART user account `enterprisedb` on the BART host that was earlier generated in [Generating a Public Key File for the BART User Account](#generating-a-public-key-file-for-the-bart-user-account), now resides on the remote PostgreSQL host: + +```text +-bash-4.1$ scp ~/.ssh/id_rsa.pub postgres@192.168.2.24:/tmp/tmp.pub +postgres@192.168.2.24's password: +id_rsa.pub +``` + +Log into the `postgres` user account on the remote host and copy the public key file onto the `authorized_keys` file of `postgres` under its `.ssh` directory: + +```text +-bash-4.1$ ssh postgres@192.168.2.24 +postgres@192.168.2.24's password: +Last login: Mon Jan 26 18:08:36 2015 from 192.168.2.19 +-bash-4.1$ pwd +/opt/PostgreSQL/9.6 +-bash-4.1$ cat /tmp/tmp.pub >> ~/.ssh/authorized_keys +``` + +Adjust the file permissions on `authorized_keys`: + +```text +-bash-4.1$ ls -l .ssh +total 16 +-rw-rw-r-- 1 postgres postgres 416 Apr 23 13:52 authorized_keys +-rw------- 1 postgres postgres 1671 Apr 23 13:36 id_rsa +-rw-r--r-- 1 postgres postgres 412 Apr 23 13:36 id_rsa.pub +-rw-r--r-- 1 postgres postgres 394 Apr 23 13:36 known_hosts +-bash-4.1$ chmod 600 ~/.ssh/authorized_keys +-bash-4.1$ ls -l .ssh +total 16 +-rw------- 1 postgres postgres 416 Apr 23 13:52 authorized_keys +-rw------- 1 postgres postgres 1671 Apr 23 13:36 id_rsa +-rw-r--r-- 1 postgres postgres 412 Apr 23 13:36 id_rsa.pub +-rw-r--r-- 1 postgres postgres 394 Apr 23 13:36 known_hosts +-bash-4.1$ rm /tmp/tmp.pub +-bash-4.1$ exit +logout +Connection to 192.168.2.24 closed. +``` + +Test the passwordless connection from the BART host to the remote PostgreSQL host: + +```text +[user@localhost ~]$ su - enterprisedb +Password: +-bash-4.1$ ssh postgres@192.168.2.24 +Last login: Thu Apr 23 13:52:25 2015 from 192.168.2.22 +-bash-4.1$ exit +logout +Connection to 192.168.2.24 closed. +``` + + + +## Configuring a Replication Database User + +This section demonstrates how a replication database user is established. + +**All database servers must use a superuser as the replication database user.** + +The replication database user for each database server is specified by the `user` parameter in the BART configuration file as shown by the following: + +```text +[ACCTG] + +host = 127.0.0.1 +port = 5444 +user = enterprisedb <=== Replication Database User +cluster_owner = enterprisedb +backup_name = acctg_%year-%month-%dayT%hour:%minute +archive_command = 'cp %p %a/%f' +description = "Accounting" + +[MKTG] +host = 192.168.2.24 +port = 5444 +user = repuser <=== Replication Database User +cluster_owner = enterprisedb +backup_name = mktg_%year-%month-%dayT%hour:%minute +remote_host = enterprisedb@192.168.2.24 +description = "Marketing" + +[HR] + +host = 192.168.2.24 +port = 5432 +user = postgres <=== Replication Database User +cluster_owner = enterprisedb +backup_name = hr_%year-%month-%dayT%hour:%minute +remote_host = postgres@192.168.2.24 +copy_wals_during_restore = enabled +description = "Human Resources" +``` + +Add entries to the `.pgpass` file on each server to allow the BART user account to initiate a backup without being prompted for credentials. The `.pgpass` file is located in `/opt/PostgresPlus/9.6AS/.pgpass`: + +```text +127.0.0.1:5444:*:enterprisedb:password +192.168.2.24:5444:*:repuser:password +192.168.2.24:5432:*:postgres:password +``` + +For more information about using a `.pgpass` file, please see the [PostgreSQL documentation](https://www.postgresql.org/docs/current/libpq-pgpass.html). + +While connected to `MKTG` on 192.168.2.24, execute the following `CREATE ROLE` command to create the replication database superuser: + +```text +CREATE ROLE repuser WITH LOGIN SUPERUSER PASSWORD 'password'; +``` + +Access is granted in the `pg_hba.conf` file for the local Advanced Server: + +```text +# TYPE DATABASE USER ADDRESS METHOD +# "local" is for Unix domain socket connections only +local all all md5 +# IPv4 local connections: +host template1 enterprisedb 127.0.0.1/32 md5 +host edb enterprisedb 127.0.0.1/32 md5 +#host all all 127.0.0.1/32 md5 +# IPv6 local connections: +host all all ::1/128 md5 +# Allow replication connections from localhost, by a user with the +# replication privilege. +#local replication enterprisedb md5 +host replication enterprisedb 127.0.0.1/32 md5 +``` + +Similarly, access is granted in the `pg_hba.conf` file for the remote Advanced Server installation: + +```text +# TYPE DATABASE USER ADDRESS METHOD +# "local" is for Unix domain socket connections only +local all all md5 +# IPv4 local connections: +host template1 repuser 192.168.2.22/32 md5 +host all enterprisedb 127.0.0.1/32 md5 +#host all all 127.0.0.1/32 md5 +# IPv6 local connections: +host all all ::1/128 md5 +# Allow replication connections from localhost, by a user with the +# replication privilege. +#local replication enterprisedb md5 +host replication repuser 192.168.2.22/32 md5 +``` + +Access is also granted in the `pg_hba.conf` file for the remote PostgreSQL server: + +```text +# TYPE DATABASE USER ADDRESS METHOD +# "local" is for Unix domain socket connections only +local all all md5 +# IPv4 local connections: +host template1 postgres 192.168.2.22/32 md5 +host all all 127.0.0.1/32 md5 +# IPv6 local connections: +host all all ::1/128 md5 +# Allow replication connections from localhost, by a user with the +q# replication privilege. +#local replication postgres md5 +host replication postgres 192.168.2.22/32 md5 +``` + + + +## WAL Archiving Configuration Parameters + +Use the following parameters in the `postgresql.conf` file to enable WAL archiving. The `postgresql.conf` file for the local Advanced Server database (`ACCTG`) is set as follows: + +```text +wal_level = archive +archive_mode = on # allows archiving to be done + # (change requires restart) +#archive_command = '' # command to use to archive + a logfile segment + # placeholders: %p = path of + file to archive + # %f = file name only +max_wal_senders = 3 +``` + +When the `INIT` subcommand is invoked, the Postgres `archive_command` configuration parameter in the `postgresql.auto.conf` file will be set based on the BART `archive_command` parameter located in the BART configuration file. + +!!! Note + If the Postgres `archive_command` is already set, invoke the `INIT` subcommand with the `-- no-configure` option to prevent the `archive_command` from being reset. For details, see [INIT](../bart_user/03_using_bart/03_basic_bart_subcommand_usage/02_init/#init). + +```text +[BART] +bart_host= enterprisedb@192.168.2.22 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +retention_policy = 6 BACKUPS +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log + +[ACCTG] +host = 127.0.0.1 +port = 5444 +user = enterprisedb +cluster_owner = enterprisedb +backup_name = acctg_%year-%month-%dayT%hour:%minute +archive_command = 'cp %p %a/%f' +description = "Accounting" +``` + +When the `INIT` subcommand is invoked, the `postgresql.auto.conf` file contains the following: + +```text +# Do not edit this file manually! +# It will be overwritten by ALTER SYSTEM command. +archive_command = 'cp %p /opt/backup/acctg/archived_wals/%f' +``` + +The `archive_command` uses the `cp` command instead of `scp` since the BART backup catalog is local to this database cluster and the BART user account (the account that owns the backup catalog, `enterprisedb`), is the same user account running Advanced Server. The result is that there is no directory permission conflict during the archive operation. + +The `postgresql.conf` file for the remote Advanced Server, `MKTG` is set as follows: + +```text +wal_level = archive +archive_mode = on # allows archiving to be done + # (change requires restart) +archive_command = '' # command to use to archive a + logfile segment + # placeholders: %p = path of + file to archive + # %f = file name only +max_wal_senders = 3 +``` + +When the `INIT` subcommand is invoked, the Postgres `archive_command` configuration parameter in the `postgresql.auto.conf` file will be set by the default BART format of the BART `archive_command` parameter (since it is not explicitly set for this database server in the BART configuration file). + +```text +[BART] +bart_host= enterprisedb@192.168.2.22 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +retention_policy = 6 BACKUPS +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log +. +. +. +[MKTG] + +host = 192.168.2.24 +port = 5444 +user = repuser +cluster_owner = enterprisedb +backup_name = mktg_%year-%month-%dayT%hour:%minute +remote_host = enterprisedb@192.168.2.24 +description = "Marketing" +``` + +The default BART `archive_command` format is: + +```text +archive_command = 'scp %p %h:%a/%f' +``` + +The `postgresql.auto.conf` file contains the following after the `INIT` subcommand is invoked: + +```text +# Do not edit this file manually! +# It will be overwritten by ALTER SYSTEM command. +archive_command = 'scp %p +enterprisedb@192.168.2.22:/opt/backup/hr/archived_wals/%f' +``` + +The `archive_command` uses the `scp` command since the BART backup catalog is remote relative to this database cluster. The BART user account, `enterprisedb`, is specified on the `scp` command since this is the user account owning the BART backup catalog where the archived WAL files are to be copied. The result is that there is no directory permission conflict during the archive operation. + +The `postgresql.conf` file for the remote PostgreSQL server (`HR`) is set as follows: + +```text +wal_level = archive +archive_mode = on # allows archiving to be done + # (change requires restart) +#archive_command = '' # command to use to archive a + logfile segment + # placeholders: %p = path of + file to archive + # %f = file name only +max_wal_senders = 3 +``` + +When the `INIT` subcommand is invoked, the Postgres `archive_command` configuration parameter in the `postgresql.auto.conf` file will be set by the default BART format of the BART `archive_command` parameter (since it is not explicitly set for this database server in the BART configuration file): + +```text +[BART] + +bart_host= enterprisedb@192.168.2.22 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +retention_policy = 6 BACKUPS +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log +. +. +. +[HR] + +host = 192.168.2.24 +port = 5432 +user = postgres +cluster_owner = postgres +backup_name = hr_%year-%month-%dayT%hour:%minute +remote_host = postgres@192.168.2.24 +copy_wals_during_restore = enabled +description = "Human Resources" +``` + +The default BART `archive_command` format is: + +```text +archive_command = 'scp %p %h:%a/%f' +``` + +The `postgresql.auto.conf` file contains the following after the `INIT` subcommand is invoked: + +```text +# Do not edit this file manually! +# It will be overwritten by ALTER SYSTEM command. +archive_command = 'scp %p +enterprisedb@192.168.2.22:/opt/backup/hr/archived_wals/%f' +``` + +The `archive_command` uses the `scp` command since the BART backup catalog is remote relative to this database cluster. The BART user account, `enterprisedb`, is specified on the `scp` command since this is the user account owning the BART backup catalog where the archived WAL files are to be copied. The result is that there is no directory permission conflict during the archive operation. + + + +## Creating the BART Backup Catalog (backup_path) + +Create the directory specified by the `backup_path` configuration parameter. + +```text +[BART] + +bart_host= enterprisedb@192.168.2.22 +backup_path = /opt/backup +pg_basebackup_path = /usr/edb/as11/bin/pg_basebackup +retention_policy = 6 BACKUPS +logfile = /tmp/bart.log +scanner_logfile = /tmp/bart_scanner.log +``` + +Ensure that the directory is owned by the BART user account: + +```text +[root@localhost opt]# pwd +/opt +[root@localhost opt]# mkdir backup +[root@localhost opt]# chown enterprisedb backup +[root@localhost opt]# chgrp enterprisedb backup +[root@localhost opt]# chmod 700 backup +[root@localhost opt]# ls -l | grep backup +drwx------ 2 enterprisedb enterprisedb 4096 Apr 23 15:36 backup +``` + +Use the BART `INIT` subcommand to complete the directory structure and set the Postgres `archive_command` configuration parameter. + +Before invoking any BART subcommands, set up a profile under the BART user account’s home directory to set the `LD_LIBRARY_PATH` and `PATH` environment variables. For more information regarding setting this variable, see the EDB Backup and Recovery Installation and Upgrade Guide available at the [EDB website](/bart/2.6/bart_inst/). + +The `-o` option is specified with the `INIT` subcommand to force the setting of the Postgres `archive_command` configuration parameter when `archive_mode` is `off` or if the Postgres `archive_command` parameter is already set and needs to be overridden. + +```text +[user@localhost ~]$ su - enterprisedb +Password: +-bash-4.1$ bart INIT -o +INFO: setting archive_command for server 'acctg' +WARNING: archive_command is set. server restart is required +INFO: setting archive_command for server 'hr' +WARNING: archive_command is set. server restart is required +INFO: setting archive_command for server 'mktg' +WARNING: archive_command is set. server restart is required +``` + +The BART `SHOW-SERVERS` subcommand displays the following: + +```text +-bash-4.1$ bart SHOW-SERVERS +SERVER NAME : acctg +BACKUP FRIENDLY NAME: acctg_%year-%month-%dayT%hour:%minute +HOST NAME : 127.0.0.1 +USER NAME : enterprisedb +PORT : 5444 +REMOTE HOST : +RETENTION POLICY : 6 Backups +DISK UTILIZATION : 0.00 bytes +NUMBER OF ARCHIVES : 0 +ARCHIVE PATH : /opt/backup/acctg/archived_wals +ARCHIVE COMMAND : (disabled) +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +INCREMENTAL BACKUP : DISABLED +DESCRIPTION : "Accounting" +SERVER NAME : hr +BACKUP FRIENDLY NAME: hr_%year-%month-%dayT%hour:%minute +HOST NAME : 192.168.2.24 +USER NAME : postgres +PORT : 5432 +REMOTE HOST : postgres@192.168.2.24 +RETENTION POLICY : 6 Backups +DISK UTILIZATION : 0.00 bytes +NUMBER OF ARCHIVES : 0 +ARCHIVE PATH : /opt/backup/hr/archived_wals +ARCHIVE COMMAND : (disabled) +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +INCREMENTAL BACKUP : DISABLED +DESCRIPTION : "Human Resources" +SERVER NAME : mktg +BACKUP FRIENDLY NAME: mktg_%year-%month-%dayT%hour:%minute +HOST NAME : 192.168.2.24 +USER NAME : repuser +PORT : 5444 +REMOTE HOST : enterprisedb@192.168.2.24 +RETENTION POLICY : 6 Backups +DISK UTILIZATION : 0.00 bytes +NUMBER OF ARCHIVES : 0 +ARCHIVE PATH : /opt/backup/mktg/archived_wals +ARCHIVE COMMAND : (disabled) +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +INCREMENTAL BACKUP : DISABLED +DESCRIPTION : "Marketing" +-bash-4.1$ cd /opt/backup +-bash-4.1$ pwd +/opt/backup +-bash-4.1$ ls -l +total 12 +drwxrwxr-x 3 enterprisedb enterprisedb 4096 Mar 29 13:16 acctg +drwxrwxr-x 3 enterprisedb enterprisedb 4096 Mar 29 13:16 hr +drwxrwxr-x 3 enterprisedb enterprisedb 4096 Mar 29 13:16 mktg +-bash-4.1$ ls -l acctg +total 4 +drwxrwxr-x 2 enterprisedb enterprisedb 4096 Mar 29 13:16 archived_wals +-bash-4.1$ ls -l hr +total 4 +drwxrwxr-x 2 enterprisedb enterprisedb 4096 Mar 29 13:16 archived_wals +-bash-4.1$ ls -l mktg +total 4 +drwxrwxr-x 2 enterprisedb enterprisedb 4096 Mar 29 13:16 archived_wals +``` + +The `ARCHIVE PATH` field displays the full directory path to where the WAL files are copied. This directory path must match the directory path specified in the Postgres `archive_command` parameter of the `postgresql.conf` file or the `postgresql.auto.conf` file of each database server. + + + +### Starting the Database Servers with WAL Archiving + +After the BART backup catalog directory structure has been configured, start the archiving of WAL files from the database servers by restarting each database server. + +On BART host 192.168.2.22: + +```text +[root@localhost data]# service ppas-9.6 restart +``` + +On remote host 192.168.2.24: + +```text +[root@localhost data]# service ppas-9.6 restart + +[root@localhost data]# service postgresql-9.6 restart +``` + +In the BART backup catalog, verify that the WAL files are archiving. + +Archived WAL files may not appear very frequently depending upon how often WAL archiving is set to switch to a new segment file with the `archive_timeout` parameter in your database server configuration settings. + +Verify that there are no archiving-related errors in the database server log files. + +## Taking a Full Backup + +The following code sample shows the first full backup of the database servers. + +```text +-bash-4.1$ bart BACKUP -s acctg -z +INFO: creating backup for server 'acctg' +INFO: backup identifier: '1490809695281' +60776/60776 kB (100%), 1/1 tablespace + +INFO: backup completed successfully +INFO: backup checksum: 37f3defb98ca88dcf05079815555dfc2 of base.tar.gz +INFO: +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1490809695281 +BACKUP NAME: acctg_2017-03-29T13:48 +BACKUP PARENT: none +BACKUP LOCATION: /opt/backup/acctg/1490809695281 +BACKUP SIZE: 6.10 MB +BACKUP FORMAT: tar.gz +BACKUP TIMEZONE: US/Eastern +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 1 +ChkSum File +37f3defb98ca88dcf05079815555dfc2 base.tar.gz + +TABLESPACE(s): 0 +START WAL LOCATION: 000000010000000000000004 +STOP WAL LOCATION: 000000010000000000000004 +BACKUP METHOD: streamed +BACKUP FROM: primary +START TIME: 2017-03-29 13:48:15 EDT +STOP TIME: 2017-03-29 13:48:17 EDT +TOTAL DURATION: 2 sec(s) + +-bash-4.1$ bart BACKUP -s mktg -z +INFO: creating backup for server 'mktg' +INFO: backup identifier: '1490809751193' +61016/61016 kB (100%), 1/1 tablespace + +INFO: backup completed successfully +INFO: backup checksum: 8b010e130a105e76d01346bb56dfcf14 of base.tar.gz +INFO: +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1490809751193 +BACKUP NAME: mktg_2017-03-29T13:49 +BACKUP PARENT: none +BACKUP LOCATION: /opt/backup/mktg/1490809751193 +BACKUP SIZE: 6.13 MB +BACKUP FORMAT: tar.gz +BACKUP TIMEZONE: US/Eastern +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 1 +ChkSum File +8b010e130a105e76d01346bb56dfcf14 base.tar.gz + +TABLESPACE(s): 0 +START WAL LOCATION: 000000010000000100000085 +BACKUP METHOD: streamed +BACKUP FROM: primary +START TIME: 2017-03-29 13:49:11 EDT +STOP TIME: 2017-03-29 13:49:14 EDT +TOTAL DURATION: 3 sec(s) + +-bash-4.1$ bart BACKUP -s hr -z +INFO: creating backup for server 'hr' +INFO: backup identifier: '1490809824946' +38991/38991 kB (100%), 1/1 tablespace +INFO: backup completed successfully +INFO: backup checksum: 277e8a1a80ba3474f541eb316a417c9a of base.tar.gz +INFO: +BACKUP DETAILS: +BACKUP STATUS: active +BACKUP IDENTIFIER: 1490809824946 +BACKUP NAME: hr_2017-03-29T13:50 +BACKUP PARENT: none +BACKUP LOCATION: /opt/backup/hr/1490809824946 +BACKUP SIZE: 2.59 MB +BACKUP FORMAT: tar.gz +BACKUP TIMEZONE: US/Eastern +XLOG METHOD: fetch +BACKUP CHECKSUM(s): 1 +ChkSum File +277e8a1a80ba3474f541eb316a417c9a base.tar.gz + +TABLESPACE(s): 0 +START WAL LOCATION: 000000010000000000000002 +BACKUP METHOD: streamed +BACKUP FROM: primary +START TIME: 2017-03-29 13:50:25 EDT +STOP TIME: 2017-03-29 13:50:26 EDT +TOTAL DURATION: 1 sec(s) +``` + +The following code sample shows the backup directories created for each backup of each database server. The backup ID is used as the backup directory name. + +```text +-bash-4.1$ cd /opt/backup +-bash-4.1$ ls -l +total 12 +drwxrwxr-x 4 enterprisedb enterprisedb 4096 Mar 29 13:48 acctg +drwxrwxr-x 4 enterprisedb enterprisedb 4096 Mar 29 13:50 hr +drwxrwxr-x 4 enterprisedb enterprisedb 4096 Mar 29 13:49 mktg +-bash-4.1$ ls -l acctg +total 8 +drwx------ 2 enterprisedb enterprisedb 4096 Mar 29 13:48 1490809695281 +drwxrwxr-x 2 enterprisedb enterprisedb 4096 Mar 29 13:48 archived_wals +-bash-4.1$ ls -l hr +total 8 +drwx------ 2 enterprisedb enterprisedb 4096 Mar 29 13:50 1490809824946 +drwxrwxr-x 2 enterprisedb enterprisedb 4096 Mar 29 13:50 archived_wals +-bash-4.1$ ls -l mktg +total 8 +drwx------ 2 enterprisedb enterprisedb 4096 Mar 29 13:49 1490809751193 +drwxrwxr-x 2 enterprisedb enterprisedb 4096 Mar 29 13:49 archived_wals +``` + + + +## Using Point-In-Time Recovery + +This section demonstrates using the point-in-time recovery operation on the remote PostgreSQL database server. + +The following tables were created about two minutes apart with WAL archiving enabled: + +```text +postgres=# \dt + + List of relations +Schema | Name | Type | Owner + +--------+----------------+---------+--------- +public | hr_rmt_t1_1356 | table | postgres +public | hr_rmt_t1_1358 | table | postgres +public | hr_rmt_t1_1400 | table | postgres +public | hr_rmt_t1_1402 | table | postgres +public | hr_rmt_t1_1404 | table | postgres +public | hr_rmt_t1_1406 | table | postgres +(6 rows) +``` + +In the table name `hr_rmt_t_, n` represents the active timeline. `` is the approximate time the table was created. For example, `hr_rmt_t1_1356` was created at approximately 1:56 PM while timeline #1 is active. + +The PostgreSQL database server was then stopped. WAL files that have been created, but not yet archived must be identified, and then saved. The following archived WAL files are in the BART backup catalog: + +```text +-bash-4.1$ ls -l hr/archived_wals +total 49156 +-rw------- 1 enterprisedb enterprisedb 16777216 Mar 29 13:50 +000000010000000000000001 +-rw------- 1 enterprisedb enterprisedb 16777216 Mar 29 13:50 +000000010000000000000002 +-rw------- 1 enterprisedb enterprisedb 302 Mar 29 13:50 +000000010000000000000002.00000028.backup +-rw------- 1 enterprisedb enterprisedb 16777216 Mar 29 14:07 +000000010000000000000003 +``` + +The following sample lists the current PostgreSQL server WAL files. The unarchived WAL files are marked with two stars (\*\*). + +```text +-bash-4.1$ cd /opt/PostgreSQL/9.6/data/pg_xlog +-bash-4.1$ pwd +/opt/PostgreSQL/9.6/data/pg_xlog +-bash-4.1$ ls -l +total 49160 +-rw------- 1 postgres postgres 302 Mar 29 13:50 +000000010000000000000002.00000028.backup +-rw------- 1 postgres postgres 16777216 Mar 29 14:07 +000000010000000000000003 +-rw------- 1 postgres postgres 16777216 Mar 29 14:07 +**000000010000000000000004** +-rw------- 1 postgres postgres 16777216 Mar 29 13:50 +**000000010000000000000005** +drwx------ 2 postgres postgres 4096 Mar 29 14:07 archive_status +``` + +Copies of the unarchived WAL files are saved to a temporary location: + +```text +-bash-4.1$ mkdir /tmp/unarchived_pg96_wals +-bash-4.1$ pwd +/opt/PostgreSQL/9.6/data/pg_xlog +bash-4.1$ cp -p 000000010000000000000004 /tmp/unarchived_pg96_wals +bash-4.1$ cp -p 000000010000000000000005 /tmp/unarchived_pg96_wals +bash-4.1$ ls -l /tmp/unarchived_pg96_wals +total 32768 +-rw------- 1 postgres postgres 16777216 Mar 29 14:07 000000010000000000000004 +-rw------- 1 postgres postgres 16777216 Mar 29 13:50 000000010000000000000005 +``` + +On the remote host, a directory is created to which the PostgreSQL database cluster is to be restored. This restore path is named `/opt/restore_pg96` and is owned by user account `postgres`. + +```text +[user@localhost ~]$ su root +Password: +[root@localhost user]# cd /opt +[root@localhost opt]# mkdir restore_pg96 +[root@localhost opt]# chown postgres restore_pg96 +[root@localhost opt]# chgrp postgres restore_pg96 +[root@localhost opt]# chmod 700 restore_pg96 +[root@localhost opt]# ls -l +total 16 +drwxr-xr-x 4 root daemon 4096 Mar 29 12:10 PostgresPlus +drwxr-xr-x 3 root daemon 4096 Mar 29 12:25 PostgreSQL +drwx------ 2 postgres postgres 4096 Mar 29 14:15 restore_pg96 +drwxr-xr-x. 2 root root 4096 Nov 22 2013 rh +``` + +In the BART configuration file, the remote user and remote host IP address, `postgres@192.168.2.24`, have been set with the `remote_host` parameter. If not given in the BART configuration file, this information must then be specified by the `--remote-host` option when giving the `RESTORE` subcommand (for example, `bart RESTORE --remote-host postgres@192.168.2.24 …`). + +```text +[HR] + +host = 192.168.2.24 +port = 5432 +user = postgres +cluster_owner = postgres +backup_name = hr_%year-%month-%dayT%hour:%minute +remote_host = postgres@192.168.2.24 +copy_wals_during_restore = enabled +description = "Human Resources" +``` + +Use the `SHOW-BACKUPS` subcommand to identify the backup to use with the `RESTORE` subcommand. + +```text +SERVER NAME BACKUP ID BACKUP NAME BACKUP PARENT +BACKUP TIME +BACKUP SIZE WAL(s) SIZE WAL FILES STATUS +acctg 1490809695281 acctg_2017-03-29T13:48 none +2017-03-29 13:48:17 EDT +6.10 MB 32.00 MB 2 active +hr 1490809824946 hr_2017-03-29T13:50 none +2017-03-29 13:50:26 EDT +2.59 MB 32.00 MB 2 active +mktg 1490809751193 mktg_2017-03-29T13:49 none +2017-03-29 13:49:14 EDT +6.13 MB 64.00 MB 4 active +``` + +The `-t` option with the `SHOW-BACKUPS` subcommand displays additional backup information: + +```text +-bash-4.1$ bart SHOW-BACKUPS -s hr -i 1490809824946 -t +SERVER NAME : hr +BACKUP ID : 1490809824946 +BACKUP NAME : hr_2017-03-29T13:50 +BACKUP PARENT : none +BACKUP STATUS : active +BACKUP TIME : 2017-03-29 13:50:26 EDT +BACKUP SIZE : 2.59 MB +WAL(S) SIZE : 32.00 MB +NO. OF WALS : 2 +FIRST WAL FILE : 000000010000000000000002 +CREATION TIME : 2017-03-29 13:50:31 EDT +LAST WAL FILE : 000000010000000000000003 +CREATION TIME : 2017-03-29 14:07:35 EDT +``` + +A recovery is made using timeline `1` to `2017-03-29 14:01:00`. + +```text +-bash-4.1$ bart RESTORE -s hr -i hr_2017-03-29T13:50 -p +/opt/restore_pg96 -t 1 -g '2017-03-29 14:01:00' +INFO: restoring backup 'hr_2017-03-29T13:50' of server 'hr' +INFO: base backup restored +INFO: copying WAL file(s) to +postgres@192.168.2.24:/opt/restore_pg96/archived_wals +INFO: writing recovery settings to postgresql.auto.conf file +INFO: archiving is disabled +INFO: permissions set on $PGDATA +INFO: restore completed successfully +``` + +The following example shows the restored backup files in the restore path directory, `/opt/restore_pg96`: + +```text +-bash-4.1$ pwd +/opt/restore_pg96 +-bash-4.1$ ls -l +total 128 +drwxr-xr-x 2 postgres postgres 4096 Mar 29 14:27 archived_wals +-rw------- 1 postgres postgres 206 Mar 29 13:50 backup_label +drwx------ 5 postgres postgres 4096 Mar 29 12:25 base +drwx------ 2 postgres postgres 4096 Mar 29 14:27 global +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_clog +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_commit_ts +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_dynshmem +-rw------- 1 postgres postgres 4212 Mar 29 13:18 pg_hba.conf +-rw------- 1 postgres postgres 1636 Mar 29 12:25 pg_ident.conf +drwxr-xr-x 2 postgres postgres 4096 Mar 29 13:45 pg_log +drwx------ 4 postgres postgres 4096 Mar 29 12:25 pg_logical +drwx------ 4 postgres postgres 4096 Mar 29 12:25 pg_multixact +drwx------ 2 postgres postgres 4096 Mar 29 13:43 pg_notify +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_replslot +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_serial +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_snapshots +drwx------ 2 postgres postgres 4096 Mar 29 13:43 pg_stat +drwx------ 2 postgres postgres 4096 Mar 29 13:50 pg_stat_tmp +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_subtrans +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_tblspc +drwx------ 2 postgres postgres 4096 Mar 29 12:25 pg_twophase +-rw------- 1 postgres postgres 4 Mar 29 12:25 PG_VERSION +drwx------ 3 postgres postgres 4096 Mar 29 14:27 pg_xlog +-rw------- 1 postgres postgres 169 Mar 29 13:24 postgresql.auto.conf +-rw-r--r-- 1 postgres postgres 21458 Mar 29 14:27 postgresql.conf +-rw-r--r-- 1 postgres postgres 118 Mar 29 14:27 postgresql.auto.conf +``` + +Copy the saved, unarchived WAL files to the restore path `pg_xlog` subdirectory (`/opt/restore_pg96/pg_xlog`): + +```text +-bash-4.1$ pwd +/opt/restore_pg96/pg_xlog +-bash-4.1$ ls -l +total 16388 +-rw------- 1 postgres postgres 16777216 Mar 29 13:50 +000000010000000000000002 +drwx------ 2 postgres postgres 4096 Mar 29 14:27 archive_status +-bash-4.1$ ls -l /tmp/unarchived_pg96_wals +total 32768 +-rw------- 1 postgres postgres 16777216 Mar 29 14:07 +000000010000000000000004 +-rw------- 1 postgres postgres 16777216 Mar 29 13:50 +000000010000000000000005 +-bash-4.1$ cp -p /tmp/unarchived_pg96_wals/* . +-bash-4.1$ ls -l +total 49156 +-rw------- 1 postgres postgres 16777216 Mar 29 13:50 +000000010000000000000002 +-rw------- 1 postgres postgres 16777216 Mar 29 14:07 +000000010000000000000004 +-rw------- 1 postgres postgres 16777216 Mar 29 13:50 +000000010000000000000005 +drwx------ 2 postgres postgres 4096 Mar 29 14:27 archive_status +``` + +Inspect the `/opt/restore_pg96/postgresql.auto.conf` file to verify that it contains the correct recovery settings: + +```text +restore_command = 'cp archived_wals/%f %p' +recovery_target_time = '2017-03-29 14:01:00' +recovery_target_timeline = 1 +``` + +Note that the command restores from the `archived_wals` subdirectory of `/opt/restore_pg96` since the `copy_wals_during_restore` parameter in the BART configuration file is set to `enabled` for database server `hr`. + +Start the database server to initiate the point-in-time recovery operation: + +```text +[user@localhost ~]$ su postgres +Password: +bash-4.1$ cd /opt/restore_pg96 +bash-4.1$ /opt/PostgreSQL/9.6/bin/pg_ctl start -D /opt/restore_pg96 -l +/opt/restore_pg96/pg_log/logfile +server starting +``` + +Inspect the database server log file to ensure the operation did not result in any errors: + +```text +2017-03-29 14:33:23 EDT LOG: database system was interrupted; last known +up at 2017-03-29 13:50:25 EDT +2017-03-29 14:33:23 EDT LOG: starting point-in-time recovery to +2017-03-29 14:01:00-04 +2017-03-29 14:33:23 EDT LOG: restored log file +"000000010000000000000002" from archive +2017-03-29 14:33:23 EDT LOG: redo starts at 0/2000098 +2017-03-29 14:33:23 EDT LOG: consistent recovery state reached at +0/20000C0 +2017-03-29 14:33:23 EDT LOG: restored log file +"000000010000000000000003" from archive +2017-03-29 14:33:23 EDT LOG: recovery stopping before commit of +transaction 1762, time 2017-03-29 14:02:28.100072-04 +2017-03-29 14:33:23 EDT LOG: redo done at 0/303F390 +2017-03-29 14:33:23 EDT LOG: last completed transaction was at log time +2017-03-29 14:00:43.351333-04 +cp: cannot stat `archived_wals/00000002.history': No such file or +directory +2017-03-29 14:33:23 EDT LOG: selected new timeline ID: 2 +cp: cannot stat `archived_wals/00000001.history': No such file or +directory +2017-03-29 14:33:23 EDT LOG: archive recovery complete +2017-03-29 14:33:23 EDT LOG: MultiXact member wraparound protections are +now enabled +2017-03-29 14:33:23 EDT LOG: database system is ready to accept +connections +2017-03-29 14:33:23 EDT LOG: autovacuum launcher started +``` + +The tables that exist in the recovered database cluster are: + +```text +postgres=# \dt + List of relations +Schema | Name | Type | Owner +--------+----------------+-------+---------- +public | hr_rmt_t1_1356 | table | postgres +public | hr_rmt_t1_1358 | table | postgres +public | hr_rmt_t1_1400 | table | postgres +(3 rows) +``` + +Since recovery was up to and including 2017-03-29 14:01:00, the following tables created after 14:01 are not present: + +```text +public | hr_rmt_t1_1402 | table | postgres +public | hr_rmt_t1_1404 | table | postgres +public | hr_rmt_t1_1406 | table | postgres +``` + +The BART `RESTORE` operation stops WAL archiving by adding an `archive_mode = off` parameter at the very end of the `postgresql.conf` file. This last parameter in the file overrides any other previous setting of the same parameter in the file. Delete the last setting and restart the database server to start WAL archiving. + +```text +# Add settings for extensions here +archive_mode = off +``` diff --git a/product_docs/docs/bart/2.6/bart_ref/images/EDB_logo.png b/product_docs/docs/bart/2.6/bart_ref/images/EDB_logo.png new file mode 100755 index 00000000000..39a54822d85 Binary files /dev/null and b/product_docs/docs/bart/2.6/bart_ref/images/EDB_logo.png differ diff --git a/product_docs/docs/bart/2.6/bart_ref/images/edb.png b/product_docs/docs/bart/2.6/bart_ref/images/edb.png new file mode 100755 index 00000000000..71e5bdde787 Binary files /dev/null and b/product_docs/docs/bart/2.6/bart_ref/images/edb.png differ diff --git a/product_docs/docs/bart/2.6/bart_ref/images/edb_logo.svg b/product_docs/docs/bart/2.6/bart_ref/images/edb_logo.svg new file mode 100755 index 00000000000..f24d1dfefee --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_ref/images/edb_logo.svg @@ -0,0 +1,19 @@ + + + edb-logo-disc-dark + + + + \ No newline at end of file diff --git a/product_docs/docs/bart/2.6/bart_ref/images/image2.png b/product_docs/docs/bart/2.6/bart_ref/images/image2.png new file mode 100755 index 00000000000..4eba2e7efa7 Binary files /dev/null and b/product_docs/docs/bart/2.6/bart_ref/images/image2.png differ diff --git a/product_docs/docs/bart/2.6/bart_ref/index.mdx b/product_docs/docs/bart/2.6/bart_ref/index.mdx new file mode 100644 index 00000000000..1af3ceb2813 --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_ref/index.mdx @@ -0,0 +1,33 @@ +--- +navTitle: Reference Guide +title: "EDB Postgres Backup and Recovery Reference Guide" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/genindex.html" + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/conclusion.html" + - "/edb-docs/d/edb-backup-and-recovery-tool/reference/reference-guide/2.6.1/index.html" +--- + +This guide acts as a quick reference for BART subcommands and provides comprehensive examples of the following BART operations: + +- Performing a full backup of database servers +- Performing a point-in-time recovery (PITR) on a remote PostgreSQL database server +- Restoring an incremental backup +- Restoring a database cluster with tablespaces +- Evaluating, marking, and deleting backups and incremental backups +- Configuring and operating local and remote database servers + +For detailed information about BART subcommands and operations, see the EDB Backup and Recovery User Guide available at the [EDB website](/bart/2.6/bart_user/). + +The document is organized as follows: + +- See [Subcommands](01_bart_subcommands_examples/#using_bart_subcommands) to view BART subcommand examples. +- See [Examples](02_additional_examples/#examples) to view BART operations examples. +- See [Sample BART System](03_sample_bart_system_with_local_and_remote_database_servers/#a_sample_bart_system_with_local_and_remote_database_servers) to view examples of both local and remote database server configuration and operation. + +
+ +bart_subcommands_examples additional_examples sample_bart_system_with_local_and_remote_database_servers conclusion + +
diff --git a/product_docs/docs/bart/2.6/bart_user/01_introduction.mdx b/product_docs/docs/bart/2.6/bart_user/01_introduction.mdx new file mode 100644 index 00000000000..c87bc7e24e0 --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_user/01_introduction.mdx @@ -0,0 +1,55 @@ +--- +title: "Introduction" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/introduction.html" +--- + +The EDB Backup and Recovery Tool (BART) is an administrative utility that provides simplified backup and recovery management for multiple local or remote EDB Advanced Server and PostgreSQL database servers. + +BART provides the following features: + +- Support for complete, hot, physical backups of multiple Advanced Servers and PostgreSQL database servers +- Support for two types of backups – full base backups and block-level incremental backups +- Backup and recovery management of database servers on local or remote hosts +- A single, centralized catalog for backup data +- Retention policy support for defining and managing how long backups should be kept +- The capability to store the backup data in compressed format +- Verified backup data with checksums +- Backup information displayed in an easy-to-read format +- A simplified point-in-time recovery process + +This guide provides the following information about using BART: + +- an [overview](02_overview/#overview) of the BART components and concepts. +- [backup and recovery management process](03_using_bart/#using_bart). +- [using tablespaces](04_using_tablespaces/#using_tablespaces). + +For information about installing BART, see the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/2.6/bart_inst/). To view examples of BART operations and subcommand usage, see the *EDB Backup and Recovery Reference Guide* available at the [EDB website](/bart/2.6/bart_ref/). + + + +## Conventions Used in this Guide + +The following is a list of conventions used throughout this document. + +- Much of the information in this document applies interchangeably to the PostgreSQL and EDB Advanced Server database systems. The term *Advanced Server* is used to refer to EDB Advanced Server. The term *Postgres* is used to generically refer to both PostgreSQL and Advanced Server. When a distinction needs to be made between these two database systems, the specific names, PostgreSQL or Advanced Server are used. + +- The installation directory of the PostgreSQL or Advanced Server products is referred to as `POSTGRES_INSTALL_HOME`: + + - For PostgreSQL Linux installations, this defaults to `/opt/PostgreSQL/` for version 10 and earlier. For later versions, the installation directory is `/var/lib/pgsql/`. + - For Advanced Server Linux installations performed using the interactive installer for version 10 and earlier, this defaults to `/opt/PostgresPlus/AS` or `/opt/edb/as`. For Advanced Server Linux installations performed with an RPM package, this defaults to `/usr/ppas-` or `/usr/edb/as`. For Advanced Server Linux installations performed with an RPM package for version 11 or later, this defaults to `/usr/edb/as`. + +## Restrictions on pg_basebackup + +BART takes full backups using the `pg_basebackup` utility program under the following conditions: + +- The backup is taken on a standby server. +- The `--with-pg_basebackup` option is specified with the `BACKUP` subcommand (see [Backup](03_using_bart/03_basic_bart_subcommand_usage/03_backup/#backup)). +- The number of thread count in effect is 1, and the `with-pg_basebackup` option is not specified with the `BACKUP` subcommand. +- Database servers can only be backed up using `pg_basebackup` utility program of the same or later version than the database server version. + +In the global section of the BART configuration file, the `pg_basebackup_path` parameter specifies the complete directory path to the `pg_basebackup` program. For information about the `pg_basebackup_path` parameter and the `thread_count`, see the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/2.6/bart_inst/). + +For information about `pg_basebackup`, see the [PostgreSQL Core Documentation](https://postgresql.org/docs/current/static/app-pgbasebackup.html). diff --git a/product_docs/docs/bart/2.6/bart_user/02_overview/01_block-level_incremental_backup/01_incremental_backup_limitations_and_requirements.mdx b/product_docs/docs/bart/2.6/bart_user/02_overview/01_block-level_incremental_backup/01_incremental_backup_limitations_and_requirements.mdx new file mode 100644 index 00000000000..d0293b345ad --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_user/02_overview/01_block-level_incremental_backup/01_incremental_backup_limitations_and_requirements.mdx @@ -0,0 +1,42 @@ +--- +title: "Incremental Backup Limitations and Requirements" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/incremental_backup_limitations_and_requirements.html" +--- + + + +The following limitations apply to incremental backup: + +- If you have restored a full or incremental backup, you must take a full backup before enabling incremental backup. +- If a standby node has been promoted to the role of a primary node, you must take a full backup before enabling incremental backup on the cluster. +- On a standby database server, you cannot take an incremental backup. + +You must meet the following requirements before implementing incremental backup: + +- You must create or select an operating system account to be used as the BART user account. + +- You must create or select the replication database user, which must be a superuser. + +- In the BART configuration file: + + - You must set the `cluster_owner` parameter to the Linux operating system user account that owns the database cluster directory from which incremental backups are to be taken. + - You must enable the `allow_incremental_backups` parameter. + +- A passwordless SSH/SCP connection must be established between the BART user account on the BART host and the `cluster_owner` user account on the database server. + + It must be noted that a passwordless SSH/SCP connection must be established even if BART and the database server are running on the same host and the BART user account and the `cluster_owner` user account are the same account. + +- In addition to the BART host (where the BART backup catalog resides), the BART package must also be installed on every remote database server on which incremental backups are to be restored. To restore an incremental backup, the `bart` program must be executable on the remote host by the remote user (the remote user is specified by the `remote_host` parameter in the BART configuration file or by the `-r` option when using the `RESTORE` subcommand to restore the incremental backup). + +- When [restoring incremental backups on a remote database server](05_restoring_an_incremental_backup/#restoring-an-incremental-backup-on-a-remote-host), a passwordless SSH/SCP connection must be established from the BART user account on the BART host to the remote user on the remote host (the remote user is specified by the `remote_host` parameter in the BART configuration file or by the `-r` option when using the `RESTORE` subcommand to restore the incremental backup). + +- Compression of archived WAL files in the BART backup catalog is not permitted for database servers on which incremental backups are to be taken. The `wal_compression` setting in the BART configuration file must be disabled for those database servers. + +- The incremental backup must be on the same timeline as the parent backup. The timeline changes after each recovery operation so an incremental backup cannot use a parent backup from an earlier timeline. + +For information about configuring these requirements, see the EDB Backup and Recovery Installation and Upgrade Guide available at the [EDB website](/bart/2.6/bart_inst/). + +The following section provides an overview of the basic incremental backup concepts. diff --git a/product_docs/docs/bart/2.6/bart_user/02_overview/01_block-level_incremental_backup/02_concept_overview.mdx b/product_docs/docs/bart/2.6/bart_user/02_overview/01_block-level_incremental_backup/02_concept_overview.mdx new file mode 100644 index 00000000000..a771eb3b4a3 --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_user/02_overview/01_block-level_incremental_backup/02_concept_overview.mdx @@ -0,0 +1,33 @@ +--- +title: "Concept Overview" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/concept_overview.html" +--- + + + +Using incremental backups involves the following sequence of steps: + +1. Configure BART, and enable and initiate archiving of WAL files to the `archive_path` in the same manner as done for full backups. + + The default `archive_path` is the BART backup catalog (`//archived_wals`). Using the `` parameter in the server section of the BART configuration file, you can specify the location where WAL files will be archived. + + For more information about the `archive_path` parameter and configuring BART, see the EDB Backup and Recovery Installation and Upgrade Guide available at the [EDB website](/bart/2.6/bart_inst/). + +2. Take an initial full backup with the `BACKUP` subcommand. This full backup establishes the parent of the first incremental backup. + +3. Scan all WAL files produced by database servers on which incremental backups are to be taken. These WAL files are scanned once they have been archived to the `archive_path`. + + Each scanned WAL file results in a modified block map (MBM) file that records the location of modified blocks obtained from the corresponding WAL file. The BART WAL scanner program `bart-scanner` performs this process. + +4. Take incremental backups using the `BACKUP` subcommand with the `--parent` option to specify the backup identifier or name of a previous, full backup or an incremental backup. Any previous backup may be chosen as the parent as long as all backups belong to the same timeline. + +5. The incremental backup process identifies which WAL files may contain changes from when the parent backup was taken to the starting point of the incremental backup. The corresponding MBM files are used to locate and copy the modified blocks to the incremental backup directory along with other database cluster directories and files. Instead of backing up all, full relation files, only the modified blocks are copied and saved. In addition, the relevant MBM files are condensed into one consolidated block map (CBM) file that is stored with the incremental backup. + + Multiple block copier threads can be used to copy the modified blocks to the incremental backup directory. See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/2.6/bart_inst/) for information about setting the `thread_count` parameter in the BART configuration file. See [Backup](../../03_using_bart/03_basic_bart_subcommand_usage/03_backup/#backup) for information about using the `--thread-count` option with the `BACKUP` subcommand. + +6. Invoke the restore process for an incremental backup using the `RESTORE` subcommand in the same manner as restoring a full backup. The `-i` option specifies the backup identifier or name of the incremental backup to restore. The restore process begins by going back through the chain of past, parent incremental backups until the initial full backup starting the chain is identified. This full backup provides the initial set of directories and files to be restored to the location specified with the `-p` option. Each subsequent incremental backup in the chain is then restored. Restoration of an incremental backup uses its CBM file to restore the modified blocks from the incremental backup. + +The following sections provide some additional information on these procedures. diff --git a/product_docs/docs/bart/2.6/bart_user/02_overview/01_block-level_incremental_backup/03_wal_scanning_preparation_for_an_incremental_backup.mdx b/product_docs/docs/bart/2.6/bart_user/02_overview/01_block-level_incremental_backup/03_wal_scanning_preparation_for_an_incremental_backup.mdx new file mode 100644 index 00000000000..9fb0f929e0f --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_user/02_overview/01_block-level_incremental_backup/03_wal_scanning_preparation_for_an_incremental_backup.mdx @@ -0,0 +1,54 @@ +--- +title: "WAL Scanning – Preparation for an Incremental Backup" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/wal_scanning_preparation_for_an_incremental_backup.html" +--- + + + +The WAL scanner program (`bart-scanner`) scans the WAL files created from the time of the parent backup up to the start of the incremental backup to determine which blocks have modified since the parent backup, and records the information in a file called the *modified block map (MBM) file*. One MBM file is created for each WAL file. + +The MBM file is stored in the directory where archived_wals will be stored, as specified in the `archive_path` parameter in the `bart.cfg` file. If the `archive_path` is not specified, the default `archived_wals` directory is: + +`//` + +Where: + +`` is the BART backup catalog parent directory specified in the global section of the BART configuration file. + +`` is the lowercase conversion of the database server name specified in the server section of the BART configuration file. + +The following code snippet is the content of the archive path showing the MBM files created for the WAL files. (The user name and group name of the files have been removed from the example to list the WAL files and MBM files in a more comparable manner): + +```text +[root@localhost archived_wals]# pwd +/opt/backup/acctg/archived_wals +[root@localhost archived_wals]# ls -l +total 131104 +-rw------- 1 ... ... 16777216 Oct 12 09:38 000000010000000100000078 +-rw------- 1 ... ... 16777216 Oct 12 09:38 000000010000000100000079 +-rw------- 1 ... ... 16777216 Oct 12 09:38 00000001000000010000007A +-rw------- 1 ... ... 16777216 Oct 12 09:35 00000001000000010000007B +-rw------- 1 ... ... 16777216 Oct 12 09:38 00000001000000010000007C +-rw------- 1 ... ... 16777216 Oct 12 09:39 00000001000000010000007D +-rw------- 1 ... ... 16777216 Oct 12 09:42 00000001000000010000007E +-rw------- 1 ... ... 16777216 Oct 12 09:47 00000001000000010000007F +-rw-rw-r-- 1 ... ... 161 Oct 12 09:49 0000000100000001780000280000000179000000.mbm +-rw-rw-r-- 1 ... ... 684 Oct 12 09:49 000000010000000179000028000000017A000000.mbm +-rw-rw-r-- 1 ... ... 161 Oct 12 09:49 00000001000000017A000028000000017B000000.mbm +-rw-rw-r-- 1 ... ... 161 Oct 12 09:49 00000001000000017B000028000000017C000000.mbm +-rw-rw-r-- 1 ... ...1524 Oct 12 09:49 00000001000000017C000028000000017D000000.mbm +-rw-rw-r-- 1 ... ... 161 Oct 12 09:49 00000001000000017D000028000000017E000000.mbm +-rw-rw-r-- 1 ... ... 161 Oct 12 09:49 00000001000000017E000028000000017F000000.mbm +-rw-rw-r-- 1 ... ... 161 Oct 12 09:49 00000001000000017F0000280000000180000000.mbm +``` + +MBM files have the suffix, `.mbm`. + +In preparation for any incremental backup, the WAL files should be scanned as soon as they are copied to the `archive_path`. Thus, the WAL scanner should be running as soon as the WAL files from the database cluster are archived to the `archive_path`. If the `archive_path` contains WAL files that have not yet been scanned, starting the WAL scanner begins scanning these files. If WAL file fails to be scanned (resulting in a missing MBM file), you can use the WAL scanner to specify an individual WAL file. + +Under certain conditions such as when the Network File System (NFS) is used to copy WAL files to the `archive_path`, the WAL files may have been missed by the WAL scanner program for scanning and creation of MBM files. Use the `scan_interval` parameter in the BART configuration file to initiate force scanning of WAL files in the `archive_path` to ensure MBM files are generated. See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/2.6/bart_inst/) for more information about the `scan_interval` parameter. + +See [Running the BART WAL Scanner](../../03_using_bart/04_running_the_bart_wal_scanner/#running_the_bart_wal_scanner) for information about using the WAL scanner. diff --git a/product_docs/docs/bart/2.6/bart_user/02_overview/01_block-level_incremental_backup/04_performing_an_incremental_backup.mdx b/product_docs/docs/bart/2.6/bart_user/02_overview/01_block-level_incremental_backup/04_performing_an_incremental_backup.mdx new file mode 100644 index 00000000000..8198f0f6400 --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_user/02_overview/01_block-level_incremental_backup/04_performing_an_incremental_backup.mdx @@ -0,0 +1,78 @@ +--- +title: "Performing an Incremental Backup" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/performing_an_incremental_backup.html" +--- + + + +The WAL files produced at the time of the parent backup up to the start of the incremental backup contain information about which blocks were modified during that time interval. That information is consolidated into an MBM file for each WAL file by the WAL scanner. + +The MBM files for the relevant WAL files are read, and the information is used to copy the modified blocks from the database cluster to the `archived_wals` directory as specified in the `archive_path` parameter in the `bart.cfg` file. When compared to a full backup, the number and sizes of relation files can be significantly less for an incremental backup. + +For comparison, the following is an abbreviated list of the files copied to the archived `base` subdirectory of a full backup for one database: + +```text +[root@localhost 14845]# pwd +/opt/backup/acctg/1476301238969/base/base/14845 +[root@localhost 14845]# ls +112 13182_vm 14740 16467 16615 2608_vm 2655 2699 2995 ... +113 13184 14742 16471 174 2609 2656 2701 2995_vm ... +1247 13186 14745 16473 175 2609_fsm 2657 2702 2996 ... +1247_fsm 13187 14747 16474 2187 2609_vm 2658 2703 2998 ... +1247_vm 13187_fsm 14748 16476 2328 2610 2659 2704 2998_vm ... +1249 13187_vm 14749 16477 2328_fsm 2610_fsm 2660 2753 2999 ... +1249_fsm 13189 14752 16479 2328_vm 2610_vm 2661 2753_fsm 2999_vm ... +1249_vm 13191 14754 16488 2336 2611 2662 2753_vm 3079 ... +1255 13192 14755 16490 2336_vm 2611_vm 2663 2754 3079_fsm ... + . + . + . +13182_fsm 14739 16465 16603 2608_fsm 2654 2696 2893_vm 3501_vm ... +``` + +In contrast, the following is the content of the archived `base` subdirectory of the same database from a subsequent incremental backup: + +```text +[root@localhost 14845]# pwd +/opt/backup/acctg/1476301835391/base/base/14845 +[root@localhost 14845]# ls +1247 1249 1259 16384 17006 2608 2610 2658 2663 2678 ... +1247_fsm 1249_fsm 1259_fsm 16387 17009 2608_fsm 2610_fsm 2659 2673 2679 ... +1247_vm 1249_vm 1259_vm 16389 17011 2608_vm 2610_vm 2662 2674 2703 ... +``` + +The information from the MBM files are consolidated into one file called a *consolidated block map* (CBM) file. During the restore operation for the incremental backup, the CBM file is used to identify the modified blocks to be restored for that backup. In addition, the incremental backup also stores other required subdirectories and files from the database cluster as is done for full backups. + +Before taking an incremental backup, an initial full backup must be taken with the `BACKUP` subcommand. This full backup establishes the parent of the first incremental backup. + +The syntax for taking a full backup is: + +```text +bart BACKUP –s { | all } [ -F { p | t } ] + [ -z ] [ –c ] + [ --backup-name ] + [ --thread-count ] + [ { --with-pg_basebackup | --no-pg_basebackup } ] + [--checksum-algorithm ] +``` + +The syntax for taking an incremental backup is: + +```text +bart BACKUP –s { | all } [ -F p] + [ --parent { | } ] + [ --backup-name ] + [ --thread-count ] + [ --check ] + [--checksum-algorithm ] +``` + +You must specify the following before taking an incremental backup: + +- `-Fp` option for plain text format as incremental backup can only be taken in the plain text format. +- `--check` option to verify if the required MBM files are present in the `archived_wals` directory. The `--parent` option must be specified when the `--check` option is used. + +See [BACKUP](../../03_using_bart/03_basic_bart_subcommand_usage/03_backup/#backup) for more information about using the `BACKUP` subcommand. diff --git a/product_docs/docs/bart/2.6/bart_user/02_overview/01_block-level_incremental_backup/05_restoring_an_incremental_backup.mdx b/product_docs/docs/bart/2.6/bart_user/02_overview/01_block-level_incremental_backup/05_restoring_an_incremental_backup.mdx new file mode 100644 index 00000000000..edd998ec999 --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_user/02_overview/01_block-level_incremental_backup/05_restoring_an_incremental_backup.mdx @@ -0,0 +1,48 @@ +--- +title: "Restoring an Incremental Backup" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/restoring_an_incremental_backup.html" +--- + + + +Restoring an incremental backup may require additional steps depending upon the host on which the incremental backup is to be restored: + +- [Restoring an Incremental Backup on a BART Host](#restoring-an-incremental-backup-on-a-bart-host) - This section outlines restoring an incremental backup onto the same host where BART has been installed. +- [Restoring an Incremental Backup on a Remote Host](#restoring-an-incremental-backup-on-a-remote-host) - This section outlines restoring an incremental backup onto a remote host where BART has not been installed. + + + +## Restoring an Incremental Backup on a BART Host + +Specify a backup identifier or name, and include the `-i` option when invoking the `RESTORE` subcommand to restore an incremental backup. All `RESTORE` options may be used in the same manner as when restoring a full backup. See [RESTORE](../../03_using_bart/03_basic_bart_subcommand_usage/08_restore/#restore) command for more details. + +First, all files from the full backup from the beginning of the backup chain are restored. For each incremental backup, the CBM file is used to identify and restore blocks from the incremental backup. If there are new relations or databases identified in the CBM file, then relevant relation files are copied. If consolidated block map information is found indicating the drop of a relation or a database, then the relevant files are removed from the restore directory. Similarly, if there is any indication of a table truncation, then the related files are truncated. + +Also note that you can use the `-w` option of the `RESTORE` subcommand to specify a multiple number of parallel worker processes to stream the modified blocks to the restore host. + +!!! Note + If you set the [BART scanner](../../03_using_bart/04_running_the_bart_wal_scanner/#running_the_bart_wal_scanner) or [backup](../../03_using_bart/03_basic_bart_subcommand_usage/03_backup/#backup) with the `--checksum-algorithm=NONE` option, then you must specify the `--disable checksum` option while restoring an incremental backup. + + + +## Restoring an Incremental Backup on a Remote Host + +Ensure the `bart` program is available on the remote host when restoring an incremental backup on a remote host; the invocation of the `RESTORE` subcommand for an incremental backup results in the execution of the `bart` program on the remote host to restore the modified blocks to their proper location. + +To restore an incremental backup onto a remote host where BART has not been installed, perform the following steps: + +**Step 1:** Install `BART` on the remote host to which an incremental backup is to be restored. + +No editing is needed in the `bart.cfg` file installed on the remote host. + +**Step 2:** Determine the Linux operating system user account on the remote host to be used as the remote user. This user is specified by the `remote_host` parameter in the BART configuration file or by the `-r` option when using the `RESTORE` subcommand to restore the incremental backup. The remote user must be the owner of the directory where the incremental backup is to be restored on the remote host. By default, the user account is `enterprisedb` for Advanced Server or `postgres` for PostgreSQL. + +**Step 3:** Ensure a passwordless SSH/SCP connection is established from the BART user on the BART host to the remote user on the remote host. For information about creating a passwordless SSH/SCP connection, see the *EDB Backup and Recovery Installation and Upgrade Guide*, available at the [EDB website](/bart/2.6/bart_inst/). + +When restoring an incremental backup, specify the backup identifier or name of the incremental backup that will be restored. See the [RESTORE](../../03_using_bart/03_basic_bart_subcommand_usage/08_restore/#restore) documentation for more details. To view an example of restoring an incremental backup, see the *EDB Backup and Recovery Reference Guide* available at the [EDB website](/bart/2.6/bart_ref/). + +!!! Note + If you set the [BART scanner](../../03_using_bart/04_running_the_bart_wal_scanner/#running_the_bart_wal_scanner) or [backup](../../03_using_bart/03_basic_bart_subcommand_usage/03_backup/#backup) with the `--checksum-algorithm=NONE` option, then you must specify the `--disable checksum` option while restoring an incremental backup. diff --git a/product_docs/docs/bart/2.6/bart_user/02_overview/01_block-level_incremental_backup/index.mdx b/product_docs/docs/bart/2.6/bart_user/02_overview/01_block-level_incremental_backup/index.mdx new file mode 100644 index 00000000000..3e65e3b0056 --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_user/02_overview/01_block-level_incremental_backup/index.mdx @@ -0,0 +1,24 @@ +--- +title: "Block-Level Incremental Backup" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/block-level_incremental_backup.html" +--- + + + +This section describes the basic concepts of a block-level incremental backup (referred to as an incremental backup). An incremental backup is a unique functionality of BART. + +An incremental backup provides a number of advantages when compared to using a full backup: + +- The amount of time required to produce an incremental backup is generally less than a full backup, as modified relation blocks are saved instead of all full relation files of the database cluster. +- An incremental backup uses less disk space than a full backup. + +Generally, all BART features (such as retention policy management) apply to incremental backups and full backups. See [Managing Incremental Backups](../../03_using_bart/02_managing_backups_using_a_retention_policy/05_managing_incremental_backups/#managing_incremental_backups) for more information. + +
+ +incremental_backup_limitations_and_requirements concept_overview wal_scanning_preparation_for_an_incremental_backup performing_an_incremental_backup restoring_an_incremental_backup + +
diff --git a/product_docs/docs/bart/2.6/bart_user/02_overview/02_creating_a_backup_chain.mdx b/product_docs/docs/bart/2.6/bart_user/02_overview/02_creating_a_backup_chain.mdx new file mode 100644 index 00000000000..5e2f2f94b3f --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_user/02_overview/02_creating_a_backup_chain.mdx @@ -0,0 +1,22 @@ +--- +title: "Creating a Backup Chain" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/creating_a_backup_chain.html" +--- + + + +A *backup chain* is the set of backups consisting of a full backup and all of its successive incremental backups. Tracing back on the parent backups of all incremental backups in the chain eventually leads back to that single, full backup. + +It is possible to have a *multi-forked* backup chain, which is two or more successive lines of incremental backups, all of which begin with the same, full backup. Thus, within the chain there is a backup that serves as the parent of more than one incremental backup. + +Since restoration of an incremental backup is dependent upon first restoring the full backup, then all successive incremental backups up to, and including the incremental backup specified by the `RESTORE` subcommand, it is crucial to note the following: + +- Deletion or corruption of the full backup destroys the entire backup chain. It is not possible to restore any of the incremental backups that were part of that chain. +- Deletion or corruption of an incremental backup within the chain results in the inability to restore any incremental backup that was added to that successive line of backups following the deleted or corrupted backup. The full backup and incremental backups prior to the deleted or corrupted backup can still be restored. + +The actions of retention policy management are applied to the full backup and all of its successive incremental backups within the chain in an identical manner as if they were one backup. Thus, use of retention policy management does not result in the breakup of a backup chain. + +See the *EDB Backup and Recovery Reference Guide*, available at the [EDB website](/bart/2.6/bart_ref/) for examples of creating a backup chain and restoring an incremental backup. diff --git a/product_docs/docs/bart/2.6/bart_user/02_overview/index.mdx b/product_docs/docs/bart/2.6/bart_user/02_overview/index.mdx new file mode 100644 index 00000000000..ae510d0dac2 --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_user/02_overview/index.mdx @@ -0,0 +1,97 @@ +--- +title: "Overview" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/overview.html" +--- + + + +BART provides a simplified interface for the continuous archiving and point-in-time recovery method provided with Postgres database servers. This consists of the following processes: + +- Capturing a complete image of a database cluster as a full base backup or referred to simply as a *full backup*. +- Capturing a modified image of a database cluster called a *block-level incremental backup* or referred as *incremental backup*, which is similar to a full backup, but contains the modified blocks of the relation files that have been changed since a previous backup. +- Archiving the `Write-Ahead Log segments` (WAL files), which continuously record changes to be made to the database files. +- Performing *Point-In-Time Recovery* (PITR) to a specified transaction ID or timestamp with respect to a timeline using a full backup along with successive, [block-level incremental backups](01_block-level_incremental_backup/#block-level_incremental_backup) that reside in the same backup chain, and the WAL files. + +Detailed information regarding WAL files and point-in-time recovery is documented in the [PostgreSQL Core Documentation](https://www.postgresql.org/docs/current/static/continuous-archiving.html). + +The general term *backup* refers to both full backups and incremental backups. + +When taking a full backup of a standby server, BART uses the PostgreSQL `pg_basebackup` utility program. However, it must be noted that for standby servers, you can only take a full backup, but cannot take an incremental or parallel backups. For information about standby servers, see the [PostgreSQL Documentation](https://www.postgresql.org/docs/current/static/high-availability.html). + +BART uses a centralized backup catalog, a single configuration file, and a command line interface controlling the necessary operations to simplify the management process. Reasonable defaults are automatically used for various backup and restore options. BART also performs the necessary recovery file configuration required for point-in-time recovery using its command line interface. + +BART also provides the following features to enhance backup management: + +- Automation of the WAL archiving command configuration. +- Usage of retention policies to evaluate, categorize, and delete obsolete backups. +- Compression of WAL files to conserve disk space. +- Customizable naming of backups to ease their usage. +- Easy access to comprehensive information about each backup. + +The key components of a BART installation are: + +- **BART Host.** The host system on which BART is installed. BART operations are invoked from this host system. The database server backups and archived WAL files are stored on this host as well. +- **BART User Account.** Linux operating system user account you choose to run BART. The BART user account owns the BART backup catalog directory. +- **BART Configuration File.** File in editable text format containing the configuration information that BART uses. +- **BART Backup Catalog.** File system directory structure containing all of the backups for the database servers that BART manages. It is also the default `archive_path` to store archived WAL files. +- **BART Backupinfo File.** File in text format containing information for a BART backup. A `backupinfo` file resides in each backup subdirectory within the BART backup catalog. +- **BART Command Line Utility Program.** Single, executable file named `bart`, which is used to manage all BART operations. +- **BART WAL Scanner Program.** Single, executable file named `bart-scanner`, which is used to scan WAL files to locate and record the modified blocks for incremental backups. + +Other concepts and terms referred to in this document include the following: + +- **Postgres Database Cluster.** Also commonly called the *data directory*, this is the file system directory where all of the data files related to a particular Postgres database server instance are stored. (Each specific running instance is identified by its host and port number when connecting to a database.) The database cluster is identified by the `–D` option when it is created, started, stopped, etc. by the `Postgres initdb` and `pg_ctl` commands. A full backup is a copy of a database cluster. + + The terms database cluster and database server are used somewhat interchangeably throughout this document, though a single database server can run multiple database clusters. + +- **Postgres User Account.** Linux operating system user account that runs the Advanced Server or PostgreSQL database server and owns the database cluster directory. + + - By default, the database user account is `enterprisedb` when Advanced Server is installed to support compatibility with Oracle databases. + + - By default, the database user account is `postgres` when Advanced Server is installed in PostgreSQL compatible mode. For a PostgreSQL database server, the default database user account is also `postgres`. + + The BART configuration parameter `cluster_owner` must be set to the database user account for each database server. + +- **Replication Database User.** For each database server that BART manages, a database superuser must be selected to act as the replication database user. This database user is used to connect to the database server when backups are taken. The database superusers created with an initial Postgres database server installation (`enterprisedb` or `postgres`) may be used for this purpose. The BART configuration parameter `user` must be set to this replication database user for each database server. + +- **Secure Shell (SSH)/Secure Copy (SCP).** Linux utility programs used to log into hosts (SSH) and copy files (SCP) between hosts. A valid user account must be specified that exists on the target host and in fact is the user account under which the SSH or SCP operations occur. + +For information on how all of these components are configured and used with BART, see the EDB Backup and Recovery Installation and Upgrade Guide available at the [EDB website](/bart/2.6/bart_inst/). + +**Supported BART Operations** + +The following tables are not a conclusive list of the scenarios supported by BART, but instead provides an overview of some of the most common scenarios in both `pg_basebackup` (thread count=1) as well as parallel backup mode (thread count greater than 1). + +| | -Fp-xlog-method=fetch | -Fp-xlog-method=stream | -Ft-xlog-method=fetch | -Ft-xlog-method=stream | +| -------------------------------------------- | --------------------- | ---------------------- | --------------------- | ---------------------- | +| `Primary Database Server/Full backup` | Supported | Supported | Supported | Supported | +| `Primary Database Server/Incremental backup` | Supported | Supported | Not Supported | Not Supported | +| `Standby Database Server/Full backup` | Supported | Supported | Supported | Supported | +| `Standby Database Server/Incremental backup` | Not Supported | Not Supported | Not Supported | Not Supported | + +Backup + +| | Wal compression by BART | WAL scanner | +| -------------------------------------------- | ----------------------- | ----------- | +| `Primary Database Server/Full backup` | Supported | N/A | +| `Primary Database Server/Incremental backup` | Not Supported | N/A | +| `Standby Database Server/Full backup` | Supported | N/A | +| `Standby Database Server/Incremental backup` | Not Supported | N/A | + +Wal Archiving + +| | Wal compression = enabled | Wal compression = disabled | +| ------------------ | ------------------------- | -------------------------- | +| `Restore` | Supported | Supported | +| `Parallel restore` | Supported | Supported | + +Restore + +
+ +block-level_incremental_backup creating_a_backup_chain + +
diff --git a/product_docs/docs/bart/2.6/bart_user/03_using_bart/01_bart_management_overview/01_performing_a_restore_operation.mdx b/product_docs/docs/bart/2.6/bart_user/03_using_bart/01_bart_management_overview/01_performing_a_restore_operation.mdx new file mode 100644 index 00000000000..6197df8941b --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_user/03_using_bart/01_bart_management_overview/01_performing_a_restore_operation.mdx @@ -0,0 +1,60 @@ +--- +title: "Performing a Restore Operation" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/performing_a_restore_operation.html" +--- + + + +The following steps describe the process of restoring a backup: + +**Step 1:** Use your system-specific command to shut down the database server. + +**Step 2:** Inspect the `pg_wal` subdirectory (inspect the `pg_xlog` subdirectory if you are using server 9.6 version) of the data directory and save any WAL files that have not yet been archived to the `archive_path`. If there are files that have not been archived, save them to a temporary location. + +**Step 3:** If you want to restore to current data directory, it is recommended to make a copy of the current data directory and then delete all files and subdirectories under the data directory if you have enough extra space. If there is not enough space, then make a copy of `pg_wal` directory (or `pg_xlog` if you are using server 9.6 version) until the server is successfully restored. + +If you want to restore to a new, empty directory, create the directory on which you want to restore the backed up database cluster. Ensure the data directory can be written to by the BART user account or by the user account specified by the `remote_host` configuration parameter, or by the `--remote-host` option of the `RESTORE` subcommand (if these are to be used). + +**Step 4:** Perform the same process for tablespaces as described in Step 3. The `tablespace_path` parameter in the BART configuration file must contain the tablespace directory paths to which the tablespace data files are to be restored. See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/2.6/bart_inst/) for more information about this parameter. + +**Step 5:** Identify the backup to use for the restore operation and obtain the backup ID or backup name. + +To use the latest backup, omit the `-i` option; the `RESTORE` subcommand uses that backup by default. The backups can be listed with the `SHOW-BACKUPS` subcommand. + +**Step 6:** Run the BART `RESTORE` subcommand. + +- Minimal recovery settings will be saved in the `postgresql.auto.conf` file and archive recovery will proceed only until consistency is reached, with no restoration of files from the archive. See [Restore](../03_basic_bart_subcommand_usage/08_restore/#restore) for detailed information about `Restore` subcommand. + +- If the `-c` option is specified or if the `copy_wals_during_restore` BART configuration parameter is enabled for this database server, then the following actions occur: + + - In addition to restoring the database cluster to the directory specified by the `-p restore_path` option, the archived WAL files of the backup are copied from the BART backup catalog to the subdirectory `restore_path/archived_wals`. + - If recovery settings are saved in the `postgresql.auto.conf` file, the command string set in the `restore_command` parameter retrieves the WAL files from this `archived_wals` subdirectory relative to the `restore_path` parent directory as: `restore_command = cp archived_wals/%f %p` + +You must ensure that valid options are specified when using the `RESTORE` subcommand. BART will not generate an error message if invalid option values or invalid option combinations are provided. BART will accept the invalid options and pass them to the `postgresql.auto.conf` file, which will then be processed by the database server when it is restarted. + +**Step 7:** Copy any saved WAL files from Step 2 to the `restore_path/pg_xlog` subdirectory. + +**Step 8:** Inspect the restored directories and data files of the restored database cluster in directory `restore_path`. + +All files and directories must be owned by the user account that you intend to use to start the database server. Recursively change the user and group ownership of the `restore_path` directory, its files, and its subdirectories if necessary. There must only be directory access privileges for the user account that will start the database server. No other groups or users can have access to the directory. + +**Step 9:** The `postgresql.auto.conf` file should be configured to recover only until the cluster reaches consistency. In either case, the settings may be modified as desired. + +**Step 10:** Disable WAL archiving at this point. The BART `RESTORE` subcommand adds `archive_mode = off` to the end of the `postgresql.conf` file. + +- If you want to restart the database server with WAL archiving enabled, ensure that this additional parameter is deleted. +- The original `archive_mode` parameter still resides in the `postgresql.conf` file in its initial location with its last setting. + +**Step 11:** Start the database server to initiate recovery. After completion, check the database server log file to ensure the recovery was successful. + +If the backup is restored to a different location than where the original database cluster resided, operations dependent upon the database cluster location may fail if supporting service scripts are not updated to reflect the location where the backup has been restored. For information about the use and modification of service scripts, see the EDB Advanced Server Installation Guide. + +See [Restore](../03_basic_bart_subcommand_usage/08_restore/#restore) for more information about using the BART `Restore` subcommand. + +An example of a restore operation is documented in the EDB Backup and Recovery Reference Guide available at the [EDB website](/bart/2.6/bart_ref/). + +!!! Note + If you set the [backup](../03_basic_bart_subcommand_usage/03_backup/#backup) `--checksum-algorithm=NONE` option, then you must specify the `--disable checksum` option while restoring a backup. diff --git a/product_docs/docs/bart/2.6/bart_user/03_using_bart/01_bart_management_overview/02_point_in_time_recovery_operation.mdx b/product_docs/docs/bart/2.6/bart_user/03_using_bart/01_bart_management_overview/02_point_in_time_recovery_operation.mdx new file mode 100644 index 00000000000..09a45311364 --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_user/03_using_bart/01_bart_management_overview/02_point_in_time_recovery_operation.mdx @@ -0,0 +1,51 @@ +--- +title: "Point-In-Time Recovery Operation" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/point_in_time_recovery_operation.html" +--- + + + +The following steps outline how to perform a point-in-time recovery operation for a database cluster: + +1. Use your system-specific command to shut down the database server. + +2. If you want to: + a. restore the database cluster and tablespace files to new, empty directories, create the new directories with the appropriate directory ownership and permissions. + b. reuse the existing database cluster directories, delete all the files and subdirectories in the existing directories. We strongly recommend that you make a copy of this data before deleting it. Be sure to save any recent WAL files in the `pg_wal` subdirectory ( `pg_xlog` subdirectory if you are using server 9.6 version) that have not been archived to `archive_path`. + +3. Run the BART `SHOW-BACKUPS -s ` subcommand to list the backup IDs and backup names of the backups for the database server. You will need to provide the appropriate backup ID or backup name with the BART `RESTORE` subcommand, unless you intend to restore the latest backup in which case the `-i` option of the `RESTORE` subcommand for specifying the backup ID or backup name may be omitted. + +4. Run the BART `RESTORE` subcommand with the appropriate options. + + - The backup is restored to the directory specified by the `-p restore_path` option. + + - In addition, if the `RESTORE` subcommand `-c` option is specified or if the enabled setting of the `copy_wals_during_restore` BART configuration parameter is applicable to the database server, then the required archived WAL files from the `archive_path` are copied to the `restore_path/archived_wals` subdirectory. + + - Ensure the `restore_path` directory and all subdirectories and files in the `restore_path` are owned by the proper Postgres user account (for example, `enterprisedb` or `postgres`). Also ensure that only the Postgres user account has access permission to the `restore_path` directory. + + Use the `chown` command to make the appropriate adjustments to file permissions; for example, the following command changes the ownership of `restore_path` to `enterprisedb`: + + `chown -R enterprisedb:enterprisedb restore_path` + + The following command restricts access to `restore_path`: + + `chmod 700 restore_path` + +5. Copy any saved WAL files from Step 2 that were not archived to the BART backup catalog to the `restore_path/pg_wal` subdirectory (`pg_xlog` subdirectory if you are using server 9.6 version). + +6. Identify the timeline ID you wish to use to perform the restore operation. + + The available timeline IDs can be identified by the first non-zero digit of the WAL file names reading from left to right. + +7. Verify that the `postgresql.auto.conf` file created in the directory specified with the `RESTORE` subcommand’s `-p ` option was generated with the correct recovery parameter settings. + + If the `RESTORE` subcommand `-c` option is specified or if the enabled setting of the `copy_wals_during_restore` BART configuration parameter is applicable to the database server, then the `restore_command` parameter retrieves the archived WAL files from the `/archived_wals` subdirectory that was created by the `RESTORE` subcommand, otherwise the `restore_command` retrieves the archived WAL files from the BART backup catalog. + +8. The BART `RESTORE` subcommand disables WAL archiving in the restored database cluster. If you want to immediately enable WAL archiving, modify the `postgresql.conf` file by deleting the `archive_mode = off` parameter that BART appends to the end of the file. + +9. Start the database server, which will then perform the point-in-time recovery operation if recovery settings are saved in the `postgresql.auto.conf` file. + +For a detailed description of the `RESTORE` subcommand, see [Basic BART Subcommand Usage](../03_basic_bart_subcommand_usage/#basic_bart_subcommand_usage). An example of a Point-in-Time Recovery operation is documented in the *EDB Backup and Recovery Reference Guide* available at the [EDB website](/bart/2.6/bart_ref/). See [Restore](../03_basic_bart_subcommand_usage/08_restore/#restore) for more information about using the `Restore` subcommand. diff --git a/product_docs/docs/bart/2.6/bart_user/03_using_bart/01_bart_management_overview/index.mdx b/product_docs/docs/bart/2.6/bart_user/03_using_bart/01_bart_management_overview/index.mdx new file mode 100644 index 00000000000..4cb9c779397 --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_user/03_using_bart/01_bart_management_overview/index.mdx @@ -0,0 +1,34 @@ +--- +title: "BART Management Overview" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/bart_management_overview.html" +--- + + + +After configuring BART, you can begin the backup and recovery management process. The following steps will help you get started: + +1. Run the `CHECK-CONFIG` subcommand without the `-s` option. When the `CHECK-CONFIG` subcommand is used without specifying the `-s` option, it checks the parameters in the global section of the BART configuration file. +2. Run the `INIT` subcommand (if you have not already done so) to finish creation of the BART backup catalog, which results in the complete directory structure to which backups and WAL files are saved. This step must be done before restarting the database servers with enabled WAL archiving, otherwise the copy operation in the `archive_command` parameter of the `postgresql.conf` file or the `postgresql.auto.conf` file fails due to the absence of the target archive directory. When the directory structure is complete, the `archived_wals` subdirectory should exist for each database server. +3. Start the Postgres database servers with archiving enabled. Verify that the WAL files are appearing in the `archive_path`. The archiving frequency is dependent upon other `postgresql.conf` configuration parameters. Check the Postgres database server log files to ensure there are no archiving errors. Archiving should be operational before taking a backup in order to ensure that the WAL files that may be created during the backup process are archived. +4. Start the WAL scanner if you intend to take incremental backups. Since the WAL scanner processes the WAL files copied to the `archive path`, it is advantageous to commence the WAL scanning as soon as the WAL files begin to appear in the `archive_path` in order to keep the scanning in pace with the WAL archiving. +5. Run the BART `CHECK-CONFIG` subcommand for each database server with the `-s` option specifying the server name. This ensures the database server is properly configured for taking backups. +6. Create a full backup for each database server. The full backup establishes the starting point of when point-in-time recovery can begin and also establishes the initial parent backup for any incremental backups to be taken. + +There are now a number of other BART management processes you may perform: + +- Execute the `BACKUP` subcommand to create additional full backups or incremental backups. +- Use the `VERIFY-CHKSUM` subcommand to verify the checksum of the full backups. +- Display database server information with the `SHOW-SERVERS` subcommand. +- Display backup information with the `SHOW-BACKUPS` subcommand. +- Compress the archived WAL files in the `archive_path` by enabling WAL compression in the BART configuration file and then invoking the `MANAGE` subcommand. +- Determine and set the retention policy for backups in the BART configuration file. +- Establish the procedure for using the `MANAGE` subcommand to enforce the retention policy for backups. This may include using `cron` jobs to schedule the `MANAGE` subcommand. + +
+ +performing_a_restore_operation point_in_time_recovery_operation + +
diff --git a/product_docs/docs/bart/2.6/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/01_overview_managing_backups_using_a_retention_policy.mdx b/product_docs/docs/bart/2.6/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/01_overview_managing_backups_using_a_retention_policy.mdx new file mode 100644 index 00000000000..7169d6f7bb6 --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/01_overview_managing_backups_using_a_retention_policy.mdx @@ -0,0 +1,23 @@ +--- +title: "Overview - Managing Backups Using a Retention Policy" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/overview_managing_backups_using_a_retention_policy.html" +--- + + + +The BART retention policy results in the categorization of each backup in one of three statuses – *active*, *obsolete*, and *keep*. + +- **Active.** The backup satisfies the retention policy applicable to its server. Such backups would be considered necessary to ensure the recovery safety for the server and thus should be retained. +- **Obsolete.** The backup does not satisfy the retention policy applicable to its server. The backup is no longer considered necessary for the recovery safety of the server and thus can be deleted. +- **Keep.** The backup is to be retained regardless of the retention policy applicable to its server. The backup is considered vital to the recovery safety for the server and thus should not be deleted for an indefinite period of time. + +There are two types of retention policies - redundancy retention policy and recovery window retention policy. + +- **Redundancy Retention Policy** - The [redundancy retention policy](03_setting_the_retention_policy/#redundancy-retention-policy) relies on a specified, maximum number of most recent backups to retain for a given server. When the number of backups exceeds that maximum number, the oldest backups are considered obsolete (except for backups marked as keep). +- **Recovery Window Retention Policy** - The [recovery window retention policy](03_setting_the_retention_policy/#recovery-window-retention-policy) relies on a time frame (the recovery window) for when a backup should be considered active. The boundaries defining the recovery window are the current date/time (the ending boundary of the recovery window) and the date/time going back in the past for a specified length of time (the starting boundary of the recovery window). + - If the date/time the backup was taken is within the recovery window (that is, the backup date/time is on or after the starting date/time of the recovery window), then the backup is considered active, otherwise it is considered obsolete (except for backups marked as keep). + - Thus, for the recovery window retention policy, the recovery window time frame dynamically shifts, so the end of the recovery window is always the current date/time when the `MANAGE` subcommand is run. As you run the `MANAGE` subcommand at future points in time, the starting boundary of the recovery window moves forward in time. At some future point, the date/time of when a backup was taken will be earlier than the starting boundary of the recovery window. This is when an active backup’s status will be considered obsolete. + - You can see the starting boundary of the recovery window at any point in time by running the `SHOW-SERVERS` subcommand. The `RETENTION POLICY` field of the `SHOW-SERVERS` subcommand displays the starting boundary of the recovery window. diff --git a/product_docs/docs/bart/2.6/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/02_marking_the_backup_status.mdx b/product_docs/docs/bart/2.6/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/02_marking_the_backup_status.mdx new file mode 100644 index 00000000000..047552d0a9e --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/02_marking_the_backup_status.mdx @@ -0,0 +1,25 @@ +--- +title: "Marking the Backup Status" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/marking_the_backup_status.html" +--- + + + +When a backup is initially created with the `BACKUP` subcommand, it is always recorded with active status. Use the `MANAGE` subcommand to evaluate if the backup status should be changed to obsolete in accordance with the retention policy. You can review the current status of your backups with the `SHOW-BACKUPS` subcommand. + +Active backups are evaluated and also marked (that is, internally recorded by BART) as obsolete only when the `MANAGE` subcommand is invoked either with no options or with only the `-s` option. + +Once a backup has been marked as obsolete, you cannot change it back to active unless you perform the following steps: + +- Use the `MANAGE` subcommand with the `-c` option along with the backup identifier or name with the `-i` option. To keep this particular backup indefinitely, use `-c keep`, otherwise use `-c nokeep`. +- If you use the `-c nokeep` option, the backup status is changed back to active. When the `MANAGE` subcommand is used the next time, the backup is re-evaluated to determine if its status needs to be changed back to obsolete based on the current retention policy in the BART configuration file. + +After setting the `retention_policy` parameter and running the `MANAGE` subcommand if you change the `retention_policy` parameter, the current, marked status of the backups are probably inconsistent with the new `retention_policy` setting. To modify the backup status to be consistent with the new `retention_policy` setting, you need to run the `MANAGE` subcommand with: + +- the `-c nokeep` option to change the obsolete status to active status if there are backups currently marked as obsolete that would no longer be considered obsolete under a new retention policy. You can also specify the `-i all` option to change all backups back to active status, including those currently marked as keep. +- no options or with only the `-s` option to reset the marked status based on the new `retention_policy` setting in the BART configuration file. + +See [MANAGE](../03_basic_bart_subcommand_usage/07_manage/#manage) for usage information for the `MANAGE` subcommand. diff --git a/product_docs/docs/bart/2.6/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/03_setting_the_retention_policy.mdx b/product_docs/docs/bart/2.6/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/03_setting_the_retention_policy.mdx new file mode 100644 index 00000000000..d4fd91675c9 --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/03_setting_the_retention_policy.mdx @@ -0,0 +1,82 @@ +--- +title: "Setting the Retention Policy" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/setting_the_retention_policy.html" +--- + + + +The retention policy is determined by the `retention_policy` parameter in the BART configuration file. It can be applied globally to all servers, but each server can override the global retention policy with its own. For information about creating a global retention policy and an individual database server retention policy, see the EDB Backup and Recovery Installation and Upgrade Guide available at the [EDB website](/bart/2.6/bart_inst/). + +There are two types of retention policies - redundancy retention policy and the recovery window retention policy as described in the following sections. + + + +## Redundancy Retention Policy + +To use the redundancy retention policy, set `retention_policy = max_number BACKUPS` where `max_number` is a positive integer designating the maximum number of most recent backups. + +**Additional Restrictions:** + +- The keyword `BACKUPS` must always be specified in plural form (for example, `1 BACKUPS`). +- BART will accept a maximum integer value of 2,147,483,647 for `max_number`; however, you should use a realistic, practical value based on your system environment. + +The redundancy retention policy is the default type of retention policy if all keywords `BACKUPS`, `DAYS`, `WEEKS`, and `MONTHS` following the `max_number` integer are omitted as shown by the following example: + +`retention_policy = 3` + +In the following example, the redundancy retention policy setting considers the three most recent backups as the active backups. Any older backups, except those marked as `keep`, are considered obsolete: + +```text +[ACCTG] +host = 127.0.0.1 +port = 5444 +user = enterprisedb +archive_command = 'cp %p %a/%f' +retention_policy = 3 BACKUPS +description = "Accounting" +``` + +The `SHOW-SERVERS` subcommand displays the `3 Backups` redundancy retention policy in the `RETENTION POLICY` field: + +```bash +-bash-4.1$ bart SHOW-SERVERS -s acctg +SERVER NAME : acctg +HOST NAME : 127.0.0.1 +USER NAME : enterprisedb +PORT : 5444 +REMOTE HOST : +RETENTION POLICY : 3 Backups +DISK UTILIZATION : 627.04 MB +NUMBER OF ARCHIVES : 25 +ARCHIVE PATH : /opt/backup/acctg/archived_wals +ARCHIVE COMMAND : cp %p /opt/backup/acctg/archived_wals/%f +XLOG METHOD : fetch +WAL COMPRESSION : disabled +TABLESPACE PATH(s) : +DESCRIPTION : "Accounting" +``` + + + +## Recovery Window Retention Policy + +To use the recovery window retention policy, set the `retention_policy` parameter to the desired length of time for the recovery window in one of the following ways: + +- Set to `max_number DAYS` to define the start date/time recovery window boundary as the number of days specified by `max_number` going back in time from the current date/time. +- Set to `max_number WEEKS` to define the start date/time recovery window boundary as the number of weeks specified by `max_number` going back in time from the current date/time. +- Set to `max_number MONTHS` to define the start date/time recovery window boundary as the number of months specified by `max_number` going back in time from the current date/time. + +**Additional Restrictions:** + +- The keywords `DAYS`, `WEEKS`, and `MONTHS` must always be specified in plural form (for example, `1 DAYS`, `1 WEEKS`, or `1 MONTHS`). +- BART will accept a maximum integer value of `2,147,483,647` for `max_number`, however, a realistic, practical value based on your system environment must always be used. + +A backup is considered active if the date/time of the backup is equal to or greater than the start of the recovery window date/time. + +You can view the actual, calculated recovery window by: + +- Invoking the `MANAGE` subcommand in debug mode, along with the `-n` option. +- Using the `SHOW-SERVERS` subcommand. diff --git a/product_docs/docs/bart/2.6/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/04_managing_the_backups_based_on_the_retention_policy.mdx b/product_docs/docs/bart/2.6/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/04_managing_the_backups_based_on_the_retention_policy.mdx new file mode 100644 index 00000000000..f0750c1565e --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/04_managing_the_backups_based_on_the_retention_policy.mdx @@ -0,0 +1,147 @@ +--- +title: "Managing the Backups Based on the Retention Policy" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/managing_the_backups_based_on_the_retention_policy.html" +--- + + + +The [MANAGE](../03_basic_bart_subcommand_usage/07_manage/#manage) subcommand is used to evaluate and categorize backups according to the retention policy set in the BART configuration file. When a backup is first created with the `BACKUP` subcommand, it is `active`. You can use the `MANAGE` subcommand to change the status of an active backup to `obsolete`. Obsolete backups can then be deleted. + +This section covers following aspects of backup management: + +- The rules for [deleting backups](#deletions_permitted_under_retention_policy) depending upon the backup status and the subcommand used. +- The process to retain a backup indefinitely by [marking it as keep](#marking-backups-for-indefinite-keep-status). This section also provides information about resetting backups status (that are marked as `obsolete` and `keep`) back to active status. +- The general process for [evaluating, marking, and then deleting obsolete backups](#evaluating-marking-and-deleting-obsolete-backups). + + + +## Deletions Permitted Under a Retention Policy + +This section describes how and under what conditions backups may be deleted under a retention policy. + +You must use the `MANAGE` subcommand to delete obsolete backups. Use the `DELETE` subcommand only for special administrative purposes. + +The deletion behavior of the `MANAGE` subcommand and the `DELETE` subcommand are based on different aspects of the retention policy. + +- The `MANAGE` subcommand deletion relies solely upon how a backup status is currently marked (that is, internally recorded by BART). The current setting of the `retention_policy` parameter in the BART configuration file is ignored. +- The `DELETE` subcommand relies solely upon the current setting of the `retention_policy` parameter in the BART configuration file. The current active, obsolete, or keep status of a backup is ignored. + +The specific deletion rules for the `MANAGE` and `DELETE` subcommands are as follows: + +- `MANAGE` subcommand: The `MANAGE` subcommand with the `-d` option can only delete backups marked as obsolete. This deletion occurs regardless of the current `retention_policy` setting in the BART configuration file. The deletion of backups relies on the last occasion when the backups have been marked. +- `DELETE` subcommand: + + - Under a redundancy retention policy currently set with the `retention_policy` parameter in the BART configuration file, any backup regardless of its marked status, can be deleted with the `DELETE` subcommand when the backup identifier or name is specified with the `-i` option and if the current total number of backups for the specified database server is greater than the maximum number of redundancy backups currently specified with the `retention_policy` parameter. + + If the total number of backups is less than or equal to the specified, maximum number of redundancy backups, then no additional backups can be deleted using `DELETE` with the `-i backup` option. + + - Under a recovery window retention policy currently set with the `retention_policy` parameter in the BART configuration file, any backup regardless of its marked status, can be deleted with the `DELETE` subcommand when the backup identifier or name is specified with the `-i` option, and if the backup date/time is not within the recovery window currently specified with the `retention_policy` parameter. If the backup date/time is within the recovery window, then it cannot be deleted using `DELETE` with the `-i backup` option. + + - Invoking the `DELETE` subcommand with the `-i all` option results in the deletion of all backups regardless of the retention policy and regardless of whether the status is marked as active, obsolete, or keep. + +The following table summarizes the deletion rules of backups according to their marked status. An entry of `Yes` indicates the backup may be deleted under the specified circumstances. An entry of `No` indicates that the backup may not be deleted. + + ++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
OperationRedundancy Retention PolicyRecovery Window Retention Policy
ActiveObsoleteKeepActiveObsoleteKeep
MANAGE –dNoYesNoNoYesNo
DELETE –i *backup* +

Yes

+

(see Note 1)

+
+

Yes

+

(see Note 1)

+
+

Yes

+

(see Note 1_)

+
+

Yes

+

(see Note 2

+
+

Yes

(see Note 2 +
+

Yes

(see Note 2) +
DELETE –i allYesYesYesYesYesYes
+ + + +!!! Note + Redundancy Retention Policy (Note 1) : Deletion occurs only if the total number of backups for the specified database server is greater than the specified, maximum number of redundancy backups currently set with the `redundancy_policy` parameter in the BART configuration file. + + + +!!! Note + Recovery Window Retention Policy (Note 2): Deletion occurs only if the backup is not within the recovery window currently set with the `redundancy_policy` parameter in the BART configuration file. + + + +## Marking Backups for Indefinite Keep Status + +There may be certain backups that you wish to keep for an indefinite period of time and do not wish to delete based upon the retention policy applied to the database server. Such backups can be marked as `keep` to exclude them from being marked as obsolete. Use the `MANAGE` subcommand with the `-c keep` option to retain such backups indefinitely. + + + +## Evaluating, Marking, and Deleting Obsolete Backups + +When the `MANAGE` subcommand is invoked, BART evaluates active backups: + +- If you include the `-s` option when invoking the `MANAGE` subcommand, BART evaluates backups for the database server. +- If you include the `-s all` option when invoking the `MANAGE` subcommand, BART evaluates backups for all database servers. +- If the `-s` option is omitted, the command evaluates the current number of backups for the database server based on the redundancy retention policy or the current date/time for a recovery window retention policy. + +!!! Note + The status of backups currently marked as `obsolete` or `keep` is not changed. To re-evaluate such backups and then classify them, their status must first be reset to `active` with the `MANAGE -c nokeep` option. See [Marking the Backup Status](02_marking_the_backup_status/#marking_the_backup_status) for more information. + +See the *EDB Backup and Recovery Reference Guide* available at the [EDB website](/bart/2.6/bart_ref/) to review examples of how to evaluate, mark, and delete backups using a redundancy retention policy and recovery window retention policy, as well as examples of `MANAGE` subcommand. diff --git a/product_docs/docs/bart/2.6/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/05_managing_incremental_backups.mdx b/product_docs/docs/bart/2.6/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/05_managing_incremental_backups.mdx new file mode 100644 index 00000000000..3cf29e34f3a --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/05_managing_incremental_backups.mdx @@ -0,0 +1,51 @@ +--- +title: "Managing Incremental Backups" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/managing_incremental_backups.html" +--- + + + +The following section summarizes how retention policy management affects incremental backups. + +- The retention policy rules are applied to full backups. + - A redundancy retention policy uses the number of full backups to determine if a backup is obsolete. Incremental backups are excluded from the comparison count against the `retention_policy` setting for the maximum number of backups. + - A recovery window retention policy uses the backup date/time of any full backups to determine if a backup is obsolete. The backup date/time of any successive incremental backups in the chain are ignored when comparing with the recovery window. +- The retention status of all incremental backups in a chain is set to the same status applied to the full backup of the chain. +- The actions applied by the `MANAGE` and `DELETE` subcommands on a full backup are applied to all incremental backups in the chain in the same manner. +- Thus, a backup chain (that is, the full backup and all its successive incremental backups) are treated by retention policy management as if they are all one, single backup. + - The status setting applied to the full backup is also applied to all incremental backups in its chain. + - If a full backup is marked as obsolete and then deleted according to the retention policy, all incremental backups in the chain are also marked obsolete and then deleted as well. + +The following are some specific points regarding the `MANAGE` and `DELETE` subcommands on incremental backups. + +- `MANAGE` subcommand: + - When the `MANAGE` subcommand is invoked, the status applied to the full backup is also applied to all successive incremental backups in the chain. + - The `MANAGE` subcommand with the `-c { keep | nokeep}` option cannot specify the backup identifier or backup name of an incremental backup with `-i` backup option. The `-i` backup option can only specify the backup identifier or backup name of a full backup. + - You can also use the `-i` all option to take a backup of all backups. When the `MANAGE` subcommand with the `-c { keep | nokeep }` option is applied to a full backup, the same status change is made to all incremental backups in the chain. +- `DELETE` subcommand: + - The `DELETE` subcommand with the `-s server -i` backup option specifies the backup identifier or backup name of an incremental backup in which case that incremental backup along with all its successive incremental backups are deleted, thus shortening that backup chain. + +## Using a Redundancy Retention Policy with Incremental Backups + +When a [redundancy retention policy](03_setting_the_retention_policy/#redundancy-retention-policy) is used and the `MANAGE` subcommand is invoked, the status of the oldest `active` full backup is changed to `obsolete` if the number of full backups exceeds the maximum number specified by the `retention_policy` parameter in the BART configuration file. + +!!! Note + When a full backup is changed from `active` to `obsolete`, all successive incremental backups in the chain of the full backup are also changed from `active` to `obsolete`. + +When determining the number of backups that exceeds the number specified by the `retention_policy` parameter, only full backups are counted for the comparison. Incremental backups are not included in the count for the comparison against the `retention_policy` parameter setting. + +See the *EDB Backup and Recovery Reference Guide* available at the [EDB website](/bart/2.6/bart_ref/) for examples demonstrating use of the `MANAGE` and `DELETE` subcommands when a redundancy retention policy is in effect. + +## Using a Recovery Window Retention Policy with Incremental Backups + +If the `MANAGE` command is invoked when BART is configured to use a [recovery window retention policy](03_setting_the_retention_policy/#recovery-window-retention-policy), the status of `active` full backups are changed to `obsolete` if the date/time of the full backup is outside of the recovery window. + +!!! Note + If a full backup is changed from `active` to `obsolete`, all successive incremental backups in the chain of the full backup are also changed from `active` to `obsolete`. + +The status of an incremental backup is changed to `obsolete` regardless of whether or not the date/time of when the incremental backup was taken still lies within the recovery window. + +See the *EDB Backup and Recovery Reference Guide* available at the [EDB website](/bart/2.6/bart_ref/) for examples demonstrating use of the `MANAGE` and `DELETE` subcommands when a recovery window retention policy is in effect. diff --git a/product_docs/docs/bart/2.6/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/index.mdx b/product_docs/docs/bart/2.6/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/index.mdx new file mode 100644 index 00000000000..aff92bbd6a5 --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_user/03_using_bart/02_managing_backups_using_a_retention_policy/index.mdx @@ -0,0 +1,27 @@ +--- +title: "Managing Backups Using a Retention Policy" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/managing_backups_using_a_retention_policy.html" +--- + + + +Over the course of time when using BART, the number of backups can grow significantly. This ultimately leads to a large consumption of disk space unless an administrator periodically performs the process of deleting the oldest backups that are no longer needed. This process of determining when a backup is old enough to be deleted and then actually deleting such backups can be done and automated with the following basic steps: + +1. Determine and set a retention policy in the BART configuration file. A *retention policy* is a rule that determines when a backup is considered obsolete. The retention policy can be applied globally to all servers, but each server can override the global retention policy with its own. + +2. Use the `MANAGE` subcommand to categorize and manage backups according to the retention policy. + +3. Create a cron job to periodically run the `MANAGE` subcommand to evaluate the backups and then list and/or delete the obsolete backups. + + Retention policy management applies differently to incremental backups than to full backups. See [Managing Incremental Backups](05_managing_incremental_backups/#managing_incremental_backups) for information about how retention policy management is applied to each backup type. + + The following sections describe how retention policy management generally applies to backups, and its specific usage and effect on full backups. + +
+ +overview_managing_backups_using_a_retention_policy marking_the_backup_status setting_the_retention_policy managing_the_backups_based_on_the_retention_policy managing_incremental_backups + +
diff --git a/product_docs/docs/bart/2.6/bart_user/03_using_bart/03_basic_bart_subcommand_usage/01_check_config.mdx b/product_docs/docs/bart/2.6/bart_user/03_using_bart/03_basic_bart_subcommand_usage/01_check_config.mdx new file mode 100644 index 00000000000..f12dd038edd --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_user/03_using_bart/03_basic_bart_subcommand_usage/01_check_config.mdx @@ -0,0 +1,35 @@ +--- +title: "CHECK-CONFIG" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/check_config.html" +--- + + + +The `CHECK-CONFIG` subcommand checks the parameter settings in the BART configuration file as well as the database server configuration for which the `-s` option is specified. + +**Syntax:** + +`bart CHECK-CONFIG [ –s server_name ]` + +The following table describes the option. + +| Options | Description | +| ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s ` or `--server ` | `server_name` is the name of the database server to be checked for proper configuration. If the option is omitted, the settings of the global section of the BART configuration file are checked. | + +- When the `-s` option is omitted, the global section \[BART] parameters including `bart_host`, `backup_path`, and `pg_basebackup_path` are checked. +- When the `-s` option is specified, the server section parameters are checked. In addition, certain database server `postgresql.conf` parameters are also checked, which include the following: + - The `cluster_owner` parameter must be set to the user account owning the database cluster directory. + - A passwordless SSH/SCP connection must be set between the BART user and the user account specified by the `cluster_owner` parameter. + - A database superuser must be specified by the BART `user` parameter. + - The `pg_hba.conf` file must contain a replication entry for the database superuser specified by the BART `user` parameter. + - The `archive_mode` parameter in the `postgresql.conf` file must be enabled. + - The `archive_command` parameter in the `postgresql.auto.conf` or the `postgresql.conf` file must be set. + - The `allow_incremental_backups` parameter in the BART configuration file must be enabled for database servers for which incremental backups are to be taken. + - Archiving of WAL files to the `archive_path` must be in process. + - The WAL scanner program must be running. + +The `CHECK-CONFIG` subcommand displays an error message if the required configuration is not properly set. diff --git a/product_docs/docs/bart/2.6/bart_user/03_using_bart/03_basic_bart_subcommand_usage/02_init.mdx b/product_docs/docs/bart/2.6/bart_user/03_using_bart/03_basic_bart_subcommand_usage/02_init.mdx new file mode 100644 index 00000000000..d8cdeed8126 --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_user/03_using_bart/03_basic_bart_subcommand_usage/02_init.mdx @@ -0,0 +1,41 @@ +--- +title: "INIT" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/init.html" +--- + + + +The `INIT` subcommand is used to create the BART backup catalog directory, rebuild the BART `backupinfo` file, and set the `archive_command` in the PostgreSQL server based on the `archive_command` setting in the `bart.cfg` file. + +!!! Note + If the `archive_mode` configuration parameter is set to `off`, then the `-o` option must be used to set the Postgres `archive_command` using the BART `archive_command` parameter in the BART configuration file even if the `archive_command` is not currently set in `postgresql.conf` nor in `postgresql.auto.conf` file. + +**Syntax:** + +```text +bart INIT [ –s { | all } ] [ -o ] + [ -r [ -i { | | all } ] ] + [--no-configure] +``` + +All subcommand options are generally specified in lowercase. The following table describes the command options: + +| Options | Description | +| ------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { \| all }`

`--server { \| all }` | `server_name` is the name of the database server to which the `INIT` actions are to be applied. If `all` is specified or if the option is omitted, the actions are applied to all servers. | +| `-o`

`--override` | Overrides the existing, active Postgres `archive_command` configuration parameter setting in the `postgresql.conf` file or the `postgresql.auto.conf` file using the BART `archive_command` parameter in the BART configuration file. The `INIT` generated archive command string is written to the `postgresql.auto.conf` file. | +| `-r`

`--rebuild` | Rebuilds the backupinfo file (a text file named `backupinfo`) located in each backup subdirectory. This option is only intended for recovering from a situation where the backupinfo file has become corrupt.
If the backup was initially created with a user-defined backup name, and then the `INIT -r` option is invoked to rebuild that `backupinfo` file, the user-defined backup name is no longer available. Thus, future references to the backup must use the backup identifier. | +| `-i { \| \| all }`

`--backupid { \| \| all }` | `` is an integer, backup identifier and `` is the user-defined alphanumeric name for the backup. If `all` is specified or if the option is omitted, the backupinfo files of all backups for the database servers specified by the `-s` option are recreated. The `-i` option can only be used with the `-r` option. | +| `--no-configure` | Prevents the `archive_command` from being set in the PostgreSQL server. | + +**Archive Command Setting** + +After the `archive_command` is set, you need to either restart the PostgreSQL server or reload the configuration file in the PostgreSQL server based on the following conditions. + +- If the `archive_mode` is set to `off` and `archive_command` is not set in the PostgreSQL server, the `archive_command` is set based on the `archive_command` setting in the `bart.cfg` and also sets the `archive_mode` to `on`. In this case, you need to restart the PostgreSQL server using `pg_ctl restart` +- If the `archive_mode` is set to `on` and `archive_command` is not set in the PostgreSQL server, the `archive_command` is set based on the `archive_command` setting in the `bart.cfg`. In this case, you need to reload the configuration in the PostgreSQL server using `pg_reload_conf()` or `pg_ctl reload`. +- If the `archive_mode` is set to `off` and `archive_command` is already set in the PostgreSQL server, the `archive_mode` is set to on. In this case, you need to restart the PostgreSQL server using `pg_ctl restart` +- If the `archive_mode` is set to `on` and `archive_command` is already set in the PostgreSQL server, then the `archive_command` is not set unless `-o` option is specified. diff --git a/product_docs/docs/bart/2.6/bart_user/03_using_bart/03_basic_bart_subcommand_usage/03_backup.mdx b/product_docs/docs/bart/2.6/bart_user/03_using_bart/03_basic_bart_subcommand_usage/03_backup.mdx new file mode 100644 index 00000000000..fb59ed1f30e --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_user/03_using_bart/03_basic_bart_subcommand_usage/03_backup.mdx @@ -0,0 +1,106 @@ +--- +title: "BACKUP" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/backup.html" +--- + + + +The `BACKUP` subcommand is used to create a full backup or an incremental backup. + +**Syntax for full backup:** + +```text +bart BACKUP –s { | all } [ -F { p | t } ] + [ -z ] [ –c ] + [ --backup-name ] + [ --thread-count ] + [ { --with-pg_basebackup | --no-pg_basebackup } ] +``` + +!!! Note + While taking a backup, if a file (for example, database server log file) exceeding 1 GB size is stored in the `$PGDATA` directory, the backup will fail. To avoid such backup failure, you need to store large files (exceeding 1 GB) outside the `$PGDATA` directory. + +**Syntax for incremental Backup:** + +```text +bart BACKUP –s { | all } [ -F p] + [ --parent { | } ] + [ --backup-name ] + [ --thread-count ] + [ --check ] + [--checksum-algorithm ] +``` + +!!! Note + To take an [incremental backup](../../02_overview/01_block-level_incremental_backup/#block-level_incremental_backup), you must take a full backup first followed by incremental backup. + +**Please Note:** + +- While a `BACKUP` subcommand is in progress, no other subcommands must be invoked. Any subcommands invoked while a backup is in progress will skip and ignore the backups. + +- For full backup, the target default format is a tar file, whereas for incremental backup, only plain format must be specified. + +- The backup is saved in the `//` directory, where `` is the value assigned to the `` parameter in the BART configuration file, `` is the lowercase name of the database server as listed in the configuration file, and `` is a backup identifier assigned by BART to the particular backup. + +- MD5 checksums of the full backup and any user-defined tablespaces are saved as well for tar backups. + +- Before performing the backup, BART checks to ensure if there is enough disk space to completely store the backup in the BART backup catalog. + +- In the `postgresql.conf` file, ensure the `wal_keep_segments` configuration parameter is set to a sufficiently large value. A low setting of the `wal_keep_segments` configuration parameter may result in the deletion of some WAL files before the BART `BACKUP` subcommand saves them to the `archive_path`. For information about the `wal_keep_segments` parameter, see the [PostgreSQL Core Documentation](https://www.postgresql.org/docs/current/static/runtime-config-replication.html). + +- In the BART configuration file, setting `xlog_method=stream` will instruct the server to stream the transaction log in parallel with creation of the backup for a specific database server; otherwise the transaction log files are collected upon completion of the backup. See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/2.6/bart_inst/) for details about database server setting. + + !!! Note + If the transaction log streaming method is used, the `-Fp` option for a plain text backup format must be specified with the `BACKUP` subcommand. + +- When you use BART to take a backup of PostgreSQL server, multiple backups can be taken simultaneously and if a backup is interrupted, the backup mode is terminated automatically without the need to run `pg_stop_backup()` command manually to terminate the backup. + +**Options** + +Along with the `BACKUP` subcommand, specify the following option: + +| Options | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { server_name \| all }`
`--server { server_name \| all }` | `server_name` is the database server name to be backed up as specified in the BART configuration file. If `all` is specified, all servers are backed up. This option is mandatory.
If `all` is specified, and a connection to a database server listed in the BART configuration file cannot be opened, the backup for that database server is skipped, but the backup operation continues for the other database servers. | + +Specify the following options as required. If you do not specify any of the following options, the backup is created using default settings. + +| Options | Description | +| -------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-F { p \| t }`
`--format { p \| t }` | Specify this option to provide the backup file format. Use `p` for plain text or `t` for tar. If the option is omitted, the default is tar format.
For taking incremental backups, the option `-Fp` must be specified. | +| `-z`
`--gzip` | This is applicable only for full backup. Specify this option to use gzip compression on the tar file output using the default compression level. This option is applicable only for the tar format. | +| `-c `
`--compress-level ` | This is applicable only for full backup. Specify this option to use the gzip compression level on the tar file output. `compression_level` is a digit from 1 through 9, with 9 being the best compression. This option is applicable only for the tar format. | +| `--parent { backup_id \| backup_name }` | Specify this option to take an incremental backup. `` is the backup identifier of a parent backup. `` is the user-defined alphanumeric name of a parent backup.
The parent is a backup taken prior to the incremental backup. The parent backup can be either a full backup or an incremental backup.
The option `–Fp` must be specified since an incremental backup can only be taken in plain text format.
An incremental backup cannot be taken on a standby database server. See [Block-Level Incremental Backup](../../02_overview/01_block-level_incremental_backup/#block-level_incremental_backup) for additional information on incremental backups. | +| `--backup-name ` | Specify this option to assign a user-defined, alphanumeric friendly name to the backup. The maximum permitted length of backup name is 49 characters.
The backup name may include the following variables to be substituted by the timestamp values when the backup is taken: 1) `%year` – 4-digit year, 2) `%month` – 2-digit month, 3) `%day` – 2-digit day, 4) `%hour` 2-digit hour, 5) `%minute` – 2-digit minute, and 6) `%second` – 2-digit second.
To include the percent sign (`%`) as a character in the backup name, specify `%%` in the alphanumeric string.
If the backup name contains space characters (i.e. more than one word) or when referenced with the option `-i` by other subcommands (such as `restore`), enclose the string in single quotes or double quotes. See [backup name examples](#backup_name_examples).
If the `--backup-name` option is not specified, and the `backup_name` parameter is not set for this database server in the BART configuration file, then the backup can only be referenced in other BART subcommands by the BART assigned backup identifier. | +| `--thread-count ` | Use this option to use the number of worker threads to run in parallel to copy blocks for a backup.
If the option `--thread-count` is omitted, then the `thread_count` parameter in the BART configuration file applicable to this database server is used.
If the option `--thread-count` is not enabled for this database server, then the `thread_count` setting in the global section of the BART configuration file is used.
If the option `--thread-count` is not set in the global section as well, the default number of threads is 1.
If parallel backup is run with N number of worker threads, then it will initiate N+ 1 concurrent connections with the server.
Thread count will not be effective if backup is taken on a standby server.
For more information about the `--thread-count` parameter, see the EDB Backup and Recovery Installation and Upgrade Guide available at the [EDB website](/bart/2.6/bart_inst/) | +| `--with-pg_basebackup` | This is applicable only for full backup. Specify this option to use `pg_basebackup` to take a full backup. The number of thread counts in effect is ignored as given by the `thread_count` parameter in the BART configuration file.
When taking a full backup, if the thread count in effect is greater than `1`, then the `pg_basebackup` utility is not used to take the full backup (parallel worker threads are used) unless the option `--with-pg_basebackup` is specified with the `BACKUP` subcommand. | +| `--no-pg_basebackup` | This is applicable only for full backup. Specify this option if you do not want `pg_basebackup` to be used to take a full backup.
When taking a full backup, if the thread count in effect is only `1`, then the `pg_basebackup` utility is used to take the full backup unless the option `--no-pg_basebackup` is specified with the `BACKUP` subcommand. | +| `--check` | This is applicable only for incremental backup. Specify this option to verify if the required MBM files are present in the `archived_wals` directory as specified in the `archive_path` parameter in the `bart.cfg` file before taking an incremental backup. The option `--parent` must be specified when the option `--check` is used. An actual incremental backup is not taken when the option `--check` is specified. | +| `--checksum-algorithm` | While taking a backup, you can specify one of the following values with the `--checksum-algorithm` option:
`--checksum-algorithm=MD5` (default) to generate MD5 checksum files.
`--checksum-algorithm=SHA256` to generate SHA256 checksum files.
`--checksum-algorithm=NONE` to skip generating checksum files. | + + + +**Backup Name Examples** + +The following examples demonstrate using the `--backup-name` clause: + +```text +./bart backup -s ppas12 -Ft --backup-name "YEAR = %year +MONTH = %month DAY = %day" +./bart backup -s ppas12 -Ft --backup-name "YEAR = %year +MONTH = %month DAY = %day %%" +./bart show-backups -s ppas12 -i "test backup" +``` + +**Error messages** + +The following table lists the error messages that may be encountered when using the `BACKUP` subcommand: + +| error message | Cause | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `edb@localhost bin]$ ./bart backup -s mktg -Ft`

`WARNING: xlog_method is empty, defaulting to global policy`

`ERROR: backup failed for server 'mktg'`

`free disk space is not enough to backup the server 'mktg'`

`space available 13.35 GB, approximately required 14.65 GB` | Insufficient free disk space. | +| `ERROR: backup failed for server 'mktg'`

`command failed with exit code 1`

`pg_basebackup: could not get transaction log end position from server: ERROR: requested WAL segment 00000001000000D50000006B has already been removed` | The wal_keep_segments configuration parameter is not set to a sufficiently large value in the postgresql.conf file. | +| `ERROR: backup failed for server 'mktg'`

`connection to the server failed: could not connect to server: Connection refused`

`Is the server running on host "172.16.114.132" and accepting`

`TCP/IP connections on port 5444?` | A connection to a database server listed in the BART configuration file fails. As a result the backup for that database server is skipped, but the backup operation continues for other database servers | diff --git a/product_docs/docs/bart/2.6/bart_user/03_using_bart/03_basic_bart_subcommand_usage/04_show_servers.mdx b/product_docs/docs/bart/2.6/bart_user/03_using_bart/03_basic_bart_subcommand_usage/04_show_servers.mdx new file mode 100644 index 00000000000..778efd3d4d6 --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_user/03_using_bart/03_basic_bart_subcommand_usage/04_show_servers.mdx @@ -0,0 +1,21 @@ +--- +title: "SHOW-SERVERS" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/show_servers.html" +--- + + + +The `SHOW-SERVERS` subcommand displays the information for the managed database servers listed in the BART configuration file. + +**Syntax:** + +`bart SHOW-SERVERS [ –s { | all } ]` + +The following table describes the command options. + +| Options | Description | +| ---------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { \| all }`
`--server { \| all }` | `` is the name of the database server whose BART configuration information is to be displayed. If `all` is specified or if the option is omitted, information for all database servers is displayed. | diff --git a/product_docs/docs/bart/2.6/bart_user/03_using_bart/03_basic_bart_subcommand_usage/05_show_backups.mdx b/product_docs/docs/bart/2.6/bart_user/03_using_bart/03_basic_bart_subcommand_usage/05_show_backups.mdx new file mode 100644 index 00000000000..d006df69db1 --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_user/03_using_bart/03_basic_bart_subcommand_usage/05_show_backups.mdx @@ -0,0 +1,25 @@ +--- +title: "SHOW-BACKUPS" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/show_backups.html" +--- + +The `SHOW-BACKUPS` subcommand displays the backup information for the managed database servers. + +**Syntax:** + +```text +bart SHOW-BACKUPS [ –s { | all } ] + [ -i { | | all } ] + [ -t ] +``` + +The following table describes the command options: + +| Options | Description | +| ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { \| all }`
`--server { \| all }` | `` is the name of the database server whose backup information is to be displayed.
If `all` is specified or if the option is omitted, the backup information for all database servers is displayed with the exception as described by the following note:
If `SHOW-BACKUPS` is invoked while the BART `BACKUP` subcommand is in progress, backups affected by the backup process are shown in progress status in the displayed backup information. | +| `-i { \| \| all }`
`--backupid { \| \| all }` | `` is a backup identifier and `` is the user-defined alphanumeric name for the backup.
If `all` is specified or if the option is omitted, all backup information for the relevant database server is displayed. | +| `-t`
`--toggle` | Displays more backup information in a list format. If the option is omitted, the default is a tabular format. | diff --git a/product_docs/docs/bart/2.6/bart_user/03_using_bart/03_basic_bart_subcommand_usage/06_verify_chksum.mdx b/product_docs/docs/bart/2.6/bart_user/03_using_bart/03_basic_bart_subcommand_usage/06_verify_chksum.mdx new file mode 100644 index 00000000000..4ec79d52d62 --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_user/03_using_bart/03_basic_bart_subcommand_usage/06_verify_chksum.mdx @@ -0,0 +1,29 @@ +--- +title: "VERIFY-CHKSUM" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/verify_chksum.html" +--- + + + +The `VERIFY-CHKSUM` subcommand verifies the MD5 checksums of the full backups and any user-defined tablespaces for the specified database server or for all database servers. The checksum is verified by comparing the current checksum of the backup against the checksum when the backup was taken. + +!!! Note + The `VERIFY-CHKSUM` subcommand is only used for tar format backups. It is not applicable to plain format backups. + +**Syntax:** + +```text +bart VERIFY-CHKSUM + [ -s { | all } ] + [ -i { | | all } ] +``` + +The following table describes the command options: + +| Options | Description | +| ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s { \| all }`

`--server { \| all }` | `` is the name of the database server whose tar backup checksums are to be verified. If `all` is specified or if the `-s` option is omitted, the checksums are verified for all database servers. | +| `-i { \| \| all }`

`--backupid { \| \| all }` | `` is the backup identifier of a tar format full backup whose checksum is to be verified along with any user-defined tablespaces.
`` is the user-defined alphanumeric name for the full backup.
If `all` is specified or if the `-i` option is omitted, the checksums of all tar backups for the relevant database server are verified. | diff --git a/product_docs/docs/bart/2.6/bart_user/03_using_bart/03_basic_bart_subcommand_usage/07_manage.mdx b/product_docs/docs/bart/2.6/bart_user/03_using_bart/03_basic_bart_subcommand_usage/07_manage.mdx new file mode 100644 index 00000000000..856566907f7 --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_user/03_using_bart/03_basic_bart_subcommand_usage/07_manage.mdx @@ -0,0 +1,62 @@ +--- +title: "MANAGE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/manage.html" +--- + + + +The `MANAGE` subcommand can be invoked to: + +- Evaluate backups, mark their status, and delete obsolete backups based on the `retention_policy` parameter in the BART configuration file (See [Managing Backups Using a Retention Policy](../02_managing_backups_using_a_retention_policy/#managing_backups_using_a_retention_policy) for information about retention policy management). + +- Compress the archived WAL files based on the `wal_compression` parameter in the BART configuration file (See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/2.6/bart_inst/) for information about setting this parameter). + + **Syntax:** + + ```text + bart MANAGE [ –s { | all} ] + [ -l ] [ -d ] + [ -c { keep | nokeep } + -i { | | all } ] + [ -n ] + ``` + +The following summarizes the actions performed when the `MANAGE` subcommand is invoked: + +- When the `MANAGE` subcommand is invoked with no options or with only the `-s ` or `-s all` option, the following actions are performed: + - For the server specified by the `-s` option, or for all servers (if `-s all` is specified or the `-s` option is omitted), active backups are marked as `obsolete` in accordance with the retention policy. + - All backups that were marked `obsolete` or `keep` prior to invoking the `MANAGE` subcommand remain marked with the same prior status. + - If WAL compression is enabled for the database server, then any uncompressed, archived WAL files in the BART backup catalog of the database server are compressed with gzip. +- When the `MANAGE` subcommand is invoked with any other option besides the `-s` option, the following actions are performed: + - For the server specified by the `-s` option, or for all servers, the action performed is determined by the other specified options (that is, `-l` to list obsolete backups, `-d` to delete obsolete backups, `-c` to keep or to return backups to `active` status, or `-n` to perform a dry run of any action). + - No marking of `active` backups to `obsolete` status is performed regardless of the retention policy. + - All backups that were marked `obsolete` or `keep` prior to invoking the `MANAGE` subcommand remain marked with the same prior status unless the `-c` option (without the `-n` option) is specified to change the backup status of the particular backup or all backups referenced with the `-i` option. + - No compression is applied to any uncompressed, archived WAL file in the BART backup catalog regardless of whether or not WAL compression is enabled. + +The following are additional considerations when using WAL compression: + +- Compression of archived WAL files is not permitted for database servers on which incremental backups are to be taken. +- The gzip compression program must be installed on the BART host and be accessible in the `PATH` of the BART user account. +- When the `RESTORE` subcommand is invoked, if the `-c` option is specified or if the `copy_wals_during_restore` BART configuration parameter is enabled for the database server, then the following actions occur: + + - If compressed, archived WAL files are stored in the BART backup catalog and the location to which the WAL files are to be restored is on a remote host relative to the BART host: + + - the archived WAL files are transmitted across the network to the remote host in compressed format only if the gzip compression program is accessible in the `PATH` of the remote user account that is used to log into the remote host when performing the `RESTORE` operation. + - This remote user is specified with either the `remote_host` parameter in the BART configuration file or the `RESTORE -r` option (see [RESTORE](08_restore/#restore)). + - Transmission of compressed WAL files results in less network traffic. After the compressed WAL files are transmitted across the network, the `RESTORE` subcommand uncompresses the files for the point-in-time recovery operation. + - If the gzip program is not accessible on the remote host in the manner described in the previous bullet point, then the compressed, archived WAL files are first uncompressed while on the BART host, then transmitted across the network to the remote host in uncompressed format. +- When the `RESTORE` subcommand is invoked without the `-c` option and the `copy_wals_during_restore` BART configuration parameter is disabled for the database server, then any compressed, archived WAL files needed for the `RESTORE` operation are uncompressed in the BART backup catalog. The uncompressed WAL files can then be saved to the remote host by the `restore_command` in the `postgresql.auto.conf` file when the database server archive recovery begins. + +The following table describes the command options: + +| Options | Description | +| ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `s { \| all }`
`--server { \| all }` | `` is the name of the database server to which the actions are to be applied. If `all` is specified or if the `-s` option is omitted, the actions are applied to all database servers. | +| `-l`
`--list-obsolete` | Lists the backups marked as obsolete. | +| `-d`
`--delete-obsolete` | Delete the backups marked as `obsolete`. This action physically deletes the backup along with its archived WAL files and any MBM files for incremental backups. | +| `-c { keep \| nokeep }`

`--change-status { keep \| nokeep }` | Specify `keep` to change the status of a backup to `keep` to retain it indefinitely.
Specify `nokeep` to change the status of any backup back to active status. The backup can then be re-evaluated and possibly be marked to `obsolete` according to the retention policy by subsequent usage of the `MANAGE` subcommand.
The `–i` option must be included when using the `-c` option. | +| `-i { \| \| all }`

`--backupid { \| \| all }` | `` is a backup identifier and `` is the user-defined alphanumeric name for the backup.
If `all` is specified, then actions are applied to all backups.
The `–c` option must be included when using the `-i` option. | +| `-n`
`--dry-run` | Performs the test run and displays the results prior to actually implementing the actions as if the operation was performed, however, no changes are actually made.
If `-n` is specified with the `-d` option, it displays which backups would be deleted, but does not actually delete the backups.
If `-n` is specified with the `-c` option, it displays the keep or nokeep action, but does not actually change the backup from its current status.
If `-n` is specified alone with no other options, or with only the `-s` option, it displays which active backups would be marked as obsolete, but does not actually change the backup status. In addition, no compression is performed on uncompressed, archived WAL files even if WAL compression is enabled for the database server. | diff --git a/product_docs/docs/bart/2.6/bart_user/03_using_bart/03_basic_bart_subcommand_usage/08_restore.mdx b/product_docs/docs/bart/2.6/bart_user/03_using_bart/03_basic_bart_subcommand_usage/08_restore.mdx new file mode 100644 index 00000000000..969d5aa0aa7 --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_user/03_using_bart/03_basic_bart_subcommand_usage/08_restore.mdx @@ -0,0 +1,48 @@ +--- +title: "RESTORE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/restore.html" +--- + + + +The `RESTORE` subcommand restores a backup and its archived WAL files for the designated database server to the specified directory location. If the appropriate `RESTORE` options are specified, all recovery settings will be saved in the `postgresql.auto.conf` file. + +**Syntax:** + +```text +bart RESTORE –s -p + [ –i { | } ] + [ -r ] + [ -w ] + [ -t ] + [ { -x | -g } ] + [ -c ] + [ --disable-checksum ] +``` + +For information about using a continuous archive backup for recovery, see the [PostgreSQL Core Documentation](https://www.postgresql.org/docs/13/static/continuous-archiving.html). This reference material provides detailed information about the underlying point-in-time recovery process and the meaning and usage of the restore options that are generated into the `postgresql.auto.conf` file by BART. + +**Please note**: + +- For special requirements when restoring an incremental backup to a remote database server, see [Restoring an Incremental Backup on a Remote Host](../../02_overview/01_block-level_incremental_backup/05_restoring_an_incremental_backup/#restoring_an_incremental_backup_on_a_remote_host). +- Check to ensure that the host where the backup is to be restored contains enough disk space for the backup and its archived WAL files. The `RESTORE` subcommand may result in an error while copying files if there is not enough disk space available. +- See [Performing a Restore Operation](../01_bart_management_overview/01_performing_a_restore_operation/#performing_a_restore_operation) to view steps on how to perform a restore operation and see [Point-In-Time Recovery Operation](../01_bart_management_overview/02_point_in_time_recovery_operation/#point_in_time_recovery_operation) to view steps on how to perform a point-in-time recovery operation. +- If the backup is restored to a different database cluster directory than where the original database cluster resided, certain operations dependent upon the database cluster location may fail. This happens if their supporting service scripts are not updated to reflect the new directory location of restored backup. For information about the usage and modification of service scripts, see the *EDB Advanced Server Installation Guide*. + +The following table describes the command options: + +| Options | Description | +| ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s `
`--server ` | `` is the name of the database server to be restored. | +| `-p `
`--restore-path ` | `` is the directory path where the backup of the database server is to be restored. The directory must be empty and have the proper ownership and privileges assigned to it. | +| `-i { \| }`

`--backupid { \| }` | `` is the backup identifier of the backup to be used for the restoration and `` is the user-defined alphanumeric name for the backup.
If the option is omitted, the default is to use the latest backup. | +| `-r or --remote-host ` | `` is the user account on the remote database server host that accepts a passwordless SSH/SCP login connection and is the owner of the directory where the backup is to be restored and `` is the IP address of the remote host to which the backup is to be restored. This option must be specified if the `` parameter for this database server is not set in the BART configuration file.
If the BART user account is not the same as the operating system account owning the `` directory given with the `-p` option, use the `` BART configuration parameter or the `RESTORE` subcommand `-r` option to specify the `` directory owner even when restoring to a directory on the same host as the BART host.
See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/2.6/bart_inst/) for information about the `` parameter. | +| `-w `
`--workers ` | `` is the specification of the number of worker processes to run in parallel to stream the modified blocks of an incremental backup to the restore location.
For example, if 4 worker processes are specified, 4 receiver processes on the restore host and 4 streamer processes on the BART host are used. The output of each streamer process is connected to the input of a receiver process. When the receiver gets to the point where it needs a modified block file, it obtains those modified blocks from its input. With this method, the modified block files are never written to the restore host disk. If the `-w` option is omitted, the default is `1` \| worker process. | +| `-t `
`--target-tli ` | `` is the integer identifier of the timeline to be used for replaying the archived WAL files for point-in-time recovery. | +| `-x `
`--target-xid ` | `` is the integer identifier of the transaction ID that determines the transaction up to and including, which point-in-time recovery encompasses. Include either the `-x ` or the `--target-xid ` option if point-in-time recovery is desired. | +| `-g `

`--target-timestamp ` | `` is the timestamp that determines the point in time up to and including, which point-in-time recovery encompasses. Include either the `--target-timestamp ` or the `-g ` option if point-in-time recovery is desired. | +| `-c`
`--copy-wals` | Specify this option to copy archived WAL files from the BART backup catalog to `/archived_wals` directory.
If recovery settings are saved in the `postgresql.auto.conf` file for point-in-time recovery, the `restore_command` retrieves the WAL files from `/archived_wals` for the database server archive recovery.
If the `-c` option is omitted and the `copy_wals_during_restore` parameter in the BART configuration file is not enabled in a manner applicable to this database server, the `restore_command` in the `postgresql.auto.conf` file is generated by default to retrieve the archived WAL files directly from the BART backup catalog. See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/2.6/bart_inst/) for information about the `copy_wals_during_restore` parameter. | +| `--disable-checksum` | While restoring a backup, specify this option to skip verifying the MD5 or SHA256 checksum files.
If you set the `--checksum-algorithm=NONE` option with the [BART scanner](../04_running_the_bart_wal_scanner/#running_the_bart_wal_scanner) or while taking a [backup](03_backup/#backup), you must specify the `--disable checksum` option while restoring an incremental backup. | diff --git a/product_docs/docs/bart/2.6/bart_user/03_using_bart/03_basic_bart_subcommand_usage/09_delete.mdx b/product_docs/docs/bart/2.6/bart_user/03_using_bart/03_basic_bart_subcommand_usage/09_delete.mdx new file mode 100644 index 00000000000..7f9836ad724 --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_user/03_using_bart/03_basic_bart_subcommand_usage/09_delete.mdx @@ -0,0 +1,34 @@ +--- +title: "DELETE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/delete.html" +--- + + + +The `DELETE` subcommand removes the subdirectory and data files from the BART backup catalog for the specified backups along with its archived WAL files. + +**Syntax:** + +```text +bart DELETE –s + -i { all | + [']{ | },... }['] + } + [ -n ] +``` + +!!! Note + While invoking the `DELETE` subcommand, you must specify a specific database server. + +For database servers under a retention policy, there are conditions where certain backups may not be deleted. See [Deletions Permitted Under a Retention Policy](../02_managing_backups_using_a_retention_policy/04_managing_the_backups_based_on_the_retention_policy/#deletions_permitted_under_retention_policy) for information about permitted backup deletions. + +The following table describes the command options: + +| Options | Description | +| -------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-s `

`--server ` | `` is the name of the database server whose backups are to be deleted. | +| `-i { all \| [']{ \| },... }['] }`

`--backupid { all \| [']{ \| },... }['] }` | `` is the backup identifier of the backup to be deleted and `` is the user-defined alphanumeric name for the backup.
Multiple backup identifiers and backup names may be specified in a comma-separated list. The list must be enclosed within single quotes if there is any white space appearing before or after each comma.
If `all` is specified, all of the backups and their archived WAL files for the specified database server are deleted. | +| `-n`
`--dry-run` | Displays the results as if the deletions were done, however, no physical removal of the files are actually performed. In other words, a test run is performed so that you can see the potential results prior to actually initiating the action.
After the deletion, the BART backup catalog for the database server no longer contains the corresponding directory for the deleted backup ID. The `archived_wals` subdirectory no longer contains the WAL files of the backup. | diff --git a/product_docs/docs/bart/2.6/bart_user/03_using_bart/03_basic_bart_subcommand_usage/index.mdx b/product_docs/docs/bart/2.6/bart_user/03_using_bart/03_basic_bart_subcommand_usage/index.mdx new file mode 100644 index 00000000000..b4dd726573b --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_user/03_using_bart/03_basic_bart_subcommand_usage/index.mdx @@ -0,0 +1,50 @@ +--- +title: "Basic BART Subcommand Usage" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/basic_bart_subcommand_usage.html" +--- + + + +This section briefly describes the BART subcommands and options. You can invoke the `bart` program (located in the `/bin` directory) with the desired options and subcommands to manage your BART installation. + +To view examples of BART subcommands, see the *EDB Backup and Recovery Reference Guide* available at the [EDB website](/bart/2.6/bart_ref/). + +**Syntax for invoking BART**: + + `bart [ general_option ]... [ subcommand ] [subcommand_option ]...` + +- When invoking a subcommand, the subcommand name is not case-sensitive (that is, the subcommand can be specified in uppercase, lowercase, or mixed case). +- Each subcommand has a number of its own applicable options that are specified following the subcommand. All options are available in both single-character and multi-character forms. +- Keywords are case-sensitive; options are generally specified in lowercase unless specified otherwise in this section. +- When invoking BART, the current user must be the BART user account (operating system user account used to run the BART command line program). For example, enterprisedb or postgres can be selected as the BART user account when the managed database servers are Advanced Server or PostgreSQL respectively. +- The chosen operating system user account must own the BART backup catalog directory, be able to run the `bart` program and the `bart scanner` program, and have a passwordless SSH/SCP connection established between database servers managed by BART. + +You can specify one or more of the following general options: + +| Options | Description | +| ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-h` `--help` | Displays general syntax and information on BART usage. All subcommands support a help option (`-h`, `--help`). If the help option is specified, information is displayed regarding that particular subcommand. The subcommand, itself, is not executed. | +| `-v` `--version` | Displays the BART version information. | +| `-d` `--debug` | Displays debugging output while executing BART subcommands. | +| `-c ` `--config-path ` | Specifies `config_file_path` as the full directory path to a BART configuration file. Use this option if you do not want to use the default BART configuration file `/etc/bart.cfg`. | + +**Troubleshooting: Setting Path Environment Variable** + +If execution of BART subcommands fails with the following error message, then you need to set the `LD_LIBRARY_PATH` to include the `libpq` library directory: + + `./bart: symbol lookup error: ./bart: undefined symbol: PQping` + +**Workaround:** Set the `LD_LIBRARY_PATH` environment variable for the BART user account to include the directory containing the `libpq` library. This directory is `POSTGRES_INSTALL_HOME/lib`. + +It is suggested that the `PATH` and the `LD_LIBRARY_PATH` environment variable settings be placed in the BART user account’s profile. See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/2.6/bart_inst/) for details. + +In the following sections, the `help` option is omitted from the syntax diagrams for the purpose of providing readability for the subcommand options. + +
+ +check_config init backup show_servers show_backups verify_chksum manage restore delete + +
diff --git a/product_docs/docs/bart/2.6/bart_user/03_using_bart/04_running_the_bart_wal_scanner.mdx b/product_docs/docs/bart/2.6/bart_user/03_using_bart/04_running_the_bart_wal_scanner.mdx new file mode 100644 index 00000000000..02984b649de --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_user/03_using_bart/04_running_the_bart_wal_scanner.mdx @@ -0,0 +1,61 @@ +--- +title: "Running the BART WAL Scanner" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/running_the_bart_wal_scanner.html" +--- + + + +Use the BART WAL scanner to invoke the `bart-scanner` program located in the `BART_HOME/bin` directory. When invoking the WAL scanner, the current user must be the BART user account. + +**Syntax:** + +```text +bart-scanner + [ -d ] + [ -c ] + { –h | + -v | + --daemon | + -p | + | + RELOAD | + STOP + --checksum-algorithm } +``` + +!!! Note + For clarity, the syntax diagram shows only the single-character option form (for example, `-d`), but the multi-character option form (for example, `--debug`) is supported as well. + +The WAL scanner processes each WAL file to find and record modified blocks in a corresponding modified block map (MBM) file. The default approach is that the WAL scanner gets notified whenever a new WAL file is added to the `archived_wals` directory specified in the `archive_path` parameter of the configuration file. It then scans the WAL file and produces the MBM file. + +The default approach does not work in some cases; for example when the WAL files are shipped to the `archive_path` using the Network File System (NFS) and also in case of some specific platforms. This results in the WAL files being copied to the `archived_wals` directory, but the WAL scanner does not scan them (as WAL scanner is not aware of WAL file) and produce the MBM files. This results in the failure of an incremental backup. This can be avoided by using the timer-based WAL scanning approach, which is done by using the `scan_interval` parameter in the BART configuration file. The value for `scan_interval` is the number of seconds after which the WAL scanner will initiate force scanning of the new WAL files. See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/2.6/bart_inst/) for more information about `scan_interval` parameter. + +!!! Note + After upgrading to BART 2.6, users who have set this parameter to a non-default value may see increased CPU consumption on the part of bart-scanner. If this is an issue, consider increasing the configured value of scan_interval parameter, or removing the setting if it is not required. + +When the `bart-scanner` program is invoked, it forks a separate process for each database server enabled with the `allow_incremental_backups` parameter. + +The WAL scanner processes can run in either the foreground or background depending upon usage of the `--daemon` option. Use the `--daemon` option to run the WAL scanner process in the background so that all output messages can be viewed in the BART log file. If the `--daemon` option is omitted, the WAL scanner process runs in the foreground and all output messages can be viewed from the terminal running the program as well as in the BART log file. + +See the *EDB Backup and Recovery Installation and Upgrade Guide* available at the [EDB website](/bart/2.6/bart_inst/) for additional information about WAL scanning, `allow_incremental_backups`, and `logfile` parameters. + +!!! Note + The BART user account’s `LD_LIBRARY_PATH` environment variable may need to be set to include the directory containing the `libpq` library if invocation of the WAL scanner program fails. See [Basic BART Subcommand Usage](03_basic_bart_subcommand_usage/#basic_bart_subcommand_usage) for information about setting the `LD_LIBRARY_PATH` environment variable. + +The following table describes the scanner options: + +| Options | Description | +| ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-h` `--help` | Displays general syntax and information on WAL scanner usage. | +| `-v` `--version` | Displays the WAL scanner version information. | +| `-d` `--debug` | Displays debugging output while executing the WAL scanner with any of its options. | +| `-c ` `--config-path ` | Use this option to specify the `config_file_path` of a BART configuration file if you do not want to use the default BART configuration file path `BART_HOME/etc/bart.cfg`. | +| `--daemon` | Runs the WAL scanner as a background process. | +| `-p ` `--print ` | Use this option to specify the full directory path to an MBM file whose content is to be printed. The directory specified in the `archive_path` parameter in the `bart.cfg` file contains the MBM files. | +| `` | Specify the full directory path to a WAL file to be scanned. The directory specified in the `archive_path` parameter in the `bart.cfg` file contains the WAL files. Use this option if a WAL file in the archive path is missing its MBM file. This option is to be used for assisting the EnterpriseDB support team for debugging problems that may have been encountered. | +| `RELOAD` | Reloads the BART configuration file. The keyword `RELOAD` is not case-sensitive. The `RELOAD` option is useful if you make changes to the configuration file after the WAL scanner has been started. It will reload the configuration file and adjust the WAL scanners accordingly. For example, if a server section allowing incremental backups is removed from the BART configuration file, then the process attached to that server will stop. Similarly, if a server allowing incremental backups is added, a new WAL scanner process will be launched to scan the WAL files of that server. | +| `STOP` | Stops the WAL scanner. The keyword `STOP` is not case-sensitive. | +| `--checksum-algorithm` | While invoking the WAL scanner, you can specify one of the following values with the `--checksum-algorithm` option: `--checksum-algorithm=MD5` (default) to generate MD5 checksum files. `--checksum-algorithm=SHA256` to generate SHA256 checksum files. `--checksum-algorithm=NONE` to skip generating checksum files. | diff --git a/product_docs/docs/bart/2.6/bart_user/03_using_bart/index.mdx b/product_docs/docs/bart/2.6/bart_user/03_using_bart/index.mdx new file mode 100644 index 00000000000..a076b82b5e9 --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_user/03_using_bart/index.mdx @@ -0,0 +1,19 @@ +--- +title: "Using BART" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/using_bart.html" +--- + + + +After installing and configuring the BART host and the database servers, you can start using BART. + +This section describes how to perform backup and recovery management operations using BART. Review the sections that follow before proceeding with any BART operation. + +
+ +bart_management_overview managing_backups_using_a_retention_policy basic_bart_subcommand_usage running_the_bart_wal_scanner + +
diff --git a/product_docs/docs/bart/2.6/bart_user/04_using_tablespaces.mdx b/product_docs/docs/bart/2.6/bart_user/04_using_tablespaces.mdx new file mode 100644 index 00000000000..6683466db04 --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_user/04_using_tablespaces.mdx @@ -0,0 +1,59 @@ +--- +title: "Using Tablespaces" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/using_tablespaces.html" +--- + + + +If the database cluster contains user-defined tablespaces (that is, tablespaces created with the `CREATE TABLESPACE` command): + +- You can take full backups with the `BACKUP` subcommand in either tar (`-Ft`) or plain text (`-Fp`) backup file format. +- You must take incremental backups in the plain text (`-Fp`) backup file format. +- You can take full backups using the transaction log streaming method (xlog_method = stream in the BART configuration file) `--with-pg_basebackup` and the `BACKUP` subcommand in either tar (`-Ft`) or plain text (`-Fp`) backup file format. + +!!! Note + If the particular database cluster you plan to back up contains tablespaces created by the `CREATE TABLESPACE` command, then you must set the `tablespace_path` parameter in the BART configuration file before you perform a BART `RESTORE` operation. + +The `tablespace_path` parameter specifies the directory paths to which you want the tablespaces to be restored. It takes the following format: + + `OID_1=tablespace_path_1;OID_2=tablespace_path_2 ...` + +Where `OID_1`, `OID_2`, … are the Object Identifiers of the tablespaces. You can find the OIDs of the tablespaces and their corresponding soft links to the directories by listing the contents of the `POSTGRES_INSTALL_HOME/data/pg_tblspc` subdirectory as shown in the following example: + +```text +[root@localhost pg_tblspc ]# pwd +/opt/PostgresPlus/9.6AS/data/pg_tblspc +[root@localhost pg_tblspc]# ls -l +total 0 +lrwxrwxrwx 1 enterprisedb enterprisedb 17 Aug 22 16:38 16644 -> /mnt/tablespace_1 +lrwxrwxrwx 1 enterprisedb enterprisedb 17 Aug 22 16:38 16645 -> /mnt/tablespace_2 +``` + +The OIDs are `16644` and `16645` to directories `/mnt/tablespace_1` and `/mnt/tablespace_2`, respectively. + +If you later wish to restore the tablespaces to the same locations as indicated in the preceding example, the BART configuration file must contain the following entry: + +```text +[ACCTG] +host = 127.0.0.1 +port = 5444 +user = enterprisedb +cluster_owner = enterprisedb +tablespace_path = 16644=/mnt/tablespace_1;16645=/mnt/tablespace_2 +description = "Accounting" +``` + +If you later wish to restore the tablespaces to different locations, specify the new directory locations in the `tablespace_path` parameter. + +In either case, the directories specified in the `tablespace_path` parameter must exist and be empty at the time you perform the `BART RESTORE` operation. + +If the database server is running on a remote host (in other words you are also using the `remote_host` configuration parameter or will specify the `--remote-host` option with the `RESTORE` subcommand), the specified tablespace directories must exist on the specified remote host. + +To view examples of backing up and restoring a database cluster on a remote host containing tablespaces, see the *EDB Backup and Recovery Reference Guide* available at the [EDB website](/bart/2.6/bart_ref/). + +The directories must be owned by the user account with which you intend to start the database server (typically the Postgres user account) with no access by other users or groups as is required for the directory path to which the main full backup is to be restored. + +To view a sample BART managed backup and recovery system consisting of both local and remote database servers, see the *EDB Backup and Recovery Reference Guide* available at the [EDB website](/bart/2.6/bart_ref/). diff --git a/product_docs/docs/bart/2.6/bart_user/images/EDB_logo.png b/product_docs/docs/bart/2.6/bart_user/images/EDB_logo.png new file mode 100644 index 00000000000..39a54822d85 Binary files /dev/null and b/product_docs/docs/bart/2.6/bart_user/images/EDB_logo.png differ diff --git a/product_docs/docs/bart/2.6/bart_user/images/copy_1.png b/product_docs/docs/bart/2.6/bart_user/images/copy_1.png new file mode 100644 index 00000000000..b15833dc37d Binary files /dev/null and b/product_docs/docs/bart/2.6/bart_user/images/copy_1.png differ diff --git a/product_docs/docs/bart/2.6/bart_user/images/edb.png b/product_docs/docs/bart/2.6/bart_user/images/edb.png new file mode 100644 index 00000000000..71e5bdde787 Binary files /dev/null and b/product_docs/docs/bart/2.6/bart_user/images/edb.png differ diff --git a/product_docs/docs/bart/2.6/bart_user/images/edb_logo.svg b/product_docs/docs/bart/2.6/bart_user/images/edb_logo.svg new file mode 100644 index 00000000000..f24d1dfefee --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_user/images/edb_logo.svg @@ -0,0 +1,19 @@ + + + edb-logo-disc-dark + + + + \ No newline at end of file diff --git a/product_docs/docs/bart/2.6/bart_user/index.mdx b/product_docs/docs/bart/2.6/bart_user/index.mdx new file mode 100644 index 00000000000..50504d9e3db --- /dev/null +++ b/product_docs/docs/bart/2.6/bart_user/index.mdx @@ -0,0 +1,17 @@ +--- +navTitle: Backup and Recovery Guide +title: "EDB Postgres Backup and Recovery User Guide" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/genindex.html" + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/introduction.html" + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/conclusion.html" + - "/edb-docs/d/edb-backup-and-recovery-tool/user-guides/backup-recovery-guide/2.6.1/index.html" +--- + +
+ +introduction overview using_bart using_tablespaces conclusion + +
diff --git a/product_docs/docs/bart/2.6/bart_v2.6_documentation.pdf b/product_docs/docs/bart/2.6/bart_v2.6_documentation.pdf new file mode 100644 index 00000000000..1d4aff9d658 Binary files /dev/null and b/product_docs/docs/bart/2.6/bart_v2.6_documentation.pdf differ diff --git a/product_docs/docs/bart/2.6/index.mdx b/product_docs/docs/bart/2.6/index.mdx new file mode 100644 index 00000000000..245dc0e42ef --- /dev/null +++ b/product_docs/docs/bart/2.6/index.mdx @@ -0,0 +1,13 @@ +--- +title: Backup and Recovery Tool +directoryDefaults: +description: "EDB Backup and Recovery Tool Version 2.6 Documentation and release notes. A tool to manage and configure PostgreSQL backups and disaster recovery." +navigation: + - "#Getting Started" + - bart_inst + - bart_qs_7 + - bart_qs_8 + - "#Guides" + - bart_user + - bart_ref +--- \ No newline at end of file diff --git a/product_docs/docs/bdr/3.6/bdr_v3.6_documentation.pdf b/product_docs/docs/bdr/3.6/bdr_v3.6_documentation.pdf new file mode 100644 index 00000000000..fa11a10c039 Binary files /dev/null and b/product_docs/docs/bdr/3.6/bdr_v3.6_documentation.pdf differ diff --git a/product_docs/docs/bdr/3.6/index.mdx b/product_docs/docs/bdr/3.6/index.mdx new file mode 100644 index 00000000000..e6845be5b39 --- /dev/null +++ b/product_docs/docs/bdr/3.6/index.mdx @@ -0,0 +1,60 @@ +--- +navTitle: BDR +title: "BDR (Bi-Directional Replication)" +directoryDefaults: + description: "BDR (Bi-Directional Replication) is a ground-breaking multi-master replication capability for PostgreSQL clusters that has been in full production status since 2014." +--- + +**BDR (Bi-Directional Replication)** is a ground-breaking multi-master replication capability for PostgreSQL clusters that has been in full production status since 2014. In the complex environment of replication, this 3rd generation of BDR achieves efficiency and accuracy, enabling very high availability of all nodes in a geographically distributed cluster. This solution is for top-tier enterprise applications that require near-zero downtime and near-zero data loss. + +As a standard PostgreSQL extension BDR does this through logical replication of data and schema along with a robust set of features and tooling to manage conflicts and monitor performance. This means applications with the most stringent demands can be run with confidence on PostgreSQL. + +BDR was built from the start to allow for rolling upgrades and developed in conjunction with partners who were replacing costly legacy solutions. + +Available as two editions, BDR Standard provides essential multi-master replication capabilities for delivering row level consistency to address high availability and/or geographically distributed workloads. BDR Enterprise adds advanced conflict-handling and data-loss protection capabilities. + +## BDR Enterprise + +To provide very high availability, avoid data conflicts, and to cope with more advanced usage scenarios, the Enterprise edition provides the following extensive additional features: + +* Eager replication provides conflict free replication by synchronizing across cluster nodes before committing a transaction +* Commit at most once consistency guards application transactions even in the presence of node failures +* Conflict-free replicated data types (CRDTs) provide mathematically proven consistency in asynchronous multi-master update scenarios +* Column level conflict resolution enables per column last-update wins resolution to merge updates +* Transform triggers execute on incoming data for modifying or advanced programmatic filtering +* Conflict triggers provide custom resolution techniques when a conflict is detected + +BDR Enterprise requires EDB Postgres Extended v11 (formerly known as 2ndQuadrant Postgres) which is SQL and on-disk compatible with PostgreSQL. + +!!!note + The documentation for the latest stable 3.6 release is available here: + + [BDR 3.6 Enterprise Edition](https://documentation.2ndquadrant.com/bdr3-enterprise/release/latest-3.6/) + + **This is a protected area of our website, if you need access please [contact us](https://www.enterprisedb.com/contact)** +!!! + +## BDR Standard + +The Standard edition provides loosely-coupled multi-master logical replication using a mesh topology. This means that you can write to any node and the changes will be sent directly, row-by-row to all the other nodes that are part of the BDR cluster. + +By default BDR uses asynchronous replication to provide row-level eventual consistency, applying changes on the peer nodes only after the local commit. + +The following are included to support very high availability and geographically distributed workloads: + +* Rolling application and database upgrades to address the largest source of downtime +* DDL replication supports changes to application schema, ideal for use in continuous release environments +* Sequence handling provides applications different options for generating unique surrogate ids that a multi-node aware +* Tools to assess applications, monitor operation, and verify data consistency + +BDR Standard requires PostgreSQL v10 or v11. + +!!!note + The documentation for the latest stable 3.6 release is available here: + + [BDR 3.6 Standard Edition](https://documentation.2ndquadrant.com/bdr3/release/latest-3.6/) + + **This is a protected area of our website, if you need access please [contact us](https://www.enterprisedb.com/contact)** +!!! + + diff --git a/product_docs/docs/efm/3.10/efm_v3.10_documentation.pdf b/product_docs/docs/efm/3.10/efm_v3.10_documentation.pdf new file mode 100644 index 00000000000..c15092ee73b Binary files /dev/null and b/product_docs/docs/efm/3.10/efm_v3.10_documentation.pdf differ diff --git a/product_docs/docs/efm/3.10/index.mdx b/product_docs/docs/efm/3.10/index.mdx new file mode 100644 index 00000000000..6056a182e76 --- /dev/null +++ b/product_docs/docs/efm/3.10/index.mdx @@ -0,0 +1,12 @@ +--- +title: "EDB Postgres Failover Manager" +productStub: true +directoryDefaults: + description: "EDB Postgres Failover Manager Version 3.10 Documentation and release notes. PostgreSQL replication and failover manager for achieving high availability." + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/p/edb-postgres-failover-manager/3.10" +--- + + diff --git a/product_docs/docs/efm/3.6/efm_v3.6_documentation.pdf b/product_docs/docs/efm/3.6/efm_v3.6_documentation.pdf new file mode 100644 index 00000000000..acaacec8c61 Binary files /dev/null and b/product_docs/docs/efm/3.6/efm_v3.6_documentation.pdf differ diff --git a/product_docs/docs/efm/3.6/index.mdx b/product_docs/docs/efm/3.6/index.mdx new file mode 100644 index 00000000000..da27fd43bb5 --- /dev/null +++ b/product_docs/docs/efm/3.6/index.mdx @@ -0,0 +1,12 @@ +--- +title: "EDB Postgres Failover Manager" +productStub: true +directoryDefaults: + description: "EDB Postgres Failover Manager Version 3.6 Documentation and release notes. PostgreSQL replication and failover manager for achieving high availability." + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/p/edb-postgres-failover-manager/3.6" +--- + + diff --git a/product_docs/docs/efm/3.7/efm_v3.7_documentation.pdf b/product_docs/docs/efm/3.7/efm_v3.7_documentation.pdf new file mode 100644 index 00000000000..3a4c2d14968 Binary files /dev/null and b/product_docs/docs/efm/3.7/efm_v3.7_documentation.pdf differ diff --git a/product_docs/docs/efm/3.7/index.mdx b/product_docs/docs/efm/3.7/index.mdx new file mode 100644 index 00000000000..661ac948756 --- /dev/null +++ b/product_docs/docs/efm/3.7/index.mdx @@ -0,0 +1,12 @@ +--- +title: "EDB Postgres Failover Manager" +productStub: true +directoryDefaults: + description: "EDB Postgres Failover Manager Version 3.7 Documentation and release notes. PostgreSQL replication and failover manager for achieving high availability." + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/p/edb-postgres-failover-manager/3.7" +--- + + diff --git a/product_docs/docs/efm/3.8/efm_v3.8_documentation.pdf b/product_docs/docs/efm/3.8/efm_v3.8_documentation.pdf new file mode 100644 index 00000000000..06d2f69242a Binary files /dev/null and b/product_docs/docs/efm/3.8/efm_v3.8_documentation.pdf differ diff --git a/product_docs/docs/efm/3.8/index.mdx b/product_docs/docs/efm/3.8/index.mdx new file mode 100644 index 00000000000..8a8ee74b8fd --- /dev/null +++ b/product_docs/docs/efm/3.8/index.mdx @@ -0,0 +1,12 @@ +--- +title: "EDB Postgres Failover Manager" +productStub: true +directoryDefaults: + description: "EDB Postgres Failover Manager Version 3.8 Documentation and release notes. PostgreSQL replication and failover manager for achieving high availability." + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/p/edb-postgres-failover-manager/3.8" +--- + + diff --git a/product_docs/docs/efm/3.9/efm_v3.9_documentation.pdf b/product_docs/docs/efm/3.9/efm_v3.9_documentation.pdf new file mode 100644 index 00000000000..bd1c2ac4422 Binary files /dev/null and b/product_docs/docs/efm/3.9/efm_v3.9_documentation.pdf differ diff --git a/product_docs/docs/efm/3.9/index.mdx b/product_docs/docs/efm/3.9/index.mdx new file mode 100644 index 00000000000..c2e3cac6772 --- /dev/null +++ b/product_docs/docs/efm/3.9/index.mdx @@ -0,0 +1,12 @@ +--- +title: "EDB Postgres Failover Manager" +productStub: true +directoryDefaults: + description: "EDB Postgres Failover Manager Version 3.9 Documentation and release notes. PostgreSQL replication and failover manager for achieving high availability." + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/p/edb-postgres-failover-manager/3.9" +--- + + diff --git a/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/01_introduction.mdx b/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/01_introduction.mdx new file mode 100644 index 00000000000..e4e12dc4206 --- /dev/null +++ b/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/01_introduction.mdx @@ -0,0 +1,60 @@ +--- +title: "Architecture Overview" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/high-availability-scalability-guide/4.1/introduction.html" +--- + +This guide explains how to configure Failover Manager and Pgpool best to leverage the benefits that they provide for Advanced Server. Using the reference architecture described in the Architecture section, you can learn how to achieve high availability by implementing an automatic failover mechanism (with Failover Manager) while scaling the system for larger workloads and an increased number of concurrent clients with read-intensive or mixed workloads to achieve horizontal scaling/read-scalability (with Pgpool). + +The architecture described in this document has been developed and tested for EFM 4.0, EDB Pgpool, and Advanced Server 12. + +Documentation for Advanced Server and Failover Manager are available from EnterpriseDB at: + + + +Documentation for pgPool-II can be found at: + + + +## Failover Manager Overview + +Failover Manager is a high-availability module that monitors the health of a Postgres streaming replication cluster and verifies failures quickly. When a database failure occurs, Failover Manager can automatically promote a streaming replication Standby node into a writable Primary node to ensure continued performance and protect against data loss with minimal service interruption. + +**Basic EFM Architecture Terminology** + +A Failover Manager cluster is comprised of EFM processes that reside on the following hosts on a network: + +- A **Primary** node is the Primary database server that is servicing database clients. +- One or more **Standby nodes** are streaming replication servers associated with the Primary node. +- The **Witness node** confirms assertions of either the Primary or a Standby in a failover scenario. If, during a failure situation, the Primary finds itself in a partition with half or more of the nodes, it will stay Primary. As such, EFM supports running in a cluster with an even number of agents. + +## Pgpool-II Overview + +Pgpool-II (Pgpool) is an open-source application that provides connection pooling and load balancing for horizontal scalability of SELECT queries on multiple Standbys in EPAS and community Postgres clusters. For every backend, a backend_weight parameter can set the ratio of read traffic to be directed to the backend node. To prevent read traffic on the Primary node, the backend_weight parameter can be set to 0. In such cases, data modification language (DML) queries (i.e., INSERT, UPDATE, and DELETE) will still be sent to the Primary node, while read queries are load-balanced to the Standbys, providing scalability with mixed and read-intensive workloads. + +EnterpriseDB supports the following Pgpool functionality: + +- Load balancing +- Connection pooling +- High availability +- Connection limits + +### PCP Overview + +Pgpool provides an interface called PCP for administrators that performs management operations such as retrieving the status of Pgpool or terminating Pgpool processes remotely. PCP commands are UNIX commands that manipulate Pgpool via the network. + +### Pgpool Watchdog + +`watchdog` is an optional sub process of Pgpool that provides a high availability feature. Features added by `watchdog` include: + +- Health checking of the pgpool service +- Mutual monitoring of other watchdog processes +- Changing leader/Standby state if certain faults are detected +- Automatic virtual IP address assigning synchronous to server switching +- Automatic registration of a server as a Standby during recovery + +More information about the `Pgpool watchdog` component can be found at: + + diff --git a/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/02_architecture.mdx b/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/02_architecture.mdx new file mode 100644 index 00000000000..e6800ee7fea --- /dev/null +++ b/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/02_architecture.mdx @@ -0,0 +1,32 @@ +--- +title: "Architecture" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/high-availability-scalability-guide/4.0/architecture.html" +--- + +![A typical EFM and Pgpool configuration](images/edb_ha_architecture.png) + +The sample architecture diagram shows four nodes as described in the table below: + +| **Systems** | **Components** | +| ------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Primary Pgpool/EFM witness node | The Primary Pgpool node will only run Pgpool, and EFM witness, as such leaving as much resources available to Pgpool as possible. During normal runmode (no Pgpool Failovers), the Primary Pgpool node has attached the Virtual IP address, and all applications connect through the Virtual IP address to Pgpool. Pgpool will forward all write traffic to the Primary Database node, and will balance all read across all Standby nodes.On the Primary Pgpool node, the EFM witness process ensures that a minimum quota of three EFM agents remains available even if one of the database nodes fails. Some examples are when a node is already unavailable due to maintenance, or failure, and another failure occurs. | +| Primary Database node | The Primary Database node will only run Postgres (Primary)and EFM, leaving all resources to Postgres. Read/Write traffic (i.e., INSERT, UPDATE, DELETE) is forwarded to this node by the Primary Pgpool node. | +| Standby nodes | The Standby nodes are running Postgres (Standby), EFM and an inactive Pgpool process. In case of a Primary database failure, EFM will promote Postgres on one of these Standby nodes to handle read-write traffic. In case of a Primary Pgpool failure, the Pgpool watchdog will activate Pgpool on one of the Standby nodes which will attach the VIP, and handle the forwarding of the application connections to the Database nodes. Note that in a double failure situation (both the Primary Pgpool node and the Primary Database node are in failure), both of these Primary processes might end up on the same node. | + +This architecture: + +- Achieves high availability by providing two Standbys that can be promoted in case of a Primary Postgres node failure. +- Achieves high availability by providing at least three Pgpool processes in a watchdog configuration. +- Increases performance with mixed and read-intensive workloads by introducing increased read scalability with more than one Standby for load balancing. +- Reduces load on the Primary database node by redirecting read-only traffic with the Primary pgpool node. +- Prevents resource contention between Pgpool and Postgres on the Primary Database node. By not running Pgpool on the Primary database node, the Primary Postgres process can utilize as much resources as possible. +- Prevents resource contention between pgpool and Postgres on the Primary Pgpool node. By not running Standby databases on the Primary Pgpool node, Pgpool can utilize as many resources as possible. +- Optionally, synchronous replication can be set up to achieve near-zero data loss in a failure event. + +!!! Note + The architecture also allows us to completely separate 3 virtual machines running Postgres from 3 virtual machines running Pgpool. This kind of setup requires 2 extra virtual machines, but it is a better choice if you want to prevent resource contention between Pgpool and Postgres in Failover scenarios. In this setup, the architecture can run without an extra 7th node running the EFM Witness Process. To increase failure resolution efm witness agents could be deployed on the Pgpool servers. + +![Deployment of EFM and Pgpool on separate virtual machines](images/edb_ha_architecture_separate_VM.png) diff --git a/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/03_components_ha_pgpool.mdx b/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/03_components_ha_pgpool.mdx new file mode 100644 index 00000000000..2f17e0d16aa --- /dev/null +++ b/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/03_components_ha_pgpool.mdx @@ -0,0 +1,137 @@ +--- +title: "Implementing High Availability with Pgpool" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/high-availability-scalability-guide/4.0/components_ha_pgpool.html" +--- + +Failover Manager monitors the health of Postgres nodes; in the event of a database failure, Failover Manager performs an automatic failover to a Standby node. Note that Pgpool does not monitor the health of backend nodes and will not perform failover to any Standby nodes. + +## Configuring Failover Manager + +Failover Manager provides functionality that will remove failed database nodes from Pgpool load balancing; Failover Manager can also re-attach nodes to Pgpool when returned to the Failover Manager cluster. To configure this behavior, you must identify the load balancer attach and detach scripts in the efm.properties file in the following parameters: + +• `script.load.balancer.attach`=`/path/to/load_balancer_attach.sh %h` + +• `script.load.balancer.detach`=`/path/to/load_balancer_detach.sh %h` + +The script referenced by `load.balancer.detach` is called when Failover Manager decides that a database node has failed. The script detaches the node from Pgpool by issuing a PCP interface call. You can verify a successful execution of the load.balancer.detach script by calling `SHOW NODES` in a psql session attached to the Pgpool port. The call to SHOW NODES should return that the node is marked as down; Pgpool will not send any queries to a downed node. + +The script referenced by `load.balancer.attach` is called when a resume command is issued to the efm command-line interface to add a downed node back to the Failover Manager cluster. Once the node rejoins the cluster, the script referenced by `load.balancer.attach` is invoked, issuing a PCP interface call, which adds the node back to the Pgpool cluster. You can verify a successful execution of the `load.balancer.attach` script by calling `SHOW NODES` in a psql session attached to the Pgpool port; the command should return that the node is marked as up. At this point, Pgpool will resume using this node as a load balancing candidate. Sample scripts for each of these parameters are provided in Appendix B. + + +## Configuring Pgpool + +You must provide values for the following configuration parameters in the pgpool.conf file on the Pgpool host: + +```text +follow_master_command = '/path/to/follow_primary.sh %d %P' +load_balance_mode = on +master_slave_mode = on +master_slave_sub_mode = 'stream' +fail_over_on_backend_error = off +health_check_period = 0 +failover_if_affected_tuples_mismatch = off +failover_command = '' +failback_command = '' +search_primary_node_timeout = 3 +backend_hostname0='primary' +backend_port0=5433 +backend_flag0='ALLOW_TO_FAILOVER' +backend_hostname1='standby1' +backend_port1=5433 +backend_flag1='ALLOW_TO_FAILOVER' +backend_hostname2='standby2' +backend_port2=5433 +backend_flag2='ALLOW_TO_FAILOVER' +sr_check_period = 10 +sr_check_user = 'enterprisedb' +sr_check_password = 'edb' +sr_check_database = 'edb' +health_check_user = 'enterprisedb' +health_check_password = 'edb' +health_check_database = 'edb' +``` + +When the primary/master node is changed in Pgpool (either by failover or by manual promotion) in a non-Failover Manager setup, Pgpool detaches all standby nodes from itself, and executes the `follow_master_command` for each standby node, making them follow the new primary node. Since Failover Manager reconfigures the standby nodes before executing the post-promotion script (where a standby is promoted to primary in Pgpool to match the Failover Manager configuration), the `follow_master_command` merely needs to reattach standby nodes to Pgpool. + +Note that the load-balancing is turned on to ensure read scalability by distributing read traffic across the standby nodes. + +Note also that the health checking and error-triggered backend failover have been turned off, as Failover Manager will be responsible for performing health checks and triggering failover. It is not advisable for Pgpool to perform health checking in this case, so as not to create a conflict with Failover Manager, or prematurely perform failover. + +Finally, `search_primary_node_timeout` has been set to a low value to ensure prompt recovery of Pgpool services upon an Failover Manager-triggered failover. + +## pgpool_backend.sh + +In order for the attach and detach scripts to be successfully called, a pgpool_backend.sh script must be provided. `pgpool_backend.sh` is a helper script for issuing the actual PCP interface commands on Pgpool. Nodes in Failover Manager are identified by IP addresses, while PCP commands refer to a node ID. `pgpool_backend.sh` provides a layer of abstraction to perform the IP address to node ID mapping transparently. + +## Virtual IP Addresses + +Both Pgpool-II and Failover Manager provide functionality to employ a virtual IP for seamless failover. While both provide this capability, the pgpool-II leader is the process that receives the Application connections through the Virtual IP. As in this design, such Virtual IP management is performed by the Pgpool-II watchdog system. EFM VIP has no beneficial effect in this design and it must be disabled. + +Note that in a failure situation of the active instance of Pgpool (The Primary Pgpool Server in our sample architecture), the next available Standby Pgpool instance (according to watchdog priority) will be activated and takes charge as the leader Pgpool instance. + +## Configuring Pgpool-II Watchdog + +Watchdog provides the high availability of Pgpool-II nodes. This section lists the configuration required for watchdog on each Pgpool-II node. + +**Common watchdog configurations on all Pgpool nodes** + +The following configuration parameters enable and configure the watchdog. The interval and retry values can be adjusted depending upon the requirements and testing results. + +```text +use_watchdog = on # enable watchdog +wd_port = 9000 # watchdog port, can be changed +delegate_IP = ‘Virtual IP address’ +wd_lifecheck_method = 'heartbeat' +wd_interval = 10 # we can lower this value for quick detection +wd_life_point = 3 +# virtual IP control +ifconfig_path = '/sbin' # ifconfig command path +if_up_cmd = 'ifconfig eth0:0 inet $_IP_$ netmask 255.255.255.0' + # startup delegate IP command +if_down_cmd = 'ifconfig eth0:0 down' # shutdown delegate IP command +arping_path = '/usr/sbin' # arping command path +``` + +!!! Note + Replace the value of eth0 with the network interface on your system. See [Chapter 5](05_appendix_b/#configuration-for-number-of-connections-and-pooling) for tuning the number of connections, and pooling configuration. + +**Watchdog configurations on server 2** + +```text +other_pgpool_hostname0 = 'server 3 IP/hostname' +other_pgpool_port0 = 9999 +other_wd_port0 = 9000 +other_pgpool_hostname1 = 'server 4 IP/hostname' +other_pgpool_port1 = 9999 +other_wd_port1 = 9000 +wd_priority = 1 +``` + +**Watchdog configurations on server 3** + +```text +other_pgpool_hostname0 = 'server 2 IP/hostname' +other_pgpool_port0 = 9999 +other_wd_port0 = 9000 +other_pgpool_hostname1 = 'server 4 IP/hostname' +other_pgpool_port1 = 9999 +other_wd_port1 = 9000 +wd_priority = 3 +``` + +**Watchdog configurations on server 4** + +```text +other_pgpool_hostname0 = 'server 2 IP/hostname' +other_pgpool_port0 = 9999 +other_wd_port0 = 9000 +other_pgpool_hostname1 = 'server 3 IP/hostname' +other_pgpool_port1 = 9999 +other_wd_port1 = 9000 +wd_priority = 5 # use high watchdog priority on server 4 +``` +!!! Note + Replace the value of eth0 with the network interface on your system. \ No newline at end of file diff --git a/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/04_appendix_a.mdx b/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/04_appendix_a.mdx new file mode 100644 index 00000000000..5908076127f --- /dev/null +++ b/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/04_appendix_a.mdx @@ -0,0 +1,292 @@ +--- +title: "Integration Scripts" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/high-availability-scalability-guide/4.1/appendix_a.html" +--- + + + +## load_balancer_detach.sh + +```text +#!/bin/bash +#%h host name +output_file=/tmp/scripts/pp_log +pool_backend=/tmp/scripts/pgpool_backend.sh +node_address=$1 +current_date_time="`date +"%Y-%m-%d %H:%M:%S"`"; +echo $current_date_time >>$output_file +echo "node address to detach = $node_address". >>$output_file +$pool_backend detach $node_address >>$output_file +echo "-------------------".>>$output_file +exit 0 +``` + +## load_balancer_attach.sh + +```text +#!/bin/bash +#%h host name +output_file=/tmp/scripts/pp_log +pool_backend=/tmp/scripts/pgpool_backend.sh +node_address=$1 +current_date_time="`date +"%Y-%m-%d %H:%M:%S"`"; +echo $current_date_time >>$output_file +echo "node address to attach = $node_address". >>$output_file +$pool_backend attach $1 >>$output_file +echo "-------------------".>>$output_file +exit 0 +``` + +## follow_master.sh + +```text +#! /bin/sh +PCP_USER=USER_PLACEHOLDER +PCP_PORT=PORT_PLACEHOLDER +PCP_HOST=HOST_PLACEHOLDER +PGPOOL_PATH=/usr/edb/pgpool4.0/bin/ # Pgpool-II installed path +export PCPPASSFILE=/tmp/pcppass # Path to PCPPASS file +# Execute command by failover. +# special values: %d = node id +# %h = host name +# %p = port number +# %D = database cluster path +# %m = new master node id +# %M = old master node id +# %H = new master node host name +# %P = old primary node id +# %R = new master database cluster path +# %r = new master port number +# %% = '%' character +failed_node_id=$1 +old_master_id=$2 +echo failed_node_id $1 +echo old_master_id $2 +if [ $failed_node_id -ne $old_master_id ]; then + sleep 10 +$PGPOOL_PATH/pcp_attach_node -w -U $PCP_USER -h $PCP_HOST -p $PCP_ ˓→PORT $failed_node_id +fi +``` + +## pgpool_backend.sh + +```text +#!/bin/bash +# +# pgpool-II backend node configuration driver. +# +# usage: promote_standby.sh hostname [port] +# +# set the following variables according to your setup + +PCP_USER=USER_PLACEHOLDER # PCP user name +PCP_PORT=PORT_PLACEHOLDER # PCP port number as in pgpool.conf +PCP_HOST=HOST_PLACEHOLDER # hostname of Pgpool-II +PGPOOL_PATH=/usr/edb/pgpoolVERSION_PLACEHOLDER/bin/ # Pgpool-II installed path +export PCPPASSFILE=/var/pcppass # Path to PCPPASS file + +# function returns the Pgpool-II backend node-id for the given hostname +# and port number, And if the node-id is not found 255 is returned +# Arguments: +# 1- Hostname +# 2- Port (optional) if not provided, node-id of first matching +# hostname will be returned +# +function get_pgpool_nodeid_from_host { + if [ -z "$1" ]; then + echo "hostname not provided" + return 255 + fi + + #Now get the total number of nodes configured in Pgpool-II + node_count=`$PGPOOL_PATH/pcp_node_count -U $PCP_USER -h $PCP_HOST -p $PCP_PORT -w` + echo searching node-id for $1:$2 from $node_count configured backends + i=0 + while [ $i -lt $node_count ]; + do + nodeinfo=`$PGPOOL_PATH/pcp_node_info -U $PCP_USER -h $PCP_HOST -p $PCP_PORT -w $i` + hostname=`echo $nodeinfo | awk -v N=1 '{print $N}'` + port=`echo $nodeinfo | awk -v N=2 '{print $N}'` + #if port numbner is <= 0 we just need to compare hostname + if [ "$hostname" == $1 ] && ( [ -z "$2" ] || [ $port -eq $2 ] ); then + echo "$1:$2 has backend node-id = $i in Pgpool-II" + return $i + fi + let i=i+1 + done + return 255 +} + +# function returns 1 if Pgpool-II backend node for the given hostname +# and port number is the primary node in Pgpool-II +# returns 0 for the standby node and 255 if no node exist for the hostname +# Arguments: +# 1- Hostname +# 2- Port (optional) if not provided, node-id of first matching +# hostname will be returned +# +function is_host_is_primary_pgpool_node { + if [ -z "$1" ]; then + echo "hostname not provided" + return 255 + fi + + #Now get the total number of nodes configured in Pgpool-II + node_count=`$PGPOOL_PATH/pcp_node_count -U $PCP_USER -h $PCP_HOST -p $PCP_PORT -w` + echo searching node-id for $1:$2 from $node_count configured backends + i=0 + while [ $i -lt $node_count ]; + do + nodeinfo=`$PGPOOL_PATH/pcp_node_info -U $PCP_USER -h $PCP_HOST -p $PCP_PORT -w $i` + hostname=`echo $nodeinfo | awk -v N=1 '{print $N}'` + port=`echo $nodeinfo | awk -v N=2 '{print $N}'` + role=`echo $nodeinfo | awk -v N=6 '{print $N}'` + #if port numbner is <= 0 we just need to compare hostname + if [ "$hostname" == $1 ] && ( [ -z "$2" ] || [ $port -eq $2 ] ); then + echo "$1:$2 has backend node-id = $i in Pgpool-II" + # check if the node role is primary + if [ "$role" == "primary" ]; then + return 1 + else + return 0 + fi + fi + let i=i+1 + done + return 255 +} + +# Function promotes the node-id to the new master node +# Arguments: +# 1- node-id: Pgpool-II backend node-id of node to be promoted to master +function promote_node_id_to_master { + if [ -z "$1" ]; then + echo "node-id not provided" + return 255 + fi + $PGPOOL_PATH/pcp_promote_node -w -U $PCP_USER -h $PCP_HOST -p $PCP_PORT $1 + return $? +} + +# Function attach the node-id to the Pgpool-II +# Arguments +# 1- node-id: Pgpool-II backend node-id to be attached +function attach_node_id { + if [ -z "$1" ]; then + echo "node-id not provided" + return 255 + fi + $PGPOOL_PATH/pcp_attach_node -w -U $PCP_USER -h $PCP_HOST -p $PCP_PORT $1 + return $? +} + +# Function detach the node-id from the Pgpool-II +# Arguments +# 1- node-id: Pgpool-II backend node-id to be detached +function detach_node_id { + if [ -z "$1" ]; then + echo "node-id not provided" + return 255 + fi + $PGPOOL_PATH/pcp_detach_node -w -U $PCP_USER -h $PCP_HOST -p $PCP_PORT $1 + return $? +} + +# function promotes the standby node identified by hostname:port +# to the master node in Pgpool-II +# Arguments: +# 1- Hostname +# 2- Port (optional) if not provided, node-id of first matching +# hostname will be promoted +# +function promote_standby_to_master { + get_pgpool_nodeid_from_host $1 $2 + node_id=$? + if [ $node_id -eq 255 ]; then + echo unable to find Pgpool-II backend node id for $1:$2 + return 255 + else + echo promoting node-id: $node_id to master + promote_node_id_to_master $node_id + return $? + fi +} + +# function attaches the backend node identified by hostname:port +# to Pgpool-II +# Arguments: +# 1- Hostname +# 2- Port (optional) if not provided, node-id of first matching +# hostname will be promoted +# +function attach_node { + get_pgpool_nodeid_from_host $1 $2 + node_id=$? + if [ $node_id -eq 255 ]; then + echo unable to find Pgpool-II backend node id for $1:$2 + return 255 + else + echo attaching node-id: $node_id to Pgpool-II + attach_node_id $node_id + return $? + fi +} +# function detaches the backend node identified by hostname:port +# from Pgpool-II +# Arguments: +# 1- Hostname +# 2- Port (optional) if not provided, node-id of first matching +# hostname will be promoted +# +function detach_node { + get_pgpool_nodeid_from_host $1 $2 + node_id=$? + if [ $node_id -eq 255 ]; then + echo unable to find Pgpool-II backend node id for $1:$2 + return 255 + else + echo detaching node-id: $node_id from Pgpool-II + detach_node_id $node_id + return $? + fi +} + +function print_usage { + echo "usage:" + echo " $(basename $0) operation hostname [port]". + echo " operations:". + echo " check_primary: check if node has a primary role". + echo " promot: promote node". + echo " attach: attach node". + echo " detach: detach node". +} + +# script entry point +if [ -z "$1" ] || [ -z "$2" ]; then + echo "ERROR: operation not provided" + print_usage + exit 1 +fi +shopt -s nocasematch +case "$1" in + "check_primary" ) + is_host_is_primary_pgpool_node $2 $3 + ;; + "promote" ) echo "promote" + promote_standby_to_master $2 $3 + ;; + "attach" ) echo "attach" + attach_node $2 $3;; + "detach" ) echo "detach" + detach_node $2 $3;; + "watchdog" ) echo "detach" + $PGPOOL_PATH/pcp_watchdog_info -w -U $PCP_USER -h $PCP_HOST -p $PCP_PORT -v;; + *) echo "invalid operation $1". + print_usage;; + esac +exit $? + +``` \ No newline at end of file diff --git a/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/images/EDB_logo.png b/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/images/EDB_logo.png new file mode 100755 index 00000000000..739c43dccc4 Binary files /dev/null and b/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/images/EDB_logo.png differ diff --git a/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/images/EFM_PgPool_Azure.png b/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/images/EFM_PgPool_Azure.png new file mode 100644 index 00000000000..6a183c39450 Binary files /dev/null and b/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/images/EFM_PgPool_Azure.png differ diff --git a/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/images/backend_pools.png b/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/images/backend_pools.png new file mode 100644 index 00000000000..9ec8e018a7b Binary files /dev/null and b/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/images/backend_pools.png differ diff --git a/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/images/edb_ha_architecture.png b/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/images/edb_ha_architecture.png new file mode 100644 index 00000000000..fe4ff379e29 Binary files /dev/null and b/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/images/edb_ha_architecture.png differ diff --git a/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/images/edb_ha_architecture1.png b/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/images/edb_ha_architecture1.png new file mode 100755 index 00000000000..a496f59b161 Binary files /dev/null and b/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/images/edb_ha_architecture1.png differ diff --git a/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/images/edb_ha_architecture_separate_VM.png b/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/images/edb_ha_architecture_separate_VM.png new file mode 100644 index 00000000000..117ff2973b8 Binary files /dev/null and b/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/images/edb_ha_architecture_separate_VM.png differ diff --git a/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/images/edb_logo.svg b/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/images/edb_logo.svg new file mode 100755 index 00000000000..74babf2f8da --- /dev/null +++ b/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/images/edb_logo.svg @@ -0,0 +1,56 @@ + + + + +logo + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/images/failover_manager_overview.png b/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/images/failover_manager_overview.png new file mode 100755 index 00000000000..9c79c7bdfc9 Binary files /dev/null and b/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/images/failover_manager_overview.png differ diff --git a/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/images/health_probes.png b/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/images/health_probes.png new file mode 100644 index 00000000000..567f71828b3 Binary files /dev/null and b/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/images/health_probes.png differ diff --git a/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/images/load_balancing_rules.png b/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/images/load_balancing_rules.png new file mode 100644 index 00000000000..41ca798f440 Binary files /dev/null and b/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/images/load_balancing_rules.png differ diff --git a/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/images/placeholder.png b/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/images/placeholder.png new file mode 100755 index 00000000000..b83a03f80c5 Binary files /dev/null and b/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/images/placeholder.png differ diff --git a/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/images/rule_port_9898.png b/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/images/rule_port_9898.png new file mode 100644 index 00000000000..a69326a55f3 Binary files /dev/null and b/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/images/rule_port_9898.png differ diff --git a/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/images/rule_port_9999.png b/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/images/rule_port_9999.png new file mode 100644 index 00000000000..aebd897f798 Binary files /dev/null and b/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/images/rule_port_9999.png differ diff --git a/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/index.mdx b/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/index.mdx new file mode 100644 index 00000000000..5df92a42cee --- /dev/null +++ b/product_docs/docs/efm/4.0/efm_pgpool_ha_guide/index.mdx @@ -0,0 +1,18 @@ +--- +title: "High Availability & Scalability Guide" + +#legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + #- "/edb-docs/d/edb-postgres-failover-manager/user-guides/high-availability-scalability-guide/4.0/genindex.html" + #- "/edb-docs/d/edb-postgres-failover-manager/user-guides/high-availability-scalability-guide/4.0/introduction.html" + #- "/edb-docs/d/edb-postgres-failover-manager/user-guides/high-availability-scalability-guide/4.0/conclusion.html" + #- "/edb-docs/d/edb-postgres-failover-manager/user-guides/high-availability-scalability-guide/4.0/index.html" +--- + +Since high-availability and read scalability are not part of the core feature set of EDB Postgres Advanced Server, Advanced Server relies on external tools to provide this functionality. This document focuses on the functionality provided by EDB Failover Manager and Pgpool-II, and discusses the implications of a high-availability architecture formed around these tools. + +
+ +introduction architecture components_ha_pgpool appendix_a appendix_b conclusion + +
diff --git a/product_docs/docs/efm/4.0/efm_quick_start/images/edb_logo.png b/product_docs/docs/efm/4.0/efm_quick_start/images/edb_logo.png new file mode 100755 index 00000000000..b83a03f80c5 Binary files /dev/null and b/product_docs/docs/efm/4.0/efm_quick_start/images/edb_logo.png differ diff --git a/product_docs/docs/efm/4.0/efm_quick_start/images/edb_logo.svg b/product_docs/docs/efm/4.0/efm_quick_start/images/edb_logo.svg new file mode 100755 index 00000000000..74babf2f8da --- /dev/null +++ b/product_docs/docs/efm/4.0/efm_quick_start/images/edb_logo.svg @@ -0,0 +1,56 @@ + + + + +logo + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/product_docs/docs/efm/4.0/efm_quick_start/images/failover_manager_overview.png b/product_docs/docs/efm/4.0/efm_quick_start/images/failover_manager_overview.png new file mode 100755 index 00000000000..9c79c7bdfc9 Binary files /dev/null and b/product_docs/docs/efm/4.0/efm_quick_start/images/failover_manager_overview.png differ diff --git a/product_docs/docs/efm/4.0/efm_quick_start/images/placeholder.png b/product_docs/docs/efm/4.0/efm_quick_start/images/placeholder.png new file mode 100755 index 00000000000..b83a03f80c5 Binary files /dev/null and b/product_docs/docs/efm/4.0/efm_quick_start/images/placeholder.png differ diff --git a/product_docs/docs/efm/4.0/efm_quick_start/index.mdx b/product_docs/docs/efm/4.0/efm_quick_start/index.mdx new file mode 100644 index 00000000000..8b72367a915 --- /dev/null +++ b/product_docs/docs/efm/4.0/efm_quick_start/index.mdx @@ -0,0 +1,146 @@ +--- +title: "Creating a Failover Manager Cluster" + +#legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + #- "/edb-docs/d/edb-postgres-failover-manager/installation-getting-started/quick-start/4.0/genindex.html" + #- "/edb-docs/d/edb-postgres-failover-manager/installation-getting-started/quick-start/4.0/index.html" +--- + +EDB Postgres Failover Manager (Failover Manager) is a high-availability module from EnterpriseDB that enables a Postgres Primary node to automatically failover to a Standby node in the event of a software or hardware failure on the Primary. + +This quick start guide describes configuring a Failover Manager cluster in a test environment. You should read and understand the [EDB Failover Manager User's Guide](/efm/latest/) before configuring Failover Manager for a production deployment. + +You must perform some basic installation and configuration steps before performing this tutorial: + +- You must install and initialize a database server on one primary and one or two standby nodes; for information about installing Advanced Server, visit: + + [https://www.enterprisedb.com/docs/p/edb-postgres-advanced-server](/epas/latest/) + +- Postgres streaming replication must be configured and running between the primary and standby nodes. For detailed information about configuring streaming replication, visit: + + . + +- You must also install Failover Manager on each primary and standby node. During Advanced Server installation, you configured an EnterpriseDB repository on each database host. You can use the EnterpriseDB repository and the `yum install` command to install Failover Manager on each node of the cluster: + + ```text + yum install edb-efm40 + ``` + +During the installation process, the installer will create a user named `efm` that has sufficient privileges to invoke scripts that control the Failover Manager service for clusters owned by `enterprisedb` or `postgres`. The example that follows creates a cluster named `efm`. + +Start the configuration process on a primary or standby node. Then, copy the configuration files to other nodes to save time. + +**Step 1: Create Working Configuration Files** + +Copy the provided sample files to create EFM configuration files, and correct the ownership: + +```text +cd /etc/edb/efm-4.0 + +cp efm.properties.in efm.properties + +cp efm.nodes.in efm.nodes + +chown efm:efm efm.properties + +chown efm:efm efm.nodes +``` + +**Step 2: Create an Encrypted Password** + +Create the [encrypted password](/efm/latest/efm_user/04_configuring_efm/02_encrypting_database_password/) needed for the properties file: + +```text +/usr/edb/efm-4.0/bin/efm encrypt efm +``` + +Follow the onscreen instructions to produce the encrypted version of your database password. + +**Step 3: Update the efm.properties File** + +The `.properties` file (efm.properties file in this example) contains parameters that specify connection properties and behaviors for your Failover Manager cluster. Modifications to property settings are applied when Failover Manager starts. + +The properties mentioned in this tutorial are the minimal properties required to configure a Failover Manager cluster. If you are configuring a production system, please review the *EDB Failover Manager Guide* for detailed information about Failover Manager options. + +Provide values for the following properties on all cluster nodes: + +| Property | Description | +| ----------------------- | -------------------------------------------------------------------------------------------------------------------------------- | +| `db.user` | The name of the database user. | +| `db.password.encrypted` | The encrypted password of the database user. | +| `db.port` | The port monitored by the database. | +| `db.database` | The name of the database. | +| `db.service.owner` | The owner of the `data` directory (usually `postgres` or `enterprisedb`). Required only if the database is running as a service. | +| `db.service.name` | The name of the database service (used to restart the server). Required only if the database is running as a service. | +| `db.bin` | The path to the `bin` directory (used for calls to `pg_ctl`). | +| `db.recovery.dir` | The `data` directory in which EFM will find or create the `recovery.conf` file or the `standby.signal` file. | +| `user.email` | An email address at which to receive email notifications (notification text is also in the agent log file). | +| `bind.address` | The local address of the node and the port to use for EFM. The format is: `bind.address=1.2.3.4:7800` | +| `is.witness` | `true` on a witness node and `false` if it is a primary or standby. | +| `ping.server.ip` | If you are running on a network without Internet access, set `ping.server.ip` to an address that is available on your network. | +| `auto.allow.hosts` | On a test cluster, set to `true` to simplify startup; for production usage, consult the user's guide. | +| `stable.nodes.file` | On a test cluster, set to `true` to simplify startup; for production usage, consult the user's guide. | + +**Step 4: Update the efm.nodes File** + +The `.nodes` file (efm.nodes file in this example) is read at startup to tell an agent how to find the rest of the cluster or, in the case of the first node started, can be used to simplify authorization of subsequent nodes. Add the addresses and ports of each node in the cluster to this file. One node will act as the membership coordinator; the list should include at least the membership coordinator's address. For example: + + `1.2.3.4:7800` + + `1.2.3.5:7800` + + `1.2.3.6:7800` + +Please note that the Failover Manager agent will not verify the content of the `efm.nodes` file; the agent expects that some of the addresses in the file cannot be reached (e.g. that another agent hasn’t been started yet). + +**Step 5: Configure the Other Nodes** + +Copy the `efm.properties` and `efm.nodes` files to the `/etc/edb/efm-4.0` directory on the other nodes in your sample cluster. After copying the files, change the file ownership so the files are owned by `efm:efm`. The `efm.properties` file can be the same on every node, except for the following properties: + +- Modify the `bind.address` property to use the node’s local address. +- Set `is.witness` to `true` if the node is a witness node. If the node is a witness node, the properties relating to a local database installation will be ignored. + +**Step 6: Start the EFM Cluster** + +On any node, start the Failover Manager agent. The agent is named `edb-efm-4.0`; you can use your platform-specific service command to control the service. For example, on a CentOS/RHEL 7.x or CentOS/RHEL 8.x host use the command: + +```text +systemctl start edb-efm-4.0 +``` + +On a a CentOS or RHEL 6.x host use the command: + +```text +service edb-efm-4.0 start +``` + +After the agent starts, run the following command to see the status of the single-node cluster. You should see the addresses of the other nodes in the `Allowed node host` list. + +```text +/usr/edb/efm-4.0/bin/efm cluster-status efm +``` + +Start the agent on the other nodes. Run the `efm cluster-status efm` command on any node to see the cluster status. + +If any agent fails to start, see the startup log for information about what went wrong: + +```text +cat /var/log/efm-4.0/startup-efm.log +``` + +**Performing a Switchover** + +If the cluster status output shows that the primary and standby(s) are in sync, you can perform a switchover with the following command: + +```text +/usr/edb/efm-4.0/bin/efm promote efm -switchover +``` + +The command will promote a standby and reconfigure the primary database as a new standby in the cluster. To switch back, run the command again. + +For quick access to online help, you can invoke the following command: + +```text +/usr/edb/efm-4.0/bin/efm --help +``` diff --git a/product_docs/docs/efm/4.0/efm_user/01_whats_new.mdx b/product_docs/docs/efm/4.0/efm_user/01_whats_new.mdx new file mode 100644 index 00000000000..33bc9b3f8f5 --- /dev/null +++ b/product_docs/docs/efm/4.0/efm_user/01_whats_new.mdx @@ -0,0 +1,17 @@ +--- +title: "What’s New" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + #- "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.1/whats_new.html" +--- + + + +The following changes have been made to EDB Postgres Failover Manager to create version 4.0: + +- Encryption for database password has been improved. Encryption has also been enabled for communication between the agents. +- Standby servers are no longer stopped while selecting the new primary. This enhancement significantly speeds up the promotion process. +- To be consistent with community naming guidelines, the term Master has been replaced with Primary in the Failover Manager product and documentation. The upgrade-conf tool will handle the task of renaming the impacted properties post-upgrade. The load balancer scripts such as `script.load.balancer.attach`, `script.load. balancer.detach` will now accept character `p` instead of character `m` as an argument. +- Support has been added to delay the restart of standbys after a promotion. You can increase the availability by staggering the restart of standbys. +- A primary agent now attempts to resume health monitoring in a situation where the agent can not reach its local database but other agents can. diff --git a/product_docs/docs/efm/4.0/efm_user/02_failover_manager_overview/01_prerequisites.mdx b/product_docs/docs/efm/4.0/efm_user/02_failover_manager_overview/01_prerequisites.mdx new file mode 100644 index 00000000000..dff775c99ff --- /dev/null +++ b/product_docs/docs/efm/4.0/efm_user/02_failover_manager_overview/01_prerequisites.mdx @@ -0,0 +1,102 @@ +--- +title: "Prerequisites" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.1/prerequisites.html" +--- + + + +Before configuring a Failover Manager cluster, you must satisfy the prerequisites described below. + +**Install Java 1.8 (or later)** + +Before using Failover Manager, you must first install Java (version 1.8 or later). Failover Manager is tested with OpenJDK, and we strongly recommend installing that version of Java. [Installation instructions for Java](https://openjdk.java.net/install/) are platform specific. + +**Provide an SMTP Server** + +You can receive notifications from Failover Manager as specified by a user-defined notification script, by email, or both. + +- If you are using email notifications, an SMTP server must be running on each node of the Failover Manager scenario. +- If you provide a value in the script.notification property, you can leave the user.email field blank; an SMTP server is not required. + +If an event occurs, Failover Manager invokes the script (if provided), and can also send a notification email to any email addresses specified in the user.email parameter of the cluster properties file. For more information about using an SMTP server, visit: + +[https://access.redhat.com/site/documentation](https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/s1-email-mta.html) + +**Configure Streaming Replication** + +Failover Manager requires that PostgreSQL streaming replication be configured between the Primary node and the Standby node or nodes. Failover Manager does not support other types of replication. + +On database versions 11 (or prior), unless specified with the `-sourcenode` option, a `recovery.conf` file is copied from a random standby node to the stopped primary during switchover. You should ensure that the paths within the `recovery.conf` file on your standby nodes are consistent before performing a switchover. For more information about the `-sourcenode` option, please see [Promoting a Failover Manager Node](../05_using_efm/#promote_node). + +On database version 12 or later, the `primary_conninfo` and `restore_command` properties are copied from a random standby node to the stopped primary during switchover (unless otherwise specified with the `-sourcenode` option). + +**Modify the pg_hba.conf File** + +You must modify the `pg_hba.conf` file on the Primary and Standby nodes, adding entries that allow communication between the all of the nodes in the cluster. The following example demonstrates entries that might be made to the pg_hba.conf file on the Primary node: + +```text +# access for itself +host fmdb efm 127.0.0.1/32 md5 +# access for standby +host fmdb efm 192.168.27.1/32 md5 +# access for witness +host fmdb efm 192.168.27.34/32 md5 +``` + +Where: + + `efm` specifies the name of a valid database user. + + `fmdb` specifies the name of a database to which the efm user may connect. + +By default, the `pg_hba.conf` file resides in the `data` directory, under your Postgres installation. After modifying the `pg_hba.conf` file, you must reload the configuration file on each node for the changes to take effect. You can use the following command: + + `# systemctl reload edb-as-x` + +Where `x` specifies the Postgres version. + +**Using Autostart for the Database Servers** + +If a Primary node reboots, Failover Manager may detect the database is down on the Primary node and promote a Standby node to the role of Primary. If this happens, the Failover Manager agent on the (rebooted) Primary node will not get a chance to write the `recovery.conf` file; the `recovery.conf` file prevents the database server from starting. If this happens, the rebooted Primary node will return to the cluster as a second Primary node. + +To prevent this, ensure that the Failover Manager agent auto starts before the database server. The agent will start in idle mode, and check to see if there is already a primary in the cluster. If there is a primary node, the agent will verify that a `recovery.conf` or `standby.signal` file exists, and the database will not start as a second primary. + +**Ensure Communication Through Firewalls** + +If a Linux firewall (i.e. iptables) is enabled on the host of a Failover Manager node, you may need to add rules to the firewall configuration that allow tcp communication between the Failover Manager processes in the cluster. For example: + +```text +# iptables -I INPUT -p tcp --dport 7800 -j ACCEPT +/sbin/service iptables save +``` + +The command shown above opens the port 7800. Failover Manager will connect via the port that corresponds to the port specified in the cluster properties file. + +**Ensure that the Database user has Sufficient Privileges** + +The database user specified by the `db.user` property in the `efm.properties` file must have sufficient privileges to invoke the following functions on behalf of Failover Manager: + + `pg_current_wal_lsn()` + + `pg_last_wal_replay_lsn()` + + `pg_wal_replay_resume()` + + `pg_wal_replay_pause()` + + `pg_reload_conf()` + +The `pg_reload_conf()` privilege is required only if you have the `reconfigure.num.sync` or `reconfigure.sync.primary` property set to `true`. + +For detailed information about each of these functions, please see the [PostgreSQL core documentation](https://www.postgresql.org/docs/current/index.html). + +The user must also have permissions to read the values of configuration variables; a database superuser can use the PostgreSQL `GRANT` command to provide the permissions needed: + +```text +GRANT pg_read_all_settings TO user_name; +``` + +For more information about `pg_read_all_settings`, please see the [PostgreSQL core documentation](https://www.postgresql.org/docs/current/default-roles.html). diff --git a/product_docs/docs/efm/4.0/efm_user/02_failover_manager_overview/index.mdx b/product_docs/docs/efm/4.0/efm_user/02_failover_manager_overview/index.mdx new file mode 100644 index 00000000000..fac4ec73d30 --- /dev/null +++ b/product_docs/docs/efm/4.0/efm_user/02_failover_manager_overview/index.mdx @@ -0,0 +1,37 @@ +--- +title: "Failover Manager Overview" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.1/failover_manager_overview.html" +--- + + + +An EDB Postgres Failover Manager (EFM) cluster is comprised of Failover Manager processes that reside on the following hosts on a network: + +- A Primary node - The Primary node is the primary database server that is servicing database clients. +- One or more Standby nodes - A Standby node is a streaming replication server associated with the Primary node. +- A Witness node - The Witness node confirms assertions of either the Primary or a Standby in a failover scenario. A cluster does not need a dedicated witness node if the cluster contains three or more nodes. If you do not have a third cluster member that is a database host, you can add a dedicated Witness node. A cluster may include more than one witness node. + +Traditionally, a *cluster* is a single instance of Postgres managing multiple databases. In this document, the term cluster refers to a Failover Manager cluster. A Failover Manager cluster consists of a Primary agent, one or more Standby agents, and an optional Witness agent that reside on servers in a cloud or on a traditional network and communicate using the JGroups toolkit. + +![An EFM scenario employing a Virtual IP address.](../images/failover_manager_overview.png) + +When a non-witness agent starts, it connects to the local database and checks the state of the database: + +- If the agent cannot reach the database, it will start in idle mode. +- If it finds that the database is in recovery, the agent assumes the role of standby. +- If the database is not in recovery, the agent assumes the role of primary. + +In the event of a failover, Failover Manager attempts to ensure that the promoted standby is the most up-to-date standby in the cluster; please note that data loss is possible if the standby node is not in sync with the primary node. + +[JGroups](http://www.jgroups.org/) provides technology that allows Failover Manager to create clusters whose member nodes can communicate with each other and detect node failures. + +The figure shown above illustrates a Failover Manager cluster that employs a virtual IP address. You can use a load balancer in place of a [virtual IP address](../04_configuring_efm/05_using_vip_addresses/#using_vip_addresses) if you provide your own [script](../04_configuring_efm/01_cluster_properties/#cluster_properties) to re-configure the load balancer whenever databases are added or removed. You can also choose to enable native EFM-Pgpool integration for high availability. + +
+ +prerequisites + +
diff --git a/product_docs/docs/efm/4.0/efm_user/03_installing_efm.mdx b/product_docs/docs/efm/4.0/efm_user/03_installing_efm.mdx new file mode 100644 index 00000000000..add844dddfe --- /dev/null +++ b/product_docs/docs/efm/4.0/efm_user/03_installing_efm.mdx @@ -0,0 +1,315 @@ +--- +title: "Installing Failover Manager" +legacyRedirects: + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.0/installing_debian_ubuntu.html" + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.0/installing_sles.html" + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.0/post_install_tasks.html" + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.0/installing_rhel_centos_oel.html" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.0/installing_efm.html" +--- + + + + + +To request credentials that allow you to access an EnterpriseDB repository, visit the EDB website at: + + + +## RedHat or CentOS Host + +When you install an RPM package that is signed by a source that is not recognized by your system, yum may ask for your permission to import the key to your local server. If prompted, and you are satisfied that the packages come from a trustworthy source, enter y, and press Return to continue. + +During the installation, yum may encounter a dependency that it cannot resolve. If it does, it will provide a list of the required dependencies that you must manually resolve. + +Failover Manager must be installed by root. During the installation process, the installer will also create a user named efm that has sufficient privileges to invoke scripts that control the Failover Manager service for clusters owned by enterprisedb or postgres. + +After receiving your credentials, you must create the EnterpriseDB repository configuration file on each node of the cluster, and then modify the file to enable access. The following steps provide detailed information about accessing the EnterpriseDB repository; the steps must be performed on each node of the cluster. + +### RHEL or CentOS 7 PPCLE Host + +1. Use the following command to create a configuration file and install Advance Toolchain: + + ```text + rpm --import https://public.dhe.ibm.com/software/server/POWER/Linux/toolchain/at/redhat/RHEL7/gpg-pubkey-6976a827-5164221b + + cat > /etc/yum.repos.d/advance-toolchain.repo <:@USERNAME:PASSWORD@" /etc/yum.repos.d/edb.repo + ``` + +4. Install the EPEL repository: + + ```text + yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm + ``` + +5. On RHEL 7 PPCLE, enable the additional repositories to resolve EPEL dependencies: + + ```text + subscription-manager repos --enable "rhel-*-optional-rpms" --enable "rhel-*-extras-rpms" --enable "rhel-ha-for-rhel-*-server-rpms" + ``` + +6. Install the selected package: + + ```text + yum -y install edb-efm40 + ``` + +### RHEL or CentOS 7 Host + +1. To create the repository configuration file, assume superuser privileges, and invoke the following command: + + ```text + yum -y install https://yum.enterprisedb.com/edbrepos/edb-repo-latest.noarch.rpm + ``` + +2. Replace ‘USERNAME:PASSWORD’ below with your username and password for the EDB repositories: + + ```text + sed -i "s@:@USERNAME:PASSWORD@" /etc/yum.repos.d/edb.repo + ``` + +3. Install the EPEL repository: + + ```text + yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm + ``` + +4. On RHEL 7, enable the additional repositories to resolve dependencies: + + ```text + subscription-manager repos --enable "rhel-*-optional-rpms" --enable "rhel-*-extras-rpms" --enable "rhel-ha-for-rhel-*-server-rpms" + ``` + +5. Install the selected package: + + ```text + yum -y install edb-efm40 + ``` + +### RHEL or CentOS 8 Host + +1. To create the repository configuration file, assume superuser privileges, and invoke the following command: + ```text + dnf -y install https://yum.enterprisedb.com/edbrepos/edb-repo-latest.noarch.rpm + ``` + +2. Replace ‘USERNAME:PASSWORD’ below with your username and password for the EDB repositories: + + ```text + sed -i "s@:@USERNAME:PASSWORD@" /etc/yum.repos.d/edb.repo + ``` + +3. Install the EPEL repository: + +- On CentOS 8 + ```text + dnf -y install epel-release + ``` +- On RHEL 8 + ```text + dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm + ``` + +4. Enable the additional repositories to resolve dependencies: + +- On CentOS 8 + ```text + dnf config-manager --set-enabled PowerTools + ``` +- On RHEL 8 + + ```text + ARCH=$( /bin/arch ) subscription-manager repos --enable "codeready-builder-for-rhel-8-${ARCH}-rpms" + ``` + +5. Disable the built-in PostgreSQL module: + + ```text + dnf -qy module disable postgresql + ``` +6. Install the selected package: + ```text + dnf -y install edb-efm40 + ``` + +## Debian or Ubuntu Host + +To install Failover Manager, you must have credentials that allow access to the EnterpriseDB repository. To request credentials for the repository, visit the EnterpriseDB website at: + + + +The following steps will walk you through using the EnterpriseDB apt repository to install Failover Manager. + +### Debian Host + +1. Assume superuser privileges: + ```text + sudo su – + ``` +2. Configure the EnterpriseDB repository by substituting your EnterpriseDB credentials for the username and password placeholders in the following commands: + +- On Debian 9 + ```text + sh -c 'echo "deb https://username:password@apt.enterprisedb.com/$(lsb_release -cs)-edb/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/edb-$(lsb_release -cs).list' + ``` +- On Debian 10 + + ```text + sh -c 'echo "deb [arch=amd64] https://apt.enterprisedb.com/$(lsb_release -cs)-edb/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/edb-$(lsb_release -cs).list' + + sh -c 'echo "machine apt.enterprisedb.com login password " > /etc/apt/auth.conf.d/edb.conf' + ``` + +3. Add support to your system for secure APT repositories: + ```text + apt-get install apt-transport-https + ``` +4. Add the EDB signing key: + ```text + wget -q -O - https://:@apt.enterprisedb.com/edb-deb.gpg.key | apt-key add - + ``` +5. Update the repository meta data: + ```text + apt-get update + ``` +6. Install Failover Manager: + ```text + apt-get -y install edb-efm40 + ``` + +### Ububtu Host + +1. Assume superuser privileges: + ```text + sudo su – + ``` +2. Configure the EnterpriseDB repository by substituting your EnterpriseDB credentials for the username and password placeholders in the following commands: + +- On Ubuntu 18.04 + ```text + sh -c 'echo "deb https://username:password@apt.enterprisedb.com/$(lsb_release -cs)-edb/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/edb-$(lsb_release -cs).list' + ``` +- On Ubuntu 20.4 + + ```text + sh -c 'echo "deb [arch=amd64] https://apt.enterprisedb.com/$(lsb_release -cs)-edb/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/edb-$(lsb_release -cs).list' + + sh -c 'echo "machine apt.enterprisedb.com login password " > /etc/apt/auth.conf.d/edb.conf' + ``` + +3. Add support to your system for secure APT repositories: + ```text + apt-get install apt-transport-https + ``` +4. Add the EDB signing key: + ```text + wget -q -O - https://:@apt.enterprisedb.com/edb-deb.gpg.key | apt-key add - + ``` +5. Update the repository meta data: + ```text + apt-get update + ``` +6. Install Failover Manager: + ```text + apt-get -y install edb-efm40 + ``` + +## SLES Host + +To install Failover Manager, you must have credentials that allow access to the EnterpriseDB repository. To request credentials for the repository, visit the EnterpriseDB website at: + + + +You can use the zypper package manager to install a Failover Manager agent on an SLES 12 host. zypper will attempt to satisfy package dependencies as it installs a package, but requires access to specific repositories that are not hosted at EnterpriseDB. + +1. You must assume superuser privileges and stop any firewalls before installing Failover Manager. Then, use the following commands to add EnterpriseDB repositories to your system: + + ```text + zypper addrepo https://zypp.enterprisedb.com/suse/edb-sles.repo + ``` + +2. The commands create the repository configuration files in the /etc/zypp/repos.d directory. Then, use the following command to refresh the metadata on your SLES host to include the EnterpriseDB repository: + + ```text + zypper refresh + ``` + + When prompted, provide credentials for the repository, and specify a to always trust the provided key, and update the metadata to include the EnterpriseDB repository. + +3. You must also add SUSEConnect and the SUSE Package Hub extension to the SLES host, and register the host with SUSE, allowing access to SUSE repositories. Use the commands: + + ```text + zypper install SUSEConnect + SUSEConnect -r -e + SUSEConnect -p PackageHub/12.4/x86_64 + SUSEConnect -p sle-sdk/12.4/x86_64 + ``` + +4. Install SUSEConnect to register the host with SUSE, allowing access to SUSE repositories: + + ```text + zypper addrepo https://download.opensuse.org/repositories/Apache:/Modules/SLE_12_SP4/Apache:Modules.repo + ``` + +5. Install OpenJDK (version 1.8) for Java based components: + + ```text + zypper -n install java-1_8_0-openjdk + ``` + +6. Now you can use the zypper utility to install a Failover Manager agent: + + ```text + zypper -n install edb-efm40 + ``` + +## Performing post-installation tasks + +If you are using Failover Manager to monitor a cluster owned by a user other than `enterprisedb` or `postgres`, see [Extending Failover Manager Permissions](04_configuring_efm/04_extending_efm_permissions/#extending_efm_permissions) . + +After installing on each node of the cluster, you must: + +1. Modify the [cluster properties file](04_configuring_efm/01_cluster_properties/#cluster_properties) on each node. +2. Modify the [cluster members file](04_configuring_efm/03_cluster_members/#cluster_members) on each node. +3. If applicable, configure and test virtual IP address settings and any scripts that are identified in the cluster properties file. +4. Start the agent on each node of the cluster. For more information about controlling the service, see [Section 5](08_controlling_efm_service/#controlling-the-failover-manager-service). + +### Installation Locations + +components are installed in the following locations: + +| Component | Location | +| --------------------------------- | --------------------------- | +| Executables | /usr/edb/efm-4.0/bin | +| Libraries | /usr/edb/efm-4.0/lib | +| Cluster configuration files | /etc/edb/efm-4.0 | +| Logs | /var/log/efm- 4.0 | +| Lock files | /var/lock/efm-4.0 | +| Log rotation file | /etc/logrotate.d/efm-4.0 | +| sudo configuration file | /etc/sudoers.d/efm-40 | +| Binary to access VIP without sudo | /usr/edb/efm-4.0/bin/secure | diff --git a/product_docs/docs/efm/4.0/efm_user/04_configuring_efm/01_cluster_properties/01_encrypting_database_password.mdx b/product_docs/docs/efm/4.0/efm_user/04_configuring_efm/01_cluster_properties/01_encrypting_database_password.mdx new file mode 100644 index 00000000000..77f0a39f8c9 --- /dev/null +++ b/product_docs/docs/efm/4.0/efm_user/04_configuring_efm/01_cluster_properties/01_encrypting_database_password.mdx @@ -0,0 +1,77 @@ +--- +title: "Encrypting Your Database Password" +--- + + + +Failover Manager requires you to encrypt your database password before including it in the cluster properties file. Use the [efm utility](../../07_using_efm_utility/#efm_encrypt) (located in the `/usr/edb/efm-4.0/bin` directory) to encrypt the password. When encrypting a password, you can either pass the password on the command line when you invoke the utility, or use the `EFMPASS` environment variable. + +To encrypt a password, use the command: + +```text +# efm encrypt [ --from-env ] +``` + +Where `` specifies the name of the Failover Manager cluster. + +If you include the `--from-env` option, you must export the value you wish to encrypt before invoking the encryption utility. For example: + +```text +export EFMPASS=password +``` + +If you do not include the `--from-env` option, Failover Manager will prompt you to enter the database password twice before generating an encrypted password for you to place in your cluster property file. When the utility shares the encrypted password, copy and paste the encrypted password into the cluster property files. + +!!! Note + Many Java vendors ship their version of Java with full-strength encryption included, but not enabled due to export restrictions. If you encounter an error that refers to an illegal key size when attempting to encrypt the database password, you should download and enable a Java Cryptography Extension (JCE) that provides an unlimited policy for your platform. + +The following example demonstrates using the encrypt utility to encrypt a password for the `acctg` cluster: + +```text +# efm encrypt acctg +This utility will generate an encrypted password for you to place in + your EFM cluster property file: +/etc/edb/efm-4.0/acctg.properties +Please enter the password and hit enter: +Please enter the password again to confirm: +The encrypted password is: 516b36fb8031da17cfbc010f7d09359c +Please paste this into your acctg.properties file +db.password.encrypted=516b36fb8031da17cfbc010f7d09359c +``` + +!!! Note + The utility will notify you if a properties file does not exist. + +After receiving your encrypted password, paste the password into the properties file and start the Failover Manager service. If there is a problem with the encrypted password, the Failover Manager service will not start: + +```text +[witness@localhost ~]# systemctl start edb-efm-4.0 +Job for edb-efm-4.0.service failed because the control process exited with error code. See "systemctl status edb-efm-4.0.service" and "journalctl -xe" for details. +``` + +If you receive this message when starting the Failover Manager service, please see the startup log (located in `/var/log/efm-4.0/startup-efm.log`) for more information. + +If you are using RHEL/CentOS 7.x or RHEL/CentOS 8.x, startup information is also available with the following command: + +```text +systemctl status edb-efm-4.0 +``` + +To prevent a cluster from inadvertently connecting to the database of another cluster, the cluster name is incorporated into the encrypted password. If you modify the cluster name, you will need to re-encrypt the database password and update the cluster properties file. + +**Using the EFMPASS Environment Variable** + +The following example demonstrates using the --from-env environment variable when encrypting a password. Before invoking the `efm encrypt` command, set the value of `EFMPASS` to the password (`1safepassword`): + +```text +# export EFMPASS=1safepassword +``` + +Then, invoke `efm encrypt`, specifying the `--from-env` option: + +```text +# efm encrypt acctg --from-env +# 7ceecd8965fa7a5c330eaa9e43696f83 +``` + +The encrypted password (`7ceecd8965fa7a5c330eaa9e43696f83`) is returned as a text value; when using a script, you can check the exit code of the command to confirm that the command succeeded. A successful execution returns `0`. diff --git a/product_docs/docs/efm/4.0/efm_user/04_configuring_efm/01_cluster_properties/index.mdx b/product_docs/docs/efm/4.0/efm_user/04_configuring_efm/01_cluster_properties/index.mdx new file mode 100644 index 00000000000..a447ad897d6 --- /dev/null +++ b/product_docs/docs/efm/4.0/efm_user/04_configuring_efm/01_cluster_properties/index.mdx @@ -0,0 +1,1186 @@ +--- +title: "The Cluster Properties File" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.0/cluster_properties.html" +--- + + + +Each node in a Failover Manager cluster has a properties file (by default, named `efm.properties`) that contains the properties of the individual node on which it resides. The Failover Manager installer creates a file template for the properties file named `efm.properties.in` in the `/etc/edb/efm-4.0` directory. + +After completing the Failover Manager installation, you must make a working copy of the template before modifying the file contents: + +```text +# cp /etc/edb/efm-4.0/efm.properties.in /etc/edb/efm-4.0/efm.properties +``` + +After copying the template file, change the owner of the file to `efm`: + +```text +# chown efm:efm efm.properties +``` + +!!! Note + By default, Failover Manager expects the cluster properties file to be named `efm.properties`. If you name the properties file something other than `efm.properties`, you must modify the service script or unit file to instruct Failover Manager to use a different name. + +After creating the cluster properties file, add (or modify) configuration parameter values as required. For detailed information about each property, see [Specifying Cluster Properties](#specifying-cluster-properties). + +The property files are owned by `root`. The Failover Manager service script expects to find the files in the `/etc/edb/efm-4.0 directory`. If you move the property file to another location, you must create a symbolic link that specifies the new location. + +!!! Note + All user scripts referenced in the properties file will be invoked as the Failover Manager user. + + + +## Specifying Cluster Properties + +You can use the properties listed in the cluster properties file to specify connection properties and behaviors for your Failover Manager cluster. Modifications to property settings will be applied when Failover Manager starts. If you modify a property value you must restart Failover Manager to apply the changes. + +Property values are case-sensitive. Note that while Postgres uses quoted strings in parameter values, Failover Manager does not allow quoted strings in property values. For example, while you might specify an IP address in a Postgres configuration parameter as: + +> `listen_addresses='192.168.2.47'` + +Failover Manager requires that the value *not* be enclosed in quotes: + +> `bind.address=192.168.2.54:7800` + +Use the properties in the `efm.properties` file to specify connection, administrative, and operational details for Failover Manager. + +**Legends**: In the following table: + +- `A`: Required on Primary or Standby node +- `W`: Required on Witness node +- `Y` : Yes + +| **Property Name** | **A** | **W** | **Default Value** | **Comments** | +| ------------------------------------------------------------- | ----- | ----- | ------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [db.user](#db_user) | Y | Y | | Username for the database | +| [db.password.encrypted](#db_password_encrypted) | Y | Y | | Password encrypted using 'efm encrypt' | +| [db.port](#db_port) | Y | Y | | This value must be same for all the agents | +| [db.database](#db_database) | Y | Y | | Database name | +| [db.service.owner](#db_service_owner) | Y | | | Owner of $PGDATA dir for db.database | +| [db.service.name](#db_service_name) | | | | Required if running the database as a service | +| [db.bin](#db_bin) | Y | | | Directory containing the pg_controldata/pg_ctl commands such as '/usr/edb/as12/bin' | +| [db.data.dir](#db_data_dir) | Y | | | Same as the output of query 'show data_directory;' | +| [db.config.dir](#db_config_dir) | | | | Same as the output of query 'show config_file;'. Should be specified if it is not same as *db.data.dir* | +| [jdbc.sslmode](#jdbc_sslmode) | Y | Y | disable | See the [note](#jdbc_note) | +| [user.email](#user_email) | | | | This value must be same for all the agents; can be left blank if using a notification script | +| [from.email](#from_email) | | | [efm@localhost](mailto:efm@localhost) | Leave blank to use the default [efm@localhost](mailto:efm@localhost) | +| [notification.level](#notification_level) | Y | Y | INFO | See the [list of notifications](../../10_notifications/#notifications) | +| [notification.text.prefix](#notification_text_prefix) | | | | | +| [script.notification](#script_notification) | | | | Required if user.email property is not used; both parameters can be used together | +| [bind.address](#bind_address) | Y | Y | | Example: <ip_address>:<port> | +| [external.address](#external_address) | | | | Example: <ip_address/hostname> | +| [admin.port](#admin_port) | Y | Y | 7809 | Modify if the default port is already in use | +| [is.witness](#is_witness) | Y | Y | | See description | +| [local.period](#local_period) | Y | | 10 | | +| [local.timeout](#local_timeout) | Y | | 60 | | +| [local.timeout.final](#local_timeout_final) | Y | | 10 | | +| [remote.timeout](#remote_timeout) | Y | Y | 10 | | +| [node.timeout](#node_timeout) | Y | Y | 50 | This value must be same for all the agents | +| [encrypt.agent.messages](#encrypt_agent_messages) | Y | Y | false | This value must be same for all the agents | +| [stop.isolated.primary](#stop_isolated_primary) | Y | | true | | +| [stop.failed.primary](#stop_failed_primary) | Y | | true | | +| [primary.shutdown.as.failure](#primary_shutdown_as_failure) | Y | Y | false | | +| [update.physical.slots.period](#update_physical_slots_period) | Y | | 0 | | +| [ping.server.ip](#ping_server_ip) | Y | Y | 8.8.8.8 | | +| [ping.server.command](#ping_server_command) | Y | Y | /bin/ping -q -c3 -w5 | | +| [auto.allow.hosts](#auto_allow_hosts) | Y | Y | false | | +| [stable.nodes.file](#stable_nodes_file) | Y | Y | false | | +| [db.reuse.connection.count](#db_reuse_connection_count) | Y | | 0 | | +| [auto.failover](#auto_failover) | Y | Y | true | | +| [auto.reconfigure](#auto_reconfigure) | Y | | true | This value must be same for all the agents | +| [promotable](#promotable) | Y | | true | | +| [use.replay.tiebreaker](#use_replay_tiebreaker) | Y | Y | true | This value must be same for all the agents | +| [standby.restart.delay](#standby_restart_delay) | | | 0 | | +| [application.name](#application_name) | | | | Set to replace the application_name portion of the primary_conninfo entry with this property value before starting the original primary database as a standby. | +| [restore.command](#restore_command) | | | | Example: restore.command=scp <db_service_owner>@%h: <archive_path>/%f %p | +| [reconfigure.num.sync](#reconfigure_num_sync) | Y | | false | | +| [reconfigure.sync.primary](#reconfigure_sync_primary) | Y | | false | | +| [minimum.standbys](#minimum_standbys) | Y | Y | 0 | This value must be same for all the nodes | +| [recovery.check.period](#recovery_check_period) | Y | | 1 | | +| [restart.connection.timeout](#restart_connection_timeout) | | | 60 | | +| [auto.resume.period](#auto_resume_period) | Y | | 0 | | +| [virtual.ip](#virtual_ip) | | | (see virtual.ip.single) | Leave blank if you do not specify a VIP | +| [virtual.ip.interface](#virtual_ip) | | | | Required if you specify a VIP | +| [virtual.ip.prefix](#virtual_ip) | | | | Required if you specify a VIP | +| [virtual.ip.single](#virtual_ip) | Y | Y | Yes | This value must be same for all the nodes | +| [check.vip.before.promotion](#check_vip_before_promotion) | Y | Y | Yes | | +| [script.load.balancer.attach](#script_load_balancer) | | | | Example: script.load.balancer.attach= /<path>/<attach_script> %h %t | +| [script.load.balancer.detach](#script_load_balancer) | | | | Example: script.load.balancer.detach= /<path>/<detach_script> %h %t | +| [script.fence](#script_fence) | | | | Example: script.fence= /<path>/<script_name> %p %f | +| [script.post.promotion](#script_post_promotion) | | | | Example: script.post.promotion= /<path>/<script_name> %f %p | +| [script.resumed](#script_resumed) | | | | Example: script.resumed= /<path>/<script_name> | +| [script.db.failure](#script_db_failure) | | | | Example: script.db.failure= /<path>/<script_name> | +| [script.primary.isolated](#script_primary_isolated) | | | | Example: script.primary.isolated= /<path>/<script_name> | +| [script.remote.pre.promotion](#script_remote_pre_promotion) | | | | Example: script.remote.pre.promotion= /<path>/<script_name> %p | +| [script.remote.post.promotion](#script_remote_post_promotion) | | | | Example: script.remote.post.promotion= /<path>/<script_name> %p | +| [script.custom.monitor](#script_custom_monitor) | | | | Example: script.custom.monitor= /<path>/<script_name> | +| [custom.monitor.interval](#script_custom_monitor) | | | | Required if a custom monitoring script is specified | +| [custom.monitor.timeout](#script_custom_monitor) | | | | Required if a custom monitoring script is specified | +| [custom.monitor.safe.mode](#script_custom_monitor) | | | | Required if a custom monitoring script is specified | +| [sudo.command](#sudo_command) | Y | Y | sudo | | +| [sudo.user.command](#sudo_command) | Y | Y | sudo -u %u | | +| [lock.dir](#lock_dir) | | | | If not specified, defaults to '/var/lock/efm-<version>' | +| [log.dir](#log_dir) | | | | If not specified, defaults to '/var/log/efm-<version>' | +| [syslog.host](#syslog_logging) | | | localhost | | +| [syslog.port](#syslog_logging) | | | 514 | | +| [syslog.protocol](#syslog_logging) | | | | | +| [syslog.facility](#syslog_logging) | | | UDP | | +| [file.log.enabled](#logtype_enabled) | Y | Y | true | | +| [syslog.enabled](#logtype_enabled) | Y | Y | false | | +| [jgroups.loglevel](#loglevel) | | | info | | +| [efm.loglevel](#loglevel) | | | info | | +| [jvm.options](#jvm_options) | | | -Xmx128m | | + +**Cluster Properties** + + + + + + + + + +Use the following properties to specify connection details for the Failover Manager cluster: + +```text +# The value for the password property should be the output from +# 'efm encrypt' -- do not include a cleartext password here. To +# prevent accidental sharing of passwords among clusters, the +# cluster name is incorporated into the encrypted password. If +# you change the cluster name (the name of this file), you must +# encrypt the password again with the new name. +# The db.port property must be the same for all nodes. +db.user= +db.password.encrypted= +db.port= +db.database= +``` + +The `db.user` specified must have sufficient privileges to invoke selected PostgreSQL commands on behalf of Failover Manager. For more information, please see [Prerequisites](../../02_failover_manager_overview/01_prerequisites/#prerequisites). + +For information about encrypting the password for the database user, see [Encrypting Your Database Password](01_encrypting_database_password/#encrypting_database_password). + + + +Use the `db.service.owner` property to specify the name of the operating system user that owns the cluster that is being managed by Failover Manager. This property is not required on a dedicated witness node. + +```text +# This property tells EFM which OS user owns the $PGDATA dir for +# the 'db.database'. By default, the owner is either 'postgres' +# for PostgreSQL or 'enterprisedb' for EDB Postgres Advanced +# Server. However, if you have configured your db to run as a +# different user, you will need to copy the /etc/sudoers.d/efm-XX +# conf file to grant the necessary permissions to your db owner. +# +# This username must have write permission to the +# 'db.data.dir' specified below. +db.service.owner= +``` + + + +Specify the name of the database service in the `db.service.name` property if you use the service or systemctl command when starting or stopping the service. + +```text +# Specify the proper service name in order to use service commands +# rather than pg_ctl to start/stop/restart a database. For example, if +# this property is set, then 'service restart' or 'systemctl +# restart ' +# (depending on OS version) will be used to restart the database rather +# than pg_ctl. +# This property is required if running the database as a service. +db.service.name= +``` + + + +You should use the same service control mechanism (pg_ctl, service, or systemctl) each time you start or stop the database service. If you use the `pg_ctl` program to control the service, specify the location of the `pg_ctl` program in the `db.bin` property. + +```text +# Specify the directory containing the pg_controldata/pg_ctl commands, +# for example: +# /usr/edb/as11/bin. Unless the db.service.name property is used, the +# pg_ctl command is used to start/stop/restart databases as needed +# after a failover or switchover. This property is required. +db.bin= +``` + + + +Use the `db.data.dir` property to specify the location to which a recovery file will be written on the Primary node of the cluster during promotion. This property is required on primary and standby nodes; it is not required on a dedicated witness node. + +```text +# For database version 12 and up, this is the directory where a +# standby.signal file will exist for a standby node. For previous +# versions, this is the location of the db recovery.conf file on +# the node. +# After a failover, the recovery.conf files on remaining standbys are +# changed to point to the new primary db (a copy of the original is made +# first). On a primary node, a recovery.conf file will be written during +# failover and promotion to ensure that the primary node can not be +# restarted as the primary database. +# This corresponds to database environment variable PGDATA and should +# be same as the output of query 'show data_directory;' on respective +# database. +db.data.dir= +``` + + + +Use the `db.config.dir` property to specify the location of database configuration files if they are not stored in the same directory as the `recovery.conf` or `standby.signal` file. This should be the value specified by the `config_file` parameter directory of your Advanced Server or PostgreSQL installation. This value will be used as the location of the Postgres `data` directory when stopping, starting, or restarting the database. + +```text +# Specify the location of database configuration files if they are +# not contained in the same location as the recovery.conf or +# standby.signal file. This is most likely the case for Debian +# installations. The location specified will be used as the -D value +# (the location of the data directory for the cluster) when calling +# pg_ctl to start or stop the database. If this property is blank, +# the db.data.dir location specified by the db.data.dir property will +# be used. This corresponds to the output of query 'show config_file;' +# on respective database. +db.config.dir= +``` + +For more information about database configuration files, visit the [PostgreSQL website](https://www.postgresql.org/docs/current/runtime-config-file-locations.html). + + + +Use the `jdbc.sslmode` property to instruct Failover Manager to use SSL connections; by default, SSL is disabled. + +```text +# Use the jdbc.sslmode property to enable ssl for EFM +# connections. Setting this property to anything but 'disable' +# will force the agents to use 'ssl=true' for all JDBC database +# connections (to both local and remote databases). +# Valid values are: +# +# disable - Do not use ssl for connections. +# verify-ca - EFM will perform CA verification before allowing +# the certificate. +# require - Verification will not be performed on the server +# certificate. +jdbc.sslmode=disable +``` + + + +!!! Note + If you set the value of `jdbc.sslmode` to `verify-ca` and you want to use Java trust store for certificate validation, you need to set the following value: + + `jdbc.properties=sslfactory=org.postgresql.ssl.DefaultJavaSSLFactory` + +For information about configuring and using SSL, please see: + +> + +and + +> + + + +Use the `user.email` property to specify an email address (or multiple email addresses) that will receive any notifications sent by Failover Manager. + +```text +# Email address(es) for notifications. The value of this +# property must be the same across all agents. Multiple email +# addresses must be separated by space. If using a notification +# script instead, this property can be left blank. +user.email= +``` + + + +The `from.email` property specifies the value that will be used as the sender's address on any email notifications from Failover Manager. You can: + +- leave `from.email` blank to use the default value (`efm@localhost`). +- specify a custom value for the email address. +- specify a custom email address, using the `%h` placeholder to represent the name of the node host (e.g., [example@%h](mailto:example@%h)). The placeholder will be replaced with the name of the host as returned by the Linux hostname utility. + +For more information about notifications, see [Notifications](../../10_notifications/#notifications). + +```text +# Use the from.email property to specify the from email address that +# will be used for email notifications. Use the %h placeholder to +# represent the name of the node host (e.g. example@%h). The +# placeholder will be replaced with the name of the host as returned +# by the hostname command. +# Leave blank to use the default, efm@localhost. +from.email= +``` + + + +Use the `notification.level` property to specify the minimum severity level at which Failover Manager will send user notifications or when a notification script is called. For a complete list of notifications, please see [Notifications](../../10_notifications/#notifications). + +```text +# Minimum severity level of notifications that will be sent by +# the agent. The minimum level also applies to the notification +# script (below). Valid values are INFO, WARNING, and SEVERE. +# A list of notifications is grouped by severity in the user's +# guide. +notification.level=INFO +``` + + + +Use the `notification.text.prefix` property to specify the text to be added to the beginning of every notification. + +```text +# Text to add to the beginning of every notification. This could +# be used to help identify what the cluster is used for, the role +# of this node, etc. To use multiple lines, add a backslash \ to +# the end of a line of text. To include a newline use \n. +# Example: +# notification.text.prefix=Development cluster for Example dept.\n\ +# Used by Dev and QA \ +# See Example group for questions. +notification.text.prefix= +``` + + + +Use the `script.notification` property to specify the path to a user-supplied script that acts as a notification service; the script will be passed a message subject and a message body. The script will be invoked each time Failover Manager generates a user notification. + +```text +# Absolute path to script run for user notifications. +# +# This is an optional user-supplied script that can be used for +# notifications instead of email. This is required if not using +# email notifications. Either/both can be used. The script will +# be passed two parameters: the message subject and the message +# body. +script.notification= +``` + + + +The `bind.address` property specifies the IP address and port number of the agent on the current node of the Failover Manager cluster. + +```text +# This property specifies the ip address and port that jgroups +# will bind to on this node. The value is of the form +# :. +# Note that the port specified here is used for communicating +# with other nodes, and is not the same as the admin.port below, +# used only to communicate with the local agent to send control +# signals. +# For example, :7800 +bind.address= +``` + + + +Use the `external.address` property to specify the IP address or hostname that should be used for communication with all other Failover Manager agents in a NAT environment. + +```text +# This is the ip address/hostname to be used for communication with all +# other Failover Manager agents. All traffic towards this address +# should be routed by the network to the bind.address of the node. +# The value is in the ip/hostname format only. This address will be +# used in scenarios where nodes are on different networks and broadcast +# an IP address other than the bind.address to the external world. +external.address= +``` + + + +Use the `admin.port` property to specify a port on which Failover Manager listens for administrative commands. + +```text +# This property controls the port binding of the administration +# server which is used for some commands (ie cluster-status). The +# default is 7809; you can modify this value if the port is +# already in use. +admin.port=7809 +``` + + + +Set the `is.witness` property to true to indicate that the current node is a witness node. If is.witness is true, the local agent will not check to see if a local database is running. + +```text +# Specifies whether or not this is a witness node. Witness nodes +# do not have local databases running. +is.witness= +``` + +The Postgres `pg_is_in_recovery()` function is a boolean function that reports the recovery state of a database. The function returns `true` if the database is in recovery, or false if the database is not in recovery. When an agent starts, it connects to the local database and invokes the `pg_is_in_recovery()` function. If the server responds true, the agent assumes the role of standby; if the server responds false, the agent assumes the role of primary. If there is no local database, the agent will assume an idle state. + +!!! Note + If `is.witness` is `true`, Failover Manager will not check the recovery state. + + + + + + + +The following properties specify properties that apply to the local server: + +- The `local.period` property specifies how many seconds between attempts to contact the database server. +- The `local.timeout` property specifies how long an agent will wait for a positive response from the local database server. +- The `local.timeout.final` property specifies how long an agent will wait after the above-mentioned previous checks have failed to contact the database server on the current node. If a response is not received from the database within the number of seconds specified by the `local.timeout.final` property, the database is assumed to have failed. + +For example, given the default values of these properties, a check of the local database happens once every 10 seconds. If an attempt to contact the local database does not come back positive within 60 seconds, Failover Manager makes a final attempt to contact the database. If a response is not received within 10 seconds, Failover Manager declares database failure and notifies the administrator listed in the user.email property. These properties are not required on a dedicated witness node. + +```text +# These properties apply to the connection(s) EFM uses to monitor +# the local database. Every 'local.period' seconds, a database +# check is made in a background thread. If the main monitoring +# thread does not see that any checks were successful in +# 'local.timeout' seconds, then the main thread makes a final +# check with a timeout value specified by the +# 'local.timeout.final' value. All values are in seconds. +# Whether EFM uses single or multiple connections for database +# checks is controlled by the 'db.reuse.connection.count' +# property. +local.period=10 +local.timeout=60 +local.timeout.final=10 +``` + +If necessary, you should modify these values to suit your business model. + + + +Use the `remote.timeout` property to specify how many seconds an agent waits for a response from a remote database server (i.e., how long a standby agent waits to verify that the primary database is actually down before performing failover). The `remote.timeout` property value specifies a timeout value for agent-to-agent communication; other timeout properties in the cluster properties file specify values for agent-to-database communication. + +```text +# Timeout for a call to check if a remote database is responsive. +# For example, this is how long a standby would wait for a +# DB ping request from itself and the witness to the primary DB +# before performing failover. +remote.timeout=10 +``` + + + +Use the `node.timeout` property to specify the number of seconds that an agent will wait for a response from a node when determining if a node has failed. + +```text +# The total amount of time in seconds to wait before determining +# that a node has failed or been disconnected from this node. +# +# The value of this property must be the same across all agents. +node.timeout=50 +``` + + + +Use the `encrypt.agent.messages` property to specify if the messages sent between agents should be encrypted. + +```text +# Set to true to encrypt messages that are sent between agents. +# This property must be the same on all agents or else the agents +# will not be able to connect. +encrypt.agent.messages=false +``` + + + +Use the `stop.isolated.primary` property to instruct Failover Manager to shut down the database if a primary agent detects that it is isolated. When true (the default), Failover Manager will stop the database before invoking the script specified in the `script.primary.isolated` property. + +```text +# Shut down the database after a primary agent detects that it has +# been isolated from the majority of the efm cluster. If set to +# true, efm will stop the database before running the +# 'script.primary.isolated' script, if a script is specified. +stop.isolated.primary=true +``` + + + +Use the `stop.failed.primary` property to instruct Failover Manager to attempt to shut down a primary database if it can not reach the database. If `true`, Failover Manager will run the script specified in the `script.db.failure` property after attempting to shut down the database. + +```text +# Attempt to shut down a failed primary database after EFM can no +# longer connect to it. This can be used for added safety in the +# case a failover is caused by a failure of the network on the +# primary node. +# If specified, a 'script.db.failure' script is run after this attempt. +stop.failed.primary=true +``` + + + +Use the `primary.shutdown.as.failure` parameter to indicate that any shutdown of the Failover Manager agent on the primary node should be treated as a failure. If this parameter is set to `true` and the primary agent stops (for any reason), the cluster will attempt to confirm if the database on the primary node is running: + +- If the database is reached, a notification will be sent informing you of the agent status. +- If the database is not reached, a failover will occur. + +```text +# Treat a primary agent shutdown as an agent failure. This can be set +# to true to treat a primary agent shutdown as a failure situation, +# e.g. during the shutdown of a node, accidental or otherwise. +# Caution should be used when using this feature, as it could +# cause an unwanted promotion in the case of performing primary +# database maintenance. +# Please see the user's guide for more information. +primary.shutdown.as.failure=false +``` + +The `primary.shutdown.as.failure` property is meant to catch user error, rather than failures, such as the accidental shutdown of a primary node. The proper shutdown of a node can appear to the rest of the cluster like a user has stopped the primary Failover Manager agent (for example to perform maintenance on the primary database). If you set the `primary.shutdown.as.failure` property to `true`, care must be taken when performing maintenance. + +To perform maintenance on the primary database when `primary.shutdown.as.failure` is `true`, you should stop the primary agent and wait to receive a notification that the primary agent has failed but the database is still running. Then it is safe to stop the primary database. Alternatively, you can use the `efm stop-cluster` command to stop all of the agents without failure checks being performed. + + + +Use the `update.physical.slots.period` property to define the slot advance frequency for database version 12 and above. When `update.physical.slots.period` is set to a non-zero value, the primary agent will read the current `restart_lsn` of the physical replication slots after every `update.physical.slots.period` seconds, and send this information with its `pg_current_wal_lsn` and `primary_slot_name` (If it is set in the postgresql.conf file) to the standbys. If physical slots do not already exist, setting this parameter to a non-zero value will create the slots and then update the `restart_lsn parameter` for these slots. A non-promotable standby will not create new slots but will update them if they exist. + +```text +# Period in seconds between having the primary agent update promotable +# standbys with physical replication slot information so that +# the cluster will continue to use replication slots after a failover. +# Set to zero to turn off. +update.physical.slots.period=0 +``` + + + +Use the `ping.server.ip` property to specify the IP address of a server that Failover Manager can use to confirm that network connectivity is not a problem. + +```text +# This is the address of a well-known server that EFM can ping +# in an effort to determine network reachability issues. It +# might be the IP address of a nameserver within your corporate +# firewall or another server that *should* always be reachable +# via a 'ping' command from each of the EFM nodes. +# +# There are many reasons why this node might not be considered +# reachable: firewalls might be blocking the request, ICMP might +# be filtered out, etc. +# +# Do not use the IP address of any node in the EFM cluster +# (primary, standby, or witness) because this ping server is meant +# to provide an additional layer of information should the EFM +# nodes lose sight of each other. +# +# The installation default is Google's DNS server. +ping.server.ip=8.8.8.8 +``` + + + +Use the `ping.server.command` property to specify the command used to test network connectivity. + +```text +# This command will be used to test the reachability of certain +# nodes. +# +# Do not include an IP address or hostname on the end of +# this command - it will be added dynamically at runtime with the +# values contained in 'virtual.ip' and 'ping.server.ip'. +# +# Make sure this command returns reasonably quickly - test it +# from a shell command line first to make sure it works properly. +ping.server.command=/bin/ping -q -c3 -w5 +``` + + + +Use the `auto.allow.hosts` property to instruct the server to use the addresses specified in the .nodes file of the first node started to update the allowed host list. Enabling this property (setting `auto.allow.hosts` to true) can simplify cluster start-up. + +```text +# Have the first node started automatically add the addresses +# from its .nodes file to the allowed host list. This will make +# it faster to start the cluster when the initial set of hosts +# is already known. +auto.allow.hosts=false +``` + + + +Use the `stable.nodes.file` property to instruct the server to not rewrite the nodes file when a node joins or leaves the cluster. This property is most useful in clusters with unchanging IP addresses. + +```text +# When set to true, EFM will not rewrite the .nodes file whenever +# new nodes join or leave the cluster. This can help starting a +# cluster in the cases where it is expected for member addresses +# to be mostly static, and combined with 'auto.allow.hosts' makes +# startup easier when learning failover manager. +stable.nodes.file=false +``` + + + +The `db.reuse.connection.count` property allows the administrator to specify the number of times Failover Manager reuses the same database connection to check the database health. The default value is 0, indicating that Failover Manager will create a fresh connection each time. This property is not required on a dedicated witness node. + +```text +# This property controls how many times a database connection is +# reused before creating a new one. If set to zero, a new +# connection will be created every time an agent pings its local +# database. +db.reuse.connection.count=0 +``` + + + +The `auto.failover` property enables automatic failover. By default, auto.failover is set to true. + +```text +# Whether or not failover will happen automatically when the primary +# fails. Set to false if you want to receive the failover notifications +# but not have EFM actually perform the failover steps. +# The value of this property must be the same across all agents. +auto.failover=true +``` + + + +Use the `auto.reconfigure` property to instruct Failover Manager to enable or disable automatic reconfiguration of remaining Standby servers after the primary standby is promoted to Primary. Set the property to `true` to enable automatic reconfiguration (the default) or `false` to disable automatic reconfiguration. This property is not required on a dedicated witness node. If you are using Advanced Server or PostgreSQL version 11 or earlier, the `recovery.conf` file will be backed up during the reconfiguration process. + +```text +# After a standby is promoted, Failover Manager will attempt to +# update the remaining standbys to use the new primary. For database +# versions before 12, Failover Manager will back up recovery.conf. +# Then it will change the host parameter of the primary_conninfo entry +# in recovery.conf or postgresql.auto.conf, and restart the database. +# The restart command is contained in either the efm_db_functions or +# efm_root_functions file; default when not running db as an os +# service is: "pg_ctl restart -m fast -w -t -D " +# where the timeout is the local.timeout property value and the +# directory is specified by db.data.dir. To turn off +# automatic reconfiguration, set this property to false. +auto.reconfigure=true +``` + +!!! Note + `primary_conninfo` is a space-delimited list of keyword=value pairs. + + + +Use the `promotable` property to indicate that a node should not be promoted. The `promotable` property is ignored when a primary agent is started. This simplifies switching back to the original primary after a switchover or failover. To override the setting, use the efm set-priority command at runtime; for more information about the efm set-priority command, see [Using the efm Utility](../../07_using_efm_utility/#using_efm_utility). + +```text +# A standby with this set to false will not be added to the +# failover priority list, and so will not be available for +# promotion. The property will be used whenever an agent starts +# as a standby or resumes as a standby after being idle. After +# startup/resume, the node can still be added or removed from the +# priority list with the 'efm set-priority' command. This +# property is required for all non-witness nodes. +promotable=true +``` + + + +If the same amount of data has been written to more than one standby node, and a failover occurs, the `use.replay.tiebreaker` value will determine how Failover Manager selects a replacement primary. Set the `use.replay.tiebreaker` property to `true` to instruct Failover Manager to failover to the node that will come out of recovery faster, as determined by the log sequence number. To ignore the log sequence number and promote a node based on user preference, set `use.replay.tiebreaker` to `false`. + +```text +# Use replay LSN value for tiebreaker when choosing a standby to +# promote before using failover priority. Set this property to true to +# consider replay location as more important than failover priority +# (as seen in cluster-status command) when choosing the "most ahead" +# standby to promote. +use.replay.tiebreaker=true +``` + + + +Use the `standby.restart.delay` property to specify the time in seconds that the standby should wait before it gets reconfigured (stopped/started) to follow the new primary after a promotion. + +```text +# Time in seconds for this standby to delay restarting to follow the +# primary after a promotion. This can be used to have standbys restart +# at different times to increase availability. Caution should be used +# when using this feature, as a delayed standby will not be following +# the new primary and care must be taken that the new primary retains +# enough WAL for the standby to follow it. +# Please see the user's guide for more information. +standby.restart.delay=0 +``` + + + +You can use the `application.name` property to provide the name of an application that will be copied to the `primary_conninfo` parameter before restarting an old primary node as a standby. + +```text +# During a switchover, recovery settings are copied from a standby +# to the original primary. If the application.name property is set, +# Failover Manager will replace the application_name portion of the +# primary_conninfo entry with this property value before starting +# the original primary database as a standby. If this property is +# not set, Failover Manager will remove the parameter value +# from primary_conninfo. +application.name= +``` + +!!! Note + You should set the `application.name` property on the primary and any promotable standby; in the event of a failover/switchover, the primary node could potentially become a standby node again. + + + +Use the `restore.command` property to instruct Failover Manager to update the `restore_command` when a new primary is promoted. `%h` represents the address of the new primary; Failover Manager will replace `%h` with the address of the new primary. `%f` and `%p` are placeholders used by the server. If the property is left blank, Failover Manager will not update the `restore_command` values on the standbys after a promotion. + +See the PostgreSQL documentation for more information about using a [restore_command](https://www.postgresql.org/docs/current/runtime-config-wal.html#RUNTIME-CONFIG-WAL-ARCHIVE-RECOVERY). + +```text +# If the restore_command on a standby restores directly from the +# primary node, use this property to have Failover Manager change +# the command when a new primary is promoted. +# +# Use the %h placeholder to represent the address of the new primary. +# During promotion it will be replaced with the address of the new +# primary. +# +# If not specified, failover manager will not change the +# restore_command value, if any, on standby nodes. +# +# Example: +# restore.command=scp @%h:/var/lib/edb/as12/data/archive/%f %p +restore.command= +``` + + + +The database parameter `synchronous_standby_names` on the primary node specifies the names and count of the synchronous standby servers that will confirm receipt of data, to ensure that the primary nodes can accept write transactions. When `reconfigure.num.sync` property is set to true, Failover Manager will reduce the number of synchronous standby servers and reload the configuration of the primary node to reflect the current value. + +```text +# Reduce num_sync when the number of synchronous standbys drops below +# the value required by the primary database. If set to true, Failover +# Manager will reduce the number of standbys needed in the primary's +# synchronous_standby_names property and reload the primary +# configuration. Failover Manager will not reduce the number below 1, +# taking the primary out of synchronous replication, unless the +# reconfigure.sync.primary property is also set to true. +# To raise num_sync, see the reconfigure.num.sync.max property below. +reconfigure.num.sync=false +``` + + + +Set the `reconfigure.sync.primary` property to `true` to take the primary database out of synchronous replication mode if the number of standby nodes drops below the level required. Set `reconfigure.sync.primary` to `false` to send a notification if the standby count drops, but not interrupt synchronous replication. + +```text +# Take the primary database out of synchronous replication mode when +# needed. If set to true, Failover Manager will clear the +# synchronous_standby_names configuration parameter on the primary +# if the number of synchronous standbys drops below the required +# level for the primary to accept writes. +# If set to false, Failover Manager will detect the situation but +# will only send a notification if the standby count drops below the +# required level. +# +# CAUTION: TAKING THE PRIMARY DATABASE OUT OF SYNCHRONOUS MODE MEANS +# THERE MAY ONLY BE ONE COPY OF DATA. DO NOT MAKE THIS CHANGE UNLESS +# YOU ARE SURE THIS IS OK. +reconfigure.sync.primary=false +``` + + + +Use the `minimum.standbys` property to specify the minimum number of standby nodes that will be retained on a cluster; if the standby count drops to the specified minimum, a replica node will not be promoted in the event of a failure of the primary node. + +```text +# Instead of setting specific standbys as being unavailable for +# promotion, this property can be used to set a minimum number +# of standbys that will not be promoted. Set to one, for +# example, promotion will not happen if it will drop the number +# of standbys below this value. This property must be the same on +# each node. +minimum.standbys=0 +``` + + + +Use the `recovery.check.period` property to specify the number of seconds that Failover Manager will wait before checks to see if a database is out of recovery. + +```text +# Time in seconds between checks to see if a promoting database +# is out of recovery. +recovery.check.period=1 +``` + + + +Use the `restart.connection.timeout` property to specify the number of seconds that Failover Manager will attempt to connect to a newly reconfigured primary or standby node while the database on that node prepares to accept connections. + +```text +# Time in seconds to keep trying to connect to a database after a +# start or restart command returns successfully but the database +# is not ready to accept connections yet (a rare occurance). This +# applies to standby databases that are restarted when being +# reconfigured for a new primary, and to primary databases that +# are stopped and started as standbys during a switchover. +# This retry mechanism is unrelated to the auto.resume.period +# parameter. +restart.connection.timeout=60 +``` + + + +Use the `auto.resume.period` property to specify the number of seconds (after a monitored database fails and an agent has assumed an idle state, or when starting in IDLE mode) during which an agent will attempt to resume monitoring that database. + +```text +# Period in seconds for IDLE agents to try to resume monitoring +# after a database failure or when starting in IDLE mode. Set to +# 0 for agents to not try to resume (in which case the +# 'efm resume ' command is used after bringing a +# database back up). +auto.resume.period=0 +``` + + + +Failover Manager provides support for clusters that use a virtual IP. If your cluster uses a virtual IP, provide the host name or IP address in the `virtual.ip` property; specify the corresponding prefix in the `virtual.ip.prefix` property. If `virtual.ip` is left blank, virtual IP support is disabled. + +Use the `virtual.ip.interface` property to provide the network interface used by the VIP. + +The specified virtual IP address is assigned only to the primary node of the cluster. If you specify `virtual.ip.single=true`, the same VIP address will be used on the new primary in the event of a failover. Specify a value of false to provide a unique IP address for each node of the cluster. + +For information about using a virtual IP address, see [Using Failover Manager with Virtual IP Addresses](../05_using_vip_addresses/#using_vip_addresses). + +```text +# These properties specify the IP and prefix length that will be +# remapped during failover. If you do not use a VIP as part of +# your failover solution, leave the virtual.ip property blank to +# disable Failover Manager support for VIP processing (assigning, +# releasing, testing reachability, etc). +# +# If you specify a VIP, the interface and prefix are required. +# +# If you specify a host name, it will be resolved to an IP address +# when acquiring or releasing the VIP. If the host name resolves +# to more than one IP address, there is no way to predict which +# address Failover Manager will use. +# +# By default, the virtual.ip and virtual.ip.prefix values must be +# the same across all agents. If you set virtual.ip.single to +# false, you can specify unique values for virtual.ip and +# virtual.ip.prefix on each node. +# +# If you are using an IPv4 address, the virtual.ip.interface value +# should not contain a secondary virtual ip id (do not include +# ":1", etc). +virtual.ip= +virtual.ip.interface= +virtual.ip.prefix= +virtual.ip.single=true +``` + +!!! Note + If a primary agent is started and the node does not currently have the VIP, the EFM agent will acquire it. Stopping a primary agent does not drop the VIP from the node. + + + +Set the `check.vip.before.promotion` property to false to indicate that Failover Manager will not check to see if a VIP is in use before assigning it to a a new primary in the event of a failure. Note that this could result in multiple nodes broadcasting on the same VIP address; unless the primary node is isolated or can be shut down via another process, you should set this property to true. + +```text +# Whether to check if the VIP (when used) is still in use before +# promoting after a primary failure. Turning this off may allow +# the new primary to have the VIP even though another node is also +# broadcasting it. This should only be used in environments where +# it is known that the failed primary node will be isolated or +# shut down through other means. +check.vip.before.promotion=true +``` + + + +Use the following properties to provide paths to scripts that reconfigure your load balancer in the event of a switchover or primary failure scenario. The scripts will also be invoked in the event of a standby failure. If you are using these properties, they should be provided on every node of the cluster (primary, standby, and witness) to ensure that if a database node fails, another node will call the detach script with the failed node's address. + +You do not need to set the below properties if you are using Pgpool as Load Balancer solution and have set the Pgpool integration properties. + +Provide a script name after the `script.load.balancer.attach` property to identify a script that will be invoked when a node should be attached to the load balancer. Use the `script.load.balancer.detach` property to specify the name of a script that will be invoked when a node should be detached from the load balancer. Include the `%h` placeholder to represent the IP address of the node that is being attached or removed from the cluster. Include the `%t` placeholder to instruct Failover Manager to include an p (for a primary node) or an s (for a standby node) in the string. + +```text +# Absolute path to load balancer scripts +# The attach script is called when a node should be attached to +# the load balancer, for example after a promotion. The detach +# script is called when a node should be removed, for example +# when a database has failed or is about to be stopped. Use %h to +# represent the IP/hostname of the node that is being +# attached/detached. Use %t to represent the type of node being +# attached or detached: the letter m will be passed in for primary nodes +#and the letter s for standby nodes. +# +# Example: +# script.load.balancer.attach=/somepath/attachscript %h %t +script.load.balancer.attach= +script.load.balancer.detach= +``` + + + +`script.fence` specifies the path to an optional user-supplied script that will be invoked during the promotion of a standby node to primary node. + +```text +# absolute path to fencing script run during promotion +# +# This is an optional user-supplied script that will be run +# during failover on the standby database node. If left blank, +# no action will be taken. If specified, EFM will execute this +# script before promoting the standby. +# +# Parameters can be passed into this script for the failed primary +# and new primary node addresses. Use %p for new primary and %f +# for failed primary. On a node that has just been promoted, %p +# should be the same as the node's efm binding address. +# +# Example: +# script.fence=/somepath/myscript %p %f +# +# NOTE: FAILOVER WILL NOT OCCUR IF THIS SCRIPT RETURNS A NON-ZERO EXIT +# CODE. +script.fence= +``` + +
+ +Use the `script.post.promotion` property to specify the path to an optional user-supplied script that will be invoked after a standby node has been promoted to primary. + +```text +# Absolute path to fencing script run after promotion +# +# This is an optional user-supplied script that will be run after +# failover on the standby node after it has been promoted and +# is no longer in recovery. The exit code from this script has +# no effect on failover manager, but will be included in a +# notification sent after the script executes. +# +# Parameters can be passed into this script for the failed primary +# and new primary node addresses. Use %p for new primary and %f +# for failed primary. On a node that has just been promoted, %p +# should be the same as the node's efm binding address. +# +# Example: +# script.post.promotion=/somepath/myscript %f %p +script.post.promotion= +``` + + + +Use the `script.resumed property` to specify an optional path to a user-supplied script that will be invoked when an agent resumes monitoring of a database. + +```text +# Absolute path to resume script +# +# This script is run before an IDLE agent resumes +# monitoring its local database. +script.resumed= +``` + + + +Use the `script.db.failure` property to specify the complete path to an optional user-supplied script that Failover Manager will invoke if an agent detects that the database that it monitors has failed. + +```text +# Absolute path to script run after database failure +# This is an optional user-supplied script that will be run after +# an agent detects that its local database has failed. +script.db.failure= +``` + + + +Use the `script.primary.isolated` property to specify the complete path to an optional user-supplied script that Failover Manager will invoke if the agent monitoring the primary database detects that the primary is isolated from the majority of the Failover Manager cluster. This script is called immediately after the VIP is released (if a VIP is in use). + +```text +# Absolute path to script run on isolated primary +# This is an optional user-supplied script that will be run after +# a primary agent detects that it has been isolated from the +# majority of the efm cluster. +script.primary.isolated= +``` + + + +Use the `script.remote.pre.promotion` property to specify the path and name of a script that will be invoked on any agent nodes not involved in the promotion when a node is about to promote its database to primary. + +Include the %p placeholder to identify the address of the new primary node. + +```text +# Absolute path to script invoked on non-promoting agent nodes +# before a promotion. +# +# This optional user-supplied script will be invoked on other +# agents when a node is about to promote its database. The exit +# code from this script has no effect on Failover Manager, but +# will be included in a notification sent after the script +# executes. +# +# Pass a parameter (%p) with the script to identify the new +# primary node address. +# +# Example: +# script.remote.pre.promotion=/path_name/script_name %p +script.remote.pre.promotion= +``` + +
+ +Use the `script.remote.post.promotion` property to specify the path and name of a script that will be invoked on any non-primary nodes after a promotion occurs. + +Include the %p placeholder to identify the address of the new primary node. + +```text +# Absolute path to script invoked on non-primary agent nodes +# after a promotion. +# +# This optional user-supplied script will be invoked on nodes +# (except the new primary) after a promotion occurs. The exit code +# from this script has no effect on Failover Manager, but will be +# included in a notification sent after the script executes. +# +# Pass a parameter (%p) with the script to identify the new +# primary node address. +# +# Example: +# script.remote.post.promotion=/path_name/script_name %p +script.remote.post.promotion= +``` + + + +Use the `script.custom.monitor` property to provide the name and location of an optional script that will be invoked on regular intervals (specified in seconds by the `custom.monitor.interval` property). + +Use `custom.monitor.timeout` to specify the maximum time that the script will be allowed to run; if script execution does not complete within the time specified, Failover Manager will send a notification. + +Set `custom.monitor.safe.mode` to `true` to instruct Failover Manager to report non-zero exit codes from the script, but not promote a standby as a result of an exit code. + +```text +# Absolute path to a custom monitoring script. +# +# Use script.custom.monitor to specify the location and name of +# an optional user-supplied script that will be invoked +# periodically to perform custom monitoring tasks. A non-zero +# exit value means that a check has failed; this will be treated +# as a database failure. On a primary node, script failure will +# cause a promotion. On a standby node script failure will +# generate a notification and the agent will become IDLE. +# +# The custom.monitor.\* properties are required if a custom +# monitoring script is specified: +# +# custom.monitor.interval is the time in seconds between executions +# of the script. +# +# custom.monitor.timeout is a timeout value in seconds for how +# long the script will be allowed to run. If script execution +# exceeds the specified time, the task will be stopped and a +# notification sent. Subsequent runs will continue. +# +# If custom.monitor.safe.mode is set to true, non-zero exit codes +# from the script will be reported but will not cause a promotion +# or be treated as a database failure. This allows testing of the +# script without affecting EFM. +# +script.custom.monitor= +custom.monitor.interval= +custom.monitor.timeout= +custom.monitor.safe.mode= +``` + + + +Use the `sudo.command` property to specify a command that will be invoked by Failover Manager when performing tasks that require extended permissions. Use this option to include command options that might be specific to your system authentication. + +Use the `sudo.user.command` property to specify a command that will be invoked by Failover Manager when executing commands that will be performed by the database owner. + +```text +# Command to use in place of 'sudo' if desired when efm runs +# the efm_db_functions or efm_root_functions, or efm_address +# scripts. +# Sudo is used in the following ways by efm: +# +# sudo /usr/edb/efm-/bin/efm_address +# sudo /usr/edb/efm-/bin/efm_root_functions +# sudo -u /usr/edb/efm-/bin/efm_db_functions +# +# 'sudo' in the first two examples will be replaced by the value +# of the sudo.command property. 'sudo -u ' will +# be replaced by the value of the sudo.user.command property. +# The '%u' field will be replaced with the db owner. +sudo.command=sudo +sudo.user.command=sudo -u %u +``` + + + +Use the `lock.dir` property to specify an alternate location for the Failover Manager lock file; the file prevents Failover Manager from starting multiple (potentially orphaned) agents for a single cluster on the node. + +```text +# Specify the directory of lock file on the node. Failover +# Manager creates a file named .lock at this location to +# avoid starting multiple agents for same cluster. If the path +# does not exist, Failover Manager will attempt to create it. If +# not specified defaults to '/var/lock/efm-' +lock.dir= +``` + + + +Use the `log.dir` property to specify the location to which agent log files will be written; Failover Manager will attempt to create the directory if the directory does not exist. + +```text +# Specify the directory of agent logs on the node. If the path +# does not exist, Failover Manager will attempt to create it. If +# not specified defaults to '/var/log/efm-'. (To store +# Failover Manager startup logs in a custom location, modify the +# path in the service script to point to an existing, writable +# directory.) +# If using a custom log directory, you must configure +# logrotate separately. Use 'man logrotate' for more information. +log.dir= +``` + + + +After enabling the UDP or TCP protocol on a Failover Manager host, you can enable logging to syslog. Use the `syslog.protocol` parameter to specify the protocol type (UDP or TCP) and the `syslog.port` parameter to specify the listener port of the syslog host. The `syslog.facility` value may be used as an identifier for the process that created the entry; the value must be between LOCAL0 and LOCAL7. + +```text +# Syslog information. The syslog service must be listening on +# the port for the given protocol, which can be UDP or TCP. +# The facilities supported are LOCAL0 through LOCAL7. +syslog.host=localhost +syslog.port=514 +syslog.protocol=UDP +syslog.facility=LOCAL1 +``` + + + +Use the `file.log.enabled` and `syslog.enabled` properties to specify the type of logging that you wish to implement. Set `file.log.enabled` to `true` to enable logging to a file; enable the UDP protocol or TCP protocol and set `syslog.enabled` to `true` to enable logging to syslog. You can enable logging to both a file and syslog. + +```text +# Which logging is enabled. +file.log.enabled=true +syslog.enabled=false +``` + +For more information about configuring syslog logging, see [Enabling syslog Log File Entries](../../09_controlling_logging/#enabling_syslog). + + + +Use the `jgroups.loglevel` and `efm.loglevel` parameters to specify the level of detail logged by Failover Manager. The default value is INFO. For more information about logging, see [Controlling Logging](../../09_controlling_logging/#controlling_logging). + +```text +# Logging levels for JGroups and EFM. +# Valid values are: TRACE, DEBUG, INFO, WARN, ERROR +# Default value: INFO +# It is not necessary to increase these values unless debugging a +# specific issue. If nodes are not discovering each other at +# startup, increasing the jgroups level to DEBUG will show +# information about the TCP connection attempts that may help +# diagnose the connection failures. +jgroups.loglevel=INFO +efm.loglevel=INFO +``` + + + +Use the `jvm.options` property to pass JVM-related configuration information. The default setting specifies the amount of memory that the Failover Manager agent will be allowed to use. + +```text +# Extra information that will be passed to the JVM when starting +# the agent. +jvm.options=-Xmx128m +``` + diff --git a/product_docs/docs/efm/4.0/efm_user/04_configuring_efm/02_encrypting_database_password.mdx b/product_docs/docs/efm/4.0/efm_user/04_configuring_efm/02_encrypting_database_password.mdx new file mode 100644 index 00000000000..c0456f97d8c --- /dev/null +++ b/product_docs/docs/efm/4.0/efm_user/04_configuring_efm/02_encrypting_database_password.mdx @@ -0,0 +1,81 @@ +--- +title: "Encrypting Your Database Password" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.0/encrypting_database_password.html" +--- + + + +Failover Manager requires you to encrypt your database password before including it in the cluster properties file. Use the [efm utility](../07_using_efm_utility/#efm_encrypt) (located in the `/usr/edb/efm-4.0/bin` directory) to encrypt the password. When encrypting a password, you can either pass the password on the command line when you invoke the utility, or use the `EFMPASS` environment variable. + +To encrypt a password, use the command: + +```text +# efm encrypt [ --from-env ] +``` + +Where `` specifies the name of the Failover Manager cluster. + +If you include the `--from-env` option, you must export the value you wish to encrypt before invoking the encryption utility. For example: + +```text +export EFMPASS=password +``` + +If you do not include the `--from-env` option, Failover Manager will prompt you to enter the database password twice before generating an encrypted password for you to place in your cluster property file. When the utility shares the encrypted password, copy and paste the encrypted password into the cluster property files. + +!!! Note + Many Java vendors ship their version of Java with full-strength encryption included, but not enabled due to export restrictions. If you encounter an error that refers to an illegal key size when attempting to encrypt the database password, you should download and enable a Java Cryptography Extension (JCE) that provides an unlimited policy for your platform. + +The following example demonstrates using the encrypt utility to encrypt a password for the `acctg` cluster: + +```text +# efm encrypt acctg +This utility will generate an encrypted password for you to place in + your EFM cluster property file: +/etc/edb/efm-4.0/acctg.properties +Please enter the password and hit enter: +Please enter the password again to confirm: +The encrypted password is: 516b36fb8031da17cfbc010f7d09359c +Please paste this into your acctg.properties file +db.password.encrypted=516b36fb8031da17cfbc010f7d09359c +``` + +!!! Note + The utility will notify you if a properties file does not exist. + +After receiving your encrypted password, paste the password into the properties file and start the Failover Manager service. If there is a problem with the encrypted password, the Failover Manager service will not start: + +```text +[witness@localhost ~]# systemctl start edb-efm-4.0 +Job for edb-efm-4.0.service failed because the control process exited with error code. See "systemctl status edb-efm-4.0.service" and "journalctl -xe" for details. +``` + +If you receive this message when starting the Failover Manager service, please see the startup log (located in `/var/log/efm-4.0/startup-efm.log`) for more information. + +If you are using RHEL/CentOS 7.x or RHEL/CentOS 8.x, startup information is also available with the following command: + +```text +systemctl status edb-efm-4.0 +``` + +To prevent a cluster from inadvertently connecting to the database of another cluster, the cluster name is incorporated into the encrypted password. If you modify the cluster name, you will need to re-encrypt the database password and update the cluster properties file. + +**Using the EFMPASS Environment Variable** + +The following example demonstrates using the --from-env environment variable when encrypting a password. Before invoking the `efm encrypt` command, set the value of `EFMPASS` to the password (`1safepassword`): + +```text +# export EFMPASS=1safepassword +``` + +Then, invoke `efm encrypt`, specifying the `--from-env` option: + +```text +# efm encrypt acctg --from-env +# 7ceecd8965fa7a5c330eaa9e43696f83 +``` + +The encrypted password (`7ceecd8965fa7a5c330eaa9e43696f83`) is returned as a text value; when using a script, you can check the exit code of the command to confirm that the command succeeded. A successful execution returns `0`. diff --git a/product_docs/docs/efm/4.0/efm_user/04_configuring_efm/03_cluster_members.mdx b/product_docs/docs/efm/4.0/efm_user/04_configuring_efm/03_cluster_members.mdx new file mode 100644 index 00000000000..5b7b5b030bf --- /dev/null +++ b/product_docs/docs/efm/4.0/efm_user/04_configuring_efm/03_cluster_members.mdx @@ -0,0 +1,35 @@ +--- +title: "The Cluster Members File" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.0/cluster_members.html" +--- + + + +Each node in a Failover Manager cluster has a cluster members file (by default, named efm.nodes) that contains a list of the current Failover Manager cluster members. When an agent starts, it uses the file to locate other cluster members. The Failover Manager installer creates a file template for the cluster members file named `efm.nodes.in` in the `/etc/edb/efm-4.0` directory. + +After completing the Failover Manager installation, you must make a working copy of the template: + +```text +cp /etc/edb/efm-4.0/efm.nodes.in /etc/edb/efm-4.0/efm.nodes +``` + +After copying the template file, change the owner of the file to `efm`: + +```text +chown efm:efm efm.nodes +``` + +By default, Failover Manager expects the cluster members file to be named `efm.nodes`. If you name the cluster members file something other than `efm.nodes`, you must modify the Failover Manager service script to instruct Failover Manager to use the new name. + +The cluster members file on the first node started can be empty; this node will become the Membership Coordinator. On each subsequent node, the cluster member file must contain the address and port number of the Membership Coordinator. Each entry in the cluster members file must be listed in an address:port format, with multiple entries separated by white space. + +The agents will update the contents of the `efm.nodes` file to match the current members of the cluster. As agents join or leave the cluster, the `efm.nodes` files on other agents are updated to reflect the current cluster membership. If you invoke the [efm stop-cluster](../07_using_efm_utility/#efm_stop_cluster) command, Failover Manager does not modify the file. + +If the Membership Coordinator leaves the cluster, another node will assume the role. You can use the [efm cluster-status](../07_using_efm_utility/#efm_cluster_status) command to find the address of the Membership Coordinator. If a node joins or leaves a cluster while an agent is down, before starting that agent you must manually ensure that the file includes at least the current Membership Coordinator's address and port. + +If you know the addresses and ports of the nodes that will be joining the cluster, you can include the addresses in the cluster members file at any time. At startup, any addresses that do not identify cluster members will be ignored unless the `auto.allow.hosts` property (in the [cluster properties file](01_cluster_properties/#auto_allow_hosts)) is set to `true`. + +If the `stable.nodes.file` property (located in the [cluster properties file](01_cluster_properties/#auto_allow_hosts)) is set to `true`, the agent will not update the `.nodes` file when cluster members join or leave the cluster; this behavior is most useful when the IP addresses of cluster members do not change often. diff --git a/product_docs/docs/efm/4.0/efm_user/04_configuring_efm/04_extending_efm_permissions.mdx b/product_docs/docs/efm/4.0/efm_user/04_configuring_efm/04_extending_efm_permissions.mdx new file mode 100644 index 00000000000..f49e8489cfb --- /dev/null +++ b/product_docs/docs/efm/4.0/efm_user/04_configuring_efm/04_extending_efm_permissions.mdx @@ -0,0 +1,116 @@ +--- +title: "Extending Failover Manager Permissions" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.0/extending_efm_permissions.html" +--- + + + +During the Failover Manager installation, the installer creates a user named `efm`. `efm` does not have sufficient privileges to perform management functions that are normally limited to the database owner or operating system superuser. + +- When performing management functions requiring database superuser privileges, `efm` invokes the `efm_db_functions` script. +- When performing management functions requiring operating system superuser privileges, `efm` invokes the `efm_root_functions` script. +- When assigning or releasing a virtual IP address, `efm` invokes the `efm_address` script. +- When enabling Pgpool integration, `efm` invokes the `efm_pgpool_functions` script. + +The `efm_db_functions` or `efm_root_functions` scripts perform management functions on behalf of the `efm` user. + +The sudoers file contains entries that allow the user `efm` to control the Failover Manager service for clusters owned by `postgres` or `enterprisedb`. You can modify a copy of the sudoers file to grant permission to manage Postgres clusters owned by other users to `efm`. + +The `efm-41` file is located in `/etc/sudoers.d`, and contains the following entries: + +```text +# Copyright EnterpriseDB Corporation, 2014-2020. All Rights Reserved. +# +# Do not edit this file. Changes to the file may be overwritten +# during an upgrade. +# +# This file assumes you are running your efm cluster as user 'efm'. If not, +# then you will need to copy this file. + +# Allow user 'efm' to sudo efm_db_functions as either 'postgres' or 'enterprisedb'. +# If you run your db service under a non-default account, you will need to copy +# this file to grant the proper permissions and specify the account in your efm +# cluster properties file by changing the 'db.service.owner' property. +efm ALL=(postgres) NOPASSWD: /usr/edb/efm-4.0/bin/efm_db_functions +efm ALL=(enterprisedb) NOPASSWD: /usr/edb/efm-4.0/bin/efm_db_functions + +# Allow user 'efm' to sudo efm_root_functions as 'root' to write/delete the PID file, +# validate the db.service.owner property, etc. +efm ALL=(ALL) NOPASSWD: /usr/edb/efm-4.0/bin/efm_root_functions + +# Allow user 'efm' to sudo efm_address as root for VIP tasks. +efm ALL=(ALL) NOPASSWD: /usr/edb/efm-4.0/bin/efm_address + +# Allow user 'efm' to sudo efm_pgpool_functions as root for pgpool tasks. +efm ALL=(ALL) NOPASSWD: /usr/edb/efm-4.0/bin/efm_pgpool_functions + +# relax tty requirement for user 'efm' +Defaults:efm !requiretty +``` + +If you are using Failover Manager to monitor clusters that are owned by users other than `postgres` or `enterprisedb`, make a copy of the `efm-41` file, and modify the content to allow the user to access the `efm_functions` script to manage their clusters. + +If an agent cannot start because of permission problems, make sure the default `/etc/sudoers` file contains the following line at the end of the file: + +```text +## Read drop-in files from /etc/sudoers.d (the # here does not # mean a comment) + +#includedir /etc/sudoers.d +``` + + + +## Running Failover Manager without sudo + +By default, Failover Manager uses sudo to securely manage access to system functionality. If you choose to configure Failover Manager to run without sudo access, Note that root access is still required to: + +- install the Failover Manager RPM. +- perform Failover Manager setup tasks. + +To run Failover Manager without sudo, you must select a database process owner that will have privileges to perform management functions on behalf of Failover Manager. The user could be the default database superuser (for example, enterprisedb or postgres) or another privileged user. After selecting the user: + +1. Use the following command to add the user to the `efm` group: + + ```text + usermod -a -G efm enterprisedb + ``` + + This should allow the user to write to `/var/run/efm-4.0` and `/var/lock/efm-4.0`. + +2. If you are reusing a cluster name, remove any previously created log files; the new user will not be able to write to log files created by the default (or other) owner. + +3. Copy the cluster properties template file and the nodes template file: + + ```text + su - enterprisedb + + cp /etc/edb/efm-4.0/efm.properties.in .properties + + cp /etc/edb/efm-4.0/efm.nodes.in /.nodes + ``` + +Then, modify the cluster properties file, providing the name of the user in the `db.service.owner` property. You must also ensure that the `db.service.name` property is blank; without sudo, you cannot run services without root access. + +After modifying the configuration, the new user can control Failover Manager with the following command: + +```text +/usr/edb/efm-4.0/bin/runefm.sh start|stop .properties +``` + +Where `` specifies the full path of the cluster properties file. Note that the user must ensure that the full path to the properties file must be provided whenever the non-default user is controlling agents or using the efm script. + +To allow the new user to manage Failover Manager as a service, you must provide a custom script or unit file. + +Failover Manager uses a binary named `manage-vip` that resides in `/usr/edb/efm-4.0/bin/secure/` to perform VIP management operations without sudo privileges. This script uses setuid to acquire with the privileges needed to manage Virtual IP addresses. + +- This directory is only accessible to root and users in the `efm` group. +- The binary is only executable by root and the `efm` group. + +For security reasons, we recommend against modifying the access privileges of the `/usr/edb/efm-4.0/bin/secure/` directory or the `manage-vip` script. + +For more information about using Failover Manager without sudo, visit: + + diff --git a/product_docs/docs/efm/4.0/efm_user/04_configuring_efm/05_using_vip_addresses.mdx b/product_docs/docs/efm/4.0/efm_user/04_configuring_efm/05_using_vip_addresses.mdx new file mode 100644 index 00000000000..99f5a68f4a2 --- /dev/null +++ b/product_docs/docs/efm/4.0/efm_user/04_configuring_efm/05_using_vip_addresses.mdx @@ -0,0 +1,148 @@ +--- +title: "Using Failover Manager with Virtual IP Addresses" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.0/using_vip_addresses.html" +--- + + + +Failover Manager uses the `efm_address` script to assign or release a virtual IP address. + +!!! Note + Virtual IP addresses are not supported by many cloud providers. In those environments, another mechanism should be used (such as an Elastic IP Address on AWS), which can be changed when needed by a fencing or post-promotion script. + +By default, the script resides in: + + `/usr/edb/efm-4.0/bin/efm_address` + +Failover Manager uses the following command variations to assign or release an IPv4 or IPv6 IP address. + +To assign a virtual IPv4 IP address: + +```text +# efm_address add4 / +``` + +To assign a virtual IPv6 IP address: + +```text +# efm_address add6 / +``` + +To release a virtual address: + +```text +# efm_address del +``` + +Where: + + `` matches the name specified in the `virtual.ip.interface` property in the cluster properties file. + + `` or `` matches the value specified in the `virtual.ip` property in the cluster properties file. + + `prefix` matches the value specified in the `virtual.ip.prefix` property in the cluster properties file. + +For more information about properties that describe a virtual IP address, see [The Cluster Properties File](01_cluster_properties/#virtual_ip). + +You must invoke the `efm_address` script as the root user. The `efm` user is created during the installation, and is granted privileges in the sudoers file to run the `efm_address` script. For more information about the sudoers file, see [Extending Failover Manager Permissions](04_extending_efm_permissions/#extending_efm_permissions). + +!!! Note + If a VIP address (or any address other than the `bind.address`) is assigned to a node, the operating system can choose the source address used when contacting the database. Be sure that you modify the `pg_hba.conf` file on all monitored databases to allow contact from all addresses within your replication scenario. + +**Testing the VIP** + +When using a virtual IP (VIP) address with Failover Manager, it is important to test the VIP functionality manually before starting Failover manager. This will catch any network-related issues before they cause a problem during an actual failover. While testing the VIP, ensure that Failover Manager is not running. + +The following steps test the actions that Failover Manager will take. The example uses the following property values: + +```text +virtual.ip=172.24.38.239 +virtual.ip.interface=eth0 +virtual.ip.prefix=24 +ping.server.command=/bin/ping -q -c3 -w5 +``` + +!!! Note + The `virtual.ip.prefix` specifies the number of significant bits in the virtual Ip address. + +When instructed to ping the VIP from a node, use the command defined by the `ping.server.command` property. + +1. Ping the VIP from all nodes to confirm that the address is not already in use: + +```text +# /bin/ping -q -c3 -w5 172.24.38.239 +PING 172.24.38.239 (172.24.38.239) 56(84) bytes of data. +--- 172.24.38.239 ping statistics --- +4 packets transmitted, 0 received, +3 errors, 100% packet loss, + time 3000ms +``` + +You should see 100% packet loss. + +2. Run the `efm_address add4` command on the Primary node to assign the VIP and then confirm with ip address: + +```text +# efm_address add4 eth0 172.24.38.239/24 +# ip address + +eth0 Link encap:Ethernet HWaddr 36:AA:A4:F4:1C:40 +inet addr:172.24.38.239 Bcast:172.24.38.255 +... +``` + +3. Ping the VIP from the other nodes to verify that they can reach the VIP: + +```text +# /bin/ping -q -c3 -w5 172.24.38.239 +PING 172.24.38.239 (172.24.38.239) 56(84) bytes of data. +--- 172.24.38.239 ping statistics --- +3 packets transmitted, 3 received, 0% packet loss, time 1999ms +rtt min/avg/max/mdev = 0.023/0.025/0.029/0.006 ms +``` + +You should see no packet loss. + +4. Use the `efm_address del` command to release the address on the primary node and confirm the node has been released with ip address: + +```text +# efm_address del eth0 172.24.38.239/24 +# ip address +eth0 Link encap:Ethernet HWaddr 22:00:0A:89:02:8E +inet addr:10.137.2.142 Bcast:10.137.2.191 +... +``` + +The output from this step should not show an eth0 interface + +5. Repeat step 3, this time verifying that the Standby and Witness do not see the VIP in use: + +```text +# /bin/ping -q -c3 -w5 172.24.38.239 +PING 172.24.38.239 (172.24.38.239) 56(84) bytes of data. +--- 172.24.38.239 ping statistics --- +4 packets transmitted, 0 received, +3 errors, 100% packet loss, + time 3000ms +``` + +You should see 100% packet loss. Repeat this step on all nodes. + +6. Repeat step 2 on all Standby nodes to assign the VIP to every node. You can ping the VIP from any node to verify that it is in use. + +```text +# efm_address add4 eth0 172.24.38.239/24 +# ip address + +eth0 Link encap:Ethernet HWaddr 36:AA:A4:F4:1C:40 +inet addr:172.24.38.239 Bcast:172.24.38.255 +... +``` + +After the test steps above, release the VIP from any non-Primary node before attempting to start Failover Manager. + +!!! Note + The network interface used for the VIP does not have to be the same interface used for the Failover Manager agent's `bind.address` value. The primary agent will drop the VIP as needed during a failover, and Failover Manager will verify that the VIP is no longer available before promoting a standby. A failure of the bind address network will lead to primary isolation and failover. + +If the VIP uses a different interface, you may encounter a timing condition where the rest of the cluster checks for a reachable VIP before the primary agent has dropped it. In this case, EFM will retry the VIP check for the number of seconds specified in the `node.timeout` property to help ensure that a failover happens as expected. diff --git a/product_docs/docs/efm/4.0/efm_user/04_configuring_efm/index.mdx b/product_docs/docs/efm/4.0/efm_user/04_configuring_efm/index.mdx new file mode 100644 index 00000000000..a89e7f687b9 --- /dev/null +++ b/product_docs/docs/efm/4.0/efm_user/04_configuring_efm/index.mdx @@ -0,0 +1,20 @@ +--- +title: "Configuring Failover Manager" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.0/configuring_efm.html" +--- + + + +Configurable Failover Manager properties are specified in two user-modifiable files: + +- [efm.properties](01_cluster_properties/#cluster_properties) +- [efm.nodes](03_cluster_members/#cluster_members) + +
+ +cluster_properties encrypting_database_password cluster_members extending_efm_permissions using_vip_addresses + +
diff --git a/product_docs/docs/efm/4.0/efm_user/05_using_efm.mdx b/product_docs/docs/efm/4.0/efm_user/05_using_efm.mdx new file mode 100644 index 00000000000..25fb74d736d --- /dev/null +++ b/product_docs/docs/efm/4.0/efm_user/05_using_efm.mdx @@ -0,0 +1,318 @@ +--- +title: "Using Failover Manager" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.0/using_efm.html" +--- + + + +Failover Manager offers support for monitoring and failover of clusters with one or more Standby servers. You can add or remove nodes from the cluster as your demand for resources grows or shrinks. + +If a primary node reboots, Failover Manager may detect the database is down on the Primary node and promote a Standby node to the role of Primary. If this happens, the Failover Manager agent on the (rebooted) Primary node will not get a chance to write the `recovery.conf` file; the rebooted Primary node will return to the cluster as a second Primary node. To prevent this, start the Failover Manager agent before starting the database server. The agent will start in idle mode, and check to see if there is already a primary in the cluster. If there is a primary node, the agent will verify that a `recovery.conf` or `standby.signal` file exists, and the database will not start as a second primary. + +## Managing a Failover Manager Cluster + +Once configured, a Failover Manager cluster requires no regular maintenance. The following sections provide information about performing the management tasks that may occasionally be required by a Failover Manager Cluster. + +By default, [some of the efm commands](07_using_efm_utility/#using_efm_utility) must be invoked by `efm` or an OS superuser; an administrator can selectively permit users to invoke these commands by adding the user to the `efm` group. The commands are: + +- [efm allow-node](07_using_efm_utility/#efm_allow_node) +- [efm disallow-node](07_using_efm_utility/#efm_disallow_node) +- [efm promote](07_using_efm_utility/#efm_promote) +- [efm resume](07_using_efm_utility/#efm_resume) +- [efm set-priority](07_using_efm_utility/#efm_set_priority) +- [efm stop-cluster](07_using_efm_utility/#efm_stop_cluster) +- [efm upgrade-conf](07_using_efm_utility/#efm_upgrade_conf) + + + +### Starting the Failover Manager Cluster + +You can start the nodes of a Failover Manager cluster in any order. + +To start the Failover Manager cluster on RHEL/CentOS 7.x or RHEL/CentOS 8.x, assume superuser privileges, and invoke the command: + +```text +systemctl start edb-efm-4.0 +``` + +If the cluster properties file for the node specifies that `is.witness` is `true`, the node will start as a Witness node. + +If the node is not a dedicated Witness node, Failover Manager will connect to the local database and invoke the `pg_is_in_recovery()` function. If the server responds `false`, the agent assumes the node is a Primary node, and assigns a virtual IP address to the node (if applicable). If the server responds `true`, the Failover Manager agent assumes that the node is a Standby server. If the server does not respond, the agent will start in an idle state. + +After joining the cluster, the Failover Manager agent checks the supplied database credentials to ensure that it can connect to all of the databases within the cluster. If the agent cannot connect, the agent will shut down. + +If a new primary or standby node joins a cluster, all of the existing nodes will also confirm that they can connect to the database on the new node. + + + +!!! Note + If you are running `/var/lock` or `/var/run` on `tmpfs` (Temporary File System), make sure that the systemd service file for Failover Manager has a dependency on `systemd-tmpfiles-setup.service`. + +### Adding Nodes to a Cluster + +You can add a node to a Failover Manager cluster at any time. When you add a node to a cluster, you must modify the cluster to allow the new node, and then tell the new node how to find the cluster. The following steps detail adding a node to a cluster: + +1. Unless `auto.allow.hosts` is set to `true`, use the `efm allow-node` command, to add the address of the new node to the Failover Manager allowed node host list. When invoking the command, specify the cluster name and the address of the new node: + + ```text + efm allow-node
+ ``` + + For more information about using the `efm allow-node` command or controlling a Failover Manager service, see [Using the EFM Utility](07_using_efm_utility/#efm_allow_node). + + Install a Failover Manager agent and configure the cluster properties file on the new node. For more information about modifying the properties file, see [The Cluster Properties File](04_configuring_efm/01_cluster_properties/#cluster_properties). + +2. Configure the cluster members file on the new node, adding an entry for the Membership Coordinator. For more information about modifying the cluster members file, see [The Cluster Members File](04_configuring_efm/03_cluster_members/#cluster_members). + +3. Assume superuser privileges on the new node, and start the Failover Manager agent. To start the Failover Manager cluster on RHEL/CentOS 7.x or RHEL/CentOS 8.x, invoke the command: + + ```text + systemctl start edb-efm-4.0 + ``` + +When the new node joins the cluster, Failover Manager will send a notification to the administrator email provided in the `user.email` property, and/or will invoke the specified notification script. + + + +!!! Note + To be a useful Standby for the current node, the node must be a standby in the PostgreSQL Streaming Replication scenario. + +### Changing the Priority of a Standby + +If your Failover Manager cluster includes more than one Standby server, you can use the `efm set-priority` command to influence the promotion priority of a Standby node. Invoke the command on any existing member of the Failover Manager cluster, and specify a priority value after the IP address of the member. + +For example, the following command instructs Failover Manager that the `acctg` cluster member that is monitoring `10.0.1.9` is the primary Standby `(1)`: + +```text +efm set-priority acctg 10.0.1.9 1 +``` + +You can set the priority of a standby to `0` to make the standby non-promotable. Setting the priority of a standby to a value greater than `0` overrides a property value of `promotable=false`. + +For example, if the properties file on node `10.0.1.10` includes a setting of `promotable=false` and you use `efm set-priority` to set the promotion priority of `10.0.1.10` to be the standby used in the event of a failover, the value designated by the `efm set-priority` command will override the value in the property file: + +```text +efm set-priority acctg 10.0.1.10 1 +``` + +In the event of a failover, Failover Manager will first retrieve information from Postgres streaming replication to confirm which Standby node has the most recent data, and promote the node with the least chance of data loss. If two Standby nodes contain equally up-to-date data, the node with a higher user-specified priority value will be promoted to Primary unless [use.replay.tiebreaker](04_configuring_efm/01_cluster_properties/#use_replay_tiebreaker) is set to `false` . To check the priority value of your Standby nodes, use the command: + +```text +efm cluster-status +``` + + + +!!! Note + The promotion priority may change if a node becomes isolated from the cluster, and later re-joins the cluster. + +### Promoting a Failover Manager Node + +You can invoke `efm promote` on any node of a Failover Manager cluster to start a manual promotion of a Standby database to Primary database. + +Manual promotion should only be performed during a maintenance window for your database cluster. If you do not have an up-to-date Standby database available, you will be prompted before continuing. To start a manual promotion, assume the identity of `efm` or the OS superuser, and invoke the command: + +```text +efm promote [-switchover] [-sourcenode
] [-quiet] [-noscripts]` +``` + +Where: + + `` is the name of the Failover Manager cluster. + + Include the `–switchover` option to reconfigure the original Primary as a Standby. If you include the `–switchover` keyword, the cluster must include a primary node and at least one standby, and the nodes must be in sync. + + Include the `–sourcenode` keyword to specify the node from which the recovery settings will be copied to the primary. + + Include the `-quiet` keyword to suppress notifications during switchover. + + Include the `-noscripts` keyword to prevent instruct Failover Manager to not invoke fencing and post-promotion scripts. + +During switchover: + +- For server versions 11 and prior, the `recovery.conf` file is copied from an existing standby to the primary node. For server version 12 and later, the `primary_conninfo` and `restore_command` parameters are copied and stored in memory. +- The primary database is stopped. +- If you are using a VIP, the address is released from the primary node. +- A standby is promoted to replace the primary node, and acquires the VIP. +- The address of the new primary node is added to the `recovery.conf` file or the `primary_conninfo` details are stored in memory. +- If the `application.name` property is set for this node, the application_name property will be added to the `recovery.conf` file or the `primary_conninfo` information will be stored in memory. +- If you are using server version 12 or later, the recovery settings that have been stored in memory are written to the `postgresql.auto.conf` file. A `standby.signal` file is created. +- The old primary is started; the agent will resume monitoring it as a standby. + +During a promotion, the Primary agent releases the virtual IP address. If it is not a switchover, a recovery.conf file is created in the directory specified by the db.data.dir property. The recovery.conf file is used to prevent the old primary database from starting until the file is removed, preventing the node from starting as a second primary in the cluster. If the promotion is part of a switchover, recovery settings are handled as described above. + +The Primary agent remains running, and assumes a status of Idle. + +The Standby agent confirms that the virtual IP address is no longer in use before pinging a well- known address to ensure that the agent is not isolated from the network. The Standby agent runs the fencing script and promotes the Standby database to Primary. The Standby agent then assigns the virtual IP address to the Standby node, and runs the post-promotion script (if applicable). + +Note that this command instructs the service to ignore the value specified in the `auto.failover` parameter in the cluster properties file. + +To return a node to the role of primary, place the node first in the promotion list: + +```text +efm set-priority
+``` + +Then, perform a manual promotion: + +```text +efm promote ‑switchover +``` + +For more information about the efm utility, see [Using the EFM Utility](07_using_efm_utility/#using_efm_utility). + + + +### Stopping a Failover Manager Agent + +When you stop an agent, Failover Manager will remove the node's address from the cluster members list on all of the running nodes of the cluster, but will not remove the address from the Failover Manager Allowed node host list. + +To stop the Failover Manager agent on RHEL/CentOS 7.x or RHEL/CentOS 8.x, assume superuser privileges, and invoke the command: + +```text +systemctl stop edb-efm-4.0 +``` + +Until you invoke the `efm disallow-node` command (removing the node's address of the node from the Allowed node host list), you can use the `service edb-efm-4.0 start` command to restart the node at a later date without first running the `efm allow-node` command again. + + +Note that stopping an agent does not signal the cluster that the agent has failed unless the [primary.shutdown.as.failure](04_configuring_efm/01_cluster_properties/cluster_properties/#primary_shutdown_as_failure) property is set to `true`. + +### Stopping a Failover Manager Cluster + +To stop a Failover Manager cluster, connect to any node of a Failover Manager cluster, assume the identity of `efm` or the OS superuser, and invoke the command: + +```text +efm stop-cluster +``` + +The command will cause *all* Failover Manager agents to exit. Terminating the Failover Manager agents completely disables all failover functionality. + +!!! Note + When you invoke the `efm stop-cluster` command, all authorized node information is lost from the Allowed node host list. + +### Removing a Node from a Cluster + +The `efm disallow-node` command removes the IP address of a node from the Failover Manager Allowed Node host list. Assume the identity of `efm` or the OS superuser on any existing node (that is currently part of the running cluster), and invoke the `efm disallow-node` command, specifying the cluster name and the IP address of the node: + +```text +efm disallow-node
+``` + +The `efm disallow-node` command will not stop a running agent; the service will continue to run on the node until you [stop the agent](#stop_efm_agent). If the agent or cluster is subsequently stopped, the node will not be allowed to rejoin the cluster, and will be removed from the failover priority list (and will be ineligible for promotion). + +After invoking the `efm disallow-node` command, you must use the [efm allow-node](07_using_efm_utility/#efm_allow_node) command to add the node to the cluster again. + + + +## Running Multiple Agents on a Single Node + +You can monitor multiple database clusters that reside on the same host by running multiple Primary or Standby agents on that Failover Manager node. You may also run multiple Witness agents on a single node. To configure Failover Manager to monitor more than one database cluster, while ensuring that Failover Manager agents from different clusters do not interfere with each other, you must: + +1. Create a cluster properties file for each member of each cluster that defines a unique set of properties and the role of the node within the cluster. +2. Create a cluster members file for each member of each cluster that lists the members of the cluster. +3. Customize the unit file (on a RHEL/CentOS 7.x or RHEL/CentOS 8.x system) for each cluster to specify the names of the cluster properties and the cluster members files. +4. Start the services for each cluster. + +The examples that follow uses two database clusters (acctg and sales) running on the same node: + +- Data for `acctg` resides in `/opt/pgdata1`; its server is monitoring port `5444`. +- Data for `sales` resides in `/opt/pgdata2`; its server is monitoring port `5445`. + +To run a Failover Manager agent for both of these database clusters, use the `efm.properties.in` template to create two properties files. Each cluster properties file must have a unique name. For this example, we create `acctg.properties` and `sales.properties` to match the `acctg` and `sales` database clusters. + +The following parameters must be unique in each cluster properties file: + + `admin.port` + + `bind.address` + + `db.port` + + `db.data.dir` + + `virtual.ip` (if used) + + `virtual.ip.interface` (if used) + +Within each cluster properties file, the `db.port` parameter should specify a unique value for each cluster, while the `db.user` and `db.database` parameter may have the same value or a unique value. For example, the `acctg.properties` file may specify: + + `db.user=efm_user` + + `db.password.encrypted=7c801b32a05c0c5cb2ad4ffbda5e8f9a` + + `db.port=5444` + + `db.database=acctg_db` + +While the `sales.properties` file may specify: + + `db.user=efm_user` + + `db.password.encrypted=e003fea651a8b4a80fb248a22b36f334` + + `db.port=5445` + + `db.database=sales_db` + +Some parameters require special attention when setting up more than one Failover Manager cluster agent on the same node. If multiple agents reside on the same node, each port must be unique. Any two ports will work, but it may be easier to keep the information clear if using ports that are not too close to each other. + +When creating the cluster properties file for each cluster, the `db.data.dir` parameters must also specify values that are unique for each respective database cluster. + +The following parameters are used when assigning the virtual IP address to a node. If your Failover Manager cluster does not use a virtual IP address, leave these parameters blank. + + `virtual.ip` + + `virtual.ip.interface` + + `virtual.ip.prefix` + +This parameter value is determined by the virtual IP addresses being used and may or may not be the same for both `acctg.properties` and `sales.properties`. + +After creating the `acctg.properties` and `sales.properties` files, create a service script or unit file for each cluster that points to the respective property files; this step is platform specific. If you are using RHEL/CentOS 7.x or RHEL/CentOS 8.x, see [RHEL/CentOS 7.x or RHEL/CentOS 8.x](#rhelcentos-7x-or-rhelcentos-8x). + +!!! Note + If you are using a unit file, you must manually update the file to reflect the new service name when you upgrade Failover Manager. + +### RHEL/CentOS 7.x or RHEL/CentOS 8.x + +If you are using RHEL/CentOS 7.x or RHEL/CentOS 8.x, you should copy the `edb-efm-4.0` unit file to new file with a name that is unique for each cluster. For example, if you have two clusters (named acctg and sales), the unit file names might be: + +```text +/usr/lib/systemd/system/efm-acctg.service + +/usr/lib/systemd/system/efm-sales.service +``` + +Then, edit the `CLUSTER` variable within each unit file, changing the specified cluster name from `efm` to the new cluster name. For example, for a cluster named `acctg`, the value would specify: + +```text +Environment=CLUSTER=acctg +``` + +You must also update the value of the `PIDfile` parameter to specify the new cluster name. For example: + +```text +PIDFile=/var/run/efm-4.0/acctg.pid +``` + +After copying the service scripts, use the following commands to enable the services: + +```text +# systemctl enable efm-acctg.service + +# systemctl enable efm-sales.service +``` + +Then, use the new service scripts to start the agents. For example, you can start the `acctg` agent with the command: + +```text +# systemctl start efm-acctg` +``` + +For information about customizing a unit file, please visit: + + diff --git a/product_docs/docs/efm/4.0/efm_user/06_monitoring_efm_cluster.mdx b/product_docs/docs/efm/4.0/efm_user/06_monitoring_efm_cluster.mdx new file mode 100644 index 00000000000..fe731b8548d --- /dev/null +++ b/product_docs/docs/efm/4.0/efm_user/06_monitoring_efm_cluster.mdx @@ -0,0 +1,142 @@ +--- +title: "Monitoring a Failover Manager Cluster" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.0/monitoring_efm_cluster.html" +--- + + + +You can use either the Failover Manager `efm cluster-status` command or the PEM Client graphical interface to check the current status of a monitored node of a Failover Manager cluster. + +## Reviewing the Cluster Status Report + +The efm cluster-status [cluster properties file](07_using_efm_utility/#efm_cluster_status) command returns a report that contains information about the status of the Failover Manager cluster. To invoke the command, enter: + +```text +# efm cluster-status +``` + +The following status report is for a cluster named edb that has three nodes running: + +```text +Agent Type Address Agent DB VIP +----------------------------------------------------------------------- +Standby 172.19.10.2 UP UP 192.168.225.190 +Standby 172.19.12.163 UP UP 192.168.225.190 +Primary 172.19.14.9 UP UP 192.168.225.190* + + +Allowed node host list: +172.19.14.9 172.19.12.163 172.19.10.2 + + +Membership coordinator: 172.19.14.9 + + +Standby priority host list: +172.19.12.163 172.19.10.2 + +Promote Status: + +DB Type Address WAL Received LSN WAL Replayed LSN Info +-------------------------------------------------------------------- +Primary 172.19.14.9 0/4000638 +Standby 172.19.12.163 0/4000638 0/4000638 +Standby 172.19.10.2 0/4000638 0/4000638 + + +Standby database(s) in sync with primary. It is safe to promote. +``` + +The cluster status section provides an overview of the status of the agents that reside on each node of the cluster: + +```text +Agent Type Address Agent DB VIP +----------------------------------------------------------------------- +Standby 172.19.10.2 UP UP 192.168.225.190 +Standby 172.19.12.163 UP UP 192.168.225.190 +Primary 172.19.14.9 UP UP 192.168.225.190* +``` + +The asterisk (\*) after the VIP address indicates that the address is available for connections. If a VIP address is not followed by an asterisk, the address has been associated with the node (in the properties file), but the address is not currently in use. + +Failover Manager agents provide the information displayed in the Cluster Status section. + +The `Allowed node host list` and `Standby priority host list` provide an easy way to tell which nodes are allowed to join the cluster, and the promotion order of the nodes. The IP address of the Membership coordinator is also displayed in the report: + +```text +Allowed node host list: +172.19.14.9 172.19.12.163 172.19.10.2 +Membership coordinator: 172.19.14.9 +Standby priority host list: +172.19.12.163 172.19.10.2 +``` + +The `Promote Status` section of the report is the result of a direct query from the node on which you are invoking the cluster-status command to each database in the cluster; the query also returns the transaction log location of each database. Because the queries to each database return at different points in time, the LSNs may not match even if streaming replication is working normally for the cluster. + +```text +Promote Status: + +DB Type Address WAL Received LSN WAL Replayed LSN Info +------------------------------------------------------------------- +Primary 172.19.14.9 0/4000638 +Standby 172.19.12.163 0/4000638 0/4000638 +Standby 172.19.10.2 0/4000638 0/4000638 +``` + +If a database is down (or if the database has been restarted, but the resume command has not yet been invoked), the state of the agent that resides on that host will be Idle. If an agent is idle, the cluster status report will include a summary of the condition of the idle node. For example: + +```text +Agent Type Address Agent DB VIP +----------------------------------------------------- +Idle 172.19.18.105 UP UP 172.19.13.105 +``` + +**Exit Codes** + +The cluster status process returns an exit code that is based on the state of the cluster: + +- An exit code of `0` indicates that all agents are running, and the databases on the Primary and Standby nodes are running and in sync. + +- A non-zero exit code indicates that there is a problem. The following problems can trigger a non-zero exit code: + + A database is down or unknown (or has an idle agent). + + Failover Manager cannot decrypt the provided database password. + + There is a problem contacting the databases to get WAL locations. + + There is no Primary agent. + + There are no Standby agents. + + One or more Standby nodes are not in sync with the Primary. + +## Monitoring Streaming Replication with Postgres Enterprise Manager + +If you use Postgres Enterprise Manager (PEM) to monitor your servers, you can configure the Streaming Replication Analysis dashboard (part of the PEM graphical interface) to display the state of a Primary or Standby node that is part of a Streaming Replication scenario. + +![The Streaming Replication dashboard (Primary node)](images/str_replication_dashboard_master.png) + +The Streaming Replication Analysis Dashboard displays statistical information about activity for any monitored server on which streaming replication is enabled. The dashboard header identifies the status of the monitored server (either Replication Primary or Replication Slave), and displays the date and time that the server was last started, the date and time that the page was last updated, and a current count of triggered alerts for the server. + +When reviewing the dashboard for a Replication Slave (a Standby node), a label at the bottom of the dashboard confirms the status of the server. + +![The Streaming Replication dashboard (Standby node)](images/str_replication_dashboard_standby.png) + +By default, the PEM replication probes that provide information for the Streaming Replication Analysis dashboard are disabled. + +To view the Streaming Replication Analysis dashboard for the Primary node of a replication scenario, you must enable the following probes: + +- Streaming Replication +- WAL Archive Status + +To view the Streaming Replication Analysis dashboard for the Standby node of a replication scenario, you must enable the following probes: + +- Streaming Replication Lag Time + +For more information about PEM, please visit the EnterpriseDB website at: + + diff --git a/product_docs/docs/efm/4.0/efm_user/07_using_efm_utility.mdx b/product_docs/docs/efm/4.0/efm_user/07_using_efm_utility.mdx new file mode 100644 index 00000000000..6db8691d3e0 --- /dev/null +++ b/product_docs/docs/efm/4.0/efm_user/07_using_efm_utility.mdx @@ -0,0 +1,213 @@ +--- +title: "Using the efm Utility" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.0/using_efm_utility.html" +--- + + + +Failover Manager provides the efm utility to assist with cluster management. The RPM installer adds the utility to the `/usr/edb/efm-4.0/bin` directory when you install Failover Manager. + +**efm allow-node** + + + +```text +efm allow-node +``` + +Invoke the `efm allow-node` command to allow the specified node to join the cluster. When invoking the command, provide the name of the cluster and the IP address of the joining node. + +This command must be invoked by `efm`, a member of the `efm` group, or root. + +**efm disallow-node** + + + +```text +efm disallow-node
+``` + +Invoke the `efm disallow-node` command to remove the specified node from the allowed hosts list, and prevent the node from joining a cluster. Provide the name of the cluster and the address of the node when calling the `efm disallow-node` command. This command must be invoked by `efm`, a member of the `efm` group, or root. + +**efm cluster-status** + + + +```text +efm cluster-status +``` + +Invoke the `efm cluster-status` command to display the status of a Failover Manager cluster. For more information about the status report, see [Monitoring a Failover Manager Cluster](06_monitoring_efm_cluster/#monitoring_efm_cluster). + +**efm cluster-status-json** + + + +```text +efm cluster-status-json +``` + +Invoke the `efm cluster-status-json` command to display the status of a Failover Manager cluster in json format. While the format of the displayed information is different than the display generated by the efm cluster-status command, the information source is the same. + +The following example is generated by querying the status of a healthy cluster with three nodes: + +```text +{ + "nodes": { + "172.16.144.176": { + "type": "Witness", + "agent": "UP", + "db": "N\/A", + "vip": "", + "vip_active": false + }, + "172.16.144.177": { + "type": "Primary", + "agent": "UP", + "db": "UP", + "vip": "", + "vip_active : false" + "xlogReceive : 0/14001478" + "xlog : 0/14001478" + "xloginfo :" + }, + "172.16.144.180": { + "type": "Standby", + "agent": "UP", + "db": "UP", + "vip": "", + "vip_active : false" + "xlogReceive : 0/14001478" + "xlog : 0/14001478" + "xloginfo :" + } + }, + "allowednodes": [ + "172.16.144.177", + "172.16.144.160", + "172.16.144.180", + "172.16.144.176" + ], + "membershipcoordinator": "172.16.144.177", + "failoverpriority": [ + "172.16.144.180" + ], + "minimumstandbys": 0, + "missingnodes": [], + "messages": [] +} +``` + +**efm encrypt** + + + +```text +efm encrypt [--from-env] +``` + +Invoke the `efm encrypt` command to encrypt the database password before include the password in the cluster properties file. Include the `--from-env` option to instruct Failover Manager to use the value specified in the `EFMPASS` environment variable, and execute without user input. For more information, see [Encrypting Your Database Password](04_configuring_efm/01_cluster_properties/01_encrypting_database_password/#encrypting_database_password). + +**efm promote** + + + +```text +efm promote cluster_name [-switchover [-sourcenode
][-quiet][-noscripts] +``` + +The `efm promote` command instructs Failover Manager to perform a manual failover of standby to primary. + +Manual promotion should only be attempted if the status command reports that the cluster includes a Standby node that is up-to-date with the Primary. If there is no up-to-date Standby, Failover Manager will prompt you before continuing. + +Include the `–switchover` clause to promote a standby node, and reconfigure a primary node as a standby node. Include the `-sourcenode` keyword, and specify a node address to indicate the node whose recovery settings will be copied to the old primary node (making it a standby). Include the `-quiet` keyword to suppress notifications during the switchover process. Include the `-noscripts` keyword to instruct Failover Manager to not invoke fencing or post-promotion scripts. + +This command must be invoked by `efm`, a member of the `efm` group, or root. + +!!! Note + This command instructs the service to ignore the value specified in the `auto.failover` parameter in the cluster properties file. + +**efm resume** + + + +```text +efm resume +``` + +Invoke the `efm resume` command to resume monitoring a previously stopped database. This command must be invoked by efm, a member of the efm group, or root. + +**efm set-priority** + + + +```text +efm set-priority
+``` + +Invoke the `efm set-priority` command to assign a failover priority to a standby node. The value specifies the order in which the node will be used in the event of a failover. This command must be invoked by `efm`, a member of the `efm` group, or root. + +Use the priority option to specify the place for the node in the priority list. For example, specify a value of 1 to indicate that the node is the primary standby, and will be the first node promoted in the event of a failover. A priority value of 0 instructs Failover Manager to not promote the standby. + +**efm stop-cluster** + + + +```text +efm stop-cluster +``` + +Invoke the `efm stop-cluster` command to stop Failover Manager on all nodes. This command instructs Failover Manager to connect to each node on the cluster and instruct the existing members to shut down. The command has no effect on running databases, but when the command completes, there is no failover protection in place. + +!!! Note + When you invoke the `efm stop-cluster` command, all authorized node information is removed from the Allowed node host list. + +This command must be invoked by `efm`, a member of the `efm` group, or root. + +**efm upgrade-conf** + + + +```text +efm upgrade-conf [-source ] +``` + +Invoke the `efm upgrade-conf` command to copy the configuration files from an existing Failover Manager installation, and add parameters required by a Failover Manager installation. Provide the name of the previous cluster when invoking the utility. This command must be invoked with root privileges. + +If you are upgrading from a Failover Manager configuration that does not use sudo, include the `-source` flag and specify the name of the *directory* in which the configuration files reside when invoking upgrade-conf. + +**efm node-status-json** + + + +```text +efm node-status-json +``` + +Invoke the `efm node-status-json` command to display the status of a local node in json format. A successful execution of this command returns `0` as its exit code. In case of a database failure or an agent status becoming IDLE, the command returns `1` as exit code. + +The following is an example output of the `efm node-status-json` command: + +> ```text +> { +> "type":"Standby", +> "address":"172.16.144.130", +> "agent":"UP", +> "db":"UP", +> "vip":"", +> "vip_active":"false" +> } +> ``` + +**efm --help** + + + +```text +efm --help +``` + +Invoke the `efm --help` command to display online help for the Failover Manager utility commands. diff --git a/product_docs/docs/efm/4.0/efm_user/08_controlling_efm_service.mdx b/product_docs/docs/efm/4.0/efm_user/08_controlling_efm_service.mdx new file mode 100644 index 00000000000..4ab2f2aa6ff --- /dev/null +++ b/product_docs/docs/efm/4.0/efm_user/08_controlling_efm_service.mdx @@ -0,0 +1,55 @@ +--- +title: "Controlling the Failover Manager Service" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.0/controlling_efm_service.html" +--- + + + +Each node in a Failover Manager cluster hosts a Failover Manager agent that is controlled by a service script. By default, the service script expects to find: + +- A configuration file named `efm.properties` that contains the properties used by the Failover Manager service. Each node of a replication scenario must contain a properties file that provides information about the node. +- A cluster members file named `efm.nodes` that contains a list of the cluster members. Each node of a replication scenario must contain a cluster members list. + +Note that if you are running multiple clusters on a single node you will need to manually create configuration files with cluster-specific names and modify the service script for the corresponding clusters. + +The commands that control the Failover Manager service are platform-specific. + + + +## Using the systemctl Utility on RHEL/CentOS 7.x and RHEL/CentOS 8.x + +On RHEL/CentOS 7.x and RHEL/CentOS 8.x, Failover Manager runs as a Linux service named (by default) `edb-efm-4.0.service` that is located in `/usr/lib/systemd/system`. Each database cluster monitored by Failover Manager will run a copy of the service on each node of the replication cluster. + +Use the following systemctl commands to control a Failover Manager agent that resides on a RHEL/CentOS 7.x and RHEL/CentOS 8.x host: + +```text +systemctl start edb-efm-4.0 +``` + +The start command starts the Failover Manager agent on the current node. The local Failover Manager agent monitors the local database and communicates with Failover Manager on the other nodes. You can start the nodes in a Failover Manager cluster in any order. This command must be invoked by root. + +```text +systemctl stop edb-efm-4.0 +``` + +Stop the Failover Manager on the current node. This command must be invoked by root. + +```text +systemctl status edb-efm-4.0 +``` + +The status command returns the status of the Failover Manager agent on which it is invoked. You can invoke the status command on any node to instruct Failover Manager to return status and server startup information. + +```text +[root@ONE ~]}> systemctl status edb-efm-4.0 + edb-efm-4.0.service - EnterpriseDB Failover Manager 4.0 + Loaded: loaded (/usr/lib/systemd/system/edb-efm-4.0.service; disabled; vendor preset: disabled) + Active: active (running) since Wed 2013-02-14 14:02:16 EST; 4s ago + Process: 58125 ExecStart=/bin/bash -c /usr/edb/edb-efm-4.0/bin/runefm.sh start ${CLUSTER} (code=exited, status=0/SUCCESS) + Main PID: 58180 (java) + CGroup: /system.slice/edb-efm-4.0.service + └─58180 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-0.b14.el7_4.x86_64/jre/bin/java -cp /usr/edb/edb-efm-4.0/lib/EFM-4.0.0.jar -Xmx128m... +``` diff --git a/product_docs/docs/efm/4.0/efm_user/09_controlling_logging.mdx b/product_docs/docs/efm/4.0/efm_user/09_controlling_logging.mdx new file mode 100644 index 00000000000..af66915f9c0 --- /dev/null +++ b/product_docs/docs/efm/4.0/efm_user/09_controlling_logging.mdx @@ -0,0 +1,90 @@ +--- +title: "Controlling Logging" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.0/controlling_logging.html" +--- + + + +Failover Manager writes and stores one log file per agent and one startup log per agent in `/var/log/-4.0` (where `` specifies the name of the cluster). + +You can control the level of detail written to the agent log by modifying the `jgroups.loglevel` and `efm.loglevel` parameters in the [cluster properties file](04_configuring_efm/01_cluster_properties/#loglevel): + +```text +# Logging levels for JGroups and EFM. +# Valid values are: TRACE, DEBUG, INFO, WARN, ERROR +# Default value: INFO +# It is not necessary to increase these values unless debugging a +# specific issue. If nodes are not discovering each other at +# startup, increasing the jgroups level to DEBUG will show +# information about the TCP connection attempts that may help +# diagnose the connection failures. +jgroups.loglevel=INFO +efm.loglevel=INFO +``` + +The logging facilities use the Java logging library and logging levels. The log levels (in order from most logging output to least) are: + +> - `TRACE` +> - `DEBUG` +> - `INFO` +> - `WARN` +> - `ERROR` + +For example, if you set the `efm.loglevel` parameter to `WARN`, Failover Manager will only log messages at the `WARN` level and above (`WARN` and `ERROR`). + +By default, Failover Manager log files are rotated daily, compressed, and stored for a week. You can modify the file rotation schedule by changing settings in the log rotation file (`/etc/logrotate.d/efm-4.0`). For more information about modifying the log rotation schedule, consult the logrotate man page: + +> `$ man logrotate` + + + +## Enabling syslog Log File Entries + +Failover Manager supports syslog logging. To implement syslog logging, you must configure syslog to allow UDP or TCP connections. + +To allow a connection to syslog, edit the `/etc/rsyslog.conf` file and uncomment the protocol you wish to use. You must also ensure that the `UDPServerRun` or `TCPServerRun` entry associated with the protocol includes the port number to which log entries will be sent. For example, the following configuration file entries enable UDP connections to port 514: + +```text +# Provides UDP syslog reception +$ModLoad imudp +$UDPServerRun 514 +``` + +The following configuration file entries enable TCP connections to port 514: + +```text +# Provides TCP syslog reception +$ModLoad imtcp +$InputTCPServerRun 514 +``` + +After modifying the syslog configuration file, restart the `rsyslog` service to enable the connections: + +> `systemctl restart rsyslog.service` + +After modifying the `rsyslog.conf` file on the Failover Manager host, you must modify the Failover Manager properties to enable logging. Use your choice of editor to [modify the properties file](04_configuring_efm/01_cluster_properties/#logtype_enabled) (`/etc/edb/efm-4.1/efm.properties.in`) specifying the type of logging that you wish to implement: + +```text +# Which logging is enabled. +file.log.enabled=true +syslog.enabled=false +``` + +You must also [specify syslog details](04_configuring_efm/01_cluster_properties/#syslog_logging) for your system. Use the `syslog.protocol` parameter to specify the protocol type (UDP or TCP) and the `syslog.port` parameter to specify the listener port of the syslog host. The `syslog.facility` value may be used as an identifier for the process that created the entry; the value must be between `LOCAL0` and `LOCAL7`. + +```text +# Syslog information. The syslog service must be listening # on the + port for the given protocol, which can be UDP or +# TCP. The facilities supported are LOCAL0 through LOCAL7. +# syslog.host=localhost +syslog.port=514 +syslog.protocol=UDP +syslog.facility=LOCAL1 +``` + +For more information about syslog, please see the syslog man page: + +> `syslog man` diff --git a/product_docs/docs/efm/4.0/efm_user/10_notifications.mdx b/product_docs/docs/efm/4.0/efm_user/10_notifications.mdx new file mode 100644 index 00000000000..3087ea24575 --- /dev/null +++ b/product_docs/docs/efm/4.0/efm_user/10_notifications.mdx @@ -0,0 +1,157 @@ +--- +title: "Notifications" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.0/notifications.html" +--- + + + +Failover Manager will send e-mail notifications and/or invoke a notification script when a notable event occurs that affects the cluster. If you have configured Failover Manager to send an email notification, you must have an SMTP server running on port 25 on each node of the cluster. Use the following parameters to configure notification behavior for Failover Manager: + +```text +user.email +script.notification +from.email +``` + +For more information about editing the configuration properties, see [Specifying Cluster Properties](04_configuring_efm/01_cluster_properties/#cluster_properties). + +The body of the notification contains details about the event that triggered the notification, and about the current state of the cluster. For example: + +```text +EFM node: 10.0.1.11 +Cluster name: acctg +Database name: postgres +VIP: ip_address (Active|Inactive) +Database health is not being monitored. +``` + +The VIP field displays the IP address and state of the virtual IP if implemented for the node. + +Failover Manager assigns a severity level to each notification. The following levels indicate increasing levels of attention required: + +- `INFO` indicates an informational message about the agent and does not require any manual intervention (for example, Failover Manager has started or stopped). See [List of INFO level notifications](#notifications_info) +- `WARNING` indicates that an event has happened that requires the administrator to check on the system (for example, failover has occurred). See [List of WARNING level notifications](#notifications_warning) +- `SEVERE` indicates that a serious event has happened and requires the immediate attention of the administrator (for example, failover was attempted, but was unable to complete). See [List of SEVERE level notifications](#notifications_severe) + +The severity level designates the urgency of the notification. A notification with a severity level of `SEVERE` requires user attention immediately, while a notification with a severity level of `INFO` will call your attention to operational information about your cluster that does not require user action. Notification severity levels are not related to logging levels; all notifications are sent regardless of the log level detail specified in the configuration file. + +You can use the [notification.level](04_configuring_efm/01_cluster_properties/#notification_level) property to specify the minimum severity level that will trigger a notification. + +!!! Note + In addition to sending notices to the administrative email address, all notifications are recorded in the cluster log file (`/var/log/efm-4.0/.log`). + +The conditions listed in the table below will trigger an `INFO` level notification: + + + +| Subject | Description | +| ---------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| Executed fencing script | Executed fencing script script_name Results: script_results | +| Executed post-promotion script | Executed post-promotion script script_name Results: script_results | +| Executed remote pre-promotion script | Executed remote pre-promotion script script_name Results: script_results | +| Executed remote post-promotion script | Executed remote post-promotion script script_name Results: script_results | +| Executed post-database failure script | Executed post-database failure script script_name Results: script_results | +| Executed primary isolation script | Executed primary isolation script script_name Results: script_results | +| Witness agent running on node_address for cluster cluster_name | Witness agent is running. | +| Primary agent running on node_address for cluster cluster_name | Primary agent is running and database health is being monitored. | +| Standby agent running on node_address for cluster cluster_name | Standby agent is running and database health is being monitored. | +| Idle agent running on node node_address for cluster cluster_name | Idle agent is running. After starting the local database, the agent can be resumed. | +| Assigning VIP to node node_address | Assigning VIP VIP_address to node node_address Results: script_results | +| Releasing VIP from node node_address | Releasing VIP VIP_address from node node_address Results: script_results | +| Starting auto resume check for cluster cluster_name | The agent on this node will check every auto.resume.period seconds to see if it can resume monitoring the failed database. The cluster should be checked during this time and the agent stopped if the database will not be started again. See the agent log for more details. | +| Executed agent resumed script | Executed agent resumed script script_name Results: script_results | +| WAL logs backed up during promotion | When reconfiguring this standby to follow the new primary, the pg_xlog or pg_wal contents were backed up in the pgdata directory. This backup should be removed when convenient to free up disk space. | + +The conditions listed in the table below will trigger a *WARNING* level notification: + + + +| Subject | Description | +| ------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Witness agent exited on node_address for cluster cluster_name | Witness agent has exited. | +| Primary agent exited on node_address for cluster cluster_name | Database health is not being monitored. | +| Cluster cluster_name notified that primary node has left | Failover is disabled for the cluster until the primary agent is restarted. | +| Standby agent exited on node_address for cluster cluster_name | Database health is not being monitored. | +| Agent exited during promotion on node_address for cluster cluster_name | Database health is not being monitored. | +| Agent exited on node_address for cluster cluster_name | The agent has exited. This is generated by an agent in the Idle state. | +| Agent exited for cluster cluster_name | The agent has exited. This notification is usually generated during startup when an agent exits before startup has completed. | +| Virtual IP address assigned to non-primary node | The virtual IP address appears to be assigned to a non-primary node. To avoid any conflicts, Failover Manager will release the VIP. You should confirm that the VIP is assigned to your primary node and manually reassign the address if it is not. | +| Virtual IP address not assigned to primary node. | The virtual IP address appears to not be assigned to a primary node. EDB Postgres Failover Manager will attempt to reacquire the VIP. | +| No standby agent in cluster for cluster cluster_name | The standbys on cluster_name have left the cluster. | +| Standby agent failed for cluster cluster_name | A standby agent on cluster_name has left the cluster, but the coordinator has detected that the standby database is still running. | +| Standby database failed for cluster cluster_name | A standby agent has signaled that its database has failed. The other nodes also cannot reach the standby database. | +| Standby agent cannot reach database for cluster cluster_name | A standby agent has signaled database failure, but the other nodes have detected that the standby database is still running. | +| Cluster cluster_name has dropped below three nodes | At least three nodes are required for full failover protection. Please add witness or agent node to the cluster. | +| Subset of cluster cluster_name disconnected from primary | This node is no longer connected to the majority of the cluster cluster_name. Because this node is part of a subset of the cluster, failover will not be attempted. Current nodes that are visible are: node_address | +| Promotion has started on cluster cluster_name. | The promotion of a standby has started on cluster cluster_name. | +| Witness failure for cluster cluster_name | Witness running at node_address has left the cluster. | +| Idle agent failure for cluster cluster_name. | Idle agent running at node_address has left the cluster. | +| One or more nodes isolated from network for cluster cluster_name | This node appears to be isolated from the network. Other members seen in the cluster are: node_name | +| Node no longer isolated from network for cluster cluster_name. | This node is no longer isolated from the network. | +| Standby agent tried to promote, but primary DB is still running | The standby EFM agent tried to promote itself, but detected that the primary DB is still running on node_address. This usually indicates that the primary EFM agent has exited. Failover has NOT occurred. | +| Standby agent started to promote, but primary has rejoined. | The standby EFM agent started to promote itself, but found that a primary agent has rejoined the cluster. Failover has NOT occurred. | +| Standby agent tried to promote, but could not verify primary DB | The standby EFM agent tried to promote itself, but could not detect whether or not the primary DB is still running on node_address. Failover has NOT occurred. | +| Standby agent tried to promote, but VIP appears to still be assigned | The standby EFM agent tried to promote itself, but could not because the virtual IP address (VIP_address) appears to still be assigned to another node. Promoting under these circumstances could cause data corruption. Failover has NOT occurred. | +| Standby agent tried to promote, but appears to be orphaned | The standby EFM agent tried to promote itself, but could not because the well-known server (server_address) could not be reached. This usually indicates a network issue that has separated the standby agent from the other agents. Failover has NOT occurred. | +| Potential manual failover required on cluster cluster_name. | A potential failover situation was detected for cluster cluster_name. Automatic failover has been disabled for this cluster, so manual intervention is required. | +| Failover has completed on cluster cluster_name | Failover has completed on cluster cluster_name. | +| Lock file for cluster cluster_name has been removed | The lock file for cluster cluster_name has been removed from: path_name on node node_address. This lock prevents multiple agents from monitoring the same cluster on the same node. Please restore this file to prevent accidentally starting another agent for cluster. | +| A recovery file for cluster cluster_name has been found on primary node | A recovery file for cluster cluster_name has been found at: path_name on primary node node_address. This may be problematic should you attempt to restart the DB on this node. | +| recovery_target_timeline is not set to latest in recovery settings | The recovery_target_timeline parameter is not set to latest in the recovery settings. The standby server will not be able to follow a timeline change that occurs when a new primary is promoted. | +| Promotion has not occurred for cluster cluster_name | A promotion was attempted but there is already a node being promoted: ip_address. | +| Standby not reconfigured after failover in cluster cluster_name | The auto.reconfigure property has been set to false for this node. The node has not been reconfigured to follow the new primary node after a failover. | +| Could not resume replay for standby standby_id. | Could not resume replay for standby. Manual intervention may be required. Error: error_message. | +| Possible problem with database timeout values | Your remote.timeout value (value) is higher than your local.timeout value (value). If the local database takes too long to respond, the local agent could assume that the database has failed though other agents can connect. While this will not cause a failover, it could force the local agent to stop monitoring, leaving you without failover protection. | +| No standbys available for promotion in cluster cluster_name | The current number of standby nodes in the cluster has dropped to the minimum number: number. There cannot be a failover unless another standby node(s) is added or made promotable. | +| No promotable standby for cluster cluster_name | The current failover priority list in the cluster is empty. You have removed the only promotable standby for the cluster cluster_name. There cannot be a failover unless another promotable standby node(s) is added or made promotable by adding to failover priority list. | +| Synchronous replication has been reconfigured for cluster cluster_name | The number of synchronous standby nodes in the cluster has dropped below number. The synchronous standby names on primary has been reconfigured to: new synchronous_standby_names value. | +| Synchronous replication has been disabled for cluster cluster_name. | The number of synchronous standby nodes in the cluster has dropped below count. The primary has been taken out of synchronous replication mode. | +| Could not reload database configuration. | Could not reload database configuration. Manual intervention is required. Error: error_message. | +| Custom monitor timeout for cluster cluster_name | The following custom monitoring script has timed out: script_name | +| Custom monitor 'safe mode' failure for cluster cluster_name | The following custom monitor script has failed, but is being run in "safe mode": script_name. Output: script_results | +| primary.shutdown.as.failure set to true for primary node | The primary.shutdown.as.failure property has been set to true for this cluster. Stopping the primary agent without stopping the entire cluster will be treated by the rest of the cluster as an immediate primary agent failure. If maintenance is required on the primary database, shut down the primary agent and wait for a notification from the remaining nodes that failover will not happen. | +| Primary cannot ping local database for cluster cluster_name | The Primary agent can no longer reach the local database running at node_address. Other nodes are able to access the database remotely, so the primary will become IDLE and attempt to resume monitoring the database. | + + + + +The conditions listed in the table below will trigger a *SEVERE* notification: + +| Subject | Description | +| -------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Standby database restarted but EFM cannot connect | The start or restart command for the database ran successfully but the database is not accepting connections. EFM will keep trying to connect for up to restart.connection.timeout seconds. | +| Unable to connect to DB on node_address | The maximum connections limit has been reached. | +| Unable to connect to DB on node_address | Invalid password for db.user=user_name. | +| Unable to connect to DB on node_address | Invalid authorization specification. | +| Primary cannot resume monitoring local database for cluster cluster_name | The primary agent can no longer reach the local database running at node_address. Other nodes are able to access the database remotely, so the primary will not release the VIP and/or create a recovery.conf file. The primary agent will remain IDLE until the resume command is run to resume monitoring the database. | +| Fencing script error | Fencing script script_name failed to execute successfully. Exit Value: exit_code Results: script_results Failover has NOT occurred. | +| Post-promotion script failed | Post-promotion script script_name failed to execute successfully. Exit Value: exit_code Results: script_results | +| Remote post-promotion script failed | Remote post-promotion script script_name failed to execute successfully Exit Value: exit_code Results: script_resultsNode: node_address | +| Remote pre-promotion script failed | Remote pre-promotion script script_name failed to execute successfully Exit Value: exit_code Results: script_resultsNode: node_address | +| Post-database failure script error | Post-database failure script script_name failed to execute successfully. Exit Value: exit_code Results: script_results | +| Agent resumed script error | Agent resumed script script_name failed to execute successfully. Results: script_results | +| Primary isolation script failed | Primary isolation script script_name failed to execute successfully. Exit Value: exit_code Results: script_results | +| Could not promote standby | The promote command failed on node. Could not promote standby. Error details: error_details | +| Error creating recovery.conf file on node_address for cluster cluster_name | There was an error creating the recovery.conf file on primary node node_address during promotion. Promotion has continued, but requires manual intervention to ensure that the old primary node can not be restarted. Error details: message_details | +| An unexpected error has occurred for cluster cluster_name | An unexpected error has occurred on this node. Please check the agent log for more information. Error: error_details | +| Primary database being fenced off for cluster cluster_name | The primary database has been isolated from the majority of the cluster. The cluster is telling the primary agent at ip_address to fence off the primary database to prevent two primarys when the rest of the failover manager cluster promotes a standby. | +| Isolated primary database shutdown. | The isolated primary database has been shutdown by failover manager. | +| Primary database being fenced off for cluster cluster_name | The primary database has been isolated from the majority of the cluster. Before the primary could finish detecting isolation, a standby was promoted and has rejoined this node in the cluster. This node is isolating itself to avoid more than one primary database. | +| Could not assign VIP to node node_address | Failover manager could not assign the VIP address for some reason. | +| primary_or_standby database failure for cluster cluster_name | The database has failed on the specified node. | +| Agent is timing out for cluster cluster_name | This agent has timed out trying to reach the local database. After the timeout, the agent could successfully ping the database and has resumed monitoring. However, the node should be checked to make sure it is performing normally to prevent a possible database or agent failure. | +| Resume timed out for cluster cluster_name | This agent could not resume monitoring after reconfiguring and restarting the local database. See agent log for details. | +| Internal state mismatch for cluster cluster_name | The failover manager cluster's internal state did not match the actual state of the cluster members. This is rare and can be caused by a timing issue of nodes joining the cluster and/or changing their state. The problem should be resolved, but you should check the cluster status as well to verify. Details of the mismatch can be found in the agent log file. | +| Failover has not occurred | An agent has detected that the primary database is no longer available in cluster cluster_name, but there are no standby nodes available for failover. | +| Database in wrong state on node_address | The standby agent has detected that the local database is no longer in recovery. The agent will now become idle. Manual intervention is required. | +| Database in wrong state on node_address | The primary agent has detected that the local database is in recovery. The agent will now become idle. Manual intervention is required. | +| Database connection failure for cluster cluster_name | This node is unable to connect to the database running on: node_addressUntil this is fixed, failover may not work properly because this node will not be able to check if the database is running or not. | +| Standby custom monitor failure for cluster cluster_name | The following custom monitor script has failed on a standby node. The agent will stop monitoring the local database. Script location: script_name Script output: script_results | +| Primary custom monitor failure for cluster cluster_name | The following custom monitor script has failed on a primary node. EFM will attempt to promote a standby. Script location: script_name Script output: script_results | +| Loopback address set for ping.server.ip | Loopback address is set for ping.server.ip property. This setting can interfere with the network isolation detection and hence it should be changed. | +| Load balancer attach script error | Load balancer attach script script_name failed to execute successfully. Exit Value: exit_code Results: script_results | +| Load balancer detach script error | Load balancer detach script script_name failed to execute successfully. Exit Value: exit_code Results: script_results | +| Not enough synchronous standbys available in cluster cluster_name. | The number of synchronous standby nodes in the cluster has dropped to count. All write queries on the primary will be blocked until enough synchronous standby nodes are added. | diff --git a/product_docs/docs/efm/4.0/efm_user/11_supported_scenarios.mdx b/product_docs/docs/efm/4.0/efm_user/11_supported_scenarios.mdx new file mode 100644 index 00000000000..f225d41f915 --- /dev/null +++ b/product_docs/docs/efm/4.0/efm_user/11_supported_scenarios.mdx @@ -0,0 +1,117 @@ +--- +title: "Supported Failover and Failure Scenarios" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.0/supported_scenarios.html" +--- + + + +Failover Manager monitors a cluster for failures that may or may not result in failover. + +Failover Manager supports a very specific and limited set of failover scenarios. Failover can occur: + +- if the Primary database crashes or is shutdown. +- if the node hosting the Primary database crashes or becomes unreachable. + +Failover Manager makes every attempt to verify the accuracy of these conditions. If agents cannot confirm that the Primary database or node has failed, Failover Manager will not perform any failover actions on the cluster. + +Failover Manager also supports a *no* *auto*-*failover* mode for situations where you want Failover Manager to monitor and detect failover conditions, but not perform an automatic failover to a Standby. In this mode, a notification is sent to the administrator when failover conditions are met. To disable automatic failover, modify the cluster properties file, setting the [auto.failover](04_configuring_efm/01_cluster_properties/#auto_failover) parameter to false. + +Failover Manager will alert an administrator to situations that require administrator intervention, but that do not merit promoting a Standby database to Primary. + + + +## Primary Database is Down + +If the agent running on the Primary database node detects a failure of the Primary database, Failover Manager begins the process of confirming the failure. + +![Confirming the Failure of the Primary Database.](images/supported_scenarios_master_db_down.png) + +If the agent on the Primary node detects that the Primary database has failed, all agents attempt to connect directly to the Primary database. If an agent can connect to the database, Failover Manager sends a notification about the state of the Primary node. If no agent can connect, the Primary agent declares database failure and releases the VIP (if applicable). + +If no agent can reach the virtual IP address or the database server, Failover Manager starts the failover process. The Standby agent on the most up-to-date node runs a fencing script (if applicable), promotes the Standby database to Primary database, and assigns the virtual IP address to the Standby node. Any additional Standby nodes are configured to replicate from the new primary unless auto.reconfigure is set to false. If applicable, the agent runs a post-promotion script. + +**Returning the Node to the Cluster** + +To recover from this scenario without restarting the entire cluster, you should: + +1. Restart the database on the original Primary node as a Standby database. +2. Invoke the `efm resume` command on the original Primary node. + +**Returning the Node to the Role of Primary** + +After returning the node to the cluster as a Standby, you can easily return the node to the role of Primary: + +1. If the cluster has more than one Standby node, use the `efm set-priority` command to set the node's failover priority to 1. +2. Invoke the [efm promote -switchover](07_using_efm_utility/#efm_promote) command to promote the node to its original role of Primary node. + + + +## Standby Database is Down + +If a Standby agent detects a failure of its database, the agent notifies the other agents; the other agents confirm the state of the database. + +![Confirming the failure of a Standby Database.](images/supported_scenarios_standby_db_down.png) + +After returning the Standby database to a healthy state, invoke the `efm resume` command to return the Standby to the cluster. + + + +## Primary Agent Exits or Node Fails + +If the Failover Manager Primary agent crashes or the node fails, a Standby agent will detect the failure and (if appropriate) initiate a failover. + +![Confirming the failure of the Primary Agent.](images/supported_scenarios_master_agent_exits.png) + +If an agent detects that the Primary agent has left, all agents attempt to connect directly to the Primary database. If any agent can connect to the database, an agent sends a notification about the failure of the Primary agent. If no agent can connect, the agents attempt to ping the virtual IP address to determine if it has been released. + +If no agent can reach the virtual IP address or the database server, Failover Manager starts the failover process. The Standby agent on the most up-to-date node runs a fencing script (if applicable), promotes the Standby database to Primary database, and assigns the virtual IP address to the Standby node; if applicable, the agent runs a post-promotion script. Any additional Standby nodes are configured to replicate from the new primary unless auto.reconfigure is set to false. + +If this scenario has occurred because the primary has been isolated from network, the Primary agent will detect the isolation and release the virtual IP address and create the recovery.conf file. Failover Manager will perform the previously listed steps on the remaining nodes of the cluster. + +To recover from this scenario without restarting the entire cluster, you should: + +1. Restart the original Primary node. +2. Bring the original Primary database up as a Standby node. +3. Start the service on the original Primary node. + +Please note that stopping an agent does not signal the cluster that the agent has failed. + + + +## Standby Agent Exits or Node Fails + +If a Standby agent exits or a Standby node fails, the other agents will detect that it is no longer connected to the cluster. + +![Failure of Standby Agent.](images/supported_scenarios_standby_agent_exits.png) + +When the failure is detected, the agents attempt to contact the database that resides on the node; if the agents confirm that there is a problem, Failover Manager sends the appropriate notification to the administrator. + +If there is only one Primary and one Standby remaining, there is no failover protection in the case of a Primary node failure. In the case of a Primary database failure, the Primary and Standby agents can agree that the database failed and proceed with failover. + + + +## Dedicated Witness Agent Exits / Node Fails + +The following scenario details the actions taken if a dedicated Witness (a node that is not hosting a database) fails. + +![Confirming the Failure of a dedicated Witness.](images/supported_scenarios_witness_agent_exits.png) + +When an agent detects that the Witness node cannot be reached, Failover Manager notifies the administrator of the state of the Witness. + +!!! Note + If the witness fails and the cluster only has two nodes, then there is no failover protection because the standby node has no way to know if the primary failed or was disconnected. In a two node cluster, if the primary database fails but the nodes are still connected, failover will still occur since the standby can confirm the condition of the primary database. + + + +## Nodes Become Isolated from the Cluster + +The following scenario details the actions taken if one or more nodes (a minority of the cluster) become isolated from the majority of the cluster. + +![If members of the cluster become isolated.](images/supported_scenarios_node_becomes_isolated.png) + +If one or more nodes (but less than half of the cluster) become isolated from the rest of the cluster, the remaining cluster behaves as if the nodes have failed. The agents attempt to discern if the Primary node is among the isolated nodes; it is, the Primary fences itself off from the cluster, while a Standby node (from within the cluster majority) is promoted to replace it. Other Standby nodes are configured to replicate from the new primary unless `auto.reconfigure` is set to `false`. + +Failover Manager then notifies an administrator, and the isolated nodes rejoin the cluster when they are able. When the nodes rejoin the cluster, the failover priority may change. diff --git a/product_docs/docs/efm/4.0/efm_user/12_upgrading_existing_cluster.mdx b/product_docs/docs/efm/4.0/efm_user/12_upgrading_existing_cluster.mdx new file mode 100644 index 00000000000..15455f32cd9 --- /dev/null +++ b/product_docs/docs/efm/4.0/efm_user/12_upgrading_existing_cluster.mdx @@ -0,0 +1,108 @@ +--- +title: "Upgrading an Existing Cluster" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.0/upgrading_existing_cluster.html" +--- + + + +Failover Manager provides a utility to assist you when upgrading a Failover Manager cluster. To upgrade an existing cluster, you must: + +1. Install Failover Manager 4.0 on each node of the cluster. For detailed information about installing Failover Manager, see [Installing Failover Manager](03_installing_efm/#installing_efm). +2. After installing Failover Manager, invoke the `efm upgrade-conf` utility to create the `.properties` and `.nodes` files for Failover Manager 4.0. The Failover Manager installer installs the upgrade utility ([efm upgrade-conf](07_using_efm_utility/#efm_upgrade_conf)) to the `/usr/edb/efm-4.0/bin directory`. To invoke the utility, assume root privileges, and invoke the command: + +```text +efm upgrade-conf +``` + +The efm `upgrade-conf` utility locates the `.properties` and `.nodes` files of pre-existing clusters and copies the parameter values to a new configuration file for use by Failover Manager. The utility saves the updated copy of the configuration files in the `/etc/edb/efm-4.0` directory. + +1. Modify the `.properties` and `.nodes` files for EFM 4.0, specifying any new preferences. Use your choice of editor to modify any additional properties in the properties file (located in the `/etc/edb/efm-4.0` directory) before starting the service for that node. For detailed information about property settings, see [The Cluster Properties File](04_configuring_efm/01_cluster_properties/#cluster_properties). + +!!! Note + `db.bin` is a required property. When modifying the properties file, ensure that the `db.bin` property specifies the location of the Postgres `bin` directory. + +1. Use a version-specific command to stop the old Failover Manager cluster; for example, you can use the following command to stop a version 4.0 cluster: + +```text +/usr/efm-4.0/bin/efm stop-cluster efm +``` + +1. Start the new [Failover manager service](08_controlling_efm_service/#controlling_efm_service) (`edb-efm-4.0`) on each node of the cluster. + +The following example demonstrates invoking the upgrade utility to create the `.properties` and `.nodes` files for a Failover Manager installation: + +```text +[root@localhost efm-4.0]# /usr/edb/efm-4.0/bin/efm upgrade-conf efm +Checking directory /etc/edb/efm-3.10 +Processing efm.properties file +The following properties were added in addition to those in previous ˓→installed version: +notification.text.prefix +encrypt.agent.messages +standby.restart.delay +The following properties were renamed from those in previous installed ˓→version: +stop.failed.master => stop.failed.primary +master.shutdown.as.failure => primary.shutdown.as.failure +script.master.isolated => script.primary.isolated +stop.isolated.master => stop.isolated.primary +reconfigure.sync.master => reconfigure.sync.primary +Checking directory /etc/edb/efm-3.10 +Processing efm.nodes file +db.password.encrypted re-encoded with stronger encryption. +Upgrade of files is finished. The owner and group for properties and ˓→nodes files have been set as 'efm'. +[root@localhost efm-4.0]# +``` + +If you are [using a Failover Manager configuration without sudo](04_configuring_efm/04_extending_efm_permissions/#running_efm_without_sudo), include the `-source` flag and specify the name of the directory in which the configuration files reside when invoking `upgrade-conf`. If the directory is not the configuration default directory, the upgraded files will be created in the directory from which the `upgrade-conf` command was invoked. + +**Please note**: If you are using a unit file, you must manually update the file to reflect the new Failover Manager service name when you perform an upgrade. + +## Un-installing Failover Manager + +After upgrading to Failover Manager 4.0, you can use your native package manager to remove previous installations of Failover Manager. For example, use the following command to remove Failover Manager 3.10 and any unneeded dependencies: + +- On RHEL or CentOS 7.x: + +```text +yum remove edb-efm310 +``` + +- On RHEL or CentOS 8.x: + +```text +dnf remove edb-efm310 +``` + +- On Debian or Ubuntu: + +```text +apt-get remove edb-efm310 +``` + +- On SLES: + +```text +zypper remove edb-efm310 +``` + +## Performing a Database Update (Minor Version) + +This section describes how to perform a quick minor database version upgrade. You can use the steps that follow to upgrade from one minor version to another (for example, from 10.1.5 to version 10.2.7), or to apply a patch release for a version. + +You should first update the database server on each Standby node of the Failover Manager cluster. Then, perform a switchover, promoting a Standby node to the role of Primary within the Failover Manager cluster. Then, perform a database update on the old primary node. + +On each node of the cluster you must perform the following steps to update the database server: + +1. Stop the Failover Manager agent. +2. Stop the database server. +3. Update the database server. +4. Start the database service. +5. Start the Failover Manager agent. + +For detailed information about controlling the Advanced Server service, or upgrading your version of Advanced Server, please see the EDB Postgres Advanced Server Guide, available at: + +[https://www.enterprisedb.com/docs](/epas/latest/) + +When your updates are complete, you can use the [efm set-priority](07_using_efm_utility/#efm_set_priority) command to add the old primary to the front of the standby list (if needed), and then switchover to return the cluster to its original state. diff --git a/product_docs/docs/efm/4.0/efm_user/13_troubleshooting.mdx b/product_docs/docs/efm/4.0/efm_user/13_troubleshooting.mdx new file mode 100644 index 00000000000..f2c421c3ce1 --- /dev/null +++ b/product_docs/docs/efm/4.0/efm_user/13_troubleshooting.mdx @@ -0,0 +1,47 @@ +--- +title: "Troubleshooting" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.0/troubleshooting.html" +--- + + + +**Authorization file not found. Is the local agent running?** + +If you invoke an EFM cluster management command and EFM is not running on the node, the `efm` command will display an error: + +```text +Authorization file not found. Is the local agent running? +``` + +**Not authorized to run this command. User '<os user>' is not a member of the \`efm\` group.** + +You must have special privileges to invoke some of the `efm` commands documented in [Using the efm Utility](07_using_efm_utility/#using_efm_utility). If these commands are invoked by a user who isn't authorized to run them, the `efm` command will display an error: + +```text +Not authorized to run this command. User '' is not a member of the `efm` group. +``` + +**Notification; Unexpected error message** + +If you receive a notification message about an unexpected error message, check the [Failover Manager log file](09_controlling_logging/#controlling_logging) for an `OutOfMemory` message. Failover Manager runs with the default memory value set by this property: + +```text +# Extra information that will be passed to the JVM when starting the agent. +jvm.options=-Xmx128m +``` + +If you are running with less than 128 megabytes allocated, you should increase the value and restart the Failover Manager agent. + +**Confirming the OpenJDK version** + +Failover Manager is tested with OpenJDK; we strongly recommend using OpenJDK. You can use the following command to check the type of your Java installation: + +```text +# java -version +openjdk version "1.8.0_191" +OpenJDK Runtime Environment (build 1.8.0_191-b12) +OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode) +``` diff --git a/product_docs/docs/efm/4.0/efm_user/14_configuring_streaming_replication.mdx b/product_docs/docs/efm/4.0/efm_user/14_configuring_streaming_replication.mdx new file mode 100644 index 00000000000..9b19511aba2 --- /dev/null +++ b/product_docs/docs/efm/4.0/efm_user/14_configuring_streaming_replication.mdx @@ -0,0 +1,44 @@ +--- +title: "Configuring Streaming Replication" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.0/configuring_streaming_replication.html" +--- + + + +Configuring a replication scenario can be complex; for detailed information about configuration options, please see the PostgreSQL core documentation, available at: + + + +You may want to use a `.pgpass` file to enable md5 authentication for the replication user – this may or may not be the safest authentication method for your environment. For more information about the supported authentication options, please see the PostgreSQL core documentation at: + + + +!!! Note + From Version 3.10 onwards, EFM uses `pg_ctl` utility for standby promotion. You do not need to set the `trigger_file` or `promote_trigger_file` parameter for promotion of a standby server. + +## Limited Support for Cascading Replication + +While Failover Manager does not provide full support for cascading replication, it does provide limited support for simple failover in a cascading replication scenario. Cascading replication allows a Standby node to stream to another Standby node, reducing the number of connections (and processing overhead) to the primary node. + +![Cascading replication.](images/cascading_replication.png) + +For detailed information about configuring cascading replication, please see the PostgreSQL documentation at: + + + +To use Failover Manager in a cascading replication scenario, you should modify the cluster properties file, setting the following property values on Standby Node #2: + +```text +promotable=false +auto.reconfigure=false +``` + +In the event of a Failover, Standby Node #1 will be promoted to the role of Primary node. Should failover occur, Standby Node #2 will continue to act as a read-only replica for the new Primary node until you take actions to manually reconfigure the replication scenario to contain 3 nodes. + +In the event of a failure of Standby Node #1, you will not have failover protection, but you will receive an email notifying you of the failure of the node. + +!!! Note + Performing a switchover and switch back to the original primary may not preserve the cascading replication scenario. diff --git a/product_docs/docs/efm/4.0/efm_user/15_configuring_ssl_authentication.mdx b/product_docs/docs/efm/4.0/efm_user/15_configuring_ssl_authentication.mdx new file mode 100644 index 00000000000..61e1a171302 --- /dev/null +++ b/product_docs/docs/efm/4.0/efm_user/15_configuring_ssl_authentication.mdx @@ -0,0 +1,69 @@ +--- +title: "Configuring SSL Authentication on a Failover Manager Cluster" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.0/configuring_ssl_authentication.html" +--- + + + +The following steps enable SSL authentication for Failover Manager. Note that all connecting clients will be required to use SSL authentication when connecting to any database server within the cluster; you will be required to modify the connection methods currently used by existing clients. + +To enable SSL on a Failover Manager cluster, you must: + +1. Place a `server.crt` and `server.key` file in the `data` directory (under your Advanced Server installation). You can purchase a certificate signed by an authority, or create your own self-signed certificate. For information about creating a self-signed certificate, see the PostgreSQL core documentation at: + + + +2. Modify the `postgresql.conf` file on each database within the Failover Manager cluster, enabling SSL: + + ```text + ssl=on + ``` + +> After modifying the postgresql.conf file, you must restart the server. + +1. Modify the `pg_hba.conf` file on each node of the Failover Manager cluster, adding the following line to the beginning of the file: + + ```text + hostnossl all all all reject + ``` + +> The line instructs the server to reject any connections that are not using SSL authentication; this enforces SSL authentication for any connecting clients. For information about modifying the pg_hba.conf file, see the PostgreSQL core documentation at: +> +> > + +1. After placing the server.crt and server.key file in the data directory, convert the certificate to a form that Java understands; you can use the command: + + ```text + openssl x509 -in server.crt -out server.crt.der -outform der + ``` + +> For more information, visit: +> +> > + +1. Then, add the certificate to the Java trusted certificates file: + + ```text + keytool -keystore $JAVA_HOME/lib/security/cacerts -alias -import -file server.crt.der + ``` + +> Where +> +> > `$JAVA_HOME` is the home directory of your Java installation. +> > +> > <alias_name> can be any string, but must be unique for each certificate. +> > +> > You can use the `keytool` command to review a list of the available certificates or retrieve information about a specific certificate. For more information about using the keytool command, enter: +> > +> > > ```text +> > > man keytool +> > > ``` +> +> The certificate from each database server must be imported into the trusted certificates file of each agent. Note that the location of the cacerts file may vary on each system. For more information, visit: +> +> > + +1. Modify the [efm.properties file](04_configuring_efm/01_cluster_properties/#jdbc_sslmode) on each node within the cluster, setting the `jdbc.sslmode` property. diff --git a/product_docs/docs/efm/4.0/efm_user/images/cascading_replication.png b/product_docs/docs/efm/4.0/efm_user/images/cascading_replication.png new file mode 100644 index 00000000000..41e86182b03 Binary files /dev/null and b/product_docs/docs/efm/4.0/efm_user/images/cascading_replication.png differ diff --git a/product_docs/docs/efm/4.0/efm_user/images/cascading_replication1.png b/product_docs/docs/efm/4.0/efm_user/images/cascading_replication1.png new file mode 100644 index 00000000000..f606c9ee850 Binary files /dev/null and b/product_docs/docs/efm/4.0/efm_user/images/cascading_replication1.png differ diff --git a/product_docs/docs/efm/4.0/efm_user/images/edb_logo.png b/product_docs/docs/efm/4.0/efm_user/images/edb_logo.png new file mode 100755 index 00000000000..b83a03f80c5 Binary files /dev/null and b/product_docs/docs/efm/4.0/efm_user/images/edb_logo.png differ diff --git a/product_docs/docs/efm/4.0/efm_user/images/failover_manager_overview.png b/product_docs/docs/efm/4.0/efm_user/images/failover_manager_overview.png new file mode 100644 index 00000000000..0a511e05ab0 Binary files /dev/null and b/product_docs/docs/efm/4.0/efm_user/images/failover_manager_overview.png differ diff --git a/product_docs/docs/efm/4.0/efm_user/images/placeholder.png b/product_docs/docs/efm/4.0/efm_user/images/placeholder.png new file mode 100755 index 00000000000..b83a03f80c5 Binary files /dev/null and b/product_docs/docs/efm/4.0/efm_user/images/placeholder.png differ diff --git a/product_docs/docs/efm/4.0/efm_user/images/str_replication_dashboard_master.png b/product_docs/docs/efm/4.0/efm_user/images/str_replication_dashboard_master.png new file mode 100644 index 00000000000..dc843892554 Binary files /dev/null and b/product_docs/docs/efm/4.0/efm_user/images/str_replication_dashboard_master.png differ diff --git a/product_docs/docs/efm/4.0/efm_user/images/str_replication_dashboard_standby.png b/product_docs/docs/efm/4.0/efm_user/images/str_replication_dashboard_standby.png new file mode 100644 index 00000000000..aef1e17ad33 Binary files /dev/null and b/product_docs/docs/efm/4.0/efm_user/images/str_replication_dashboard_standby.png differ diff --git a/product_docs/docs/efm/4.0/efm_user/images/supported_scenarios_master_agent_exits.png b/product_docs/docs/efm/4.0/efm_user/images/supported_scenarios_master_agent_exits.png new file mode 100644 index 00000000000..ac9726da488 Binary files /dev/null and b/product_docs/docs/efm/4.0/efm_user/images/supported_scenarios_master_agent_exits.png differ diff --git a/product_docs/docs/efm/4.0/efm_user/images/supported_scenarios_master_db_down.png b/product_docs/docs/efm/4.0/efm_user/images/supported_scenarios_master_db_down.png new file mode 100644 index 00000000000..0eac0491e89 Binary files /dev/null and b/product_docs/docs/efm/4.0/efm_user/images/supported_scenarios_master_db_down.png differ diff --git a/product_docs/docs/efm/4.0/efm_user/images/supported_scenarios_node_becomes_isolated.png b/product_docs/docs/efm/4.0/efm_user/images/supported_scenarios_node_becomes_isolated.png new file mode 100644 index 00000000000..ac591153eef Binary files /dev/null and b/product_docs/docs/efm/4.0/efm_user/images/supported_scenarios_node_becomes_isolated.png differ diff --git a/product_docs/docs/efm/4.0/efm_user/images/supported_scenarios_standby_agent_exits.png b/product_docs/docs/efm/4.0/efm_user/images/supported_scenarios_standby_agent_exits.png new file mode 100644 index 00000000000..1997c09fdf6 Binary files /dev/null and b/product_docs/docs/efm/4.0/efm_user/images/supported_scenarios_standby_agent_exits.png differ diff --git a/product_docs/docs/efm/4.0/efm_user/images/supported_scenarios_standby_db_down.png b/product_docs/docs/efm/4.0/efm_user/images/supported_scenarios_standby_db_down.png new file mode 100644 index 00000000000..dc9abefcead Binary files /dev/null and b/product_docs/docs/efm/4.0/efm_user/images/supported_scenarios_standby_db_down.png differ diff --git a/product_docs/docs/efm/4.0/efm_user/images/supported_scenarios_witness_agent_exits.png b/product_docs/docs/efm/4.0/efm_user/images/supported_scenarios_witness_agent_exits.png new file mode 100644 index 00000000000..1c02dc66805 Binary files /dev/null and b/product_docs/docs/efm/4.0/efm_user/images/supported_scenarios_witness_agent_exits.png differ diff --git a/product_docs/docs/efm/4.0/efm_user/index.mdx b/product_docs/docs/efm/4.0/efm_user/index.mdx new file mode 100644 index 00000000000..bb15244556c --- /dev/null +++ b/product_docs/docs/efm/4.0/efm_user/index.mdx @@ -0,0 +1,26 @@ +--- +title: "EDB Failover Manager User Guide" + +#legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + #- "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.0/whats_new.html" + #- "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.0/genindex.html" + #- "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.0/conclusion.html" + #- "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.0/index.html" +--- + +**EDB Failover Manager** + +EDB Postgres Failover Manager (EFM) is a high-availability module from EnterpriseDB that enables a Postgres primary node to automatically failover to a Standby node in the event of a software or hardware failure on the primary. + +This guide provides information about installing, configuring and using Failover Manager . For information about the platforms and versions supported by Failover Manager , visit the EnterpriseDB website at: + + + +This document uses Postgres to mean either the PostgreSQL or EDB Postgres Advanced Server database. + +
+ +whats_new failover_manager_overview installing_efm configuring_efm using_efm monitoring_efm_cluster using_efm_utility controlling_efm_service controlling_logging notifications supported_scenarios upgrading_existing_cluster troubleshooting configuring_streaming_replication configuring_ssl_authentication conclusion + +
diff --git a/product_docs/docs/efm/4.0/efm_v4.0_documentation.pdf b/product_docs/docs/efm/4.0/efm_v4.0_documentation.pdf new file mode 100644 index 00000000000..8fd970b4aea Binary files /dev/null and b/product_docs/docs/efm/4.0/efm_v4.0_documentation.pdf differ diff --git a/product_docs/docs/efm/4.0/index.mdx b/product_docs/docs/efm/4.0/index.mdx new file mode 100644 index 00000000000..01ab7d186c4 --- /dev/null +++ b/product_docs/docs/efm/4.0/index.mdx @@ -0,0 +1,14 @@ +--- +title: "EDB Postgres Failover Manager" +directoryDefaults: + description: "EDB Postgres Failover Manager Version 4.0 Documentation and release notes. PostgreSQL replication and failover manager for achieving high availability." +navigation: + - "#Getting Started" + - efm_quick_start + - "#Guides" + - efm_pgpool_ha_guide + - efm_user +#legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + # - "/edb-docs/p/edb-postgres-failover-manager/4.1" +--- diff --git a/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/01_introduction.mdx b/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/01_introduction.mdx new file mode 100644 index 00000000000..1d582eeb107 --- /dev/null +++ b/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/01_introduction.mdx @@ -0,0 +1,60 @@ +--- +title: "Architecture Overview" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/high-availability-scalability-guide/4.1/introduction.html" +--- + +This guide explains how to configure Failover Manager and Pgpool best to leverage the benefits that they provide for Advanced Server. Using the reference architecture described in the Architecture section, you can learn how to achieve high availability by implementing an automatic failover mechanism (with Failover Manager) while scaling the system for larger workloads and an increased number of concurrent clients with read-intensive or mixed workloads to achieve horizontal scaling/read-scalability (with Pgpool). + +The architecture described in this document has been developed and tested for EFM 4.1, EDB Pgpool 4.1, and Advanced Server 13. + +Documentation for Advanced Server and Failover Manager are available from EnterpriseDB at: + + + +Documentation for pgPool-II can be found at: + + + +## Failover Manager Overview + +Failover Manager is a high-availability module that monitors the health of a Postgres streaming replication cluster and verifies failures quickly. When a database failure occurs, Failover Manager can automatically promote a streaming replication Standby node into a writable Primary node to ensure continued performance and protect against data loss with minimal service interruption. + +**Basic EFM Architecture Terminology** + +A Failover Manager cluster is comprised of EFM processes that reside on the following hosts on a network: + +- A **Primary** node is the Primary database server that is servicing database clients. +- One or more **Standby nodes** are streaming replication servers associated with the Primary node. +- The **Witness node** confirms assertions of either the Primary or a Standby in a failover scenario. If, during a failure situation, the Primary finds itself in a partition with half or more of the nodes, it will stay Primary. As such, EFM supports running in a cluster with an even number of agents. + +## Pgpool-II Overview + +Pgpool-II (Pgpool) is an open-source application that provides connection pooling and load balancing for horizontal scalability of SELECT queries on multiple Standbys in EPAS and community Postgres clusters. For every backend, a backend_weight parameter can set the ratio of read traffic to be directed to the backend node. To prevent read traffic on the Primary node, the backend_weight parameter can be set to 0. In such cases, data modification language (DML) queries (i.e., INSERT, UPDATE, and DELETE) will still be sent to the Primary node, while read queries are load-balanced to the Standbys, providing scalability with mixed and read-intensive workloads. + +EnterpriseDB supports the following Pgpool functionality: + +- Load balancing +- Connection pooling +- High availability +- Connection limits + +### PCP Overview + +Pgpool provides an interface called PCP for administrators that performs management operations such as retrieving the status of Pgpool or terminating Pgpool processes remotely. PCP commands are UNIX commands that manipulate Pgpool via the network. + +### Pgpool Watchdog + +`watchdog` is an optional sub process of Pgpool that provides a high availability feature. Features added by `watchdog` include: + +- Health checking of the pgpool service +- Mutual monitoring of other watchdog processes +- Changing leader/Standby state if certain faults are detected +- Automatic virtual IP address assigning synchronous to server switching +- Automatic registration of a server as a Standby during recovery + +More information about the `Pgpool watchdog` component can be found at: + + diff --git a/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/02_architecture.mdx b/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/02_architecture.mdx new file mode 100644 index 00000000000..8526284e6b5 --- /dev/null +++ b/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/02_architecture.mdx @@ -0,0 +1,32 @@ +--- +title: "Architecture" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/high-availability-scalability-guide/4.1/architecture.html" +--- + +![A typical EFM and Pgpool configuration](images/edb_ha_architecture.png) + +The sample architecture diagram shows four nodes as described in the table below: + +| **Systems** | **Components** | +| ------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Primary Pgpool/EFM witness node | The Primary Pgpool node will only run Pgpool, and EFM witness, as such leaving as much resources available to Pgpool as possible. During normal runmode (no Pgpool Failovers), the Primary Pgpool node has attached the Virtual IP address, and all applications connect through the Virtual IP address to Pgpool. Pgpool will forward all write traffic to the Primary Database node, and will balance all read across all Standby nodes.On the Primary Pgpool node, the EFM witness process ensures that a minimum quota of three EFM agents remains available even if one of the database nodes fails. Some examples are when a node is already unavailable due to maintenance, or failure, and another failure occurs. | +| Primary Database node | The Primary Database node will only run Postgres (Primary)and EFM, leaving all resources to Postgres. Read/Write traffic (i.e., INSERT, UPDATE, DELETE) is forwarded to this node by the Primary Pgpool node. | +| Standby nodes | The Standby nodes are running Postgres (Standby), EFM and an inactive Pgpool process. In case of a Primary database failure, EFM will promote Postgres on one of these Standby nodes to handle read-write traffic. In case of a Primary Pgpool failure, the Pgpool watchdog will activate Pgpool on one of the Standby nodes which will attach the VIP, and handle the forwarding of the application connections to the Database nodes. Note that in a double failure situation (both the Primary Pgpool node and the Primary Database node are in failure), both of these Primary processes might end up on the same node. | + +This architecture: + +- Achieves high availability by providing two Standbys that can be promoted in case of a Primary Postgres node failure. +- Achieves high availability by providing at least three Pgpool processes in a watchdog configuration. +- Increases performance with mixed and read-intensive workloads by introducing increased read scalability with more than one Standby for load balancing. +- Reduces load on the Primary database node by redirecting read-only traffic with the Primary pgpool node. +- Prevents resource contention between Pgpool and Postgres on the Primary Database node. By not running Pgpool on the Primary database node, the Primary Postgres process can utilize as much resources as possible. +- Prevents resource contention between pgpool and Postgres on the Primary Pgpool node. By not running Standby databases on the Primary Pgpool node, Pgpool can utilize as many resources as possible. +- Optionally, synchronous replication can be set up to achieve near-zero data loss in a failure event. + +!!! Note + The architecture also allows us to completely separate 3 virtual machines running Postgres from 3 virtual machines running Pgpool. This kind of setup requires 2 extra virtual machines, but it is a better choice if you want to prevent resource contention between Pgpool and Postgres in Failover scenarios. In this setup, the architecture can run without an extra 7th node running the EFM Witness Process. To increase failure resolution efm witness agents could be deployed on the Pgpool servers. + +![Deployment of EFM and Pgpool on separate virtual machines](images/edb_ha_architecture_separate_VM.png) diff --git a/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/03_components_ha_pgpool.mdx b/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/03_components_ha_pgpool.mdx new file mode 100644 index 00000000000..8487a402cf1 --- /dev/null +++ b/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/03_components_ha_pgpool.mdx @@ -0,0 +1,161 @@ +--- +title: "Implementing High Availability with Pgpool" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/high-availability-scalability-guide/4.1/components_ha_pgpool.html" +--- + +Failover Manager monitors the health of Postgres nodes; in the event of a database failure, Failover Manager performs an automatic failover to a Standby node. Note that Pgpool does not monitor the health of backend nodes and will not perform failover to any Standby nodes. + +## Configuring Failover Manager + +Failover Manager provides functionality that will remove failed database nodes from Pgpool load balancing; it can also re-attach nodes to Pgpool when returned to the Failover Manager cluster. To configure EFM for high availability using Pgpool, you must set the following properties in the cluster properties file: + +pgpool.enable =<true/false> + +'pcp.user' = <User that would be invoking PCP commands> + +'pcp.host' = <Virtual IP that would be used by pgpool. Same as pgpool parameter 'delegate_IP’> + +'pcp.port' = <The port on which pgpool listens for pcp commands> + +'pcp.pass.file' = <Absolute path of PCPPASSFILE> + +'pgpool.bin' = <Absolute path of pgpool bin directory> + +## Configuring Pgpool + +The section lists the configuration of some important parameters in the `pgpool.conf` file to integrate the Pgpool-II with EFM. + +**Backend node setting** + +There are three PostgreSQL backend nodes, one Primary and two Standby nodes. Configure using `backend_*` configuration parameters in `pgpool.conf`, and use the equal backend weights for all nodes. This will make the read queries to be distributed equally among all nodes. + +```text +backend_hostname0 = ‘server1_IP' +backend_port0 = 5444 +backend_weight0 = 1 +backend_flag0 = 'DISALLOW_TO_FAILOVER' + +backend_hostname1 = ‘server2_IP' +backend_port1 = 5444 +backend_weight1 = 1 +backend_flag1 = 'DISALLOW_TO_FAILOVER' + +backend_hostname2 = ‘server3_IP' +backend_port2 = 5444 +backend_weight2 = 1 +backend_flag2 = 'DISALLOW_TO_FAILOVER' +``` + +**Enable Load-balancing and streaming replication mode** + +Set the following configuration parameter in the `pgpool.conf` file to enable load balancing and streaming replication mode + +```text +master_slave_mode = on +master_slave_sub_mode = 'stream' +load_balance_mode = on +``` + +**Disable health-checking and failover** + +Health-checking and failover must be handled by EFM and hence, these must be disabled on Pgpool-II side. To disable the health-check and failover on pgpool-II side, assign the following values: + +```text +health_check_period = 0 +fail_over_on_backend_error = off +failover_if_affected_tuples_mismatch = off +failover_command = ‘’ +failback_command = ‘’ +``` + +Ensure the following while setting up the values in the `pgpool.conf` file: + +- Keep the value of wd_priority in pgpool.conf different on each node. The node with the highest value gets the highest priority. +- The properties backend_hostname0 , backend_hostname1, backend_hostname2 and so on are shared properties (in EFM terms) and should hold the same value for all the nodes in pgpool.conf file. +- Update the correct interface value in *if\_* \* and arping cmd props in the pgpool.conf file. +- Add the properties heartbeat_destination0, heartbeat_destination1, heartbeat_destination2 etc. as per the number of nodes in pgpool.conf file on every node. Here heartbeat_destination0 should be the ip/hostname of the local node. + +**Setting up PCP** + +Script uses the PCP interface, So we need to set up the PCP and .PCPPASS file to allow PCP connections without password prompt. + +setup PCP: + +setup PCPPASS: + +Note that the load-balancing is turned on to ensure read scalability by distributing read traffic across the standby nodes + +The health checking and error-triggered backend failover have been turned off, as Failover Manager will be responsible for performing health checks and triggering failover. It is not advisable for Pgpool to perform health checking in this case, so as not to create a conflict with Failover Manager, or prematurely perform failover. + +Finally, `search_primary_node_timeout` has been set to a low value to ensure prompt recovery of Pgpool services upon an Failover Manager-triggered failover. + +## Virtual IP Addresses + +Both Pgpool-II and Failover Manager provide functionality to employ a virtual IP for seamless failover. While both provide this capability, the pgpool-II leader is the process that receives the Application connections through the Virtual IP. As in this design, such Virtual IP management is performed by the Pgpool-II watchdog system. EFM VIP has no beneficial effect in this design and it must be disabled. + +Note that in a failure situation of the active instance of Pgpool (The Primary Pgpool Server in our sample architecture), the next available Standby Pgpool instance (according to watchdog priority) will be activated and takes charge as the leader Pgpool instance. + +## Configuring Pgpool-II Watchdog + +Watchdog provides the high availability of Pgpool-II nodes. This section lists the configuration required for watchdog on each Pgpool-II node. + +**Common watchdog configurations on all Pgpool nodes** + +The following configuration parameters enable and configure the watchdog. The interval and retry values can be adjusted depending upon the requirements and testing results. + +```text +use_watchdog = on # enable watchdog +wd_port = 9000 # watchdog port, can be changed +delegate_IP = ‘Virtual IP address’ +wd_lifecheck_method = 'heartbeat' +wd_interval = 10 # we can lower this value for quick detection +wd_life_point = 3 +# virtual IP control +ifconfig_path = '/sbin' # ifconfig command path +if_up_cmd = 'ifconfig eth0:0 inet $_IP_$ netmask 255.255.255.0' + # startup delegate IP command +if_down_cmd = 'ifconfig eth0:0 down' # shutdown delegate IP command +arping_path = '/usr/sbin' # arping command path +``` + +!!! Note + Replace the value of eth0 with the network interface on your system. See [Chapter 5](05_appendix_b/#configuration-for-number-of-connections-and-pooling) for tuning the number of connections, and pooling configuration. + +**Watchdog configurations on server 2** + +```text +other_pgpool_hostname0 = 'server 3 IP/hostname' +other_pgpool_port0 = 9999 +other_wd_port0 = 9000 +other_pgpool_hostname1 = 'server 4 IP/hostname' +other_pgpool_port1 = 9999 +other_wd_port1 = 9000 +wd_priority = 1 +``` + +**Watchdog configurations on server 3** + +```text +other_pgpool_hostname0 = 'server 2 IP/hostname' +other_pgpool_port0 = 9999 +other_wd_port0 = 9000 +other_pgpool_hostname1 = 'server 4 IP/hostname' +other_pgpool_port1 = 9999 +other_wd_port1 = 9000 +wd_priority = 3 +``` + +**Watchdog configurations on server 4** + +```text +other_pgpool_hostname0 = 'server 2 IP/hostname' +other_pgpool_port0 = 9999 +other_wd_port0 = 9000 +other_pgpool_hostname1 = 'server 3 IP/hostname' +other_pgpool_port1 = 9999 +other_wd_port1 = 9000 +wd_priority = 5 # use high watchdog priority on server 4 +``` diff --git a/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/04_appendix_a.mdx b/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/04_appendix_a.mdx new file mode 100644 index 00000000000..92cfd60c34e --- /dev/null +++ b/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/04_appendix_a.mdx @@ -0,0 +1,70 @@ +--- +title: "EFM Pgpool Integration Using Azure Network Load Balancer" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/high-availability-scalability-guide/4.1/appendix_a.html" +--- + + + +This section describes a specific use case for EFM Pgpool integration, where the database, EFM, and Pgpool are installed on CentOS 8 Virtual Machines in Azure. For this specific use case, Azure Network Load Balancer (NLB) has been used to distribute the traffic amongst all the active Pgpool Instances instead of directing the traffic using Pgpool VIP. + +![Architecture diagram for EFM and Pgpool integration using Azure Load Balancer](images/EFM_PgPool_Azure.png) + +**Step 1 (Installation)**: + +Install and configure Advanced Server database, EFM, and Pgpool on Azure Virtual Machines as following: + +| **Systems** | **Components** | +| ----------- | ------------------------------------------------------------------------------ | +| Primary | Primary node running Advanced Server 13 and Failover Manager 4.1 | +| Standby 1 | Standby node running Advanced Server 13, Failover Manager 4.1, and Pgpool 4.1. | +| Standby 2 | Standby node running Advanced Server 13, Failover Manager 4.1, and Pgpool 4.1. | +| Witness | Witness node running Failover Manager 4.1 and Pgpool 4.1. | + +**Step 2 (Pgpool configuration)**: + +Configure Pgpool as per the steps given in chapter 3 (except for delegate_ip, which should be left empty in this architecture). + +**Step 3 (Azure Load Balancer configuration)**: + +You need to do the following configuration for using Azure NLB: + +**Networking**: You need to ensure the following settings for Network Load Balancer and for each of the virtual machines: Assign Public IP as well as private IP to the NLB, and only private IP to the virtual machines. The application server should connect to the NLB over public IP and NLB in turn should connect to the virtual machines over private IPs. + +In the current scenario, following are the IP addresses assigned to each component: + +- Public IP of NLB : 40.76.240.33 (pcp.host) +- Private IP of Primarydb : 172.16.1.3 (note that this is not part of the backend pool of the Load Balancer) +- Private IP of Standby 1 : 172.16.1.4 +- Private IP of Standby 2 : 172.16.1.5 +- Private IP of witness node: 172.16.1.6 + +Ensure that the ports required to run the database, EFM, and Pgpool are open for communication. Following is the list of default ports for each of these component (you can customize the ports for your environment): + +- Database: 5444 +- EFM: 7800 (bind.address) +- Pgpool: 9000, 9694, 9898, 9999 + +**Backend pool**: Create a Backend pool consisting of all the 3 virtual machines running Pgpool instances. Use the private IPs of the virtual machines to create the Backend pool. + +![Backend pool in Azure console](images/backend_pools.png) + +**Health Probe**: Add a health probe to check if the Pgpool instance is available on the virtual machines. The health probe periodically pings the virtual machines of the Backend pool on port 9999. If it does not receive any response from any of the virtual machines, it assumes that the Pgpool instance is not available and hence stops sending traffic towards that particular machine. + +![Health probes in Azure console](images/health_probes.png) + +**Load balancing rules**: Add two Load balancing rules - one each for port 9898 and port 9999. These rules should ensure that the network traffic coming towards that particular port gets distributed evenly among all the virtual machines present in the Backend pool. + +![Load balancing rules in Azure console](images/load_balancing_rules.png) + +1. Rule created for port 9999 (i.e. PCP port) + +![Load balancing rule for port 9999](images/rule_port_9898.png) + +1. Rule created for port 9999 (i.e. Pgpool port) + +![Load balancing rule for port 9999](images/rule_port_9999.png) + +After configuration of the above-mentioned setup, you can connect to Postgres on the IP address of the Network Load Balancer on port 9999. If a failure occurs on the Primary database server, EFM will promote a new Primary and then reconfigure Pgpool to redistribute traffic. If any one of the Pgpool processes is not available to accept traffic anymore, the Network Load Balancer will redistribute all the traffic to the remaining two Pgpool processes. Make sure that listen_backlog_multiplier is tuned to compensate for the higher number of connections in case of failover. diff --git a/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/05_appendix_b.mdx b/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/05_appendix_b.mdx new file mode 100644 index 00000000000..042804c6718 --- /dev/null +++ b/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/05_appendix_b.mdx @@ -0,0 +1,17 @@ +--- +title: "Configuration for Number of Connections and Pooling" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/high-availability-scalability-guide/4.1/appendix_b.html" +--- + +Pgpool has some configuration to tune the pooling and connection processing. Depending on this configuration, also the Postgres configuration for `max_connections` should be set to make sure all connections can be accepted as required. Furthermore, note that the Cloud Architecture works with active/active instances, which requires to spread `num_init_children` over all Pgpool instances (divide the normally used value by the number of active instances). The below text describes the effect of changing the configuration, and advises values for both the on-premise and the Cloud architecture. + +**max_pool**: Generally, it is advised to set `max_pool` to 1. Alternatively, for applications with a lot of reconnects, `max_pool` can be set to the number of distinct combinations of users, databases and connection options for the application connections. All but one connection in the pool would be stale connections, which consumes a connection slot from Postgres, without adding to performance. It is therefore advised not to configure `max_pool` beyond 4 to preserve a healthy ratio between active and stale connections. As an example, for an application which constantly reconnects and uses 2 distinct users both connecting to their own database, set it to 2. If both users would be able to connect to both databases set it to 4. Note that increasing `max_pool` requires to tune down `num_init_children` in Pgpool, or tune up `max_connections` in Postgres. + +**num_init_children**: It is advised to set `num_init_children` to the number of connections that could be running active in parallel, but the value should be divided by the number of active Pgpool-II instances (one with the on-premise architecture, and all instances for the cloud architecture). As an example: In an architecture with 3 Pgpool instances, to allow the application to have 100 active connections in parallel, set `num_init_children` to 100 for the on-premise architecture, and set `num_init_children` to 33 for the cloud architecture. Note that increasing `num_init_children` generally requires to tune up `max_connections` in Postgres. + +**listen_backlog_multiplier**: Can be set to multiply the number of open connections (as perceived by the application) with the number of active connections (`num_init_children`). As an example, when the application might open 500 connections of which 100 should be active in parallel, with the on-premise architecture, `num_init_children` should be set to 100, and `listen_backlog_multiplier` should be set to 4. This setup can process 100 connections active in parallel, and another 400 (`listen_backlog_multiplier*num_init_children`) connections will be queued before connections will be blocked. The application would perceive a total of 500 open connections, and Postgres would process the load of 100 connections maximum at all times. Note that increasing `listen_backlog_multiplier` only causes the application to perceive more connections, but will not increase the number of parallel active connections (which is determined by `num_init_children`). + +**max_connections**: It is advised to set `max_connections` in Postgres higher than `[number of active pgpool instances]*[max_pool]*[num_init_children] + [superuser_reserved_connections] (Postgres)`. As an example: in the on-premise setup with 3 instances active/passive, `max_pool` set to 2, `num_init_children` set to 100, and `superuser_reserved_connections (Postgres)` set to 5, Postgres `max_connections` should be set equal or higher then `[1*2*100+5]` which is 205 connections or higher. A similar setup in the cloud setup would run with 3 active instances, `max_pool` set to 2, `num_init_children` set to 33, and `superuser_reserved_connections (Postgres)` set to 5, in which case Postgres `max_connections` should be set equal or higher than `[3*2*33+5]` which is 203 or higher. Note that configuring below the advised setting can cause issues opening new connections, and in a combination with `max_pool` can cause unexpected behaviour (low or no active connections but still connection issues due to stale pooled connections using connection slots from Postgres. For more information on the relation between `num_init_children`, `max_pool` and `max_connections`, see this background information. diff --git a/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/images/EDB_logo.png b/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/images/EDB_logo.png new file mode 100755 index 00000000000..739c43dccc4 Binary files /dev/null and b/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/images/EDB_logo.png differ diff --git a/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/images/EFM_PgPool_Azure.png b/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/images/EFM_PgPool_Azure.png new file mode 100644 index 00000000000..6a183c39450 Binary files /dev/null and b/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/images/EFM_PgPool_Azure.png differ diff --git a/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/images/backend_pools.png b/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/images/backend_pools.png new file mode 100644 index 00000000000..9ec8e018a7b Binary files /dev/null and b/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/images/backend_pools.png differ diff --git a/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/images/edb_ha_architecture.png b/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/images/edb_ha_architecture.png new file mode 100644 index 00000000000..fe4ff379e29 Binary files /dev/null and b/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/images/edb_ha_architecture.png differ diff --git a/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/images/edb_ha_architecture1.png b/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/images/edb_ha_architecture1.png new file mode 100755 index 00000000000..a496f59b161 Binary files /dev/null and b/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/images/edb_ha_architecture1.png differ diff --git a/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/images/edb_ha_architecture_separate_VM.png b/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/images/edb_ha_architecture_separate_VM.png new file mode 100644 index 00000000000..117ff2973b8 Binary files /dev/null and b/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/images/edb_ha_architecture_separate_VM.png differ diff --git a/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/images/edb_logo.svg b/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/images/edb_logo.svg new file mode 100755 index 00000000000..74babf2f8da --- /dev/null +++ b/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/images/edb_logo.svg @@ -0,0 +1,56 @@ + + + + +logo + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/images/failover_manager_overview.png b/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/images/failover_manager_overview.png new file mode 100755 index 00000000000..9c79c7bdfc9 Binary files /dev/null and b/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/images/failover_manager_overview.png differ diff --git a/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/images/health_probes.png b/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/images/health_probes.png new file mode 100644 index 00000000000..567f71828b3 Binary files /dev/null and b/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/images/health_probes.png differ diff --git a/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/images/load_balancing_rules.png b/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/images/load_balancing_rules.png new file mode 100644 index 00000000000..41ca798f440 Binary files /dev/null and b/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/images/load_balancing_rules.png differ diff --git a/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/images/placeholder.png b/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/images/placeholder.png new file mode 100755 index 00000000000..b83a03f80c5 Binary files /dev/null and b/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/images/placeholder.png differ diff --git a/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/images/rule_port_9898.png b/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/images/rule_port_9898.png new file mode 100644 index 00000000000..a69326a55f3 Binary files /dev/null and b/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/images/rule_port_9898.png differ diff --git a/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/images/rule_port_9999.png b/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/images/rule_port_9999.png new file mode 100644 index 00000000000..aebd897f798 Binary files /dev/null and b/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/images/rule_port_9999.png differ diff --git a/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/index.mdx b/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/index.mdx new file mode 100644 index 00000000000..d351a2e7008 --- /dev/null +++ b/product_docs/docs/efm/4.1/efm_pgpool_ha_guide/index.mdx @@ -0,0 +1,18 @@ +--- +title: "EDB Postgres High Availability & Horizontal Read Scaling Architecture" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/high-availability-scalability-guide/4.1/genindex.html" + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/high-availability-scalability-guide/4.1/introduction.html" + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/high-availability-scalability-guide/4.1/conclusion.html" + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/high-availability-scalability-guide/4.1/index.html" +--- + +Since high-availability and read scalability are not part of the core feature set of EDB Postgres Advanced Server, Advanced Server relies on external tools to provide this functionality. This document focuses on the functionality provided by EDB Failover Manager and Pgpool-II, and discusses the implications of a high-availability architecture formed around these tools. + +
+ +introduction architecture components_ha_pgpool appendix_a appendix_b conclusion + +
diff --git a/product_docs/docs/efm/4.1/efm_quick_start/images/edb_logo.png b/product_docs/docs/efm/4.1/efm_quick_start/images/edb_logo.png new file mode 100755 index 00000000000..b83a03f80c5 Binary files /dev/null and b/product_docs/docs/efm/4.1/efm_quick_start/images/edb_logo.png differ diff --git a/product_docs/docs/efm/4.1/efm_quick_start/images/edb_logo.svg b/product_docs/docs/efm/4.1/efm_quick_start/images/edb_logo.svg new file mode 100755 index 00000000000..74babf2f8da --- /dev/null +++ b/product_docs/docs/efm/4.1/efm_quick_start/images/edb_logo.svg @@ -0,0 +1,56 @@ + + + + +logo + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/product_docs/docs/efm/4.1/efm_quick_start/images/failover_manager_overview.png b/product_docs/docs/efm/4.1/efm_quick_start/images/failover_manager_overview.png new file mode 100755 index 00000000000..9c79c7bdfc9 Binary files /dev/null and b/product_docs/docs/efm/4.1/efm_quick_start/images/failover_manager_overview.png differ diff --git a/product_docs/docs/efm/4.1/efm_quick_start/images/placeholder.png b/product_docs/docs/efm/4.1/efm_quick_start/images/placeholder.png new file mode 100755 index 00000000000..b83a03f80c5 Binary files /dev/null and b/product_docs/docs/efm/4.1/efm_quick_start/images/placeholder.png differ diff --git a/product_docs/docs/efm/4.1/efm_quick_start/index.mdx b/product_docs/docs/efm/4.1/efm_quick_start/index.mdx new file mode 100644 index 00000000000..71d4d63b056 --- /dev/null +++ b/product_docs/docs/efm/4.1/efm_quick_start/index.mdx @@ -0,0 +1,146 @@ +--- +title: "Creating a Failover Manager Cluster" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/installation-getting-started/quick-start/4.1/genindex.html" + - "/edb-docs/d/edb-postgres-failover-manager/installation-getting-started/quick-start/4.1/index.html" +--- + +EDB Postgres Failover Manager (Failover Manager) is a high-availability module from EnterpriseDB that enables a Postgres Primary node to automatically failover to a Standby node in the event of a software or hardware failure on the Primary. + +This quick start guide describes configuring a Failover Manager cluster in a test environment. You should read and understand the [EDB Failover Manager User's Guide](/efm/latest/) before configuring Failover Manager for a production deployment. + +You must perform some basic installation and configuration steps before performing this tutorial: + +- You must install and initialize a database server on one primary and one or two standby nodes; for information about installing Advanced Server, visit: + + [https://www.enterprisedb.com/docs/p/edb-postgres-advanced-server](/epas/latest/) + +- Postgres streaming replication must be configured and running between the primary and standby nodes. For detailed information about configuring streaming replication, visit: + + . + +- You must also install Failover Manager on each primary and standby node. During Advanced Server installation, you configured an EnterpriseDB repository on each database host. You can use the EnterpriseDB repository and the `yum install` command to install Failover Manager on each node of the cluster: + + ```text + yum install edb-efm41 + ``` + +During the installation process, the installer will create a user named `efm` that has sufficient privileges to invoke scripts that control the Failover Manager service for clusters owned by `enterprisedb` or `postgres`. The example that follows creates a cluster named `efm`. + +Start the configuration process on a primary or standby node. Then, copy the configuration files to other nodes to save time. + +**Step 1: Create Working Configuration Files** + +Copy the provided sample files to create EFM configuration files, and correct the ownership: + +```text +cd /etc/edb/efm-4.1 + +cp efm.properties.in efm.properties + +cp efm.nodes.in efm.nodes + +chown efm:efm efm.properties + +chown efm:efm efm.nodes +``` + +**Step 2: Create an Encrypted Password** + +Create the [encrypted password](/efm/latest/efm_user/04_configuring_efm/02_encrypting_database_password/) needed for the properties file: + +```text +/usr/edb/efm-4.1/bin/efm encrypt efm +``` + +Follow the onscreen instructions to produce the encrypted version of your database password. + +**Step 3: Update the efm.properties File** + +The `.properties` file (efm.properties file in this example) contains parameters that specify connection properties and behaviors for your Failover Manager cluster. Modifications to property settings are applied when Failover Manager starts. + +The properties mentioned in this tutorial are the minimal properties required to configure a Failover Manager cluster. If you are configuring a production system, please review the *EDB Failover Manager Guide* for detailed information about Failover Manager options. + +Provide values for the following properties on all cluster nodes: + +| Property | Description | +| ----------------------- | -------------------------------------------------------------------------------------------------------------------------------- | +| `db.user` | The name of the database user. | +| `db.password.encrypted` | The encrypted password of the database user. | +| `db.port` | The port monitored by the database. | +| `db.database` | The name of the database. | +| `db.service.owner` | The owner of the `data` directory (usually `postgres` or `enterprisedb`). Required only if the database is running as a service. | +| `db.service.name` | The name of the database service (used to restart the server). Required only if the database is running as a service. | +| `db.bin` | The path to the `bin` directory (used for calls to `pg_ctl`). | +| `db.recovery.dir` | The `data` directory in which EFM will find or create the `recovery.conf` file or the `standby.signal` file. | +| `user.email` | An email address at which to receive email notifications (notification text is also in the agent log file). | +| `bind.address` | The local address of the node and the port to use for EFM. The format is: `bind.address=1.2.3.4:7800` | +| `is.witness` | `true` on a witness node and `false` if it is a primary or standby. | +| `ping.server.ip` | If you are running on a network without Internet access, set `ping.server.ip` to an address that is available on your network. | +| `auto.allow.hosts` | On a test cluster, set to `true` to simplify startup; for production usage, consult the user's guide. | +| `stable.nodes.file` | On a test cluster, set to `true` to simplify startup; for production usage, consult the user's guide. | + +**Step 4: Update the efm.nodes File** + +The `.nodes` file (efm.nodes file in this example) is read at startup to tell an agent how to find the rest of the cluster or, in the case of the first node started, can be used to simplify authorization of subsequent nodes. Add the addresses and ports of each node in the cluster to this file. One node will act as the membership coordinator; the list should include at least the membership coordinator's address. For example: + + `1.2.3.4:7800` + + `1.2.3.5:7800` + + `1.2.3.6:7800` + +Please note that the Failover Manager agent will not verify the content of the `efm.nodes` file; the agent expects that some of the addresses in the file cannot be reached (e.g. that another agent hasn’t been started yet). + +**Step 5: Configure the Other Nodes** + +Copy the `efm.properties` and `efm.nodes` files to the `/etc/edb/efm-4.1` directory on the other nodes in your sample cluster. After copying the files, change the file ownership so the files are owned by `efm:efm`. The `efm.properties` file can be the same on every node, except for the following properties: + +- Modify the `bind.address` property to use the node’s local address. +- Set `is.witness` to `true` if the node is a witness node. If the node is a witness node, the properties relating to a local database installation will be ignored. + +**Step 6: Start the EFM Cluster** + +On any node, start the Failover Manager agent. The agent is named `edb-efm-4.1`; you can use your platform-specific service command to control the service. For example, on a CentOS/RHEL 7.x or CentOS/RHEL 8.x host use the command: + +```text +systemctl start edb-efm-4.1 +``` + +On a a CentOS or RHEL 6.x host use the command: + +```text +service edb-efm-4.1 start +``` + +After the agent starts, run the following command to see the status of the single-node cluster. You should see the addresses of the other nodes in the `Allowed node host` list. + +```text +/usr/edb/efm-4.1/bin/efm cluster-status efm +``` + +Start the agent on the other nodes. Run the `efm cluster-status efm` command on any node to see the cluster status. + +If any agent fails to start, see the startup log for information about what went wrong: + +```text +cat /var/log/efm-4.1/startup-efm.log +``` + +**Performing a Switchover** + +If the cluster status output shows that the primary and standby(s) are in sync, you can perform a switchover with the following command: + +```text +/usr/edb/efm-4.1/bin/efm promote efm -switchover +``` + +The command will promote a standby and reconfigure the primary database as a new standby in the cluster. To switch back, run the command again. + +For quick access to online help, you can invoke the following command: + +```text +/usr/edb/efm-4.1/bin/efm --help +``` diff --git a/product_docs/docs/efm/4.1/efm_user/01_whats_new.mdx b/product_docs/docs/efm/4.1/efm_user/01_whats_new.mdx new file mode 100644 index 00000000000..721f5dccce8 --- /dev/null +++ b/product_docs/docs/efm/4.1/efm_user/01_whats_new.mdx @@ -0,0 +1,16 @@ +--- +title: "What’s New" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.1/whats_new.html" +--- + + + +The following changes have been made to EDB Postgres Failover Manager to create version 4.1: + +- EFM Pgpool integration scripts have been included in the EFM distribution. This will allow the customers to implement EFM Pgpool HA architecture directly from the deployed software, without using the custom integration scripts. +- EFM Pgpool HA architecture deployment with Azure Network Load Balancer has been enabled, tested, and documented. +- Standby Agents attempt to resume health monitoring when local database connectivity is recovered. +- Option provided to automatically increase `num_sync` when synchronous Standbys are added to a cluster or they rejoin a cluster. diff --git a/product_docs/docs/efm/4.1/efm_user/02_failover_manager_overview/01_prerequisites.mdx b/product_docs/docs/efm/4.1/efm_user/02_failover_manager_overview/01_prerequisites.mdx new file mode 100644 index 00000000000..dff775c99ff --- /dev/null +++ b/product_docs/docs/efm/4.1/efm_user/02_failover_manager_overview/01_prerequisites.mdx @@ -0,0 +1,102 @@ +--- +title: "Prerequisites" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.1/prerequisites.html" +--- + + + +Before configuring a Failover Manager cluster, you must satisfy the prerequisites described below. + +**Install Java 1.8 (or later)** + +Before using Failover Manager, you must first install Java (version 1.8 or later). Failover Manager is tested with OpenJDK, and we strongly recommend installing that version of Java. [Installation instructions for Java](https://openjdk.java.net/install/) are platform specific. + +**Provide an SMTP Server** + +You can receive notifications from Failover Manager as specified by a user-defined notification script, by email, or both. + +- If you are using email notifications, an SMTP server must be running on each node of the Failover Manager scenario. +- If you provide a value in the script.notification property, you can leave the user.email field blank; an SMTP server is not required. + +If an event occurs, Failover Manager invokes the script (if provided), and can also send a notification email to any email addresses specified in the user.email parameter of the cluster properties file. For more information about using an SMTP server, visit: + +[https://access.redhat.com/site/documentation](https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/s1-email-mta.html) + +**Configure Streaming Replication** + +Failover Manager requires that PostgreSQL streaming replication be configured between the Primary node and the Standby node or nodes. Failover Manager does not support other types of replication. + +On database versions 11 (or prior), unless specified with the `-sourcenode` option, a `recovery.conf` file is copied from a random standby node to the stopped primary during switchover. You should ensure that the paths within the `recovery.conf` file on your standby nodes are consistent before performing a switchover. For more information about the `-sourcenode` option, please see [Promoting a Failover Manager Node](../05_using_efm/#promote_node). + +On database version 12 or later, the `primary_conninfo` and `restore_command` properties are copied from a random standby node to the stopped primary during switchover (unless otherwise specified with the `-sourcenode` option). + +**Modify the pg_hba.conf File** + +You must modify the `pg_hba.conf` file on the Primary and Standby nodes, adding entries that allow communication between the all of the nodes in the cluster. The following example demonstrates entries that might be made to the pg_hba.conf file on the Primary node: + +```text +# access for itself +host fmdb efm 127.0.0.1/32 md5 +# access for standby +host fmdb efm 192.168.27.1/32 md5 +# access for witness +host fmdb efm 192.168.27.34/32 md5 +``` + +Where: + + `efm` specifies the name of a valid database user. + + `fmdb` specifies the name of a database to which the efm user may connect. + +By default, the `pg_hba.conf` file resides in the `data` directory, under your Postgres installation. After modifying the `pg_hba.conf` file, you must reload the configuration file on each node for the changes to take effect. You can use the following command: + + `# systemctl reload edb-as-x` + +Where `x` specifies the Postgres version. + +**Using Autostart for the Database Servers** + +If a Primary node reboots, Failover Manager may detect the database is down on the Primary node and promote a Standby node to the role of Primary. If this happens, the Failover Manager agent on the (rebooted) Primary node will not get a chance to write the `recovery.conf` file; the `recovery.conf` file prevents the database server from starting. If this happens, the rebooted Primary node will return to the cluster as a second Primary node. + +To prevent this, ensure that the Failover Manager agent auto starts before the database server. The agent will start in idle mode, and check to see if there is already a primary in the cluster. If there is a primary node, the agent will verify that a `recovery.conf` or `standby.signal` file exists, and the database will not start as a second primary. + +**Ensure Communication Through Firewalls** + +If a Linux firewall (i.e. iptables) is enabled on the host of a Failover Manager node, you may need to add rules to the firewall configuration that allow tcp communication between the Failover Manager processes in the cluster. For example: + +```text +# iptables -I INPUT -p tcp --dport 7800 -j ACCEPT +/sbin/service iptables save +``` + +The command shown above opens the port 7800. Failover Manager will connect via the port that corresponds to the port specified in the cluster properties file. + +**Ensure that the Database user has Sufficient Privileges** + +The database user specified by the `db.user` property in the `efm.properties` file must have sufficient privileges to invoke the following functions on behalf of Failover Manager: + + `pg_current_wal_lsn()` + + `pg_last_wal_replay_lsn()` + + `pg_wal_replay_resume()` + + `pg_wal_replay_pause()` + + `pg_reload_conf()` + +The `pg_reload_conf()` privilege is required only if you have the `reconfigure.num.sync` or `reconfigure.sync.primary` property set to `true`. + +For detailed information about each of these functions, please see the [PostgreSQL core documentation](https://www.postgresql.org/docs/current/index.html). + +The user must also have permissions to read the values of configuration variables; a database superuser can use the PostgreSQL `GRANT` command to provide the permissions needed: + +```text +GRANT pg_read_all_settings TO user_name; +``` + +For more information about `pg_read_all_settings`, please see the [PostgreSQL core documentation](https://www.postgresql.org/docs/current/default-roles.html). diff --git a/product_docs/docs/efm/4.1/efm_user/02_failover_manager_overview/index.mdx b/product_docs/docs/efm/4.1/efm_user/02_failover_manager_overview/index.mdx new file mode 100644 index 00000000000..fac4ec73d30 --- /dev/null +++ b/product_docs/docs/efm/4.1/efm_user/02_failover_manager_overview/index.mdx @@ -0,0 +1,37 @@ +--- +title: "Failover Manager Overview" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.1/failover_manager_overview.html" +--- + + + +An EDB Postgres Failover Manager (EFM) cluster is comprised of Failover Manager processes that reside on the following hosts on a network: + +- A Primary node - The Primary node is the primary database server that is servicing database clients. +- One or more Standby nodes - A Standby node is a streaming replication server associated with the Primary node. +- A Witness node - The Witness node confirms assertions of either the Primary or a Standby in a failover scenario. A cluster does not need a dedicated witness node if the cluster contains three or more nodes. If you do not have a third cluster member that is a database host, you can add a dedicated Witness node. A cluster may include more than one witness node. + +Traditionally, a *cluster* is a single instance of Postgres managing multiple databases. In this document, the term cluster refers to a Failover Manager cluster. A Failover Manager cluster consists of a Primary agent, one or more Standby agents, and an optional Witness agent that reside on servers in a cloud or on a traditional network and communicate using the JGroups toolkit. + +![An EFM scenario employing a Virtual IP address.](../images/failover_manager_overview.png) + +When a non-witness agent starts, it connects to the local database and checks the state of the database: + +- If the agent cannot reach the database, it will start in idle mode. +- If it finds that the database is in recovery, the agent assumes the role of standby. +- If the database is not in recovery, the agent assumes the role of primary. + +In the event of a failover, Failover Manager attempts to ensure that the promoted standby is the most up-to-date standby in the cluster; please note that data loss is possible if the standby node is not in sync with the primary node. + +[JGroups](http://www.jgroups.org/) provides technology that allows Failover Manager to create clusters whose member nodes can communicate with each other and detect node failures. + +The figure shown above illustrates a Failover Manager cluster that employs a virtual IP address. You can use a load balancer in place of a [virtual IP address](../04_configuring_efm/05_using_vip_addresses/#using_vip_addresses) if you provide your own [script](../04_configuring_efm/01_cluster_properties/#cluster_properties) to re-configure the load balancer whenever databases are added or removed. You can also choose to enable native EFM-Pgpool integration for high availability. + +
+ +prerequisites + +
diff --git a/product_docs/docs/efm/4.1/efm_user/03_installing_efm.mdx b/product_docs/docs/efm/4.1/efm_user/03_installing_efm.mdx new file mode 100644 index 00000000000..356d8649f0b --- /dev/null +++ b/product_docs/docs/efm/4.1/efm_user/03_installing_efm.mdx @@ -0,0 +1,315 @@ +--- +title: "Installing Failover Manager" +legacyRedirects: + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.1/installing_debian_ubuntu.html" + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.1/installing_sles.html" + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.1/post_install_tasks.html" + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.1/installing_rhel_centos_oel.html" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.1/installing_efm.html" +--- + + + + + +To request credentials that allow you to access an EnterpriseDB repository, visit the EDB website at: + + + +## RedHat or CentOS Host + +When you install an RPM package that is signed by a source that is not recognized by your system, yum may ask for your permission to import the key to your local server. If prompted, and you are satisfied that the packages come from a trustworthy source, enter y, and press Return to continue. + +During the installation, yum may encounter a dependency that it cannot resolve. If it does, it will provide a list of the required dependencies that you must manually resolve. + +Failover Manager must be installed by root. During the installation process, the installer will also create a user named efm that has sufficient privileges to invoke scripts that control the Failover Manager service for clusters owned by enterprisedb or postgres. + +After receiving your credentials, you must create the EnterpriseDB repository configuration file on each node of the cluster, and then modify the file to enable access. The following steps provide detailed information about accessing the EnterpriseDB repository; the steps must be performed on each node of the cluster. + +### RHEL or CentOS 7 PPCLE Host + +1. Use the following command to create a configuration file and install Advance Toolchain: + + ```text + rpm --import https://public.dhe.ibm.com/software/server/POWER/Linux/toolchain/at/redhat/RHEL7/gpg-pubkey-6976a827-5164221b + + cat > /etc/yum.repos.d/advance-toolchain.repo <:@USERNAME:PASSWORD@" /etc/yum.repos.d/edb.repo + ``` + +4. Install the EPEL repository: + + ```text + yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm + ``` + +5. On RHEL 7 PPCLE, enable the additional repositories to resolve EPEL dependencies: + + ```text + subscription-manager repos --enable "rhel-*-optional-rpms" --enable "rhel-*-extras-rpms" --enable "rhel-ha-for-rhel-*-server-rpms" + ``` + +6. Install the selected package: + + ```text + yum -y install edb-efm41 + ``` + +### RHEL or CentOS 7 Host + +1. To create the repository configuration file, assume superuser privileges, and invoke the following command: + + ```text + yum -y install https://yum.enterprisedb.com/edbrepos/edb-repo-latest.noarch.rpm + ``` + +2. Replace ‘USERNAME:PASSWORD’ below with your username and password for the EDB repositories: + + ```text + sed -i "s@:@USERNAME:PASSWORD@" /etc/yum.repos.d/edb.repo + ``` + +3. Install the EPEL repository: + + ```text + yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm + ``` + +4. On RHEL 7, enable the additional repositories to resolve dependencies: + + ```text + subscription-manager repos --enable "rhel-*-optional-rpms" --enable "rhel-*-extras-rpms" --enable "rhel-ha-for-rhel-*-server-rpms" + ``` + +5. Install the selected package: + + ```text + yum -y install edb-efm41 + ``` + +### RHEL or CentOS 8 Host + +1. To create the repository configuration file, assume superuser privileges, and invoke the following command: + ```text + dnf -y install https://yum.enterprisedb.com/edbrepos/edb-repo-latest.noarch.rpm + ``` + +2. Replace ‘USERNAME:PASSWORD’ below with your username and password for the EDB repositories: + + ```text + sed -i "s@:@USERNAME:PASSWORD@" /etc/yum.repos.d/edb.repo + ``` + +3. Install the EPEL repository: + +- On CentOS 8 + ```text + dnf -y install epel-release + ``` +- On RHEL 8 + ```text + dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm + ``` + +4. Enable the additional repositories to resolve dependencies: + +- On CentOS 8 + ```text + dnf config-manager --set-enabled PowerTools + ``` +- On RHEL 8 + + ```text + ARCH=$( /bin/arch ) subscription-manager repos --enable "codeready-builder-for-rhel-8-${ARCH}-rpms" + ``` + +5. Disable the built-in PostgreSQL module: + + ```text + dnf -qy module disable postgresql + ``` +6. Install the selected package: + ```text + dnf -y install edb-efm41 + ``` + +## Debian or Ubuntu Host + +To install Failover Manager, you must have credentials that allow access to the EnterpriseDB repository. To request credentials for the repository, visit the EnterpriseDB website at: + + + +The following steps will walk you through using the EnterpriseDB apt repository to install Failover Manager. + +### Debian Host + +1. Assume superuser privileges: + ```text + sudo su – + ``` +2. Configure the EnterpriseDB repository by substituting your EnterpriseDB credentials for the username and password placeholders in the following commands: + +- On Debian 9 + ```text + sh -c 'echo "deb https://username:password@apt.enterprisedb.com/$(lsb_release -cs)-edb/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/edb-$(lsb_release -cs).list' + ``` +- On Debian 10 + + ```text + sh -c 'echo "deb [arch=amd64] https://apt.enterprisedb.com/$(lsb_release -cs)-edb/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/edb-$(lsb_release -cs).list' + + sh -c 'echo "machine apt.enterprisedb.com login password " > /etc/apt/auth.conf.d/edb.conf' + ``` + +3. Add support to your system for secure APT repositories: + ```text + apt-get install apt-transport-https + ``` +4. Add the EDB signing key: + ```text + wget -q -O - https://:@apt.enterprisedb.com/edb-deb.gpg.key | apt-key add - + ``` +5. Update the repository meta data: + ```text + apt-get update + ``` +6. Install Failover Manager: + ```text + apt-get -y install edb-efm41 + ``` + +### Ububtu Host + +1. Assume superuser privileges: + ```text + sudo su – + ``` +2. Configure the EnterpriseDB repository by substituting your EnterpriseDB credentials for the username and password placeholders in the following commands: + +- On Ubuntu 18.04 + ```text + sh -c 'echo "deb https://username:password@apt.enterprisedb.com/$(lsb_release -cs)-edb/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/edb-$(lsb_release -cs).list' + ``` +- On Ubuntu 20.4 + + ```text + sh -c 'echo "deb [arch=amd64] https://apt.enterprisedb.com/$(lsb_release -cs)-edb/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/edb-$(lsb_release -cs).list' + + sh -c 'echo "machine apt.enterprisedb.com login password " > /etc/apt/auth.conf.d/edb.conf' + ``` + +3. Add support to your system for secure APT repositories: + ```text + apt-get install apt-transport-https + ``` +4. Add the EDB signing key: + ```text + wget -q -O - https://:@apt.enterprisedb.com/edb-deb.gpg.key | apt-key add - + ``` +5. Update the repository meta data: + ```text + apt-get update + ``` +6. Install Failover Manager: + ```text + apt-get -y install edb-efm41 + ``` + +## SLES Host + +To install Failover Manager, you must have credentials that allow access to the EnterpriseDB repository. To request credentials for the repository, visit the EnterpriseDB website at: + + + +You can use the zypper package manager to install a Failover Manager agent on an SLES 12 host. zypper will attempt to satisfy package dependencies as it installs a package, but requires access to specific repositories that are not hosted at EnterpriseDB. + +1. You must assume superuser privileges and stop any firewalls before installing Failover Manager. Then, use the following commands to add EnterpriseDB repositories to your system: + + ```text + zypper addrepo https://zypp.enterprisedb.com/suse/edb-sles.repo + ``` + +2. The commands create the repository configuration files in the /etc/zypp/repos.d directory. Then, use the following command to refresh the metadata on your SLES host to include the EnterpriseDB repository: + + ```text + zypper refresh + ``` + + When prompted, provide credentials for the repository, and specify a to always trust the provided key, and update the metadata to include the EnterpriseDB repository. + +3. You must also add SUSEConnect and the SUSE Package Hub extension to the SLES host, and register the host with SUSE, allowing access to SUSE repositories. Use the commands: + + ```text + zypper install SUSEConnect + SUSEConnect -r -e + SUSEConnect -p PackageHub/12.4/x86_64 + SUSEConnect -p sle-sdk/12.4/x86_64 + ``` + +4. Install SUSEConnect to register the host with SUSE, allowing access to SUSE repositories: + + ```text + zypper addrepo https://download.opensuse.org/repositories/Apache:/Modules/SLE_12_SP4/Apache:Modules.repo + ``` + +5. Install OpenJDK (version 1.8) for Java based components: + + ```text + zypper -n install java-1_8_0-openjdk + ``` + +6. Now you can use the zypper utility to install a Failover Manager agent: + + ```text + zypper -n install edb-efm41 + ``` + +## Performing post-installation tasks + +If you are using Failover Manager to monitor a cluster owned by a user other than `enterprisedb` or `postgres`, see [Extending Failover Manager Permissions](04_configuring_efm/04_extending_efm_permissions/#extending_efm_permissions) . + +After installing on each node of the cluster, you must: + +1. Modify the [cluster properties file](04_configuring_efm/01_cluster_properties/#cluster_properties) on each node. +2. Modify the [cluster members file](04_configuring_efm/03_cluster_members/#cluster_members) on each node. +3. If applicable, configure and test virtual IP address settings and any scripts that are identified in the cluster properties file. +4. Start the agent on each node of the cluster. For more information about controlling the service, see [Section 5](08_controlling_efm_service/#controlling-the-failover-manager-service). + +### Installation Locations + +components are installed in the following locations: + +| Component | Location | +| --------------------------------- | --------------------------- | +| Executables | /usr/edb/efm-4.1/bin | +| Libraries | /usr/edb/efm-4.1/lib | +| Cluster configuration files | /etc/edb/efm-4.1 | +| Logs | /var/log/efm- 4.1 | +| Lock files | /var/lock/efm-4.1 | +| Log rotation file | /etc/logrotate.d/efm-4.1 | +| sudo configuration file | /etc/sudoers.d/efm-41 | +| Binary to access VIP without sudo | /usr/edb/efm-4.1/bin/secure | diff --git a/product_docs/docs/efm/4.1/efm_user/04_configuring_efm/01_cluster_properties/01_encrypting_database_password.mdx b/product_docs/docs/efm/4.1/efm_user/04_configuring_efm/01_cluster_properties/01_encrypting_database_password.mdx new file mode 100644 index 00000000000..519c8771bf8 --- /dev/null +++ b/product_docs/docs/efm/4.1/efm_user/04_configuring_efm/01_cluster_properties/01_encrypting_database_password.mdx @@ -0,0 +1,77 @@ +--- +title: "Encrypting Your Database Password" +--- + + + +Failover Manager requires you to encrypt your database password before including it in the cluster properties file. Use the [efm utility](../../07_using_efm_utility/#efm_encrypt) (located in the `/usr/edb/efm-4.1/bin` directory) to encrypt the password. When encrypting a password, you can either pass the password on the command line when you invoke the utility, or use the `EFMPASS` environment variable. + +To encrypt a password, use the command: + +```text +# efm encrypt [ --from-env ] +``` + +Where `` specifies the name of the Failover Manager cluster. + +If you include the `--from-env` option, you must export the value you wish to encrypt before invoking the encryption utility. For example: + +```text +export EFMPASS=password +``` + +If you do not include the `--from-env` option, Failover Manager will prompt you to enter the database password twice before generating an encrypted password for you to place in your cluster property file. When the utility shares the encrypted password, copy and paste the encrypted password into the cluster property files. + +!!! Note + Many Java vendors ship their version of Java with full-strength encryption included, but not enabled due to export restrictions. If you encounter an error that refers to an illegal key size when attempting to encrypt the database password, you should download and enable a Java Cryptography Extension (JCE) that provides an unlimited policy for your platform. + +The following example demonstrates using the encrypt utility to encrypt a password for the `acctg` cluster: + +```text +# efm encrypt acctg +This utility will generate an encrypted password for you to place in + your EFM cluster property file: +/etc/edb/efm-4.1/acctg.properties +Please enter the password and hit enter: +Please enter the password again to confirm: +The encrypted password is: 516b36fb8031da17cfbc010f7d09359c +Please paste this into your acctg.properties file +db.password.encrypted=516b36fb8031da17cfbc010f7d09359c +``` + +!!! Note + The utility will notify you if a properties file does not exist. + +After receiving your encrypted password, paste the password into the properties file and start the Failover Manager service. If there is a problem with the encrypted password, the Failover Manager service will not start: + +```text +[witness@localhost ~]# systemctl start edb-efm-4.1 +Job for edb-efm-4.1.service failed because the control process exited with error code. See "systemctl status edb-efm-4.1.service" and "journalctl -xe" for details. +``` + +If you receive this message when starting the Failover Manager service, please see the startup log (located in `/var/log/efm-4.1/startup-efm.log`) for more information. + +If you are using RHEL/CentOS 7.x or RHEL/CentOS 8.x, startup information is also available with the following command: + +```text +systemctl status edb-efm-4.1 +``` + +To prevent a cluster from inadvertently connecting to the database of another cluster, the cluster name is incorporated into the encrypted password. If you modify the cluster name, you will need to re-encrypt the database password and update the cluster properties file. + +**Using the EFMPASS Environment Variable** + +The following example demonstrates using the --from-env environment variable when encrypting a password. Before invoking the `efm encrypt` command, set the value of `EFMPASS` to the password (`1safepassword`): + +```text +# export EFMPASS=1safepassword +``` + +Then, invoke `efm encrypt`, specifying the `--from-env` option: + +```text +# efm encrypt acctg --from-env +# 7ceecd8965fa7a5c330eaa9e43696f83 +``` + +The encrypted password (`7ceecd8965fa7a5c330eaa9e43696f83`) is returned as a text value; when using a script, you can check the exit code of the command to confirm that the command succeeded. A successful execution returns `0`. diff --git a/product_docs/docs/efm/4.1/efm_user/04_configuring_efm/01_cluster_properties/index.mdx b/product_docs/docs/efm/4.1/efm_user/04_configuring_efm/01_cluster_properties/index.mdx new file mode 100644 index 00000000000..cf5e88e0e03 --- /dev/null +++ b/product_docs/docs/efm/4.1/efm_user/04_configuring_efm/01_cluster_properties/index.mdx @@ -0,0 +1,1249 @@ +--- +title: "The Cluster Properties File" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.1/cluster_properties.html" +--- + + + +Each node in a Failover Manager cluster has a properties file (by default, named `efm.properties`) that contains the properties of the individual node on which it resides. The Failover Manager installer creates a file template for the properties file named `efm.properties.in` in the `/etc/edb/efm-4.1` directory. + +After completing the Failover Manager installation, you must make a working copy of the template before modifying the file contents: + +```text +# cp /etc/edb/efm-4.1/efm.properties.in /etc/edb/efm-4.1/efm.properties +``` + +After copying the template file, change the owner of the file to `efm`: + +```text +# chown efm:efm efm.properties +``` + +!!! Note + By default, Failover Manager expects the cluster properties file to be named `efm.properties`. If you name the properties file something other than `efm.properties`, you must modify the service script or unit file to instruct Failover Manager to use a different name. + +After creating the cluster properties file, add (or modify) configuration parameter values as required. For detailed information about each property, see [Specifying Cluster Properties](#specifying-cluster-properties). + +The property files are owned by `root`. The Failover Manager service script expects to find the files in the `/etc/edb/efm-4.1 directory`. If you move the property file to another location, you must create a symbolic link that specifies the new location. + +!!! Note + All user scripts referenced in the properties file will be invoked as the Failover Manager user. + + + +## Specifying Cluster Properties + +You can use the properties listed in the cluster properties file to specify connection properties and behaviors for your Failover Manager cluster. Modifications to property settings will be applied when Failover Manager starts. If you modify a property value you must restart Failover Manager to apply the changes. + +Property values are case-sensitive. Note that while Postgres uses quoted strings in parameter values, Failover Manager does not allow quoted strings in property values. For example, while you might specify an IP address in a Postgres configuration parameter as: + +> `listen_addresses='192.168.2.47'` + +Failover Manager requires that the value *not* be enclosed in quotes: + +> `bind.address=192.168.2.54:7800` + +Use the properties in the `efm.properties` file to specify connection, administrative, and operational details for Failover Manager. + +**Legends**: In the following table: + +- `A`: Required on Primary or Standby node +- `W`: Required on Witness node +- `Y` : Yes + +| **Property Name** | **A** | **W** | **Default Value** | **Comments** | +| ------------------------------------------------------------- | ----- | ----- | ------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [db.user](#db_user) | Y | Y | | Username for the database | +| [db.password.encrypted](#db_password_encrypted) | Y | Y | | Password encrypted using 'efm encrypt' | +| [db.port](#db_port) | Y | Y | | This value must be same for all the agents | +| [db.database](#db_database) | Y | Y | | Database name | +| [db.service.owner](#db_service_owner) | Y | | | Owner of $PGDATA dir for db.database | +| [db.service.name](#db_service_name) | | | | Required if running the database as a service | +| [db.bin](#db_bin) | Y | | | Directory containing the pg_controldata/pg_ctl commands such as '/usr/edb/as12/bin' | +| [db.data.dir](#db_data_dir) | Y | | | Same as the output of query 'show data_directory;' | +| [db.config.dir](#db_config_dir) | | | | Same as the output of query 'show config_file;'. Should be specified if it is not same as *db.data.dir* | +| [jdbc.sslmode](#jdbc_sslmode) | Y | Y | disable | See the [note](#jdbc_note) | +| [user.email](#user_email) | | | | This value must be same for all the agents; can be left blank if using a notification script | +| [from.email](#from_email) | | | [efm@localhost](mailto:efm@localhost) | Leave blank to use the default [efm@localhost](mailto:efm@localhost) | +| [notification.level](#notification_level) | Y | Y | INFO | See the [list of notifications](../../10_notifications/#notifications) | +| [notification.text.prefix](#notification_text_prefix) | | | | | +| [script.notification](#script_notification) | | | | Required if user.email property is not used; both parameters can be used together | +| [bind.address](#bind_address) | Y | Y | | Example: <ip_address>:<port> | +| [external.address](#external_address) | | | | Example: <ip_address/hostname> | +| [admin.port](#admin_port) | Y | Y | 7809 | Modify if the default port is already in use | +| [is.witness](#is_witness) | Y | Y | | See description | +| [local.period](#local_period) | Y | | 10 | | +| [local.timeout](#local_timeout) | Y | | 60 | | +| [local.timeout.final](#local_timeout_final) | Y | | 10 | | +| [remote.timeout](#remote_timeout) | Y | Y | 10 | | +| [node.timeout](#node_timeout) | Y | Y | 50 | This value must be same for all the agents | +| [encrypt.agent.messages](#encrypt_agent_messages) | Y | Y | false | This value must be same for all the agents | +| [stop.isolated.primary](#stop_isolated_primary) | Y | | true | | +| [stop.failed.primary](#stop_failed_primary) | Y | | true | | +| [primary.shutdown.as.failure](#primary_shutdown_as_failure) | Y | Y | false | | +| [update.physical.slots.period](#update_physical_slots_period) | Y | | 0 | | +| [ping.server.ip](#ping_server_ip) | Y | Y | 8.8.8.8 | | +| [ping.server.command](#ping_server_command) | Y | Y | /bin/ping -q -c3 -w5 | | +| [auto.allow.hosts](#auto_allow_hosts) | Y | Y | false | | +| [stable.nodes.file](#stable_nodes_file) | Y | Y | false | | +| [db.reuse.connection.count](#db_reuse_connection_count) | Y | | 0 | | +| [auto.failover](#auto_failover) | Y | Y | true | | +| [auto.reconfigure](#auto_reconfigure) | Y | | true | This value must be same for all the agents | +| [promotable](#promotable) | Y | | true | | +| [use.replay.tiebreaker](#use_replay_tiebreaker) | Y | Y | true | This value must be same for all the agents | +| [standby.restart.delay](#standby_restart_delay) | | | 0 | | +| [application.name](#application_name) | | | | Set to replace the application_name portion of the primary_conninfo entry with this property value before starting the original primary database as a standby. | +| [restore.command](#restore_command) | | | | Example: restore.command=scp <db_service_owner>@%h: <archive_path>/%f %p | +| [reconfigure.num.sync](#reconfigure_num_sync) | Y | | false | | +| [reconfigure.num.sync.max](#reconfigure_num_sync_max) | | | | | +| [reconfigure.sync.primary](#reconfigure_sync_primary) | Y | | false | | +| [minimum.standbys](#minimum_standbys) | Y | Y | 0 | This value must be same for all the nodes | +| [recovery.check.period](#recovery_check_period) | Y | | 1 | | +| [restart.connection.timeout](#restart_connection_timeout) | | | 60 | | +| [auto.resume.period](#auto_resume_period) | Y | | 0 | | +| [virtual.ip](#virtual_ip) | | | (see virtual.ip.single) | Leave blank if you do not specify a VIP | +| [virtual.ip.interface](#virtual_ip) | | | | Required if you specify a VIP | +| [virtual.ip.prefix](#virtual_ip) | | | | Required if you specify a VIP | +| [virtual.ip.single](#virtual_ip) | Y | Y | Yes | This value must be same for all the nodes | +| [check.vip.before.promotion](#check_vip_before_promotion) | Y | Y | Yes | | +| [pgpool.enable](#pgpool_enable) | | | false | | +| [pcp.user](#pgpool_enable) | | | | Required if pgpool.enable is set to true | +| [pcp.host](#pgpool_enable) | | | | Required if pgpool.enable is set to true, this value must be same for all the agents | +| [pcp.port](#pgpool_enable) | | | | Required if pgpool.enable is set to true, this value must be same for all the agents | +| [pcp.pass.file](#pgpool_enable) | | | | Required if pgpool.enable is set to true | +| [pgpool.bin](#pgpool_enable) | | | | Required if pgpool.enable is set to true | +| [script.load.balancer.attach](#script_load_balancer) | | | | Example: script.load.balancer.attach= /<path>/<attach_script> %h %t | +| [script.load.balancer.detach](#script_load_balancer) | | | | Example: script.load.balancer.detach= /<path>/<detach_script> %h %t | +| [script.fence](#script_fence) | | | | Example: script.fence= /<path>/<script_name> %p %f | +| [script.post.promotion](#script_post_promotion) | | | | Example: script.post.promotion= /<path>/<script_name> %f %p | +| [script.resumed](#script_resumed) | | | | Example: script.resumed= /<path>/<script_name> | +| [script.db.failure](#script_db_failure) | | | | Example: script.db.failure= /<path>/<script_name> | +| [script.primary.isolated](#script_primary_isolated) | | | | Example: script.primary.isolated= /<path>/<script_name> | +| [script.remote.pre.promotion](#script_remote_pre_promotion) | | | | Example: script.remote.pre.promotion= /<path>/<script_name> %p | +| [script.remote.post.promotion](#script_remote_post_promotion) | | | | Example: script.remote.post.promotion= /<path>/<script_name> %p | +| [script.custom.monitor](#script_custom_monitor) | | | | Example: script.custom.monitor= /<path>/<script_name> | +| [custom.monitor.interval](#script_custom_monitor) | | | | Required if a custom monitoring script is specified | +| [custom.monitor.timeout](#script_custom_monitor) | | | | Required if a custom monitoring script is specified | +| [custom.monitor.safe.mode](#script_custom_monitor) | | | | Required if a custom monitoring script is specified | +| [sudo.command](#sudo_command) | Y | Y | sudo | | +| [sudo.user.command](#sudo_command) | Y | Y | sudo -u %u | | +| [lock.dir](#lock_dir) | | | | If not specified, defaults to '/var/lock/efm-<version>' | +| [log.dir](#log_dir) | | | | If not specified, defaults to '/var/log/efm-<version>' | +| [syslog.host](#syslog_logging) | | | localhost | | +| [syslog.port](#syslog_logging) | | | 514 | | +| [syslog.protocol](#syslog_logging) | | | | | +| [syslog.facility](#syslog_logging) | | | UDP | | +| [file.log.enabled](#logtype_enabled) | Y | Y | true | | +| [syslog.enabled](#logtype_enabled) | Y | Y | false | | +| [jgroups.loglevel](#loglevel) | | | info | | +| [efm.loglevel](#loglevel) | | | info | | +| [jvm.options](#jvm_options) | | | -Xmx128m | | + +**Cluster Properties** + + + + + + + + + +Use the following properties to specify connection details for the Failover Manager cluster: + +```text +# The value for the password property should be the output from +# 'efm encrypt' -- do not include a cleartext password here. To +# prevent accidental sharing of passwords among clusters, the +# cluster name is incorporated into the encrypted password. If +# you change the cluster name (the name of this file), you must +# encrypt the password again with the new name. +# The db.port property must be the same for all nodes. +db.user= +db.password.encrypted= +db.port= +db.database= +``` + +The `db.user` specified must have sufficient privileges to invoke selected PostgreSQL commands on behalf of Failover Manager. For more information, please see [Prerequisites](../../02_failover_manager_overview/01_prerequisites/#prerequisites). + +For information about encrypting the password for the database user, see [Encrypting Your Database Password](01_encrypting_database_password/#encrypting_database_password). + + + +Use the `db.service.owner` property to specify the name of the operating system user that owns the cluster that is being managed by Failover Manager. This property is not required on a dedicated witness node. + +```text +# This property tells EFM which OS user owns the $PGDATA dir for +# the 'db.database'. By default, the owner is either 'postgres' +# for PostgreSQL or 'enterprisedb' for EDB Postgres Advanced +# Server. However, if you have configured your db to run as a +# different user, you will need to copy the /etc/sudoers.d/efm-XX +# conf file to grant the necessary permissions to your db owner. +# +# This username must have write permission to the +# 'db.data.dir' specified below. +db.service.owner= +``` + + + +Specify the name of the database service in the `db.service.name` property if you use the service or systemctl command when starting or stopping the service. + +```text +# Specify the proper service name in order to use service commands +# rather than pg_ctl to start/stop/restart a database. For example, if +# this property is set, then 'service restart' or 'systemctl +# restart ' +# (depending on OS version) will be used to restart the database rather +# than pg_ctl. +# This property is required if running the database as a service. +db.service.name= +``` + + + +You should use the same service control mechanism (pg_ctl, service, or systemctl) each time you start or stop the database service. If you use the `pg_ctl` program to control the service, specify the location of the `pg_ctl` program in the `db.bin` property. + +```text +# Specify the directory containing the pg_controldata/pg_ctl commands, +# for example: +# /usr/edb/as11/bin. Unless the db.service.name property is used, the +# pg_ctl command is used to start/stop/restart databases as needed +# after a failover or switchover. This property is required. +db.bin= +``` + + + +Use the `db.data.dir` property to specify the location to which a recovery file will be written on the Primary node of the cluster during promotion. This property is required on primary and standby nodes; it is not required on a dedicated witness node. + +```text +# For database version 12 and up, this is the directory where a +# standby.signal file will exist for a standby node. For previous +# versions, this is the location of the db recovery.conf file on +# the node. +# After a failover, the recovery.conf files on remaining standbys are +# changed to point to the new primary db (a copy of the original is made +# first). On a primary node, a recovery.conf file will be written during +# failover and promotion to ensure that the primary node can not be +# restarted as the primary database. +# This corresponds to database environment variable PGDATA and should +# be same as the output of query 'show data_directory;' on respective +# database. +db.data.dir= +``` + + + +Use the `db.config.dir` property to specify the location of database configuration files if they are not stored in the same directory as the `recovery.conf` or `standby.signal` file. This should be the value specified by the `config_file` parameter directory of your Advanced Server or PostgreSQL installation. This value will be used as the location of the Postgres `data` directory when stopping, starting, or restarting the database. + +```text +# Specify the location of database configuration files if they are +# not contained in the same location as the recovery.conf or +# standby.signal file. This is most likely the case for Debian +# installations. The location specified will be used as the -D value +# (the location of the data directory for the cluster) when calling +# pg_ctl to start or stop the database. If this property is blank, +# the db.data.dir location specified by the db.data.dir property will +# be used. This corresponds to the output of query 'show config_file;' +# on respective database. +db.config.dir= +``` + +For more information about database configuration files, visit the [PostgreSQL website](https://www.postgresql.org/docs/current/runtime-config-file-locations.html). + + + +Use the `jdbc.sslmode` property to instruct Failover Manager to use SSL connections; by default, SSL is disabled. + +```text +# Use the jdbc.sslmode property to enable ssl for EFM +# connections. Setting this property to anything but 'disable' +# will force the agents to use 'ssl=true' for all JDBC database +# connections (to both local and remote databases). +# Valid values are: +# +# disable - Do not use ssl for connections. +# verify-ca - EFM will perform CA verification before allowing +# the certificate. +# require - Verification will not be performed on the server +# certificate. +jdbc.sslmode=disable +``` + + + +!!! Note + If you set the value of `jdbc.sslmode` to `verify-ca` and you want to use Java trust store for certificate validation, you need to set the following value: + + `jdbc.properties=sslfactory=org.postgresql.ssl.DefaultJavaSSLFactory` + +For information about configuring and using SSL, please see: + +> + +and + +> + + + +Use the `user.email` property to specify an email address (or multiple email addresses) that will receive any notifications sent by Failover Manager. + +```text +# Email address(es) for notifications. The value of this +# property must be the same across all agents. Multiple email +# addresses must be separated by space. If using a notification +# script instead, this property can be left blank. +user.email= +``` + + + +The `from.email` property specifies the value that will be used as the sender's address on any email notifications from Failover Manager. You can: + +- leave `from.email` blank to use the default value (`efm@localhost`). +- specify a custom value for the email address. +- specify a custom email address, using the `%h` placeholder to represent the name of the node host (e.g., [example@%h](mailto:example@%h)). The placeholder will be replaced with the name of the host as returned by the Linux hostname utility. + +For more information about notifications, see [Notifications](../../10_notifications/#notifications). + +```text +# Use the from.email property to specify the from email address that +# will be used for email notifications. Use the %h placeholder to +# represent the name of the node host (e.g. example@%h). The +# placeholder will be replaced with the name of the host as returned +# by the hostname command. +# Leave blank to use the default, efm@localhost. +from.email= +``` + + + +Use the `notification.level` property to specify the minimum severity level at which Failover Manager will send user notifications or when a notification script is called. For a complete list of notifications, please see [Notifications](../../10_notifications/#notifications). + +```text +# Minimum severity level of notifications that will be sent by +# the agent. The minimum level also applies to the notification +# script (below). Valid values are INFO, WARNING, and SEVERE. +# A list of notifications is grouped by severity in the user's +# guide. +notification.level=INFO +``` + + + +Use the `notification.text.prefix` property to specify the text to be added to the beginning of every notification. + +```text +# Text to add to the beginning of every notification. This could +# be used to help identify what the cluster is used for, the role +# of this node, etc. To use multiple lines, add a backslash \ to +# the end of a line of text. To include a newline use \n. +# Example: +# notification.text.prefix=Development cluster for Example dept.\n\ +# Used by Dev and QA \ +# See Example group for questions. +notification.text.prefix= +``` + + + +Use the `script.notification` property to specify the path to a user-supplied script that acts as a notification service; the script will be passed a message subject and a message body. The script will be invoked each time Failover Manager generates a user notification. + +```text +# Absolute path to script run for user notifications. +# +# This is an optional user-supplied script that can be used for +# notifications instead of email. This is required if not using +# email notifications. Either/both can be used. The script will +# be passed two parameters: the message subject and the message +# body. +script.notification= +``` + + + +The `bind.address` property specifies the IP address and port number of the agent on the current node of the Failover Manager cluster. + +```text +# This property specifies the ip address and port that jgroups +# will bind to on this node. The value is of the form +# :. +# Note that the port specified here is used for communicating +# with other nodes, and is not the same as the admin.port below, +# used only to communicate with the local agent to send control +# signals. +# For example, :7800 +bind.address= +``` + + + +Use the `external.address` property to specify the IP address or hostname that should be used for communication with all other Failover Manager agents in a NAT environment. + +```text +# This is the ip address/hostname to be used for communication with all +# other Failover Manager agents. All traffic towards this address +# should be routed by the network to the bind.address of the node. +# The value is in the ip/hostname format only. This address will be +# used in scenarios where nodes are on different networks and broadcast +# an IP address other than the bind.address to the external world. +external.address= +``` + + + +Use the `admin.port` property to specify a port on which Failover Manager listens for administrative commands. + +```text +# This property controls the port binding of the administration +# server which is used for some commands (ie cluster-status). The +# default is 7809; you can modify this value if the port is +# already in use. +admin.port=7809 +``` + + + +Set the `is.witness` property to true to indicate that the current node is a witness node. If is.witness is true, the local agent will not check to see if a local database is running. + +```text +# Specifies whether or not this is a witness node. Witness nodes +# do not have local databases running. +is.witness= +``` + +The Postgres `pg_is_in_recovery()` function is a boolean function that reports the recovery state of a database. The function returns `true` if the database is in recovery, or false if the database is not in recovery. When an agent starts, it connects to the local database and invokes the `pg_is_in_recovery()` function. If the server responds true, the agent assumes the role of standby; if the server responds false, the agent assumes the role of primary. If there is no local database, the agent will assume an idle state. + +!!! Note + If `is.witness` is `true`, Failover Manager will not check the recovery state. + + + + + + + +The following properties specify properties that apply to the local server: + +- The `local.period` property specifies how many seconds between attempts to contact the database server. +- The `local.timeout` property specifies how long an agent will wait for a positive response from the local database server. +- The `local.timeout.final` property specifies how long an agent will wait after the above-mentioned previous checks have failed to contact the database server on the current node. If a response is not received from the database within the number of seconds specified by the `local.timeout.final` property, the database is assumed to have failed. + +For example, given the default values of these properties, a check of the local database happens once every 10 seconds. If an attempt to contact the local database does not come back positive within 60 seconds, Failover Manager makes a final attempt to contact the database. If a response is not received within 10 seconds, Failover Manager declares database failure and notifies the administrator listed in the user.email property. These properties are not required on a dedicated witness node. + +```text +# These properties apply to the connection(s) EFM uses to monitor +# the local database. Every 'local.period' seconds, a database +# check is made in a background thread. If the main monitoring +# thread does not see that any checks were successful in +# 'local.timeout' seconds, then the main thread makes a final +# check with a timeout value specified by the +# 'local.timeout.final' value. All values are in seconds. +# Whether EFM uses single or multiple connections for database +# checks is controlled by the 'db.reuse.connection.count' +# property. +local.period=10 +local.timeout=60 +local.timeout.final=10 +``` + +If necessary, you should modify these values to suit your business model. + + + +Use the `remote.timeout` property to specify how many seconds an agent waits for a response from a remote database server (i.e., how long a standby agent waits to verify that the primary database is actually down before performing failover). The `remote.timeout` property value specifies a timeout value for agent-to-agent communication; other timeout properties in the cluster properties file specify values for agent-to-database communication. + +```text +# Timeout for a call to check if a remote database is responsive. +# For example, this is how long a standby would wait for a +# DB ping request from itself and the witness to the primary DB +# before performing failover. +remote.timeout=10 +``` + + + +Use the `node.timeout` property to specify the number of seconds that an agent will wait for a response from a node when determining if a node has failed. + +```text +# The total amount of time in seconds to wait before determining +# that a node has failed or been disconnected from this node. +# +# The value of this property must be the same across all agents. +node.timeout=50 +``` + + + +Use the `encrypt.agent.messages` property to specify if the messages sent between agents should be encrypted. + +```text +# Set to true to encrypt messages that are sent between agents. +# This property must be the same on all agents or else the agents +# will not be able to connect. +encrypt.agent.messages=false +``` + + + +Use the `stop.isolated.primary` property to instruct Failover Manager to shut down the database if a primary agent detects that it is isolated. When true (the default), Failover Manager will stop the database before invoking the script specified in the `script.primary.isolated` property. + +```text +# Shut down the database after a primary agent detects that it has +# been isolated from the majority of the efm cluster. If set to +# true, efm will stop the database before running the +# 'script.primary.isolated' script, if a script is specified. +stop.isolated.primary=true +``` + + + +Use the `stop.failed.primary` property to instruct Failover Manager to attempt to shut down a primary database if it can not reach the database. If `true`, Failover Manager will run the script specified in the `script.db.failure` property after attempting to shut down the database. + +```text +# Attempt to shut down a failed primary database after EFM can no +# longer connect to it. This can be used for added safety in the +# case a failover is caused by a failure of the network on the +# primary node. +# If specified, a 'script.db.failure' script is run after this attempt. +stop.failed.primary=true +``` + + + +Use the `primary.shutdown.as.failure` parameter to indicate that any shutdown of the Failover Manager agent on the primary node should be treated as a failure. If this parameter is set to `true` and the primary agent stops (for any reason), the cluster will attempt to confirm if the database on the primary node is running: + +- If the database is reached, a notification will be sent informing you of the agent status. +- If the database is not reached, a failover will occur. + +```text +# Treat a primary agent shutdown as an agent failure. This can be set +# to true to treat a primary agent shutdown as a failure situation, +# e.g. during the shutdown of a node, accidental or otherwise. +# Caution should be used when using this feature, as it could +# cause an unwanted promotion in the case of performing primary +# database maintenance. +# Please see the user's guide for more information. +primary.shutdown.as.failure=false +``` + +The `primary.shutdown.as.failure` property is meant to catch user error, rather than failures, such as the accidental shutdown of a primary node. The proper shutdown of a node can appear to the rest of the cluster like a user has stopped the primary Failover Manager agent (for example to perform maintenance on the primary database). If you set the `primary.shutdown.as.failure` property to `true`, care must be taken when performing maintenance. + +To perform maintenance on the primary database when `primary.shutdown.as.failure` is `true`, you should stop the primary agent and wait to receive a notification that the primary agent has failed but the database is still running. Then it is safe to stop the primary database. Alternatively, you can use the `efm stop-cluster` command to stop all of the agents without failure checks being performed. + + + +Use the `update.physical.slots.period` property to define the slot advance frequency for database version 12 and above. When `update.physical.slots.period` is set to a non-zero value, the primary agent will read the current `restart_lsn` of the physical replication slots after every `update.physical.slots.period` seconds, and send this information with its `pg_current_wal_lsn` and `primary_slot_name` (If it is set in the postgresql.conf file) to the standbys. If physical slots do not already exist, setting this parameter to a non-zero value will create the slots and then update the `restart_lsn parameter` for these slots. A non-promotable standby will not create new slots but will update them if they exist. + +```text +# Period in seconds between having the primary agent update promotable +# standbys with physical replication slot information so that +# the cluster will continue to use replication slots after a failover. +# Set to zero to turn off. +update.physical.slots.period=0 +``` + + + +Use the `ping.server.ip` property to specify the IP address of a server that Failover Manager can use to confirm that network connectivity is not a problem. + +```text +# This is the address of a well-known server that EFM can ping +# in an effort to determine network reachability issues. It +# might be the IP address of a nameserver within your corporate +# firewall or another server that *should* always be reachable +# via a 'ping' command from each of the EFM nodes. +# +# There are many reasons why this node might not be considered +# reachable: firewalls might be blocking the request, ICMP might +# be filtered out, etc. +# +# Do not use the IP address of any node in the EFM cluster +# (primary, standby, or witness) because this ping server is meant +# to provide an additional layer of information should the EFM +# nodes lose sight of each other. +# +# The installation default is Google's DNS server. +ping.server.ip=8.8.8.8 +``` + + + +Use the `ping.server.command` property to specify the command used to test network connectivity. + +```text +# This command will be used to test the reachability of certain +# nodes. +# +# Do not include an IP address or hostname on the end of +# this command - it will be added dynamically at runtime with the +# values contained in 'virtual.ip' and 'ping.server.ip'. +# +# Make sure this command returns reasonably quickly - test it +# from a shell command line first to make sure it works properly. +ping.server.command=/bin/ping -q -c3 -w5 +``` + + + +Use the `auto.allow.hosts` property to instruct the server to use the addresses specified in the .nodes file of the first node started to update the allowed host list. Enabling this property (setting `auto.allow.hosts` to true) can simplify cluster start-up. + +```text +# Have the first node started automatically add the addresses +# from its .nodes file to the allowed host list. This will make +# it faster to start the cluster when the initial set of hosts +# is already known. +auto.allow.hosts=false +``` + + + +Use the `stable.nodes.file` property to instruct the server to not rewrite the nodes file when a node joins or leaves the cluster. This property is most useful in clusters with unchanging IP addresses. + +```text +# When set to true, EFM will not rewrite the .nodes file whenever +# new nodes join or leave the cluster. This can help starting a +# cluster in the cases where it is expected for member addresses +# to be mostly static, and combined with 'auto.allow.hosts' makes +# startup easier when learning failover manager. +stable.nodes.file=false +``` + + + +The `db.reuse.connection.count` property allows the administrator to specify the number of times Failover Manager reuses the same database connection to check the database health. The default value is 0, indicating that Failover Manager will create a fresh connection each time. This property is not required on a dedicated witness node. + +```text +# This property controls how many times a database connection is +# reused before creating a new one. If set to zero, a new +# connection will be created every time an agent pings its local +# database. +db.reuse.connection.count=0 +``` + + + +The `auto.failover` property enables automatic failover. By default, auto.failover is set to true. + +```text +# Whether or not failover will happen automatically when the primary +# fails. Set to false if you want to receive the failover notifications +# but not have EFM actually perform the failover steps. +# The value of this property must be the same across all agents. +auto.failover=true +``` + + + +Use the `auto.reconfigure` property to instruct Failover Manager to enable or disable automatic reconfiguration of remaining Standby servers after the primary standby is promoted to Primary. Set the property to `true` to enable automatic reconfiguration (the default) or `false` to disable automatic reconfiguration. This property is not required on a dedicated witness node. If you are using Advanced Server or PostgreSQL version 11 or earlier, the `recovery.conf` file will be backed up during the reconfiguration process. + +```text +# After a standby is promoted, Failover Manager will attempt to +# update the remaining standbys to use the new primary. For database +# versions before 12, Failover Manager will back up recovery.conf. +# Then it will change the host parameter of the primary_conninfo entry +# in recovery.conf or postgresql.auto.conf, and restart the database. +# The restart command is contained in either the efm_db_functions or +# efm_root_functions file; default when not running db as an os +# service is: "pg_ctl restart -m fast -w -t -D " +# where the timeout is the local.timeout property value and the +# directory is specified by db.data.dir. To turn off +# automatic reconfiguration, set this property to false. +auto.reconfigure=true +``` + +!!! Note + `primary_conninfo` is a space-delimited list of keyword=value pairs. + + + +Use the `promotable` property to indicate that a node should not be promoted. The `promotable` property is ignored when a primary agent is started. This simplifies switching back to the original primary after a switchover or failover. To override the setting, use the efm set-priority command at runtime; for more information about the efm set-priority command, see [Using the efm Utility](../../07_using_efm_utility/#using_efm_utility). + +```text +# A standby with this set to false will not be added to the +# failover priority list, and so will not be available for +# promotion. The property will be used whenever an agent starts +# as a standby or resumes as a standby after being idle. After +# startup/resume, the node can still be added or removed from the +# priority list with the 'efm set-priority' command. This +# property is required for all non-witness nodes. +promotable=true +``` + + + +If the same amount of data has been written to more than one standby node, and a failover occurs, the `use.replay.tiebreaker` value will determine how Failover Manager selects a replacement primary. Set the `use.replay.tiebreaker` property to `true` to instruct Failover Manager to failover to the node that will come out of recovery faster, as determined by the log sequence number. To ignore the log sequence number and promote a node based on user preference, set `use.replay.tiebreaker` to `false`. + +```text +# Use replay LSN value for tiebreaker when choosing a standby to +# promote before using failover priority. Set this property to true to +# consider replay location as more important than failover priority +# (as seen in cluster-status command) when choosing the "most ahead" +# standby to promote. +use.replay.tiebreaker=true +``` + + + +Use the `standby.restart.delay` property to specify the time in seconds that the standby should wait before it gets reconfigured (stopped/started) to follow the new primary after a promotion. + +```text +# Time in seconds for this standby to delay restarting to follow the +# primary after a promotion. This can be used to have standbys restart +# at different times to increase availability. Caution should be used +# when using this feature, as a delayed standby will not be following +# the new primary and care must be taken that the new primary retains +# enough WAL for the standby to follow it. +# Please see the user's guide for more information. +standby.restart.delay=0 +``` + + + +You can use the `application.name` property to provide the name of an application that will be copied to the `primary_conninfo` parameter before restarting an old primary node as a standby. + +```text +# During a switchover, recovery settings are copied from a standby +# to the original primary. If the application.name property is set, +# Failover Manager will replace the application_name portion of the +# primary_conninfo entry with this property value before starting +# the original primary database as a standby. If this property is +# not set, Failover Manager will remove the parameter value +# from primary_conninfo. +application.name= +``` + +!!! Note + You should set the `application.name` property on the primary and any promotable standby; in the event of a failover/switchover, the primary node could potentially become a standby node again. + + + +Use the `restore.command` property to instruct Failover Manager to update the `restore_command` when a new primary is promoted. `%h` represents the address of the new primary; Failover Manager will replace `%h` with the address of the new primary. `%f` and `%p` are placeholders used by the server. If the property is left blank, Failover Manager will not update the `restore_command` values on the standbys after a promotion. + +See the PostgreSQL documentation for more information about using a [restore_command](https://www.postgresql.org/docs/current/runtime-config-wal.html#RUNTIME-CONFIG-WAL-ARCHIVE-RECOVERY). + +```text +# If the restore_command on a standby restores directly from the +# primary node, use this property to have Failover Manager change +# the command when a new primary is promoted. +# +# Use the %h placeholder to represent the address of the new primary. +# During promotion it will be replaced with the address of the new +# primary. +# +# If not specified, failover manager will not change the +# restore_command value, if any, on standby nodes. +# +# Example: +# restore.command=scp @%h:/var/lib/edb/as12/data/archive/%f %p +restore.command= +``` + + + +The database parameter `synchronous_standby_names` on the primary node specifies the names and count of the synchronous standby servers that will confirm receipt of data, to ensure that the primary nodes can accept write transactions. When `reconfigure.num.sync` property is set to true, Failover Manager will reduce the number of synchronous standby servers and reload the configuration of the primary node to reflect the current value. + +```text +# Reduce num_sync when the number of synchronous standbys drops below +# the value required by the primary database. If set to true, Failover +# Manager will reduce the number of standbys needed in the primary's +# synchronous_standby_names property and reload the primary +# configuration. Failover Manager will not reduce the number below 1, +# taking the primary out of synchronous replication, unless the +# reconfigure.sync.primary property is also set to true. +# To raise num_sync, see the reconfigure.num.sync.max property below. +reconfigure.num.sync=false +``` + + + +Use the `reconfigure.num.sync.max` property to specify the maximum number to which num-sync can be raised when a standby is added to the cluster. + +```text +# If reconfigure.num.sync is set to true and this property is set, +# Failover Manager will check if num_sync can be raised when a standby +# is added to the cluster. +# Failover Manager will not raise the value above the maximum set here. +# If the primary database has been taken out of synchronous mode +# completely (see the reconfigure.sync.primary property), then Failover +# Manager will not reconfigure the primary database if standbys are +# added to the cluster. +reconfigure.num.sync.max= +``` + + + +Set the `reconfigure.sync.primary` property to `true` to take the primary database out of synchronous replication mode if the number of standby nodes drops below the level required. Set `reconfigure.sync.primary` to `false` to send a notification if the standby count drops, but not interrupt synchronous replication. + +```text +# Take the primary database out of synchronous replication mode when +# needed. If set to true, Failover Manager will clear the +# synchronous_standby_names configuration parameter on the primary +# if the number of synchronous standbys drops below the required +# level for the primary to accept writes. +# If set to false, Failover Manager will detect the situation but +# will only send a notification if the standby count drops below the +# required level. +# +# CAUTION: TAKING THE PRIMARY DATABASE OUT OF SYNCHRONOUS MODE MEANS +# THERE MAY ONLY BE ONE COPY OF DATA. DO NOT MAKE THIS CHANGE UNLESS +# YOU ARE SURE THIS IS OK. +reconfigure.sync.primary=false +``` + + + +Use the `minimum.standbys` property to specify the minimum number of standby nodes that will be retained on a cluster; if the standby count drops to the specified minimum, a replica node will not be promoted in the event of a failure of the primary node. + +```text +# Instead of setting specific standbys as being unavailable for +# promotion, this property can be used to set a minimum number +# of standbys that will not be promoted. Set to one, for +# example, promotion will not happen if it will drop the number +# of standbys below this value. This property must be the same on +# each node. +minimum.standbys=0 +``` + + + +Use the `recovery.check.period` property to specify the number of seconds that Failover Manager will wait before checks to see if a database is out of recovery. + +```text +# Time in seconds between checks to see if a promoting database +# is out of recovery. +recovery.check.period=1 +``` + + + +Use the `restart.connection.timeout` property to specify the number of seconds that Failover Manager will attempt to connect to a newly reconfigured primary or standby node while the database on that node prepares to accept connections. + +```text +# Time in seconds to keep trying to connect to a database after a +# start or restart command returns successfully but the database +# is not ready to accept connections yet (a rare occurance). This +# applies to standby databases that are restarted when being +# reconfigured for a new primary, and to primary databases that +# are stopped and started as standbys during a switchover. +# This retry mechanism is unrelated to the auto.resume.period +# parameter. +restart.connection.timeout=60 +``` + + + +Use the `auto.resume.period` property to specify the number of seconds (after a monitored database fails and an agent has assumed an idle state, or when starting in IDLE mode) during which an agent will attempt to resume monitoring that database. + +```text +# Period in seconds for IDLE agents to try to resume monitoring +# after a database failure or when starting in IDLE mode. Set to +# 0 for agents to not try to resume (in which case the +# 'efm resume ' command is used after bringing a +# database back up). +auto.resume.period=0 +``` + + + +Failover Manager provides support for clusters that use a virtual IP. If your cluster uses a virtual IP, provide the host name or IP address in the `virtual.ip` property; specify the corresponding prefix in the `virtual.ip.prefix` property. If `virtual.ip` is left blank, virtual IP support is disabled. + +Use the `virtual.ip.interface` property to provide the network interface used by the VIP. + +The specified virtual IP address is assigned only to the primary node of the cluster. If you specify `virtual.ip.single=true`, the same VIP address will be used on the new primary in the event of a failover. Specify a value of false to provide a unique IP address for each node of the cluster. + +For information about using a virtual IP address, see [Using Failover Manager with Virtual IP Addresses](../05_using_vip_addresses/#using_vip_addresses). + +```text +# These properties specify the IP and prefix length that will be +# remapped during failover. If you do not use a VIP as part of +# your failover solution, leave the virtual.ip property blank to +# disable Failover Manager support for VIP processing (assigning, +# releasing, testing reachability, etc). +# +# If you specify a VIP, the interface and prefix are required. +# +# If you specify a host name, it will be resolved to an IP address +# when acquiring or releasing the VIP. If the host name resolves +# to more than one IP address, there is no way to predict which +# address Failover Manager will use. +# +# By default, the virtual.ip and virtual.ip.prefix values must be +# the same across all agents. If you set virtual.ip.single to +# false, you can specify unique values for virtual.ip and +# virtual.ip.prefix on each node. +# +# If you are using an IPv4 address, the virtual.ip.interface value +# should not contain a secondary virtual ip id (do not include +# ":1", etc). +virtual.ip= +virtual.ip.interface= +virtual.ip.prefix= +virtual.ip.single=true +``` + +!!! Note + If a primary agent is started and the node does not currently have the VIP, the EFM agent will acquire it. Stopping a primary agent does not drop the VIP from the node. + + + +Set the `check.vip.before.promotion` property to false to indicate that Failover Manager will not check to see if a VIP is in use before assigning it to a a new primary in the event of a failure. Note that this could result in multiple nodes broadcasting on the same VIP address; unless the primary node is isolated or can be shut down via another process, you should set this property to true. + +```text +# Whether to check if the VIP (when used) is still in use before +# promoting after a primary failure. Turning this off may allow +# the new primary to have the VIP even though another node is also +# broadcasting it. This should only be used in environments where +# it is known that the failed primary node will be isolated or +# shut down through other means. +check.vip.before.promotion=true +``` + + + +Use the `pgpool.enable` property to specify if you want to enable the Failover Manager and Pgpool integration for high availability. You must have sudo access to enable the Pgpool integration. + +```text +# A boolean property to enable Failover Manager managed Pgpool HA. +# If enabled, Failover Manager would natively update the joining +# and leaving status of database nodes to active pgpool instance. +# Failover manager expects properly configured and running pgpool +# instances on required nodes. It does not manage setup and +# configuration of pgpool on any node. +# +# By default the property is disabled. +pgpool.enable=false +``` + +Use the following parameters to specify the values that should be used for Pgpool integration. + +```text +# Configurations required for pgpool integration. +# 'pcp.user' - User that would be invoking PCP commands +# 'pcp.host' - Virtual IP that would be used by pgpool. Same as +# pgpool parameter 'delegate_IP' +# 'pcp.port' - The port on which pgpool listens for pcp commands. +# 'pcp.pass.file' - Absolute path of PCPPASSFILE. +# 'pgpool.bin' - Absolute path of pgpool bin directory + +# These properties are required if 'pgpool.enable' is set to true. +pcp.user= +pcp.host= +pcp.port= +pcp.pass.file= +pgpool.bin= +``` + + + +Use the following properties to provide paths to scripts that reconfigure your load balancer in the event of a switchover or primary failure scenario. The scripts will also be invoked in the event of a standby failure. If you are using these properties, they should be provided on every node of the cluster (primary, standby, and witness) to ensure that if a database node fails, another node will call the detach script with the failed node's address. + +You do not need to set the below properties if you are using Pgpool as Load Balancer solution and have set the Pgpool integration properties. + +Provide a script name after the `script.load.balancer.attach` property to identify a script that will be invoked when a node should be attached to the load balancer. Use the `script.load.balancer.detach` property to specify the name of a script that will be invoked when a node should be detached from the load balancer. Include the `%h` placeholder to represent the IP address of the node that is being attached or removed from the cluster. Include the `%t` placeholder to instruct Failover Manager to include an p (for a primary node) or an s (for a standby node) in the string. + +```text +# Absolute path to load balancer scripts +# The attach script is called when a node should be attached to +# the load balancer, for example after a promotion. The detach +# script is called when a node should be removed, for example +# when a database has failed or is about to be stopped. Use %h to +# represent the IP/hostname of the node that is being +# attached/detached. Use %t to represent the type of node being +# attached or detached: the letter m will be passed in for primary nodes +#and the letter s for standby nodes. +# +# Example: +# script.load.balancer.attach=/somepath/attachscript %h %t +script.load.balancer.attach= +script.load.balancer.detach= +``` + + + +`script.fence` specifies the path to an optional user-supplied script that will be invoked during the promotion of a standby node to primary node. + +```text +# absolute path to fencing script run during promotion +# +# This is an optional user-supplied script that will be run +# during failover on the standby database node. If left blank, +# no action will be taken. If specified, EFM will execute this +# script before promoting the standby. +# +# Parameters can be passed into this script for the failed primary +# and new primary node addresses. Use %p for new primary and %f +# for failed primary. On a node that has just been promoted, %p +# should be the same as the node's efm binding address. +# +# Example: +# script.fence=/somepath/myscript %p %f +# +# NOTE: FAILOVER WILL NOT OCCUR IF THIS SCRIPT RETURNS A NON-ZERO EXIT +# CODE. +script.fence= +``` + +
+ +Use the `script.post.promotion` property to specify the path to an optional user-supplied script that will be invoked after a standby node has been promoted to primary. + +```text +# Absolute path to fencing script run after promotion +# +# This is an optional user-supplied script that will be run after +# failover on the standby node after it has been promoted and +# is no longer in recovery. The exit code from this script has +# no effect on failover manager, but will be included in a +# notification sent after the script executes. +# +# Parameters can be passed into this script for the failed primary +# and new primary node addresses. Use %p for new primary and %f +# for failed primary. On a node that has just been promoted, %p +# should be the same as the node's efm binding address. +# +# Example: +# script.post.promotion=/somepath/myscript %f %p +script.post.promotion= +``` + + + +Use the `script.resumed property` to specify an optional path to a user-supplied script that will be invoked when an agent resumes monitoring of a database. + +```text +# Absolute path to resume script +# +# This script is run before an IDLE agent resumes +# monitoring its local database. +script.resumed= +``` + + + +Use the `script.db.failure` property to specify the complete path to an optional user-supplied script that Failover Manager will invoke if an agent detects that the database that it monitors has failed. + +```text +# Absolute path to script run after database failure +# This is an optional user-supplied script that will be run after +# an agent detects that its local database has failed. +script.db.failure= +``` + + + +Use the `script.primary.isolated` property to specify the complete path to an optional user-supplied script that Failover Manager will invoke if the agent monitoring the primary database detects that the primary is isolated from the majority of the Failover Manager cluster. This script is called immediately after the VIP is released (if a VIP is in use). + +```text +# Absolute path to script run on isolated primary +# This is an optional user-supplied script that will be run after +# a primary agent detects that it has been isolated from the +# majority of the efm cluster. +script.primary.isolated= +``` + + + +Use the `script.remote.pre.promotion` property to specify the path and name of a script that will be invoked on any agent nodes not involved in the promotion when a node is about to promote its database to primary. + +Include the %p placeholder to identify the address of the new primary node. + +```text +# Absolute path to script invoked on non-promoting agent nodes +# before a promotion. +# +# This optional user-supplied script will be invoked on other +# agents when a node is about to promote its database. The exit +# code from this script has no effect on Failover Manager, but +# will be included in a notification sent after the script +# executes. +# +# Pass a parameter (%p) with the script to identify the new +# primary node address. +# +# Example: +# script.remote.pre.promotion=/path_name/script_name %p +script.remote.pre.promotion= +``` + +
+ +Use the `script.remote.post.promotion` property to specify the path and name of a script that will be invoked on any non-primary nodes after a promotion occurs. + +Include the %p placeholder to identify the address of the new primary node. + +```text +# Absolute path to script invoked on non-primary agent nodes +# after a promotion. +# +# This optional user-supplied script will be invoked on nodes +# (except the new primary) after a promotion occurs. The exit code +# from this script has no effect on Failover Manager, but will be +# included in a notification sent after the script executes. +# +# Pass a parameter (%p) with the script to identify the new +# primary node address. +# +# Example: +# script.remote.post.promotion=/path_name/script_name %p +script.remote.post.promotion= +``` + + + +Use the `script.custom.monitor` property to provide the name and location of an optional script that will be invoked on regular intervals (specified in seconds by the `custom.monitor.interval` property). + +Use `custom.monitor.timeout` to specify the maximum time that the script will be allowed to run; if script execution does not complete within the time specified, Failover Manager will send a notification. + +Set `custom.monitor.safe.mode` to `true` to instruct Failover Manager to report non-zero exit codes from the script, but not promote a standby as a result of an exit code. + +```text +# Absolute path to a custom monitoring script. +# +# Use script.custom.monitor to specify the location and name of +# an optional user-supplied script that will be invoked +# periodically to perform custom monitoring tasks. A non-zero +# exit value means that a check has failed; this will be treated +# as a database failure. On a primary node, script failure will +# cause a promotion. On a standby node script failure will +# generate a notification and the agent will become IDLE. +# +# The custom.monitor.\* properties are required if a custom +# monitoring script is specified: +# +# custom.monitor.interval is the time in seconds between executions +# of the script. +# +# custom.monitor.timeout is a timeout value in seconds for how +# long the script will be allowed to run. If script execution +# exceeds the specified time, the task will be stopped and a +# notification sent. Subsequent runs will continue. +# +# If custom.monitor.safe.mode is set to true, non-zero exit codes +# from the script will be reported but will not cause a promotion +# or be treated as a database failure. This allows testing of the +# script without affecting EFM. +# +script.custom.monitor= +custom.monitor.interval= +custom.monitor.timeout= +custom.monitor.safe.mode= +``` + + + +Use the `sudo.command` property to specify a command that will be invoked by Failover Manager when performing tasks that require extended permissions. Use this option to include command options that might be specific to your system authentication. + +Use the `sudo.user.command` property to specify a command that will be invoked by Failover Manager when executing commands that will be performed by the database owner. + +```text +# Command to use in place of 'sudo' if desired when efm runs +# the efm_db_functions or efm_root_functions, or efm_address +# scripts. +# Sudo is used in the following ways by efm: +# +# sudo /usr/edb/efm-/bin/efm_address +# sudo /usr/edb/efm-/bin/efm_root_functions +# sudo -u /usr/edb/efm-/bin/efm_db_functions +# +# 'sudo' in the first two examples will be replaced by the value +# of the sudo.command property. 'sudo -u ' will +# be replaced by the value of the sudo.user.command property. +# The '%u' field will be replaced with the db owner. +sudo.command=sudo +sudo.user.command=sudo -u %u +``` + + + +Use the `lock.dir` property to specify an alternate location for the Failover Manager lock file; the file prevents Failover Manager from starting multiple (potentially orphaned) agents for a single cluster on the node. + +```text +# Specify the directory of lock file on the node. Failover +# Manager creates a file named .lock at this location to +# avoid starting multiple agents for same cluster. If the path +# does not exist, Failover Manager will attempt to create it. If +# not specified defaults to '/var/lock/efm-' +lock.dir= +``` + + + +Use the `log.dir` property to specify the location to which agent log files will be written; Failover Manager will attempt to create the directory if the directory does not exist. + +```text +# Specify the directory of agent logs on the node. If the path +# does not exist, Failover Manager will attempt to create it. If +# not specified defaults to '/var/log/efm-'. (To store +# Failover Manager startup logs in a custom location, modify the +# path in the service script to point to an existing, writable +# directory.) +# If using a custom log directory, you must configure +# logrotate separately. Use 'man logrotate' for more information. +log.dir= +``` + + + +After enabling the UDP or TCP protocol on a Failover Manager host, you can enable logging to syslog. Use the `syslog.protocol` parameter to specify the protocol type (UDP or TCP) and the `syslog.port` parameter to specify the listener port of the syslog host. The `syslog.facility` value may be used as an identifier for the process that created the entry; the value must be between LOCAL0 and LOCAL7. + +```text +# Syslog information. The syslog service must be listening on +# the port for the given protocol, which can be UDP or TCP. +# The facilities supported are LOCAL0 through LOCAL7. +syslog.host=localhost +syslog.port=514 +syslog.protocol=UDP +syslog.facility=LOCAL1 +``` + + + +Use the `file.log.enabled` and `syslog.enabled` properties to specify the type of logging that you wish to implement. Set `file.log.enabled` to `true` to enable logging to a file; enable the UDP protocol or TCP protocol and set `syslog.enabled` to `true` to enable logging to syslog. You can enable logging to both a file and syslog. + +```text +# Which logging is enabled. +file.log.enabled=true +syslog.enabled=false +``` + +For more information about configuring syslog logging, see [Enabling syslog Log File Entries](../../09_controlling_logging/#enabling_syslog). + + + +Use the `jgroups.loglevel` and `efm.loglevel` parameters to specify the level of detail logged by Failover Manager. The default value is INFO. For more information about logging, see [Controlling Logging](../../09_controlling_logging/#controlling_logging). + +```text +# Logging levels for JGroups and EFM. +# Valid values are: TRACE, DEBUG, INFO, WARN, ERROR +# Default value: INFO +# It is not necessary to increase these values unless debugging a +# specific issue. If nodes are not discovering each other at +# startup, increasing the jgroups level to DEBUG will show +# information about the TCP connection attempts that may help +# diagnose the connection failures. +jgroups.loglevel=INFO +efm.loglevel=INFO +``` + + + +Use the `jvm.options` property to pass JVM-related configuration information. The default setting specifies the amount of memory that the Failover Manager agent will be allowed to use. + +```text +# Extra information that will be passed to the JVM when starting +# the agent. +jvm.options=-Xmx128m +``` + +
+ +encrypting_database_password + +
diff --git a/product_docs/docs/efm/4.1/efm_user/04_configuring_efm/02_encrypting_database_password.mdx b/product_docs/docs/efm/4.1/efm_user/04_configuring_efm/02_encrypting_database_password.mdx new file mode 100644 index 00000000000..25926e23c36 --- /dev/null +++ b/product_docs/docs/efm/4.1/efm_user/04_configuring_efm/02_encrypting_database_password.mdx @@ -0,0 +1,81 @@ +--- +title: "Encrypting Your Database Password" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.1/encrypting_database_password.html" +--- + + + +Failover Manager requires you to encrypt your database password before including it in the cluster properties file. Use the [efm utility](../07_using_efm_utility/#efm_encrypt) (located in the `/usr/edb/efm-4.1/bin` directory) to encrypt the password. When encrypting a password, you can either pass the password on the command line when you invoke the utility, or use the `EFMPASS` environment variable. + +To encrypt a password, use the command: + +```text +# efm encrypt [ --from-env ] +``` + +Where `` specifies the name of the Failover Manager cluster. + +If you include the `--from-env` option, you must export the value you wish to encrypt before invoking the encryption utility. For example: + +```text +export EFMPASS=password +``` + +If you do not include the `--from-env` option, Failover Manager will prompt you to enter the database password twice before generating an encrypted password for you to place in your cluster property file. When the utility shares the encrypted password, copy and paste the encrypted password into the cluster property files. + +!!! Note + Many Java vendors ship their version of Java with full-strength encryption included, but not enabled due to export restrictions. If you encounter an error that refers to an illegal key size when attempting to encrypt the database password, you should download and enable a Java Cryptography Extension (JCE) that provides an unlimited policy for your platform. + +The following example demonstrates using the encrypt utility to encrypt a password for the `acctg` cluster: + +```text +# efm encrypt acctg +This utility will generate an encrypted password for you to place in + your EFM cluster property file: +/etc/edb/efm-4.1/acctg.properties +Please enter the password and hit enter: +Please enter the password again to confirm: +The encrypted password is: 516b36fb8031da17cfbc010f7d09359c +Please paste this into your acctg.properties file +db.password.encrypted=516b36fb8031da17cfbc010f7d09359c +``` + +!!! Note + The utility will notify you if a properties file does not exist. + +After receiving your encrypted password, paste the password into the properties file and start the Failover Manager service. If there is a problem with the encrypted password, the Failover Manager service will not start: + +```text +[witness@localhost ~]# systemctl start edb-efm-4.1 +Job for edb-efm-4.1.service failed because the control process exited with error code. See "systemctl status edb-efm-4.1.service" and "journalctl -xe" for details. +``` + +If you receive this message when starting the Failover Manager service, please see the startup log (located in `/var/log/efm-4.1/startup-efm.log`) for more information. + +If you are using RHEL/CentOS 7.x or RHEL/CentOS 8.x, startup information is also available with the following command: + +```text +systemctl status edb-efm-4.1 +``` + +To prevent a cluster from inadvertently connecting to the database of another cluster, the cluster name is incorporated into the encrypted password. If you modify the cluster name, you will need to re-encrypt the database password and update the cluster properties file. + +**Using the EFMPASS Environment Variable** + +The following example demonstrates using the --from-env environment variable when encrypting a password. Before invoking the `efm encrypt` command, set the value of `EFMPASS` to the password (`1safepassword`): + +```text +# export EFMPASS=1safepassword +``` + +Then, invoke `efm encrypt`, specifying the `--from-env` option: + +```text +# efm encrypt acctg --from-env +# 7ceecd8965fa7a5c330eaa9e43696f83 +``` + +The encrypted password (`7ceecd8965fa7a5c330eaa9e43696f83`) is returned as a text value; when using a script, you can check the exit code of the command to confirm that the command succeeded. A successful execution returns `0`. diff --git a/product_docs/docs/efm/4.1/efm_user/04_configuring_efm/03_cluster_members.mdx b/product_docs/docs/efm/4.1/efm_user/04_configuring_efm/03_cluster_members.mdx new file mode 100644 index 00000000000..96319761065 --- /dev/null +++ b/product_docs/docs/efm/4.1/efm_user/04_configuring_efm/03_cluster_members.mdx @@ -0,0 +1,35 @@ +--- +title: "The Cluster Members File" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.1/cluster_members.html" +--- + + + +Each node in a Failover Manager cluster has a cluster members file (by default, named efm.nodes) that contains a list of the current Failover Manager cluster members. When an agent starts, it uses the file to locate other cluster members. The Failover Manager installer creates a file template for the cluster members file named `efm.nodes.in` in the `/etc/edb/efm-4.1` directory. + +After completing the Failover Manager installation, you must make a working copy of the template: + +```text +cp /etc/edb/efm-4.1/efm.nodes.in /etc/edb/efm-4.1/efm.nodes +``` + +After copying the template file, change the owner of the file to `efm`: + +```text +chown efm:efm efm.nodes +``` + +By default, Failover Manager expects the cluster members file to be named `efm.nodes`. If you name the cluster members file something other than `efm.nodes`, you must modify the Failover Manager service script to instruct Failover Manager to use the new name. + +The cluster members file on the first node started can be empty; this node will become the Membership Coordinator. On each subsequent node, the cluster member file must contain the address and port number of the Membership Coordinator. Each entry in the cluster members file must be listed in an address:port format, with multiple entries separated by white space. + +The agents will update the contents of the `efm.nodes` file to match the current members of the cluster. As agents join or leave the cluster, the `efm.nodes` files on other agents are updated to reflect the current cluster membership. If you invoke the [efm stop-cluster](../07_using_efm_utility/#efm_stop_cluster) command, Failover Manager does not modify the file. + +If the Membership Coordinator leaves the cluster, another node will assume the role. You can use the [efm cluster-status](../07_using_efm_utility/#efm_cluster_status) command to find the address of the Membership Coordinator. If a node joins or leaves a cluster while an agent is down, before starting that agent you must manually ensure that the file includes at least the current Membership Coordinator's address and port. + +If you know the addresses and ports of the nodes that will be joining the cluster, you can include the addresses in the cluster members file at any time. At startup, any addresses that do not identify cluster members will be ignored unless the `auto.allow.hosts` property (in the [cluster properties file](01_cluster_properties/#auto_allow_hosts)) is set to `true`. + +If the `stable.nodes.file` property (located in the [cluster properties file](01_cluster_properties/#auto_allow_hosts)) is set to `true`, the agent will not update the `.nodes` file when cluster members join or leave the cluster; this behavior is most useful when the IP addresses of cluster members do not change often. diff --git a/product_docs/docs/efm/4.1/efm_user/04_configuring_efm/04_extending_efm_permissions.mdx b/product_docs/docs/efm/4.1/efm_user/04_configuring_efm/04_extending_efm_permissions.mdx new file mode 100644 index 00000000000..71eb33b42e0 --- /dev/null +++ b/product_docs/docs/efm/4.1/efm_user/04_configuring_efm/04_extending_efm_permissions.mdx @@ -0,0 +1,116 @@ +--- +title: "Extending Failover Manager Permissions" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.1/extending_efm_permissions.html" +--- + + + +During the Failover Manager installation, the installer creates a user named `efm`. `efm` does not have sufficient privileges to perform management functions that are normally limited to the database owner or operating system superuser. + +- When performing management functions requiring database superuser privileges, `efm` invokes the `efm_db_functions` script. +- When performing management functions requiring operating system superuser privileges, `efm` invokes the `efm_root_functions` script. +- When assigning or releasing a virtual IP address, `efm` invokes the `efm_address` script. +- When enabling Pgpool integration, `efm` invokes the `efm_pgpool_functions` script. + +The `efm_db_functions` or `efm_root_functions` scripts perform management functions on behalf of the `efm` user. + +The sudoers file contains entries that allow the user `efm` to control the Failover Manager service for clusters owned by `postgres` or `enterprisedb`. You can modify a copy of the sudoers file to grant permission to manage Postgres clusters owned by other users to `efm`. + +The `efm-41` file is located in `/etc/sudoers.d`, and contains the following entries: + +```text +# Copyright EnterpriseDB Corporation, 2014-2020. All Rights Reserved. +# +# Do not edit this file. Changes to the file may be overwritten +# during an upgrade. +# +# This file assumes you are running your efm cluster as user 'efm'. If not, +# then you will need to copy this file. + +# Allow user 'efm' to sudo efm_db_functions as either 'postgres' or 'enterprisedb'. +# If you run your db service under a non-default account, you will need to copy +# this file to grant the proper permissions and specify the account in your efm +# cluster properties file by changing the 'db.service.owner' property. +efm ALL=(postgres) NOPASSWD: /usr/edb/efm-4.1/bin/efm_db_functions +efm ALL=(enterprisedb) NOPASSWD: /usr/edb/efm-4.1/bin/efm_db_functions + +# Allow user 'efm' to sudo efm_root_functions as 'root' to write/delete the PID file, +# validate the db.service.owner property, etc. +efm ALL=(ALL) NOPASSWD: /usr/edb/efm-4.1/bin/efm_root_functions + +# Allow user 'efm' to sudo efm_address as root for VIP tasks. +efm ALL=(ALL) NOPASSWD: /usr/edb/efm-4.1/bin/efm_address + +# Allow user 'efm' to sudo efm_pgpool_functions as root for pgpool tasks. +efm ALL=(ALL) NOPASSWD: /usr/edb/efm-4.1/bin/efm_pgpool_functions + +# relax tty requirement for user 'efm' +Defaults:efm !requiretty +``` + +If you are using Failover Manager to monitor clusters that are owned by users other than `postgres` or `enterprisedb`, make a copy of the `efm-41` file, and modify the content to allow the user to access the `efm_functions` script to manage their clusters. + +If an agent cannot start because of permission problems, make sure the default `/etc/sudoers` file contains the following line at the end of the file: + +```text +## Read drop-in files from /etc/sudoers.d (the # here does not # mean a comment) + +#includedir /etc/sudoers.d +``` + + + +## Running Failover Manager without sudo + +By default, Failover Manager uses sudo to securely manage access to system functionality. If you choose to configure Failover Manager to run without sudo access, Note that root access is still required to: + +- install the Failover Manager RPM. +- perform Failover Manager setup tasks. + +To run Failover Manager without sudo, you must select a database process owner that will have privileges to perform management functions on behalf of Failover Manager. The user could be the default database superuser (for example, enterprisedb or postgres) or another privileged user. After selecting the user: + +1. Use the following command to add the user to the `efm` group: + + ```text + usermod -a -G efm enterprisedb + ``` + + This should allow the user to write to `/var/run/efm-4.1` and `/var/lock/efm-4.1`. + +2. If you are reusing a cluster name, remove any previously created log files; the new user will not be able to write to log files created by the default (or other) owner. + +3. Copy the cluster properties template file and the nodes template file: + + ```text + su - enterprisedb + + cp /etc/edb/efm-4.1/efm.properties.in .properties + + cp /etc/edb/efm-4.1/efm.nodes.in /.nodes + ``` + +Then, modify the cluster properties file, providing the name of the user in the `db.service.owner` property. You must also ensure that the `db.service.name` property is blank; without sudo, you cannot run services without root access. + +After modifying the configuration, the new user can control Failover Manager with the following command: + +```text +/usr/edb/efm-4.1/bin/runefm.sh start|stop .properties +``` + +Where `` specifies the full path of the cluster properties file. Note that the user must ensure that the full path to the properties file must be provided whenever the non-default user is controlling agents or using the efm script. + +To allow the new user to manage Failover Manager as a service, you must provide a custom script or unit file. + +Failover Manager uses a binary named `manage-vip` that resides in `/usr/edb/efm-4.1/bin/secure/` to perform VIP management operations without sudo privileges. This script uses setuid to acquire with the privileges needed to manage Virtual IP addresses. + +- This directory is only accessible to root and users in the `efm` group. +- The binary is only executable by root and the `efm` group. + +For security reasons, we recommend against modifying the access privileges of the `/usr/edb/efm-4.1/bin/secure/` directory or the `manage-vip` script. + +For more information about using Failover Manager without sudo, visit: + + diff --git a/product_docs/docs/efm/4.1/efm_user/04_configuring_efm/05_using_vip_addresses.mdx b/product_docs/docs/efm/4.1/efm_user/04_configuring_efm/05_using_vip_addresses.mdx new file mode 100644 index 00000000000..f7aed65651f --- /dev/null +++ b/product_docs/docs/efm/4.1/efm_user/04_configuring_efm/05_using_vip_addresses.mdx @@ -0,0 +1,148 @@ +--- +title: "Using Failover Manager with Virtual IP Addresses" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.1/using_vip_addresses.html" +--- + + + +Failover Manager uses the `efm_address` script to assign or release a virtual IP address. + +!!! Note + Virtual IP addresses are not supported by many cloud providers. In those environments, another mechanism should be used (such as an Elastic IP Address on AWS), which can be changed when needed by a fencing or post-promotion script. + +By default, the script resides in: + + `/usr/edb/efm-4.1/bin/efm_address` + +Failover Manager uses the following command variations to assign or release an IPv4 or IPv6 IP address. + +To assign a virtual IPv4 IP address: + +```text +# efm_address add4 / +``` + +To assign a virtual IPv6 IP address: + +```text +# efm_address add6 / +``` + +To release a virtual address: + +```text +# efm_address del +``` + +Where: + + `` matches the name specified in the `virtual.ip.interface` property in the cluster properties file. + + `` or `` matches the value specified in the `virtual.ip` property in the cluster properties file. + + `prefix` matches the value specified in the `virtual.ip.prefix` property in the cluster properties file. + +For more information about properties that describe a virtual IP address, see [The Cluster Properties File](01_cluster_properties/#virtual_ip). + +You must invoke the `efm_address` script as the root user. The `efm` user is created during the installation, and is granted privileges in the sudoers file to run the `efm_address` script. For more information about the sudoers file, see [Extending Failover Manager Permissions](04_extending_efm_permissions/#extending_efm_permissions). + +!!! Note + If a VIP address (or any address other than the `bind.address`) is assigned to a node, the operating system can choose the source address used when contacting the database. Be sure that you modify the `pg_hba.conf` file on all monitored databases to allow contact from all addresses within your replication scenario. + +**Testing the VIP** + +When using a virtual IP (VIP) address with Failover Manager, it is important to test the VIP functionality manually before starting Failover manager. This will catch any network-related issues before they cause a problem during an actual failover. While testing the VIP, ensure that Failover Manager is not running. + +The following steps test the actions that Failover Manager will take. The example uses the following property values: + +```text +virtual.ip=172.24.38.239 +virtual.ip.interface=eth0 +virtual.ip.prefix=24 +ping.server.command=/bin/ping -q -c3 -w5 +``` + +!!! Note + The `virtual.ip.prefix` specifies the number of significant bits in the virtual Ip address. + +When instructed to ping the VIP from a node, use the command defined by the `ping.server.command` property. + +1. Ping the VIP from all nodes to confirm that the address is not already in use: + +```text +# /bin/ping -q -c3 -w5 172.24.38.239 +PING 172.24.38.239 (172.24.38.239) 56(84) bytes of data. +--- 172.24.38.239 ping statistics --- +4 packets transmitted, 0 received, +3 errors, 100% packet loss, + time 3000ms +``` + +You should see 100% packet loss. + +2. Run the `efm_address add4` command on the Primary node to assign the VIP and then confirm with ip address: + +```text +# efm_address add4 eth0 172.24.38.239/24 +# ip address + +eth0 Link encap:Ethernet HWaddr 36:AA:A4:F4:1C:40 +inet addr:172.24.38.239 Bcast:172.24.38.255 +... +``` + +3. Ping the VIP from the other nodes to verify that they can reach the VIP: + +```text +# /bin/ping -q -c3 -w5 172.24.38.239 +PING 172.24.38.239 (172.24.38.239) 56(84) bytes of data. +--- 172.24.38.239 ping statistics --- +3 packets transmitted, 3 received, 0% packet loss, time 1999ms +rtt min/avg/max/mdev = 0.023/0.025/0.029/0.006 ms +``` + +You should see no packet loss. + +4. Use the `efm_address del` command to release the address on the primary node and confirm the node has been released with ip address: + +```text +# efm_address del eth0 172.24.38.239/24 +# ip address +eth0 Link encap:Ethernet HWaddr 22:00:0A:89:02:8E +inet addr:10.137.2.142 Bcast:10.137.2.191 +... +``` + +The output from this step should not show an eth0 interface + +5. Repeat step 3, this time verifying that the Standby and Witness do not see the VIP in use: + +```text +# /bin/ping -q -c3 -w5 172.24.38.239 +PING 172.24.38.239 (172.24.38.239) 56(84) bytes of data. +--- 172.24.38.239 ping statistics --- +4 packets transmitted, 0 received, +3 errors, 100% packet loss, + time 3000ms +``` + +You should see 100% packet loss. Repeat this step on all nodes. + +6. Repeat step 2 on all Standby nodes to assign the VIP to every node. You can ping the VIP from any node to verify that it is in use. + +```text +# efm_address add4 eth0 172.24.38.239/24 +# ip address + +eth0 Link encap:Ethernet HWaddr 36:AA:A4:F4:1C:40 +inet addr:172.24.38.239 Bcast:172.24.38.255 +... +``` + +After the test steps above, release the VIP from any non-Primary node before attempting to start Failover Manager. + +!!! Note + The network interface used for the VIP does not have to be the same interface used for the Failover Manager agent's `bind.address` value. The primary agent will drop the VIP as needed during a failover, and Failover Manager will verify that the VIP is no longer available before promoting a standby. A failure of the bind address network will lead to primary isolation and failover. + +If the VIP uses a different interface, you may encounter a timing condition where the rest of the cluster checks for a reachable VIP before the primary agent has dropped it. In this case, EFM will retry the VIP check for the number of seconds specified in the `node.timeout` property to help ensure that a failover happens as expected. diff --git a/product_docs/docs/efm/4.1/efm_user/04_configuring_efm/index.mdx b/product_docs/docs/efm/4.1/efm_user/04_configuring_efm/index.mdx new file mode 100644 index 00000000000..cf98ce3702b --- /dev/null +++ b/product_docs/docs/efm/4.1/efm_user/04_configuring_efm/index.mdx @@ -0,0 +1,20 @@ +--- +title: "Configuring Failover Manager" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.1/configuring_efm.html" +--- + + + +Configurable Failover Manager properties are specified in two user-modifiable files: + +- [efm.properties](01_cluster_properties/#cluster_properties) +- [efm.nodes](03_cluster_members/#cluster_members) + +
+ +cluster_properties encrypting_database_password cluster_members extending_efm_permissions using_vip_addresses + +
diff --git a/product_docs/docs/efm/4.1/efm_user/05_using_efm.mdx b/product_docs/docs/efm/4.1/efm_user/05_using_efm.mdx new file mode 100644 index 00000000000..65af68937c9 --- /dev/null +++ b/product_docs/docs/efm/4.1/efm_user/05_using_efm.mdx @@ -0,0 +1,318 @@ +--- +title: "Using Failover Manager" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.1/using_efm.html" +--- + + + +Failover Manager offers support for monitoring and failover of clusters with one or more Standby servers. You can add or remove nodes from the cluster as your demand for resources grows or shrinks. + +If a primary node reboots, Failover Manager may detect the database is down on the Primary node and promote a Standby node to the role of Primary. If this happens, the Failover Manager agent on the (rebooted) Primary node will not get a chance to write the `recovery.conf` file; the rebooted Primary node will return to the cluster as a second Primary node. To prevent this, start the Failover Manager agent before starting the database server. The agent will start in idle mode, and check to see if there is already a primary in the cluster. If there is a primary node, the agent will verify that a `recovery.conf` or `standby.signal` file exists, and the database will not start as a second primary. + +## Managing a Failover Manager Cluster + +Once configured, a Failover Manager cluster requires no regular maintenance. The following sections provide information about performing the management tasks that may occasionally be required by a Failover Manager Cluster. + +By default, [some of the efm commands](07_using_efm_utility/#using_efm_utility) must be invoked by `efm` or an OS superuser; an administrator can selectively permit users to invoke these commands by adding the user to the `efm` group. The commands are: + +- [efm allow-node](07_using_efm_utility/#efm_allow_node) +- [efm disallow-node](07_using_efm_utility/#efm_disallow_node) +- [efm promote](07_using_efm_utility/#efm_promote) +- [efm resume](07_using_efm_utility/#efm_resume) +- [efm set-priority](07_using_efm_utility/#efm_set_priority) +- [efm stop-cluster](07_using_efm_utility/#efm_stop_cluster) +- [efm upgrade-conf](07_using_efm_utility/#efm_upgrade_conf) + + + +### Starting the Failover Manager Cluster + +You can start the nodes of a Failover Manager cluster in any order. + +To start the Failover Manager cluster on RHEL/CentOS 7.x or RHEL/CentOS 8.x, assume superuser privileges, and invoke the command: + +```text +systemctl start edb-efm-4.1 +``` + +If the cluster properties file for the node specifies that `is.witness` is `true`, the node will start as a Witness node. + +If the node is not a dedicated Witness node, Failover Manager will connect to the local database and invoke the `pg_is_in_recovery()` function. If the server responds `false`, the agent assumes the node is a Primary node, and assigns a virtual IP address to the node (if applicable). If the server responds `true`, the Failover Manager agent assumes that the node is a Standby server. If the server does not respond, the agent will start in an idle state. + +After joining the cluster, the Failover Manager agent checks the supplied database credentials to ensure that it can connect to all of the databases within the cluster. If the agent cannot connect, the agent will shut down. + +If a new primary or standby node joins a cluster, all of the existing nodes will also confirm that they can connect to the database on the new node. + + + +!!! Note + If you are running `/var/lock` or `/var/run` on `tmpfs` (Temporary File System), make sure that the systemd service file for Failover Manager has a dependency on `systemd-tmpfiles-setup.service`. + +### Adding Nodes to a Cluster + +You can add a node to a Failover Manager cluster at any time. When you add a node to a cluster, you must modify the cluster to allow the new node, and then tell the new node how to find the cluster. The following steps detail adding a node to a cluster: + +1. Unless `auto.allow.hosts` is set to `true`, use the `efm allow-node` command, to add the address of the new node to the Failover Manager allowed node host list. When invoking the command, specify the cluster name and the address of the new node: + + ```text + efm allow-node
+ ``` + + For more information about using the `efm allow-node` command or controlling a Failover Manager service, see [Using the EFM Utility](07_using_efm_utility/#efm_allow_node). + + Install a Failover Manager agent and configure the cluster properties file on the new node. For more information about modifying the properties file, see [The Cluster Properties File](04_configuring_efm/01_cluster_properties/#cluster_properties). + +2. Configure the cluster members file on the new node, adding an entry for the Membership Coordinator. For more information about modifying the cluster members file, see [The Cluster Members File](04_configuring_efm/03_cluster_members/#cluster_members). + +3. Assume superuser privileges on the new node, and start the Failover Manager agent. To start the Failover Manager cluster on RHEL/CentOS 7.x or RHEL/CentOS 8.x, invoke the command: + + ```text + systemctl start edb-efm-4.1 + ``` + +When the new node joins the cluster, Failover Manager will send a notification to the administrator email provided in the `user.email` property, and/or will invoke the specified notification script. + + + +!!! Note + To be a useful Standby for the current node, the node must be a standby in the PostgreSQL Streaming Replication scenario. + +### Changing the Priority of a Standby + +If your Failover Manager cluster includes more than one Standby server, you can use the `efm set-priority` command to influence the promotion priority of a Standby node. Invoke the command on any existing member of the Failover Manager cluster, and specify a priority value after the IP address of the member. + +For example, the following command instructs Failover Manager that the `acctg` cluster member that is monitoring `10.0.1.9` is the primary Standby `(1)`: + +```text +efm set-priority acctg 10.0.1.9 1 +``` + +You can set the priority of a standby to `0` to make the standby non-promotable. Setting the priority of a standby to a value greater than `0` overrides a property value of `promotable=false`. + +For example, if the properties file on node `10.0.1.10` includes a setting of `promotable=false` and you use `efm set-priority` to set the promotion priority of `10.0.1.10` to be the standby used in the event of a failover, the value designated by the `efm set-priority` command will override the value in the property file: + +```text +efm set-priority acctg 10.0.1.10 1 +``` + +In the event of a failover, Failover Manager will first retrieve information from Postgres streaming replication to confirm which Standby node has the most recent data, and promote the node with the least chance of data loss. If two Standby nodes contain equally up-to-date data, the node with a higher user-specified priority value will be promoted to Primary unless [use.replay.tiebreaker](04_configuring_efm/01_cluster_properties/#use_replay_tiebreaker) is set to `false` . To check the priority value of your Standby nodes, use the command: + +```text +efm cluster-status +``` + + + +!!! Note + The promotion priority may change if a node becomes isolated from the cluster, and later re-joins the cluster. + +### Promoting a Failover Manager Node + +You can invoke `efm promote` on any node of a Failover Manager cluster to start a manual promotion of a Standby database to Primary database. + +Manual promotion should only be performed during a maintenance window for your database cluster. If you do not have an up-to-date Standby database available, you will be prompted before continuing. To start a manual promotion, assume the identity of `efm` or the OS superuser, and invoke the command: + +```text +efm promote [-switchover] [-sourcenode
] [-quiet] [-noscripts]` +``` + +Where: + + `` is the name of the Failover Manager cluster. + + Include the `–switchover` option to reconfigure the original Primary as a Standby. If you include the `–switchover` keyword, the cluster must include a primary node and at least one standby, and the nodes must be in sync. + + Include the `–sourcenode` keyword to specify the node from which the recovery settings will be copied to the primary. + + Include the `-quiet` keyword to suppress notifications during switchover. + + Include the `-noscripts` keyword to prevent instruct Failover Manager to not invoke fencing and post-promotion scripts. + +During switchover: + +- For server versions 11 and prior, the `recovery.conf` file is copied from an existing standby to the primary node. For server version 12 and later, the `primary_conninfo` and `restore_command` parameters are copied and stored in memory. +- The primary database is stopped. +- If you are using a VIP, the address is released from the primary node. +- A standby is promoted to replace the primary node, and acquires the VIP. +- The address of the new primary node is added to the `recovery.conf` file or the `primary_conninfo` details are stored in memory. +- If the `application.name` property is set for this node, the application_name property will be added to the `recovery.conf` file or the `primary_conninfo` information will be stored in memory. +- If you are using server version 12 or later, the recovery settings that have been stored in memory are written to the `postgresql.auto.conf` file. A `standby.signal` file is created. +- The old primary is started; the agent will resume monitoring it as a standby. + +During a promotion, the Primary agent releases the virtual IP address. If it is not a switchover, a recovery.conf file is created in the directory specified by the db.data.dir property. The recovery.conf file is used to prevent the old primary database from starting until the file is removed, preventing the node from starting as a second primary in the cluster. If the promotion is part of a switchover, recovery settings are handled as described above. + +The Primary agent remains running, and assumes a status of Idle. + +The Standby agent confirms that the virtual IP address is no longer in use before pinging a well- known address to ensure that the agent is not isolated from the network. The Standby agent runs the fencing script and promotes the Standby database to Primary. The Standby agent then assigns the virtual IP address to the Standby node, and runs the post-promotion script (if applicable). + +Note that this command instructs the service to ignore the value specified in the `auto.failover` parameter in the cluster properties file. + +To return a node to the role of primary, place the node first in the promotion list: + +```text +efm set-priority
+``` + +Then, perform a manual promotion: + +```text +efm promote ‑switchover +``` + +For more information about the efm utility, see [Using the EFM Utility](07_using_efm_utility/#using_efm_utility). + + + +### Stopping a Failover Manager Agent + +When you stop an agent, Failover Manager will remove the node's address from the cluster members list on all of the running nodes of the cluster, but will not remove the address from the Failover Manager Allowed node host list. + +To stop the Failover Manager agent on RHEL/CentOS 7.x or RHEL/CentOS 8.x, assume superuser privileges, and invoke the command: + +```text +systemctl stop edb-efm-4.1 +``` + +Until you invoke the `efm disallow-node` command (removing the node's address of the node from the Allowed node host list), you can use the `service edb-efm-4.1 start` command to restart the node at a later date without first running the `efm allow-node` command again. + + +Note that stopping an agent does not signal the cluster that the agent has failed unless the [primary.shutdown.as.failure](04_configuring_efm/01_cluster_properties/#primary_shutdown_as_failure) property is set to `true`. + +### Stopping a Failover Manager Cluster + +To stop a Failover Manager cluster, connect to any node of a Failover Manager cluster, assume the identity of `efm` or the OS superuser, and invoke the command: + +```text +efm stop-cluster +``` + +The command will cause *all* Failover Manager agents to exit. Terminating the Failover Manager agents completely disables all failover functionality. + +!!! Note + When you invoke the `efm stop-cluster` command, all authorized node information is lost from the Allowed node host list. + +### Removing a Node from a Cluster + +The `efm disallow-node` command removes the IP address of a node from the Failover Manager Allowed Node host list. Assume the identity of `efm` or the OS superuser on any existing node (that is currently part of the running cluster), and invoke the `efm disallow-node` command, specifying the cluster name and the IP address of the node: + +```text +efm disallow-node
+``` + +The `efm disallow-node` command will not stop a running agent; the service will continue to run on the node until you [stop the agent](#stop_efm_agent). If the agent or cluster is subsequently stopped, the node will not be allowed to rejoin the cluster, and will be removed from the failover priority list (and will be ineligible for promotion). + +After invoking the `efm disallow-node` command, you must use the [efm allow-node](07_using_efm_utility/#efm_allow_node) command to add the node to the cluster again. + + + +## Running Multiple Agents on a Single Node + +You can monitor multiple database clusters that reside on the same host by running multiple Primary or Standby agents on that Failover Manager node. You may also run multiple Witness agents on a single node. To configure Failover Manager to monitor more than one database cluster, while ensuring that Failover Manager agents from different clusters do not interfere with each other, you must: + +1. Create a cluster properties file for each member of each cluster that defines a unique set of properties and the role of the node within the cluster. +2. Create a cluster members file for each member of each cluster that lists the members of the cluster. +3. Customize the unit file (on a RHEL/CentOS 7.x or RHEL/CentOS 8.x system) for each cluster to specify the names of the cluster properties and the cluster members files. +4. Start the services for each cluster. + +The examples that follow uses two database clusters (acctg and sales) running on the same node: + +- Data for `acctg` resides in `/opt/pgdata1`; its server is monitoring port `5444`. +- Data for `sales` resides in `/opt/pgdata2`; its server is monitoring port `5445`. + +To run a Failover Manager agent for both of these database clusters, use the `efm.properties.in` template to create two properties files. Each cluster properties file must have a unique name. For this example, we create `acctg.properties` and `sales.properties` to match the `acctg` and `sales` database clusters. + +The following parameters must be unique in each cluster properties file: + + `admin.port` + + `bind.address` + + `db.port` + + `db.data.dir` + + `virtual.ip` (if used) + + `virtual.ip.interface` (if used) + +Within each cluster properties file, the `db.port` parameter should specify a unique value for each cluster, while the `db.user` and `db.database` parameter may have the same value or a unique value. For example, the `acctg.properties` file may specify: + + `db.user=efm_user` + + `db.password.encrypted=7c801b32a05c0c5cb2ad4ffbda5e8f9a` + + `db.port=5444` + + `db.database=acctg_db` + +While the `sales.properties` file may specify: + + `db.user=efm_user` + + `db.password.encrypted=e003fea651a8b4a80fb248a22b36f334` + + `db.port=5445` + + `db.database=sales_db` + +Some parameters require special attention when setting up more than one Failover Manager cluster agent on the same node. If multiple agents reside on the same node, each port must be unique. Any two ports will work, but it may be easier to keep the information clear if using ports that are not too close to each other. + +When creating the cluster properties file for each cluster, the `db.data.dir` parameters must also specify values that are unique for each respective database cluster. + +The following parameters are used when assigning the virtual IP address to a node. If your Failover Manager cluster does not use a virtual IP address, leave these parameters blank. + + `virtual.ip` + + `virtual.ip.interface` + + `virtual.ip.prefix` + +This parameter value is determined by the virtual IP addresses being used and may or may not be the same for both `acctg.properties` and `sales.properties`. + +After creating the `acctg.properties` and `sales.properties` files, create a service script or unit file for each cluster that points to the respective property files; this step is platform specific. If you are using RHEL/CentOS 7.x or RHEL/CentOS 8.x, see [RHEL/CentOS 7.x or RHEL/CentOS 8.x](#rhelcentos-7x-or-rhelcentos-8x). + +!!! Note + If you are using a unit file, you must manually update the file to reflect the new service name when you upgrade Failover Manager. + +### RHEL/CentOS 7.x or RHEL/CentOS 8.x + +If you are using RHEL/CentOS 7.x or RHEL/CentOS 8.x, you should copy the `edb-efm-4.1` unit file to new file with a name that is unique for each cluster. For example, if you have two clusters (named acctg and sales), the unit file names might be: + +```text +/usr/lib/systemd/system/efm-acctg.service + +/usr/lib/systemd/system/efm-sales.service +``` + +Then, edit the `CLUSTER` variable within each unit file, changing the specified cluster name from `efm` to the new cluster name. For example, for a cluster named `acctg`, the value would specify: + +```text +Environment=CLUSTER=acctg +``` + +You must also update the value of the `PIDfile` parameter to specify the new cluster name. For example: + +```text +PIDFile=/var/run/efm-4.1/acctg.pid +``` + +After copying the service scripts, use the following commands to enable the services: + +```text +# systemctl enable efm-acctg.service + +# systemctl enable efm-sales.service +``` + +Then, use the new service scripts to start the agents. For example, you can start the `acctg` agent with the command: + +```text +# systemctl start efm-acctg` +``` + +For information about customizing a unit file, please visit: + + diff --git a/product_docs/docs/efm/4.1/efm_user/06_monitoring_efm_cluster.mdx b/product_docs/docs/efm/4.1/efm_user/06_monitoring_efm_cluster.mdx new file mode 100644 index 00000000000..82aef759984 --- /dev/null +++ b/product_docs/docs/efm/4.1/efm_user/06_monitoring_efm_cluster.mdx @@ -0,0 +1,142 @@ +--- +title: "Monitoring a Failover Manager Cluster" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.1/monitoring_efm_cluster.html" +--- + + + +You can use either the Failover Manager `efm cluster-status` command or the PEM Client graphical interface to check the current status of a monitored node of a Failover Manager cluster. + +## Reviewing the Cluster Status Report + +The efm cluster-status [cluster properties file](07_using_efm_utility/#efm_cluster_status) command returns a report that contains information about the status of the Failover Manager cluster. To invoke the command, enter: + +```text +# efm cluster-status +``` + +The following status report is for a cluster named edb that has three nodes running: + +```text +Agent Type Address Agent DB VIP +----------------------------------------------------------------------- +Standby 172.19.10.2 UP UP 192.168.225.190 +Standby 172.19.12.163 UP UP 192.168.225.190 +Primary 172.19.14.9 UP UP 192.168.225.190* + + +Allowed node host list: +172.19.14.9 172.19.12.163 172.19.10.2 + + +Membership coordinator: 172.19.14.9 + + +Standby priority host list: +172.19.12.163 172.19.10.2 + +Promote Status: + +DB Type Address WAL Received LSN WAL Replayed LSN Info +-------------------------------------------------------------------- +Primary 172.19.14.9 0/4000638 +Standby 172.19.12.163 0/4000638 0/4000638 +Standby 172.19.10.2 0/4000638 0/4000638 + + +Standby database(s) in sync with primary. It is safe to promote. +``` + +The cluster status section provides an overview of the status of the agents that reside on each node of the cluster: + +```text +Agent Type Address Agent DB VIP +----------------------------------------------------------------------- +Standby 172.19.10.2 UP UP 192.168.225.190 +Standby 172.19.12.163 UP UP 192.168.225.190 +Primary 172.19.14.9 UP UP 192.168.225.190* +``` + +The asterisk (\*) after the VIP address indicates that the address is available for connections. If a VIP address is not followed by an asterisk, the address has been associated with the node (in the properties file), but the address is not currently in use. + +Failover Manager agents provide the information displayed in the Cluster Status section. + +The `Allowed node host list` and `Standby priority host list` provide an easy way to tell which nodes are allowed to join the cluster, and the promotion order of the nodes. The IP address of the Membership coordinator is also displayed in the report: + +```text +Allowed node host list: +172.19.14.9 172.19.12.163 172.19.10.2 +Membership coordinator: 172.19.14.9 +Standby priority host list: +172.19.12.163 172.19.10.2 +``` + +The `Promote Status` section of the report is the result of a direct query from the node on which you are invoking the cluster-status command to each database in the cluster; the query also returns the transaction log location of each database. Because the queries to each database return at different points in time, the LSNs may not match even if streaming replication is working normally for the cluster. + +```text +Promote Status: + +DB Type Address WAL Received LSN WAL Replayed LSN Info +------------------------------------------------------------------- +Primary 172.19.14.9 0/4000638 +Standby 172.19.12.163 0/4000638 0/4000638 +Standby 172.19.10.2 0/4000638 0/4000638 +``` + +If a database is down (or if the database has been restarted, but the resume command has not yet been invoked), the state of the agent that resides on that host will be Idle. If an agent is idle, the cluster status report will include a summary of the condition of the idle node. For example: + +```text +Agent Type Address Agent DB VIP +----------------------------------------------------- +Idle 172.19.18.105 UP UP 172.19.13.105 +``` + +**Exit Codes** + +The cluster status process returns an exit code that is based on the state of the cluster: + +- An exit code of `0` indicates that all agents are running, and the databases on the Primary and Standby nodes are running and in sync. + +- A non-zero exit code indicates that there is a problem. The following problems can trigger a non-zero exit code: + + A database is down or unknown (or has an idle agent). + + Failover Manager cannot decrypt the provided database password. + + There is a problem contacting the databases to get WAL locations. + + There is no Primary agent. + + There are no Standby agents. + + One or more Standby nodes are not in sync with the Primary. + +## Monitoring Streaming Replication with Postgres Enterprise Manager + +If you use Postgres Enterprise Manager (PEM) to monitor your servers, you can configure the Streaming Replication Analysis dashboard (part of the PEM graphical interface) to display the state of a Primary or Standby node that is part of a Streaming Replication scenario. + +![The Streaming Replication dashboard (Primary node)](images/str_replication_dashboard_master.png) + +The Streaming Replication Analysis Dashboard displays statistical information about activity for any monitored server on which streaming replication is enabled. The dashboard header identifies the status of the monitored server (either Replication Primary or Replication Slave), and displays the date and time that the server was last started, the date and time that the page was last updated, and a current count of triggered alerts for the server. + +When reviewing the dashboard for a Replication Slave (a Standby node), a label at the bottom of the dashboard confirms the status of the server. + +![The Streaming Replication dashboard (Standby node)](images/str_replication_dashboard_standby.png) + +By default, the PEM replication probes that provide information for the Streaming Replication Analysis dashboard are disabled. + +To view the Streaming Replication Analysis dashboard for the Primary node of a replication scenario, you must enable the following probes: + +- Streaming Replication +- WAL Archive Status + +To view the Streaming Replication Analysis dashboard for the Standby node of a replication scenario, you must enable the following probes: + +- Streaming Replication Lag Time + +For more information about PEM, please visit the EnterpriseDB website at: + + diff --git a/product_docs/docs/efm/4.1/efm_user/07_using_efm_utility.mdx b/product_docs/docs/efm/4.1/efm_user/07_using_efm_utility.mdx new file mode 100644 index 00000000000..e54f5e3f120 --- /dev/null +++ b/product_docs/docs/efm/4.1/efm_user/07_using_efm_utility.mdx @@ -0,0 +1,213 @@ +--- +title: "Using the efm Utility" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.1/using_efm_utility.html" +--- + + + +Failover Manager provides the efm utility to assist with cluster management. The RPM installer adds the utility to the `/usr/edb/efm-4.1/bin` directory when you install Failover Manager. + +**efm allow-node** + + + +```text +efm allow-node +``` + +Invoke the `efm allow-node` command to allow the specified node to join the cluster. When invoking the command, provide the name of the cluster and the IP address of the joining node. + +This command must be invoked by `efm`, a member of the `efm` group, or root. + +**efm disallow-node** + + + +```text +efm disallow-node
+``` + +Invoke the `efm disallow-node` command to remove the specified node from the allowed hosts list, and prevent the node from joining a cluster. Provide the name of the cluster and the address of the node when calling the `efm disallow-node` command. This command must be invoked by `efm`, a member of the `efm` group, or root. + +**efm cluster-status** + + + +```text +efm cluster-status +``` + +Invoke the `efm cluster-status` command to display the status of a Failover Manager cluster. For more information about the status report, see [Monitoring a Failover Manager Cluster](06_monitoring_efm_cluster/#monitoring_efm_cluster). + +**efm cluster-status-json** + + + +```text +efm cluster-status-json +``` + +Invoke the `efm cluster-status-json` command to display the status of a Failover Manager cluster in json format. While the format of the displayed information is different than the display generated by the efm cluster-status command, the information source is the same. + +The following example is generated by querying the status of a healthy cluster with three nodes: + +```text +{ + "nodes": { + "172.16.144.176": { + "type": "Witness", + "agent": "UP", + "db": "N\/A", + "vip": "", + "vip_active": false + }, + "172.16.144.177": { + "type": "Primary", + "agent": "UP", + "db": "UP", + "vip": "", + "vip_active : false" + "xlogReceive : 0/14001478" + "xlog : 0/14001478" + "xloginfo :" + }, + "172.16.144.180": { + "type": "Standby", + "agent": "UP", + "db": "UP", + "vip": "", + "vip_active : false" + "xlogReceive : 0/14001478" + "xlog : 0/14001478" + "xloginfo :" + } + }, + "allowednodes": [ + "172.16.144.177", + "172.16.144.160", + "172.16.144.180", + "172.16.144.176" + ], + "membershipcoordinator": "172.16.144.177", + "failoverpriority": [ + "172.16.144.180" + ], + "minimumstandbys": 0, + "missingnodes": [], + "messages": [] +} +``` + +**efm encrypt** + + + +```text +efm encrypt [--from-env] +``` + +Invoke the `efm encrypt` command to encrypt the database password before include the password in the cluster properties file. Include the `--from-env` option to instruct Failover Manager to use the value specified in the `EFMPASS` environment variable, and execute without user input. For more information, see [Encrypting Your Database Password](04_configuring_efm/01_cluster_properties/01_encrypting_database_password/#encrypting_database_password). + +**efm promote** + + + +```text +efm promote cluster_name [-switchover [-sourcenode
][-quiet][-noscripts] +``` + +The `efm promote` command instructs Failover Manager to perform a manual failover of standby to primary. + +Manual promotion should only be attempted if the status command reports that the cluster includes a Standby node that is up-to-date with the Primary. If there is no up-to-date Standby, Failover Manager will prompt you before continuing. + +Include the `–switchover` clause to promote a standby node, and reconfigure a primary node as a standby node. Include the `-sourcenode` keyword, and specify a node address to indicate the node whose recovery settings will be copied to the old primary node (making it a standby). Include the `-quiet` keyword to suppress notifications during the switchover process. Include the `-noscripts` keyword to instruct Failover Manager to not invoke fencing or post-promotion scripts. + +This command must be invoked by `efm`, a member of the `efm` group, or root. + +!!! Note + This command instructs the service to ignore the value specified in the `auto.failover` parameter in the cluster properties file. + +**efm resume** + + + +```text +efm resume +``` + +Invoke the `efm resume` command to resume monitoring a previously stopped database. This command must be invoked by efm, a member of the efm group, or root. + +**efm set-priority** + + + +```text +efm set-priority
+``` + +Invoke the `efm set-priority` command to assign a failover priority to a standby node. The value specifies the order in which the node will be used in the event of a failover. This command must be invoked by `efm`, a member of the `efm` group, or root. + +Use the priority option to specify the place for the node in the priority list. For example, specify a value of 1 to indicate that the node is the primary standby, and will be the first node promoted in the event of a failover. A priority value of 0 instructs Failover Manager to not promote the standby. + +**efm stop-cluster** + + + +```text +efm stop-cluster +``` + +Invoke the `efm stop-cluster` command to stop Failover Manager on all nodes. This command instructs Failover Manager to connect to each node on the cluster and instruct the existing members to shut down. The command has no effect on running databases, but when the command completes, there is no failover protection in place. + +!!! Note + When you invoke the `efm stop-cluster` command, all authorized node information is removed from the Allowed node host list. + +This command must be invoked by `efm`, a member of the `efm` group, or root. + +**efm upgrade-conf** + + + +```text +efm upgrade-conf [-source ] +``` + +Invoke the `efm upgrade-conf` command to copy the configuration files from an existing Failover Manager installation, and add parameters required by a Failover Manager installation. Provide the name of the previous cluster when invoking the utility. This command must be invoked with root privileges. + +If you are upgrading from a Failover Manager configuration that does not use sudo, include the `-source` flag and specify the name of the *directory* in which the configuration files reside when invoking upgrade-conf. + +**efm node-status-json** + + + +```text +efm node-status-json +``` + +Invoke the `efm node-status-json` command to display the status of a local node in json format. A successful execution of this command returns `0` as its exit code. In case of a database failure or an agent status becoming IDLE, the command returns `1` as exit code. + +The following is an example output of the `efm node-status-json` command: + +> ```text +> { +> "type":"Standby", +> "address":"172.16.144.130", +> "agent":"UP", +> "db":"UP", +> "vip":"", +> "vip_active":"false" +> } +> ``` + +**efm --help** + + + +```text +efm --help +``` + +Invoke the `efm --help` command to display online help for the Failover Manager utility commands. diff --git a/product_docs/docs/efm/4.1/efm_user/08_controlling_efm_service.mdx b/product_docs/docs/efm/4.1/efm_user/08_controlling_efm_service.mdx new file mode 100644 index 00000000000..a50493bd577 --- /dev/null +++ b/product_docs/docs/efm/4.1/efm_user/08_controlling_efm_service.mdx @@ -0,0 +1,55 @@ +--- +title: "Controlling the Failover Manager Service" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.1/controlling_efm_service.html" +--- + + + +Each node in a Failover Manager cluster hosts a Failover Manager agent that is controlled by a service script. By default, the service script expects to find: + +- A configuration file named `efm.properties` that contains the properties used by the Failover Manager service. Each node of a replication scenario must contain a properties file that provides information about the node. +- A cluster members file named `efm.nodes` that contains a list of the cluster members. Each node of a replication scenario must contain a cluster members list. + +Note that if you are running multiple clusters on a single node you will need to manually create configuration files with cluster-specific names and modify the service script for the corresponding clusters. + +The commands that control the Failover Manager service are platform-specific. + + + +## Using the systemctl Utility on RHEL/CentOS 7.x and RHEL/CentOS 8.x + +On RHEL/CentOS 7.x and RHEL/CentOS 8.x, Failover Manager runs as a Linux service named (by default) `edb-efm-4.1.service` that is located in `/usr/lib/systemd/system`. Each database cluster monitored by Failover Manager will run a copy of the service on each node of the replication cluster. + +Use the following systemctl commands to control a Failover Manager agent that resides on a RHEL/CentOS 7.x and RHEL/CentOS 8.x host: + +```text +systemctl start edb-efm-4.1 +``` + +The start command starts the Failover Manager agent on the current node. The local Failover Manager agent monitors the local database and communicates with Failover Manager on the other nodes. You can start the nodes in a Failover Manager cluster in any order. This command must be invoked by root. + +```text +systemctl stop edb-efm-4.1 +``` + +Stop the Failover Manager on the current node. This command must be invoked by root. + +```text +systemctl status edb-efm-4.1 +``` + +The status command returns the status of the Failover Manager agent on which it is invoked. You can invoke the status command on any node to instruct Failover Manager to return status and server startup information. + +```text +[root@ONE ~]}> systemctl status edb-efm-4.1 + edb-efm-4.1.service - EnterpriseDB Failover Manager 4.1 + Loaded: loaded (/usr/lib/systemd/system/edb-efm-4.1.service; disabled; vendor preset: disabled) + Active: active (running) since Wed 2013-02-14 14:02:16 EST; 4s ago + Process: 58125 ExecStart=/bin/bash -c /usr/edb/edb-efm-4.1/bin/runefm.sh start ${CLUSTER} (code=exited, status=0/SUCCESS) + Main PID: 58180 (java) + CGroup: /system.slice/edb-efm-4.1.service + └─58180 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-0.b14.el7_4.x86_64/jre/bin/java -cp /usr/edb/edb-efm-4.1/lib/EFM-4.1.0.jar -Xmx128m... +``` diff --git a/product_docs/docs/efm/4.1/efm_user/09_controlling_logging.mdx b/product_docs/docs/efm/4.1/efm_user/09_controlling_logging.mdx new file mode 100644 index 00000000000..586370f91ee --- /dev/null +++ b/product_docs/docs/efm/4.1/efm_user/09_controlling_logging.mdx @@ -0,0 +1,90 @@ +--- +title: "Controlling Logging" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.1/controlling_logging.html" +--- + + + +Failover Manager writes and stores one log file per agent and one startup log per agent in `/var/log/-4.1` (where `` specifies the name of the cluster). + +You can control the level of detail written to the agent log by modifying the `jgroups.loglevel` and `efm.loglevel` parameters in the [cluster properties file](04_configuring_efm/01_cluster_properties/#loglevel): + +```text +# Logging levels for JGroups and EFM. +# Valid values are: TRACE, DEBUG, INFO, WARN, ERROR +# Default value: INFO +# It is not necessary to increase these values unless debugging a +# specific issue. If nodes are not discovering each other at +# startup, increasing the jgroups level to DEBUG will show +# information about the TCP connection attempts that may help +# diagnose the connection failures. +jgroups.loglevel=INFO +efm.loglevel=INFO +``` + +The logging facilities use the Java logging library and logging levels. The log levels (in order from most logging output to least) are: + +> - `TRACE` +> - `DEBUG` +> - `INFO` +> - `WARN` +> - `ERROR` + +For example, if you set the `efm.loglevel` parameter to `WARN`, Failover Manager will only log messages at the `WARN` level and above (`WARN` and `ERROR`). + +By default, Failover Manager log files are rotated daily, compressed, and stored for a week. You can modify the file rotation schedule by changing settings in the log rotation file (`/etc/logrotate.d/efm-4.1`). For more information about modifying the log rotation schedule, consult the logrotate man page: + +> `$ man logrotate` + + + +## Enabling syslog Log File Entries + +Failover Manager supports syslog logging. To implement syslog logging, you must configure syslog to allow UDP or TCP connections. + +To allow a connection to syslog, edit the `/etc/rsyslog.conf` file and uncomment the protocol you wish to use. You must also ensure that the `UDPServerRun` or `TCPServerRun` entry associated with the protocol includes the port number to which log entries will be sent. For example, the following configuration file entries enable UDP connections to port 514: + +```text +# Provides UDP syslog reception +$ModLoad imudp +$UDPServerRun 514 +``` + +The following configuration file entries enable TCP connections to port 514: + +```text +# Provides TCP syslog reception +$ModLoad imtcp +$InputTCPServerRun 514 +``` + +After modifying the syslog configuration file, restart the `rsyslog` service to enable the connections: + +> `systemctl restart rsyslog.service` + +After modifying the `rsyslog.conf` file on the Failover Manager host, you must modify the Failover Manager properties to enable logging. Use your choice of editor to [modify the properties file](04_configuring_efm/01_cluster_properties/#logtype_enabled) (`/etc/edb/efm-4.1/efm.properties.in`) specifying the type of logging that you wish to implement: + +```text +# Which logging is enabled. +file.log.enabled=true +syslog.enabled=false +``` + +You must also [specify syslog details](04_configuring_efm/01_cluster_properties/#syslog_logging) for your system. Use the `syslog.protocol` parameter to specify the protocol type (UDP or TCP) and the `syslog.port` parameter to specify the listener port of the syslog host. The `syslog.facility` value may be used as an identifier for the process that created the entry; the value must be between `LOCAL0` and `LOCAL7`. + +```text +# Syslog information. The syslog service must be listening # on the + port for the given protocol, which can be UDP or +# TCP. The facilities supported are LOCAL0 through LOCAL7. +# syslog.host=localhost +syslog.port=514 +syslog.protocol=UDP +syslog.facility=LOCAL1 +``` + +For more information about syslog, please see the syslog man page: + +> `syslog man` diff --git a/product_docs/docs/efm/4.1/efm_user/10_notifications.mdx b/product_docs/docs/efm/4.1/efm_user/10_notifications.mdx new file mode 100644 index 00000000000..dd529b3d36b --- /dev/null +++ b/product_docs/docs/efm/4.1/efm_user/10_notifications.mdx @@ -0,0 +1,160 @@ +--- +title: "Notifications" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.1/notifications.html" +--- + + + +Failover Manager will send e-mail notifications and/or invoke a notification script when a notable event occurs that affects the cluster. If you have configured Failover Manager to send an email notification, you must have an SMTP server running on port 25 on each node of the cluster. Use the following parameters to configure notification behavior for Failover Manager: + +```text +user.email +script.notification +from.email +``` + +For more information about editing the configuration properties, see [Specifying Cluster Properties](04_configuring_efm/01_cluster_properties/#cluster_properties). + +The body of the notification contains details about the event that triggered the notification, and about the current state of the cluster. For example: + +```text +EFM node: 10.0.1.11 +Cluster name: acctg +Database name: postgres +VIP: ip_address (Active|Inactive) +Database health is not being monitored. +``` + +The VIP field displays the IP address and state of the virtual IP if implemented for the node. + +Failover Manager assigns a severity level to each notification. The following levels indicate increasing levels of attention required: + +- `INFO` indicates an informational message about the agent and does not require any manual intervention (for example, Failover Manager has started or stopped). See [List of INFO level notifications](#notifications_info) +- `WARNING` indicates that an event has happened that requires the administrator to check on the system (for example, failover has occurred). See [List of WARNING level notifications](#notifications_warning) +- `SEVERE` indicates that a serious event has happened and requires the immediate attention of the administrator (for example, failover was attempted, but was unable to complete). See [List of SEVERE level notifications](#notifications_severe) + +The severity level designates the urgency of the notification. A notification with a severity level of `SEVERE` requires user attention immediately, while a notification with a severity level of `INFO` will call your attention to operational information about your cluster that does not require user action. Notification severity levels are not related to logging levels; all notifications are sent regardless of the log level detail specified in the configuration file. + +You can use the [notification.level](04_configuring_efm/01_cluster_properties/#notification_level) property to specify the minimum severity level that will trigger a notification. + +!!! Note + In addition to sending notices to the administrative email address, all notifications are recorded in the cluster log file (`/var/log/efm-4.1/.log`). + +The conditions listed in the table below will trigger an `INFO` level notification: + + + +| Subject | Description | +| ---------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| Executed fencing script | Executed fencing script script_name Results: script_results | +| Executed post-promotion script | Executed post-promotion script script_name Results: script_results | +| Executed remote pre-promotion script | Executed remote pre-promotion script script_name Results: script_results | +| Executed remote post-promotion script | Executed remote post-promotion script script_name Results: script_results | +| Executed post-database failure script | Executed post-database failure script script_name Results: script_results | +| Executed primary isolation script | Executed primary isolation script script_name Results: script_results | +| Witness agent running on node_address for cluster cluster_name | Witness agent is running. | +| Primary agent running on node_address for cluster cluster_name | Primary agent is running and database health is being monitored. | +| Standby agent running on node_address for cluster cluster_name | Standby agent is running and database health is being monitored. | +| Idle agent running on node node_address for cluster cluster_name | Idle agent is running. After starting the local database, the agent can be resumed. | +| Assigning VIP to node node_address | Assigning VIP VIP_address to node node_address Results: script_results | +| Releasing VIP from node node_address | Releasing VIP VIP_address from node node_address Results: script_results | +| Starting auto resume check for cluster cluster_name | The agent on this node will check every auto.resume.period seconds to see if it can resume monitoring the failed database. The cluster should be checked during this time and the agent stopped if the database will not be started again. See the agent log for more details. | +| Executed agent resumed script | Executed agent resumed script script_name Results: script_results | +| WAL logs backed up during promotion | When reconfiguring this standby to follow the new primary, the pg_xlog or pg_wal contents were backed up in the pgdata directory. This backup should be removed when convenient to free up disk space. | + +The conditions listed in the table below will trigger a *WARNING* level notification: + + + +| Subject | Description | +| ------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Witness agent exited on node_address for cluster cluster_name | Witness agent has exited. | +| Primary agent exited on node_address for cluster cluster_name | Database health is not being monitored. | +| Cluster cluster_name notified that primary node has left | Failover is disabled for the cluster until the primary agent is restarted. | +| Standby agent exited on node_address for cluster cluster_name | Database health is not being monitored. | +| Agent exited during promotion on node_address for cluster cluster_name | Database health is not being monitored. | +| Agent exited on node_address for cluster cluster_name | The agent has exited. This is generated by an agent in the Idle state. | +| Agent exited for cluster cluster_name | The agent has exited. This notification is usually generated during startup when an agent exits before startup has completed. | +| Virtual IP address assigned to non-primary node | The virtual IP address appears to be assigned to a non-primary node. To avoid any conflicts, Failover Manager will release the VIP. You should confirm that the VIP is assigned to your primary node and manually reassign the address if it is not. | +| Virtual IP address not assigned to primary node. | The virtual IP address appears to not be assigned to a primary node. EDB Postgres Failover Manager will attempt to reacquire the VIP. | +| No standby agent in cluster for cluster cluster_name | The standbys on cluster_name have left the cluster. | +| Standby agent failed for cluster cluster_name | A standby agent on cluster_name has left the cluster, but the coordinator has detected that the standby database is still running. | +| Standby database failed for cluster cluster_name | A standby agent has signaled that its database has failed. The other nodes also cannot reach the standby database. | +| Standby agent cannot reach database for cluster cluster_name | A standby agent has signaled database failure, but the other nodes have detected that the standby database is still running. | +| Cluster cluster_name has dropped below three nodes | At least three nodes are required for full failover protection. Please add witness or agent node to the cluster. | +| Subset of cluster cluster_name disconnected from primary | This node is no longer connected to the majority of the cluster cluster_name. Because this node is part of a subset of the cluster, failover will not be attempted. Current nodes that are visible are: node_address | +| Promotion has started on cluster cluster_name. | The promotion of a standby has started on cluster cluster_name. | +| Witness failure for cluster cluster_name | Witness running at node_address has left the cluster. | +| Idle agent failure for cluster cluster_name. | Idle agent running at node_address has left the cluster. | +| One or more nodes isolated from network for cluster cluster_name | This node appears to be isolated from the network. Other members seen in the cluster are: node_name | +| Node no longer isolated from network for cluster cluster_name. | This node is no longer isolated from the network. | +| Standby agent tried to promote, but primary DB is still running | The standby EFM agent tried to promote itself, but detected that the primary DB is still running on node_address. This usually indicates that the primary EFM agent has exited. Failover has NOT occurred. | +| Standby agent started to promote, but primary has rejoined. | The standby EFM agent started to promote itself, but found that a primary agent has rejoined the cluster. Failover has NOT occurred. | +| Standby agent tried to promote, but could not verify primary DB | The standby EFM agent tried to promote itself, but could not detect whether or not the primary DB is still running on node_address. Failover has NOT occurred. | +| Standby agent tried to promote, but VIP appears to still be assigned | The standby EFM agent tried to promote itself, but could not because the virtual IP address (VIP_address) appears to still be assigned to another node. Promoting under these circumstances could cause data corruption. Failover has NOT occurred. | +| Standby agent tried to promote, but appears to be orphaned | The standby EFM agent tried to promote itself, but could not because the well-known server (server_address) could not be reached. This usually indicates a network issue that has separated the standby agent from the other agents. Failover has NOT occurred. | +| Potential manual failover required on cluster cluster_name. | A potential failover situation was detected for cluster cluster_name. Automatic failover has been disabled for this cluster, so manual intervention is required. | +| Failover has completed on cluster cluster_name | Failover has completed on cluster cluster_name. | +| Lock file for cluster cluster_name has been removed | The lock file for cluster cluster_name has been removed from: path_name on node node_address. This lock prevents multiple agents from monitoring the same cluster on the same node. Please restore this file to prevent accidentally starting another agent for cluster. | +| A recovery file for cluster cluster_name has been found on primary node | A recovery file for cluster cluster_name has been found at: path_name on primary node node_address. This may be problematic should you attempt to restart the DB on this node. | +| recovery_target_timeline is not set to latest in recovery settings | The recovery_target_timeline parameter is not set to latest in the recovery settings. The standby server will not be able to follow a timeline change that occurs when a new primary is promoted. | +| Promotion has not occurred for cluster cluster_name | A promotion was attempted but there is already a node being promoted: ip_address. | +| Standby not reconfigured after failover in cluster cluster_name | The auto.reconfigure property has been set to false for this node. The node has not been reconfigured to follow the new primary node after a failover. | +| Could not resume replay for standby standby_id. | Could not resume replay for standby. Manual intervention may be required. Error: error_message. | +| Possible problem with database timeout values | Your remote.timeout value (value) is higher than your local.timeout value (value). If the local database takes too long to respond, the local agent could assume that the database has failed though other agents can connect. While this will not cause a failover, it could force the local agent to stop monitoring, leaving you without failover protection. | +| No standbys available for promotion in cluster cluster_name | The current number of standby nodes in the cluster has dropped to the minimum number: number. There cannot be a failover unless another standby node(s) is added or made promotable. | +| No promotable standby for cluster cluster_name | The current failover priority list in the cluster is empty. You have removed the only promotable standby for the cluster cluster_name. There cannot be a failover unless another promotable standby node(s) is added or made promotable by adding to failover priority list. | +| Synchronous replication has been reconfigured for cluster cluster_name | The number of synchronous standby nodes in the cluster has dropped below number. The synchronous standby names on primary has been reconfigured to: new synchronous_standby_names value. | +| Synchronous replication has been reconfigured for cluster cluster_name | The synchronous_standby_names on primary has been reconfigured to new_synchronous_standby_names | +| Synchronous replication has been disabled for cluster cluster_name. | The number of synchronous standby nodes in the cluster has dropped below count. The primary has been taken out of synchronous replication mode. | +| Could not reload database configuration. | Could not reload database configuration. Manual intervention is required. Error: error_message. | +| Custom monitor timeout for cluster cluster_name | The following custom monitoring script has timed out: script_name | +| Custom monitor 'safe mode' failure for cluster cluster_name | The following custom monitor script has failed, but is being run in "safe mode": script_name. Output: script_results | +| primary.shutdown.as.failure set to true for primary node | The primary.shutdown.as.failure property has been set to true for this cluster. Stopping the primary agent without stopping the entire cluster will be treated by the rest of the cluster as an immediate primary agent failure. If maintenance is required on the primary database, shut down the primary agent and wait for a notification from the remaining nodes that failover will not happen. | +| Primary_or_Standby cannot ping local database for cluster cluster_name | The Primary_or_Standby agent can no longer reach the local database running at node_address. Other nodes are able to access the database remotely, so the agent will become IDLE and attempt to resume monitoring the database. | +| Standby cannot resume monitoring local database for cluster cluster_name | The standby agent can no longer reach the local database running at node_address. Other nodes are able to access the database remotely. The standby agent will remain IDLE until the resume command is run to resume monitoring the database. | + + + +The conditions listed in the table below will trigger a *SEVERE* notification: + +| Subject | Description | +| -------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Standby database restarted but EFM cannot connect | The start or restart command for the database ran successfully but the database is not accepting connections. EFM will keep trying to connect for up to restart.connection.timeout seconds. | +| Unable to connect to DB on node_address | The maximum connections limit has been reached. | +| Unable to connect to DB on node_address | Invalid password for db.user=user_name. | +| Unable to connect to DB on node_address | Invalid authorization specification. | +| Primary cannot resume monitoring local database for cluster cluster_name | The primary agent can no longer reach the local database running at node_address. Other nodes are able to access the database remotely, so the primary will not release the VIP and/or create a recovery.conf file. The primary agent will remain IDLE until the resume command is run to resume monitoring the database. | +| Fencing script error | Fencing script script_name failed to execute successfully. Exit Value: exit_code Results: script_results Failover has NOT occurred. | +| Post-promotion script failed | Post-promotion script script_name failed to execute successfully. Exit Value: exit_code Results: script_results | +| Remote post-promotion script failed | Remote post-promotion script script_name failed to execute successfully Exit Value: exit_code Results: script_resultsNode: node_address | +| Remote pre-promotion script failed | Remote pre-promotion script script_name failed to execute successfully Exit Value: exit_code Results: script_resultsNode: node_address | +| Post-database failure script error | Post-database failure script script_name failed to execute successfully. Exit Value: exit_code Results: script_results | +| Agent resumed script error | Agent resumed script script_name failed to execute successfully. Results: script_results | +| Primary isolation script failed | Primary isolation script script_name failed to execute successfully. Exit Value: exit_code Results: script_results | +| Could not promote standby | The promote command failed on node. Could not promote standby. Error details: error_details | +| Error creating recovery.conf file on node_address for cluster cluster_name | There was an error creating the recovery.conf file on primary node node_address during promotion. Promotion has continued, but requires manual intervention to ensure that the old primary node can not be restarted. Error details: message_details | +| An unexpected error has occurred for cluster cluster_name | An unexpected error has occurred on this node. Please check the agent log for more information. Error: error_details | +| Primary database being fenced off for cluster cluster_name | The primary database has been isolated from the majority of the cluster. The cluster is telling the primary agent at ip_address to fence off the primary database to prevent two primarys when the rest of the failover manager cluster promotes a standby. | +| Isolated primary database shutdown. | The isolated primary database has been shutdown by failover manager. | +| Primary database being fenced off for cluster cluster_name | The primary database has been isolated from the majority of the cluster. Before the primary could finish detecting isolation, a standby was promoted and has rejoined this node in the cluster. This node is isolating itself to avoid more than one primary database. | +| Could not assign VIP to node node_address | Failover manager could not assign the VIP address for some reason. | +| primary_or_standby database failure for cluster cluster_name | The database has failed on the specified node. | +| Agent is timing out for cluster cluster_name | This agent has timed out trying to reach the local database. After the timeout, the agent could successfully ping the database and has resumed monitoring. However, the node should be checked to make sure it is performing normally to prevent a possible database or agent failure. | +| Resume timed out for cluster cluster_name | This agent could not resume monitoring after reconfiguring and restarting the local database. See agent log for details. | +| Internal state mismatch for cluster cluster_name | The failover manager cluster's internal state did not match the actual state of the cluster members. This is rare and can be caused by a timing issue of nodes joining the cluster and/or changing their state. The problem should be resolved, but you should check the cluster status as well to verify. Details of the mismatch can be found in the agent log file. | +| Failover has not occurred | An agent has detected that the primary database is no longer available in cluster cluster_name, but there are no standby nodes available for failover. | +| Database in wrong state on node_address | The standby agent has detected that the local database is no longer in recovery. The agent will now become idle. Manual intervention is required. | +| Database in wrong state on node_address | The primary agent has detected that the local database is in recovery. The agent will now become idle. Manual intervention is required. | +| Database connection failure for cluster cluster_name | This node is unable to connect to the database running on: node_addressUntil this is fixed, failover may not work properly because this node will not be able to check if the database is running or not. | +| Standby custom monitor failure for cluster cluster_name | The following custom monitor script has failed on a standby node. The agent will stop monitoring the local database. Script location: script_name Script output: script_results | +| Primary custom monitor failure for cluster cluster_name | The following custom monitor script has failed on a primary node. EFM will attempt to promote a standby. Script location: script_name Script output: script_results | +| Loopback address set for ping.server.ip | Loopback address is set for ping.server.ip property. This setting can interfere with the network isolation detection and hence it should be changed. | +| Load balancer attach script error | Load balancer attach script script_name failed to execute successfully. Exit Value: exit_code Results: script_results | +| Load balancer detach script error | Load balancer detach script script_name failed to execute successfully. Exit Value: exit_code Results: script_results | +| Pgpool attach node error | Failover Manager failed to attach pgpool node. Exit Value: exit_code. Results: script_results | +| Pgpool detach node error | Failover Manager failed to detach pgpool node. Exit Value: exit_code. Results: script_results | +| Not enough synchronous standbys available in cluster cluster_name. | The number of synchronous standby nodes in the cluster has dropped to count. All write queries on the primary will be blocked until enough synchronous standby nodes are added. | diff --git a/product_docs/docs/efm/4.1/efm_user/11_supported_scenarios.mdx b/product_docs/docs/efm/4.1/efm_user/11_supported_scenarios.mdx new file mode 100644 index 00000000000..48aded81ac8 --- /dev/null +++ b/product_docs/docs/efm/4.1/efm_user/11_supported_scenarios.mdx @@ -0,0 +1,117 @@ +--- +title: "Supported Failover and Failure Scenarios" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.1/supported_scenarios.html" +--- + + + +Failover Manager monitors a cluster for failures that may or may not result in failover. + +Failover Manager supports a very specific and limited set of failover scenarios. Failover can occur: + +- if the Primary database crashes or is shutdown. +- if the node hosting the Primary database crashes or becomes unreachable. + +Failover Manager makes every attempt to verify the accuracy of these conditions. If agents cannot confirm that the Primary database or node has failed, Failover Manager will not perform any failover actions on the cluster. + +Failover Manager also supports a *no* *auto*-*failover* mode for situations where you want Failover Manager to monitor and detect failover conditions, but not perform an automatic failover to a Standby. In this mode, a notification is sent to the administrator when failover conditions are met. To disable automatic failover, modify the cluster properties file, setting the [auto.failover](04_configuring_efm/01_cluster_properties/#auto_failover) parameter to false. + +Failover Manager will alert an administrator to situations that require administrator intervention, but that do not merit promoting a Standby database to Primary. + + + +## Primary Database is Down + +If the agent running on the Primary database node detects a failure of the Primary database, Failover Manager begins the process of confirming the failure. + +![Confirming the Failure of the Primary Database.](images/supported_scenarios_master_db_down.png) + +If the agent on the Primary node detects that the Primary database has failed, all agents attempt to connect directly to the Primary database. If an agent can connect to the database, Failover Manager sends a notification about the state of the Primary node. If no agent can connect, the Primary agent declares database failure and releases the VIP (if applicable). + +If no agent can reach the virtual IP address or the database server, Failover Manager starts the failover process. The Standby agent on the most up-to-date node runs a fencing script (if applicable), promotes the Standby database to Primary database, and assigns the virtual IP address to the Standby node. Any additional Standby nodes are configured to replicate from the new primary unless auto.reconfigure is set to false. If applicable, the agent runs a post-promotion script. + +**Returning the Node to the Cluster** + +To recover from this scenario without restarting the entire cluster, you should: + +1. Restart the database on the original Primary node as a Standby database. +2. Invoke the `efm resume` command on the original Primary node. + +**Returning the Node to the Role of Primary** + +After returning the node to the cluster as a Standby, you can easily return the node to the role of Primary: + +1. If the cluster has more than one Standby node, use the `efm set-priority` command to set the node's failover priority to 1. +2. Invoke the [efm promote -switchover](07_using_efm_utility/#efm_promote) command to promote the node to its original role of Primary node. + + + +## Standby Database is Down + +If a Standby agent detects a failure of its database, the agent notifies the other agents; the other agents confirm the state of the database. + +![Confirming the failure of a Standby Database.](images/supported_scenarios_standby_db_down.png) + +After returning the Standby database to a healthy state, invoke the `efm resume` command to return the Standby to the cluster. + + + +## Primary Agent Exits or Node Fails + +If the Failover Manager Primary agent crashes or the node fails, a Standby agent will detect the failure and (if appropriate) initiate a failover. + +![Confirming the failure of the Primary Agent.](images/supported_scenarios_master_agent_exits.png) + +If an agent detects that the Primary agent has left, all agents attempt to connect directly to the Primary database. If any agent can connect to the database, an agent sends a notification about the failure of the Primary agent. If no agent can connect, the agents attempt to ping the virtual IP address to determine if it has been released. + +If no agent can reach the virtual IP address or the database server, Failover Manager starts the failover process. The Standby agent on the most up-to-date node runs a fencing script (if applicable), promotes the Standby database to Primary database, and assigns the virtual IP address to the Standby node; if applicable, the agent runs a post-promotion script. Any additional Standby nodes are configured to replicate from the new primary unless auto.reconfigure is set to false. + +If this scenario has occurred because the primary has been isolated from network, the Primary agent will detect the isolation and release the virtual IP address and create the recovery.conf file. Failover Manager will perform the previously listed steps on the remaining nodes of the cluster. + +To recover from this scenario without restarting the entire cluster, you should: + +1. Restart the original Primary node. +2. Bring the original Primary database up as a Standby node. +3. Start the service on the original Primary node. + +Please note that stopping an agent does not signal the cluster that the agent has failed. + + + +## Standby Agent Exits or Node Fails + +If a Standby agent exits or a Standby node fails, the other agents will detect that it is no longer connected to the cluster. + +![Failure of Standby Agent.](images/supported_scenarios_standby_agent_exits.png) + +When the failure is detected, the agents attempt to contact the database that resides on the node; if the agents confirm that there is a problem, Failover Manager sends the appropriate notification to the administrator. + +If there is only one Primary and one Standby remaining, there is no failover protection in the case of a Primary node failure. In the case of a Primary database failure, the Primary and Standby agents can agree that the database failed and proceed with failover. + + + +## Dedicated Witness Agent Exits / Node Fails + +The following scenario details the actions taken if a dedicated Witness (a node that is not hosting a database) fails. + +![Confirming the Failure of a dedicated Witness.](images/supported_scenarios_witness_agent_exits.png) + +When an agent detects that the Witness node cannot be reached, Failover Manager notifies the administrator of the state of the Witness. + +!!! Note + If the witness fails and the cluster only has two nodes, then there is no failover protection because the standby node has no way to know if the primary failed or was disconnected. In a two node cluster, if the primary database fails but the nodes are still connected, failover will still occur since the standby can confirm the condition of the primary database. + + + +## Nodes Become Isolated from the Cluster + +The following scenario details the actions taken if one or more nodes (a minority of the cluster) become isolated from the majority of the cluster. + +![If members of the cluster become isolated.](images/supported_scenarios_node_becomes_isolated.png) + +If one or more nodes (but less than half of the cluster) become isolated from the rest of the cluster, the remaining cluster behaves as if the nodes have failed. The agents attempt to discern if the Primary node is among the isolated nodes; it is, the Primary fences itself off from the cluster, while a Standby node (from within the cluster majority) is promoted to replace it. Other Standby nodes are configured to replicate from the new primary unless `auto.reconfigure` is set to `false`. + +Failover Manager then notifies an administrator, and the isolated nodes rejoin the cluster when they are able. When the nodes rejoin the cluster, the failover priority may change. diff --git a/product_docs/docs/efm/4.1/efm_user/12_upgrading_existing_cluster.mdx b/product_docs/docs/efm/4.1/efm_user/12_upgrading_existing_cluster.mdx new file mode 100644 index 00000000000..bcdce46ad3e --- /dev/null +++ b/product_docs/docs/efm/4.1/efm_user/12_upgrading_existing_cluster.mdx @@ -0,0 +1,111 @@ +--- +title: "Upgrading an Existing Cluster" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.1/upgrading_existing_cluster.html" +--- + + + +Failover Manager provides a utility to assist you when upgrading a Failover Manager cluster. To upgrade an existing cluster, you must: + +1. Install Failover Manager 4.1 on each node of the cluster. For detailed information about installing Failover Manager, see [Installing Failover Manager](03_installing_efm/#installing_efm). +2. After installing Failover Manager, invoke the `efm upgrade-conf` utility to create the `.properties` and `.nodes` files for Failover Manager 4.1. The Failover Manager installer installs the upgrade utility ([efm upgrade-conf](07_using_efm_utility/#efm_upgrade_conf)) to the `/usr/edb/efm-4.1/bin directory`. To invoke the utility, assume root privileges, and invoke the command: + +```text +efm upgrade-conf +``` + +The efm `upgrade-conf` utility locates the `.properties` and `.nodes` files of pre-existing clusters and copies the parameter values to a new configuration file for use by Failover Manager. The utility saves the updated copy of the configuration files in the `/etc/edb/efm-4.1` directory. + +1. Modify the `.properties` and `.nodes` files for EFM 4.1, specifying any new preferences. Use your choice of editor to modify any additional properties in the properties file (located in the `/etc/edb/efm-4.1` directory) before starting the service for that node. For detailed information about property settings, see [The Cluster Properties File](04_configuring_efm/01_cluster_properties/#cluster_properties). + +!!! Note + `db.bin` is a required property. When modifying the properties file, ensure that the `db.bin` property specifies the location of the Postgres `bin` directory. + +1. Use a version-specific command to stop the old Failover Manager cluster; for example, you can use the following command to stop a version 4.0 cluster: + +```text +/usr/efm-4.0/bin/efm stop-cluster efm +``` + +1. Start the new [Failover manager service](08_controlling_efm_service/#controlling_efm_service) (`edb-efm-4.1`) on each node of the cluster. + +The following example demonstrates invoking the upgrade utility to create the `.properties` and `.nodes` files for a Failover Manager installation: + +```text +host-192-168-17-43:/etc/edb/efm-4.1 # /usr/edb/efm-4.1/bin/efm upgrade-conf efm +Checking directory /etc/edb/efm-4.0 +Processing efm.properties file + +The following properties were added in addition to those in previous installed version: +reconfigure.num.sync.max +pgpool.enable +pcp.user +pcp.host +pcp.port +pcp.pass.file +pgpool.bin + +Checking directory /etc/edb/efm-4.0 +Processing efm.nodes file + +db.password.encrypted re-encoded with stronger encryption. + +Upgrade of files is finished. The owner and group for properties and nodes files have been set as 'efm'. + +root@localhost efm-4.1]# +``` + +If you are [using a Failover Manager configuration without sudo](04_configuring_efm/04_extending_efm_permissions/#running_efm_without_sudo), include the `-source` flag and specify the name of the directory in which the configuration files reside when invoking `upgrade-conf`. If the directory is not the configuration default directory, the upgraded files will be created in the directory from which the `upgrade-conf` command was invoked. + +**Please note**: If you are using a unit file, you must manually update the file to reflect the new Failover Manager service name when you perform an upgrade. + +## Un-installing Failover Manager + +After upgrading to Failover Manager 4.1, you can use your native package manager to remove previous installations of Failover Manager. For example, use the following command to remove Failover Manager 4.0 and any unneeded dependencies: + +- On RHEL or CentOS 7.x: + +```text +yum remove edb-efm40 +``` + +- On RHEL or CentOS 8.x: + +```text +dnf remove edb-efm40 +``` + +- On Debian or Ubuntu: + +```text +apt-get remove edb-efm40 +``` + +- On SLES: + +```text +zypper remove edb-efm40 +``` + +## Performing a Database Update (Minor Version) + +This section describes how to perform a quick minor database version upgrade. You can use the steps that follow to upgrade from one minor version to another (for example, from 10.1.5 to version 10.2.7), or to apply a patch release for a version. + +You should first update the database server on each Standby node of the Failover Manager cluster. Then, perform a switchover, promoting a Standby node to the role of Primary within the Failover Manager cluster. Then, perform a database update on the old primary node. + +On each node of the cluster you must perform the following steps to update the database server: + +1. Stop the Failover Manager agent. +2. Stop the database server. +3. Update the database server. +4. Start the database service. +5. Start the Failover Manager agent. + +For detailed information about controlling the Advanced Server service, or upgrading your version of Advanced Server, please see the EDB Postgres Advanced Server Guide, available at: + +[https://www.enterprisedb.com/docs](/epas/latest/) + +When your updates are complete, you can use the [efm set-priority](07_using_efm_utility/#efm_set_priority) command to add the old primary to the front of the standby list (if needed), and then switchover to return the cluster to its original state. diff --git a/product_docs/docs/efm/4.1/efm_user/13_troubleshooting.mdx b/product_docs/docs/efm/4.1/efm_user/13_troubleshooting.mdx new file mode 100644 index 00000000000..60dc934bd9f --- /dev/null +++ b/product_docs/docs/efm/4.1/efm_user/13_troubleshooting.mdx @@ -0,0 +1,47 @@ +--- +title: "Troubleshooting" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.1/troubleshooting.html" +--- + + + +**Authorization file not found. Is the local agent running?** + +If you invoke an EFM cluster management command and EFM is not running on the node, the `efm` command will display an error: + +```text +Authorization file not found. Is the local agent running? +``` + +**Not authorized to run this command. User '<os user>' is not a member of the \`efm\` group.** + +You must have special privileges to invoke some of the `efm` commands documented in [Using the efm Utility](07_using_efm_utility/#using_efm_utility). If these commands are invoked by a user who isn't authorized to run them, the `efm` command will display an error: + +```text +Not authorized to run this command. User '' is not a member of the `efm` group. +``` + +**Notification; Unexpected error message** + +If you receive a notification message about an unexpected error message, check the [Failover Manager log file](09_controlling_logging/#controlling_logging) for an `OutOfMemory` message. Failover Manager runs with the default memory value set by this property: + +```text +# Extra information that will be passed to the JVM when starting the agent. +jvm.options=-Xmx128m +``` + +If you are running with less than 128 megabytes allocated, you should increase the value and restart the Failover Manager agent. + +**Confirming the OpenJDK version** + +Failover Manager is tested with OpenJDK; we strongly recommend using OpenJDK. You can use the following command to check the type of your Java installation: + +```text +# java -version +openjdk version "1.8.0_191" +OpenJDK Runtime Environment (build 1.8.0_191-b12) +OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode) +``` diff --git a/product_docs/docs/efm/4.1/efm_user/14_configuring_streaming_replication.mdx b/product_docs/docs/efm/4.1/efm_user/14_configuring_streaming_replication.mdx new file mode 100644 index 00000000000..8d39ab3ff43 --- /dev/null +++ b/product_docs/docs/efm/4.1/efm_user/14_configuring_streaming_replication.mdx @@ -0,0 +1,44 @@ +--- +title: "Configuring Streaming Replication" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.1/configuring_streaming_replication.html" +--- + + + +Configuring a replication scenario can be complex; for detailed information about configuration options, please see the PostgreSQL core documentation, available at: + + + +You may want to use a `.pgpass` file to enable md5 authentication for the replication user – this may or may not be the safest authentication method for your environment. For more information about the supported authentication options, please see the PostgreSQL core documentation at: + + + +!!! Note + From Version 3.10 onwards, EFM uses `pg_ctl` utility for standby promotion. You do not need to set the `trigger_file` or `promote_trigger_file` parameter for promotion of a standby server. + +## Limited Support for Cascading Replication + +While Failover Manager does not provide full support for cascading replication, it does provide limited support for simple failover in a cascading replication scenario. Cascading replication allows a Standby node to stream to another Standby node, reducing the number of connections (and processing overhead) to the primary node. + +![Cascading replication.](images/cascading_replication.png) + +For detailed information about configuring cascading replication, please see the PostgreSQL documentation at: + + + +To use Failover Manager in a cascading replication scenario, you should modify the cluster properties file, setting the following property values on Standby Node #2: + +```text +promotable=false +auto.reconfigure=false +``` + +In the event of a Failover, Standby Node #1 will be promoted to the role of Primary node. Should failover occur, Standby Node #2 will continue to act as a read-only replica for the new Primary node until you take actions to manually reconfigure the replication scenario to contain 3 nodes. + +In the event of a failure of Standby Node #1, you will not have failover protection, but you will receive an email notifying you of the failure of the node. + +!!! Note + Performing a switchover and switch back to the original primary may not preserve the cascading replication scenario. diff --git a/product_docs/docs/efm/4.1/efm_user/15_configuring_ssl_authentication.mdx b/product_docs/docs/efm/4.1/efm_user/15_configuring_ssl_authentication.mdx new file mode 100644 index 00000000000..d6eba350b5a --- /dev/null +++ b/product_docs/docs/efm/4.1/efm_user/15_configuring_ssl_authentication.mdx @@ -0,0 +1,69 @@ +--- +title: "Configuring SSL Authentication on a Failover Manager Cluster" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.1/configuring_ssl_authentication.html" +--- + + + +The following steps enable SSL authentication for Failover Manager. Note that all connecting clients will be required to use SSL authentication when connecting to any database server within the cluster; you will be required to modify the connection methods currently used by existing clients. + +To enable SSL on a Failover Manager cluster, you must: + +1. Place a `server.crt` and `server.key` file in the `data` directory (under your Advanced Server installation). You can purchase a certificate signed by an authority, or create your own self-signed certificate. For information about creating a self-signed certificate, see the PostgreSQL core documentation at: + + + +2. Modify the `postgresql.conf` file on each database within the Failover Manager cluster, enabling SSL: + + ```text + ssl=on + ``` + +> After modifying the postgresql.conf file, you must restart the server. + +1. Modify the `pg_hba.conf` file on each node of the Failover Manager cluster, adding the following line to the beginning of the file: + + ```text + hostnossl all all all reject + ``` + +> The line instructs the server to reject any connections that are not using SSL authentication; this enforces SSL authentication for any connecting clients. For information about modifying the pg_hba.conf file, see the PostgreSQL core documentation at: +> +> > + +1. After placing the server.crt and server.key file in the data directory, convert the certificate to a form that Java understands; you can use the command: + + ```text + openssl x509 -in server.crt -out server.crt.der -outform der + ``` + +> For more information, visit: +> +> > + +1. Then, add the certificate to the Java trusted certificates file: + + ```text + keytool -keystore $JAVA_HOME/lib/security/cacerts -alias -import -file server.crt.der + ``` + +> Where +> +> > `$JAVA_HOME` is the home directory of your Java installation. +> > +> > <alias_name> can be any string, but must be unique for each certificate. +> > +> > You can use the `keytool` command to review a list of the available certificates or retrieve information about a specific certificate. For more information about using the keytool command, enter: +> > +> > > ```text +> > > man keytool +> > > ``` +> +> The certificate from each database server must be imported into the trusted certificates file of each agent. Note that the location of the cacerts file may vary on each system. For more information, visit: +> +> > + +1. Modify the [efm.properties file](04_configuring_efm/01_cluster_properties/#jdbc_sslmode) on each node within the cluster, setting the `jdbc.sslmode` property. diff --git a/product_docs/docs/efm/4.1/efm_user/images/cascading_replication.png b/product_docs/docs/efm/4.1/efm_user/images/cascading_replication.png new file mode 100644 index 00000000000..41e86182b03 Binary files /dev/null and b/product_docs/docs/efm/4.1/efm_user/images/cascading_replication.png differ diff --git a/product_docs/docs/efm/4.1/efm_user/images/cascading_replication1.png b/product_docs/docs/efm/4.1/efm_user/images/cascading_replication1.png new file mode 100644 index 00000000000..f606c9ee850 Binary files /dev/null and b/product_docs/docs/efm/4.1/efm_user/images/cascading_replication1.png differ diff --git a/product_docs/docs/efm/4.1/efm_user/images/edb_logo.png b/product_docs/docs/efm/4.1/efm_user/images/edb_logo.png new file mode 100755 index 00000000000..b83a03f80c5 Binary files /dev/null and b/product_docs/docs/efm/4.1/efm_user/images/edb_logo.png differ diff --git a/product_docs/docs/efm/4.1/efm_user/images/failover_manager_overview.png b/product_docs/docs/efm/4.1/efm_user/images/failover_manager_overview.png new file mode 100644 index 00000000000..0a511e05ab0 Binary files /dev/null and b/product_docs/docs/efm/4.1/efm_user/images/failover_manager_overview.png differ diff --git a/product_docs/docs/efm/4.1/efm_user/images/placeholder.png b/product_docs/docs/efm/4.1/efm_user/images/placeholder.png new file mode 100755 index 00000000000..b83a03f80c5 Binary files /dev/null and b/product_docs/docs/efm/4.1/efm_user/images/placeholder.png differ diff --git a/product_docs/docs/efm/4.1/efm_user/images/str_replication_dashboard_master.png b/product_docs/docs/efm/4.1/efm_user/images/str_replication_dashboard_master.png new file mode 100644 index 00000000000..dc843892554 Binary files /dev/null and b/product_docs/docs/efm/4.1/efm_user/images/str_replication_dashboard_master.png differ diff --git a/product_docs/docs/efm/4.1/efm_user/images/str_replication_dashboard_standby.png b/product_docs/docs/efm/4.1/efm_user/images/str_replication_dashboard_standby.png new file mode 100644 index 00000000000..aef1e17ad33 Binary files /dev/null and b/product_docs/docs/efm/4.1/efm_user/images/str_replication_dashboard_standby.png differ diff --git a/product_docs/docs/efm/4.1/efm_user/images/supported_scenarios_master_agent_exits.png b/product_docs/docs/efm/4.1/efm_user/images/supported_scenarios_master_agent_exits.png new file mode 100644 index 00000000000..ac9726da488 Binary files /dev/null and b/product_docs/docs/efm/4.1/efm_user/images/supported_scenarios_master_agent_exits.png differ diff --git a/product_docs/docs/efm/4.1/efm_user/images/supported_scenarios_master_db_down.png b/product_docs/docs/efm/4.1/efm_user/images/supported_scenarios_master_db_down.png new file mode 100644 index 00000000000..0eac0491e89 Binary files /dev/null and b/product_docs/docs/efm/4.1/efm_user/images/supported_scenarios_master_db_down.png differ diff --git a/product_docs/docs/efm/4.1/efm_user/images/supported_scenarios_node_becomes_isolated.png b/product_docs/docs/efm/4.1/efm_user/images/supported_scenarios_node_becomes_isolated.png new file mode 100644 index 00000000000..ac591153eef Binary files /dev/null and b/product_docs/docs/efm/4.1/efm_user/images/supported_scenarios_node_becomes_isolated.png differ diff --git a/product_docs/docs/efm/4.1/efm_user/images/supported_scenarios_standby_agent_exits.png b/product_docs/docs/efm/4.1/efm_user/images/supported_scenarios_standby_agent_exits.png new file mode 100644 index 00000000000..1997c09fdf6 Binary files /dev/null and b/product_docs/docs/efm/4.1/efm_user/images/supported_scenarios_standby_agent_exits.png differ diff --git a/product_docs/docs/efm/4.1/efm_user/images/supported_scenarios_standby_db_down.png b/product_docs/docs/efm/4.1/efm_user/images/supported_scenarios_standby_db_down.png new file mode 100644 index 00000000000..dc9abefcead Binary files /dev/null and b/product_docs/docs/efm/4.1/efm_user/images/supported_scenarios_standby_db_down.png differ diff --git a/product_docs/docs/efm/4.1/efm_user/images/supported_scenarios_witness_agent_exits.png b/product_docs/docs/efm/4.1/efm_user/images/supported_scenarios_witness_agent_exits.png new file mode 100644 index 00000000000..1c02dc66805 Binary files /dev/null and b/product_docs/docs/efm/4.1/efm_user/images/supported_scenarios_witness_agent_exits.png differ diff --git a/product_docs/docs/efm/4.1/efm_user/index.mdx b/product_docs/docs/efm/4.1/efm_user/index.mdx new file mode 100644 index 00000000000..73312a18777 --- /dev/null +++ b/product_docs/docs/efm/4.1/efm_user/index.mdx @@ -0,0 +1,26 @@ +--- +title: "EDB Failover Manager" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.1/whats_new.html" + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.1/genindex.html" + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.1/conclusion.html" + - "/edb-docs/d/edb-postgres-failover-manager/user-guides/user-guide/4.1/index.html" +--- + +**EDB Failover Manager** + +EDB Postgres Failover Manager (EFM) is a high-availability module from EnterpriseDB that enables a Postgres primary node to automatically failover to a Standby node in the event of a software or hardware failure on the primary. + +This guide provides information about installing, configuring and using Failover Manager . For information about the platforms and versions supported by Failover Manager , visit the EnterpriseDB website at: + + + +This document uses Postgres to mean either the PostgreSQL or EDB Postgres Advanced Server database. + +
+ +whats_new failover_manager_overview installing_efm configuring_efm using_efm monitoring_efm_cluster using_efm_utility controlling_efm_service controlling_logging notifications supported_scenarios upgrading_existing_cluster troubleshooting configuring_streaming_replication configuring_ssl_authentication conclusion + +
diff --git a/product_docs/docs/efm/4.1/efm_v4.1_documentation.pdf b/product_docs/docs/efm/4.1/efm_v4.1_documentation.pdf new file mode 100644 index 00000000000..aba462d5e51 Binary files /dev/null and b/product_docs/docs/efm/4.1/efm_v4.1_documentation.pdf differ diff --git a/product_docs/docs/efm/4.1/index.mdx b/product_docs/docs/efm/4.1/index.mdx new file mode 100644 index 00000000000..0cdfe7b68a4 --- /dev/null +++ b/product_docs/docs/efm/4.1/index.mdx @@ -0,0 +1,14 @@ +--- +title: "EDB Postgres Failover Manager" +directoryDefaults: + description: "EDB Postgres Failover Manager Version 4.1 Documentation and release notes. PostgreSQL replication and failover manager for achieving high availability." +navigation: + - "#Getting Started" + - efm_quick_start + - "#Guides" + - efm_pgpool_ha_guide + - efm_user +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/p/edb-postgres-failover-manager/4.1" +--- diff --git a/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/01_introduction.mdx b/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/01_introduction.mdx new file mode 100644 index 00000000000..05d847a6e66 --- /dev/null +++ b/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/01_introduction.mdx @@ -0,0 +1,56 @@ +--- +title: "Architecture Overview" +--- + +This guide explains how to configure Failover Manager and Pgpool best to leverage the benefits that they provide for Advanced Server. Using the reference architecture described in the Architecture section, you can learn how to achieve high availability by implementing an automatic failover mechanism (with Failover Manager) while scaling the system for larger workloads and an increased number of concurrent clients with read-intensive or mixed workloads to achieve horizontal scaling/read-scalability (with Pgpool). + +The architecture described in this document has been developed and tested for EFM 4.2, EDB pgPool 4.2, and Advanced Server 13. + +Documentation for Advanced Server and Failover Manager are available from EnterpriseDB at: + + + +Documentation for pgPool-II can be found at: + + + +## Failover Manager Overview + +Failover Manager is a high-availability module that monitors the health of a Postgres streaming replication cluster and verifies failures quickly. When a database failure occurs, Failover Manager can automatically promote a streaming replication Standby node into a writable Primary node to ensure continued performance and protect against data loss with minimal service interruption. + +**Basic EFM Architecture Terminology** + +A Failover Manager cluster is comprised of EFM processes that reside on the following hosts on a network: + +- A **Primary** node is the Primary database server that is servicing database clients. +- One or more **Standby nodes** are streaming replication servers associated with the Primary node. +- The **Witness node** confirms assertions of either the Primary or a Standby in a failover scenario. If, during a failure situation, the Primary finds itself in a partition with half or more of the nodes, it will stay Primary. As such, EFM supports running in a cluster with an even number of agents. + +## Pgpool-II Overview + +Pgpool-II (Pgpool) is an open-source application that provides connection pooling and load balancing for horizontal scalability of SELECT queries on multiple Standbys in EPAS and community Postgres clusters. For every backend, a backend_weight parameter can set the ratio of read traffic to be directed to the backend node. To prevent read traffic on the Primary node, the backend_weight parameter can be set to 0. In such cases, data modification language (DML) queries (i.e., INSERT, UPDATE, and DELETE) will still be sent to the Primary node, while read queries are load-balanced to the Standbys, providing scalability with mixed and read-intensive workloads. + +EnterpriseDB supports the following Pgpool functionality: + +- Load balancing +- Connection pooling +- High availability +- Connection limits + +### PCP Overview + +Pgpool provides an interface called PCP for administrators that performs management operations such as retrieving the status of Pgpool or terminating Pgpool processes remotely. PCP commands are UNIX commands that manipulate Pgpool via the network. + +### Pgpool Watchdog + +`watchdog` is an optional sub process of Pgpool that provides a high availability feature. Features added by `watchdog` include: + +- Health checking of the pgpool service +- Mutual monitoring of other watchdog processes +- Changing leader/Standby state if certain faults are detected +- Automatic virtual IP address assigning synchronous to server switching +- Automatic registration of a server as a Standby during recovery + +More information about the `Pgpool watchdog` component can be found at: + + diff --git a/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/02_architecture.mdx b/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/02_architecture.mdx new file mode 100644 index 00000000000..d2ae10a0d3a --- /dev/null +++ b/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/02_architecture.mdx @@ -0,0 +1,28 @@ +--- +title: "Architecture" +--- + +![A typical EFM and Pgpool configuration](images/edb_ha_architecture.png) + +The sample architecture diagram shows four nodes as described in the table below: + +| **Systems** | **Components** | +| ------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Primary Pgpool/EFM witness node | The Primary Pgpool node will only run Pgpool, and EFM witness, as such leaving as much resources available to Pgpool as possible. During normal runmode (no Pgpool Failovers), the Primary Pgpool node has attached the Virtual IP address, and all applications connect through the Virtual IP address to Pgpool. Pgpool will forward all write traffic to the Primary Database node, and will balance all read across all Standby nodes.On the Primary Pgpool node, the EFM witness process ensures that a minimum quota of three EFM agents remains available even if one of the database nodes fails. Some examples are when a node is already unavailable due to maintenance, or failure, and another failure occurs. | +| Primary Database node | The Primary Database node will only run Postgres (Primary)and EFM, leaving all resources to Postgres. Read/Write traffic (i.e., INSERT, UPDATE, DELETE) is forwarded to this node by the Primary Pgpool node. | +| Standby nodes | The Standby nodes are running Postgres (Standby), EFM and an inactive Pgpool process. In case of a Primary database failure, EFM will promote Postgres on one of these Standby nodes to handle read-write traffic. In case of a Primary Pgpool failure, the Pgpool watchdog will activate Pgpool on one of the Standby nodes which will attach the VIP, and handle the forwarding of the application connections to the Database nodes. Note that in a double failure situation (both the Primary Pgpool node and the Primary Database node are in failure), both of these Primary processes might end up on the same node. | + +This architecture: + +- Achieves high availability by providing two Standbys that can be promoted in case of a Primary Postgres node failure. +- Achieves high availability by providing at least three Pgpool processes in a watchdog configuration. +- Increases performance with mixed and read-intensive workloads by introducing increased read scalability with more than one Standby for load balancing. +- Reduces load on the Primary database node by redirecting read-only traffic with the Primary pgpool node. +- Prevents resource contention between Pgpool and Postgres on the Primary Database node. By not running Pgpool on the Primary database node, the Primary Postgres process can utilize as much resources as possible. +- Prevents resource contention between pgpool and Postgres on the Primary Pgpool node. By not running Standby databases on the Primary Pgpool node, Pgpool can utilize as many resources as possible. +- Optionally, synchronous replication can be set up to achieve near-zero data loss in a failure event. + +!!! Note + The architecture also allows us to completely separate 3 virtual machines running Postgres from 3 virtual machines running Pgpool. This kind of setup requires 2 extra virtual machines, but it is a better choice if you want to prevent resource contention between Pgpool and Postgres in Failover scenarios. In this setup, the architecture can run without an extra 7th node running the EFM Witness Process. To increase failure resolution efm witness agents could be deployed on the Pgpool servers. + +![Deployment of EFM and Pgpool on separate virtual machines](images/edb_ha_architecture_separate_VM.png) diff --git a/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/03_components_ha_pgpool.mdx b/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/03_components_ha_pgpool.mdx new file mode 100644 index 00000000000..e1e33d397a2 --- /dev/null +++ b/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/03_components_ha_pgpool.mdx @@ -0,0 +1,218 @@ +--- +title: "Implementing High Availability with Pgpool" +--- + +Failover Manager monitors the health of Postgres nodes; in the event of a database failure, Failover Manager performs an automatic failover to a Standby node. Note that Pgpool does not monitor the health of backend nodes and will not perform failover to any Standby nodes. + +## Configuring Failover Manager + +Failover Manager provides functionality that will remove failed database nodes from Pgpool load balancing; it can also re-attach nodes to Pgpool when returned to the Failover Manager cluster. To configure EFM for high availability using Pgpool, you must set the following properties in the cluster properties file: + +`pgpool.enable` = `true/false` + +`pcp.user` = `User that would be invoking PCP commands` + +`pcp.host` = `Virtual IP that would be used by pgpool. Same as pgpool parameter 'delegate_IP’` + +`pcp.port` = `The port on which pgpool listens for pcp commands` + +`pcp.pass.file` = `Absolute path of PCPPASSFILE` + +`pgpool.bin` = `Absolute path of pgpool bin directory` + +## Configuring Pgpool + +The section lists the configuration of some important parameters in the `pgpool.conf` file to integrate the Pgpool-II with EFM. + +**Backend node setting** + +There are three PostgreSQL backend nodes, one Primary and two Standby nodes. Configure using `backend_*` configuration parameters in `pgpool.conf`, and use the equal backend weights for all nodes. This will make the read queries to be distributed equally among all nodes. + +```text +backend_hostname0 = ‘server1_IP' +backend_port0 = 5444 +backend_weight0 = 1 +backend_flag0 = 'DISALLOW_TO_FAILOVER' + +backend_hostname1 = ‘server2_IP' +backend_port1 = 5444 +backend_weight1 = 1 +backend_flag1 = 'DISALLOW_TO_FAILOVER' + +backend_hostname2 = ‘server3_IP' +backend_port2 = 5444 +backend_weight2 = 1 +backend_flag2 = 'DISALLOW_TO_FAILOVER' +``` + +**Enable Load-balancing and streaming replication mode** + +Set the following configuration parameter in the `pgpool.conf` file to enable load balancing and streaming replication mode: + +- For Pgpool version 4.2: + + ```text + backend_clustering_mode = 'streaming_replication' + load_balance_mode = on + ``` + +- For Pgpool versions prior to 4.2: + + ```text + master_slave_mode = on + master_slave_sub_mode = 'stream' + load_balance_mode = on + ``` + +**Disable health-checking and failover** + +Health-checking and failover must be handled by EFM and hence, these must be disabled on Pgpool-II side. To disable the health-check and failover on pgpool-II side, assign the following values: + +```text +health_check_period = 0 +fail_over_on_backend_error = off +failover_if_affected_tuples_mismatch = off +failover_command = ‘’ +failback_command = ‘’ +``` + +Ensure the following while setting up the values in the `pgpool.conf` file: + +- Keep the value of wd_priority in pgpool.conf different on each node. The node with the highest value gets the highest priority. +- The properties backend_hostname0 , backend_hostname1, backend_hostname2 and so on are shared properties (in EFM terms) and should hold the same value for all the nodes in pgpool.conf file. +- Update the correct interface value in *if\_* \* and arping cmd props in the pgpool.conf file. +- Add the properties heartbeat_destination0, heartbeat_destination1, heartbeat_destination2 etc. as per the number of nodes in pgpool.conf file on every node. Here heartbeat_destination0 should be the ip/hostname of the local node. + +**Setting up PCP** + +Script uses the PCP interface, So we need to set up the PCP and .PCPPASS file to allow PCP connections without password prompt. + +setup PCP: + +setup PCPPASS: + +Note that the load-balancing is turned on to ensure read scalability by distributing read traffic across the standby nodes + +The health checking and error-triggered backend failover have been turned off, as Failover Manager will be responsible for performing health checks and triggering failover. It is not advisable for Pgpool to perform health checking in this case, so as not to create a conflict with Failover Manager, or prematurely perform failover. + +Finally, `search_primary_node_timeout` has been set to a low value to ensure prompt recovery of Pgpool services upon an Failover Manager-triggered failover. + +## Virtual IP Addresses + +Both Pgpool-II and Failover Manager provide functionality to employ a virtual IP for seamless failover. While both provide this capability, the pgpool-II leader is the process that receives the Application connections through the Virtual IP. As in this design, such Virtual IP management is performed by the Pgpool-II watchdog system. EFM VIP has no beneficial effect in this design and it must be disabled. + +Note that in a failure situation of the active instance of Pgpool (The Primary Pgpool Server in our sample architecture), the next available Standby Pgpool instance (according to watchdog priority) will be activated and takes charge as the leader Pgpool instance. + +## Configuring Pgpool-II Watchdog + +Watchdog provides the high availability of Pgpool-II nodes. This section lists the configuration required for watchdog on each Pgpool-II node. + + +### Configuring Pgpool-II Watchdog for Pgpool version 4.2 + +Unlike 4.1 or prior versions, you need to keep all the watchdog parameters identical on all the hosts while configuring Pgpool version 4.2. + +The following configuration parameters enable and configure the watchdog. The interval and retry values can be adjusted depending upon the requirements and testing results. + +```text +use_watchdog = on # enable watchdog +delegate_IP = ‘Virtual IP address’ +wd_lifecheck_method = 'heartbeat' +wd_interval = 10 # we can lower this value for quick detection +wd_life_point = 3 +# virtual IP control +ifconfig_path = '/sbin' # ifconfig command path +if_up_cmd = 'ifconfig eth0:0 inet $_IP_$ netmask 255.255.255.0' + # startup delegate IP command +if_down_cmd = 'ifconfig eth0:0 down' # shutdown delegate IP command +arping_path = '/usr/sbin' # arping command path +hostname0 = 'node-1' +pgpool_port0 = 9999 +wd_port0 = 9000 + +hostname1 = 'node-2' +pgpool_port1 = 9999 +wd_port1 = 9000 + +heartbeat_hostname0 = 'node-1' +heartbeat_port0 = 9694 +heartbeat_device0 = '' + +heartbeat_hostname1 = 'node-2' +heartbeat_port1 = 9694 +heartbeat_device1 = '' +``` + +Since some of the parameters would be same on all the nodes, you need to specify a mechanism to distinguish between local and remote watchdog nodes. For this purpose, you can create `pgpool_node_id` file in `pgpool.conf` directory with value 0,1, and 2 on node-1, node-2,node-3 respectively. The ownership and permissions for this file would be the same as `pgpool.conf` file. + +The following is an example of the file on the first node: + +```text +[root@ONE efm-4.2]}> cat /etc/sysconfig/edb/pgpool4.2/pgpool_node_id +0 +[root@ONE efm-4.2]}> +``` + +### Configuring Pgpool-II Watchdog for Pgpool versions prior to 4.2 + +**Common watchdog configurations on all Pgpool nodes** + +The following configuration parameters enable and configure the watchdog. The interval and retry values can be adjusted depending upon the requirements and testing results. + +```text +use_watchdog = on # enable watchdog +wd_port = 9000 # watchdog port, can be changed +delegate_IP = ‘Virtual IP address’ +wd_lifecheck_method = 'heartbeat' +wd_interval = 10 # we can lower this value for quick detection +wd_life_point = 3 +# virtual IP control +ifconfig_path = '/sbin' # ifconfig command path +if_up_cmd = 'ifconfig eth0:0 inet $_IP_$ netmask 255.255.255.0' + # startup delegate IP command +if_down_cmd = 'ifconfig eth0:0 down' # shutdown delegate IP command +arping_path = '/usr/sbin' # arping command path +``` + +!!! Note + Replace the value of eth0 with the network interface on your system. See [Chapter 5](05_appendix_b/#configuration-for-number-of-connections-and-pooling) for tuning the number of connections, and pooling configuration. + +**Watchdog configurations on server 2** + +```text +other_pgpool_hostname0 = 'server 3 IP/hostname' +other_pgpool_port0 = 9999 +other_wd_port0 = 9000 +other_pgpool_hostname1 = 'server 4 IP/hostname' +other_pgpool_port1 = 9999 +other_wd_port1 = 9000 +wd_priority = 1 +``` + +**Watchdog configurations on server 3** + +```text +other_pgpool_hostname0 = 'server 2 IP/hostname' +other_pgpool_port0 = 9999 +other_wd_port0 = 9000 +other_pgpool_hostname1 = 'server 4 IP/hostname' +other_pgpool_port1 = 9999 +other_wd_port1 = 9000 +wd_priority = 3 +``` + +**Watchdog configurations on server 4** + +```text +other_pgpool_hostname0 = 'server 2 IP/hostname' +other_pgpool_port0 = 9999 +other_wd_port0 = 9000 +other_pgpool_hostname1 = 'server 3 IP/hostname' +other_pgpool_port1 = 9999 +other_wd_port1 = 9000 +wd_priority = 5 # use high watchdog priority on server 4 +``` + +!!! Note + Replace the value of eth0 with the network interface on your system. See [Chapter 5](05_appendix_b/#configuration-for-number-of-connections-and-pooling) for tuning the number of connections, and pooling configuration. + diff --git a/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/04_appendix_a.mdx b/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/04_appendix_a.mdx new file mode 100644 index 00000000000..959a44d8bf3 --- /dev/null +++ b/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/04_appendix_a.mdx @@ -0,0 +1,66 @@ +--- +title: "EFM Pgpool Integration Using Azure Network Load Balancer" +--- + + + +This section describes a specific use case for EFM Pgpool integration, where the database, EFM, and Pgpool are installed on CentOS 8 Virtual Machines in Azure. For this specific use case, Azure Load Balancer (LNB) has been used to distribute the traffic amongst all the active Pgpool Instances instead of directing the traffic using Pgpool VIP. + +![Architecture diagram for EFM and Pgpool integration using Azure Load Balancer](images/EFM_PgPool_Azure.png) + +**Step 1 (Installation)**: + +Install and configure Advanced Server database, EFM, and Pgpool on Azure Virtual Machines as following: + +| **Systems** | **Components** | +| ----------- | ------------------------------------------------------------------------------ | +| Primary | Primary node running Advanced Server 13 and Failover Manager 4.2 | +| Standby 1 | Standby node running Advanced Server 13, Failover Manager 4.2, and Pgpool 4.2. | +| Standby 2 | Standby node running Advanced Server 13, Failover Manager 4.2, and Pgpool 4.2. | +| Witness | Witness node running Failover Manager 4.2 and Pgpool 4.2. | + +**Step 2 (Pgpool configuration)**: + +Configure Pgpool as per the steps given in chapter 3 (except for delegate_ip, which should be left empty in this architecture). + +**Step 3 (Azure Load Balancer configuration)**: + +You need to do the following configuration for using Azure NLB: + +**Networking**: You need to ensure the following settings for Network Load Balancer and for each of the virtual machines: Assign Public IP as well as private IP to the NLB, and only private IP to the virtual machines. The application server should connect to the NLB over public IP and NLB in turn should connect to the virtual machines over private IPs. + +In the current scenario, following are the IP addresses assigned to each component: + +- Public IP of NLB : 40.76.240.33 (pcp.host) +- Private IP of Primarydb : 172.16.1.3 (note that this is not part of the backend pool of the Load Balancer) +- Private IP of Standby 1 : 172.16.1.4 +- Private IP of Standby 2 : 172.16.1.5 +- Private IP of witness node: 172.16.1.6 + +Ensure that the ports required to run the database, EFM, and Pgpool are open for communication. Following is the list of default ports for each of these component (you can customize the ports for your environment): + +- Database: 5444 +- EFM: 7800 (bind.address) +- Pgpool: 9000, 9694, 9898, 9999 + +**Backend pool**: Create a Backend pool consisting of all the 3 virtual machines running Pgpool instances. Use the private IPs of the virtual machines to create the Backend pool. + +![Backend pool in Azure console](images/backend_pools.png) + +**Health Probe**: Add a health probe to check if the Pgpool instance is available on the virtual machines. The health probe periodically pings the virtual machines of the Backend pool on port 9999. If it does not receive any response from any of the virtual machines, it assumes that the Pgpool instance is not available and hence stops sending traffic towards that particular machine. + +![Health probes in Azure console](images/health_probes.png) + +**Load balancing rules**: Add two Load balancing rules - one each for port 9898 and port 9999. These rules should ensure that the network traffic coming towards that particular port gets distributed evenly among all the virtual machines present in the Backend pool. + +![Load balancing rules in Azure console](images/load_balancing_rules.png) + +1. Rule created for port 9999 (i.e. PCP port) + +![Load balancing rule for port 9999](images/rule_port_9898.png) + +1. Rule created for port 9999 (i.e. Pgpool port) + +![Load balancing rule for port 9999](images/rule_port_9999.png) + +After configuration of the above-mentioned setup, you can connect to Postgres on the IP address of the Network Load Balancer on port 9999. If a failure occurs on the Primary database server, EFM will promote a new Primary and then reconfigure Pgpool to redistribute traffic. If any one of the Pgpool processes is not available to accept traffic anymore, the Network Load Balancer will redistribute all the traffic to the remaining two Pgpool processes. Make sure that listen_backlog_multiplier is tuned to compensate for the higher number of connections in case of failover. diff --git a/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/05_appendix_b.mdx b/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/05_appendix_b.mdx new file mode 100644 index 00000000000..785a9efa581 --- /dev/null +++ b/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/05_appendix_b.mdx @@ -0,0 +1,13 @@ +--- +title: "Configuration for Number of Connections and Pooling" +--- + +Pgpool has some configuration to tune the pooling and connection processing. Depending on this configuration, also the Postgres configuration for `max_connections` should be set to make sure all connections can be accepted as required. Furthermore, note that the Cloud Architecture works with active/active instances, which requires to spread `num_init_children` over all Pgpool instances (divide the normally used value by the number of active instances). The below text describes the effect of changing the configuration, and advises values for both the on-premise and the Cloud architecture. + +**max_pool**: Generally, it is advised to set `max_pool` to 1. Alternatively, for applications with a lot of reconnects, `max_pool` can be set to the number of distinct combinations of users, databases and connection options for the application connections. All but one connection in the pool would be stale connections, which consumes a connection slot from Postgres, without adding to performance. It is therefore advised not to configure `max_pool` beyond 4 to preserve a healthy ratio between active and stale connections. As an example, for an application which constantly reconnects and uses 2 distinct users both connecting to their own database, set it to 2. If both users would be able to connect to both databases set it to 4. Note that increasing `max_pool` requires to tune down `num_init_children` in Pgpool, or tune up `max_connections` in Postgres. + +**num_init_children**: It is advised to set `num_init_children` to the number of connections that could be running active in parallel, but the value should be divided by the number of active Pgpool-II instances (one with the on-premise architecture, and all instances for the cloud architecture). As an example: In an architecture with 3 Pgpool instances, to allow the application to have 100 active connections in parallel, set `num_init_children` to 100 for the on-premise architecture, and set `num_init_children` to 33 for the cloud architecture. Note that increasing `num_init_children` generally requires to tune up `max_connections` in Postgres. + +**listen_backlog_multiplier**: Can be set to multiply the number of open connections (as perceived by the application) with the number of active connections (`num_init_children`). As an example, when the application might open 500 connections of which 100 should be active in parallel, with the on-premise architecture, `num_init_children` should be set to 100, and `listen_backlog_multiplier` should be set to 4. This setup can process 100 connections active in parallel, and another 400 (`listen_backlog_multiplier*num_init_children`) connections will be queued before connections will be blocked. The application would perceive a total of 500 open connections, and Postgres would process the load of 100 connections maximum at all times. Note that increasing `listen_backlog_multiplier` only causes the application to perceive more connections, but will not increase the number of parallel active connections (which is determined by `num_init_children`). + +**max_connections**: It is advised to set `max_connections` in Postgres higher than `[number of active pgpool instances]*[max_pool]*[num_init_children] + [superuser_reserved_connections] (Postgres)`. As an example: in the on-premise setup with 3 instances active/passive, `max_pool` set to 2, `num_init_children` set to 100, and `superuser_reserved_connections (Postgres)` set to 5, Postgres `max_connections` should be set equal or higher then `[1*2*100+5]` which is 205 connections or higher. A similar setup in the cloud setup would run with 3 active instances, `max_pool` set to 2, `num_init_children` set to 33, and `superuser_reserved_connections (Postgres)` set to 5, in which case Postgres `max_connections` should be set equal or higher than `[3*2*33+5]` which is 203 or higher. Note that configuring below the advised setting can cause issues opening new connections, and in a combination with `max_pool` can cause unexpected behaviour (low or no active connections but still connection issues due to stale pooled connections using connection slots from Postgres. For more information on the relation between `num_init_children`, `max_pool` and `max_connections`, see this background information. diff --git a/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/images/EDB_logo.png b/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/images/EDB_logo.png new file mode 100755 index 00000000000..739c43dccc4 Binary files /dev/null and b/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/images/EDB_logo.png differ diff --git a/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/images/EFM_PgPool_Azure.png b/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/images/EFM_PgPool_Azure.png new file mode 100644 index 00000000000..6a183c39450 Binary files /dev/null and b/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/images/EFM_PgPool_Azure.png differ diff --git a/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/images/backend_pools.png b/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/images/backend_pools.png new file mode 100644 index 00000000000..9ec8e018a7b Binary files /dev/null and b/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/images/backend_pools.png differ diff --git a/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/images/edb_ha_architecture.png b/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/images/edb_ha_architecture.png new file mode 100644 index 00000000000..fe4ff379e29 Binary files /dev/null and b/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/images/edb_ha_architecture.png differ diff --git a/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/images/edb_ha_architecture1.png b/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/images/edb_ha_architecture1.png new file mode 100755 index 00000000000..a496f59b161 Binary files /dev/null and b/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/images/edb_ha_architecture1.png differ diff --git a/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/images/edb_ha_architecture_separate_VM.png b/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/images/edb_ha_architecture_separate_VM.png new file mode 100644 index 00000000000..117ff2973b8 Binary files /dev/null and b/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/images/edb_ha_architecture_separate_VM.png differ diff --git a/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/images/edb_logo.svg b/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/images/edb_logo.svg new file mode 100755 index 00000000000..74babf2f8da --- /dev/null +++ b/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/images/edb_logo.svg @@ -0,0 +1,56 @@ + + + + +logo + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/images/failover_manager_overview.png b/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/images/failover_manager_overview.png new file mode 100755 index 00000000000..9c79c7bdfc9 Binary files /dev/null and b/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/images/failover_manager_overview.png differ diff --git a/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/images/health_probes.png b/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/images/health_probes.png new file mode 100644 index 00000000000..567f71828b3 Binary files /dev/null and b/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/images/health_probes.png differ diff --git a/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/images/load_balancing_rules.png b/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/images/load_balancing_rules.png new file mode 100644 index 00000000000..41ca798f440 Binary files /dev/null and b/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/images/load_balancing_rules.png differ diff --git a/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/images/placeholder.png b/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/images/placeholder.png new file mode 100755 index 00000000000..b83a03f80c5 Binary files /dev/null and b/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/images/placeholder.png differ diff --git a/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/images/rule_port_9898.png b/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/images/rule_port_9898.png new file mode 100644 index 00000000000..a69326a55f3 Binary files /dev/null and b/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/images/rule_port_9898.png differ diff --git a/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/images/rule_port_9999.png b/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/images/rule_port_9999.png new file mode 100644 index 00000000000..aebd897f798 Binary files /dev/null and b/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/images/rule_port_9999.png differ diff --git a/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/index.mdx b/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/index.mdx new file mode 100644 index 00000000000..66783b12538 --- /dev/null +++ b/product_docs/docs/efm/4.2/efm_pgpool_ha_guide/index.mdx @@ -0,0 +1,11 @@ +--- +title: "High Availability & Scalability Guide" +--- + +Since high-availability and read scalability are not part of the core feature set of EDB Postgres Advanced Server, Advanced Server relies on external tools to provide this functionality. This document focuses on the functionality provided by EDB Failover Manager and Pgpool-II, and discusses the implications of a high-availability architecture formed around these tools. + +
+ +introduction architecture components_ha_pgpool appendix_a appendix_b conclusion + +
diff --git a/product_docs/docs/efm/4.2/efm_quick_start/images/edb_logo.png b/product_docs/docs/efm/4.2/efm_quick_start/images/edb_logo.png new file mode 100755 index 00000000000..b83a03f80c5 Binary files /dev/null and b/product_docs/docs/efm/4.2/efm_quick_start/images/edb_logo.png differ diff --git a/product_docs/docs/efm/4.2/efm_quick_start/images/edb_logo.svg b/product_docs/docs/efm/4.2/efm_quick_start/images/edb_logo.svg new file mode 100755 index 00000000000..74babf2f8da --- /dev/null +++ b/product_docs/docs/efm/4.2/efm_quick_start/images/edb_logo.svg @@ -0,0 +1,56 @@ + + + + +logo + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/product_docs/docs/efm/4.2/efm_quick_start/images/failover_manager_overview.png b/product_docs/docs/efm/4.2/efm_quick_start/images/failover_manager_overview.png new file mode 100755 index 00000000000..9c79c7bdfc9 Binary files /dev/null and b/product_docs/docs/efm/4.2/efm_quick_start/images/failover_manager_overview.png differ diff --git a/product_docs/docs/efm/4.2/efm_quick_start/images/placeholder.png b/product_docs/docs/efm/4.2/efm_quick_start/images/placeholder.png new file mode 100755 index 00000000000..b83a03f80c5 Binary files /dev/null and b/product_docs/docs/efm/4.2/efm_quick_start/images/placeholder.png differ diff --git a/product_docs/docs/efm/4.2/efm_quick_start/index.mdx b/product_docs/docs/efm/4.2/efm_quick_start/index.mdx new file mode 100644 index 00000000000..f5085386aab --- /dev/null +++ b/product_docs/docs/efm/4.2/efm_quick_start/index.mdx @@ -0,0 +1,141 @@ +--- +title: "Creating a Failover Manager Cluster" +--- + +EDB Postgres Failover Manager (Failover Manager) is a high-availability module from EnterpriseDB that enables a Postgres Primary node to automatically failover to a Standby node in the event of a software or hardware failure on the Primary. + +This quick start guide describes configuring a Failover Manager cluster in a test environment. You should read and understand the [EDB Failover Manager User's Guide](/efm/latest/) before configuring Failover Manager for a production deployment. + +You must perform some basic installation and configuration steps before performing this tutorial: + +- You must install and initialize a database server on one primary and one or two standby nodes; for information about installing Advanced Server, visit: + + [https://www.enterprisedb.com/docs/epas/latest/](https://www.enterprisedb.com/docs/epas/latest/) + +- Postgres streaming replication must be configured and running between the primary and standby nodes. For detailed information about configuring streaming replication, visit: + + . + +- You must also install Failover Manager on each primary and standby node. During Advanced Server installation, you configured an EnterpriseDB repository on each database host. You can use the EnterpriseDB repository and the `yum install` command to install Failover Manager on each node of the cluster: + + ```text + yum install edb-efm42 + ``` + +During the installation process, the installer will create a user named `efm` that has sufficient privileges to invoke scripts that control the Failover Manager service for clusters owned by `enterprisedb` or `postgres`. The example that follows creates a cluster named `efm`. + +Start the configuration process on a primary or standby node. Then, copy the configuration files to other nodes to save time. + +**Step 1: Create Working Configuration Files** + +Copy the provided sample files to create EFM configuration files, and correct the ownership: + +```text +cd /etc/edb/efm-4.2 + +cp efm.properties.in efm.properties + +cp efm.nodes.in efm.nodes + +chown efm:efm efm.properties + +chown efm:efm efm.nodes +``` + +**Step 2: Create an Encrypted Password** + +Create the [encrypted password](/efm/latest/efm_user/04_configuring_efm/02_encrypting_database_password/) needed for the properties file: + +```text +/usr/edb/efm-4.2/bin/efm encrypt efm +``` + +Follow the onscreen instructions to produce the encrypted version of your database password. + +**Step 3: Update the efm.properties File** + +The `.properties` file (efm.properties file in this example) contains parameters that specify connection properties and behaviors for your Failover Manager cluster. Modifications to property settings are applied when Failover Manager starts. + +The properties mentioned in this tutorial are the minimal properties required to configure a Failover Manager cluster. If you are configuring a production system, please review the *EDB Failover Manager User Guide* for detailed information about Failover Manager options. + +Provide values for the following properties on all cluster nodes: + +| Property | Description | +| ----------------------- | -------------------------------------------------------------------------------------------------------------------------------- | +| `db.user` | The name of the database user. | +| `db.password.encrypted` | The encrypted password of the database user. | +| `db.port` | The port monitored by the database. | +| `db.database` | The name of the database. | +| `db.service.owner` | The owner of the `data` directory (usually `postgres` or `enterprisedb`). Required only if the database is running as a service. | +| `db.service.name` | The name of the database service (used to restart the server). Required only if the database is running as a service. | +| `db.bin` | The path to the `bin` directory (used for calls to `pg_ctl`). | +| `db.recovery.dir` | The `data` directory in which EFM will find or create the `recovery.conf` file or the `standby.signal` file. | +| `user.email` | An email address at which to receive email notifications (notification text is also in the agent log file). | +| `bind.address` | The local address of the node and the port to use for EFM. The format is: `bind.address=1.2.3.4:7800` | +| `is.witness` | `true` on a witness node and `false` if it is a primary or standby. | +| `ping.server.ip` | If you are running on a network without Internet access, set `ping.server.ip` to an address that is available on your network. | +| `auto.allow.hosts` | On a test cluster, set to `true` to simplify startup; for production usage, consult the user's guide. | +| `stable.nodes.file` | On a test cluster, set to `true` to simplify startup; for production usage, consult the user's guide. | + +**Step 4: Update the efm.nodes File** + +The `.nodes` file (efm.nodes file in this example) is read at startup to tell an agent how to find the rest of the cluster or, in the case of the first node started, can be used to simplify authorization of subsequent nodes. Add the addresses and ports of each node in the cluster to this file. One node will act as the membership coordinator; the list should include at least the membership coordinator's address. For example: + + `1.2.3.4:7800` + + `1.2.3.5:7800` + + `1.2.3.6:7800` + +Please note that the Failover Manager agent will not verify the content of the `efm.nodes` file; the agent expects that some of the addresses in the file cannot be reached (e.g. that another agent hasn’t been started yet). + +**Step 5: Configure the Other Nodes** + +Copy the `efm.properties` and `efm.nodes` files to the `/etc/edb/efm-4.2` directory on the other nodes in your sample cluster. After copying the files, change the file ownership so the files are owned by `efm:efm`. The `efm.properties` file can be the same on every node, except for the following properties: + +- Modify the `bind.address` property to use the node’s local address. +- Set `is.witness` to `true` if the node is a witness node. If the node is a witness node, the properties relating to a local database installation will be ignored. + +**Step 6: Start the EFM Cluster** + +On any node, start the Failover Manager agent. The agent is named `edb-efm-4.2`; you can use your platform-specific service command to control the service. For example, on a CentOS/RHEL 7.x or CentOS/RHEL 8.x host use the command: + +```text +systemctl start edb-efm-4.2 +``` + +On a a CentOS or RHEL 6.x host use the command: + +```text +service edb-efm-4.2 start +``` + +After the agent starts, run the following command to see the status of the single-node cluster. You should see the addresses of the other nodes in the `Allowed node host` list. + +```text +/usr/edb/efm-4.2/bin/efm cluster-status efm +``` + +Start the agent on the other nodes. Run the `efm cluster-status efm` command on any node to see the cluster status. + +If any agent fails to start, see the startup log for information about what went wrong: + +```text +cat /var/log/efm-4.2/startup-efm.log +``` + +**Performing a Switchover** + +If the cluster status output shows that the primary and standby(s) are in sync, you can perform a switchover with the following command: + +```text +/usr/edb/efm-4.2/bin/efm promote efm -switchover +``` + +The command will promote a standby and reconfigure the primary database as a new standby in the cluster. To switch back, run the command again. + +For quick access to online help, you can invoke the following command: + +```text +/usr/edb/efm-4.2/bin/efm --help +``` diff --git a/product_docs/docs/efm/4.2/efm_user/01_whats_new.mdx b/product_docs/docs/efm/4.2/efm_user/01_whats_new.mdx new file mode 100644 index 00000000000..47225bca132 --- /dev/null +++ b/product_docs/docs/efm/4.2/efm_user/01_whats_new.mdx @@ -0,0 +1,15 @@ +--- +title: "What’s New" +--- + + + +The following changes have been made to EDB Postgres Failover Manager to create version 4.2: + +- Support has been added to enable Pgpool EFM integration in a non-sudo mode. +- Failover Manager now provides an option to specify if you do not want to detach the node from the load balancer in case the primary agent fails but the database is still reachable. +- Support has been added to define the priority of standbys applicable for a particular primary node. +- Enhancements have been done to the way standbys are reconfigured so that when archiving is used, standbys will properly follow the new primary. +- A run mode called Eager Failover has been added to the documentation to allow for failovers in situations where previously the old primary would remain active but unmonitored. +- An option to disable the stop-cluster command has been added. + diff --git a/product_docs/docs/efm/4.2/efm_user/02_failover_manager_overview/01_prerequisites.mdx b/product_docs/docs/efm/4.2/efm_user/02_failover_manager_overview/01_prerequisites.mdx new file mode 100644 index 00000000000..d4282deb96d --- /dev/null +++ b/product_docs/docs/efm/4.2/efm_user/02_failover_manager_overview/01_prerequisites.mdx @@ -0,0 +1,101 @@ +--- +title: "Prerequisites" +--- + + + +Before configuring a Failover Manager cluster, you must satisfy the prerequisites described below. + +**Install Java 1.8 (or later)** + +Before using Failover Manager, you must first install Java (version 1.8 or later). Failover Manager is tested with OpenJDK, and we strongly recommend installing that version of Java. [Installation instructions for Java](https://openjdk.java.net/install/) are platform specific. + +**Provide an SMTP Server** + +You can receive notifications from Failover Manager as specified by a user-defined notification script, by email, or both. + +- If you are using email notifications, an SMTP server must be running on each node of the Failover Manager scenario. +- If you provide a value in the script.notification property, you can leave the user.email field blank; an SMTP server is not required. + +If an event occurs, Failover Manager invokes the script (if provided), and can also send a notification email to any email addresses specified in the user.email parameter of the cluster properties file. For more information about using an SMTP server, visit: + +[https://access.redhat.com/site/documentation](https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/s1-email-mta.html) + +**Configure Streaming Replication** + +Failover Manager requires that PostgreSQL streaming replication be configured between the Primary node and the Standby node or nodes. Failover Manager does not support other types of replication. + +On database versions 11 (or prior), unless specified with the `-sourcenode` option, a `recovery.conf` file is copied from a random standby node to the stopped primary during switchover. You should ensure that the paths within the `recovery.conf` file on your standby nodes are consistent before performing a switchover. For more information about the `-sourcenode` option, please see [Promoting a Failover Manager Node](../05_using_efm/#promote_node). + +On database version 12 or later, the `primary_conninfo` and `restore_command` properties are copied from a random standby node to the stopped primary during switchover (unless otherwise specified with the `-sourcenode` option). + +**Modify the pg_hba.conf File** + +You must modify the `pg_hba.conf` file on the Primary and Standby nodes, adding entries that allow communication between the all of the nodes in the cluster. The following example demonstrates entries that might be made to the pg_hba.conf file on the Primary node: + +```text +# access for itself +host fmdb efm 127.0.0.1/32 md5 +# access for standby +host fmdb efm 192.168.27.1/32 md5 +# access for witness +host fmdb efm 192.168.27.34/32 md5 +``` + +Where: + + `efm` specifies the name of a valid database user. + + `fmdb` specifies the name of a database to which the efm user may connect. + +By default, the `pg_hba.conf` file resides in the `data` directory, under your Postgres installation. After modifying the `pg_hba.conf` file, you must reload the configuration file on each node for the changes to take effect. You can use the following command: + + `# systemctl reload edb-as-x` + +Where `x` specifies the Postgres version. + +**Using Autostart for the Database Servers** + +If a Primary node reboots, Failover Manager may detect the database is down on the Primary node and promote a Standby node to the role of Primary. If this happens, the Failover Manager agent on the (rebooted) Primary node will not get a chance to write the `recovery.conf` file; the `recovery.conf` file prevents the database server from starting. If this happens, the rebooted Primary node will return to the cluster as a second Primary node. + +To prevent this, ensure that the Failover Manager agent auto starts before the database server. The agent will start in idle mode, and check to see if there is already a primary in the cluster. If there is a primary node, the agent will verify that a `recovery.conf` or `standby.signal` file exists, and the database will not start as a second primary. + +**Ensure Communication Through Firewalls** + +If a Linux firewall (i.e. iptables) is enabled on the host of a Failover Manager node, you may need to add rules to the firewall configuration that allow tcp communication between the Failover Manager processes in the cluster. For example: + +```text +# iptables -I INPUT -p tcp --dport 7800 -j ACCEPT +/sbin/service iptables save +``` + +The command shown above opens the port 7800. Failover Manager will connect via the port that corresponds to the port specified in the cluster properties file. + +**Ensure that the Database user has Sufficient Privileges** + +The database user specified by the `db.user` property in the `efm.properties` file must have sufficient privileges to invoke the following functions on behalf of Failover Manager: + + `pg_current_wal_lsn()` + + `pg_last_wal_replay_lsn()` + + `pg_wal_replay_resume()` + + `pg_wal_replay_pause()` + + +If the `reconfigure.num.sync` or `reconfigure.sync.primary` property is set to `true`, then: + +- For database version 9.6, the `db.user` needs to be a superuser. + +- For database versions higher than version 9.6, the `db.user` requires `pg_read_all_stats` privilege and permissions to run `pg_reload_conf()`. + +For detailed information about each of these functions, please see the [PostgreSQL core documentation](https://www.postgresql.org/docs/current/index.html). + +The user must also have permissions to read the values of configuration variables; a database superuser can use the PostgreSQL `GRANT` command to provide the permissions needed: + +```text +GRANT pg_read_all_settings TO user_name; +``` + +For more information about `pg_read_all_settings`, please see the [PostgreSQL core documentation](https://www.postgresql.org/docs/current/default-roles.html). diff --git a/product_docs/docs/efm/4.2/efm_user/02_failover_manager_overview/index.mdx b/product_docs/docs/efm/4.2/efm_user/02_failover_manager_overview/index.mdx new file mode 100644 index 00000000000..dca82b2767c --- /dev/null +++ b/product_docs/docs/efm/4.2/efm_user/02_failover_manager_overview/index.mdx @@ -0,0 +1,35 @@ +--- +title: "Failover Manager Overview" +--- + + + +An EDB Postgres Failover Manager (EFM) cluster is comprised of Failover Manager processes that reside on the following hosts on a network: + +- A Primary node - The Primary node is the primary database server that is servicing database clients. +- One or more Standby nodes - A Standby node is a streaming replication server associated with the Primary node. +- A Witness node - The Witness node confirms assertions of either the Primary or a Standby in a failover scenario. A cluster does not need a dedicated witness node if the cluster contains three or more nodes. If you do not have a third cluster member that is a database host, you can add a dedicated Witness node. A cluster may include more than one witness node. + +Traditionally, a cluster is a single instance of Postgres managing multiple databases. In this document, the term cluster refers to a Failover Manager cluster. A Failover Manager cluster consists of a Primary agent, one or more Standby agents, and an optional Witness agent that reside on servers in a cloud or on a traditional network and communicate using the JGroups toolkit. + +![An EFM scenario employing a virtual IP address](../images/failover_manager_overview.png) + +*An EFM scenario employing a virtual IP address* + +When a non-witness agent starts, it connects to the local database and checks the state of the database: + +- If the agent cannot reach the database, it will start in idle mode. +- If it finds that the database is in recovery, the agent assumes the role of standby. +- If the database is not in recovery, the agent assumes the role of primary. + +In the event of a failover, Failover Manager attempts to ensure that the promoted standby is the most up-to-date standby in the cluster; please note that data loss is possible if the standby node is not in sync with the primary node. + +[JGroups](http://www.jgroups.org/) provides technology that allows Failover Manager to create clusters whose member nodes can communicate with each other and detect node failures. + +The figure shown above illustrates a Failover Manager cluster that employs a virtual IP address. You can use a load balancer in place of a [virtual IP address](../04_configuring_efm/05_using_vip_addresses/#using_vip_addresses) if you provide your own [script](../04_configuring_efm/01_cluster_properties/#cluster_properties) to re-configure the load balancer whenever databases are added or removed. You can also choose to enable native EFM-Pgpool integration for high availability. + +
+ +prerequisites + +
diff --git a/product_docs/docs/efm/4.2/efm_user/03_installing_efm.mdx b/product_docs/docs/efm/4.2/efm_user/03_installing_efm.mdx new file mode 100644 index 00000000000..c37be160e11 --- /dev/null +++ b/product_docs/docs/efm/4.2/efm_user/03_installing_efm.mdx @@ -0,0 +1,306 @@ +--- +title: "Installing Failover Manager" +--- + + + + + +To request credentials that allow you to access an EnterpriseDB repository, visit the EDB website at: + + + +## RedHat or CentOS Host + +When you install an RPM package that is signed by a source that is not recognized by your system, yum may ask for your permission to import the key to your local server. If prompted, and you are satisfied that the packages come from a trustworthy source, enter y, and press Return to continue. + +During the installation, yum may encounter a dependency that it cannot resolve. If it does, it will provide a list of the required dependencies that you must manually resolve. + +Failover Manager must be installed by root. During the installation process, the installer will also create a user named efm that has sufficient privileges to invoke scripts that control the Failover Manager service for clusters owned by enterprisedb or postgres. + +After receiving your credentials, you must create the EnterpriseDB repository configuration file on each node of the cluster, and then modify the file to enable access. The following steps provide detailed information about accessing the EnterpriseDB repository; the steps must be performed on each node of the cluster. + +### RHEL or CentOS 7 PPCLE Host + +1. Use the following command to create a configuration file and install Advance Toolchain: + + ```text + rpm --import https://public.dhe.ibm.com/software/server/POWER/Linux/toolchain/at/redhat/RHEL7/gpg-pubkey-6976a827-5164221b + + cat > /etc/yum.repos.d/advance-toolchain.repo <:@USERNAME:PASSWORD@" /etc/yum.repos.d/edb.repo + ``` + +4. Install the EPEL repository: + + ```text + yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm + ``` + +5. On RHEL 7 PPCLE, enable the additional repositories to resolve EPEL dependencies: + + ```text + subscription-manager repos --enable "rhel-*-optional-rpms" --enable "rhel-*-extras-rpms" --enable "rhel-ha-for-rhel-*-server-rpms" + ``` + +6. Install the selected package: + + ```text + yum -y install edb-efm42 + ``` + +### RHEL or CentOS 7 Host + +1. To create the repository configuration file, assume superuser privileges, and invoke the following command: + + ```text + yum -y install https://yum.enterprisedb.com/edbrepos/edb-repo-latest.noarch.rpm + ``` + +2. Replace ‘USERNAME:PASSWORD’ below with your username and password for the EDB repositories: + + ```text + sed -i "s@:@USERNAME:PASSWORD@" /etc/yum.repos.d/edb.repo + ``` + +3. Install the EPEL repository: + + ```text + yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm + ``` + +4. On RHEL 7, enable the additional repositories to resolve dependencies: + + ```text + subscription-manager repos --enable "rhel-*-optional-rpms" --enable "rhel-*-extras-rpms" --enable "rhel-ha-for-rhel-*-server-rpms" + ``` + +5. Install the selected package: + + ```text + yum -y install edb-efm42 + ``` + +### RHEL or CentOS 8 Host + +1. To create the repository configuration file, assume superuser privileges, and invoke the following command: + ```text + dnf -y install https://yum.enterprisedb.com/edbrepos/edb-repo-latest.noarch.rpm + ``` + +2. Replace ‘USERNAME:PASSWORD’ below with your username and password for the EDB repositories: + + ```text + sed -i "s@:@USERNAME:PASSWORD@" /etc/yum.repos.d/edb.repo + ``` + +3. Install the EPEL repository: + +- On CentOS 8 + ```text + dnf -y install epel-release + ``` +- On RHEL 8 + ```text + dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm + ``` + +4. Enable the additional repositories to resolve dependencies: + +- On CentOS 8 + ```text + dnf config-manager --set-enabled PowerTools + ``` +- On RHEL 8 + + ```text + ARCH=$( /bin/arch ) subscription-manager repos --enable "codeready-builder-for-rhel-8-${ARCH}-rpms" + ``` + +5. Disable the built-in PostgreSQL module: + + ```text + dnf -qy module disable postgresql + ``` +6. Install the selected package: + ```text + dnf -y install edb-efm42 + ``` + +## Debian or Ubuntu Host + +To install Failover Manager, you must have credentials that allow access to the EnterpriseDB repository. To request credentials for the repository, visit the EnterpriseDB website at: + + + +The following steps will walk you through using the EnterpriseDB apt repository to install Failover Manager. + +### Debian Host + +1. Assume superuser privileges: + ```text + sudo su – + ``` +2. Configure the EnterpriseDB repository by substituting your EnterpriseDB credentials for the username and password placeholders in the following commands: + +- On Debian 9 + ```text + sh -c 'echo "deb https://username:password@apt.enterprisedb.com/$(lsb_release -cs)-edb/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/edb-$(lsb_release -cs).list' + ``` +- On Debian 10 + + ```text + sh -c 'echo "deb [arch=amd64] https://apt.enterprisedb.com/$(lsb_release -cs)-edb/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/edb-$(lsb_release -cs).list' + + sh -c 'echo "machine apt.enterprisedb.com login password " > /etc/apt/auth.conf.d/edb.conf' + ``` + +3. Add support to your system for secure APT repositories: + ```text + apt-get install apt-transport-https + ``` +4. Add the EDB signing key: + ```text + wget -q -O - https://:@apt.enterprisedb.com/edb-deb.gpg.key | apt-key add - + ``` +5. Update the repository meta data: + ```text + apt-get update + ``` +6. Install Failover Manager: + ```text + apt-get -y install edb-efm42 + ``` + +### Ububtu Host + +1. Assume superuser privileges: + ```text + sudo su – + ``` +2. Configure the EnterpriseDB repository by substituting your EnterpriseDB credentials for the username and password placeholders in the following commands: + +- On Ubuntu 18.04 + ```text + sh -c 'echo "deb https://username:password@apt.enterprisedb.com/$(lsb_release -cs)-edb/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/edb-$(lsb_release -cs).list' + ``` +- On Ubuntu 20.4 + + ```text + sh -c 'echo "deb [arch=amd64] https://apt.enterprisedb.com/$(lsb_release -cs)-edb/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/edb-$(lsb_release -cs).list' + + sh -c 'echo "machine apt.enterprisedb.com login password " > /etc/apt/auth.conf.d/edb.conf' + ``` + +3. Add support to your system for secure APT repositories: + ```text + apt-get install apt-transport-https + ``` +4. Add the EDB signing key: + ```text + wget -q -O - https://:@apt.enterprisedb.com/edb-deb.gpg.key | apt-key add - + ``` +5. Update the repository meta data: + ```text + apt-get update + ``` +6. Install Failover Manager: + ```text + apt-get -y install edb-efm42 + ``` + +## SLES Host + +To install Failover Manager, you must have credentials that allow access to the EnterpriseDB repository. To request credentials for the repository, visit the EnterpriseDB website at: + + + +You can use the zypper package manager to install a Failover Manager agent on an SLES 12 host. zypper will attempt to satisfy package dependencies as it installs a package, but requires access to specific repositories that are not hosted at EnterpriseDB. + +1. You must assume superuser privileges and stop any firewalls before installing Failover Manager. Then, use the following commands to add EnterpriseDB repositories to your system: + + ```text + zypper addrepo https://zypp.enterprisedb.com/suse/edb-sles.repo + ``` + +2. The commands create the repository configuration files in the /etc/zypp/repos.d directory. Then, use the following command to refresh the metadata on your SLES host to include the EnterpriseDB repository: + + ```text + zypper refresh + ``` + + When prompted, provide credentials for the repository, and specify a to always trust the provided key, and update the metadata to include the EnterpriseDB repository. + +3. You must also add SUSEConnect and the SUSE Package Hub extension to the SLES host, and register the host with SUSE, allowing access to SUSE repositories. Use the commands: + + ```text + zypper install SUSEConnect + SUSEConnect -r -e + SUSEConnect -p PackageHub/12.4/x86_64 + SUSEConnect -p sle-sdk/12.4/x86_64 + ``` + +4. Install SUSEConnect to register the host with SUSE, allowing access to SUSE repositories: + + ```text + zypper addrepo https://download.opensuse.org/repositories/Apache:/Modules/SLE_12_SP4/Apache:Modules.repo + ``` + +5. Install OpenJDK (version 1.8) for Java based components: + + ```text + zypper -n install java-1_8_0-openjdk + ``` + +6. Now you can use the zypper utility to install a Failover Manager agent: + + ```text + zypper -n install edb-efm42 + ``` + +## Performing post-installation tasks + +If you are using Failover Manager to monitor a cluster owned by a user other than `enterprisedb` or `postgres`, see [Extending Failover Manager Permissions](04_configuring_efm/04_extending_efm_permissions/#extending_efm_permissions) . + +After installing on each node of the cluster, you must: + +1. Modify the [cluster properties file](04_configuring_efm/01_cluster_properties/#cluster_properties) on each node. +2. Modify the [cluster members file](04_configuring_efm/03_cluster_members/#cluster_members) on each node. +3. If applicable, configure and test virtual IP address settings and any scripts that are identified in the cluster properties file. +4. Start the agent on each node of the cluster. For more information about controlling the service, see [Section 5](08_controlling_efm_service/#controlling-the-failover-manager-service). + +### Installation Locations + +components are installed in the following locations: + +| Component | Location | +| --------------------------------- | --------------------------- | +| Executables | /usr/edb/efm-4.2/bin | +| Libraries | /usr/edb/efm-4.2/lib | +| Cluster configuration files | /etc/edb/efm-4.2 | +| Logs | /var/log/efm- 4.2 | +| Lock files | /var/lock/efm-4.2 | +| Log rotation file | /etc/logrotate.d/efm-4.2 | +| sudo configuration file | /etc/sudoers.d/efm-42 | +| Binary to access VIP without sudo | /usr/edb/efm-4.2/bin/secure | diff --git a/product_docs/docs/efm/4.2/efm_user/04_configuring_efm/01_cluster_properties/01_encrypting_database_password.mdx b/product_docs/docs/efm/4.2/efm_user/04_configuring_efm/01_cluster_properties/01_encrypting_database_password.mdx new file mode 100644 index 00000000000..9df42bb2108 --- /dev/null +++ b/product_docs/docs/efm/4.2/efm_user/04_configuring_efm/01_cluster_properties/01_encrypting_database_password.mdx @@ -0,0 +1,77 @@ +--- +title: "Encrypting Your Database Password" +--- + + + +Failover Manager requires you to encrypt your database password before including it in the cluster properties file. Use the [efm utility](../../07_using_efm_utility/#efm_encrypt) (located in the `/usr/edb/efm-4.2/bin` directory) to encrypt the password. When encrypting a password, you can either pass the password on the command line when you invoke the utility, or use the `EFMPASS` environment variable. + +To encrypt a password, use the command: + +```text +# efm encrypt [ --from-env ] +``` + +Where `` specifies the name of the Failover Manager cluster. + +If you include the `--from-env` option, you must export the value you wish to encrypt before invoking the encryption utility. For example: + +```text +export EFMPASS=password +``` + +If you do not include the `--from-env` option, Failover Manager will prompt you to enter the database password twice before generating an encrypted password for you to place in your cluster property file. When the utility shares the encrypted password, copy and paste the encrypted password into the cluster property files. + +!!! Note + Many Java vendors ship their version of Java with full-strength encryption included, but not enabled due to export restrictions. If you encounter an error that refers to an illegal key size when attempting to encrypt the database password, you should download and enable a Java Cryptography Extension (JCE) that provides an unlimited policy for your platform. + +The following example demonstrates using the encrypt utility to encrypt a password for the `acctg` cluster: + +```text +# efm encrypt acctg +This utility will generate an encrypted password for you to place in + your EFM cluster property file: +/etc/edb/efm-4.2/acctg.properties +Please enter the password and hit enter: +Please enter the password again to confirm: +The encrypted password is: 516b36fb8031da17cfbc010f7d09359c +Please paste this into your acctg.properties file +db.password.encrypted=516b36fb8031da17cfbc010f7d09359c +``` + +!!! Note + The utility will notify you if a properties file does not exist. + +After receiving your encrypted password, paste the password into the properties file and start the Failover Manager service. If there is a problem with the encrypted password, the Failover Manager service will not start: + +```text +[witness@localhost ~]# systemctl start edb-efm-4.2 +Job for edb-efm-4.2.service failed because the control process exited with error code. See "systemctl status edb-efm-4.2.service" and "journalctl -xe" for details. +``` + +If you receive this message when starting the Failover Manager service, please see the startup log (located in `/var/log/efm-4.2/startup-efm.log`) for more information. + +If you are using RHEL/CentOS 7.x or RHEL/CentOS 8.x, startup information is also available with the following command: + +```text +systemctl status edb-efm-4.2 +``` + +To prevent a cluster from inadvertently connecting to the database of another cluster, the cluster name is incorporated into the encrypted password. If you modify the cluster name, you will need to re-encrypt the database password and update the cluster properties file. + +**Using the EFMPASS Environment Variable** + +The following example demonstrates using the --from-env environment variable when encrypting a password. Before invoking the `efm encrypt` command, set the value of `EFMPASS` to the password (`1safepassword`): + +```text +# export EFMPASS=1safepassword +``` + +Then, invoke `efm encrypt`, specifying the `--from-env` option: + +```text +# efm encrypt acctg --from-env +# 7ceecd8965fa7a5c330eaa9e43696f83 +``` + +The encrypted password (`7ceecd8965fa7a5c330eaa9e43696f83`) is returned as a text value; when using a script, you can check the exit code of the command to confirm that the command succeeded. A successful execution returns `0`. diff --git a/product_docs/docs/efm/4.2/efm_user/04_configuring_efm/01_cluster_properties/index.mdx b/product_docs/docs/efm/4.2/efm_user/04_configuring_efm/01_cluster_properties/index.mdx new file mode 100644 index 00000000000..0a8abffaba2 --- /dev/null +++ b/product_docs/docs/efm/4.2/efm_user/04_configuring_efm/01_cluster_properties/index.mdx @@ -0,0 +1,1323 @@ +--- +title: "The Cluster Properties File" +--- + + + +Each node in a Failover Manager cluster has a properties file (by default, named `efm.properties`) that contains the properties of the individual node on which it resides. The Failover Manager installer creates a file template for the properties file named `efm.properties.in` in the `/etc/edb/efm-4.2` directory. + +After completing the Failover Manager installation, you must make a working copy of the template before modifying the file contents: + +```text +# cp /etc/edb/efm-4.2/efm.properties.in /etc/edb/efm-4.2/efm.properties +``` + +After copying the template file, change the owner of the file to `efm`: + +```text +# chown efm:efm efm.properties +``` + +!!! Note + By default, Failover Manager expects the cluster properties file to be named `efm.properties`. If you name the properties file something other than `efm.properties`, you must modify the service script or unit file to instruct Failover Manager to use a different name. + +After creating the cluster properties file, add (or modify) configuration parameter values as required. For detailed information about each property, see [Specifying Cluster Properties](#specifying-cluster-properties). + +The property files are owned by `root`. The Failover Manager service script expects to find the files in the `/etc/edb/efm-4.2` directory. If you move the property file to another location, you must create a symbolic link that specifies the new location. + +!!! Note + All user scripts referenced in the properties file will be invoked as the Failover Manager user. + + + +## Specifying Cluster Properties + +You can use the properties listed in the cluster properties file to specify connection properties and behaviors for your Failover Manager cluster. Modifications to property settings will be applied when Failover Manager starts. If you modify a property value you must restart Failover Manager to apply the changes. + +Property values are case-sensitive. Note that while Postgres uses quoted strings in parameter values, Failover Manager does not allow quoted strings in property values. For example, while you might specify an IP address in a Postgres configuration parameter as: + +`listen_addresses='192.168.2.47'` + +Failover Manager requires that the value *not* be enclosed in quotes: + +`bind.address=192.168.2.54:7800` + +Use the properties in the `efm.properties` file to specify connection, administrative, and operational details for Failover Manager. + +**Legends**: In the following table: + +- `A`: Required on Primary or Standby node +- `W`: Required on Witness node +- `Y` : Yes + +| **Property Name** | **A** | **W** | **Default Value** | **Comments** | +| ------------------------------------------------------------- | ----- | ----- | ------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [db.user](#db_user) | Y | Y | | Username for the database | +| [db.password.encrypted](#db_password_encrypted) | Y | Y | | Password encrypted using 'efm encrypt' | +| [db.port](#db_port) | Y | Y | | This value must be same for all the agents | +| [db.database](#db_database) | Y | Y | | Database name | +| [db.service.owner](#db_service_owner) | Y | | | Owner of $PGDATA dir for db.database | +| [db.service.name](#db_service_name) | | | | Required if running the database as a service | +| [db.bin](#db_bin) | Y | | | Directory containing the pg_controldata/pg_ctl commands such as '/usr/edb/as12/bin' | +| [db.data.dir](#db_data_dir) | Y | | | Same as the output of query 'show data_directory;' | +| [db.config.dir](#db_config_dir) | | | | Same as the output of query 'show config_file;'. Should be specified if it is not same as *db.data.dir* | +| [jdbc.sslmode](#jdbc_sslmode) | Y | Y | disable | See the [note](#jdbc_note) | +| [user.email](#user_email) | | | | This value must be same for all the agents; can be left blank if using a notification script | +| [from.email](#from_email) | | | [efm@localhost](mailto:efm@localhost) | Leave blank to use the default [efm@localhost](mailto:efm@localhost) | +| [notification.level](#notification_level) | Y | Y | INFO | See the [list of notifications](../../10_notifications/#notifications) | +| [notification.text.prefix](#notification_text_prefix) | | | | | +| [script.notification](#script_notification) | | | | Required if user.email property is not used; both parameters can be used together | +| [bind.address](#bind_address) | Y | Y | | Example: <ip_address>:<port> | +| [external.address](#external_address) | | | | Example: <ip_address/hostname> | +| [admin.port](#admin_port) | Y | Y | 7809 | Modify if the default port is already in use | +| [is.witness](#is_witness) | Y | Y | | See description | +| [local.period](#local_period) | Y | | 10 | | +| [local.timeout](#local_timeout) | Y | | 60 | | +| [local.timeout.final](#local_timeout_final) | Y | | 10 | | +| [remote.timeout](#remote_timeout) | Y | Y | 10 | | +| [node.timeout](#node_timeout) | Y | Y | 50 | This value must be same for all the agents | +| [encrypt.agent.messages](#encrypt_agent_messages) | Y | Y | false | This value must be same for all the agents | +| [enable.stop.cluster](#enable_stop_cluster) | | | true | This value must be same for all the agents | +| [stop.isolated.primary](#stop_isolated_primary) | Y | | true | This value must be same for all the agents | +| [stop.failed.primary](#stop_failed_primary) | Y | | true | | +| [primary.shutdown.as.failure](#primary_shutdown_as_failure) | Y | Y | false | | +| [update.physical.slots.period](#update_physical_slots_period) | Y | | 0 | | +| [ping.server.ip](#ping_server_ip) | Y | Y | 8.8.8.8 | | +| [ping.server.command](#ping_server_command) | Y | Y | /bin/ping -q -c3 -w5 | | +| [auto.allow.hosts](#auto_allow_hosts) | Y | Y | false | | +| [stable.nodes.file](#stable_nodes_file) | Y | Y | false | | +| [db.reuse.connection.count](#db_reuse_connection_count) | Y | | 0 | | +| [auto.failover](#auto_failover) | Y | Y | true | | +| [auto.reconfigure](#auto_reconfigure) | Y | | true | This value must be same for all the agents | +| [promotable](#promotable) | Y | | true | | +| [use.replay.tiebreaker](#use_replay_tiebreaker) | Y | Y | true | This value must be same for all the agents | +| [standby.restart.delay](#standby_restart_delay) | | | 0 | | +| [application.name](#application_name) | | | | Set to replace the application_name portion of the primary_conninfo entry with this property value before starting the original primary database as a standby. | +| [restore.command](#restore_command) | | | | Example: restore.command=scp <db_service_owner>@%h: <archive_path>/%f %p | +| [reconfigure.num.sync](#reconfigure_num_sync) | Y | | false | | +| [reconfigure.num.sync.max](#reconfigure_num_sync_max) | | | | | +| [reconfigure.sync.primary](#reconfigure_sync_primary) | Y | | false | | +| [minimum.standbys](#minimum_standbys) | Y | Y | 0 | This value must be same for all the nodes | +| [priority.standbys](#priority_standbys) | | | | | +| [recovery.check.period](#recovery_check_period) | Y | | 1 | | +| [restart.connection.timeout](#restart_connection_timeout) | | | 60 | | +| [auto.resume.period](#auto_resume_period) | Y | | 0 | | +| [virtual.ip](#virtual_ip) | | | (see virtual.ip.single) | Leave blank if you do not specify a VIP | +| [virtual.ip.interface](#virtual_ip) | | | | Required if you specify a VIP | +| [virtual.ip.prefix](#virtual_ip) | | | | Required if you specify a VIP | +| [virtual.ip.single](#virtual_ip) | Y | Y | Yes | This value must be same for all the nodes | +| [check.vip.before.promotion](#check_vip_before_promotion) | Y | Y | Yes | | +| [pgpool.enable](#pgpool_enable) | | | false | | +| [pcp.user](#pgpool_enable) | | | | Required if pgpool.enable is set to true | +| [pcp.host](#pgpool_enable) | | | | Required if pgpool.enable is set to true, this value must be same for all the agents | +| [pcp.port](#pgpool_enable) | | | | Required if pgpool.enable is set to true, this value must be same for all the agents | +| [pcp.pass.file](#pgpool_enable) | | | | Required if pgpool.enable is set to true | +| [pgpool.bin](#pgpool_enable) | | | | Required if pgpool.enable is set to true | +| [script.load.balancer.attach](#script_load_balancer) | | | | Example: script.load.balancer.attach= /<path>/<attach_script> %h %t | +| [script.load.balancer.detach](#script_load_balancer) | | | | Example: script.load.balancer.detach= /<path>/<detach_script> %h %t | +| [detach.on.agent.failure](#detach_on_agent_failure) | | | true | Set to false if you want to keep a running primary database attached. | +| [script.fence](#script_fence) | | | | Example: script.fence= /<path>/<script_name> %p %f | +| [script.post.promotion](#script_post_promotion) | | | | Example: script.post.promotion= /<path>/<script_name> %f %p | +| [script.resumed](#script_resumed) | | | | Example: script.resumed= /<path>/<script_name> | +| [script.db.failure](#script_db_failure) | | | | Example: script.db.failure= /<path>/<script_name> | +| [script.primary.isolated](#script_primary_isolated) | | | | Example: script.primary.isolated= /<path>/<script_name> | +| [script.remote.pre.promotion](#script_remote_pre_promotion) | | | | Example: script.remote.pre.promotion= /<path>/<script_name> %p | +| [script.remote.post.promotion](#script_remote_post_promotion) | | | | Example: script.remote.post.promotion= /<path>/<script_name> %p | +| [script.custom.monitor](#script_custom_monitor) | | | | Example: script.custom.monitor= /<path>/<script_name> | +| [custom.monitor.interval](#script_custom_monitor) | | | | Required if a custom monitoring script is specified | +| [custom.monitor.timeout](#script_custom_monitor) | | | | Required if a custom monitoring script is specified | +| [custom.monitor.safe.mode](#script_custom_monitor) | | | | Required if a custom monitoring script is specified | +| [sudo.command](#sudo_command) | Y | Y | sudo | | +| [sudo.user.command](#sudo_command) | Y | Y | sudo -u %u | | +| [lock.dir](#lock_dir) | | | | If not specified, defaults to '/var/lock/efm-<version>' | +| [log.dir](#log_dir) | | | | If not specified, defaults to '/var/log/efm-<version>' | +| [syslog.host](#syslog_logging) | | | localhost | | +| [syslog.port](#syslog_logging) | | | 514 | | +| [syslog.protocol](#syslog_logging) | | | | | +| [syslog.facility](#syslog_logging) | | | UDP | | +| [file.log.enabled](#logtype_enabled) | Y | Y | true | | +| [syslog.enabled](#logtype_enabled) | Y | Y | false | | +| [jgroups.loglevel](#loglevel) | | | info | | +| [efm.loglevel](#loglevel) | | | info | | +| [jvm.options](#jvm_options) | | | -Xmx128m | | + +**Cluster Properties** + + + + + + + + + +Use the following properties to specify connection details for the Failover Manager cluster: + +```text +# The value for the password property should be the output from +# 'efm encrypt' -- do not include a cleartext password here. To +# prevent accidental sharing of passwords among clusters, the +# cluster name is incorporated into the encrypted password. If +# you change the cluster name (the name of this file), you must +# encrypt the password again with the new name. +# The db.port property must be the same for all nodes. +db.user= +db.password.encrypted= +db.port= +db.database= +``` + +The `db.user` specified must have sufficient privileges to invoke selected PostgreSQL commands on behalf of Failover Manager. For more information, please see [Prerequisites](../../02_failover_manager_overview/01_prerequisites/#prerequisites). + +For information about encrypting the password for the database user, see [Encrypting Your Database Password](01_encrypting_database_password/#encrypting_database_password). + + + +Use the `db.service.owner` property to specify the name of the operating system user that owns the cluster that is being managed by Failover Manager. This property is not required on a dedicated witness node. + +```text +# This property tells EFM which OS user owns the $PGDATA dir for +# the 'db.database'. By default, the owner is either 'postgres' +# for PostgreSQL or 'enterprisedb' for EDB Postgres Advanced +# Server. However, if you have configured your db to run as a +# different user, you will need to copy the /etc/sudoers.d/efm-XX +# conf file to grant the necessary permissions to your db owner. +# +# This username must have write permission to the +# 'db.data.dir' specified below. +db.service.owner= +``` + + + +Specify the name of the database service in the `db.service.name` property if you use the service or systemctl command when starting or stopping the service. + +```text +# Specify the proper service name in order to use service commands +# rather than pg_ctl to start/stop/restart a database. For example, if +# this property is set, then 'service restart' or 'systemctl +# restart ' +# (depending on OS version) will be used to restart the database rather +# than pg_ctl. +# This property is required if running the database as a service. +db.service.name= +``` + + + +You should use the same service control mechanism (pg_ctl, service, or systemctl) each time you start or stop the database service. If you use the `pg_ctl` program to control the service, specify the location of the `pg_ctl` program in the `db.bin` property. + +```text +# Specify the directory containing the pg_controldata/pg_ctl commands, +# for example: +# /usr/edb/as12/bin. Unless the db.service.name property is used, the +# pg_ctl command is used to start/stop/restart databases as needed +# after a failover or switchover. This property is required. +db.bin= +``` + + + +Use the `db.data.dir` property to specify the location to which a recovery file will be written on the Primary node of the cluster during promotion. This property is required on primary and standby nodes; it is not required on a dedicated witness node. + +```text +# For database version 12 and up, this is the directory where a +# standby.signal file will exist for a standby node. For previous +# versions, this is the location of the db recovery.conf file on +# the node. +# After a failover, the recovery.conf files on remaining standbys are +# changed to point to the new primary db (a copy of the original is made +# first). On a primary node, a recovery.conf file will be written during +# failover and promotion to ensure that the primary node can not be +# restarted as the primary database. +# This corresponds to database environment variable PGDATA and should +# be same as the output of query 'show data_directory;' on respective +# database. +db.data.dir= +``` + + + + +Use the `db.data.dir` property to specify the location to which a recovery file will be written on the Primary node of the cluster during promotion. This property is required on primary and standby nodes; it is not required on a dedicated witness node. + +```text +# For database version 12 and up, this is the directory where a +# standby.signal file will exist for a standby node. For previous +# versions, this is the location of the db recovery.conf file on +# the node. +# After a failover, the recovery.conf files on remaining standbys are +# changed to point to the new primary db (a copy of the original is made +# first). On a primary node, a recovery.conf file will be written during +# failover and promotion to ensure that the primary node can not be +# restarted as the primary database. +# This corresponds to database environment variable PGDATA and should +# be same as the output of query 'show data_directory;' on respective +# database. +db.data.dir= +``` + + + +Use the `db.config.dir` property to specify the location of database configuration files if they are not stored in the same directory as the `recovery.conf` or `standby.signal` file. This should be the value specified by the `config_file` parameter directory of your Advanced Server or PostgreSQL installation. This value will be used as the location of the Postgres `data` directory when stopping, starting, or restarting the database. + +```text +# Specify the location of database configuration files if they are +# not contained in the same location as the recovery.conf or +# standby.signal file. This is most likely the case for Debian +# installations. The location specified will be used as the -D value +# (the location of the data directory for the cluster) when calling +# pg_ctl to start or stop the database. If this property is blank, +# the db.data.dir location specified by the db.data.dir property will +# be used. This corresponds to the output of query 'show config_file;' +# on respective database. +db.config.dir= +``` + +For more information about database configuration files, visit the [PostgreSQL website](https://www.postgresql.org/docs/current/runtime-config-file-locations.html). + + + +Use the `jdbc.sslmode` property to instruct Failover Manager to use SSL connections; by default, SSL is disabled. + +```text +# Use the jdbc.sslmode property to enable ssl for EFM +# connections. Setting this property to anything but 'disable' +# will force the agents to use 'ssl=true' for all JDBC database +# connections (to both local and remote databases). +# Valid values are: +# +# disable - Do not use ssl for connections. +# verify-ca - EFM will perform CA verification before allowing +# the certificate. +# require - Verification will not be performed on the server +# certificate. +jdbc.sslmode=disable +``` + + + +!!! Note + If you set the value of `jdbc.sslmode` to `verify-ca` and you want to use Java trust store for certificate validation, you need to set the following value: + + `jdbc.properties=sslfactory=org.postgresql.ssl.DefaultJavaSSLFactory` + +For information about configuring and using SSL, please see: + +> + +and + +> + + + +Use the `user.email` property to specify an email address (or multiple email addresses) that will receive any notifications sent by Failover Manager. + +```text +# Email address(es) for notifications. The value of this +# property must be the same across all agents. Multiple email +# addresses must be separated by space. If using a notification +# script instead, this property can be left blank. +user.email= +``` + + + +The `from.email` property specifies the value that will be used as the sender's address on any email notifications from Failover Manager. You can: + +- leave `from.email` blank to use the default value (`efm@localhost`). +- specify a custom value for the email address. +- specify a custom email address, using the `%h` placeholder to represent the name of the node host (e.g., [example@%h](mailto:example@%h)). The placeholder will be replaced with the name of the host as returned by the Linux hostname utility. + +For more information about notifications, see [Notifications](../../10_notifications/#notifications). + +```text +# Use the from.email property to specify the from email address that +# will be used for email notifications. Use the %h placeholder to +# represent the name of the node host (e.g. example@%h). The +# placeholder will be replaced with the name of the host as returned +# by the hostname command. +# Leave blank to use the default, efm@localhost. +from.email= +``` + + + +Use the `notification.level` property to specify the minimum severity level at which Failover Manager will send user notifications or when a notification script is called. For a complete list of notifications, please see [Notifications](../../10_notifications/#notifications). + +```text +# Minimum severity level of notifications that will be sent by +# the agent. The minimum level also applies to the notification +# script (below). Valid values are INFO, WARNING, and SEVERE. +# A list of notifications is grouped by severity in the user's +# guide. +notification.level=INFO +``` + + + +Use the `notification.text.prefix` property to specify the text to be added to the beginning of every notification. + +```text +# Text to add to the beginning of every notification. This could +# be used to help identify what the cluster is used for, the role +# of this node, etc. To use multiple lines, add a backslash \ to +# the end of a line of text. To include a newline use \n. +# Example: +# notification.text.prefix=Development cluster for Example dept.\n\ +# Used by Dev and QA \ +# See Example group for questions. +notification.text.prefix= +``` + + + +Use the `script.notification` property to specify the path to a user-supplied script that acts as a notification service; the script will be passed a message subject and a message body. The script will be invoked each time Failover Manager generates a user notification. + +```text +# Absolute path to script run for user notifications. +# +# This is an optional user-supplied script that can be used for +# notifications instead of email. This is required if not using +# email notifications. Either/both can be used. The script will +# be passed two parameters: the message subject and the message +# body. +script.notification= +``` + + + +The `bind.address` property specifies the IP address and port number of the agent on the current node of the Failover Manager cluster. + +```text +# This property specifies the ip address and port that jgroups +# will bind to on this node. The value is of the form +# :. +# Note that the port specified here is used for communicating +# with other nodes, and is not the same as the admin.port below, +# used only to communicate with the local agent to send control +# signals. +# For example, :7800 +bind.address= +``` + + + +Use the `external.address` property to specify the IP address or hostname that should be used for communication with all other Failover Manager agents in a NAT environment. + +```text +# This is the ip address/hostname to be used for communication with all +# other Failover Manager agents. All traffic towards this address +# should be routed by the network to the bind.address of the node. +# The value is in the ip/hostname format only. This address will be +# used in scenarios where nodes are on different networks and broadcast +# an IP address other than the bind.address to the external world. +external.address= +``` + + + +Use the `admin.port` property to specify a port on which Failover Manager listens for administrative commands. + +```text +# This property controls the port binding of the administration +# server which is used for some commands (ie cluster-status). The +# default is 7809; you can modify this value if the port is +# already in use. +admin.port=7809 +``` + + + +Set the `is.witness` property to true to indicate that the current node is a witness node. If is.witness is true, the local agent will not check to see if a local database is running. + +```text +# Specifies whether or not this is a witness node. Witness nodes +# do not have local databases running. +is.witness= +``` + +The Postgres `pg_is_in_recovery()` function is a boolean function that reports the recovery state of a database. The function returns `true` if the database is in recovery, or false if the database is not in recovery. When an agent starts, it connects to the local database and invokes the `pg_is_in_recovery()` function. If the server responds true, the agent assumes the role of standby; if the server responds false, the agent assumes the role of primary. If there is no local database, the agent will assume an idle state. + +!!! Note + If `is.witness` is `true`, Failover Manager will not check the recovery state. + + + + + + + +The following properties specify properties that apply to the local server: + +- The `local.period` property specifies how many seconds between attempts to contact the database server. +- The `local.timeout` property specifies how long an agent will wait for a positive response from the local database server. +- The `local.timeout.final` property specifies how long an agent will wait after the above-mentioned previous checks have failed to contact the database server on the current node. If a response is not received from the database within the number of seconds specified by the `local.timeout.final` property, the database is assumed to have failed. + +For example, given the default values of these properties, a check of the local database happens once every 10 seconds. If an attempt to contact the local database does not come back positive within 60 seconds, Failover Manager makes a final attempt to contact the database. If a response is not received within 10 seconds, Failover Manager declares database failure and notifies the administrator listed in the user.email property. These properties are not required on a dedicated witness node. + +```text +# These properties apply to the connection(s) EFM uses to monitor +# the local database. Every 'local.period' seconds, a database +# check is made in a background thread. If the main monitoring +# thread does not see that any checks were successful in +# 'local.timeout' seconds, then the main thread makes a final +# check with a timeout value specified by the +# 'local.timeout.final' value. All values are in seconds. +# Whether EFM uses single or multiple connections for database +# checks is controlled by the 'db.reuse.connection.count' +# property. +local.period=10 +local.timeout=60 +local.timeout.final=10 +``` + +If necessary, you should modify these values to suit your business model. + + + +Use the `remote.timeout` property to specify how many seconds an agent waits for a response from a remote database server (i.e., how long a standby agent waits to verify that the primary database is actually down before performing failover). The `remote.timeout` property value specifies a timeout value for agent-to-agent communication; other timeout properties in the cluster properties file specify values for agent-to-database communication. + +```text +# Timeout for a call to check if a remote database is responsive. +# For example, this is how long a standby would wait for a +# DB ping request from itself and the witness to the primary DB +# before performing failover. +remote.timeout=10 +``` + + + +Use the `node.timeout` property to specify the number of seconds that an agent will wait for a response from a node when determining if a node has failed. + +```text +# The total amount of time in seconds to wait before determining +# that a node has failed or been disconnected from this node. +# +# The value of this property must be the same across all agents. +node.timeout=50 +``` + + + +Use the `encrypt.agent.messages` property to specify if the messages sent between agents should be encrypted. + +```text +# Set to true to encrypt messages that are sent between agents. +# This property must be the same on all agents or else the agents +# will not be able to connect. +encrypt.agent.messages=false +``` + + + +Use the `enable.stop.cluster` property to enable or disable the `stop-cluster` command. The command could be a convenience in some environments but could cause issues when unintentionally invoked. In Eager Failover mode, the command would result in stopping Postgres without failover. + +```text +# Whether or not the 'efm stop-cluster ' command is enabled. +# Set to false to disable the command, in which case all Failover +# Manager agents must be stopped individually. Note that stopping each +# agent separately will change the .nodes files on remaining agents +# unless stable.nodes.file is also true. This property value must +# be the same on all agents if set. The default is true if not set. +enable.stop.cluster=true +``` + + + +Use the `stop.isolated.primary` property to instruct Failover Manager to shut down the database if a primary agent detects that it is isolated. When true (the default), Failover Manager will stop the database before invoking the script specified in the `script.primary.isolated` property. + +```text +# Shut down the database after a primary agent detects that it has +# been isolated from the majority of the efm cluster. If set to +# true, efm will stop the database before running the +# 'script.primary.isolated' script, if a script is specified. +stop.isolated.primary=true +``` + + + +Use the `stop.failed.primary` property to instruct Failover Manager to attempt to shut down a primary database if it can not reach the database. If `true`, Failover Manager will run the script specified in the `script.db.failure` property after attempting to shut down the database. + +```text +# Attempt to shut down a failed primary database after EFM can no +# longer connect to it. This can be used for added safety in the +# case a failover is caused by a failure of the network on the +# primary node. +# If specified, a 'script.db.failure' script is run after this attempt. +stop.failed.primary=true +``` + + + +Use the `primary.shutdown.as.failure` parameter to indicate that any shutdown of the Failover Manager agent on the primary node should be treated as a failure. If this parameter is set to `true` and the primary agent stops (for any reason), the cluster will attempt to confirm if the database on the primary node is running: + +- If the database is reached, a notification will be sent informing you of the agent status. +- If the database is not reached, a failover will occur. + +```text +# Treat a primary agent shutdown as an agent failure. This can be set +# to true to treat a primary agent shutdown as a failure situation. +# Caution should be used when using this feature, as it could +# cause an unwanted promotion in the case of performing primary +# database maintenance. +# Please see the user's guide for more information. +primary.shutdown.as.failure=false +``` + +The `primary.shutdown.as.failure` property is meant to catch user error, rather than failures, such as the accidental shutdown of a primary node. The proper shutdown of a node can appear to the rest of the cluster like a user has stopped the primary Failover Manager agent (for example to perform maintenance on the primary database). If you set the `primary.shutdown.as.failure` property to `true`, care must be taken when performing maintenance. + +To perform maintenance on the primary database when `primary.shutdown.as.failure` is `true`, you should stop the primary agent and wait to receive a notification that the primary agent has failed but the database is still running. Then it is safe to stop the primary database. Alternatively, you can use the `stop-cluster` command to stop all of the agents without failure checks being performed. + + + +Use the `update.physical.slots.period` property to define the slot advance frequency for database version 12 and above. When `update.physical.slots.period` is set to a non-zero value, the primary agent will read the current `restart_lsn` of the physical replication slots after every `update.physical.slots.period` seconds, and send this information with its `pg_current_wal_lsn` and `primary_slot_name` (If it is set in the postgresql.conf file) to the standbys. If physical slots do not already exist, setting this parameter to a non-zero value will create the slots and then update the `restart_lsn parameter` for these slots. A non-promotable standby will not create new slots but will update them if they exist. + +```text +# Period in seconds between having the primary agent update promotable +# standbys with physical replication slot information so that +# the cluster will continue to use replication slots after a failover. +# Set to zero to turn off. +update.physical.slots.period=0 +``` + + + +Use the `ping.server.ip` property to specify the IP address of a server that Failover Manager can use to confirm that network connectivity is not a problem. + +```text +# This is the address of a well-known server that EFM can ping +# in an effort to determine network reachability issues. It +# might be the IP address of a nameserver within your corporate +# firewall or another server that *should* always be reachable +# via a 'ping' command from each of the EFM nodes. +# +# There are many reasons why this node might not be considered +# reachable: firewalls might be blocking the request, ICMP might +# be filtered out, etc. +# +# Do not use the IP address of any node in the EFM cluster +# (primary, standby, or witness) because this ping server is meant +# to provide an additional layer of information should the EFM +# nodes lose sight of each other. +# +# The installation default is Google's DNS server. +ping.server.ip=8.8.8.8 +``` + + + +Use the `ping.server.command` property to specify the command used to test network connectivity. + +```text +# This command will be used to test the reachability of certain +# nodes. +# +# Do not include an IP address or hostname on the end of +# this command - it will be added dynamically at runtime with the +# values contained in 'virtual.ip' and 'ping.server.ip'. +# +# Make sure this command returns reasonably quickly - test it +# from a shell command line first to make sure it works properly. +ping.server.command=/bin/ping -q -c3 -w5 +``` + + + +Use the `auto.allow.hosts` property to instruct the server to use the addresses specified in the .nodes file of the first node started to update the allowed host list. Enabling this property (setting `auto.allow.hosts` to true) can simplify cluster start-up. + +```text +# Have the first node started automatically add the addresses +# from its .nodes file to the allowed host list. This will make +# it faster to start the cluster when the initial set of hosts +# is already known. +auto.allow.hosts=false +``` + + + +Use the `stable.nodes.file` property to instruct the server to not rewrite the nodes file when a node joins or leaves the cluster. This property is most useful in clusters with unchanging IP addresses. + +```text +# When set to true, EFM will not rewrite the .nodes file whenever +# new nodes join or leave the cluster. This can help starting a +# cluster in the cases where it is expected for member addresses +# to be mostly static, and combined with 'auto.allow.hosts' makes +# startup easier when learning failover manager. +stable.nodes.file=false +``` + + + +The `db.reuse.connection.count` property allows the administrator to specify the number of times Failover Manager reuses the same database connection to check the database health. The default value is 0, indicating that Failover Manager will create a fresh connection each time. This property is not required on a dedicated witness node. + +```text +# This property controls how many times a database connection is +# reused before creating a new one. If set to zero, a new +# connection will be created every time an agent pings its local +# database. +db.reuse.connection.count=0 +``` + + + +The `auto.failover` property enables automatic failover. By default, auto.failover is set to true. + +```text +# Whether or not failover will happen automatically when the primary +# fails. Set to false if you want to receive the failover notifications +# but not have EFM actually perform the failover steps. +# The value of this property must be the same across all agents. +auto.failover=true +``` + + + +Use the `auto.reconfigure` property to instruct Failover Manager to enable or disable automatic reconfiguration of remaining Standby servers after the primary standby is promoted to Primary. Set the property to `true` to enable automatic reconfiguration (the default) or `false` to disable automatic reconfiguration. This property is not required on a dedicated witness node. If you are using Advanced Server or PostgreSQL version 11 or earlier, the `recovery.conf` file will be backed up during the reconfiguration process. + +```text +# After a standby is promoted, Failover Manager will attempt to +# update the remaining standbys to use the new primary. For database +# versions before 12, Failover Manager will back up recovery.conf. +# Then it will change the host parameter of the primary_conninfo entry +# in recovery.conf or postgresql.auto.conf, and restart the database. +# The restart command is contained in either the efm_db_functions or +# efm_root_functions file; default when not running db as an os +# service is: "pg_ctl restart -m fast -w -t -D " +# where the timeout is the local.timeout property value and the +# directory is specified by db.data.dir. To turn off +# automatic reconfiguration, set this property to false. +auto.reconfigure=true +``` + +!!! Note + `primary_conninfo` is a space-delimited list of keyword=value pairs. + + + +Use the `promotable` property to indicate that a node should not be promoted. The `promotable` property is ignored when a primary agent is started. This simplifies switching back to the original primary after a switchover or failover. To override the setting, use the efm set-priority command at runtime; for more information about the efm set-priority command, see [Using the efm Utility](../../07_using_efm_utility/#using_efm_utility). + +```text +# A standby with this set to false will not be added to the +# failover priority list, and so will not be available for +# promotion. The property will be used whenever an agent starts +# as a standby or resumes as a standby after being idle. After +# startup/resume, the node can still be added or removed from the +# priority list with the 'efm set-priority' command. This +# property is required for all non-witness nodes. +promotable=true +``` + + + +If the same amount of data has been written to more than one standby node, and a failover occurs, the `use.replay.tiebreaker` value will determine how Failover Manager selects a replacement primary. Set the `use.replay.tiebreaker` property to `true` to instruct Failover Manager to failover to the node that will come out of recovery faster, as determined by the log sequence number. To ignore the log sequence number and promote a node based on user preference, set `use.replay.tiebreaker` to `false`. + +```text +# Use replay LSN value for tiebreaker when choosing a standby to +# promote before using failover priority. Set this property to true to +# consider replay location as more important than failover priority +# (as seen in cluster-status command) when choosing the "most ahead" +# standby to promote. +use.replay.tiebreaker=true +``` + + + +Use the `standby.restart.delay` property to specify the time in seconds that the standby should wait before it gets reconfigured (stopped/started) to follow the new primary after a promotion. + +```text +# Time in seconds for this standby to delay restarting to follow the +# primary after a promotion. This can be used to have standbys restart +# at different times to increase availability. Caution should be used +# when using this feature, as a delayed standby will not be following +# the new primary and care must be taken that the new primary retains +# enough WAL for the standby to follow it. +# Please see the user's guide for more information. +standby.restart.delay=0 +``` + + + +You can use the `application.name` property to provide the name of an application that will be copied to the `primary_conninfo` parameter before restarting an old primary node as a standby. + +```text +# During a switchover, recovery settings are copied from a standby +# to the original primary. If the application.name property is set, +# Failover Manager will replace the application_name portion of the +# primary_conninfo entry with this property value before starting +# the original primary database as a standby. If this property is +# not set, Failover Manager will remove the parameter value +# from primary_conninfo. +application.name= +``` + +!!! Note + You should set the `application.name` property on the primary and any promotable standby; in the event of a failover/switchover, the primary node could potentially become a standby node again. + + + +Use the `restore.command` property to instruct Failover Manager to update the `restore_command` when a new primary is promoted. `%h` represents the address of the new primary; Failover Manager will replace `%h` with the address of the new primary. `%f` and `%p` are placeholders used by the server. If the property is left blank, Failover Manager will not update the `restore_command` values on the standbys after a promotion. + +See the PostgreSQL documentation for more information about using a [restore_command](https://www.postgresql.org/docs/current/runtime-config-wal.html#RUNTIME-CONFIG-WAL-ARCHIVE-RECOVERY). + +```text +# If the restore_command on a standby restores directly from the +# primary node, use this property to have Failover Manager change +# the command when a new primary is promoted. +# +# Use the %h placeholder to represent the address of the new primary. +# During promotion it will be replaced with the address of the new +# primary. +# +# If not specified, failover manager will not change the +# restore_command value, if any, on standby nodes. +# +# Example: +# restore.command=scp @%h:/var/lib/edb/as12/data/archive/%f %p +restore.command= +``` + + + +The database parameter `synchronous_standby_names` on the primary node specifies the names and count of the synchronous standby servers that will confirm receipt of data, to ensure that the primary nodes can accept write transactions. When `reconfigure.num.sync` property is set to true, Failover Manager will reduce the number of synchronous standby servers and reload the configuration of the primary node to reflect the current value. + +```text +# Reduce num_sync when the number of synchronous standbys drops below +# the value required by the primary database. If set to true, Failover +# Manager will reduce the number of standbys needed in the primary's +# synchronous_standby_names property and reload the primary +# configuration. Failover Manager will not reduce the number below 1, +# taking the primary out of synchronous replication, unless the +# reconfigure.sync.primary property is also set to true. +# To raise num_sync, see the reconfigure.num.sync.max property below. +reconfigure.num.sync=false +``` + +!!! Note + + If you are using the `reconfigure.num.sync` property, ensure that the `wal_sender_timeout` in the primary database is set to at least ten seconds less than the `efm.node.timeout` value. + + + + + +Use the `reconfigure.num.sync.max` property to specify the maximum number to which num-sync can be raised when a standby is added to the cluster. + +```text +# If reconfigure.num.sync is set to true and this property is set, +# Failover Manager will check if num_sync can be raised when a standby +# is added to the cluster. +# Failover Manager will not raise the value above the maximum set here. +# If the primary database has been taken out of synchronous mode +# completely (see the reconfigure.sync.primary property), then Failover +# Manager will not reconfigure the primary database if standbys are +# added to the cluster. +reconfigure.num.sync.max= +``` + + + +Set the `reconfigure.sync.primary` property to `true` to take the primary database out of synchronous replication mode if the number of standby nodes drops below the level required. Set `reconfigure.sync.primary` to `false` to send a notification if the standby count drops, but not interrupt synchronous replication. + +```text +# Take the primary database out of synchronous replication mode when +# needed. If set to true, Failover Manager will clear the +# synchronous_standby_names configuration parameter on the primary +# if the number of synchronous standbys drops below the required +# level for the primary to accept writes. +# If set to false, Failover Manager will detect the situation but +# will only send a notification if the standby count drops below the +# required level. +# +# CAUTION: TAKING THE PRIMARY DATABASE OUT OF SYNCHRONOUS MODE MEANS +# THERE MAY ONLY BE ONE COPY OF DATA. DO NOT MAKE THIS CHANGE UNLESS +# YOU ARE SURE THIS IS OK. +reconfigure.sync.primary=false +``` + +!!! Note + + If you are using the `reconfigure.sync.primary` property, ensure that the `wal_sender_timeout` in the primary database is set to at least ten seconds less than the `efm.node.timeout` value. + + + + +Use the `minimum.standbys` property to specify the minimum number of standby nodes that will be retained on a cluster; if the standby count drops to the specified minimum, a replica node will not be promoted in the event of a failure of the primary node. + +```text +# Instead of setting specific standbys as being unavailable for +# promotion, this property can be used to set a minimum number +# of standbys that will not be promoted. Set to one, for +# example, promotion will not happen if it will drop the number +# of standbys below this value. This property must be the same on +# each node. +minimum.standbys=0 +``` + + + +Use the `priority.standbys` property to specify the priority of standbys after this node is promoted. + +```text +# Space-separated list of standby addresses that are high priority for +# promotion when this node is the primary. If set, when this node is +# promoted, addresses in this list will be added to the front of the +# standby priority list. If this list contains addresses that are not +# standbys at the time of promotion, they will not be added. +priority.standbys= +``` + + + +Use the `recovery.check.period` property to specify the number of seconds that Failover Manager will wait before checks to see if a database is out of recovery. + +```text +# Time in seconds between checks to see if a promoting database +# is out of recovery. +recovery.check.period=1 +``` + + + +Use the `restart.connection.timeout` property to specify the number of seconds that Failover Manager will attempt to connect to a newly reconfigured primary or standby node while the database on that node prepares to accept connections. + +```text +# Time in seconds to keep trying to connect to a database after a +# start or restart command returns successfully but the database +# is not ready to accept connections yet (a rare occurance). This +# applies to standby databases that are restarted when being +# reconfigured for a new primary, and to primary databases that +# are stopped and started as standbys during a switchover. +# This retry mechanism is unrelated to the auto.resume.period +# parameter. +restart.connection.timeout=60 +``` + + + +Use the `auto.resume.period` property to specify the number of seconds (after a monitored database fails and an agent has assumed an idle state, or when starting in IDLE mode) during which an agent will attempt to resume monitoring that database. + +```text +# Period in seconds for IDLE agents to try to resume monitoring +# after a database failure or when starting in IDLE mode. Set to +# 0 for agents to not try to resume (in which case the +# 'efm resume ' command is used after bringing a +# database back up). +auto.resume.period=0 +``` + + + +Failover Manager provides support for clusters that use a virtual IP. If your cluster uses a virtual IP, provide the host name or IP address in the `virtual.ip` property; specify the corresponding prefix in the `virtual.ip.prefix` property. If `virtual.ip` is left blank, virtual IP support is disabled. + +Use the `virtual.ip.interface` property to provide the network interface used by the VIP. + +The specified virtual IP address is assigned only to the primary node of the cluster. If you specify `virtual.ip.single=true`, the same VIP address will be used on the new primary in the event of a failover. Specify a value of false to provide a unique IP address for each node of the cluster. + +For information about using a virtual IP address, see [Using Failover Manager with Virtual IP Addresses](../05_using_vip_addresses/#using_vip_addresses). + +```text +# These properties specify the IP and prefix length that will be +# remapped during failover. If you do not use a VIP as part of +# your failover solution, leave the virtual.ip property blank to +# disable Failover Manager support for VIP processing (assigning, +# releasing, testing reachability, etc). +# +# If you specify a VIP, the interface and prefix are required. +# +# If you specify a host name, it will be resolved to an IP address +# when acquiring or releasing the VIP. If the host name resolves +# to more than one IP address, there is no way to predict which +# address Failover Manager will use. +# +# By default, the virtual.ip and virtual.ip.prefix values must be +# the same across all agents. If you set virtual.ip.single to +# false, you can specify unique values for virtual.ip and +# virtual.ip.prefix on each node. +# +# If you are using an IPv4 address, the virtual.ip.interface value +# should not contain a secondary virtual ip id (do not include +# ":1", etc). +virtual.ip= +virtual.ip.interface= +virtual.ip.prefix= +virtual.ip.single=true +``` + +!!! Note + If a primary agent is started and the node does not currently have the VIP, the EFM agent will acquire it. Stopping a primary agent does not drop the VIP from the node. + + + +Set the `check.vip.before.promotion` property to false to indicate that Failover Manager will not check to see if a VIP is in use before assigning it to a a new primary in the event of a failure. Note that this could result in multiple nodes broadcasting on the same VIP address; unless the primary node is isolated or can be shut down via another process, you should set this property to true. + +```text +# Whether to check if the VIP (when used) is still in use before +# promoting after a primary failure. Turning this off may allow +# the new primary to have the VIP even though another node is also +# broadcasting it. This should only be used in environments where +# it is known that the failed primary node will be isolated or +# shut down through other means. +check.vip.before.promotion=true +``` + + + +Use the `pgpool.enable` property to specify if you want to enable the Failover Manager and Pgpool integration for high availability. If you want to enable Pgpool integration in a non-sudo mode (running as the DB owner), the PCPPASS file must be owned by the DB owner operating system user and file permissions should be set to 600. + + +```text +# A boolean property to enable Failover Manager managed Pgpool HA. +# If enabled, Failover Manager would natively update the joining +# and leaving status of database nodes to active pgpool instance. +# Failover manager expects properly configured and running pgpool +# instances on required nodes. It does not manage setup and +# configuration of pgpool on any node. +# +# By default the property is disabled. +pgpool.enable=false +``` + +Use the following parameters to specify the values that should be used for Pgpool integration. + +```text +# Configurations required for pgpool integration. +# 'pcp.user' - User that would be invoking PCP commands +# 'pcp.host' - Virtual IP that would be used by pgpool. Same as +# pgpool parameter 'delegate_IP' +# 'pcp.port' - The port on which pgpool listens for pcp commands. +# 'pcp.pass.file' - Absolute path of PCPPASSFILE. +# 'pgpool.bin' - Absolute path of pgpool bin directory + +# These properties are required if 'pgpool.enable' is set to true. +pcp.user= +pcp.host= +pcp.port= +pcp.pass.file= +pgpool.bin= +``` + + + +Use the following properties to provide paths to scripts that reconfigure your load balancer in the event of a switchover or primary failure scenario. The scripts will also be invoked in the event of a standby failure. If you are using these properties, they should be provided on every node of the cluster (primary, standby, and witness) to ensure that if a database node fails, another node will call the detach script with the failed node's address. + +You do not need to set the below properties if you are using Pgpool as Load Balancer solution and have set the Pgpool integration properties. + +Provide a script name after the `script.load.balancer.attach` property to identify a script that will be invoked when a node should be attached to the load balancer. Use the `script.load.balancer.detach` property to specify the name of a script that will be invoked when a node should be detached from the load balancer. Include the `%h` placeholder to represent the IP address of the node that is being attached or removed from the cluster. Include the `%t` placeholder to instruct Failover Manager to include an p (for a primary node) or an s (for a standby node) in the string. + +```text +# Absolute path to load balancer scripts +# The attach script is called when a node should be attached to +# the load balancer, for example after a promotion. The detach +# script is called when a node should be removed, for example +# when a database has failed or is about to be stopped. Use %h to +# represent the IP/hostname of the node that is being +# attached/detached. Use %t to represent the type of node being +# attached or detached: the letter m will be passed in for primary nodes +#and the letter s for standby nodes. +# +# Example: +# script.load.balancer.attach=/somepath/attachscript %h %t +script.load.balancer.attach= +script.load.balancer.detach= +``` + + + +Use the `detach.on.agent.failure` property to indicate if you do not want to detach a node from the load balancer in a scenario where the primary agent fails but the database is still reachable. The default value is true. + +```text +# If set to true, Failover Manager will detach the node from load +# balancer if the primary agent fails but the database is still +# reachable. In most scenarios this is NOT the desired situation. In +# scenarios where the detach script should run with a failed primary +# agent, even when the primary database is still healthy this parameter +# should be set to true. If no value specified it defaults to true (for +# backwards compatibility). +# This is not applicable for standbys. +detach.on.agent.failure= +``` + + + +`script.fence` specifies the path to an optional user-supplied script that will be invoked during the promotion of a standby node to primary node. + +```text +# absolute path to fencing script run during promotion +# +# This is an optional user-supplied script that will be run +# during failover on the standby database node. If left blank, +# no action will be taken. If specified, EFM will execute this +# script before promoting the standby. +# +# Parameters can be passed into this script for the failed primary +# and new primary node addresses. Use %p for new primary and %f +# for failed primary. On a node that has just been promoted, %p +# should be the same as the node's efm binding address. +# +# Example: +# script.fence=/somepath/myscript %p %f +# +# NOTE: FAILOVER WILL NOT OCCUR IF THIS SCRIPT RETURNS A NON-ZERO EXIT +# CODE. +script.fence= +``` + +
+ +Use the `script.post.promotion` property to specify the path to an optional user-supplied script that will be invoked after a standby node has been promoted to primary. + +```text +# Absolute path to fencing script run after promotion +# +# This is an optional user-supplied script that will be run after +# failover on the standby node after it has been promoted and +# is no longer in recovery. The exit code from this script has +# no effect on failover manager, but will be included in a +# notification sent after the script executes. +# +# Parameters can be passed into this script for the failed primary +# and new primary node addresses. Use %p for new primary and %f +# for failed primary. On a node that has just been promoted, %p +# should be the same as the node's efm binding address. +# +# Example: +# script.post.promotion=/somepath/myscript %f %p +script.post.promotion= +``` + + + +Use the `script.resumed property` to specify an optional path to a user-supplied script that will be invoked when an agent resumes monitoring of a database. + +```text +# Absolute path to resume script +# +# This script is run before an IDLE agent resumes +# monitoring its local database. +script.resumed= +``` + + + +Use the `script.db.failure` property to specify the complete path to an optional user-supplied script that Failover Manager will invoke if an agent detects that the database that it monitors has failed. + +```text +# Absolute path to script run after database failure +# This is an optional user-supplied script that will be run after +# an agent detects that its local database has failed. +script.db.failure= +``` + + + +Use the `script.primary.isolated` property to specify the complete path to an optional user-supplied script that Failover Manager will invoke if the agent monitoring the primary database detects that the primary is isolated from the majority of the Failover Manager cluster. This script is called immediately after the VIP is released (if a VIP is in use). + +```text +# Absolute path to script run on isolated primary +# This is an optional user-supplied script that will be run after +# a primary agent detects that it has been isolated from the +# majority of the efm cluster. +script.primary.isolated= +``` + + + +Use the `script.remote.pre.promotion` property to specify the path and name of a script that will be invoked on any agent nodes not involved in the promotion when a node is about to promote its database to primary. + +Include the %p placeholder to identify the address of the new primary node. + +```text +# Absolute path to script invoked on non-promoting agent nodes +# before a promotion. +# +# This optional user-supplied script will be invoked on other +# agents when a node is about to promote its database. The exit +# code from this script has no effect on Failover Manager, but +# will be included in a notification sent after the script +# executes. +# +# Pass a parameter (%p) with the script to identify the new +# primary node address. +# +# Example: +# script.remote.pre.promotion=/path_name/script_name %p +script.remote.pre.promotion= +``` + +
+ +Use the `script.remote.post.promotion` property to specify the path and name of a script that will be invoked on any non-primary nodes after a promotion occurs. + +Include the %p placeholder to identify the address of the new primary node. + +```text +# Absolute path to script invoked on non-primary agent nodes +# after a promotion. +# +# This optional user-supplied script will be invoked on nodes +# (except the new primary) after a promotion occurs. The exit code +# from this script has no effect on Failover Manager, but will be +# included in a notification sent after the script executes. +# +# Pass a parameter (%p) with the script to identify the new +# primary node address. +# +# Example: +# script.remote.post.promotion=/path_name/script_name %p +script.remote.post.promotion= +``` + + + +Use the `script.custom.monitor` property to provide the name and location of an optional script that will be invoked on regular intervals (specified in seconds by the `custom.monitor.interval` property). + +Use `custom.monitor.timeout` to specify the maximum time that the script will be allowed to run; if script execution does not complete within the time specified, Failover Manager will send a notification. + +Set `custom.monitor.safe.mode` to `true` to instruct Failover Manager to report non-zero exit codes from the script, but not promote a standby as a result of an exit code. + +```text +# Absolute path to a custom monitoring script. +# +# Use script.custom.monitor to specify the location and name of +# an optional user-supplied script that will be invoked +# periodically to perform custom monitoring tasks. A non-zero +# exit value means that a check has failed; this will be treated +# as a database failure. On a primary node, script failure will +# cause a promotion. On a standby node script failure will +# generate a notification and the agent will become IDLE. +# +# The custom.monitor.\* properties are required if a custom +# monitoring script is specified: +# +# custom.monitor.interval is the time in seconds between executions +# of the script. +# +# custom.monitor.timeout is a timeout value in seconds for how +# long the script will be allowed to run. If script execution +# exceeds the specified time, the task will be stopped and a +# notification sent. Subsequent runs will continue. +# +# If custom.monitor.safe.mode is set to true, non-zero exit codes +# from the script will be reported but will not cause a promotion +# or be treated as a database failure. This allows testing of the +# script without affecting EFM. +# +script.custom.monitor= +custom.monitor.interval= +custom.monitor.timeout= +custom.monitor.safe.mode= +``` + + + +Use the `sudo.command` property to specify a command that will be invoked by Failover Manager when performing tasks that require extended permissions. Use this option to include command options that might be specific to your system authentication. + +Use the `sudo.user.command` property to specify a command that will be invoked by Failover Manager when executing commands that will be performed by the database owner. + +```text +# Command to use in place of 'sudo' if desired when efm runs +# the efm_db_functions or efm_root_functions, or efm_address +# scripts. +# Sudo is used in the following ways by efm: +# +# sudo /usr/edb/efm-/bin/efm_address +# sudo /usr/edb/efm-/bin/efm_root_functions +# sudo -u /usr/edb/efm-/bin/efm_db_functions +# +# 'sudo' in the first two examples will be replaced by the value +# of the sudo.command property. 'sudo -u ' will +# be replaced by the value of the sudo.user.command property. +# The '%u' field will be replaced with the db owner. +sudo.command=sudo +sudo.user.command=sudo -u %u +``` + + + +Use the `lock.dir` property to specify an alternate location for the Failover Manager lock file; the file prevents Failover Manager from starting multiple (potentially orphaned) agents for a single cluster on the node. + +```text +# Specify the directory of lock file on the node. Failover +# Manager creates a file named .lock at this location to +# avoid starting multiple agents for same cluster. If the path +# does not exist, Failover Manager will attempt to create it. If +# not specified defaults to '/var/lock/efm-' +lock.dir= +``` + + + +Use the `log.dir` property to specify the location to which agent log files will be written; Failover Manager will attempt to create the directory if the directory does not exist. + +```text +# Specify the directory of agent logs on the node. If the path +# does not exist, Failover Manager will attempt to create it. If +# not specified defaults to '/var/log/efm-'. (To store +# Failover Manager startup logs in a custom location, modify the +# path in the service script to point to an existing, writable +# directory.) +# If using a custom log directory, you must configure +# logrotate separately. Use 'man logrotate' for more information. +log.dir= +``` + + + +After enabling the UDP or TCP protocol on a Failover Manager host, you can enable logging to syslog. Use the `syslog.protocol` parameter to specify the protocol type (UDP or TCP) and the `syslog.port` parameter to specify the listener port of the syslog host. The `syslog.facility` value may be used as an identifier for the process that created the entry; the value must be between LOCAL0 and LOCAL7. + +```text +# Syslog information. The syslog service must be listening on +# the port for the given protocol, which can be UDP or TCP. +# The facilities supported are LOCAL0 through LOCAL7. +syslog.host=localhost +syslog.port=514 +syslog.protocol=UDP +syslog.facility=LOCAL1 +``` + + + +Use the `file.log.enabled` and `syslog.enabled` properties to specify the type of logging that you wish to implement. Set `file.log.enabled` to `true` to enable logging to a file; enable the UDP protocol or TCP protocol and set `syslog.enabled` to `true` to enable logging to syslog. You can enable logging to both a file and syslog. + +```text +# Which logging is enabled. +file.log.enabled=true +syslog.enabled=false +``` + +For more information about configuring syslog logging, see [Enabling syslog Log File Entries](../../09_controlling_logging/#enabling_syslog). + + + +Use the `jgroups.loglevel` and `efm.loglevel` parameters to specify the level of detail logged by Failover Manager. The default value is INFO. For more information about logging, see [Controlling Logging](../../09_controlling_logging/#controlling_logging). + +```text +# Logging levels for JGroups and EFM. +# Valid values are: TRACE, DEBUG, INFO, WARN, ERROR +# Default value: INFO +# It is not necessary to increase these values unless debugging a +# specific issue. If nodes are not discovering each other at +# startup, increasing the jgroups level to DEBUG will show +# information about the TCP connection attempts that may help +# diagnose the connection failures. +jgroups.loglevel=INFO +efm.loglevel=INFO +``` + + + +Use the `jvm.options` property to pass JVM-related configuration information. The default setting specifies the amount of memory that the Failover Manager agent will be allowed to use. + +```text +# Extra information that will be passed to the JVM when starting +# the agent. +jvm.options=-Xmx128m +``` + +
+ +encrypting_database_password + +
diff --git a/product_docs/docs/efm/4.2/efm_user/04_configuring_efm/02_encrypting_database_password.mdx b/product_docs/docs/efm/4.2/efm_user/04_configuring_efm/02_encrypting_database_password.mdx new file mode 100644 index 00000000000..367a4bce02e --- /dev/null +++ b/product_docs/docs/efm/4.2/efm_user/04_configuring_efm/02_encrypting_database_password.mdx @@ -0,0 +1,77 @@ +--- +title: "Encrypting Your Database Password" +--- + + + +Failover Manager requires you to encrypt your database password before including it in the cluster properties file. Use the [efm utility](../07_using_efm_utility/#efm_encrypt) (located in the `/usr/edb/efm-4.2/bin` directory) to encrypt the password. When encrypting a password, you can either pass the password on the command line when you invoke the utility, or use the `EFMPASS` environment variable. + +To encrypt a password, use the command: + +```text +# efm encrypt [ --from-env ] +``` + +Where `` specifies the name of the Failover Manager cluster. + +If you include the `--from-env` option, you must export the value you wish to encrypt before invoking the encryption utility. For example: + +```text +export EFMPASS=password +``` + +If you do not include the `--from-env` option, Failover Manager will prompt you to enter the database password twice before generating an encrypted password for you to place in your cluster property file. When the utility shares the encrypted password, copy and paste the encrypted password into the cluster property files. + +!!! Note + Many Java vendors ship their version of Java with full-strength encryption included, but not enabled due to export restrictions. If you encounter an error that refers to an illegal key size when attempting to encrypt the database password, you should download and enable a Java Cryptography Extension (JCE) that provides an unlimited policy for your platform. + +The following example demonstrates using the encrypt utility to encrypt a password for the `acctg` cluster: + +```text +# efm encrypt acctg +This utility will generate an encrypted password for you to place in + your EFM cluster property file: +/etc/edb/efm-4.2/acctg.properties +Please enter the password and hit enter: +Please enter the password again to confirm: +The encrypted password is: 516b36fb8031da17cfbc010f7d09359c +Please paste this into your acctg.properties file +db.password.encrypted=516b36fb8031da17cfbc010f7d09359c +``` + +!!! Note + The utility will notify you if a properties file does not exist. + +After receiving your encrypted password, paste the password into the properties file and start the Failover Manager service. If there is a problem with the encrypted password, the Failover Manager service will not start: + +```text +[witness@localhost ~]# systemctl start edb-efm-4.2 +Job for edb-efm-4.2.service failed because the control process exited with error code. See "systemctl status edb-efm-4.2.service" and "journalctl -xe" for details. +``` + +If you receive this message when starting the Failover Manager service, please see the startup log (located in `/var/log/efm-4.2/startup-efm.log`) for more information. + +If you are using RHEL/CentOS 7.x or RHEL/CentOS 8.x, startup information is also available with the following command: + +```text +systemctl status edb-efm-4.2 +``` + +To prevent a cluster from inadvertently connecting to the database of another cluster, the cluster name is incorporated into the encrypted password. If you modify the cluster name, you will need to re-encrypt the database password and update the cluster properties file. + +**Using the EFMPASS Environment Variable** + +The following example demonstrates using the --from-env environment variable when encrypting a password. Before invoking the `efm encrypt` command, set the value of `EFMPASS` to the password (`1safepassword`): + +```text +# export EFMPASS=1safepassword +``` + +Then, invoke `efm encrypt`, specifying the `--from-env` option: + +```text +# efm encrypt acctg --from-env +# 7ceecd8965fa7a5c330eaa9e43696f83 +``` + +The encrypted password (`7ceecd8965fa7a5c330eaa9e43696f83`) is returned as a text value; when using a script, you can check the exit code of the command to confirm that the command succeeded. A successful execution returns `0`. diff --git a/product_docs/docs/efm/4.2/efm_user/04_configuring_efm/03_cluster_members.mdx b/product_docs/docs/efm/4.2/efm_user/04_configuring_efm/03_cluster_members.mdx new file mode 100644 index 00000000000..644e81e702e --- /dev/null +++ b/product_docs/docs/efm/4.2/efm_user/04_configuring_efm/03_cluster_members.mdx @@ -0,0 +1,31 @@ +--- +title: "The Cluster Members File" +--- + + + +Each node in a Failover Manager cluster has a cluster members file (by default, named efm.nodes) that contains a list of the current Failover Manager cluster members. When an agent starts, it uses the file to locate other cluster members. The Failover Manager installer creates a file template for the cluster members file named `efm.nodes.in` in the `/etc/edb/efm-4.2` directory. + +After completing the Failover Manager installation, you must make a working copy of the template: + +```text +cp /etc/edb/efm-4.2/efm.nodes.in /etc/edb/efm-4.2/efm.nodes +``` + +After copying the template file, change the owner of the file to `efm`: + +```text +chown efm:efm efm.nodes +``` + +By default, Failover Manager expects the cluster members file to be named `efm.nodes`. If you name the cluster members file something other than `efm.nodes`, you must modify the Failover Manager service script to instruct Failover Manager to use the new name. + +The cluster members file on the first node started can be empty; this node will become the Membership Coordinator. On each subsequent node, the cluster member file must contain the address and port number of the Membership Coordinator. Each entry in the cluster members file must be listed in an address:port format, with multiple entries separated by white space. + +The agents will update the contents of the `efm.nodes` file to match the current members of the cluster. As agents join or leave the cluster, the `efm.nodes` files on other agents are updated to reflect the current cluster membership. If you invoke the [efm stop-cluster](../07_using_efm_utility/#efm_stop_cluster) command, Failover Manager does not modify the file. + +If the Membership Coordinator leaves the cluster, another node will assume the role. You can use the [efm cluster-status](../07_using_efm_utility/#efm_cluster_status) command to find the address of the Membership Coordinator. If a node joins or leaves a cluster while an agent is down, before starting that agent you must manually ensure that the file includes at least the current Membership Coordinator's address and port. + +If you know the addresses and ports of the nodes that will be joining the cluster, you can include the addresses in the cluster members file at any time. At startup, any addresses that do not identify cluster members will be ignored unless the `auto.allow.hosts` property (in the [cluster properties file](01_cluster_properties/#auto_allow_hosts)) is set to `true`. + +If the `stable.nodes.file` property (located in the [cluster properties file](01_cluster_properties/#auto_allow_hosts)) is set to `true`, the agent will not update the `.nodes` file when cluster members join or leave the cluster; this behavior is most useful when the IP addresses of cluster members do not change often. diff --git a/product_docs/docs/efm/4.2/efm_user/04_configuring_efm/04_extending_efm_permissions.mdx b/product_docs/docs/efm/4.2/efm_user/04_configuring_efm/04_extending_efm_permissions.mdx new file mode 100644 index 00000000000..049163d4e56 --- /dev/null +++ b/product_docs/docs/efm/4.2/efm_user/04_configuring_efm/04_extending_efm_permissions.mdx @@ -0,0 +1,112 @@ +--- +title: "Extending Failover Manager Permissions" +--- + + + +During the Failover Manager installation, the installer creates a user named `efm`. `efm` does not have sufficient privileges to perform management functions that are normally limited to the database owner or operating system superuser. + +- When performing management functions requiring database superuser privileges, `efm` invokes the `efm_db_functions` script. +- When performing management functions requiring operating system superuser privileges, `efm` invokes the `efm_root_functions` script. +- When assigning or releasing a virtual IP address, `efm` invokes the `efm_address` script. +- When enabling Pgpool integration, `efm` invokes the `efm_pgpool_functions` script. + +The `efm_db_functions` or `efm_root_functions` scripts perform management functions on behalf of the `efm` user. + +The sudoers file contains entries that allow the user `efm` to control the Failover Manager service for clusters owned by `postgres` or `enterprisedb`. You can modify a copy of the sudoers file to grant permission to manage Postgres clusters owned by other users to `efm`. + +The `efm-42` file is located in `/etc/sudoers.d`, and contains the following entries: + +```text +# Copyright EnterpriseDB Corporation, 2014-2020. All Rights Reserved. +# +# Do not edit this file. Changes to the file may be overwritten +# during an upgrade. +# +# This file assumes you are running your efm cluster as user 'efm'. If not, +# then you will need to copy this file. + +# Allow user 'efm' to sudo efm_db_functions as either 'postgres' or 'enterprisedb'. +# If you run your db service under a non-default account, you will need to copy +# this file to grant the proper permissions and specify the account in your efm +# cluster properties file by changing the 'db.service.owner' property. +efm ALL=(postgres) NOPASSWD: /usr/edb/efm-4.2/bin/efm_db_functions +efm ALL=(enterprisedb) NOPASSWD: /usr/edb/efm-4.2/bin/efm_db_functions + +# Allow user 'efm' to sudo efm_root_functions as 'root' to write/delete the PID file, +# validate the db.service.owner property, etc. +efm ALL=(ALL) NOPASSWD: /usr/edb/efm-4.2/bin/efm_root_functions + +# Allow user 'efm' to sudo efm_address as root for VIP tasks. +efm ALL=(ALL) NOPASSWD: /usr/edb/efm-4.2/bin/efm_address + +# Allow user 'efm' to sudo efm_pgpool_functions as root for pgpool tasks. +efm ALL=(ALL) NOPASSWD: /usr/edb/efm-4.2/bin/efm_pgpool_functions + +# relax tty requirement for user 'efm' +Defaults:efm !requiretty +``` + +If you are using Failover Manager to monitor clusters that are owned by users other than `postgres` or `enterprisedb`, make a copy of the `efm-42` file, and modify the content to allow the user to access the `efm_functions` script to manage their clusters. + +If an agent cannot start because of permission problems, make sure the default `/etc/sudoers` file contains the following line at the end of the file: + +```text +## Read drop-in files from /etc/sudoers.d (the # here does not # mean a comment) + +#includedir /etc/sudoers.d +``` + + + +## Running Failover Manager without sudo + +By default, Failover Manager uses sudo to securely manage access to system functionality. If you choose to configure Failover Manager to run without sudo access, Note that root access is still required to: + +- install the Failover Manager RPM. +- perform Failover Manager setup tasks. + +To run Failover Manager without sudo, you must select a database process owner that will have privileges to perform management functions on behalf of Failover Manager. The user could be the default database superuser (for example, enterprisedb or postgres) or another privileged user. After selecting the user: + +1. Use the following command to add the user to the `efm` group: + + ```text + usermod -a -G efm enterprisedb + ``` + + This should allow the user to write to `/var/run/efm-4.2` and `/var/lock/efm-4.2`. + +2. If you are reusing a cluster name, remove any previously created log files; the new user will not be able to write to log files created by the default (or other) owner. + +3. Copy the cluster properties template file and the nodes template file: + + ```text + su - enterprisedb + + cp /etc/edb/efm-4.2/efm.properties.in .properties + + cp /etc/edb/efm-4.2/efm.nodes.in /.nodes + ``` + +Then, modify the cluster properties file, providing the name of the user in the `db.service.owner` property. You must also ensure that the `db.service.name` property is blank; without sudo, you cannot run services without root access. + +After modifying the configuration, the new user can control Failover Manager with the following command: + +```text +/usr/edb/efm-4.2/bin/runefm.sh start|stop .properties +``` + +Where `` specifies the full path of the cluster properties file. Note that the user must ensure that the full path to the properties file must be provided whenever the non-default user is controlling agents or using the efm script. + +To allow the new user to manage Failover Manager as a service, you must provide a custom script or unit file. + +Failover Manager uses a binary named `manage-vip` that resides in `/usr/edb/efm-4.2/bin/secure/` to perform VIP management operations without sudo privileges. This script uses setuid to acquire with the privileges needed to manage virtual IP addresses. + +- This directory is only accessible to root and users in the `efm` group. +- The binary is only executable by root and the `efm` group. + +For security reasons, we recommend against modifying the access privileges of the `/usr/edb/efm-4.2/bin/secure/` directory or the `manage-vip` script. + +For more information about using Failover Manager without sudo, visit: + + diff --git a/product_docs/docs/efm/4.2/efm_user/04_configuring_efm/05_using_vip_addresses.mdx b/product_docs/docs/efm/4.2/efm_user/04_configuring_efm/05_using_vip_addresses.mdx new file mode 100644 index 00000000000..24e0320c6bf --- /dev/null +++ b/product_docs/docs/efm/4.2/efm_user/04_configuring_efm/05_using_vip_addresses.mdx @@ -0,0 +1,144 @@ +--- +title: "Using Failover Manager with Virtual IP Addresses" +--- + + + +Failover Manager uses the `efm_address` script to assign or release a virtual IP address. + +!!! Note + Virtual IP addresses are not supported by many cloud providers. In those environments, another mechanism should be used (such as an Elastic IP Address on AWS), which can be changed when needed by a fencing or post-promotion script. + +By default, the script resides in: + + `/usr/edb/efm-4.2/bin/efm_address` + +Failover Manager uses the following command variations to assign or release an IPv4 or IPv6 IP address. + +To assign a virtual IPv4 IP address: + +```text +# efm_address add4 / +``` + +To assign a virtual IPv6 IP address: + +```text +# efm_address add6 / +``` + +To release a virtual address: + +```text +# efm_address del +``` + +Where: + + `` matches the name specified in the `virtual.ip.interface` property in the cluster properties file. + + `` or `` matches the value specified in the `virtual.ip` property in the cluster properties file. + + `prefix` matches the value specified in the `virtual.ip.prefix` property in the cluster properties file. + +For more information about properties that describe a virtual IP address, see [The Cluster Properties File](01_cluster_properties/#virtual_ip). + +You must invoke the `efm_address` script as the root user. The `efm` user is created during the installation, and is granted privileges in the sudoers file to run the `efm_address` script. For more information about the sudoers file, see [Extending Failover Manager Permissions](04_extending_efm_permissions/#extending_efm_permissions). + +!!! Note + If a VIP address (or any address other than the `bind.address`) is assigned to a node, the operating system can choose the source address used when contacting the database. Be sure that you modify the `pg_hba.conf` file on all monitored databases to allow contact from all addresses within your replication scenario. + +**Testing the VIP** + +When using a virtual IP (VIP) address with Failover Manager, it is important to test the VIP functionality manually before starting Failover manager. This will catch any network-related issues before they cause a problem during an actual failover. While testing the VIP, ensure that Failover Manager is not running. + +The following steps test the actions that Failover Manager will take. The example uses the following property values: + +```text +virtual.ip=172.24.38.239 +virtual.ip.interface=eth0 +virtual.ip.prefix=24 +ping.server.command=/bin/ping -q -c3 -w5 +``` + +!!! Note + The `virtual.ip.prefix` specifies the number of significant bits in the virtual Ip address. + +When instructed to ping the VIP from a node, use the command defined by the `ping.server.command` property. + +1. Ping the VIP from all nodes to confirm that the address is not already in use: + +```text +# /bin/ping -q -c3 -w5 172.24.38.239 +PING 172.24.38.239 (172.24.38.239) 56(84) bytes of data. +--- 172.24.38.239 ping statistics --- +4 packets transmitted, 0 received, +3 errors, 100% packet loss, + time 3000ms +``` + +You should see 100% packet loss. + +2. Run the `efm_address add4` command on the Primary node to assign the VIP and then confirm with ip address: + +```text +# efm_address add4 eth0 172.24.38.239/24 +# ip address + +eth0 Link encap:Ethernet HWaddr 36:AA:A4:F4:1C:40 +inet addr:172.24.38.239 Bcast:172.24.38.255 +... +``` + +3. Ping the VIP from the other nodes to verify that they can reach the VIP: + +```text +# /bin/ping -q -c3 -w5 172.24.38.239 +PING 172.24.38.239 (172.24.38.239) 56(84) bytes of data. +--- 172.24.38.239 ping statistics --- +3 packets transmitted, 3 received, 0% packet loss, time 1999ms +rtt min/avg/max/mdev = 0.023/0.025/0.029/0.006 ms +``` + +You should see no packet loss. + +4. Use the `efm_address del` command to release the address on the primary node and confirm the node has been released with ip address: + +```text +# efm_address del eth0 172.24.38.239/24 +# ip address +eth0 Link encap:Ethernet HWaddr 22:00:0A:89:02:8E +inet addr:10.137.2.142 Bcast:10.137.2.191 +... +``` + +The output from this step should not show an eth0 interface + +5. Repeat step 3, this time verifying that the Standby and Witness do not see the VIP in use: + +```text +# /bin/ping -q -c3 -w5 172.24.38.239 +PING 172.24.38.239 (172.24.38.239) 56(84) bytes of data. +--- 172.24.38.239 ping statistics --- +4 packets transmitted, 0 received, +3 errors, 100% packet loss, + time 3000ms +``` + +You should see 100% packet loss. Repeat this step on all nodes. + +6. Repeat step 2 on all Standby nodes to assign the VIP to every node. You can ping the VIP from any node to verify that it is in use. + +```text +# efm_address add4 eth0 172.24.38.239/24 +# ip address + +eth0 Link encap:Ethernet HWaddr 36:AA:A4:F4:1C:40 +inet addr:172.24.38.239 Bcast:172.24.38.255 +... +``` + +After the test steps above, release the VIP from any non-Primary node before attempting to start Failover Manager. + +!!! Note + The network interface used for the VIP does not have to be the same interface used for the Failover Manager agent's `bind.address` value. The primary agent will drop the VIP as needed during a failover, and Failover Manager will verify that the VIP is no longer available before promoting a standby. A failure of the bind address network will lead to primary isolation and failover. + +If the VIP uses a different interface, you may encounter a timing condition where the rest of the cluster checks for a reachable VIP before the primary agent has dropped it. In this case, EFM will retry the VIP check for the number of seconds specified in the `node.timeout` property to help ensure that a failover happens as expected. diff --git a/product_docs/docs/efm/4.2/efm_user/04_configuring_efm/06_configuring_for_eager_failover.mdx b/product_docs/docs/efm/4.2/efm_user/04_configuring_efm/06_configuring_for_eager_failover.mdx new file mode 100644 index 00000000000..a703762a71f --- /dev/null +++ b/product_docs/docs/efm/4.2/efm_user/04_configuring_efm/06_configuring_for_eager_failover.mdx @@ -0,0 +1,95 @@ +--- +title: "Configuring for Eager Failover" +--- + + + +In default run mode, if a primary Failover Manager process fails, there is no failover protection until the agent is restarted. To avoid such a case, you can set up the primary node through `systemd` to cause a failover when the primary agent exits, which is called Eager Failover. +You can set up Eager Failover by performing the following steps (the example uses Advanced Server version 12 and EFM version 4.2): + + + +# Enabling Eager Failover + +- Since the database server stops as soon as the Failover Manager agent stops or fails, you must set the following property for all the agents before starting Failover Manager: + ```text + primary.shutdown.as.failure=true + ``` + + If you do not set this property before starting Failover Manager, shutting down an EFM agent will shut down the database without failover. + +- With Eager Failover enabled, using the `efm stop-cluster` command will stop all of the efm agents and shut down the primary database. Since the agents are not running, there is no failover. To avoid such a scenario, the command can be disabled with the `enable.stop.cluster` property. + + ```text + enable.stop.cluster=false + ``` + +- Ensure that the database server and the local Failover Manager agent are running. + +- As root, create `/etc/systemd/system/edb-as-12.service` file and include: + + ```text + .include /lib/systemd/system/edb-as-12.service + [Unit] + BindsTo=edb-efm-4.2.service + ``` + +- Run the following command to reload the configuration files: + + ```text + systemctl daemon-reload + ``` + +With the above-mentioned changes, when the Failover Manager agent is stopped or is killed, the rest of the cluster will treat this situation as a failure and attempt a failover. + + + +# Disabling Eager Failover + +- If you want to stop Failover Manager without stopping the database, comment out the following line in `/etc/systemd/system/edb-as-12.service`: + ```text + BindsTo=edb-efm-4.2.service + ``` +- Run the following command to reload the configuration files: + ```text + systemctl daemon-reload + ``` + +# Upgrading EFM in Eager Failover Mode + +To upgrade Failover Manager without stopping Postgres, the Eager Failover mode should be temporarily disabled. Perform the following steps: + +1. [Disable Eager Failover](#disabling_the_eager_failover) + +2. [Stop and upgrade EFM](12_upgrading_existing_cluster/#upgrading_existing_cluster) + +3. [Enable Eager Failover](#enabling_the_eager_failover) + +# Important Notes + +- Since systemd command is not used to manage the database while running EFM with a non-sudo setup, Eager Failover is only supported in sudo mode and not supported in a non-sudo mode. + +- Eager failover is not suitable for situations where a VIP would not be released by the old primary. + +- Eager Failover is suitable in the following situations: + + - With the `EDB Postgres High Availability` setup + - In a setup using client connection failover with [jdbc](https://jdbc.postgresql.org/documentation/head/connect.html#connection-failover) or libpq [(target-session-attrs)](https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-PARAMKEYWORDS) + - When custom scripting triggered by `script.fence` would fence the old primary server (STONITH). Some examples would be to shut down the VM with VMWare vCenter integration, openstack integration, or lights-out management. + - When custom scripting triggered by `script.fence` would use ssh to deactivate the VIP. + + **Note:** + Setting `check.vip.before.promotion=false` is required to allow the new primary to attach the VIP before the old primary has released it. + +- Care must be taken when using `primary.shutdown.as.failure=true`. See the description of [primary.shutdown.as.failure](01_cluster_properties/#primary_shutdown_as_failure) property for information on how to safely bring down the database if needed. + +- With every failover, a primary ends up being a failed primary, which does not automatically recover as an operational standby. Therefore, the cluster should contain multiple promotable standbys, and the total number of standbys should be at least two more than the value specified for the `minimum.standbys` property. This is a general recommendation, but it becomes more pressing when using Eager Failover. +- If the database server is stopped, restarting the database will also start Failover Manager. + + **Notes:** + - If there is a problem starting EFM, such as a bad property value, the database server will start and shut down again without displaying any warning that it is not running. + - If the Failover Manager process was previously killed, the lock file will still exist and the agent can not be restarted automatically. + - If there are problems starting the database server or the Failover Manager agent, check the EFM startup log for information. + +- As a result of running the `stop-cluster` command, EFM will be stopped on all the nodes. In Eager Failover mode, the `stop-cluster` command would also stop Postgres without a failover. Set `enable.stop.cluster=false` to make sure the `stop-cluster` command can not unintentionally be invoked. + diff --git a/product_docs/docs/efm/4.2/efm_user/04_configuring_efm/index.mdx b/product_docs/docs/efm/4.2/efm_user/04_configuring_efm/index.mdx new file mode 100644 index 00000000000..8f944d53d10 --- /dev/null +++ b/product_docs/docs/efm/4.2/efm_user/04_configuring_efm/index.mdx @@ -0,0 +1,16 @@ +--- +title: "Configuring Failover Manager" +--- + + + +Configurable Failover Manager properties are specified in two user-modifiable files: + +- [efm.properties](01_cluster_properties/#cluster_properties) +- [efm.nodes](03_cluster_members/#cluster_members) + +
+ +cluster_properties encrypting_database_password cluster_members extending_efm_permissions using_vip_addresses + +
diff --git a/product_docs/docs/efm/4.2/efm_user/05_using_efm.mdx b/product_docs/docs/efm/4.2/efm_user/05_using_efm.mdx new file mode 100644 index 00000000000..c1167b70b96 --- /dev/null +++ b/product_docs/docs/efm/4.2/efm_user/05_using_efm.mdx @@ -0,0 +1,317 @@ +--- +title: "Using Failover Manager" +--- + + + +Failover Manager offers support for monitoring and failover of clusters with one or more Standby servers. You can add or remove nodes from the cluster as your demand for resources grows or shrinks. + +If a Primary node reboots, Failover Manager may detect the database is down on the Primary node and promote a Standby node to the role of Primary. If this happens, the Failover Manager agent on the (rebooted) Primary node will attempt to write a `recovery.conf` file to make sure Postgres does not start as a secondary primary. Therefore, the Failover Manager agent must be started before starting the database server. The agent will start in idle mode, and check to see if there is already a primary in the cluster. If there is a primary node, the agent will verify that a recovery.conf or standby.signal file exists, or create recovery.conf if needed to prevent the database from starting as a second primary. + +## Managing a Failover Manager Cluster + +Once configured, a Failover Manager cluster requires no regular maintenance. The following sections provide information about performing the management tasks that may occasionally be required by a Failover Manager Cluster. + +By default, [some of the efm commands](07_using_efm_utility/#using_efm_utility) must be invoked by `efm` or an OS superuser; an administrator can selectively permit users to invoke these commands by adding the user to the `efm` group. The commands are: + +- [efm allow-node](07_using_efm_utility/#efm_allow_node) +- [efm disallow-node](07_using_efm_utility/#efm_disallow_node) +- [efm promote](07_using_efm_utility/#efm_promote) +- [efm resume](07_using_efm_utility/#efm_resume) +- [efm set-priority](07_using_efm_utility/#efm_set_priority) +- [efm stop-cluster](07_using_efm_utility/#efm_stop_cluster) +- [efm upgrade-conf](07_using_efm_utility/#efm_upgrade_conf) + + + +### Starting the Failover Manager Cluster + +You can start the nodes of a Failover Manager cluster in any order. + +To start the Failover Manager cluster on RHEL/CentOS 7.x or RHEL/CentOS 8.x, assume superuser privileges, and invoke the command: + +```text +systemctl start edb-efm-4.2 +``` + +If the cluster properties file for the node specifies that `is.witness` is `true`, the node will start as a Witness node. + +If the node is not a dedicated Witness node, Failover Manager will connect to the local database and invoke the `pg_is_in_recovery()` function. If the server responds `false`, the agent assumes the node is a Primary node, and assigns a virtual IP address to the node (if applicable). If the server responds `true`, the Failover Manager agent assumes that the node is a Standby server. If the server does not respond, the agent will start in an idle state. + +After joining the cluster, the Failover Manager agent checks the supplied database credentials to ensure that it can connect to all of the databases within the cluster. If the agent cannot connect, the agent will shut down. + +If a new primary or standby node joins a cluster, all of the existing nodes will also confirm that they can connect to the database on the new node. + + + +!!! Note + If you are running `/var/lock` or `/var/run` on `tmpfs` (Temporary File System), make sure that the systemd service file for Failover Manager has a dependency on `systemd-tmpfiles-setup.service`. + +### Adding Nodes to a Cluster + +You can add a node to a Failover Manager cluster at any time. When you add a node to a cluster, you must modify the cluster to allow the new node, and then tell the new node how to find the cluster. The following steps detail adding a node to a cluster: + +1. Unless `auto.allow.hosts` is set to `true`, use the `efm allow-node` command, to add the address of the new node to the Failover Manager allowed node host list. When invoking the command, specify the cluster name and the address of the new node: + + ```text + efm allow-node
+ ``` + + For more information about using the `efm allow-node` command or controlling a Failover Manager service, see [Using the EFM Utility](07_using_efm_utility/#efm_allow_node). + + Install a Failover Manager agent and configure the cluster properties file on the new node. For more information about modifying the properties file, see [The Cluster Properties File](04_configuring_efm/01_cluster_properties/#cluster_properties). + +2. Configure the cluster members file on the new node, adding an entry for the Membership Coordinator. For more information about modifying the cluster members file, see [The Cluster Members File](04_configuring_efm/03_cluster_members/#cluster_members). + +3. Assume superuser privileges on the new node, and start the Failover Manager agent. To start the Failover Manager cluster on RHEL/CentOS 7.x or RHEL/CentOS 8.x, invoke the command: + + ```text + systemctl start edb-efm-4.2 + ``` + +When the new node joins the cluster, Failover Manager will send a notification to the administrator email provided in the `user.email` property, and/or will invoke the specified notification script. + + + +!!! Note + To be a useful Standby for the current node, the node must be a standby in the PostgreSQL Streaming Replication scenario. + +### Changing the Priority of a Standby + +If your Failover Manager cluster includes more than one Standby server, you can use the `efm set-priority` command to influence the promotion priority of a Standby node. Invoke the command on any existing member of the Failover Manager cluster, and specify a priority value after the IP address of the member. + +For example, the following command instructs Failover Manager that the `acctg` cluster member that is monitoring `10.0.1.9` is the primary Standby `(1)`: + +```text +efm set-priority acctg 10.0.1.9 1 +``` + +You can set the priority of a standby to `0` to make the standby non-promotable. Setting the priority of a standby to a value greater than `0` overrides a property value of `promotable=false`. + +For example, if the properties file on node `10.0.1.10` includes a setting of `promotable=false` and you use `efm set-priority` to set the promotion priority of `10.0.1.10` to be the standby used in the event of a failover, the value designated by the `efm set-priority` command will override the value in the property file: + +```text +efm set-priority acctg 10.0.1.10 1 +``` + +In the event of a failover, Failover Manager will first retrieve information from Postgres streaming replication to confirm which Standby node has the most recent data, and promote the node with the least chance of data loss. If two Standby nodes contain equally up-to-date data, the node with a higher user-specified priority value will be promoted to Primary unless [use.replay.tiebreaker](04_configuring_efm/01_cluster_properties/#use_replay_tiebreaker) is set to `false` . To check the priority value of your Standby nodes, use the command: + +```text +efm cluster-status +``` + + + +!!! Note + + The promotion priority for nodes will change when a new primary is promoted. + + If the efm set-priority command has been used to change whether or not a standby is promotable, this may be reset to the value in the standby's properties file through promotion or cluster splits and rejoins. + +### Promoting a Failover Manager Node + +You can invoke `efm promote` on any node of a Failover Manager cluster to start a manual promotion of a Standby database to Primary database. + +Manual promotion should only be performed during a maintenance window for your database cluster. If you do not have an up-to-date Standby database available, you will be prompted before continuing. To start a manual promotion, assume the identity of `efm` or the OS superuser, and invoke the command: + +```text +efm promote [-switchover] [-sourcenode
] [-quiet] [-noscripts]` +``` + +Where: + + `` is the name of the Failover Manager cluster. + + Include the `–switchover` option to reconfigure the original Primary as a Standby. If you include the `–switchover` keyword, the cluster must include a primary node and at least one standby, and the nodes must be in sync. + + Include the `–sourcenode` keyword to specify the node from which the recovery settings will be copied to the primary. + + Include the `-quiet` keyword to suppress notifications during switchover. + + Include the `-noscripts` keyword to prevent instruct Failover Manager to not invoke fencing and post-promotion scripts. + +During switchover: + +- For server versions 11 and prior, the `recovery.conf` file is copied from an existing standby to the primary node. For server version 12 and later, the `primary_conninfo` and `restore_command` parameters are copied and stored in memory. +- The primary database is stopped. +- If you are using a VIP, the address is released from the primary node. +- A standby is promoted to replace the primary node, and acquires the VIP. +- The address of the new primary node is added to the `recovery.conf` file or the `primary_conninfo` details are stored in memory. +- If the `application.name` property is set for this node, the application_name property will be added to the `recovery.conf` file or the `primary_conninfo` information will be stored in memory. +- If you are using server version 12 or later, the recovery settings that have been stored in memory are written to the `postgresql.auto.conf` file. A `standby.signal` file is created. +- The old primary is started; the agent will resume monitoring it as a standby. + +During a promotion, the Primary agent releases the virtual IP address. If it is not a switchover, a `recovery.conf` file is created in the directory specified by the `db.data.dir` property. The `recovery.conf` file is used to prevent the old primary database from starting until the file is removed, preventing the node from starting as a second primary in the cluster. If the promotion is part of a switchover, recovery settings are handled as described above. + +The Primary agent remains running, and assumes a status of Idle. + +The Standby agent confirms that the virtual IP address is no longer in use before pinging a well- known address to ensure that the agent is not isolated from the network. The Standby agent runs the fencing script and promotes the Standby database to Primary. The Standby agent then assigns the virtual IP address to the Standby node, and runs the post-promotion script (if applicable). + +Note that this command instructs the service to ignore the value specified in the `auto.failover` parameter in the cluster properties file. + +To return a node to the role of primary, place the node first in the promotion list: + +```text +efm set-priority
+``` + +Then, perform a manual promotion: + +```text +efm promote ‑switchover +``` + +For more information about the efm utility, see [Using the EFM Utility](07_using_efm_utility/#using_efm_utility). + + + +### Stopping a Failover Manager Agent + +When you stop an agent, Failover Manager will remove the node's address from the cluster members list on all of the running nodes of the cluster, but will not remove the address from the Failover Manager Allowed node host list. + +To stop the Failover Manager agent on RHEL/CentOS 7.x or RHEL/CentOS 8.x, assume superuser privileges, and invoke the command: + +```text +systemctl stop edb-efm-4.2 +``` + +Until you invoke the `efm disallow-node` command (removing the node's address of the node from the Allowed node host list), you can use the `service edb-efm-4.2 start` command to restart the node at a later date without first running the `efm allow-node` command again. + + +Note that stopping an agent does not signal the cluster that the agent has failed unless the [primary.shutdown.as.failure](04_configuring_efm/01_cluster_properties/#primary_shutdown_as_failure) property is set to `true`. + +### Stopping a Failover Manager Cluster + +To stop a Failover Manager cluster, connect to any node of a Failover Manager cluster, assume the identity of `efm` or the OS superuser, and invoke the command: + +```text +efm stop-cluster +``` + +The command will cause *all* Failover Manager agents to exit. Terminating the Failover Manager agents completely disables all failover functionality. + +!!! Note + When you invoke the `efm stop-cluster` command, all authorized node information is lost from the Allowed node host list. + +### Removing a Node from a Cluster + +The `efm disallow-node` command removes the IP address of a node from the Failover Manager Allowed Node host list. Assume the identity of `efm` or the OS superuser on any existing node (that is currently part of the running cluster), and invoke the `efm disallow-node` command, specifying the cluster name and the IP address of the node: + +```text +efm disallow-node
+``` + +The `efm disallow-node` command will not stop a running agent; the service will continue to run on the node until you [stop the agent](#stop_efm_agent). If the agent or cluster is subsequently stopped, the node will not be allowed to rejoin the cluster, and will be removed from the failover priority list (and will be ineligible for promotion). + +After invoking the `efm disallow-node` command, you must use the [efm allow-node](07_using_efm_utility/#efm_allow_node) command to add the node to the cluster again. + + + +## Running Multiple Agents on a Single Node + +You can monitor multiple database clusters that reside on the same host by running multiple Primary or Standby agents on that Failover Manager node. You may also run multiple Witness agents on a single node. To configure Failover Manager to monitor more than one database cluster, while ensuring that Failover Manager agents from different clusters do not interfere with each other, you must: + +1. Create a cluster properties file for each member of each cluster that defines a unique set of properties and the role of the node within the cluster. +2. Create a cluster members file for each member of each cluster that lists the members of the cluster. +3. Customize the unit file (on a RHEL/CentOS 7.x or RHEL/CentOS 8.x system) for each cluster to specify the names of the cluster properties and the cluster members files. +4. Start the services for each cluster. + +The examples that follow uses two database clusters (acctg and sales) running on the same node: + +- Data for `acctg` resides in `/opt/pgdata1`; its server is monitoring port `5444`. +- Data for `sales` resides in `/opt/pgdata2`; its server is monitoring port `5445`. + +To run a Failover Manager agent for both of these database clusters, use the `efm.properties.in` template to create two properties files. Each cluster properties file must have a unique name. For this example, we create `acctg.properties` and `sales.properties` to match the `acctg` and `sales` database clusters. + +The following parameters must be unique in each cluster properties file: + + `admin.port` + + `bind.address` + + `db.port` + + `db.data.dir` + + `virtual.ip` (if used) + + `virtual.ip.interface` (if used) + +Within each cluster properties file, the `db.port` parameter should specify a unique value for each cluster, while the `db.user` and `db.database` parameter may have the same value or a unique value. For example, the `acctg.properties` file may specify: + + `db.user=efm_user` + + `db.password.encrypted=7c801b32a05c0c5cb2ad4ffbda5e8f9a` + + `db.port=5444` + + `db.database=acctg_db` + +While the `sales.properties` file may specify: + + `db.user=efm_user` + + `db.password.encrypted=e003fea651a8b4a80fb248a22b36f334` + + `db.port=5445` + + `db.database=sales_db` + +Some parameters require special attention when setting up more than one Failover Manager cluster agent on the same node. If multiple agents reside on the same node, each port must be unique. Any two ports will work, but it may be easier to keep the information clear if using ports that are not too close to each other. + +When creating the cluster properties file for each cluster, the `db.data.dir` parameters must also specify values that are unique for each respective database cluster. + +The following parameters are used when assigning the virtual IP address to a node. If your Failover Manager cluster does not use a virtual IP address, leave these parameters blank. + + `virtual.ip` + + `virtual.ip.interface` + + `virtual.ip.prefix` + +This parameter value is determined by the virtual IP addresses being used and may or may not be the same for both `acctg.properties` and `sales.properties`. + +After creating the `acctg.properties` and `sales.properties` files, create a service script or unit file for each cluster that points to the respective property files; this step is platform specific. If you are using RHEL/CentOS 7.x or RHEL/CentOS 8.x, see [RHEL/CentOS 7.x or RHEL/CentOS 8.x](#rhelcentos-7x-or-rhelcentos-8x). + +!!! Note + If you are using a unit file, you must manually update the file to reflect the new service name when you upgrade Failover Manager. + +### RHEL/CentOS 7.x or RHEL/CentOS 8.x + +If you are using RHEL/CentOS 7.x or RHEL/CentOS 8.x, you should copy the `edb-efm-4.2` unit file to new file with a name that is unique for each cluster. For example, if you have two clusters (named acctg and sales), the unit file names might be: + +```text +/usr/lib/systemd/system/efm-acctg.service + +/usr/lib/systemd/system/efm-sales.service +``` + +Then, edit the `CLUSTER` variable within each unit file, changing the specified cluster name from `efm` to the new cluster name. For example, for a cluster named `acctg`, the value would specify: + +```text +Environment=CLUSTER=acctg +``` + +You must also update the value of the `PIDfile` parameter to specify the new cluster name. For example: + +```text +PIDFile=/var/run/efm-4.2/acctg.pid +``` + +After copying the service scripts, use the following commands to enable the services: + +```text +# systemctl enable efm-acctg.service + +# systemctl enable efm-sales.service +``` + +Then, use the new service scripts to start the agents. For example, you can start the `acctg` agent with the command: + +```text +# systemctl start efm-acctg` +``` + +For information about customizing a unit file, please visit: + + diff --git a/product_docs/docs/efm/4.2/efm_user/06_monitoring_efm_cluster.mdx b/product_docs/docs/efm/4.2/efm_user/06_monitoring_efm_cluster.mdx new file mode 100644 index 00000000000..3aa94260dd3 --- /dev/null +++ b/product_docs/docs/efm/4.2/efm_user/06_monitoring_efm_cluster.mdx @@ -0,0 +1,138 @@ +--- +title: "Monitoring a Failover Manager Cluster" +--- + + + +You can use either the Failover Manager `efm cluster-status` command or the PEM Client graphical interface to check the current status of a monitored node of a Failover Manager cluster. + +## Reviewing the Cluster Status Report + +The efm cluster-status [cluster properties file](07_using_efm_utility/#efm_cluster_status) command returns a report that contains information about the status of the Failover Manager cluster. To invoke the command, enter: + +```text +# efm cluster-status +``` + +The following status report is for a cluster named edb that has three nodes running: + +```text +Agent Type Address Agent DB VIP +----------------------------------------------------------------------- +Standby 172.19.10.2 UP UP 192.168.225.190 +Standby 172.19.12.163 UP UP 192.168.225.190 +Primary 172.19.14.9 UP UP 192.168.225.190* + + +Allowed node host list: +172.19.14.9 172.19.12.163 172.19.10.2 + + +Membership coordinator: 172.19.14.9 + + +Standby priority host list: +172.19.12.163 172.19.10.2 + +Promote Status: + +DB Type Address WAL Received LSN WAL Replayed LSN Info +-------------------------------------------------------------------- +Primary 172.19.14.9 0/4000638 +Standby 172.19.12.163 0/4000638 0/4000638 +Standby 172.19.10.2 0/4000638 0/4000638 + + +Standby database(s) in sync with primary. It is safe to promote. +``` + +The cluster status section provides an overview of the status of the agents that reside on each node of the cluster: + +```text +Agent Type Address Agent DB VIP +----------------------------------------------------------------------- +Standby 172.19.10.2 UP UP 192.168.225.190 +Standby 172.19.12.163 UP UP 192.168.225.190 +Primary 172.19.14.9 UP UP 192.168.225.190* +``` + +The asterisk (\*) after the VIP address indicates that the address is available for connections. If a VIP address is not followed by an asterisk, the address has been associated with the node (in the properties file), but the address is not currently in use. + +Failover Manager agents provide the information displayed in the Cluster Status section. + +The `Allowed node host list` and `Standby priority host list` provide an easy way to tell which nodes are allowed to join the cluster, and the promotion order of the nodes. The IP address of the Membership coordinator is also displayed in the report: + +```text +Allowed node host list: +172.19.14.9 172.19.12.163 172.19.10.2 +Membership coordinator: 172.19.14.9 +Standby priority host list: +172.19.12.163 172.19.10.2 +``` + +The `Promote Status` section of the report is the result of a direct query from the node on which you are invoking the cluster-status command to each database in the cluster; the query also returns the transaction log location of each database. Because the queries to each database return at different points in time, the LSNs may not match even if streaming replication is working normally for the cluster. + +```text +Promote Status: + +DB Type Address WAL Received LSN WAL Replayed LSN Info +------------------------------------------------------------------- +Primary 172.19.14.9 0/4000638 +Standby 172.19.12.163 0/4000638 0/4000638 +Standby 172.19.10.2 0/4000638 0/4000638 +``` + +If a database is down (or if the database has been restarted, but the resume command has not yet been invoked), the state of the agent that resides on that host will be Idle. If an agent is idle, the cluster status report will include a summary of the condition of the idle node. For example: + +```text +Agent Type Address Agent DB VIP +----------------------------------------------------- +Idle 172.19.18.105 UP UP 172.19.13.105 +``` + +**Exit Codes** + +The cluster status process returns an exit code that is based on the state of the cluster: + +- An exit code of `0` indicates that all agents are running, and the databases on the Primary and Standby nodes are running and in sync. + +- A non-zero exit code indicates that there is a problem. The following problems can trigger a non-zero exit code: + + A database is down or unknown (or has an idle agent). + + Failover Manager cannot decrypt the provided database password. + + There is a problem contacting the databases to get WAL locations. + + There is no Primary agent. + + There are no Standby agents. + + One or more Standby nodes are not in sync with the Primary. + +## Monitoring Streaming Replication with Postgres Enterprise Manager + +If you use Postgres Enterprise Manager (PEM) to monitor your servers, you can configure the Streaming Replication Analysis dashboard (part of the PEM graphical interface) to display the state of a Primary or Standby node that is part of a Streaming Replication scenario. + +![The Streaming Replication dashboard (Primary node)](images/str_replication_dashboard_master.png) + +The Streaming Replication Analysis Dashboard displays statistical information about activity for any monitored server on which streaming replication is enabled. The dashboard header identifies the status of the monitored server (either Replication Primary or Replication Slave), and displays the date and time that the server was last started, the date and time that the page was last updated, and a current count of triggered alerts for the server. + +When reviewing the dashboard for a Replication Slave (a Standby node), a label at the bottom of the dashboard confirms the status of the server. + +![The Streaming Replication dashboard (Standby node)](images/str_replication_dashboard_standby.png) + +By default, the PEM replication probes that provide information for the Streaming Replication Analysis dashboard are disabled. + +To view the Streaming Replication Analysis dashboard for the Primary node of a replication scenario, you must enable the following probes: + +- Streaming Replication +- WAL Archive Status + +To view the Streaming Replication Analysis dashboard for the Standby node of a replication scenario, you must enable the following probes: + +- Streaming Replication Lag Time + +For more information about PEM, please visit the EnterpriseDB website at: + + diff --git a/product_docs/docs/efm/4.2/efm_user/07_using_efm_utility.mdx b/product_docs/docs/efm/4.2/efm_user/07_using_efm_utility.mdx new file mode 100644 index 00000000000..684a099abb4 --- /dev/null +++ b/product_docs/docs/efm/4.2/efm_user/07_using_efm_utility.mdx @@ -0,0 +1,209 @@ +--- +title: "Using the efm Utility" +--- + + + +Failover Manager provides the efm utility to assist with cluster management. The RPM installer adds the utility to the `/usr/edb/efm-42/bin` directory when you install Failover Manager. + +**efm allow-node** + + + +```text +efm allow-node +``` + +Invoke the `efm allow-node` command to allow the specified node to join the cluster. When invoking the command, provide the name of the cluster and the IP address of the joining node. + +This command must be invoked by `efm`, a member of the `efm` group, or root. + +**efm disallow-node** + + + +```text +efm disallow-node
+``` + +Invoke the `efm disallow-node` command to remove the specified node from the allowed hosts list, and prevent the node from joining a cluster. Provide the name of the cluster and the address of the node when calling the `efm disallow-node` command. This command must be invoked by `efm`, a member of the `efm` group, or root. + +**efm cluster-status** + + + +```text +efm cluster-status +``` + +Invoke the `efm cluster-status` command to display the status of a Failover Manager cluster. For more information about the status report, see [Monitoring a Failover Manager Cluster](06_monitoring_efm_cluster/#monitoring_efm_cluster). + +**efm cluster-status-json** + + + +```text +efm cluster-status-json +``` + +Invoke the `efm cluster-status-json` command to display the status of a Failover Manager cluster in json format. While the format of the displayed information is different than the display generated by the efm cluster-status command, the information source is the same. + +The following example is generated by querying the status of a healthy cluster with three nodes: + +```text +{ + "nodes": { + "172.16.144.176": { + "type": "Witness", + "agent": "UP", + "db": "N\/A", + "vip": "", + "vip_active": false + }, + "172.16.144.177": { + "type": "Primary", + "agent": "UP", + "db": "UP", + "vip": "", + "vip_active : false" + "xlogReceive : 0/14001478" + "xlog : 0/14001478" + "xloginfo :" + }, + "172.16.144.180": { + "type": "Standby", + "agent": "UP", + "db": "UP", + "vip": "", + "vip_active : false" + "xlogReceive : 0/14001478" + "xlog : 0/14001478" + "xloginfo :" + } + }, + "allowednodes": [ + "172.16.144.177", + "172.16.144.160", + "172.16.144.180", + "172.16.144.176" + ], + "membershipcoordinator": "172.16.144.177", + "failoverpriority": [ + "172.16.144.180" + ], + "minimumstandbys": 0, + "missingnodes": [], + "messages": [] +} +``` + +**efm encrypt** + + + +```text +efm encrypt [--from-env] +``` + +Invoke the `efm encrypt` command to encrypt the database password before include the password in the cluster properties file. Include the `--from-env` option to instruct Failover Manager to use the value specified in the `EFMPASS` environment variable, and execute without user input. For more information, see [Encrypting Your Database Password](04_configuring_efm/01_cluster_properties/01_encrypting_database_password/#encrypting_database_password). + +**efm promote** + + + +```text +efm promote cluster_name [-switchover [-sourcenode
][-quiet][-noscripts] +``` + +The `efm promote` command instructs Failover Manager to perform a manual failover of standby to primary. + +Manual promotion should only be attempted if the status command reports that the cluster includes a Standby node that is up-to-date with the Primary. If there is no up-to-date Standby, Failover Manager will prompt you before continuing. + +Include the `–switchover` clause to promote a standby node, and reconfigure a primary node as a standby node. Include the `-sourcenode` keyword, and specify a node address to indicate the node whose recovery settings will be copied to the old primary node (making it a standby). Include the `-quiet` keyword to suppress notifications during the switchover process. Include the `-noscripts` keyword to instruct Failover Manager to not invoke fencing or post-promotion scripts. + +This command must be invoked by `efm`, a member of the `efm` group, or root. + +!!! Note + This command instructs the service to ignore the value specified in the `auto.failover` parameter in the cluster properties file. + +**efm resume** + + + +```text +efm resume +``` + +Invoke the `efm resume` command to resume monitoring a previously stopped database. This command must be invoked by efm, a member of the efm group, or root. + +**efm set-priority** + + + +```text +efm set-priority
+``` + +Invoke the `efm set-priority` command to assign a failover priority to a standby node. The value specifies the order in which the node will be used in the event of a failover. This command must be invoked by `efm`, a member of the `efm` group, or root. + +Use the priority option to specify the place for the node in the priority list. For example, specify a value of 1 to indicate that the node is the primary standby, and will be the first node promoted in the event of a failover. A priority value of 0 instructs Failover Manager to not promote the standby. + +**efm stop-cluster** + + + +```text +efm stop-cluster +``` + +Invoke the `efm stop-cluster` command to stop Failover Manager on all nodes. This command instructs Failover Manager to connect to each node on the cluster and instruct the existing members to shut down. The command has no effect on running databases, but when the command completes, there is no failover protection in place. + +!!! Note + When you invoke the `efm stop-cluster` command, all authorized node information is removed from the Allowed node host list. + +This command must be invoked by `efm`, a member of the `efm` group, or root. + +**efm upgrade-conf** + + + +```text +efm upgrade-conf [-source ] +``` + +Invoke the `efm upgrade-conf` command to copy the configuration files from an existing Failover Manager installation, and add parameters required by a Failover Manager installation. Provide the name of the previous cluster when invoking the utility. This command must be invoked with root privileges. + +If you are upgrading from a Failover Manager configuration that does not use sudo, include the `-source` flag and specify the name of the *directory* in which the configuration files reside when invoking upgrade-conf. + +**efm node-status-json** + + + +```text +efm node-status-json +``` + +Invoke the `efm node-status-json` command to display the status of a local node in json format. A successful execution of this command returns `0` as its exit code. In case of a database failure or an agent status becoming IDLE, the command returns `1` as exit code. + +The following is an example output of the `efm node-status-json` command: + +```text +{ + "type":"Standby", + "address":"172.16.144.130", + "agent":"UP", + "db":"UP", + "vip":"", + "vip_active":"false" + } +``` + +**efm --help** + + + +```text +efm --help +``` + +Invoke the `efm --help` command to display online help for the Failover Manager utility commands. diff --git a/product_docs/docs/efm/4.2/efm_user/08_controlling_efm_service.mdx b/product_docs/docs/efm/4.2/efm_user/08_controlling_efm_service.mdx new file mode 100644 index 00000000000..ae65d8808ef --- /dev/null +++ b/product_docs/docs/efm/4.2/efm_user/08_controlling_efm_service.mdx @@ -0,0 +1,51 @@ +--- +title: "Controlling the Failover Manager Service" +--- + + + +Each node in a Failover Manager cluster hosts a Failover Manager agent that is controlled by a service script. By default, the service script expects to find: + +- A configuration file named `efm.properties` that contains the properties used by the Failover Manager service. Each node of a replication scenario must contain a properties file that provides information about the node. +- A cluster members file named `efm.nodes` that contains a list of the cluster members. Each node of a replication scenario must contain a cluster members list. + +Note that if you are running multiple clusters on a single node you will need to manually create configuration files with cluster-specific names and modify the service script for the corresponding clusters. + +The commands that control the Failover Manager service are platform-specific. + + + +## Using the systemctl Utility on RHEL/CentOS 7.x and RHEL/CentOS 8.x + +On RHEL/CentOS 7.x and RHEL/CentOS 8.x, Failover Manager runs as a Linux service named (by default) `edb-efm-4.2.service` that is located in `/usr/lib/systemd/system`. Each database cluster monitored by Failover Manager will run a copy of the service on each node of the replication cluster. + +Use the following systemctl commands to control a Failover Manager agent that resides on a RHEL/CentOS 7.x and RHEL/CentOS 8.x host: + +```text +systemctl start edb-efm-4.2 +``` + +The start command starts the Failover Manager agent on the current node. The local Failover Manager agent monitors the local database and communicates with Failover Manager on the other nodes. You can start the nodes in a Failover Manager cluster in any order. This command must be invoked by root. + +```text +systemctl stop edb-efm-4.2 +``` + +Stop the Failover Manager on the current node. This command must be invoked by root. + +```text +systemctl status edb-efm-4.2 +``` + +The status command returns the status of the Failover Manager agent on which it is invoked. You can invoke the status command on any node to instruct Failover Manager to return status and server startup information. + +```text +[root@ONE ~]}> systemctl status edb-efm-4.2 + edb-efm-4.2.service - EnterpriseDB Failover Manager 4.2 + Loaded: loaded (/usr/lib/systemd/system/edb-efm-4.2.service; disabled; vendor preset: disabled) + Active: active (running) since Wed 2013-02-14 14:02:16 EST; 4s ago + Process: 58125 ExecStart=/bin/bash -c /usr/edb/edb-efm-4.2/bin/runefm.sh start ${CLUSTER} (code=exited, status=0/SUCCESS) + Main PID: 58180 (java) + CGroup: /system.slice/edb-efm-4.2.service + └─58180 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-0.b14.el7_4.x86_64/jre/bin/java -cp /usr/edb/edb-efm-4.2/lib/EFM-4.2.0.jar -Xmx128m... +``` diff --git a/product_docs/docs/efm/4.2/efm_user/09_controlling_logging.mdx b/product_docs/docs/efm/4.2/efm_user/09_controlling_logging.mdx new file mode 100644 index 00000000000..2d9fcae75b8 --- /dev/null +++ b/product_docs/docs/efm/4.2/efm_user/09_controlling_logging.mdx @@ -0,0 +1,86 @@ +--- +title: "Controlling Logging" +--- + + + +Failover Manager writes and stores one log file per agent and one startup log per agent in `/var/log/-4.2` (where `` specifies the name of the cluster). + +You can control the level of detail written to the agent log by modifying the `jgroups.loglevel` and `efm.loglevel` parameters in the [cluster properties file](04_configuring_efm/01_cluster_properties/#loglevel): + +```text +# Logging levels for JGroups and EFM. +# Valid values are: TRACE, DEBUG, INFO, WARN, ERROR +# Default value: INFO +# It is not necessary to increase these values unless debugging a +# specific issue. If nodes are not discovering each other at +# startup, increasing the jgroups level to DEBUG will show +# information about the TCP connection attempts that may help +# diagnose the connection failures. +jgroups.loglevel=INFO +efm.loglevel=INFO +``` + +The logging facilities use the Java logging library and logging levels. The log levels (in order from most logging output to least) are: + +> - `TRACE` +> - `DEBUG` +> - `INFO` +> - `WARN` +> - `ERROR` + +For example, if you set the `efm.loglevel` parameter to `WARN`, Failover Manager will only log messages at the `WARN` level and above (`WARN` and `ERROR`). + +By default, Failover Manager log files are rotated daily, compressed, and stored for a week. You can modify the file rotation schedule by changing settings in the log rotation file (`/etc/logrotate.d/efm-4.2`). For more information about modifying the log rotation schedule, consult the logrotate man page: + +> `$ man logrotate` + + + +## Enabling syslog Log File Entries + +Failover Manager supports syslog logging. To implement syslog logging, you must configure syslog to allow UDP or TCP connections. + +To allow a connection to syslog, edit the `/etc/rsyslog.conf` file and uncomment the protocol you wish to use. You must also ensure that the `UDPServerRun` or `TCPServerRun` entry associated with the protocol includes the port number to which log entries will be sent. For example, the following configuration file entries enable UDP connections to port 514: + +```text +# Provides UDP syslog reception +$ModLoad imudp +$UDPServerRun 514 +``` + +The following configuration file entries enable TCP connections to port 514: + +```text +# Provides TCP syslog reception +$ModLoad imtcp +$InputTCPServerRun 514 +``` + +After modifying the syslog configuration file, restart the `rsyslog` service to enable the connections: + +> `systemctl restart rsyslog.service` + +After modifying the `rsyslog.conf` file on the Failover Manager host, you must modify the Failover Manager properties to enable logging. Use your choice of editor to [modify the properties file](04_configuring_efm/01_cluster_properties/#logtype_enabled) (`/etc/edb/efm-4.2/efm.properties.in`) specifying the type of logging that you wish to implement: + +```text +# Which logging is enabled. +file.log.enabled=true +syslog.enabled=false +``` + +You must also [specify syslog details](04_configuring_efm/01_cluster_properties/#syslog_logging) for your system. Use the `syslog.protocol` parameter to specify the protocol type (UDP or TCP) and the `syslog.port` parameter to specify the listener port of the syslog host. The `syslog.facility` value may be used as an identifier for the process that created the entry; the value must be between `LOCAL0` and `LOCAL7`. + +```text +# Syslog information. The syslog service must be listening # on the + port for the given protocol, which can be UDP or +# TCP. The facilities supported are LOCAL0 through LOCAL7. +# syslog.host=localhost +syslog.port=514 +syslog.protocol=UDP +syslog.facility=LOCAL1 +``` + +For more information about syslog, please see the syslog man page: + +> `syslog man` diff --git a/product_docs/docs/efm/4.2/efm_user/10_notifications.mdx b/product_docs/docs/efm/4.2/efm_user/10_notifications.mdx new file mode 100644 index 00000000000..f489dd6a6d9 --- /dev/null +++ b/product_docs/docs/efm/4.2/efm_user/10_notifications.mdx @@ -0,0 +1,161 @@ +--- +title: "Notifications" +--- + + + +Failover Manager will send e-mail notifications and/or invoke a notification script when a notable event occurs that affects the cluster. If you have configured Failover Manager to send an email notification, you must have an SMTP server running on port 25 on each node of the cluster. Use the following parameters to configure notification behavior for Failover Manager: + +```text +user.email +script.notification +from.email +``` + +For more information about editing the configuration properties, see [Specifying Cluster Properties](04_configuring_efm/01_cluster_properties/#cluster_properties). + +The body of the notification contains details about the event that triggered the notification, and about the current state of the cluster. For example: + +```text +EFM node: 10.0.1.11 +Cluster name: acctg +Database name: postgres +VIP: ip_address (Active|Inactive) +Database health is not being monitored. +``` + +The VIP field displays the IP address and state of the virtual IP if implemented for the node. + +Failover Manager assigns a severity level to each notification. The following levels indicate increasing levels of attention required: + +- `INFO` indicates an informational message about the agent and does not require any manual intervention (for example, Failover Manager has started or stopped). See [List of INFO level notifications](#notifications_info) +- `WARNING` indicates that an event has happened that requires the administrator to check on the system (for example, failover has occurred). See [List of WARNING level notifications](#notifications_warning) +- `SEVERE` indicates that a serious event has happened and requires the immediate attention of the administrator (for example, failover was attempted, but was unable to complete). See [List of SEVERE level notifications](#notifications_severe) + +The severity level designates the urgency of the notification. A notification with a severity level of `SEVERE` requires user attention immediately, while a notification with a severity level of `INFO` will call your attention to operational information about your cluster that does not require user action. Notification severity levels are not related to logging levels; all notifications are sent regardless of the log level detail specified in the configuration file. + +You can use the [notification.level](04_configuring_efm/01_cluster_properties/#notification_level) property to specify the minimum severity level that will trigger a notification. + +!!! Note + In addition to sending notices to the administrative email address, all notifications are recorded in the agent log file (`/var/log/efm-4.2/<*cluster name*>.log`). + +The conditions listed in the table below will trigger an `INFO` level notification: + + + +| Subject | Description | +| -------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Executed fencing script | Executed fencing script *script_name* Results: *script_results* | +| Executed post-promotion script | Executed post-promotion script *script_name* Results: *script_results* | +| Executed remote pre-promotion script | Executed remote pre-promotion script *script_name* Results: *script_results* | +| Executed remote post-promotion script | Executed remote post-promotion script *script_name* Results: *script_results* | +| Executed post-database failure script | Executed post-database failure script *script_name* Results: *script_results* | +| Executed primary isolation script | Executed primary isolation script *script_name* Results: *script_results* | +| Witness agent running on *node_address* for cluster *cluster_name* | Witness agent is running. | +| Primary agent running on *node_address* for cluster *cluster_name* | Primary agent is running and database health is being monitored. | +| Standby agent running on *node_address* for cluster *cluster_name* | Standby agent is running and database health is being monitored. | +| Idle agent running on node *node_address* for cluster *cluster_name* | Idle agent is running. After starting the local database, the agent can be resumed. | +| Assigning VIP to node *node_address* | Assigning VIP *VIP_address* to node *node_address* Results: *script_results* | +| Releasing VIP from node *node_address* | Releasing VIP *VIP_address* from node *node_address* Results: *script_results* | +| Starting auto resume check for cluster *cluster_name* | The agent on this node will check every *auto.resume.period* seconds to see if it can resume monitoring the failed database. The cluster should be checked during this time and the agent stopped if the database will not be started again. See the agent log for more details. | +| Executed agent resumed script | Executed agent resumed script script_name Results: script_results | +| WAL logs backed up during promotion | When reconfiguring this standby to follow the new primary, the pg_xlog or pg_wal contents were backed up in the pgdata directory. This backup should be removed when convenient to free up disk space. | + +The conditions listed in the table below will trigger a *WARNING* level notification: + + + +| Subject | Description | +| ----------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Witness agent exited on *node_address* for cluster *cluster_name* | Witness agent has exited. | +| Primary agent exited on *node_address* for cluster *cluster_name* | Database health is not being monitored. | +| Cluster *cluster_name* notified that primary agent has left | Failover is disabled for the cluster until the primary agent is restarted. | +| Standby agent exited on *node_address* for cluster *cluster_name* | Database health is not being monitored. | +| Agent exited during promotion on *node_address* for cluster *cluster name* | Database health is not being monitored. | +| Agent exited on *node_address* for cluster *cluster name* | The agent has exited. This is generated by an agent in the Idle state. | +| Agent exited for cluster *cluster name* | The agent has exited. This notification is usually generated during startup when an agent exits before startup has completed. | +| Virtual IP address assigned to non-primary node | The virtual IP address appears to be assigned to a non-primary node. To avoid any conflicts, Failover Manager will release the VIP. You should confirm that the VIP is assigned to your primary node and manually reassign the address if it is not. | +| Virtual IP address not assigned to primary node. | The virtual IP address appears to not be assigned to a primary node. EDB Postgres Failover Manager will attempt to reacquire the VIP. | +| No standby agent in cluster for cluster *cluster name* | The standbys on *cluster_name* have left the cluster. | +| Standby agent failed for cluster *cluster name* | A standby agent on *cluster_name* has left the cluster, but the coordinator has detected that the standby database is still running. | +| Standby database failed for cluster *cluster name* | A standby agent has signaled that its database has failed. The other nodes also cannot reach the standby database. | +| Standby agent cannot reach database for cluster *cluster name* | A standby agent has signaled database failure, but the other nodes have detected that the standby database is still running. | +| Cluster *cluster name* has dropped below three nodes | At least three nodes are required for full failover protection. Please add witness or agent node to the cluster. | +| Subset of cluster *cluster name* disconnected from primary | This node is no longer connected to the majority of the cluster *cluster name*. Because this node is part of a subset of the cluster, failover will not be attempted. Current nodes that are visible are: *node_address*. | +| Promotion has started on cluster *cluster name*. | The promotion of a standby has started on cluster *cluster_name*. | +| Witness failure for cluster *cluster_name* | Witness running at *node_address* has left the cluster. | +| Idle agent failure for cluster *cluster_name*. | Idle agent running at *node_address* has left the cluster. | +| One or more nodes isolated from network for cluster *cluster_name* | This node appears to be isolated from the network. Other members seen in the cluster are: node_name | +| Node no longer isolated from network for cluster *cluster_name*. | This node is no longer isolated from the network. | +| Failover Manager tried to promote, but primary DB is still running | Failover Manager has started promotion steps, but detected that the primary DB is still running on *address*. This usually indicates that the primary EFM agent has exited. Failover has NOT occurred. There is no failover protection until the primary agent is restarted. | +| Primary agent missing for cluster *cluster_name* | The primary agent has previously left the cluster. Until a primary agent joins the cluster, there is no failover protection. | +| Standby agent started to promote, but primary has rejoined. | The standby EFM agent started to promote itself, but found that a primary agent has rejoined the cluster. Failover has NOT occurred. | +| Standby agent tried to promote, but could not verify primary DB | The standby EFM agent tried to promote itself, but could not detect whether or not the primary DB is still running on *node_address*. Failover has NOT occurred. | +| Standby agent tried to promote, but VIP appears to still be assigned | The standby EFM agent tried to promote itself, but could not because the virtual IP address (VIP_address) appears to still be assigned to another node. Promoting under these circumstances could cause data corruption. Failover has NOT occurred. | +| Standby agent tried to promote, but appears to be orphaned | The standby EFM agent tried to promote itself, but could not because the well-known server (server_address) could not be reached. This usually indicates a network issue that has separated the standby agent from the other agents. Failover has NOT occurred. | +| Potential manual failover required on cluster *cluster_name*. | A potential failover situation was detected for cluster *cluster_name*. Automatic failover has been disabled for this cluster, so manual intervention is required. | +| Failover has completed on cluster *cluster_name* | Failover has completed on cluster *cluster_name*. | +| Lock file for cluster *cluster_name* has been removed | The lock file for cluster *cluster_name* has been removed from: path_name on node *node_address*. This lock prevents multiple agents from monitoring the same cluster on the same node. Please restore this file to prevent accidentally starting another agent for cluster. | +| A recovery file for cluster *cluster_name* has been found on primary node | A recovery file for cluster *cluster_name* has been found at: path_name on primary node *node_address*. This may be problematic should you attempt to restart the DB on this node. | +| recovery_target_timeline is not set to latest in recovery settings | The recovery_target_timeline parameter is not set to latest in the recovery settings. The standby server will not be able to follow a timeline change that occurs when a new primary is promoted. | +| Promotion has not occurred for cluster *cluster_name* | A promotion was attempted but there is already a node being promoted: ip_address. | +| Standby will not be reconfigured after failover in cluster **cluster_name** | The 'auto.reconfigure' property has been set to false for this node, so it will not be reconfigured to follow the new primary node after a promotion. | +| Could not resume replay for standby standby_id. | Could not resume replay for standby. Manual intervention may be required. Error: error_message. | +| Possible problem with database timeout values | Your remote.timeout value (value) is higher than your local.timeout value (value). If the local database takes too long to respond, the local agent could assume that the database has failed though other agents can connect. While this will not cause a failover, it could force the local agent to stop monitoring, leaving you without failover protection. | +| No standbys available for promotion in cluster *cluster_name* | The current number of standby nodes in the cluster has dropped to the minimum number: number. There cannot be a failover unless another standby node(s) is added or made promotable. | +| No promotable standby for cluster *cluster_name* | The current failover priority list in the cluster is empty. You have removed the only promotable standby for the cluster *cluster_name*. There cannot be a failover unless another promotable standby node(s) is added or made promotable by adding to failover priority list. | +| Synchronous replication has been reconfigured for cluster *cluster_name* | The number of synchronous standby nodes in the cluster has dropped below number. The synchronous standby names on primary has been reconfigured to: new synchronous_standby_names value. | +| Synchronous replication has been reconfigured for cluster *cluster_name* | The synchronous_standby_names on primary has been reconfigured to new_synchronous_standby_names | +| Synchronous replication has been disabled for cluster *cluster_name*. | The number of synchronous standby nodes in the cluster has dropped below count. The primary has been taken out of synchronous replication mode. | +| Could not reload database configuration. | Could not reload database configuration. Manual intervention is required. Error: error_message. | +| Custom monitor timeout for cluster *cluster_name* | The following custom monitoring script has timed out: script_name | +| Custom monitor 'safe mode' failure for cluster *cluster_name* | The following custom monitor script has failed, but is being run in "safe mode": script_name. Output: script_results | +| primary.shutdown.as.failure set to true for primary node | The primary.shutdown.as.failure property has been set to true for this cluster. Stopping the primary agent without stopping the entire cluster will be treated by the rest of the cluster as an immediate primary agent failure. If maintenance is required on the primary database, shut down the primary agent and wait for a notification from the remaining nodes that failover will not happen. | +| Primary_or_Standby cannot ping local database for cluster *cluster_name* | The Primary_or_Standby agent can no longer reach the local database running at *node_address*. Other nodes are able to access the database remotely, so the agent will become IDLE and attempt to resume monitoring the database. | +| Standby cannot resume monitoring local database for cluster *cluster_name* | The standby agent can no longer reach the local database running at *node_address*. Other nodes are able to access the database remotely. The standby agent will remain IDLE until the resume command is run to resume monitoring the database. | +| Primary agent left the cluster and node detached from load balancer | The standby agent can no longer reach the local database running at *node_address*. Other nodes are able to access the database remotely. The standby agent will remain IDLE until the resume command is run to resume monitoring the database. | +| Standby database in cluster *cluster_name* not stopped before primary is promoted | The standby.restart.delay property is set for this agent, so it will not be reconfigured to follow the new primary until num_seconds seconds after promotion has completed. In some cases it may not be able to follow the new primary without manual intervention. | + + + + +The conditions listed in the table below will trigger a *SEVERE* notification: + +| Subject | Description | +| ------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Standby database restarted but EFM cannot connect | The start or restart command for the database ran successfully but the database is not accepting connections. EFM will keep trying to connect for up to restart.connection.timeout seconds. | +| Unable to connect to DB on *node_address* | The maximum connections limit has been reached. | +| Unable to connect to DB on *node_address* | Invalid password for db.user=user_name. | +| Unable to connect to DB on *node_address* | Invalid authorization specification. | +| Primary cannot resume monitoring local database for cluster *cluster_name* | The primary agent can no longer reach the local database running at *node_address*. Other nodes are able to access the database remotely, so the primary will not release the VIP and/or create a recovery.conf file. The primary agent will remain IDLE until the resume command is run to resume monitoring the database. | +| Fencing script error | Fencing script script_name failed to execute successfully. Exit Value: exit_code Results: script_results Failover has NOT occurred. | +| Post-promotion script failed | Post-promotion script script_name failed to execute successfully. Exit Value: exit_code Results: script_results | +| Remote post-promotion script failed | Remote post-promotion script script_name failed to execute successfully Exit Value: exit_code Results: script_resultsNode: *node_address* | +| Remote pre-promotion script failed | Remote pre-promotion script script_name failed to execute successfully Exit Value: exit_code Results: script_resultsNode: *node_address* | +| Post-database failure script error | Post-database failure script script_name failed to execute successfully. Exit Value: exit_code Results: script_results | +| Agent resumed script error | Agent resumed script script_name failed to execute successfully. Results: script_results | +| Primary isolation script failed | Primary isolation script script_name failed to execute successfully. Exit Value: exit_code Results: script_results | +| Could not promote standby | The promote command failed on node. Could not promote standby. Error details: error_details | +| Error creating recovery.conf file on *node_address* for cluster *cluster_name* | There was an error creating the recovery.conf file on primary node *node_address* during promotion. Promotion has continued, but requires manual intervention to ensure that the old primary node can not be restarted. Error details: message_details | +| An unexpected error has occurred for cluster *cluster_name* | An unexpected error has occurred on this node. Please check the agent log for more information. Error: error_details | +| Primary database being fenced off for cluster *cluster_name* | The primary database has been isolated from the majority of the cluster. The cluster is telling the primary agent at ip_address to fence off the primary database to prevent two primaries when the rest of the failover manager cluster promotes a standby. | +| Isolated primary database shutdown. | The isolated primary database has been shutdown by failover manager. | +| Primary database being fenced off for cluster *cluster_name* | The primary database has been isolated from the majority of the cluster. Before the primary could finish detecting isolation, a standby was promoted and has rejoined this node in the cluster. This node is isolating itself to avoid more than one primary database. | +| Could not assign VIP to node *node_address* | Failover manager could not assign the VIP address for some reason. | +| primary_or_standby database failure for cluster *cluster_name* | The database has failed on the specified node. | +| Agent is timing out for cluster *cluster_name* | This agent has timed out trying to reach the local database. After the timeout, the agent could successfully ping the database and has resumed monitoring. However, the node should be checked to make sure it is performing normally to prevent a possible database or agent failure. | +| Resume timed out for cluster *cluster_name* | This agent could not resume monitoring after reconfiguring and restarting the local database. See agent log for details. | +| Internal state mismatch for cluster *cluster_name* | The failover manager cluster's internal state did not match the actual state of the cluster members. This is rare and can be caused by a timing issue of nodes joining the cluster and/or changing their state. The problem should be resolved, but you should check the cluster status as well to verify. Details of the mismatch can be found in the agent log file. | +| Failover has not occurred | An agent has detected that the primary database is no longer available in cluster *cluster_name*, but there are no standby nodes available for failover. | +| Failover has not occurred | An agent has detected that the primary database is no longer available in cluster *cluster_name*, but there are not enough standby nodes available for failover. | +| Database in wrong state on *node_address* | The standby agent has detected that the local database is no longer in recovery. The agent will now become IDLE. Manual intervention is required. | +| Database in wrong state on *node_address* | The primary agent has detected that the local database is in recovery. The agent will now become IDLE. Manual intervention is required. | +| Database connection failure for cluster *cluster_name* | This node is unable to connect to the database running on: *node_address*Until this is fixed, failover may not work properly because this node will not be able to check if the database is running or not. | +| Standby custom monitor failure for cluster *cluster_name* | The following custom monitor script has failed on a standby node. The agent will stop monitoring the local database. Script location: script_name Script output: script_results | +| Primary custom monitor failure for cluster *cluster_name* | The following custom monitor script has failed on a primary node. EFM will attempt to promote a standby. Script location: script_name Script output: script_results | +| Loopback address set for ping.server.ip | Loopback address is set for ping.server.ip property. This setting can interfere with the network isolation detection and hence it should be changed. | +| Load balancer attach script error | Load balancer attach script script_name failed to execute successfully. Exit Value: exit_code Results: script_results | +| Load balancer detach script error | Load balancer detach script script_name failed to execute successfully. Exit Value: exit_code Results: script_results | +| Pgpool attach node error | Failover Manager failed to attach pgpool node. Exit Value: exit_code. Results: script_results | +| Pgpool detach node error | Failover Manager failed to detach pgpool node. Exit Value: exit_code. Results: script_results | +| Not enough synchronous standbys available in cluster *cluster_name* | The number of synchronous standby nodes in the cluster has dropped to count. All write queries on the primary will be blocked until enough synchronous standby nodes are added. | diff --git a/product_docs/docs/efm/4.2/efm_user/11_supported_scenarios.mdx b/product_docs/docs/efm/4.2/efm_user/11_supported_scenarios.mdx new file mode 100644 index 00000000000..c1ba20dc241 --- /dev/null +++ b/product_docs/docs/efm/4.2/efm_user/11_supported_scenarios.mdx @@ -0,0 +1,116 @@ +--- +title: "Supported Failover and Failure Scenarios" +--- + + + +Failover Manager monitors a cluster for failures that may or may not result in failover. + +Failover Manager supports a very specific and limited set of failover scenarios. Failover can occur: + +- if the Primary database crashes or is shutdown. +- if the node hosting the Primary database crashes or becomes unreachable. + +Failover Manager makes every attempt to verify the accuracy of these conditions. If agents cannot confirm that the Primary database or node has failed, Failover Manager will not perform any failover actions on the cluster. + +Failover Manager also supports a *no* *auto*-*failover* mode for situations where you want Failover Manager to monitor and detect failover conditions, but not perform an automatic failover to a Standby. In this mode, a notification is sent to the administrator when failover conditions are met. To disable automatic failover, modify the cluster properties file, setting the [auto.failover](04_configuring_efm/01_cluster_properties/#auto_failover) parameter to false. + +Failover Manager will alert an administrator to situations that require administrator intervention, but that do not merit promoting a Standby database to Primary. + + + +## Primary Database is Down + +If the agent running on the Primary database node detects a failure of the Primary database, Failover Manager begins the process of confirming the failure. + +![Confirming the Failure of the Primary Database.](images/supported_scenarios_master_db_down.png) + +If the agent on the Primary node detects that the Primary database has failed, all agents attempt to connect directly to the Primary database. If an agent can connect to the database, Failover Manager sends a notification about the state of the Primary node. If no agent can connect, the Primary agent declares database failure and releases the VIP (if applicable). + +If no agent can reach the virtual IP address or the database server, Failover Manager starts the failover process. The Standby agent on the most up-to-date node runs a fencing script (if applicable), promotes the Standby database to Primary database, and assigns the virtual IP address to the Standby node. Any additional Standby nodes are configured to replicate from the new primary unless auto.reconfigure is set to false. If applicable, the agent runs a post-promotion script. + +**Returning the Node to the Cluster** + +To recover from this scenario without restarting the entire cluster, you should: + +1. Restart the database on the original Primary node as a Standby database. +2. Invoke the `efm resume` command on the original Primary node. + +**Returning the Node to the Role of Primary** + +After returning the node to the cluster as a Standby, you can easily return the node to the role of Primary: + +1. If the cluster has more than one Standby node, use the `efm set-priority` command to set the node's failover priority to 1. +2. Invoke the [efm promote -switchover](07_using_efm_utility/#efm_promote) command to promote the node to its original role of Primary node. + + + +## Standby Database is Down + +If a Standby agent detects a failure of its database, the agent notifies the other agents; the other agents confirm the state of the database. + +![Confirming the failure of a Standby Database.](images/supported_scenarios_standby_db_down.png) + +After returning the Standby database to a healthy state, invoke the `efm resume` command to return the Standby to the cluster. + + + +## Primary Agent Exits or Node Fails + +If the Failover Manager Primary agent crashes or the node fails, a Standby agent will detect the failure and (if appropriate) initiate a failover. + +![Confirming the failure of the Primary Agent.](images/supported_scenarios_master_agent_exits.png) + +If an agent detects that the Primary agent has left, all agents attempt to connect directly to the Primary database. If any agent can connect to the database, an agent sends a notification about the failure of the Primary agent. If no agent can connect, the agents attempt to ping the virtual IP address (if applicable) to determine if it has been released. + +If no agent can reach the virtual IP address or the database server, Failover Manager starts the failover process. The Standby agent on the most up-to-date node runs a fencing script (if applicable), promotes the Standby database to Primary database, and assigns the virtual IP address to the Standby node; if applicable, the agent runs a post-promotion script. Any additional Standby nodes are configured to replicate from the new primary unless auto.reconfigure is set to false. + +If this scenario has occurred because the primary has been isolated from network, the Primary agent will detect the isolation and release the virtual IP address and create the recovery.conf file. Failover Manager will perform the previously listed steps on the remaining nodes of the cluster. + +To recover from this scenario without restarting the entire cluster, you should: + +1. Restart the original Primary node. +2. Bring the original Primary database up as a Standby node. +3. Start the service on the original Primary node. + +Please note that stopping an agent does not signal the cluster that the agent has failed. + +If a primary Failover Manager process fails, there is no failover protection until the agent is restarted. To avoid such a case, you can set up the primary node through systemd to cause a failover when the primary agent exits. For more information, see the section [Configuring for Eager Failover](04_configuring_efm/06_configuring_for_eager_failover/#configuring_for_eager_failover). + + + + +## Standby Agent Exits or Node Fails + +If a Standby agent exits or a Standby node fails, the other agents will detect that it is no longer connected to the cluster. + +![Failure of Standby Agent.](images/supported_scenarios_standby_agent_exits.png) + +When the failure is detected, the agents attempt to contact the database that resides on the node; if the agents confirm that there is a problem, Failover Manager sends the appropriate notification to the administrator. + +If there is only one Primary and one Standby remaining, there is no failover protection in the case of a Primary node failure. In the case of a Primary database failure, the Primary and Standby agents can agree that the database failed and proceed with failover. + + + +## Dedicated Witness Agent Exits / Node Fails + +The following scenario details the actions taken if a dedicated Witness (a node that is not hosting a database) fails. + +![Confirming the Failure of a dedicated Witness.](images/supported_scenarios_witness_agent_exits.png) + +When an agent detects that the Witness node cannot be reached, Failover Manager notifies the administrator of the state of the Witness. + +!!! Note + If the witness fails and the cluster only has two nodes, then there is no failover protection because the standby node has no way to know if the primary failed or was disconnected. In a two node cluster, if the primary database fails but the nodes are still connected, failover will still occur since the standby can confirm the condition of the primary database. + + + +## Nodes Become Isolated from the Cluster + +The following scenario details the actions taken if one or more nodes (a minority of the cluster) become isolated from the majority of the cluster. + +![If members of the cluster become isolated.](images/supported_scenarios_node_becomes_isolated.png) + +If one or more nodes (but less than half of the cluster) become isolated from the rest of the cluster, the remaining cluster behaves as if the nodes have failed. The agents attempt to discern if the Primary node is among the isolated nodes; it is, the Primary fences itself off from the cluster, while a Standby node (from within the cluster majority) is promoted to replace it. Other Standby nodes are configured to replicate from the new primary unless `auto.reconfigure` is set to `false`. + +Failover Manager then notifies an administrator, and the isolated nodes rejoin the cluster when they are able. When the nodes rejoin the cluster, the failover priority may change. diff --git a/product_docs/docs/efm/4.2/efm_user/12_upgrading_existing_cluster.mdx b/product_docs/docs/efm/4.2/efm_user/12_upgrading_existing_cluster.mdx new file mode 100644 index 00000000000..ecf8d5502ee --- /dev/null +++ b/product_docs/docs/efm/4.2/efm_user/12_upgrading_existing_cluster.mdx @@ -0,0 +1,102 @@ +--- +title: "Upgrading an Existing Cluster" +--- + + + +Failover Manager provides a utility to assist you when upgrading a Failover Manager cluster. To upgrade an existing cluster, you must: + +1. Install Failover Manager 4.2 on each node of the cluster. For detailed information about installing Failover Manager, see [Installing Failover Manager](03_installing_efm/#installing_efm). + +2. After installing Failover Manager, invoke the `efm upgrade-conf` utility to create the `.properties` and `.nodes` files for Failover Manager 4.2. The Failover Manager installer installs the upgrade utility ([efm upgrade-conf](07_using_efm_utility/#efm_upgrade_conf)) to the `/usr/edb/efm-4.2/bin directory`. To invoke the utility, assume root privileges, and invoke the command: + +```text +efm upgrade-conf +``` + +The efm `upgrade-conf` utility locates the `.properties` and `.nodes` files of pre-existing clusters and copies the parameter values to a new configuration file for use by Failover Manager. The utility saves the updated copy of the configuration files in the `/etc/edb/efm-4.2` directory. + +3. Modify the `.properties` and `.nodes` files for EFM 4.2, specifying any new preferences. Use your choice of editor to modify any additional properties in the properties file (located in the `/etc/edb/efm-4.2` directory) before starting the service for that node. For detailed information about property settings, see [The Cluster Properties File](04_configuring_efm/01_cluster_properties/#cluster_properties). + +!!! Note + `db.bin` is a required property. When modifying the properties file, ensure that the `db.bin` property specifies the location of the Postgres `bin` directory. + +4. If you are using Eager Failover, you must disable it before stopping the EFM cluster. For more information, see [Disabling Eager Failover](06_configuring_for_eager_failover/disabling_the_eager_failover). + +5. Use a version-specific command to stop the old Failover Manager cluster; for example, you can use the following command to stop a version 4.1 cluster: + +```text +/usr/efm-4.1/bin/efm stop-cluster efm +``` + +1. Start the new [Failover manager service](08_controlling_efm_service/#controlling_efm_service) (`edb-efm-4.2`) on each node of the cluster. + +The following example demonstrates invoking the upgrade utility to create the `.properties` and `.nodes` files for a Failover Manager installation: + +```text +[root@k8s-worker ~]# /usr/edb/efm-4.2/bin/efm upgrade-conf efm +Checking directory /etc/edb/efm-4.1 +Processing efm.properties file + +The following properties were added in addition to those in previous installed version: +priority.standbys +detach.on.agent.failure + +Checking directory /etc/edb/efm-4.1 +Processing efm.nodes file + +Upgrade of files is finished. The owner and group for properties and nodes files have been set as 'efm'. +[root@k8s-worker ~]# +``` + +If you are [using a Failover Manager configuration without sudo](04_configuring_efm/04_extending_efm_permissions/#running_efm_without_sudo), include the `-source` flag and specify the name of the directory in which the configuration files reside when invoking `upgrade-conf`. If the directory is not the configuration default directory, the upgraded files will be created in the directory from which the `upgrade-conf` command was invoked. + +**Please note**: If you are using a unit file, you must manually update the file to reflect the new Failover Manager service name when you perform an upgrade. + +## Uninstalling Failover Manager + +After upgrading to Failover Manager 4.2, you can use your native package manager to remove previous installations of Failover Manager. For example, use the following command to remove Failover Manager 4.1 and any unneeded dependencies: + +- On RHEL or CentOS 7.x: + +```text +yum remove edb-efm41 +``` + +- On RHEL or CentOS 8.x: + +```text +dnf remove edb-efm41 +``` + +- On Debian or Ubuntu: + +```text +apt-get remove edb-efm41 +``` + +- On SLES: + +```text +zypper remove edb-efm41 +``` + +## Performing a Database Update (Minor Version) + +This section describes how to perform a quick minor database version upgrade. You can use the steps that follow to upgrade from one minor version to another (for example, from 10.1.5 to version 10.2.7), or to apply a patch release for a version. + +You should first update the database server on each Standby node of the Failover Manager cluster. Then, perform a switchover, promoting a Standby node to the role of Primary within the Failover Manager cluster. Then, perform a database update on the old primary node. + +On each node of the cluster you must perform the following steps to update the database server: + +1. Stop the Failover Manager agent. +2. Stop the database server. +3. Update the database server. +4. Start the database service. +5. Start the Failover Manager agent. + +For detailed information about controlling the Advanced Server service, or upgrading your version of Advanced Server, please see the EDB Postgres Advanced Server Guide, available at: + +[https://www.enterprisedb.com/docs](/epas/latest/) + +When your updates are complete, you can use the [efm set-priority](07_using_efm_utility/#efm_set_priority) command to add the old primary to the front of the standby list (if needed), and then switchover to return the cluster to its original state. diff --git a/product_docs/docs/efm/4.2/efm_user/13_troubleshooting.mdx b/product_docs/docs/efm/4.2/efm_user/13_troubleshooting.mdx new file mode 100644 index 00000000000..fbef2d1b42c --- /dev/null +++ b/product_docs/docs/efm/4.2/efm_user/13_troubleshooting.mdx @@ -0,0 +1,43 @@ +--- +title: "Troubleshooting" +--- + + + +**Authorization file not found. Is the local agent running?** + +If you invoke an EFM cluster management command and EFM is not running on the node, the `efm` command will display an error: + +```text +Authorization file not found. Is the local agent running? +``` + +**Not authorized to run this command. User '<os user>' is not a member of the \`efm\` group.** + +You must have special privileges to invoke some of the `efm` commands documented in [Using the efm Utility](07_using_efm_utility/#using_efm_utility). If these commands are invoked by a user who isn't authorized to run them, the `efm` command will display an error: + +```text +Not authorized to run this command. User '' is not a member of the `efm` group. +``` + +**Notification; Unexpected error message** + +If you receive a notification message about an unexpected error message, check the [Failover Manager log file](09_controlling_logging/#controlling_logging) for an `OutOfMemory` message. Failover Manager runs with the default memory value set by this property: + +```text +# Extra information that will be passed to the JVM when starting the agent. +jvm.options=-Xmx128m +``` + +If you are running with less than 128 megabytes allocated, you should increase the value and restart the Failover Manager agent. + +**Confirming the OpenJDK version** + +Failover Manager is tested with OpenJDK; we strongly recommend using OpenJDK. You can use the following command to check the type of your Java installation: + +```text +# java -version +openjdk version "1.8.0_191" +OpenJDK Runtime Environment (build 1.8.0_191-b12) +OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode) +``` diff --git a/product_docs/docs/efm/4.2/efm_user/14_configuring_streaming_replication.mdx b/product_docs/docs/efm/4.2/efm_user/14_configuring_streaming_replication.mdx new file mode 100644 index 00000000000..2009941dfcb --- /dev/null +++ b/product_docs/docs/efm/4.2/efm_user/14_configuring_streaming_replication.mdx @@ -0,0 +1,40 @@ +--- +title: "Configuring Streaming Replication" +--- + + + +Configuring a replication scenario can be complex; for detailed information about configuration options, please see the PostgreSQL core documentation, available at: + + + +You may want to use a `.pgpass` file to enable md5 authentication for the replication user – this may or may not be the safest authentication method for your environment. For more information about the supported authentication options, please see the PostgreSQL core documentation at: + + + +!!! Note + From Version 3.10 onwards, EFM uses `pg_ctl` utility for standby promotion. You do not need to set the `trigger_file` or `promote_trigger_file` parameter for promotion of a standby server. + +## Limited Support for Cascading Replication + +While Failover Manager does not provide full support for cascading replication, it does provide limited support for simple failover in a cascading replication scenario. Cascading replication allows a Standby node to stream to another Standby node, reducing the number of connections (and processing overhead) to the primary node. + +![Cascading replication.](images/cascading_replication.png) + +For detailed information about configuring cascading replication, please see the PostgreSQL documentation at: + + + +To use Failover Manager in a cascading replication scenario, you should modify the cluster properties file, setting the following property values on Standby Node #2: + +```text +promotable=false +auto.reconfigure=false +``` + +In the event of a Failover, Standby Node #1 will be promoted to the role of Primary node. Should failover occur, Standby Node #2 will continue to act as a read-only replica for the new Primary node until you take actions to manually reconfigure the replication scenario to contain 3 nodes. + +In the event of a failure of Standby Node #1, you will not have failover protection, but you will receive an email notifying you of the failure of the node. + +!!! Note + Performing a switchover and switch back to the original primary may not preserve the cascading replication scenario. diff --git a/product_docs/docs/efm/4.2/efm_user/15_configuring_ssl_authentication.mdx b/product_docs/docs/efm/4.2/efm_user/15_configuring_ssl_authentication.mdx new file mode 100644 index 00000000000..82d9cf612e1 --- /dev/null +++ b/product_docs/docs/efm/4.2/efm_user/15_configuring_ssl_authentication.mdx @@ -0,0 +1,65 @@ +--- +title: "Configuring SSL Authentication on a Failover Manager Cluster" +--- + + + +The following steps enable SSL authentication for Failover Manager. Note that all connecting clients will be required to use SSL authentication when connecting to any database server within the cluster; you will be required to modify the connection methods currently used by existing clients. + +To enable SSL on a Failover Manager cluster, you must: + +1. Place a `server.crt` and `server.key` file in the `data` directory (under your Advanced Server installation). You can purchase a certificate signed by an authority, or create your own self-signed certificate. For information about creating a self-signed certificate, see the PostgreSQL core documentation at: + + + +2. Modify the `postgresql.conf` file on each database within the Failover Manager cluster, enabling SSL: + + ```text + ssl=on + ``` + +> After modifying the postgresql.conf file, you must restart the server. + +1. Modify the `pg_hba.conf` file on each node of the Failover Manager cluster, adding the following line to the beginning of the file: + + ```text + hostnossl all all all reject + ``` + +> The line instructs the server to reject any connections that are not using SSL authentication; this enforces SSL authentication for any connecting clients. For information about modifying the pg_hba.conf file, see the PostgreSQL core documentation at: +> +> > + +1. After placing the server.crt and server.key file in the data directory, convert the certificate to a form that Java understands; you can use the command: + + ```text + openssl x509 -in server.crt -out server.crt.der -outform der + ``` + +> For more information, visit: +> +> > + +1. Then, add the certificate to the Java trusted certificates file: + + ```text + keytool -keystore $JAVA_HOME/lib/security/cacerts -alias -import -file server.crt.der + ``` + +> Where +> +> > `$JAVA_HOME` is the home directory of your Java installation. +> > +> > <alias_name> can be any string, but must be unique for each certificate. +> > +> > You can use the `keytool` command to review a list of the available certificates or retrieve information about a specific certificate. For more information about using the keytool command, enter: +> > +> > > ```text +> > > man keytool +> > > ``` +> +> The certificate from each database server must be imported into the trusted certificates file of each agent. Note that the location of the cacerts file may vary on each system. For more information, visit: +> +> > + +1. Modify the [efm.properties file](04_configuring_efm/01_cluster_properties/#jdbc_sslmode) on each node within the cluster, setting the `jdbc.sslmode` property. diff --git a/product_docs/docs/efm/4.2/efm_user/images/cascading_replication.png b/product_docs/docs/efm/4.2/efm_user/images/cascading_replication.png new file mode 100644 index 00000000000..41e86182b03 Binary files /dev/null and b/product_docs/docs/efm/4.2/efm_user/images/cascading_replication.png differ diff --git a/product_docs/docs/efm/4.2/efm_user/images/cascading_replication1.png b/product_docs/docs/efm/4.2/efm_user/images/cascading_replication1.png new file mode 100644 index 00000000000..f606c9ee850 Binary files /dev/null and b/product_docs/docs/efm/4.2/efm_user/images/cascading_replication1.png differ diff --git a/product_docs/docs/efm/4.2/efm_user/images/edb_logo.png b/product_docs/docs/efm/4.2/efm_user/images/edb_logo.png new file mode 100755 index 00000000000..b83a03f80c5 Binary files /dev/null and b/product_docs/docs/efm/4.2/efm_user/images/edb_logo.png differ diff --git a/product_docs/docs/efm/4.2/efm_user/images/failover_manager_overview.png b/product_docs/docs/efm/4.2/efm_user/images/failover_manager_overview.png new file mode 100644 index 00000000000..0a511e05ab0 Binary files /dev/null and b/product_docs/docs/efm/4.2/efm_user/images/failover_manager_overview.png differ diff --git a/product_docs/docs/efm/4.2/efm_user/images/placeholder.png b/product_docs/docs/efm/4.2/efm_user/images/placeholder.png new file mode 100755 index 00000000000..b83a03f80c5 Binary files /dev/null and b/product_docs/docs/efm/4.2/efm_user/images/placeholder.png differ diff --git a/product_docs/docs/efm/4.2/efm_user/images/str_replication_dashboard_master.png b/product_docs/docs/efm/4.2/efm_user/images/str_replication_dashboard_master.png new file mode 100644 index 00000000000..dc843892554 Binary files /dev/null and b/product_docs/docs/efm/4.2/efm_user/images/str_replication_dashboard_master.png differ diff --git a/product_docs/docs/efm/4.2/efm_user/images/str_replication_dashboard_standby.png b/product_docs/docs/efm/4.2/efm_user/images/str_replication_dashboard_standby.png new file mode 100644 index 00000000000..aef1e17ad33 Binary files /dev/null and b/product_docs/docs/efm/4.2/efm_user/images/str_replication_dashboard_standby.png differ diff --git a/product_docs/docs/efm/4.2/efm_user/images/supported_scenarios_master_agent_exits.png b/product_docs/docs/efm/4.2/efm_user/images/supported_scenarios_master_agent_exits.png new file mode 100644 index 00000000000..ac9726da488 Binary files /dev/null and b/product_docs/docs/efm/4.2/efm_user/images/supported_scenarios_master_agent_exits.png differ diff --git a/product_docs/docs/efm/4.2/efm_user/images/supported_scenarios_master_db_down.png b/product_docs/docs/efm/4.2/efm_user/images/supported_scenarios_master_db_down.png new file mode 100644 index 00000000000..0eac0491e89 Binary files /dev/null and b/product_docs/docs/efm/4.2/efm_user/images/supported_scenarios_master_db_down.png differ diff --git a/product_docs/docs/efm/4.2/efm_user/images/supported_scenarios_node_becomes_isolated.png b/product_docs/docs/efm/4.2/efm_user/images/supported_scenarios_node_becomes_isolated.png new file mode 100644 index 00000000000..ac591153eef Binary files /dev/null and b/product_docs/docs/efm/4.2/efm_user/images/supported_scenarios_node_becomes_isolated.png differ diff --git a/product_docs/docs/efm/4.2/efm_user/images/supported_scenarios_standby_agent_exits.png b/product_docs/docs/efm/4.2/efm_user/images/supported_scenarios_standby_agent_exits.png new file mode 100644 index 00000000000..1997c09fdf6 Binary files /dev/null and b/product_docs/docs/efm/4.2/efm_user/images/supported_scenarios_standby_agent_exits.png differ diff --git a/product_docs/docs/efm/4.2/efm_user/images/supported_scenarios_standby_db_down.png b/product_docs/docs/efm/4.2/efm_user/images/supported_scenarios_standby_db_down.png new file mode 100644 index 00000000000..dc9abefcead Binary files /dev/null and b/product_docs/docs/efm/4.2/efm_user/images/supported_scenarios_standby_db_down.png differ diff --git a/product_docs/docs/efm/4.2/efm_user/images/supported_scenarios_witness_agent_exits.png b/product_docs/docs/efm/4.2/efm_user/images/supported_scenarios_witness_agent_exits.png new file mode 100644 index 00000000000..1c02dc66805 Binary files /dev/null and b/product_docs/docs/efm/4.2/efm_user/images/supported_scenarios_witness_agent_exits.png differ diff --git a/product_docs/docs/efm/4.2/efm_user/index.mdx b/product_docs/docs/efm/4.2/efm_user/index.mdx new file mode 100644 index 00000000000..f5f038accf7 --- /dev/null +++ b/product_docs/docs/efm/4.2/efm_user/index.mdx @@ -0,0 +1,19 @@ +--- +title: "EDB Failover Manager User Guide" +--- + +**EDB Failover Manager** + +EDB Postgres Failover Manager (EFM) is a high-availability module from EnterpriseDB that enables a Postgres primary node to automatically failover to a Standby node in the event of a software or hardware failure on the primary. + +This guide provides information about installing, configuring, and using Failover Manager. For information about the platforms and versions supported by Failover Manager, visit the EnterpriseDB website at: + + + +This document uses Postgres to mean either the PostgreSQL or EDB Postgres Advanced Server database. + +
+ +whats_new failover_manager_overview installing_efm configuring_efm using_efm monitoring_efm_cluster using_efm_utility controlling_efm_service controlling_logging notifications supported_scenarios upgrading_existing_cluster troubleshooting configuring_streaming_replication configuring_ssl_authentication conclusion + +
diff --git a/product_docs/docs/efm/4.2/efm_v4.2_documentation.pdf b/product_docs/docs/efm/4.2/efm_v4.2_documentation.pdf new file mode 100644 index 00000000000..684584d1f06 Binary files /dev/null and b/product_docs/docs/efm/4.2/efm_v4.2_documentation.pdf differ diff --git a/product_docs/docs/efm/4.2/index.mdx b/product_docs/docs/efm/4.2/index.mdx new file mode 100644 index 00000000000..36e585f5680 --- /dev/null +++ b/product_docs/docs/efm/4.2/index.mdx @@ -0,0 +1,11 @@ +--- +title: "EDB Postgres Failover Manager" +directoryDefaults: + description: "EDB Postgres Failover Manager Version 4.1 Documentation and release notes. PostgreSQL replication and failover manager for achieving high availability." +navigation: + - "#Getting Started" + - efm_quick_start + - "#Guides" + - efm_pgpool_ha_guide + - efm_user +--- diff --git a/product_docs/docs/epas/10/epas_v10_documentation.pdf b/product_docs/docs/epas/10/epas_v10_documentation.pdf new file mode 100644 index 00000000000..59c7bd23e06 Binary files /dev/null and b/product_docs/docs/epas/10/epas_v10_documentation.pdf differ diff --git a/product_docs/docs/epas/10/index.mdx b/product_docs/docs/epas/10/index.mdx new file mode 100644 index 00000000000..39d256852ac --- /dev/null +++ b/product_docs/docs/epas/10/index.mdx @@ -0,0 +1,12 @@ +--- +title: EDB Postgres Advanced Server +productStub: true +directoryDefaults: + description: "EDB Postgres Advanced Server Version 10 Documentation and release notes. Oracle database compatibility with higher security and data redaction for Enterprises." + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/p/edb-postgres-advanced-server/10" +--- + + diff --git a/product_docs/docs/epas/11/epas_v11_documentation.pdf b/product_docs/docs/epas/11/epas_v11_documentation.pdf new file mode 100644 index 00000000000..90283a38d16 Binary files /dev/null and b/product_docs/docs/epas/11/epas_v11_documentation.pdf differ diff --git a/product_docs/docs/epas/11/index.mdx b/product_docs/docs/epas/11/index.mdx new file mode 100644 index 00000000000..61ea06231e9 --- /dev/null +++ b/product_docs/docs/epas/11/index.mdx @@ -0,0 +1,12 @@ +--- +title: EDB Postgres Advanced Server +productStub: true +directoryDefaults: + description: "EDB Postgres Advanced Server Version 11 Documentation and release notes. Oracle database compatibility with higher security and data redaction for Enterprises." + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/p/edb-postgres-advanced-server/11" +--- + + diff --git a/product_docs/docs/epas/12/ecpgplus_guide/02_overview.mdx b/product_docs/docs/epas/12/ecpgplus_guide/02_overview.mdx new file mode 100644 index 00000000000..14170ebcabe --- /dev/null +++ b/product_docs/docs/epas/12/ecpgplus_guide/02_overview.mdx @@ -0,0 +1,253 @@ +--- +title: "ECPGPlus - Overview" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/user-guides/ecpgplus-guide/13/overview.html" +--- + + + +EnterpriseDB has enhanced ECPG (the PostgreSQL pre-compiler) to create ECPGPlus. ECPGPlus is a Pro\*C-compatible version of the PostgreSQL C pre-compiler. ECPGPlus translates a program that combines C code and embedded SQL statements into an equivalent C program. As it performs the translation, ECPGPlus verifies that the syntax of each SQL construct is correct. + +The following diagram charts the path of a program containing embedded SQL statements as it is compiled into an executable: + +![Compilation of a program containing embedded SQL statements](images/ecpg_path.png) + +
Fig. 1: Compilation of a program containing embedded SQL statements
+ + +To produce an executable from a C program that contains embedded SQL statements, pass the program (`my_program.pgc` in the diagram above) to the ECPGPlus pre-compiler. ECPGPlus translates each SQL statement in `my_program.pgc` into C code that calls the `ecpglib` API, and produces a C program (`my_program.c`). Then, pass the C program to a C compiler; the C compiler generates an object file (`my_program.o`). Finally, pass the object file (`my_program.o`), as well as the `ecpglib` library file, and any other required libraries to the linker, which in turn produces the executable (`my_program`). + +While the ECPGPlus preprocessor validates the *syntax* of each SQL statement, it cannot validate the *semantics*. For example, the preprocessor will confirm that an `INSERT` statement is syntactically correct, but it cannot confirm that the table mentioned in the `INSERT` statement actually exists. + +**Behind the Scenes** + +A client application contains a mix of C code and SQL code comprised of the following elements: + +- C preprocessor directives +- C declarations (variables, types, functions, ...) +- C definitions (variables, types, functions, ...) +- SQL preprocessor directives +- SQL statements + +For example: + +```text +1 #include +2 EXEC SQL INCLUDE sqlca; +3 +4 extern void printInt(char *label, int val); +5 extern void printStr(char *label, char *val); +6 extern void printFloat(char *label, float val); +7 +8 void displayCustomer(int custNumber) +9 { +10 EXEC SQL BEGIN DECLARE SECTION; +11 VARCHAR custName[50]; +12 float custBalance; +13 int custID = custNumber; +14 EXEC SQL END DECLARE SECTION; +15 +16 EXEC SQL SELECT name, balance +17 INTO :custName, :custBalance +18 FROM customer +19 WHERE id = :custID; +20 +21 printInt("ID", custID); +22 printStr("Name", custName); +23 printFloat("Balance", custBalance); +24 } +``` + +In the above code fragment: + +- Line 1 specifies a directive to the C preprocessor. + + C preprocessor directives may be interpreted or ignored; the option is controlled by a command line option (`-C PROC`) entered when you invoke ECPGPlus. In either case, ECPGPlus copies each C preprocessor directive to the output file (4) without change; any C preprocessor directive found in the source file will appear in the output file. + +- Line 2 specifies a directive to the SQL preprocessor. + + SQL preprocessor directives are interpreted by the ECPGPlus preprocessor, and are not copied to the output file. + +- Lines 4 through 6 contain C declarations. + + C declarations are copied to the output file without change, except that each `VARCHAR` declaration is translated into an equivalent `struct` declaration. + +- Lines 10 through 14 contain an embedded-SQL declaration section. + + C variables that you refer to within SQL code are known as `host variables`. If you invoke the ECPGPlus preprocessor in Pro\*C mode (`-C PROC`), you may refer to *any* C variable within a SQL statement; otherwise you must declare each host variable within a `BEGIN/END DECLARATION SECTION` pair. + +- Lines 16 through 19 contain a SQL statement. + + SQL statements are translated into calls to the ECPGPlus run-time library. + +- Lines 21 through 23 contain C code. + + C code is copied to the output file without change. + +Any SQL statement must be prefixed with `EXEC SQL` and extends to the next (unquoted) semicolon. For example: + +```text +printf(“Updating employee salaries\n”); + +EXEC SQL UPDATE emp SET sal = sal * 1.25; +EXEC SQL COMMIT; + +printf(“Employee salaries updated\n”); +``` + +When the preprocessor encounters the code fragment shown above, it passes the C code (the first line and the last line) to the output file without translation and converts each `EXEC SQL` statement into a call to an `ecpglib` function. The result would appear similar to the following: + +```text +printf("Updating employee salaries\n"); + +{ + ECPGdo( __LINE__, 0, 1, NULL, 0, ECPGst_normal, + "update emp set sal = sal * 1.25", + ECPGt_EOIT, ECPGt_EORT); +} + +{ + ECPGtrans(__LINE__, NULL, "commit"); +} + +printf(“Employee salaries updated\n”); +``` + +## Installation and Configuration + +On Windows, ECPGPlus is installed by the Advanced Server installation wizard as part of the `Database Server` component. On Linux, install with the `edb-asxx-server-devel` RPM package where `xx` is the Advanced Server version number. By default, the executable is located in: + +On Windows: + +```text +C:\Program Files\edb\as12\bin +``` + +On Linux: + +```text +/usr/edb/as12/bin +``` + +When invoking the ECPGPlus compiler, the executable must be in your search path (`%PATH%` on Windows, `$PATH` on Linux). For example, the following commands set the search path to include the directory that holds the ECPGPlus executable file `ecpg`. + +On Windows: + +```text +set EDB_PATH=C:\Program Files\edb\as12\bin +set PATH=%EDB_PATH%;%PATH% +``` + +On Linux: + +```text +export EDB_PATH==/usr/edb/as12/bin +export PATH=$EDB_PATH:$PATH +``` + +## Constructing a Makefile + +A `makefile` contains a set of instructions that tell the `make` utility how to transform a program written in C (that contains embedded SQL) into a C program. To try the examples in this guide, you will need: + +- a C compiler (and linker) +- the `make` utility +- ECPGPlus preprocessor and library +- a `makefile` that contains instructions for ECPGPlus + +The following code is an example of a `makefile` for the samples included in this guide. To use the sample code, save it in a file named `makefile` in the directory that contains the source code file. + +```text +INCLUDES = -I$(shell pg_config --includedir) +LIBPATH = -L $(shell pg_config --libdir) +CFLAGS += $(INCLUDES) -g +LDFLAGS += -g +LDLIBS += $(LIBPATH) -lecpg -lpq + +.SUFFIXES: .pgc,.pc + +.pgc.c: + ecpg -c $(INCLUDES) $? + +.pc.c: + ecpg -C PROC -c $(INCLUDES) $? +``` + +The first two lines use the `pg_config` program to locate the necessary header files and library directories: + +```text +INCLUDES = -I$(shell pg_config --includedir) +LIBPATH = -L $(shell pg_config --libdir) +``` + +The `pg_config` program is shipped with Advanced Server. + +`make` knows that it should use the `CFLAGS` variable when running the C compiler and `LDFLAGS` and `LDLIBS` when invoking the linker. ECPG programs must be linked against the ECPG run-time library (`-lecpg`) and the libpq library (`-lpq`) + +```text +CFLAGS += $(INCLUDES) -g +LDFLAGS += -g +LDLIBS += $(LIBPATH) -lecpg -lpq +``` + +The sample `makefile` instructs make how to translate a `.pgc` or a `.pc` file into a C program. Two lines in the `makefile` specify the mode in which the source file will be compiled. The first compile option is: + +```text +.pgc.c: + ecpg -c $(INCLUDES) $? +``` + +The first option tells `make` how to transform a file that ends in `.pgc` (presumably, an ECPG source file) into a file that ends in `.c` (a C program), using community ECPG (without the ECPGPlus enhancements). It invokes the ECPG pre-compiler with the `-c` flag (instructing the compiler to convert SQL code into C), using the value of the `INCLUDES` variable and the name of the `.pgc` file. + +```text +.pc.c: + ecpg -C PROC -c $(INCLUDES) $? +``` + +The second option tells make how to transform a file that ends in `.pg` (an ECPG source file) into a file that ends in `.c` (a C program), using the ECPGPlus extensions. It invokes the ECPG pre-compiler with the `-c` flag (instructing the compiler to convert SQL code into C), as well as the `-C PROC` flag (instructing the compiler to use ECPGPlus in Pro\*C-compatibility mode), using the value of the `INCLUDES` variable and the name of the `.pgc` file. + +When you run `make`, pass the name of the ECPG source code file you wish to compile. For example, to compile an ECPG source code file named `customer_list.pgc`, use the command: + +```text +make customer_list +``` + +The `make` utility consults the `makefile` (located in the current directory), discovers that the `makefile` contains a rule that will compile `customer_list.pgc` into a C program (`customer_list.c`), and then uses the rules built into `make` to compile `customer_list.c` into an executable program. + +## ECPGPlus Command Line Options + +In the sample `makefile` shown above, `make` includes the `-C` option when invoking ECPGPlus to specify that ECPGPlus should be invoked in Pro\*C compatible mode. + +If you include the `-C` `PROC` keywords on the command line, in addition to the ECPG syntax, you may use Pro\*C command line syntax; for example: + +```text +$ ecpg -C PROC INCLUDE=/usr/edb/as12/include acct_update.c +``` + +To display a complete list of the other ECPGPlus options available, navigate to the ECPGPlus installation directory, and enter: + +```text +./ecpg --help +``` + +The command line options are: + +| **Option** | **Description** | +| ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| -c | Automatically generate C code from embedded SQL code. | +| -C *mode* | Use the `-C` option to specify a compatibility mode:

`INFORMIX`

`INFORMIX_SE`

`PROC` | +| -D *symbol* | Define a preprocessor *symbol*.

The *-D* keyword is not supported when compiling in *PROC mode.* Instead, use the Oracle-style *‘DEFINE=’* clause. | +| -h | Parse a header file, this option includes option `'-c'`. | +| -i | Parse system, include files as well. | +| -I directory | Search *directory* for `include` files. | +| -o *outfile* | Write the result to *outfile*. | +| -r *option* | Specify run-time behavior; *option* can be:

`no_indicator` - Do not use indicators, but instead use special values to represent NULL values.

`prepare` - Prepare all statements before using them.

`questionmarks` - Allow use of a question mark as a placeholder.

`usebulk` - Enable bulk processing for `INSERT`, `UPDATE`, and `DELETE` statements that operate on host variable arrays. | +| --regression | Run in regression testing mode. | +| -t | Turn on `autocommit` of transactions. | +| -l | Disable `#line` directives. | +| --help | Display the help options. | +| --version | Output version information. | + +!!! Note + If you do not specify an output file name when invoking ECPGPlus, the output file name is created by stripping off the `.pgc` filename extension, and appending `.c` to the file name. diff --git a/product_docs/docs/epas/12/ecpgplus_guide/03_using_embedded_sql.mdx b/product_docs/docs/epas/12/ecpgplus_guide/03_using_embedded_sql.mdx new file mode 100644 index 00000000000..e86dd36ffcf --- /dev/null +++ b/product_docs/docs/epas/12/ecpgplus_guide/03_using_embedded_sql.mdx @@ -0,0 +1,362 @@ +--- +title: "Using Embedded SQL" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/user-guides/ecpgplus-guide/13/using_embedded_sql.html" +--- + + + +Each of the following sections leads with a code sample, followed by an explanation of each section within the code sample. + +## Example - A Simple Query + +The first code sample demonstrates how to execute a `SELECT` statement (which returns a single row), storing the results in a group of host variables. After declaring host variables, it connects to the `edb` sample database using a hard-coded role name and the associated password, and queries the `emp` table. The query returns the values into the declared host variables; after checking the value of the `NULL` indicator variable, it prints a simple result set onscreen and closes the connection. + +```text +/************************************************************ + * print_emp.pgc + * + */ +#include + +int main(void) +{ + EXEC SQL BEGIN DECLARE SECTION; + int v_empno; + char v_ename[40]; + double v_sal; + double v_comm; + short v_comm_ind; + EXEC SQL END DECLARE SECTION; + + EXEC SQL WHENEVER SQLERROR sqlprint; + + EXEC SQL CONNECT TO edb + USER 'alice' IDENTIFIED BY '1safepwd'; + + EXEC SQL + SELECT + empno, ename, sal, comm + INTO + :v_empno, :v_ename, :v_sal, :v_comm INDICATOR:v_comm_ind + FROM + emp + WHERE + empno = 7369; + + if (v_comm_ind) + printf("empno(%d), ename(%s), sal(%.2f) comm(NULL)\n", + v_empno, v_ename, v_sal); + else + printf("empno(%d), ename(%s), sal(%.2f) comm(%.2f)\n", + v_empno, v_ename, v_sal, v_comm); + EXEC SQL DISCONNECT; +} +/***********************************************************\* +``` + +The code sample begins by including the prototypes and type definitions for the C `stdio` library, and then declares the `main` function: + +```text +#include + +int main(void) +{ +``` + +Next, the application declares a set of host variables used to interact with the database server: + +```text +EXEC SQL BEGIN DECLARE SECTION; + int v_empno; + char v_ename[40]; + double v_sal; + double v_comm; + short v_comm_ind; +EXEC SQL END DECLARE SECTION; +``` + +Please note that if you plan to pre-compile the code in `PROC` mode, you may omit the `BEGIN DECLARE…END DECLARE` section. For more information about declaring host variables, refer to the [Declaring Host Variables](#declaring-host-variables). + +The data type associated with each variable within the declaration section is a C data type. Data passed between the server and the client application must share a compatible data type; for more information about data types, see the [Supported C Data Types](07_reference/#supported-c-data-types). + +The next statement instructs the server how to handle an error: + +```text +EXEC SQL WHENEVER SQLERROR sqlprint; +``` + +If the client application encounters an error in the SQL code, the server will print an error message to `stderr` (standard error), using the `sqlprint()` function supplied with `ecpglib`. The next `EXEC SQL` statement establishes a connection with Advanced Server: + +```text +EXEC SQL CONNECT TO edb + USER 'alice' IDENTIFIED BY '1safepwd'; +``` + +In our example, the client application connects to the `edb` database, using a role named `alice` with a password of `1safepwd`. + +The code then performs a query against the `emp` table: + +```text +EXEC SQL + SELECT + empno, ename, sal, comm + INTO + :v_empno, :v_ename, :v_sal, :v_comm INDICATOR :v_comm_ind + FROM + emp + WHERE + empno = 7369; +``` + +The query returns information about employee number `7369`. + +The `SELECT` statement uses an `INTO` clause to assign the retrieved values (from the `empno`, `ename`, `sal` and `comm` columns) into the `:v_empno`, `:v_ename`, `:v_sal` and `:v_comm` host variables (and the `:v_comm_ind` null indicator). The first value retrieved is assigned to the first variable listed in the `INTO` clause, the second value is assigned to the second variable, and so on. + +The `comm` column contains the commission values earned by an employee, and could potentially contain a `NULL` value. The statement includes the `INDICATOR` keyword, and a host variable to hold a null indicator. + +The code checks the null indicator, and displays the appropriate on-screen results: + +```text +if (v_comm_ind) + printf("empno(%d), ename(%s), sal(%.2f) comm(NULL)\n", + v_empno, v_ename, v_sal); +else + printf("empno(%d), ename(%s), sal(%.2f) comm(%.2f)\n", + v_empno, v_ename, v_sal, v_comm); +``` + +If the null indicator is `0` (that is, `false`), the `comm` column contains a meaningful value, and the `printf` function displays the commission. If the null indicator contains a non-zero value, `comm` is `NULL`, and `printf` displays a value of `NULL`. Please note that a host variable (other than a null indicator) contains no meaningful value if you fetch a `NULL` into that host variable; you must use null indicators to identify any value which may be `NULL`. + +The final statement in the code sample closes the connection to the server: + +```text +EXEC SQL DISCONNECT; +} +``` + +### Using Indicator Variables + +The previous example included an *indicator* *variable* that identifies any row in which the value of the `comm` column (when returned by the server) was `NULL`. An indicator variable is an extra host variable that denotes if the content of the preceding variable is `NULL` or truncated. The indicator variable is populated when the contents of a row are stored. An indicator variable may contain the following values: + +| Indicator Value | Denotes | +| --------------------------------------------- | -------------------------------------------------------------------------------- | +| If an indicator variable is less than `0`. | The value returned by the server was `NULL`. | +| If an indicator variable is equal to `0`. | The value returned by the server was not `NULL`, and was not truncated. | +| If an indicator variable is greater than `0`. | The value returned by the server was truncated when stored in the host variable. | + +When including an indicator variable in an `INTO` clause, you are not required to include the optional `INDICATOR` keyword. + +You may omit an indicator variable if you are certain that a query will never return a `NULL` value into the corresponding host variable. If you omit an indicator variable and a query returns a `NULL` value, `ecpglib` will raise a run-time error. + + + +### Declaring Host Variables + +You can use a *host variable* in a SQL statement at any point that a value may appear within that statement. A host variable is a C variable that you can use to pass data values from the client application to the server, and return data from the server to the client application. A host variable can be: + +- an array +- a `typedef` +- a pointer +- a `struct` +- any scalar C data type + +The code fragments that follow demonstrate using host variables in code compiled in `PROC` mode, and in non-`PROC` mode. The SQL statement adds a row to the `dept` table, inserting the values returned by the variables `v_deptno`, `v_dname` and `v_loc` into the `deptno` column, the `dname` column and the `loc` column, respectively. + +If you are compiling in `PROC` mode, you may omit the `EXEC SQL BEGIN DECLARE SECTION` and `EXEC SQL END DECLARE SECTION` directives. `PROC` mode permits you to use C function parameters as host variables: + +```text +void addDept(int v_deptno, char v_dname, char v_loc) +{ + EXEC SQL INSERT INTO dept VALUES( :v_deptno, :v_dname, :v_loc); +} +``` + +If you are not compiling in `PROC` mode, you must wrap embedded variable declarations with the `EXEC SQL BEGIN DECLARE SECTION` and the `EXEC SQL END DECLARE SECTION` directives, as shown below: + +```text +void addDept(int v_deptno, char v_dname, char v_loc) +{ + EXEC SQL BEGIN DECLARE SECTION; + int v_deptno_copy = v_deptno; + char v_dname_copy[14+1] = v_dname; + char v_loc_copy[13+1] = v_loc; + EXEC SQL END DECLARE SECTION; + + EXEC SQL INSERT INTO dept VALUES( :v_deptno, :v_dname, :v_loc); +} +``` + +You can also include the `INTO` clause in a `SELECT` statement to use the host variables to retrieve information: + +```text +EXEC SQL SELECT deptno, dname, loc + INTO :v_deptno, :v_dname, v_loc FROM dept; +``` + +Each column returned by the `SELECT` statement must have a type-compatible target variable in the `INTO` clause. This is a simple example that retrieves a single row; to retrieve more than one row, you must define a cursor, as demonstrated in the next example. + +## Example - Using a Cursor to Process a Result Set + +The code sample that follows demonstrates using a cursor to process a result set. There are four basic steps involved in creating and using a cursor: + +1. Use the `DECLARE CURSOR` statement to define a cursor. +2. Use the `OPEN CURSOR` statement to open the cursor. +3. Use the `FETCH` statement to retrieve data from a cursor. +4. Use the `CLOSE CURSOR` statement to close the cursor. + +After declaring host variables, our example connects to the `edb` database using a user-supplied role name and password, and queries the `emp` table. The query returns the values into a cursor named `employees`. The code sample then opens the cursor, and loops through the result set a row at a time, printing the result set. When the sample detects the end of the result set, it closes the connection. + +```text +/************************************************************ + * print_emps.pgc + * + */ +#include + +int main(int argc, char *argv[]) +{ + EXEC SQL BEGIN DECLARE SECTION; + char *username = argv[1]; + char *password = argv[2]; + int v_empno; + char v_ename[40]; + double v_sal; + double v_comm; + short v_comm_ind; + EXEC SQL END DECLARE SECTION; + + EXEC SQL WHENEVER SQLERROR sqlprint; + + EXEC SQL CONNECT TO edb USER :username IDENTIFIED BY :password; + + EXEC SQL DECLARE employees CURSOR FOR + SELECT + empno, ename, sal, comm  + FROM  + emp; + + EXEC SQL OPEN employees; + + EXEC SQL WHENEVER NOT FOUND DO break; + + for (;;) + { + EXEC SQL FETCH NEXT FROM employees  + INTO + :v_empno, :v_ename, :v_sal, :v_comm INDICATOR :v_comm_ind; + + if (v_comm_ind) + printf("empno(%d), ename(%s), sal(%.2f) comm(NULL)\n", + v_empno, v_ename, v_sal); + else + printf("empno(%d), ename(%s), sal(%.2f) comm(%.2f)\n", + v_empno, v_ename, v_sal, v_comm); + } + EXEC SQL CLOSE employees; + EXEC SQL DISCONNECT; +} +/************************************************************ +``` + +The code sample begins by including the prototypes and type definitions for the C `stdio` library, and then declares the `main` function: + +```text +#include + +int main(int argc, char *argv[]) +{ +``` + +Next, the application declares a set of host variables used to interact with the database server: + +```text +EXEC SQL BEGIN DECLARE SECTION; + char *username = argv[1]; + char *password = argv[2]; + int v_empno; + char v_ename[40]; + double v_sal; + double v_comm; + short v_comm_ind; +EXEC SQL END DECLARE SECTION; +``` + +`argv[]` is an array that contains the command line arguments entered when the user runs the client application. `argv[1]` contains the first command line argument (in this case, a `username`), and `argv[2]` contains the second command line argument (a `password`); please note that we have omitted the error-checking code you would normally include a real-world application. The declaration initializes the values of `username` and `password`, setting them to the values entered when the user invoked the client application. + +You may be thinking that you could refer to `argv[1]` and `argv[2]` in a SQL statement (instead of creating a separate copy of each variable); that will not work. All host variables must be declared within a `BEGIN/END DECLARE SECTION` (unless you are compiling in `PROC` mode). Since `argv` is a function *parameter* (not an automatic variable), it cannot be declared within a `BEGIN/END DECLARE SECTION`. If you are compiling in `PROC` mode, you can refer to *any* C variable within a SQL statement. + +The next statement instructs the server to respond to an SQL error by printing the text of the error message returned by ECPGPlus or the database server: + +```text +EXEC SQL WHENEVER SQLERROR sqlprint; +``` + +Then, the client application establishes a connection with Advanced Server: + +```text +EXEC SQL CONNECT TO edb USER :username IDENTIFIED BY :password; +``` + +The `CONNECT` statement creates a connection to the `edb` database, using the values found in the `:username` and `:password` host variables to authenticate the application to the server when connecting. + +The next statement declares a cursor named `employees`: + +```text +EXEC SQL DECLARE employees CURSOR FOR + SELECT + empno, ename, sal, comm  + FROM  + emp; +``` + +`employees` will contain the result set of a `SELECT` statement on the `emp` table. The query returns employee information from the following columns: `empno`, `ename`, `sal` and `comm`. Notice that when you declare a cursor, you do not include an `INTO` clause - instead, you specify the target variables (or descriptors) when you `FETCH` from the cursor. + +Before fetching rows from the cursor, the client application must `OPEN` the cursor: + +```text +EXEC SQL OPEN employees; +``` + +In the subsequent `FETCH` section, the client application will loop through the contents of the cursor; the client application includes a `WHENEVER` statement that instructs the server to `break` (that is, terminate the loop) when it reaches the end of the cursor: + +```text +EXEC SQL WHENEVER NOT FOUND DO break; +``` + +The client application then uses a `FETCH` statement to retrieve each row from the cursor `INTO` the previously declared host variables: + +```text +for (;;) +{ + EXEC SQL FETCH NEXT FROM employees + INTO + :v_empno, :v_ename, :v_sal, :v_comm INDICATOR :v_comm_ind; +``` + +The `FETCH` statement uses an `INTO` clause to assign the retrieved values into the `:v_empno`, `:v_ename`, `:v_sal` and `:v_comm` host variables (and the `:v_comm_ind` null indicator). The first value in the cursor is assigned to the first variable listed in the `INTO` clause, the second value is assigned to the second variable, and so on. + +The `FETCH` statement also includes the `INDICATOR` keyword and a host variable to hold a null indicator. If the `comm` column for the retrieved record contains a `NULL` value, `v_comm_ind` is set to a non-zero value, indicating that the column is `NULL`. + +The code then checks the null indicator, and displays the appropriate on-screen results: + +```text +if (v_comm_ind) + printf("empno(%d), ename(%s), sal(%.2f) comm(NULL)\n", + v_empno, v_ename, v_sal); +else + printf("empno(%d), ename(%s), sal(%.2f) comm(%.2f)\n", + v_empno, v_ename, v_sal, v_comm); +} +``` + +If the null indicator is `0` (that is, `false`), `v_comm` contains a meaningful value, and the `printf` function displays the commission. If the null indicator contains a non-zero value, `comm` is `NULL`, and `printf` displays the string `'NULL'`. Please note that a host variable (other than a null indicator) contains no meaningful value if you fetch a `NULL` into that host variable; you must use null indicators for any value which may be `NULL`. + +The final statements in the code sample close the cursor `(employees)`, and the connection to the server: + +```text +EXEC SQL CLOSE employees; +EXEC SQL DISCONNECT; +``` diff --git a/product_docs/docs/epas/12/ecpgplus_guide/04_using_descriptors.mdx b/product_docs/docs/epas/12/ecpgplus_guide/04_using_descriptors.mdx new file mode 100644 index 00000000000..aface5c6517 --- /dev/null +++ b/product_docs/docs/epas/12/ecpgplus_guide/04_using_descriptors.mdx @@ -0,0 +1,556 @@ +--- +title: "Using Descriptors" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/user-guides/ecpgplus-guide/13/using_descriptors.html" +--- + + + +Dynamic SQL allows a client application to execute SQL statements that are composed at runtime. This is useful when you don't know the content or form a statement will take when you are writing a client application. ECPGPlus does *not* allow you to use a host variable in place of an identifier (such as a table name, column name or index name); instead, you should use dynamic SQL statements to build a string that includes the information, and then execute that string. The string is passed between the client and the server in the form of a *descriptor*. A descriptor is a data structure that contains both the data and the information about the shape of the data. + +A client application must use a `GET DESCRIPTOR` statement to retrieve information from a descriptor. The following steps describe the basic flow of a client application using dynamic SQL: + +1. Use an `ALLOCATE DESCRIPTOR` statement to allocate a descriptor for the result set (select list). +2. Use an `ALLOCATE DESCRIPTOR` statement to allocate a descriptor for the input parameters (bind variables). +3. Obtain, assemble or compute the text of an SQL statement. +4. Use a `PREPARE` statement to parse and syntax-check the SQL statement. +5. Use a `DESCRIBE` statement to describe the select list into the select-list descriptor. +6. Use a `DESCRIBE` statement to describe the input parameters into the bind-variables descriptor. +7. Prompt the user (if required) for a value for each input parameter. Use a `SET DESCRIPTOR` statement to assign the values into a descriptor. +8. Use a `DECLARE CURSOR` statement to define a cursor for the statement. +9. Use an `OPEN CURSOR` statement to open a cursor for the statement. +10. Use a `FETCH` statement to fetch each row from the cursor, storing each row in select-list descriptor. +11. Use a `GET DESCRIPTOR` command to interrogate the select-list descriptor to find the value of each column in the current row. +12. Use a `CLOSE CURSOR` statement to close the cursor and free any cursor resources. + +A descriptor may contain the attributes listed in the table below: + +| **Field** | **Type** | **Attribute Description** | +| ----------------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `CARDINALITY` | `integer` | The number of rows in the result set. | +| `DATA` | N/A | The data value. | +| `DATETIME_INTERVAL_CODE` | `integer` | If `TYPE` is `9`:

`1 - DATE`

`2 - TIME`

`3 - TIMESTAMP`

`4 - TIME WITH TIMEZONE`

`5 - TIMESTAMP WITH TIMEZONE` | +| `DATETIME_INTERVAL_PRECISION` | `integer` | Unused. | +| `INDICATOR` | `integer` | Indicates a `NULL` or truncated value. | +| `KEY_MEMBER` | `integer` | Unused (returns `FALSE`). | +| `LENGTH` | `integer` | The data length (as stored on server). | +| `NAME` | `string` | The name of the column in which the data resides. | +| `NULLABLE` | `integer` | Unused (returns `TRUE`). | +| `OCTET_LENGTH` | `integer` | The data length (in bytes) as stored on server. | +| `PRECISION` | `integer` | The data precision (if the data is of `numeric` type). | +| `RETURNED_LENGTH` | `integer` | Actual length of data item. | +| `RETURNED_OCTET_LENGTH` | `integer` | Actual length of data item. | +| `SCALE` | `integer` | The data scale (if the data is of `numeric` type). | +| `TYPE` | `integer` | A numeric code that represents the data type of the column:

`1 - SQL3_CHARACTER`

`2 - SQL3_NUMERIC`

`3 - SQL3_DECIMAL`

`4 - SQL3_INTEGER`

`5 - SQL3_SMALLINT`

`6 - SQL3_FLOAT`

`7 - SQL3_REAL`

`8 - SQL3_DOUBLE_PRECISION`

`9 - SQL3_DATE_TIME_TIMESTAMP`

`10 - SQL3_INTERVAL`

`12 - SQL3_CHARACTER_VARYING`

`13 - SQL3_ENUMERATED`

`14 - SQL3_BIT`

`15 - SQL3_BIT_VARYING`

`16 - SQL3_BOOLEAN` | + +## Example - Using a Descriptor to Return Data + +The following simple application executes an SQL statement entered by an end user. The code sample demonstrates: + +- how to use a SQL descriptor to execute a `SELECT` statement. +- how to find the data and metadata returned by the statement. + +The application accepts an SQL statement from an end user, tests the statement to see if it includes the `SELECT` keyword, and executes the statement. + +When invoking the application, an end user must provide the name of the database on which the SQL statement will be performed, and a string that contains the text of the query. + +For example, a user might invoke the sample with the following command: + +```text +./exec_stmt edb "SELECT * FROM emp" + + +/************************************************************ +/* exec_stmt.pgc +* +*/ + +#include +#include +#include +#include + +EXEC SQL WHENEVER SQLERROR SQLPRINT; +static void print_meta_data( char * desc_name ); + +char *md1 = "col field data ret"; +char *md2 = "num name type len"; +char *md3 = "--- -------------------- ----------------- ---"; + +int main( int argc, char *argv[] ) +{ + + EXEC SQL BEGIN DECLARE SECTION; + char *db = argv[1]; + char *stmt = argv[2]; + int col_count; + EXEC SQL END DECLARE SECTION; + + EXEC SQL CONNECT TO :db; + + EXEC SQL ALLOCATE DESCRIPTOR parse_desc; + EXEC SQL PREPARE query FROM :stmt; + EXEC SQL DESCRIBE query INTO SQL DESCRIPTOR parse_desc; + EXEC SQL GET DESCRIPTOR 'parse_desc' :col_count = COUNT; + +if( col_count == 0 ) +{ + EXEC SQL EXECUTE IMMEDIATE :stmt; + + if( sqlca.sqlcode >= 0 ) + EXEC SQL COMMIT; +} +else +{ + int row; + + EXEC SQL ALLOCATE DESCRIPTOR row_desc; + EXEC SQL DECLARE my_cursor CURSOR FOR query; + EXEC SQL OPEN my_cursor; + + for( row = 0; ; row++ ) + { + EXEC SQL BEGIN DECLARE SECTION; + int col; + EXEC SQL END DECLARE SECTION; + EXEC SQL FETCH IN my_cursor + INTO SQL DESCRIPTOR row_desc; + + if( sqlca.sqlcode != 0 ) + break; + + if( row == 0 ) + print_meta_data( "row_desc" ); + + printf("[RECORD %d]\n", row+1); + + for( col = 1; col <= col_count; col++ ) + { + EXEC SQL BEGIN DECLARE SECTION; + short ind; + varchar val[40+1]; + varchar name[20+1]; + EXEC SQL END DECLARE SECTION; + + EXEC SQL GET DESCRIPTOR 'row_desc' + VALUE :col + :val = DATA, :ind = INDICATOR, :name = NAME; + + if( ind == -1 ) + printf( " %-20s : \n", name.arr ); + else if( ind > 0 ) + printf( " %-20s : \n", name.arr ); + else + printf( " %-20s : %s\n", name.arr, val.arr ); + } + + printf( "\n" ); + + } + printf( "%d rows\n", row ); +} + +exit( 0 ); +} + +static void print_meta_data( char *desc_name ) +{ + EXEC SQL BEGIN DECLARE SECTION; + char *desc = desc_name; + int col_count; + int col; + EXEC SQL END DECLARE SECTION; + +static char *types[] = +{ + "unused ", + "CHARACTER ", + "NUMERIC ", + "DECIMAL ", + "INTEGER ", + "SMALLINT ", + "FLOAT ", + "REAL ", + "DOUBLE ", + "DATE_TIME ", + "INTERVAL ", + "unused ", + "CHARACTER_VARYING", + "ENUMERATED ", + "BIT ", + "BIT_VARYING ", + "BOOLEAN ", + "abstract " +}; + +EXEC SQL GET DESCRIPTOR :desc :col_count = count; + + +printf( "%s\n", md1 ); +printf( "%s\n", md2 ); +printf( "%s\n", md3 ); + +for( col = 1; col <= col_count; col++ ) +{ + + EXEC SQL BEGIN DECLARE SECTION; + int type; + int ret_len; + varchar name[21]; + EXEC SQL END DECLARE SECTION; + char *type_name; + + EXEC SQL GET DESCRIPTOR :desc + VALUE :col + :name = NAME, + :type = TYPE, + :ret_len = RETURNED_OCTET_LENGTH; + + if( type > 0 && type < SQL3_abstract ) + type_name = types[type]; + else + type_name = "unknown"; + + printf( "%02d: %-20s %-17s %04d\n", + col, name.arr, type_name, ret_len ); +} +printf( "\n" ); +} + +/************************************************************ +``` + +The code sample begins by including the prototypes and type definitions for the C `stdio` and `stdlib` libraries, SQL data type symbols, and the `SQLCA` (SQL communications area) structure: + +```text +#include +#include +#include +#include +``` + +The sample provides minimal error handling; when the application encounters an SQL error, it prints the error message to screen: + +```text +EXEC SQL WHENEVER SQLERROR SQLPRINT; +``` + +The application includes a forward-declaration for a function named `print_meta_data()` that will print the metadata found in a descriptor: + +```text +static void print_meta_data( char * desc_name ); +``` + +The following code specifies the column header information that the application will use when printing the metadata: + +```text +char *md1 = "col field data ret"; +char *md2 = "num name type len"; +char *md3 = "--- -------------------- ----------------- ---"; + +int main( int argc, char *argv[] ) +{ +``` + +The following declaration section identifies the host variables that will contain the name of the database to which the application will connect, the content of the SQL Statement, and a host variable that will hold the number of columns in the result set (if any). + +```text +EXEC SQL BEGIN DECLARE SECTION; + char *db = argv[1]; + char *stmt = argv[2]; + int col_count; +EXEC SQL END DECLARE SECTION; +``` + +The application connects to the database (using the default credentials): + +```text +EXEC SQL CONNECT TO :db; +``` + +Next, the application allocates an SQL descriptor to hold the metadata for a statement: + +```text +EXEC SQL ALLOCATE DESCRIPTOR parse_desc; +``` + +The application uses a `PREPARE` statement to syntax check the string provided by the user: + +```text +EXEC SQL PREPARE query FROM :stmt; +``` + +and a `DESCRIBE` statement to move the metadata for the query into the SQL descriptor. + +```text +EXEC SQL DESCRIBE query INTO SQL DESCRIPTOR parse_desc; +``` + +Then, the application interrogates the descriptor to discover the number of columns in the result set, and stores that in the host variable `col_count`. + +```text +EXEC SQL GET DESCRIPTOR parse_desc :col_count = COUNT; +``` + +If the column count is zero, the end user did not enter a `SELECT` statement; the application uses an `EXECUTE IMMEDIATE` statement to process the contents of the statement: + +```text +if( col_count == 0 ) +{ + EXEC SQL EXECUTE IMMEDIATE :stmt; +``` + +If the statement executes successfully, the application performs a `COMMIT`: + +```text +if( sqlca.sqlcode >= 0 ) + EXEC SQL COMMIT; +} +else +{ +``` + +If the statement entered by the user is a `SELECT` statement (which we know because the column count is non-zero), the application declares a variable named `row`. + +```text +int row; +``` + +Then, the application allocates another descriptor that holds the description and the values of a specific row in the result set: + +```text +EXEC SQL ALLOCATE DESCRIPTOR row_desc; +``` + +The application declares and opens a cursor for the prepared statement: + +```text +EXEC SQL DECLARE my_cursor CURSOR FOR query; +EXEC SQL OPEN my_cursor; +``` + +Loops through the rows in result set: + +```text +for( row = 0; ; row++ ) +{ + EXEC SQL BEGIN DECLARE SECTION; + int col; + EXEC SQL END DECLARE SECTION; +``` + +Then, uses a `FETCH` to retrieve the next row from the cursor into the descriptor: + +```text +EXEC SQL FETCH IN my_cursor INTO SQL DESCRIPTOR row_desc; +``` + +The application confirms that the `FETCH` did not fail; if the `FETCH` fails, the application has reached the end of the result set, and breaks the loop: + +```text +if( sqlca.sqlcode != 0 ) + break; +``` + +The application checks to see if this is the first row of the cursor; if it is, the application prints the metadata for the row. + +```text +if( row == 0 ) + print_meta_data( "row_desc" ); +``` + +Next, it prints a record header containing the row number: + +```text +printf("[RECORD %d]\n", row+1); +``` + +Then, it loops through each column in the row: + +```text +for( col = 1; col <= col_count; col++ ) +{ + EXEC SQL BEGIN DECLARE SECTION; + short ind; + varchar val[40+1]; + varchar name[20+1]; + EXEC SQL END DECLARE SECTION; +``` + +The application interrogates the row descriptor `(row_desc)` to copy the column value `(:val)`, null indicator `(:ind)` and column name `(:name)` into the host variables declared above. Notice that you can retrieve multiple items from a descriptor using a comma-separated list. + +```text +EXEC SQL GET DESCRIPTOR row_desc + VALUE :col + :val = DATA, :ind = INDICATOR, :name = NAME; +``` + +If the null indicator `(ind)` is negative, the column value is `NULL`; if the null indicator is greater than `0`, the column value is too long to fit into the val host variable (so we print `)`; otherwise, the null indicator is `0` (meaning `NOT NULL`) so we print the value. In each case, we prefix the value (or `` or ``) with the name of the column. + +```text +if( ind == -1 ) + printf( " %-20s : \n", name.arr ); +else if( ind > 0 ) + printf( " %-20s : \n", name.arr ); +else + printf( " %-20s : %s\n", name.arr, val.arr ); +} + +printf( "\n" ); +} +``` + +When the loop terminates, the application prints the number of rows fetched, and exits: + +```text + printf( "%d rows\n", row ); + } + +exit( 0 ); +} +``` + +The `print_meta_data()` function extracts the metadata from a descriptor and prints the name, data type, and length of each column: + +```text +static void print_meta_data( char *desc_name ) +{ +``` + +The application declares host variables: + +```text +EXEC SQL BEGIN DECLARE SECTION; + char *desc = desc_name; + int col_count; + int col; +EXEC SQL END DECLARE SECTION; +``` + +The application then defines an array of character strings that map data type values `(numeric)` into data type names. We use the numeric value found in the descriptor to index into this array. For example, if we find that a given column is of type `2`, we can find the name of that type `(NUMERIC)` by writing `types[2]`. + +```text +static char *types[] = +{ + "unused ", + "CHARACTER ", + "NUMERIC ", + "DECIMAL ", + "INTEGER ", + "SMALLINT ", + "FLOAT ", + "REAL ", + "DOUBLE ", + "DATE_TIME ", + "INTERVAL ", + "unused ", + "CHARACTER_VARYING", + "ENUMERATED ", + "BIT ", + "BIT_VARYING ", + "BOOLEAN ", + "abstract " +}; +``` + +The application retrieves the column count from the descriptor. Notice that the program refers to the descriptor using a host variable `(desc)` that contains the name of the descriptor. In most scenarios, you would use an identifier to refer to a descriptor, but in this case, the caller provided the descriptor name, so we can use a host variable to refer to the descriptor. + +```text +EXEC SQL GET DESCRIPTOR :desc :col_count = count; +``` + +The application prints the column headers (defined at the beginning of this application): + +```text +printf( "%s\n", md1 ); +printf( "%s\n", md2 ); +printf( "%s\n", md3 ); +``` + +Then, loops through each column found in the descriptor, and prints the name, type and length of each column. + +```text +for( col = 1; col <= col_count; col++ ) +{ + EXEC SQL BEGIN DECLARE SECTION; + int type; + int ret_len; + varchar name[21]; + EXEC SQL END DECLARE SECTION; + char *type_name; +``` + +It retrieves the name, type code, and length of the current column: + +```text +EXEC SQL GET DESCRIPTOR :desc + VALUE :col + :name = NAME, + :type = TYPE, + :ret_len = RETURNED_OCTET_LENGTH; +``` + +If the numeric type code matches a 'known' type code (that is, a type code found in the `types[]` array), it sets `type_name` to the name of the corresponding type; otherwise, it sets `type_name` to `"unknown"`. + +```text +if( type > 0 && type < SQL3_abstract ) + type_name = types[type]; +else + type_name = "unknown"; +``` + +and prints the column number, name, type name, and length: + +```text + printf( "%02d: %-20s %-17s %04d\n", + col, name.arr, type_name, ret_len ); + } + printf( "\n" ); +} +``` + +If you invoke the sample application with the following command: + +```text +./exec_stmt test "SELECT * FROM emp WHERE empno IN(7902, 7934)" +``` + +The application returns: + +```text +col field                data              ret +num name                 type              len +--- -------------------- ----------------- --- +01: empno                NUMERIC           0004 +02: ename                CHARACTER_VARYING 0004 +03: job                  CHARACTER_VARYING 0007 +04: mgr                  NUMERIC           0004 +05: hiredate             DATE_TIME         0018 +06: sal                  NUMERIC           0007 +07: comm                 NUMERIC           0000 +08: deptno               NUMERIC           0002 + +[RECORD 1] +  empno                : 7902 +  ename                : FORD +  job                  : ANALYST +  mgr                  : 7566 +  hiredate             : 03-DEC-81 00:00:00 +  sal                  : 3000.00 +  comm                 : +  deptno               : 20 + +[RECORD 2] +  empno                : 7934 +  ename                : MILLER +  job                  : CLERK +  mgr                  : 7782 +  hiredate             : 23-JAN-82 00:00:00 +  sal                  : 1300.00 +  comm                 : +  deptno               : 10 + +2 rows +``` diff --git a/product_docs/docs/epas/12/ecpgplus_guide/05_building_executing_dynamic_sql_statements.mdx b/product_docs/docs/epas/12/ecpgplus_guide/05_building_executing_dynamic_sql_statements.mdx new file mode 100644 index 00000000000..caf7707262c --- /dev/null +++ b/product_docs/docs/epas/12/ecpgplus_guide/05_building_executing_dynamic_sql_statements.mdx @@ -0,0 +1,793 @@ +--- +title: "Building and Executing Dynamic SQL Statements" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/user-guides/ecpgplus-guide/13/building_executing_dynamic_sql_statements.html" +--- + + + +The following examples demonstrate four techniques for building and executing dynamic SQL statements. Each example demonstrates processing a different combination of statement and input types: + +- The first example demonstrates processing and executing a SQL statement that does not contain a `SELECT` statement and does not require input variables. This example corresponds to the techniques used by Oracle Dynamic SQL Method 1. +- The second example demonstrates processing and executing a SQL statement that does not contain a `SELECT` statement, and contains a known number of input variables. This example corresponds to the techniques used by Oracle Dynamic SQL Method 2. +- The third example demonstrates processing and executing a SQL statement that may contain a `SELECT` statement, and includes a known number of input variables. This example corresponds to the techniques used by Oracle Dynamic SQL Method 3. +- The fourth example demonstrates processing and executing a SQL statement that may contain a `SELECT` statement, and includes an unknown number of input variables. This example corresponds to the techniques used by Oracle Dynamic SQL Method 4. + +## Example - Executing a Non-query Statement Without Parameters + +The following example demonstrates how to use the `EXECUTE IMMEDIATE` command to execute a SQL statement where the text of the statement is not known until you run the application. You cannot use `EXECUTE IMMEDIATE` to execute a statement that returns a result set. You cannot use `EXECUTE IMMEDIATE` to execute a statement that contains parameter placeholders. + +The `EXECUTE IMMEDIATE` statement parses and plans the SQL statement each time it executes, which can have a negative impact on the performance of your application. If you plan to execute the same statement repeatedly, consider using the `PREPARE/EXECUTE` technique described in the next example. + +```text +/***********************************************************/ +#include +#include +#include + +static void handle_error(void); + +int main(int argc, char *argv[]) +{ + char *insertStmt; + + EXEC SQL WHENEVER SQLERROR DO handle_error(); + + EXEC SQL CONNECT :argv[1]; + + insertStmt = "INSERT INTO dept VALUES(50, 'ACCTG', 'SEATTLE')"; + + EXEC SQL EXECUTE IMMEDIATE :insertStmt; + + fprintf(stderr, "ok\n"); + + EXEC SQL COMMIT RELEASE; + + exit(EXIT_SUCCESS); +} + + +static void handle_error(void) +{ + fprintf(stderr, "%s\n", sqlca.sqlerrm.sqlerrmc); + + EXEC SQL WHENEVER SQLERROR CONTINUE; + EXEC SQL ROLLBACK RELEASE; + + exit(EXIT_FAILURE); +} + +/***********************************************************/ +``` + +The code sample begins by including the prototypes and type definitions for the C `stdio, string`, and `stdlib` libraries, and providing basic infrastructure for the program: + +```text +#include +#include +#include + +static void handle_error(void); +int main(int argc, char *argv[]) +{ + char *insertStmt; +``` + +The example then sets up an error handler; ECPGPlus calls the `handle_error()` function whenever a SQL error occurs: + +```text +EXEC SQL WHENEVER SQLERROR DO handle_error(); +``` + +Then, the example connects to the database using the credentials specified on the command line: + +```text +EXEC SQL CONNECT :argv[1]; +``` + +Next, the program uses an `EXECUTE IMMEDIATE` statement to execute a SQL statement, adding a row to the `dept` table: + +```text +insertStmt = "INSERT INTO dept VALUES(50, 'ACCTG', 'SEATTLE')"; + +EXEC SQL EXECUTE IMMEDIATE :insertStmt; +``` + +If the `EXECUTE IMMEDIATE` command fails for any reason, ECPGPlus will invoke the `handle_error()` function (which terminates the application after displaying an error message to the user). If the `EXECUTE IMMEDIATE` command succeeds, the application displays a message `(ok)` to the user, commits the changes, disconnects from the server, and terminates the application. + +```text + fprintf(stderr, "ok\n"); + + EXEC SQL COMMIT RELEASE; + + exit(EXIT_SUCCESS); +} +``` + +ECPGPlus calls the `handle_error()` function whenever it encounters a SQL error. The `handle_error()` function prints the content of the error message, resets the error handler, rolls back any changes, disconnects from the database, and terminates the application. + +```text +static void handle_error(void) +{ + fprintf(stderr, "%s\n", sqlca.sqlerrm.sqlerrmc); + + EXEC SQL WHENEVER SQLERROR CONTINUE; + EXEC SQL ROLLBACK RELEASE; + + exit(EXIT_FAILURE); +} +``` + +## Example - Executing a Non-query Statement with a Specified Number of Placeholders + +To execute a non-query command that includes a known number of parameter placeholders, you must first `PREPARE` the statement (providing a *statement handle*), and then `EXECUTE` the statement using the statement handle. When the application executes the statement, it must provide a *value* for each placeholder found in the statement. + +When an application uses the `PREPARE/EXECUTE` mechanism, each SQL statement is parsed and planned once, but may execute many times (providing different *values* each time). + +ECPGPlus will convert each parameter value to the type required by the SQL statement, if possible; if not possible, ECPGPlus will report an error. + +```text +/***********************************************************/ +#include +#include +#include +#include + +static void handle_error(void); + +int main(int argc, char *argv[]) +{ + char *stmtText; + + EXEC SQL WHENEVER SQLERROR DO handle_error(); + + EXEC SQL CONNECT :argv[1]; + + stmtText = "INSERT INTO dept VALUES(?, ?, ?)"; + + EXEC SQL PREPARE stmtHandle FROM :stmtText; + + EXEC SQL EXECUTE stmtHandle USING :argv[2], :argv[3], :argv[4]; + + fprintf(stderr, "ok\n"); + + EXEC SQL COMMIT RELEASE; + + exit(EXIT_SUCCESS); +} + +static void handle_error(void) +{ + printf("%s\n", sqlca.sqlerrm.sqlerrmc); + EXEC SQL WHENEVER SQLERROR CONTINUE; + EXEC SQL ROLLBACK RELEASE; + + exit(EXIT_FAILURE); +} +/***********************************************************/ +``` + +The code sample begins by including the prototypes and type definitions for the C `stdio, string, stdlib`, and `sqlca` libraries, and providing basic infrastructure for the program: + +```text +#include +#include +#include +#include + +static void handle_error(void); + +int main(int argc, char *argv[]) +{ + char *stmtText; +``` + +The example then sets up an error handler; ECPGPlus calls the `handle_error()` function whenever a SQL error occurs: + +```text +EXEC SQL WHENEVER SQLERROR DO handle_error(); +``` + +Then, the example connects to the database using the credentials specified on the command line: + +```text +EXEC SQL CONNECT :argv[1]; +``` + +Next, the program uses a `PREPARE` statement to parse and plan a statement that includes three parameter markers - if the `PREPARE` statement succeeds, it will create a statement handle that you can use to execute the statement (in this example, the statement handle is named `stmtHandle`). You can execute a given statement multiple times using the same statement handle. + +```text +stmtText = "INSERT INTO dept VALUES(?, ?, ?)"; + +EXEC SQL PREPARE stmtHandle FROM :stmtText; +``` + +After parsing and planning the statement, the application uses the `EXECUTE` statement to execute the statement associated with the statement handle, substituting user-provided values for the parameter markers: + +```text +EXEC SQL EXECUTE stmtHandle USING :argv[2], :argv[3], :argv[4]; +``` + +If the `EXECUTE` command fails for any reason, ECPGPlus will invoke the `handle_error()` function (which terminates the application after displaying an error message to the user). If the `EXECUTE` command succeeds, the application displays a message `(ok)` to the user, commits the changes, disconnects from the server, and terminates the application. + +```text + fprintf(stderr, "ok\n"); + + EXEC SQL COMMIT RELEASE; + + exit(EXIT_SUCCESS); +} +``` + +ECPGPlus calls the `handle_error()` function whenever it encounters a SQL error. The `handle_error()` function prints the content of the error message, resets the error handler, rolls back any changes, disconnects from the database, and terminates the application. + +```text +static void handle_error(void) +{ + printf("%s\n", sqlca.sqlerrm.sqlerrmc); + + EXEC SQL WHENEVER SQLERROR CONTINUE; + EXEC SQL ROLLBACK RELEASE; + exit(EXIT_FAILURE); +} +``` + +## Example - Executing a Query With a Known Number of Placeholders + +This example demonstrates how to execute a *query* with a known number of input parameters, and with a known number of columns in the result set. This method uses the `PREPARE` statement to parse and plan a query, before opening a cursor and iterating through the result set. + +```text +/***********************************************************/ +#include +#include +#include +#include +#include + +static void handle_error(void); + +int main(int argc, char *argv[]) +{ + VARCHAR empno[10]; + VARCHAR ename[20]; + + EXEC SQL WHENEVER SQLERROR DO handle_error(); + + EXEC SQL CONNECT :argv[1]; + + EXEC SQL PREPARE queryHandle + FROM "SELECT empno, ename FROM emp WHERE deptno = ?"; + + EXEC SQL DECLARE empCursor CURSOR FOR queryHandle; + + EXEC SQL OPEN empCursor USING :argv[2]; + + EXEC SQL WHENEVER NOT FOUND DO break; + + while(true) + { + + EXEC SQL FETCH empCursor INTO :empno, :ename; + + printf("%-10s %s\n", empno.arr, ename.arr); + } + + EXEC SQL CLOSE empCursor; + + EXEC SQL COMMIT RELEASE; + + exit(EXIT_SUCCESS); +} + +static void handle_error(void) +{ + printf("%s\n", sqlca.sqlerrm.sqlerrmc); + + EXEC SQL WHENEVER SQLERROR CONTINUE; + EXEC SQL ROLLBACK RELEASE; + + exit(EXIT_FAILURE); +} + +/***********************************************************/ +``` + +The code sample begins by including the prototypes and type definitions for the C `stdio, string, stdlib, stdbool`, and `sqlca` libraries, and providing basic infrastructure for the program: + +```text +#include +#include +#include +#include +#include + +static void handle_error(void); + +int main(int argc, char *argv[]) +{ + VARCHAR empno[10]; + VARCHAR ename[20]; +``` + +The example then sets up an error handler; ECPGPlus calls the `handle_error()` function whenever a SQL error occurs: + +```text +EXEC SQL WHENEVER SQLERROR DO handle_error(); +``` + +Then, the example connects to the database using the credentials specified on the command line: + +```text +EXEC SQL CONNECT :argv[1]; +``` + +Next, the program uses a `PREPARE` statement to parse and plan a query that includes a single parameter marker - if the `PREPARE` statement succeeds, it will create a statement handle that you can use to execute the statement (in this example, the statement handle is named `stmtHandle`). You can execute a given statement multiple times using the same statement handle. + +```text +EXEC SQL PREPARE stmtHandle + FROM "SELECT empno, ename FROM emp WHERE deptno = ?"; +``` + +The program then declares and opens the cursor, `empCursor`, substituting a user-provided value for the parameter marker in the prepared `SELECT` statement. Notice that the `OPEN` statement includes a `USING` clause: the `USING` clause must provide a *value* for each placeholder found in the query: + +```text +EXEC SQL DECLARE empCursor CURSOR FOR stmtHandle; + +EXEC SQL OPEN empCursor USING :argv[2]; + +EXEC SQL WHENEVER NOT FOUND DO break; + +while(true) +{ +``` + +The program iterates through the cursor, and prints the employee number and name of each employee in the selected department: + +```text + EXEC SQL FETCH empCursor INTO :empno, :ename; + + printf("%-10s %s\n", empno.arr, ename.arr); +} +``` + +The program then closes the cursor, commits any changes, disconnects from the server, and terminates the application. + +```text + EXEC SQL CLOSE empCursor; + + EXEC SQL COMMIT RELEASE; + + exit(EXIT_SUCCESS); +} +``` + +The application calls the `handle_error()` function whenever it encounters a SQL error. The `handle_error()` function prints the content of the error message, resets the error handler, rolls back any changes, disconnects from the database, and terminates the application. + +```text +static void handle_error(void) +{ + printf("%s\n", sqlca.sqlerrm.sqlerrmc); + + EXEC SQL WHENEVER SQLERROR CONTINUE; + EXEC SQL ROLLBACK RELEASE; + + exit(EXIT_FAILURE); +} +``` + + + +## Example - Executing a Query With an Unknown Number of Variables + +The next example demonstrates executing a query with an unknown number of input parameters and/or columns in the result set. This type of query may occur when you prompt the user for the text of the query, or when a query is assembled from a form on which the user chooses from a number of conditions (i.e., a filter). + +```text +/***********************************************************/ +#include +#include +#include +#include + +SQLDA *params; +SQLDA *results; + +static void allocateDescriptors(int count, + int varNameLength, + int indNameLenth); +static void bindParams(void); +static void displayResultSet(void); + +int main(int argc, char *argv[]) +{ + EXEC SQL BEGIN DECLARE SECTION; + char *username = argv[1]; + char *password = argv[2]; + char *stmtText = argv[3]; + EXEC SQL END DECLARE SECTION; + + EXEC SQL WHENEVER SQLERROR sqlprint; + + EXEC SQL CONNECT TO test + USER :username + IDENTIFIED BY :password; + + params = sqlald(20, 64, 64); + results = sqlald(20, 64, 64); + + EXEC SQL PREPARE stmt FROM :stmtText; + + EXEC SQL DECLARE dynCursor CURSOR FOR stmt; + + bindParams(); + + EXEC SQL OPEN dynCursor USING DESCRIPTOR params; + + displayResultSet(20); +} + +static void bindParams(void) +{ + EXEC SQL DESCRIBE BIND VARIABLES FOR stmt INTO params; + + if (params->F < 0) + fprintf(stderr, "Too many parameters required\n"); + else + { + int i; + + params->N = params->F; + + for (i = 0; i < params->F; i++) + { + char *paramName = params->S[i]; + int nameLen = params->C[i]; + char paramValue[255]; + + printf("Enter value for parameter %.*s: ", + nameLen, paramName); + + fgets(paramValue, sizeof(paramValue), stdin); + + params->T[i] = 1; /* Data type = Character (1) */ + params->L[i] = strlen(paramValue) - 1; + params->V[i] = strdup(paramValue); + } + } +} + +static void displayResultSet(void) +{ + EXEC SQL DESCRIBE SELECT LIST FOR stmt INTO results; + + if (results->F < 0) + fprintf(stderr, "Too many columns returned by query\n"); + else if (results->F == 0) + return; + else + { + int col; + + results->N = results->F; + + for (col = 0; col < results->F; col++) + { + int null_permitted, length; + + sqlnul(&results->T[col], + &results->T[col], + &null_permitted); + + switch (results->T[col]) + { + case 2: /* NUMERIC */ + { + int precision, scale; + + sqlprc(&results->L[col], &precision, &scale); + + if (precision == 0) + precision = 38; + + length = precision + 3; + break; + } + + case 12: /* DATE */ + { + length = 30; + break; + } + + default: /* Others */ + { + length = results->L[col] + 1; + break; + } + } + + results->V[col] = realloc(results->V[col], length); + results->L[col] = length; + results->T[col] = 1; + } + + EXEC SQL WHENEVER NOT FOUND DO break; + + while (1) + { + const char *delimiter = ""; + + EXEC SQL FETCH dynCursor USING DESCRIPTOR results; + + for (col = 0; col < results->F; col++) + { + if (*results->I[col] == -1) + printf("%s%s", delimiter, ""); + else + printf("%s%s", delimiter, results->V[col]); + delimiter = ", "; + } + + + printf("\n"); + } + } +} +/***********************************************************/ +``` + +The code sample begins by including the prototypes and type definitions for the C `stdio` and `stdlib` libraries. In addition, the program includes the `sqlda.h` and `sqlcpr.h` header files. `sqlda.h` defines the SQLDA structure used throughout this example. `sqlcpr.h` defines a small set of functions used to interrogate the metadata found in an SQLDA structure. + +```text +#include +#include +#include +#include +``` + +Next, the program declares pointers to two SQLDA structures. The first SQLDA structure `(params)` will be used to describe the metadata for any parameter markers found in the dynamic query text. The second SQLDA structure `(results)` will contain both the metadata and the result set obtained by executing the dynamic query. + +```text +SQLDA *params; +SQLDA *results; +``` + +The program then declares two helper functions (defined near the end of the code sample): + +```text +static void bindParams(void); +static void displayResultSet(void); +``` + +Next, the program declares three host variables; the first two (`username` and `password`) are used to connect to the database server; the third host variable `(stmtTxt)` is a NULL-terminated C string containing the text of the query to execute. Notice that the values for these three host variables are derived from the command-line arguments. When the program begins execution, it sets up an error handler and then connects to the database server: + +```text +int main(int argc, char *argv[]) +{ + EXEC SQL BEGIN DECLARE SECTION; + char *username = argv[1]; + char *password = argv[2]; + char *stmtText = argv[3]; + EXEC SQL END DECLARE SECTION; + + EXEC SQL WHENEVER SQLERROR sqlprint; + EXEC SQL CONNECT TO test + USER :username + IDENTIFIED BY :password; +``` + +Next, the program calls the `sqlald()` function to allocate the memory required for each descriptor. Each descriptor contains (among other things): + +- a pointer to an array of column names +- a pointer to an array of indicator names +- a pointer to an array of data types +- a pointer to an array of lengths +- a pointer to an array of data values. + +When you allocate an `SQLDA` descriptor, you specify the maximum number of columns you expect to find in the result set (for `SELECT`-list descriptors) or the maximum number of parameters you expect to find the dynamic query text (for bind-variable descriptors) - in this case, we specify that we expect no more than 20 columns and 20 parameters. You must also specify a maximum length for each column (or parameter) name and each indicator variable name - in this case, we expect names to be no more than 64 bytes long. + +See [SQLDA Structure](07_reference/#sqlda_structure) section for a complete description of the `SQLDA` structure. + +```text +params = sqlald(20, 64, 64); +results = sqlald(20, 64, 64); +``` + +After allocating the `SELECT`-list and bind descriptors, the program prepares the dynamic statement and declares a cursor over the result set. + +```text +EXEC SQL PREPARE stmt FROM :stmtText; + +EXEC SQL DECLARE dynCursor CURSOR FOR stmt; +``` + +Next, the program calls the `bindParams()` function. The `bindParams()` function examines the bind descriptor `(params)` and prompt the user for a value to substitute in place of each parameter marker found in the dynamic query. + +```text +bindParams(); +``` + +Finally, the program opens the cursor (using the parameter values supplied by the user, if any) and calls the `displayResultSet()` function to print the result set produced by the query. + +```text + EXEC SQL OPEN dynCursor USING DESCRIPTOR params; + + displayResultSet(); +} +``` + +The `bindParams()` function determines whether the dynamic query contains any parameter markers, and, if so, prompts the user for a value for each parameter and then binds that value to the corresponding marker. The `DESCRIBE BIND VARIABLE` statement populates the `params` SQLDA structure with information describing each parameter marker. + +```text +static void bindParams(void) +{ + EXEC SQL DESCRIBE BIND VARIABLES FOR stmt INTO params; +``` + +If the statement contains no parameter markers, `params->F` will contain 0. If the statement contains more parameters than will fit into the descriptor, `params->F` will contain a negative number (in this case, the absolute value of `params->F` indicates the number of parameter markers found in the statement). If `params->F` contains a positive number, that number indicates how many parameter markers were found in the statement. + +```text +if (params->F < 0) + fprintf(stderr, "Too many parameters required\n"); +else +{ + int i; + + params->N = params->F; +``` + +Next, the program executes a loop that prompts the user for a value, iterating once for each parameter marker found in the statement. + +```text +for (i = 0; i < params->F; i++) +{ + char *paramName = params->S[i]; + int nameLen = params->C[i]; + char paramValue[255]; + + printf("Enter value for parameter %.*s: ", + nameLen, paramName); + + fgets(paramValue, sizeof(paramValue), stdin); +``` + +After prompting the user for a value for a given parameter, the program *binds* that value to the parameter by setting `params->T[i]` to indicate the data type of the value (see `Type Codes` for a list of type codes), `params->L[i]` to the length of the value (we subtract one to trim off the trailing new-line character added by `fgets()`), and `params->V[i]` to point to a copy of the NULL-terminated string provided by the user. + +```text + params->T[i] = 1; /* Data type = Character (1) */ + params->L[i] = strlen(paramValue) + 1; + params->V[i] = strdup(paramValue); + } + } +} +``` + +The `displayResultSet()` function loops through each row in the result set and prints the value found in each column. `displayResultSet()` starts by executing a `DESCRIBE SELECT LIST` statement - this statement populates an SQLDA descriptor `(results)` with a description of each column in the result set. + +```text +static void displayResultSet(void) +{ + EXEC SQL DESCRIBE SELECT LIST FOR stmt INTO results; +``` + +If the dynamic statement returns no columns (that is, the dynamic statement is not a `SELECT` statement), `results->F` will contain 0. If the statement returns more columns than will fit into the descriptor, `results->F` will contain a negative number (in this case, the absolute value of `results->F` indicates the number of columns returned by the statement). If `results->F` contains a positive number, that number indicates how many columns where returned by the query. + +```text +if (results->F < 0) + fprintf(stderr, "Too many columns returned by query\n"); +else if (results->F == 0) + return; +else +{ + int col; + + results->N = results->F; +``` + +Next, the program enters a loop, iterating once for each column in the result set: + +```text +for (col = 0; col < results->F; col++) +{ + int null_permitted, length; +``` + +To decode the type code found in `results->T`, the program invokes the `sqlnul()` function (see the description of the `T` member of the SQLDA structure in the [The SQLDA Structure](07_reference/#sqlda_structure)). This call to `sqlnul()` modifies `results->T[col]` to contain only the type code (the nullability flag is copied to `null_permitted`). This step is necessary because the `DESCRIBE SELECT LIST` statement encodes the type of each column and the nullability of each column into the `T` array. + +```text +sqlnul(&results->T[col], + &results->T[col], + &null_permitted); +``` + +After decoding the actual data type of the column, the program modifies the results descriptor to tell ECPGPlus to return each value in the form of a NULL-terminated string. Before modifying the descriptor, the program must compute the amount of space required to hold each value. To make this computation, the program examines the maximum length of each column `(results->V[col])` and the data type of each column `(results->T[col])`. + +For numeric values (where `results->T[col] = 2`), the program calls the `sqlprc()` function to extract the precision and scale from the column length. To compute the number of bytes required to hold a numeric value in string form, `displayResultSet()` starts with the precision (that is, the maximum number of digits) and adds three bytes for a sign character, a decimal point, and a NULL terminator. + +```text +switch (results->T[col]) +{ + case 2: /* NUMERIC */ + { + int precision, scale; + + sqlprc(&results->L[col], &precision, &scale); + + if (precision == 0) + precision = 38; + length = precision + 3; + break; + } +``` + +For date values, the program uses a somewhat arbitrary, hard-coded length of 30. In a real-world application, you may want to more carefully compute the amount of space required. + +```text +case 12: /* DATE */ +{ + length = 30; + break; +} +``` + +For a value of any type other than date or numeric, `displayResultSet()` starts with the maximum column width reported by `DESCRIBE SELECT LIST` and adds one extra byte for the NULL terminator. Again, in a real-world application you may want to include more careful calculations for other data types. + +```text + default: /* Others */ + { + length = results->L[col] + 1; + break; + } +} +``` + +After computing the amount of space required to hold a given column, the program allocates enough memory to hold the value, sets `results->L[col]` to indicate the number of bytes found at `results->V[col]`, and set the type code for the column `(results->T[col])` to `1` to instruct the upcoming `FETCH` statement to return the value in the form of a NULL-terminated string. + +```text + results->V[col] = malloc(length); + results->L[col] = length; + results->T[col] = 1; +} +``` + +At this point, the results descriptor is configured such that a `FETCH` statement can copy each value into an appropriately sized buffer in the form of a NULL-terminated string. + +Next, the program defines a new error handler to break out of the upcoming loop when the cursor is exhausted. + +```text +EXEC SQL WHENEVER NOT FOUND DO break; + +while (1) +{ + const char *delimiter = ""; +``` + +The program executes a `FETCH` statement to fetch the next row in the cursor into the `results` descriptor. If the `FETCH` statement fails (because the cursor is exhausted), control transfers to the end of the loop because of the `EXEC SQL WHENEVER` directive found before the top of the loop. + + `EXEC SQL FETCH dynCursor USING DESCRIPTOR results;` + +The `FETCH` statement will populate the following members of the results descriptor: + +- `*results->I[col]` will indicate whether the column contains a NULL value `(-1)` or a non-NULL value `(0)`. If the value non-NULL but too large to fit into the space provided, the value is truncated and `*results->I[col]` will contain a positive value. +- `results->V[col]` will contain the value fetched for the given column `(unless *results->I[col]` indicates that the column value is NULL). +- `results->L[col]` will contain the length of the value fetched for the given column + +Finally, `displayResultSet()` iterates through each column in the result set, examines the corresponding NULL indicator, and prints the value. The result set is not aligned - instead, each value is separated from the previous value by a comma. + +```text + for (col = 0; col < results->F; col++) + { + if (*results->I[col] == -1) + printf("%s%s", delimiter, ""); + else + printf("%s%s", delimiter, results->V[col]); + delimiter = ", "; + } + + printf("\n"); + } + } +} +/***********************************************************/ +``` diff --git a/product_docs/docs/epas/12/ecpgplus_guide/06_error_handling.mdx b/product_docs/docs/epas/12/ecpgplus_guide/06_error_handling.mdx new file mode 100644 index 00000000000..73bbb350e6a --- /dev/null +++ b/product_docs/docs/epas/12/ecpgplus_guide/06_error_handling.mdx @@ -0,0 +1,214 @@ +--- +title: "Error Handling" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/user-guides/ecpgplus-guide/13/error_handling.html" +--- + + + +ECPGPlus provides two methods to detect and handle errors in embedded SQL code: + +- A client application can examine the `sqlca` data structure for error messages, and supply customized error handling for your client application. +- A client application can include `EXEC SQL WHENEVER` directives to instruct the ECPGPlus compiler to add error-handling code. + +## Error Handling with sqlca + +`sqlca` (SQL communications area) is a global variable used by `ecpglib` to communicate information from the server to the client application. After executing a SQL statement (for example, an `INSERT` or `SELECT` statement) you can inspect the contents of `sqlca` to determine if the statement has completed successfully or if the statement has failed. + +`sqlca` has the following structure: + +```text +struct +{ + char sqlcaid[8]; + long sqlabc; + long sqlcode; + struct + { + int sqlerrml; + char sqlerrmc[SQLERRMC_LEN]; + } sqlerrm; + char sqlerrp[8]; + long sqlerrd[6]; + char sqlwarn[8]; + char sqlstate[5]; + +} sqlca; +``` + +Use the following directive to implement `sqlca` functionality: + +```text +EXEC SQL INCLUDE sqlca; +``` + +If you include the `ecpg` directive, you do not need to `#include` the `sqlca.h` file in the client application's header declaration. + +The Advanced Server `sqlca` structure contains the following members: + +`sqlcaid` + + `sqlcaid` contains the string: `"SQLCA"`. + +`sqlabc` + + `sqlabc` contains the size of the `sqlca` structure. + +`sqlcode` + + The `sqlcode` member has been deprecated with SQL 92; Advanced Server supports `sqlcode` for backward compatibility, but you should use the `sqlstate` member when writing new code. + + `sqlcode` is an integer value; a positive `sqlcode` value indicates that the client application has encountered a harmless processing condition, while a negative value indicates a warning or error. + + If a statement processes without error, `sqlcode` will contain a value of `0`. If the client application encounters an error (or warning) during a statement's execution, `sqlcode` will contain the last code returned. + + The SQL standard defines only a positive value of 100, which indicates that he most recent SQL statement processed returned/affected no rows. Since the SQL standard does not define other `sqlcode` values, please be aware that the values assigned to each condition may vary from database to database. + +`sqlerrm` is a structure embedded within `sqlca`, composed of two members: + +`sqlerrml` + + `sqlerrml` contains the length of the error message currently stored in `sqlerrmc`. + +`sqlerrmc` + + `sqlerrmc` contains the null-terminated message text associated with the code stored in `sqlstate`. If a message exceeds 149 characters in length, `ecpglib` will truncate the error message. + +`sqlerrp` + + `sqlerrp` contains the string `"NOT SET"`. + +`sqlerrd` is an array that contains six elements: + +- `sqlerrd[1]` contains the OID of the processed row (if applicable). + +- `sqlerrd[2]` contains the number of processed or returned rows. + +- `sqlerrd[0], sqlerrd[3], sqlerrd[4]` and `sqlerrd[5]` are unused. + +`sqlwarn` is an array that contains 8 characters: + +- `sqlwarn[0]` contains a value of `'W'` if any other element within `sqlwarn` is set to `'W'`. + +- `sqlwarn[1]` contains a value of `'W'` if a data value was truncated when it was stored in a host variable. + +- `sqlwarn[2]` contains a value of `'W'` if the client application encounters a non-fatal warning. + +- `sqlwarn[3], sqlwarn[4], sqlwarn[5], sqlwarn[6]`, and `sqlwarn[7]` are unused. + +`sqlstate` + + `sqlstate` is a 5 character array that contains a SQL-compliant status code after the execution of a statement from the client application. If a statement processes without error, `sqlstate` will contain a value of `00000`. Please note that `sqlstate` is *not* a null-terminated string. + + `sqlstate` codes are assigned in a hierarchical scheme: + +- The first two characters of `sqlstate` indicate the general class of the condition. +- The last three characters of `sqlstate` indicate a specific status within the class. + +If the client application encounters multiple errors (or warnings) during an SQL statement's execution `sqlstate` will contain the last code returned. + +The following table lists the `sqlstate` and `sqlcode` values, as well as the symbolic name and error description for the related condition: + +| sqlstate | sqlcode (Deprecated) | Symbolic Name | Description | +| ------------------- | -------------------- | ------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `YE001` | `-12` | `ECPG_OUT_OF_MEMORY` | Virtual memory is exhausted. | +| `YE002` | `-200` | `ECPG_UNSUPPORTED` | The preprocessor has generated an unrecognized item. Could indicate incompatibility between the preprocessor and the library. | +| `07001`, or `07002` | `-201` | `ECPG_TOO_MANY_ARGUMENTS` | The program specifies more variables than the command expects. | +| `07001`, or `07002` | `-202` | `ECPG_TOO_FEW_ARGUMENTS` | The program specified fewer variables than the command expects. | +| `21000` | `-203` | `ECPG_TOO_MANY_MATCHES` | The SQL command has returned multiple rows, but the statement was prepared to receive a single row. | +| `42804` | `-204` | `ECPG_INT_FORMAT` | The host variable (defined in the C code) is of type INT, and the selected data is of a type that cannot be converted into an INT. `ecpglib` uses the `strtol()` function to convert string values into numeric form. | +| `42804` | `-205` | `ECPG_UINT_FORMAT` | The host variable (defined in the C code) is an unsigned INT, and the selected data is of a type that cannot be converted into an unsigned INT. `ecpglib` uses the `strtoul()` function to convert string values into numeric form. | +| `42804` | `-206` | `ECPG_FLOAT_FORMAT` | The host variable (defined in the C code) is of type FLOAT, and the selected data is of a type that cannot be converted into an FLOAT. `ecpglib` uses the `strtod()` function to convert string values into numeric form. | +| `42804` | `-211` | `ECPG_CONVERT_BOOL` | The host variable (defined in the C code) is of type BOOL, and the selected data cannot be stored in a BOOL. | +| `YE002` | `-2-1` | `ECPG_EMPTY` | The statement sent to the server was empty. | +| `22002` | `-213` | `ECPG_MISSING_INDICATOR` | A NULL indicator variable has not been supplied for the NULL value returned by the server (the client application has received an unexpected NULL value). | +| `42804` | `-214` | `ECPG_NO_ARRAY` | The server has returned an array, and the corresponding host variable is not capable of storing an array. | +| `42804` | `-215` | `ECPG_DATA_NOT_ARRAY` | The server has returned a value that is not an array into a host variable that expects an array value. | +| `08003` | `-220` | `ECPG_NO_CONN` | The client application has attempted to use a non-existent connection. | +| `YE002` | `-221` | `ECPG_NOT_CONN` | The client application has attempted to use an allocated, but closed connection. | +| `26000` | `-230` | `ECPG_INVALID_STMT` | The statement has not been prepared. | +| `33000` | `-240` | `ECPG_UNKNOWN_DESCRIPTOR` | The specified descriptor is not found. | +| `07009` | `-241` | `ECPG_INVALID_DESCRIPTOR_INDEX` | The descriptor index is out-of-range. | +| `YE002` | `-242` | `ECPG_UNKNOWN_DESCRIPTOR_ITEM` | The client application has requested an invalid descriptor item (internal error). | +| `07006` | `-243` | `ECPG_VAR_NOT_NUMERIC` | A dynamic statement has returned a numeric value for a non-numeric host variable. | +| `07006` | `-244` | `ECPG_VAR_NOT_CHAR` | A dynamic SQL statement has returned a CHAR value, and the host variable is not a CHAR. | +| | `-400` | `ECPG_PGSQL` | The server has returned an error message; the resulting message contains the error text. | +| `08007` | `-401` | `ECPG_TRANS` | The server cannot start, commit or rollback the specified transaction. | +| `08001` | `-402` | `ECPG_CONNECT` | The client application's attempt to connect to the database has failed. | +| `02000` | `100` | `ECPG_NOT_FOUND` | The last command retrieved or processed no rows, or you have reached the end of a cursor. | + +## EXEC SQL WHENEVER + +Use the `EXEC SQL WHENEVER` directive to implement simple error handling for client applications compiled with ECPGPlus. The syntax of the directive is: + +```text +EXEC SQL WHENEVER ; +``` + +This directive instructs the ECPG compiler to insert error-handling code into your program. + +The code instructs the client application that it should perform a specified action if the client application detects a given condition. The *condition* may be one of the following: + +`SQLERROR` + + A `SQLERROR` condition exists when `sqlca.sqlcode` is less than zero. + +`SQLWARNING` + + A `SQLWARNING` condition exists when `sqlca.sqlwarn[0]` contains a `'W'`. + +`NOT FOUND` + + A `NOT FOUND` condition exists when `sqlca.sqlcode` is `ECPG_NOT_FOUND` (when a query returns no data). + +You can specify that the client application perform one of the following *actions* if it encounters one of the previous conditions: + +`CONTINUE` + + Specify `CONTINUE` to instruct the client application to continue processing, ignoring the current `condition`. `CONTINUE` is the default action. + +`DO CONTINUE` + + An action of `DO CONTINUE` will generate a `CONTINUE` statement in the emitted C code that if it encounters the condition, skips the rest of the code in the loop and continues with the next iteration. You can only use it within a loop. + +`GOTO label` + + or + +`GO TO label` + + Use a C `goto` statement to jump to the specified `label`. + +`SQLPRINT` + + Print an error message to `stderr` (standard error), using the `sqlprint()` function. The `sqlprint()` function prints `sql error`, followed by the contents of `sqlca.sqlerrm.sqlerrmc`. + +`STOP` + + Call `exit(1)` to signal an error, and terminate the program. + +`DO BREAK` + + Execute the C `break` statement. Use this action in loops, or `switch` statements. + +`CALL name(args)` + +or + +`DO name(args)` + + Invoke the C function specified by the name `parameter`, using the parameters specified in the `args` parameter. + +**Example:** + +The following code fragment prints a message if the client application encounters a warning, and aborts the application if it encounters an error: + +```text +EXEC SQL WHENEVER SQLWARNING SQLPRINT; +EXEC SQL WHENEVER SQLERROR STOP; +``` + +!!! Note + The ECPGPlus compiler processes your program from top to bottom, even though the client application may not *execute* from top to bottom. The compiler directive is applied to each line in order, and remains in effect until the compiler encounters another directive. If the control of the flow within your program is not top-to-bottom, you should consider adding error-handling directives to any parts of the program that may be inadvertently missed during compilation. diff --git a/product_docs/docs/epas/12/ecpgplus_guide/07_reference.mdx b/product_docs/docs/epas/12/ecpgplus_guide/07_reference.mdx new file mode 100644 index 00000000000..dcfa346f20b --- /dev/null +++ b/product_docs/docs/epas/12/ecpgplus_guide/07_reference.mdx @@ -0,0 +1,1593 @@ +--- +title: "Reference" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/user-guides/ecpgplus-guide/13/reference.html" +--- + + + +The sections that follow describe ecpgPlus language elements: + +- C-Preprocessor Directives +- Supported C Data Types +- Type Codes +- The SQLDA Structure +- ECPGPlus Statements + +## C-preprocessor Directives + +The ECPGPlus C-preprocessor enforces two behaviors that are dependent on the mode in which you invoke ECPGPlus: + +- `PROC` mode +- non-`PROC` mode + +**Compiling in PROC Mode** + +In `PROC` mode, ECPGPlus allows you to: + +- Declare host variables outside of an `EXEC SQL BEGIN/END DECLARE SECTION`. +- Use any C variable as a host variable as long as it is of a data type compatible with ECPG. + +When you invoke ECPGPlus in `PROC` mode (by including the `-C PROC` keywords), the ECPG compiler honors the following C-preprocessor directives: + +```text +#include +#if expression +#ifdef symbolName +#ifndef symbolName +#else +#elif expression +#endif +#define symbolName expansion +#define symbolName([macro arguments]) expansion +#undef symbolName +#defined(symbolName) +``` + +Pre-processor directives are used to effect or direct the code that is received by the compiler. For example, using the following code sample: + +```text +#if HAVE_LONG_LONG == 1 +#define BALANCE_TYPE long long +#else +#define BALANCE_TYPE double +#endif +... +BALANCE_TYPE customerBalance; +``` + +If you invoke ECPGPlus with the following command-line arguments: + +```text +ecpg –C PROC –DHAVE_LONG_LONG=1 +``` + +ECPGPlus will copy the entire fragment (without change) to the output file, but will only send the following tokens to the ECPG parser: + +```text +long long customerBalance; +``` + +On the other hand, if you invoke ECPGPlus with the following command-line arguments: + +```text +ecpg –C PROC –DHAVE_LONG_LONG=0 +``` + +The ECPG parser will receive the following tokens: + +```text +double customerBalance; +``` + +If your code uses preprocessor directives to filter the code that is sent to the compiler, the complete code is retained in the original code, while the ECPG parser sees only the processed token stream. + +You can also use compatible syntax when executing the following preprocessor directives with an `EXEC` directive: + +```text +EXEC ORACLE DEFINE +EXEC ORACLE UNDEF +EXEC ORACLE INCLUDE +EXEC ORACLE IFDEF +EXEC ORACLE IFNDEF +EXEC ORACLE ELIF +EXEC ORACLE ELSE +EXEC ORACLE ENDIF +EXEC ORACLE OPTION +``` + +For example, if your code includes the following: + +```text +EXEC ORACLE IFDEF HAVE_LONG_LONG; +#define BALANCE_TYPE long long +EXEC ORACLE ENDIF; +BALANCE_TYPE customerBalance; +``` + +If you invoke ECPGPlus with the following command-line arguments: + +```text +ecpg –C PROC DEFINE=HAVE_LONG_LONG=1 +``` + +ECPGPlus will send the following tokens to the output file, and the ECPG parser: + +```text +long long customerBalance; +``` + +!!! Note + The `EXEC ORACLE` pre-processor directives only work if you specify `-C PROC` on the ECPG command line. + +**Using the SELECT_ERROR Precompiler Option** + +When using ECPGPlus in compatible mode, you can use the `SELECT_ERROR` precompiler option to instruct your program how to handle result sets that contain more rows than the host variable can accommodate. The syntax is: + +```text +SELECT_ERROR={YES|NO} +``` + +The default value is `YES`; a `SELECT` statement will return an error message if the result set exceeds the capacity of the host variable. Specify `NO` to instruct the program to suppress error messages when a `SELECT` statement returns more rows than a host variable can accommodate. + +Use `SELECT_ERROR` with the `EXEC ORACLE OPTION` directive. + +**Compiling in non-PROC Mode** + +If you do not include the `-C PROC` command-line option: + +- C preprocessor directives are copied to the output file without change. +- You must declare the type and name of each C variable that you intend to use as a host variable within an `EXEC SQL BEGIN/END DECLARE` section. + +When invoked in non-`PROC` mode, ECPG implements the behavior described in the PostgreSQL Core documentation. + + + +## Supported C Data Types + +An ECPGPlus application must deal with two sets of data types: SQL data types (such as `SMALLINT`, `DOUBLE PRECISION` and `CHARACTER VARYING`) and C data types (like `short`, `double` and `varchar[n]`). When an application fetches data from the server, ECPGPlus will map each SQL data type to the type of the C variable into which the data is returned. + +In general, ECPGPlus can convert most SQL server types into similar C types, but not all combinations are valid. For example, ECPGPlus will try to convert a SQL character value into a C integer value, but the conversion may fail (at execution time) if the SQL character value contains non-numeric characters. The reverse is also true; when an application sends a value to the server, ECPGPlus will try to convert the C data type into the required SQL type. Again, the conversion may fail (at execution time) if the C value cannot be converted into the required SQL type. + +ECPGPlus can convert any SQL type into C character values `(char[n]` or `varchar[n])`. Although it is safe to convert any SQL type to/from `char[n]` or `varchar[n]`, it is often convenient to use more natural C types such as `int`, `double`, or `float`. + +The supported C data types are: + +- `short` +- `int` +- `unsigned int` +- `long long int` +- `float` +- `double` +- `char[n+1]` +- `varchar[n+1]` +- `bool` +- and any equivalent created by a `typedef` + +In addition to the numeric and character types supported by C, the `pgtypeslib` run-time library offers custom data types (and functions to operate on those types) for dealing with date/time and exact numeric values: + +- `timestamp` +- `interval` +- `date` +- `decimal` +- `numeric` + +To use a data type supplied by `pgtypeslib`, you must `#include` the proper header file. + +## Type Codes + +The following table contains the type codes for *external* data types. An external data type is used to indicate the type of a C host variable. When an application binds a value to a parameter or binds a buffer to a `SELECT`-list item, the type code in the corresponding SQLDA descriptor `(descriptor->T[column])` should be set to one of the following values: + +| **Type Code** | **Host Variable Type (C Data Type)** | +| ------------------------------------------------- | ----------------------------------------- | +| `1, 2, 8, 11, 12, 15, 23, 24, 91, 94, 95, 96, 97` | `char[]` | +| `3` | `int` | +| `4, 7, 21` | `float` | +| `5, 6` | `null-terminated string (char[length+1])` | +| `9` | `varchar` | +| `22` | `double` | +| `68` | `unsigned int` | + +The following table contains the type codes for *internal* data types. An internal type code is used to indicate the type of a value as it resides in the database. The `DESCRIBE SELECT LIST` statement populates the data type array `(descriptor->T[column])` using the following values. + +| **Internal Type Code** | **Server Type** | +| ---------------------- | ------------------------ | +| `1` | `VARCHAR2` | +| `2` | `NUMBER` | +| `8` | `LONG` | +| `11` | `ROWID` | +| `12` | `DATE` | +| `23` | `RAW` | +| `24` | `LONG RAW` | +| `96` | `CHAR` | +| `100` | `BINARY FLOAT` | +| `101` | `BINARY DOUBLE` | +| `104` | `UROWID` | +| `187` | `TIMESTAMP` | +| `188` | `TIMESTAMP W/TIMEZONE` | +| `189` | `INTERVAL YEAR TO MONTH` | +| `190` | `INTERVAL DAY TO SECOND` | +| `232` | `TIMESTAMP LOCAL_TZ` | + + + +## The SQLDA Structure + +Oracle Dynamic SQL method 4 uses the SQLDA data structure to hold the data and metadata for a dynamic SQL statement. A SQLDA structure can describe a set of input parameters corresponding to the parameter markers found in the text of a dynamic statement or the result set of a dynamic statement. The layout of the SQLDA structure is: + +```text +struct SQLDA +{ + int N; /* Number of entries */ + char **V; /* Variables */ + int *L; /* Variable lengths */ + short *T; /* Variable types */ + short **I; /* Indicators */ + int F; /* Count of variables discovered by DESCRIBE */ + char **S; /* Variable names */ + short *M; /* Variable name maximum lengths */ + short *C; /* Variable name actual lengths */ + char **X; /* Indicator names */ + short *Y; /* Indicator name maximum lengths */ + short *Z; /* Indicator name actual lengths */ +}; +``` + +**Parameters** + +`N - maximum number of entries` + + The N structure member contains the maximum number of entries that the SQLDA may describe. This member is populated by the `sqlald()` function when you allocate the SQLDA structure. Before using a descriptor in an `OPEN` or `FETCH` statement, you must set `N` to the *actual* number of values described. + +`V - data values` + + The `V` structure member is a pointer to an array of data values. + +- For a `SELECT`-list descriptor, `V` points to an array of values returned by a `FETCH` statement (each member in the array corresponds to a column in the result set). +- For a bind descriptor, `V` points to an array of parameter values (you must populate the values in this array before opening a cursor that uses the descriptor). + +Your application must allocate the space required to hold each value. Refer to [displayResultSet ()](05_building_executing_dynamic_sql_statements/#executing_query_with_unknown_number_of_variables) function for an example of how to allocate space for `SELECT`-list values. + +`L - length of each data value` + + The `L` structure member is a pointer to an array of lengths. Each member of this array must indicate the amount of memory available in the corresponding member of the `V` array. For example, if `V[5]` points to a buffer large enough to hold a 20-byte NULL-terminated string, `L[5]` should contain the value 21 (20 bytes for the characters in the string plus 1 byte for the NULL-terminator). Your application must set each member of the `L` array. + +`T - data types` + + The `T` structure member points to an array of data types, one for each column (or parameter) described by the descriptor. + +- For a bind descriptor, you must set each member of the `T` array to tell ECPGPlus the data type of each parameter. +- For a `SELECT`-list descriptor, the `DESCRIBE SELECT LIST` statement sets each member of the `T` array to reflect the type of data found in the corresponding column. + +You may change any member of the `T` array before executing a `FETCH` statement to force ECPGPlus to convert the corresponding value to a specific data type. For example, if the `DESCRIBE SELECT LIST` statement indicates that a given column is of type `DATE`, you may change the corresponding `T` member to request that the next `FETCH` statement return that value in the form of a NULL-terminated string. Each member of the `T` array is a numeric type code (see [Type Codes](#type-codes) for a list of type codes). The type codes returned by a `DESCRIBE SELECT LIST` statement differ from those expected by a `FETCH` statement. After executing a `DESCRIBE SELECT LIST` statement, each member of `T` encodes a data type *and* a flag indicating whether the corresponding column is nullable. You can use the `sqlnul()` function to extract the type code and nullable flag from a member of the T array. The signature of the `sqlnul()` function is as follows: + +``` +void sqlnul(unsigned short *valType, + unsigned short *typeCode, + int *isNull) +``` + +For example, to find the type code and nullable flag for the third column of a descriptor named results, you would invoke `sqlnul()` as follows: + +``` +sqlnul(&results->T[2], &typeCode, &isNull); +``` + +`I - indicator variables` + + The `I` structure member points to an array of indicator variables. This array is allocated for you when your application calls the `sqlald()` function to allocate the descriptor. + +- For a `SELECT`-list descriptor, each member of the `I` array indicates whether the corresponding column contains a NULL (non-zero) or non-NULL (zero) value. +- For a bind parameter, your application must set each member of the `I` array to indicate whether the corresponding parameter value is NULL. + +`F - number of entries` + + The `F` structure member indicates how many values are described by the descriptor (the `N` structure member indicates the *maximum* number of values which may be described by the descriptor; `F` indicates the actual number of values). The value of the `F` member is set by ECPGPlus when you execute a `DESCRIBE` statement. `F` may be positive, negative, or zero. + +- For a `SELECT`-list descriptor, `F` will contain a positive value if the number of columns in the result set is equal to or less than the maximum number of values permitted by the descriptor (as determined by the `N` structure member); 0 if the statement is *not* a `SELECT` statement, or a negative value if the query returns more columns than allowed by the `N` structure member. +- For a bind descriptor, `F` will contain a positive number if the number of parameters found in the statement is less than or equal to the maximum number of values permitted by the descriptor (as determined by the `N` structure member); 0 if the statement contains no parameters markers, or a negative value if the statement contains more parameter markers than allowed by the `N` structure member. + +If `F` contains a positive number (after executing a `DESCRIBE` statement), that number reflects the count of columns in the result set (for a `SELECT`-list descriptor) or the number of parameter markers found in the statement (for a bind descriptor). If `F` contains a negative value, you may compute the absolute value of `F` to discover how many values (or parameter markers) are required. For example, if `F` contains `-24` after describing a `SELECT` list, you know that the query returns 24 columns. + +`S - column/parameter names` + + The `S` structure member points to an array of NULL-terminated strings. + +- For a `SELECT`-list descriptor, the `DESCRIBE SELECT LIST` statement sets each member of this array to the name of the corresponding column in the result set. +- For a bind descriptor, the `DESCRIBE BIND VARIABLES` statement sets each member of this array to the name of the corresponding bind variable. + +In this release, the name of each bind variable is determined by the left-to-right order of the parameter marker within the query - for example, the name of the first parameter is always `?0`, the name of the second parameter is always `?1`, and so on. + +`M - maximum column/parameter name length` + + The `M` structure member points to an array of lengths. Each member in this array specifies the *maximum* length of the corresponding member of the `S` array (that is, `M[0]` specifies the maximum length of the column/parameter name found at `S[0]`). This array is populated by the `sqlald()` function. + +`C - actual column/parameter name length` + + The `C` structure member points to an array of lengths. Each member in this array specifies the *actual* length of the corresponding member of the `S` array (that is, `C[0]` specifies the actual length of the column/parameter name found at `S[0]`). + + This array is populated by the `DESCRIBE` statement. + +`X - indicator variable names` + + The `X` structure member points to an array of NULL-terminated strings -each string represents the name of a NULL indicator for the corresponding value. + + This array is not used by ECPGPlus, but is provided for compatibility with Pro\*C applications. + +`Y - maximum indicator name length` + + The `Y` structure member points to an array of lengths. Each member in this array specifies the *maximum* length of the corresponding member of the `X` array (that is, `Y[0]` specifies the maximum length of the indicator name found at `X[0]`). + + This array is not used by ECPGPlus, but is provided for compatibility with Pro\*C applications. + +`Z - actual indicator name length` + + The `Z` structure member points to an array of lengths. Each member in this array specifies the *actual* length of the corresponding member of the `X` array (that is, `Z[0]` specifies the actual length of the indicator name found at `X[0]`). + + This array is not used by ECPGPlus, but is provided for compatibility with Pro\*C applications. + +## ECPGPlus Statements + +An embedded SQL statement allows your client application to interact with the server, while an embedded directive is an instruction to the ECPGPlus compiler. + +You can embed any Advanced Server SQL statement in a C program. Each statement should begin with the keywords `EXEC SQL`, and must be terminated with a semi-colon (;). Within the C program, a SQL statement takes the form: + +```text +EXEC SQL ; +``` + +Where `sql_command_body` represents a standard SQL statement. You can use a host variable anywhere that the SQL statement expects a value expression. For more information about substituting host variables for value expressions, refer to [Declaring Host Variables](03_using_embedded_sql/#declaring-host-variables). + +ECPGPlus extends the PostgreSQL server-side syntax for some statements; for those statements, syntax differences are outlined in the following reference sections. For a complete reference to the supported syntax of other SQL commands, refer to the *PostgreSQL* *Core* *Documentation* available at: + + + +### ALLOCATE DESCRIPTOR + +Use the `ALLOCATE DESCRIPTOR` statement to allocate an SQL descriptor area: + +```text +EXEC SQL [FOR ] ALLOCATE DESCRIPTOR + [WITH MAX ]; +``` + +Where: + +`array_size` is a variable that specifies the number of array elements to allocate for the descriptor. `array_size` may be an `INTEGER` value or a host variable. + +`descriptor_name` is the host variable that contains the name of the descriptor, or the name of the descriptor. This value may take the form of an identifier, a quoted string literal, or of a host variable. + +`variable_count` specifies the maximum number of host variables in the descriptor. The default value of `variable_count` is `100`. + +The following code fragment allocates a descriptor named `emp_query` that may be processed as an array `(emp_array)`: + +```text +EXEC SQL FOR :emp_array ALLOCATE DESCRIPTOR emp_query; +``` + +### CALL + +Use the `CALL` statement to invoke a procedure or function on the server. The `CALL` statement works only on Advanced Server. The `CALL` statement comes in two forms; the first form is used to call a *function*: + +```text +EXEC SQL CALL '('[]')' + INTO [[:][: ]]; +``` + +The second form is used to call a *procedure*: + +```text +EXEC SQL CALL '('[]')'; +``` + +Where: + +`program_name` is the name of the stored procedure or function that the `CALL` statement invokes. The program name may be schema-qualified or package-qualified (or both); if you do not specify the schema or package in which the program resides, ECPGPlus will use the value of `search_path` to locate the program. + +`actual_arguments` specifies a comma-separated list of arguments required by the program. Note that each `actual_argument` corresponds to a formal argument expected by the program. Each formal argument may be an `IN` parameter, an `OUT` parameter, or an `INOUT` parameter. + +`:ret_variable` specifies a host variable that will receive the value returned if the program is a function. + +`:ret_indicator` specifies a host variable that will receive the indicator value returned, if the program is a function. + +For example, the following statement invokes the `get_job_desc` function with the value contained in the `:ename` host variable, and captures the value returned by that function in the `:job` host variable: + +```text +EXEC SQL CALL get_job_desc(:ename) + INTO :job; +``` + +### CLOSE + +Use the `CLOSE` statement to close a cursor, and free any resources scurrently in use by the cursor. A client application cannot fetch rows from a closed cursor. The syntax of the `CLOSE` statement is: + +```text +EXEC SQL CLOSE []; +``` + +Where: + +`cursor_name` is the name of the cursor closed by the statement. The cursor name may take the form of an identifier or of a host variable. + +The `OPEN` statement initializes a cursor. Once initialized, a cursor result set will remain unchanged unless the cursor is re-opened. You do not need to `CLOSE` a cursor before re-opening it. + +To manually close a cursor named `emp_cursor`, use the command: + +```text +EXEC SQL CLOSE emp_cursor; +``` + +A cursor is automatically closed when an application terminates. + +### COMMIT + +Use the `COMMIT` statement to complete the current transaction, making all changes permanent and visible to other users. The syntax is: + +```text +EXEC SQL [AT ] COMMIT [WORK] + [COMMENT <'text'>] [COMMENT <'text'> RELEASE]; +``` + +Where: + +`database_name` is the name of the database (or host variable that contains the name of the database) in which the work resides. This value may take the form of an unquoted string literal, or of a host variable. + +For compatibility, ECPGPlus accepts the `COMMENT` clause without error but does *not* store any text included with the `COMMENT` clause. + +Include the `RELEASE` clause to close the current connection after performing the commit. + +For example, the following command commits all work performed on the `dept` database and closes the current connection: + +```text +EXEC SQL AT dept COMMIT RELEASE; +``` + +By default, statements are committed only when a client application performs a `COMMIT` statement. Include the `-t` option when invoking ECPGPlus to specify that a client application should invoke `AUTOCOMMIT` functionality. You can also control `AUTOCOMMIT` functionality in a client application with the following statements: + +```text +EXEC SQL SET AUTOCOMMIT TO ON +``` + +and + +```text +EXEC SQL SET AUTOCOMMIT TO OFF +``` + +### CONNECT + +Use the `CONNECT` statement to establish a connection to a database. The `CONNECT` statement is available in two forms - one form is compatible with Oracle databases, the other is not. + +The first form is compatible with Oracle databases: + +```text +EXEC SQL CONNECT + {{: IDENTIFIED BY :} | :} + [AT ] + [USING :database_string] + [ALTER AUTHORIZATION :new_password]; +``` + +Where: + +`user_name` is a host variable that contains the role that the client application will use to connect to the server. + +`password` is a host variable that contains the password associated with that role. + +`connection_id` is a host variable that contains a slash-delimited user name and password used to connect to the database. + +Include the `AT` clause to specify the database to which the connection is established. `database_name` is the name of the database to which the client is connecting; specify the value in the form of a variable, or as a string literal. + +Include the `USING` clause to specify a host variable that contains a null-terminated string identifying the database to which the connection will be established. + +The `ALTER AUTHORIZATION` clause is supported for syntax compatibility only; ECPGPlus parses the `ALTER AUTHORIZATION` clause, and reports a warning. + +Using the first form of the `CONNECT` statement, a client application might establish a connection with a host variable named `user` that contains the identity of the connecting role, and a host variable named `password` that contains the associated password using the following command: + +```text +EXEC SQL CONNECT :user IDENTIFIED BY :password; +``` + +A client application could also use the first form of the `CONNECT` statement to establish a connection using a single host variable named `:connection_id`. In the following example, `connection_id` contains the slash-delimited role name and associated password for the user: + +```text +EXEC SQL CONNECT :connection_id; +``` + +The syntax of the second form of the `CONNECT` statement is: + +```text +EXEC SQL CONNECT TO +[AS ] []; +``` + +Where `credentials` is one of the following: + +```text +USER user_name password +USER user_name IDENTIFIED BY password +USER user_name USING password +``` + +In the second form: + +`database_name` is the name or identity of the database to which the client is connecting. Specify `database_name` as a variable, or as a string literal, in one of the following forms: + +```text +[@][:] + +tcp:postgresql://[:][/][options] + +unix:postgresql://[:][/][options] +``` + +Where: + + `hostname` is the name or IP address of the server on which the database resides. + + `port` is the port on which the server listens. + + You can also specify a value of `DEFAULT` to establish a connection with the default database, using the default role name. If you specify `DEFAULT` as the target database, do not include a `connection_name` or `credentials`. + +`connection_name` is the name of the connection to the database. `connection_name` should take the form of an identifier (that is, not a string literal or a variable). You can open multiple connections, by providing a unique `connection_name` for each connection. + + If you do not specify a name for a connection, `ecpglib` assigns a name of `DEFAULT` to the connection. You can refer to the connection by name (`DEFAULT`) in any `EXEC SQL` statement. + + `CURRENT` is the most recently opened or the connection mentioned in the most-recent `SET CONNECTION TO` statement. If you do not refer to a connection by name in an `EXEC SQL` statement, ECPG assumes the name of the connection to be `CURRENT`. + +`user_name` is the role used to establish the connection with the Advanced Server database. The privileges of the specified role will be applied to all commands performed through the connection. + +`password` is the password associated with the specified `user_name`. + +The following code fragment uses the second form of the `CONNECT` statement to establish a connection to a database named `edb`, using the role `alice` and the password associated with that role, `1safepwd`: + +```text +EXEC SQL CONNECT TO edb AS acctg_conn + USER 'alice' IDENTIFIED BY '1safepwd'; +``` + +The name of the connection is `acctg_conn`; you can use the connection name when changing the connection name using the `SET CONNECTION` statement. + +### DEALLOCATE DESCRIPTOR + +Use the `DEALLOCATE DESCRIPTOR` statement to free memory in use by an allocated descriptor. The syntax of the statement is: + +```text +EXEC SQL DEALLOCATE DESCRIPTOR +``` + +Where: + +`descriptor_name` is the name of the descriptor. This value may take the form of a quoted string literal, or of a host variable. + +The following example deallocates a descriptor named `emp_query`: + +```text +EXEC SQL DEALLOCATE DESCRIPTOR emp_query; +``` + +### DECLARE CURSOR + +Use the `DECLARE CURSOR` statement to define a cursor. The syntax of the statement is: + +```text +EXEC SQL [AT ] DECLARE CURSOR FOR +( | ); +``` + +Where: + +`database_name` is the name of the database on which the cursor operates. This value may take the form of an identifier or of a host variable. If you do not specify a database name, the default value of `database_name` is the default database. + +`cursor_name` is the name of the cursor. + +`select_statement` is the text of the `SELECT` statement that defines the cursor result set; the `SELECT` statement cannot contain an `INTO` clause. + +`statement_name` is the name of a SQL statement or block that defines the cursor result set. + +The following example declares a cursor named `employees`: + +```text +EXEC SQL DECLARE employees CURSOR FOR + SELECT + empno, ename, sal, comm + FROM + emp; +``` + +The cursor generates a result set that contains the employee number, employee name, salary and commission for each employee record that is stored in the `emp` table. + +### DECLARE DATABASE + +Use the `DECLARE DATABASE` statement to declare a database identifier for use in subsequent SQL statements (for example, in a `CONNECT` statement). The syntax is: + +```text +EXEC SQL DECLARE DATABASE; +``` + +Where: + +`database_name` specifies the name of the database. + +The following example demonstrates declaring an identifier for the `acctg` database: + +```text +EXEC SQL DECLARE acctg DATABASE; +``` + +After invoking the command declaring `acctg` as a database identifier, the `acctg` database can be referenced by name when establishing a connection or in `AT` clauses. + +This statement has no effect and is provided for Pro\*C compatibility only. + +### DECLARE STATEMENT + +Use the `DECLARE STATEMENT` directive to declare an identifier for an SQL statement. Advanced Server supports two versions of the `DECLARE STATEMENT` directive: + +```text +EXEC SQL [] DECLARE STATEMENT; +``` + +and + +```text +EXEC SQL DECLARE STATEMENT ; +``` + +Where: + +`statement_name` specifies the identifier associated with the statement. + +`database_name` specifies the name of the database. This value may take the form of an identifier or of a host variable that contains the identifier. + +A typical usage sequence that includes the `DECLARE STATEMENT` directive might be: + +```text +EXEC SQL DECLARE give_raise STATEMENT; // give_raise is now a statement +handle (not prepared) +EXEC SQL PREPARE give_raise FROM :stmtText; // give_raise is now associated +with a statement +EXEC SQL EXECUTE give_raise; +``` + +This statement has no effect and is provided for Pro\*C compatibility only. + +### DELETE + +Use the `DELETE` statement to delete one or more rows from a table. The syntax for the ECPGPlus `DELETE` statement is the same as the syntax for the SQL statement, but you can use parameter markers and host variables any place that an expression is allowed. The syntax is: + +```text +[FOR ] DELETE FROM [ONLY] [[AS] ] + [USING ] + [WHERE | WHERE CURRENT OF ] + [{RETURNING|RETURN} * | [[AS] ] +[, ...] INTO ] +``` + +Where: + +Include the `FOR exec_count` clause to specify the number of times the statement will execute; this clause is valid only if the `VALUES` clause references an array or a pointer to an array. + +`table` is the name (optionally schema-qualified) of an existing table. Include the `ONLY` clause to limit processing to the specified table; if you do not include the `ONLY` clause, any tables inheriting from the named table are also processed. + +`alias` is a substitute name for the target table. + +`using_list` is a list of table expressions, allowing columns from other tables to appear in the `WHERE` condition. + +Include the `WHERE` clause to specify which rows should be deleted. If you do not include a `WHERE` clause in the statement, `DELETE` will delete all rows from the table, leaving the table definition intact. + +`condition` is an expression, host variable or parameter marker that returns a value of type `BOOLEAN`. Those rows for which `condition` returns true will be deleted. + +`cursor_name` is the name of the cursor to use in the `WHERE CURRENT OF` clause; the row to be deleted will be the one most recently fetched from this cursor. The cursor must be a non-grouping query on the `DELETE` statements target table. You cannot specify `WHERE CURRENT OF` in a `DELETE` statement that includes a Boolean condition. + +The `RETURN/RETURNING` clause specifies an `output_expression` or `host_variable_list` that is returned by the `DELETE` command after each row is deleted: + +- `output_expression` is an expression to be computed and returned by the `DELETE` command after each row is deleted. `output_name` is the name of the returned column; include \* to return all columns. + +- `host_variable_list` is a comma-separated list of host variables and optional indicator variables. Each host variable receives a corresponding value from the `RETURNING` clause. + +For example, the following statement deletes all rows from the `emp` table where the `sal` column contains a value greater than the value specified in the host variable, `:max_sal:` + +```text +DELETE FROM emp WHERE sal > :max_sal; +``` + +For more information about using the `DELETE` statement, see the PostgreSQL Core documentation available at: + + + +### DESCRIBE + +Use the `DESCRIBE` statement to find the number of input values required by a prepared statement or the number of output values returned by a prepared statement. The `DESCRIBE` statement is used to analyze a SQL statement whose shape is unknown at the time you write your application. + +The `DESCRIBE` statement populates an `SQLDA` descriptor; to populate a SQL descriptor, use the `ALLOCATE DESCRIPTOR` and `DESCRIBE...DESCRIPTOR` statements. + +```text +EXEC SQL DESCRIBE BIND VARIABLES FOR INTO ; +``` + +or + +```text +EXEC SQL DESCRIBE SELECT LIST FOR INTO ; +``` + +Where: + +`statement_name` is the identifier associated with a prepared SQL statement or PL/SQL block. + +`descriptor` is the name of C variable of type `SQLDA*`. You must allocate the space for the descriptor by calling `sqlald()` (and initialize the descriptor) before executing the `DESCRIBE` statement. + +When you execute the first form of the `DESCRIBE` statement, ECPG populates the given descriptor with a description of each input variable *required* by the statement. For example, given two descriptors: + +```text +SQLDA *query_values_in; +SQLDA *query_values_out; +``` + +You might prepare a query that returns information from the `emp` table: + +```text +EXEC SQL PREPARE get_emp FROM + "SELECT ename, empno, sal FROM emp WHERE empno = ?"; +``` + +The command requires one input variable (for the parameter marker (?)). + +```text +EXEC SQL DESCRIBE BIND VARIABLES + FOR get_emp INTO query_values_in; +``` + +After describing the bind variables for this statement, you can examine the descriptor to find the number of variables required and the type of each variable. + +When you execute the second form, ECPG populates the given descriptor with a description of each value *returned* by the statement. For example, the following statement returns three values: + +```text +EXEC SQL DESCRIBE SELECT LIST + FOR get_emp INTO query_values_out; +``` + +After describing the select list for this statement, you can examine the descriptor to find the number of returned values and the name and type of each value. + +Before *executing* the statement, you must bind a variable for each input value and a variable for each output value. The variables that you bind for the input values specify the actual values used by the statement. The variables that you bind for the output values tell ECPGPlus where to put the values when you execute the statement. + +This is alternate Pro\*C compatible syntax for the `DESCRIBE DESCRIPTOR` statement. + +### DESCRIBE DESCRIPTOR + +Use the `DESCRIBE DESCRIPTOR` statement to retrieve information about a SQL statement, and store that information in a SQL descriptor. Before using `DESCRIBE DESCRIPTOR`, you must allocate the descriptor with the `ALLOCATE DESCRIPTOR` statement. The syntax is: + +```text +EXEC SQL DESCRIBE [INPUT | OUTPUT] + USING [SQL] DESCRIPTOR ; +``` + +Where: + +`statement_name` is the name of a prepared SQL statement. + +`descriptor_name` is the name of the descriptor. `descriptor_name` can be a quoted string value or a host variable that contains the name of the descriptor. + +If you include the `INPUT` clause, ECPGPlus populates the given descriptor with a description of each input variable *required* by the statement. + +For example, given two descriptors: + +```text +EXEC SQL ALLOCATE DESCRIPTOR query_values_in; +EXEC SQL ALLOCATE DESCRIPTOR query_values_out; +``` + +You might prepare a query that returns information from the `emp` table: + +```text +EXEC SQL PREPARE get_emp FROM + "SELECT ename, empno, sal FROM emp WHERE empno = ?"; +``` + +The command requires one input variable (for the parameter marker (?)). + +```text +EXEC SQL DESCRIBE INPUT get_emp USING 'query_values_in'; +``` + +After describing the bind variables for this statement, you can examine the descriptor to find the number of variables required and the type of each variable. + +If you do not specify the `INPUT` clause, `DESCRIBE DESCRIPTOR` populates the specified descriptor with the values returned by the statement. + +If you include the `OUTPUT` clause, ECPGPlus populates the given descriptor with a description of each value *returned* by the statement. + +For example, the following statement returns three values: + +```text +EXEC SQL DESCRIBE OUTPUT FOR get_emp USING 'query_values_out'; +``` + +After describing the select list for this statement, you can examine the descriptor to find the number of returned values and the name and type of each value. + +### DISCONNECT + +Use the `DISCONNECT` statement to close the connection to the server. The syntax is: + +```text +EXEC SQL DISCONNECT [][CURRENT][DEFAULT][ALL]; +``` + +Where: + +`connection_name` is the connection name specified in the `CONNECT` statement used to establish the connection. If you do not specify a connection name, the current connection is closed. + +Include the `CURRENT` keyword to specify that ECPGPlus should close the most-recently used connection. + +Include the `DEFAULT` keyword to specify that ECPGPlus should close the connection named `DEFAULT`. If you do not specify a name when opening a connection, ECPGPlus assigns the name, `DEFAULT`, to the connection. + +Include the `ALL` keyword to instruct ECPGPlus to close all active connections. + +The following example creates a connection (named `hr_connection`) that connects to the `hr` database, and then disconnects from the connection: + +```text +/* client.pgc*/ +int main() +{ + EXEC SQL CONNECT TO hr AS connection_name; + EXEC SQL DISCONNECT connection_name; + return(0); +} +``` + +### EXECUTE + +Use the `EXECUTE` statement to execute a statement previously prepared using an `EXEC SQL PREPARE` statement. The syntax is: + +```text +EXEC SQL [FOR ] EXECUTE + [USING {DESCRIPTOR + |: [[INDICATOR] :]}]; +``` + +Where: + +`array_size` is an integer value or a host variable that contains an integer value that specifies the number of rows to be processed. If you omit the `FOR` clause, the statement is executed once for each member of the array. + +`statement_name` specifies the name assigned to the statement when the statement was created (using the `EXEC SQL PREPARE` statement). + +Include the `USING` clause to supply values for parameters within the prepared statement: + +- Include the `DESCRIPTOR` `SQLDA_descriptor` clause to provide an SQLDA descriptor value for a parameter. + +- Use a `host_variable` (and an optional `indicator_variable`) to provide a user-specified value for a parameter. + +The following example creates a prepared statement that inserts a record into the `emp` table: + +```text +EXEC SQL PREPARE add_emp (numeric, text, text, numeric) AS + INSERT INTO emp VALUES($1, $2, $3, $4); +``` + +Each time you invoke the prepared statement, provide fresh parameter values for the statement: + +```text +EXEC SQL EXECUTE add_emp USING 8000, 'DAWSON', 'CLERK', 7788; +EXEC SQL EXECUTE add_emp USING 8001, 'EDWARDS', 'ANALYST', 7698; +``` + +### EXECUTE DESCRIPTOR + +Use the `EXECUTE` statement to execute a statement previously prepared by an `EXEC SQL PREPARE` statement, using an SQL descriptor. The syntax is: + +```text +EXEC SQL [FOR ] EXECUTE + [USING [SQL] DESCRIPTOR ] + [INTO [SQL] DESCRIPTOR ]; +``` + +Where: + +`array_size` is an integer value or a host variable that contains an integer value that specifies the number of rows to be processed. If you omit the `FOR` clause, the statement is executed once for each member of the array. + +`statement_identifier` specifies the identifier assigned to the statement with the `EXEC SQL PREPARE` statement. + +Include the `USING` clause to specify values for any input parameters required by the prepared statement. + +Include the `INTO` clause to specify a descriptor into which the `EXECUTE` statement will write the results returned by the prepared statement. + +`descriptor_name` specifies the name of a descriptor (as a single-quoted string literal), or a host variable that contains the name of a descriptor. + +The following example executes the prepared statement, `give_raise`, using the values contained in the descriptor `stmtText:` + +```text +EXEC SQL PREPARE give_raise FROM :stmtText; +EXEC SQL EXECUTE give_raise USING DESCRIPTOR :stmtText; +``` + +### EXECUTE...END EXEC + +Use the `EXECUTE…END-EXEC` statement to embed an anonymous block into a client application. The syntax is: + +```text +EXEC SQL [AT ] EXECUTE END-EXEC; +``` + +Where: + +`database_name` is the database identifier or a host variable that contains the database identifier. If you omit the `AT` clause, the statement will be executed on the current default database. + +`anonymous_block` is an inline sequence of PL/pgSQL or SPL statements and declarations. You may include host variables and optional indicator variables within the block; each such variable is treated as an `IN/OUT` value. + +The following example executes an anonymous block: + +```text +EXEC SQL EXECUTE + BEGIN + IF (current_user = :admin_user_name) THEN + DBMS_OUTPUT.PUT_LINE('You are an administrator'); + END IF; +END-EXEC; +``` + +!!! Note + The `EXECUTE…END EXEC` statement is supported only by Advanced Server. + +### EXECUTE IMMEDIATE + +Use the `EXECUTE IMMEDIATE` statement to execute a string that contains a SQL command. The syntax is: + +```text +EXEC SQL [AT ] EXECUTE IMMEDIATE ; +``` + +Where: + +`database_name` is the database identifier or a host variable that contains the database identifier. If you omit the `AT` clause, the statement will be executed on the current default database. + +`command_text` is the command executed by the `EXECUTE IMMEDIATE` statement. + +This dynamic SQL statement is useful when you don't know the text of an SQL statement (ie., when writing a client application). For example, a client application may prompt a (trusted) user for a statement to execute. After the user provides the text of the statement as a string value, the statement is then executed with an `EXECUTE IMMEDIATE` command. + +The statement text may not contain references to host variables. If the statement may contain parameter markers or returns one or more values, you must use the `PREPARE` and `DESCRIBE` statements. + +The following example executes the command contained in the `:command_text` host variable: + +```text +EXEC SQL EXECUTE IMMEDIATE :command_text; +``` + +### FETCH + +Use the `FETCH` statement to return rows from a cursor into an SQLDA descriptor or a target list of host variables. Before using a `FETCH` statement to retrieve information from a cursor, you must prepare the cursor using `DECLARE` and `OPEN` statements. The statement syntax is: + +```text +EXEC SQL [FOR ] FETCH + { USING DESCRIPTOR }|{ INTO }; +``` + +Where: + +`array_size` is an integer value or a host variable that contains an integer value specifying the number of rows to fetch. If you omit the `FOR` clause, the statement is executed once for each member of the array. + +`cursor` is the name of the cursor from which rows are being fetched, or a host variable that contains the name of the cursor. + +If you include a `USING` clause, the `FETCH` statement will populate the specified SQLDA descriptor with the values returned by the server. + +If you include an `INTO` clause, the `FETCH` statement will populate the host variables (and optional indicator variables) specified in the `target_list`. + +The following code fragment declares a cursor named `employees` that retrieves the `employee number`, `name` and `salary` from the `emp` table: + +```text +EXEC SQL DECLARE employees CURSOR + SELECT empno, ename, esal FROM emp +EXEC SQL OPEN emp_cursor +EXEC SQL FETCH emp_cursor INTO :emp_no, :emp_name, :emp_sal; +``` + +### FETCH DESCRIPTOR + +Use the `FETCH DESCRIPTOR` statement to retrieve rows from a cursor into an SQL descriptor. The syntax is: + +```text +EXEC SQL [FOR ] FETCH + INTO [SQL] DESCRIPTOR ; +``` + +Where: + +`array_size` is an integer value or a host variable that contains an integer value specifying the number of rows to fetch. If you omit the `FOR` clause, the statement is executed once for each member of the array. + +`cursor` is the name of the cursor from which rows are fetched, or a host variable that contains the name of the cursor. The client must `DECLARE` and `OPEN` the cursor before calling the `FETCH DESCRIPTOR` statement. + +Include the `INTO` clause to specify an SQL descriptor into which the `EXECUTE` statement will write the results returned by the prepared statement. `descriptor_name` specifies the name of a descriptor (as a single-quoted string literal), or a host variable that contains the name of a descriptor. Prior to use, the descriptor must be allocated using an `ALLOCATE DESCRIPTOR` statement. + +The following example allocates a descriptor named `row_desc` that will hold the description and the values of a specific row in the result set. It then declares and opens a cursor for a prepared statement (`my_cursor`), before looping through the rows in result set, using a `FETCH` to retrieve the next row from the cursor into the descriptor: + +```text +EXEC SQL ALLOCATE DESCRIPTOR 'row_desc'; +EXEC SQL DECLARE my_cursor CURSOR FOR query; +EXEC SQL OPEN my_cursor; + +for( row = 0; ; row++ ) +{ + EXEC SQL BEGIN DECLARE SECTION; + int col; + EXEC SQL END DECLARE SECTION; + EXEC SQL FETCH my_cursor INTO SQL DESCRIPTOR 'row_desc'; +``` + +### GET DESCRIPTOR + +Use the `GET DESCRIPTOR` statement to retrieve information from a descriptor. The `GET DESCRIPTOR` statement comes in two forms. The first form returns the number of values (or columns) in the descriptor. + +```text +EXEC SQL GET DESCRIPTOR + : = COUNT; +``` + +The second form returns information about a specific value (specified by the `VALUE column_number` clause). + +```text +EXEC SQL [FOR ] GET DESCRIPTOR + VALUE {: = {,…}}; +``` + +Where: + +`array_size` is an integer value or a host variable that contains an integer value that specifies the number of rows to be processed. If you specify an `array_size`, the `host_variable` must be an array of that size; for example, if `array_size` is `10`, `:host_variable` must be a 10-member array of `host_variables`. If you omit the `FOR` clause, the statement is executed once for each member of the array. + +`descriptor_name` specifies the name of a descriptor (as a single-quoted string literal), or a host variable that contains the name of a descriptor. + +Include the `VALUE` clause to specify the information retrieved from the descriptor. + +- `column_number` identifies the position of the variable within the descriptor. + +- `host_variable` specifies the name of the host variable that will receive the value of the item. + +- `descriptor_item` specifies the type of the retrieved descriptor item. + +ECPGPlus implements the following `descriptor_item` types: + +- `TYPE` +- `LENGTH` +- `OCTET_LENGTH` +- `RETURNED_LENGTH` +- `RETURNED_OCTET_LENGTH` +- `PRECISION` +- `SCALE` +- `NULLABLE` +- `INDICATOR` +- `DATA` +- `NAME` + +The following code fragment demonstrates using a `GET DESCRIPTOR` statement to obtain the number of columns entered in a user-provided string: + +```text +EXEC SQL ALLOCATE DESCRIPTOR parse_desc; +EXEC SQL PREPARE query FROM :stmt; +EXEC SQL DESCRIBE query INTO SQL DESCRIPTOR parse_desc; +EXEC SQL GET DESCRIPTOR parse_desc :col_count = COUNT; +``` + +The example allocates an SQL descriptor (named `parse_desc`), before using a `PREPARE` statement to syntax check the string provided by the user `(:stmt)`. A `DESCRIBE` statement moves the user-provided string into the descriptor, `parse_desc`. The call to `EXEC SQL GET DESCRIPTOR` interrogates the descriptor to discover the number of columns `(:col_count)` in the result set. + +### INSERT + +Use the `INSERT` statement to add one or more rows to a table. The syntax for the ECPGPlus `INSERT` statement is the same as the syntax for the SQL statement, but you can use parameter markers and host variables any place that a value is allowed. The syntax is: + +```text +[FOR ] INSERT INTO
[( [, ...])] + {DEFAULT VALUES | + VALUES ({ | DEFAULT} [, ...])[, ...] | } + [RETURNING * | [[ AS ] ] [, ...]] +``` + +Where: + +Include the `FOR exec_count` clause to specify the number of times the statement will execute; this clause is valid only if the `VALUES` clause references an array or a pointer to an array. + +`table` specifies the (optionally schema-qualified) name of an existing table. + +`column` is the name of a column in the table. The column name may be qualified with a subfield name or array subscript. Specify the `DEFAULT VALUES` clause to use default values for all columns. + +`expression` is the expression, value, host variable or parameter marker that will be assigned to the corresponding column. Specify `DEFAULT` to fill the corresponding column with its default value. + +`query` specifies a `SELECT` statement that supplies the row(s) to be inserted. + +`output_expression` is an expression that will be computed and returned by the `INSERT` command after each row is inserted. The expression can refer to any column within the table. Specify \* to return all columns of the inserted row(s). + +`output_name` specifies a name to use for a returned column. + +The following example adds a row to the `employees` table: + +```text +INSERT INTO emp (empno, ename, job, hiredate) + VALUES ('8400', :ename, 'CLERK', '2011-10-31'); +``` + +!!! Note + The `INSERT` statement uses a host variable `(:ename)` to specify the value of the `ename` column. + +For more information about using the `INSERT` statement, see the PostgreSQL Core documentation available at: + + + +### OPEN + +Use the `OPEN` statement to open a cursor. The syntax is: + +```text +EXEC SQL [FOR ] OPEN [USING ]; +``` + +Where `parameters` is one of the following: + +```text +DESCRIPTOR +``` + +or + +```text + [ [ INDICATOR ] , … ] +``` + +Where: + +`array_size` is an integer value or a host variable that contains an integer value specifying the number of rows to fetch. If you omit the `FOR` clause, the statement is executed once for each member of the array. + +`cursor` is the name of the cursor being opened. + +`parameters` is either `DESCRIPTOR SQLDA_descriptor` or a comma-separated list of `host variables` (and optional `indicator variables`) that initialize the cursor. If specifying an `SQLDA_descriptor`, the descriptor must be initialized with a `DESCRIBE` statement. + +The `OPEN` statement initializes a cursor using the values provided in `parameters`. Once initialized, the cursor result set will remain unchanged unless the cursor is closed and re-opened. A cursor is automatically closed when an application terminates. + +The following example declares a cursor named `employees`, that queries the `emp` table, returning the `employee number`, `name`, `salary` and `commission` of an employee whose name matches a user-supplied value (stored in the host variable, `:emp_name`). + +```text + EXEC SQL DECLARE employees CURSOR FOR + SELECT + empno, ename, sal, comm  + FROM  + emp + WHERE ename = :emp_name; + EXEC SQL OPEN employees; +... +``` + +After declaring the cursor, the example uses an `OPEN` statement to make the contents of the cursor available to a client application. + +### OPEN DESCRIPTOR + +Use the `OPEN DESCRIPTOR` statement to open a cursor with a SQL descriptor. The syntax is: + +```text +EXEC SQL [FOR ] OPEN + [USING [SQL] DESCRIPTOR ] + [INTO [SQL] DESCRIPTOR ]; +``` + +Where: + +`array_size` is an integer value or a host variable that contains an integer value specifying the number of rows to fetch. If you omit the `FOR` clause, the statement is executed once for each member of the array. + +`cursor` is the name of the cursor being opened. + +`descriptor_name` specifies the name of an SQL descriptor (in the form of a single-quoted string literal) or a host variable that contains the name of an SQL descriptor that contains the query that initializes the cursor. + +For example, the following statement opens a cursor (named `emp_cursor`), using the host variable, `:employees`: + +```text +EXEC SQL OPEN emp_cursor USING DESCRIPTOR :employees; +``` + +### PREPARE + +Prepared statements are useful when a client application must perform a task multiple times; the statement is parsed, written and planned only once, rather than each time the statement is executed, saving repetitive processing time. + +Use the `PREPARE` statement to prepare an SQL statement or PL/pgSQL block for execution. The statement is available in two forms; the first form is: + +```text +EXEC SQL [AT ] PREPARE + FROM ; +``` + +The second form is: + +```text +EXEC SQL [AT ] PREPARE + AS ; +``` + +Where: + +`database_name` is the database identifier or a host variable that contains the database identifier against which the statement will execute. If you omit the `AT` clause, the statement will execute against the current default database. + +`statement_name` is the identifier associated with a prepared SQL statement or PL/SQL block. + +`sql_statement` may take the form of a `SELECT` statement, a single-quoted string literal or host variable that contains the text of an SQL statement. + +To include variables within a prepared statement, substitute placeholders (`$1, $2, $3`, etc.) for statement values that might change when you `PREPARE` the statement. When you `EXECUTE` the statement, provide a value for each parameter. The values must be provided in the order in which they will replace placeholders. + +The following example creates a prepared statement (named `add_emp`) that inserts a record into the `emp` table: + +```text +EXEC SQL PREPARE add_emp (int, text, text, numeric) AS + INSERT INTO emp VALUES($1, $2, $3, $4); +``` + +Each time you invoke the statement, provide fresh parameter values for the statement: + +```text +EXEC SQL EXECUTE add_emp(8003, 'Davis', 'CLERK', 2000.00); +EXEC SQL EXECUTE add_emp(8004, 'Myer', 'CLERK', 2000.00); +``` + +!!! Note + A client application must issue a `PREPARE` statement within each session in which a statement will be executed; prepared statements persist only for the duration of the current session. + +### ROLLBACK + +Use the `ROLLBACK` statement to abort the current transaction, and discard any updates made by the transaction. The syntax is: + +```text +EXEC SQL [AT ] ROLLBACK [WORK] + [ { TO [SAVEPOINT] } | RELEASE ] +``` + +Where: + +`database_name` is the database identifier or a host variable that contains the database identifier against which the statement will execute. If you omit the `AT` clause, the statement will execute against the current default database. + +Include the `TO` clause to abort any commands that were executed after the specified `savepoint`; use the `SAVEPOINT` statement to define the `savepoint`. If you omit the `TO` clause, the `ROLLBACK` statement will abort the transaction, discarding all updates. + +Include the `RELEASE` clause to cause the application to execute an `EXEC SQL COMMIT RELEASE` and close the connection. + +Use the following statement to rollback a complete transaction: + +```text +EXEC SQL ROLLBACK; +``` + +Invoking this statement will abort the transaction, undoing all changes, erasing any savepoints, and releasing all transaction locks. If you include a savepoint (`my_savepoint` in the following example): + +```text +EXEC SQL ROLLBACK TO SAVEPOINT my_savepoint; +``` + +Only the portion of the transaction that occurred after the `my_savepoint` is rolled back; `my_savepoint` is retained, but any savepoints created after `my_savepoint` will be erased. + +Rolling back to a specified savepoint releases all locks acquired after the savepoint. + +### SAVEPOINT + +Use the `SAVEPOINT` statement to define a `savepoint`; a savepoint is a marker within a transaction. You can use a `ROLLBACK` statement to abort the current transaction, returning the state of the server to its condition prior to the specified savepoint. The syntax of a `SAVEPOINT` statement is: + +```text +EXEC SQL [AT ] SAVEPOINT +``` + +Where: + +`database_name` is the database identifier or a host variable that contains the database identifier against which the savepoint resides. If you omit the `AT` clause, the statement will execute against the current default database. + +`savepoint_name` is the name of the savepoint. If you re-use a `savepoint_name`, the original savepoint is discarded. + +Savepoints can only be established within a transaction block. A transaction block may contain multiple savepoints. + +To create a savepoint named `my_savepoint`, include the statement: + +```text +EXEC SQL SAVEPOINT my_savepoint; +``` + +### SELECT + +ECPGPlus extends support of the `SQL SELECT` statement by providing the `INTO host_variables` clause. The clause allows you to select specified information from an Advanced Server database into a host variable. The syntax for the `SELECT` statement is: + +```text +EXEC SQL [AT ] +SELECT + [ ] + [ ALL | DISTINCT [ ON( , ...) ]] + select_list INTO + + [ FROM from_item [, from_item ]...] + [ WHERE condition ] + [ hierarchical_query_clause ] + [ GROUP BY expression [, ...]] + [ HAVING condition ] + [ { UNION [ ALL ] | INTERSECT | MINUS } (subquery) ] + [ ORDER BY expression> [order_by_options]] + [ LIMIT { count | ALL }] + [ OFFSET start [ ROW | ROWS ] ] + [ FETCH { FIRST | NEXT } [ count ] { ROW | ROWS } ONLY ] + [ FOR { UPDATE | SHARE } [OF table_name [, ...]][NOWAIT ][...]] +``` + +Where: + +`database_name` is the name of the database (or host variable that contains the name of the database) in which the table resides. This value may take the form of an unquoted string literal, or of a host variable. + +`host_variables` is a list of host variables that will be populated by the `SELECT` statement. If the `SELECT` statement returns more than a single row, `host_variables` must be an array. + +ECPGPlus provides support for the additional clauses of the SQL `SELECT` statement as documented in the PostgreSQL Core documentation available at: + + + +To use the `INTO` `host_variables` clause, include the names of defined host variables when specifying the `SELECT` statement. For example, the following `SELECT` statement populates the `:emp_name` and `:emp_sal` host variables with a list of `employee names` and `salaries`: + +```text +EXEC SQL SELECT ename, sal + INTO :emp_name, :emp_sal + FROM emp + WHERE empno = 7988; +``` + +The enhanced `SELECT` statement also allows you to include parameter markers (question marks) in any clause where a value would be permitted. For example, the following query contains a parameter marker in the `WHERE` clause: + +```text +SELECT * FROM emp WHERE dept_no = ?; +``` + +This `SELECT` statement allows you to provide a value at run-time for the `dept_no` parameter marker. + +### SET CONNECTION + +There are (at least) three reasons you may need more than one connection in a given client application: + +- You may want different privileges for different statements; +- You may need to interact with multiple databases within the same client. +- Multiple threads of execution (within a client application) cannot share a connection concurrently. + +The syntax for the `SET CONNECTION` statement is: + +```text +EXEC SQL SET CONNECTION ; +``` + +Where: + +`connection_name` is the name of the connection to the database. + +To use the `SET CONNECTION` statement, you should open the connection to the database using the second form of the `CONNECT` statement; include the AS clause to specify a `connection_name`. + +By default, the current thread uses the current connection; use the `SET CONNECTION` statement to specify a default connection for the current thread to use. The default connection is only used when you execute an `EXEC SQL` statement that does not explicitly specify a connection name. For example, the following statement will use the default connection because it does not include an `AT` `connection_name` clause. : + +```text +EXEC SQL DELETE FROM emp; +``` + +This statement will not use the default connection because it specifies a connection name using the `AT` `connection_name` clause: + +```text +EXEC SQL AT acctg_conn DELETE FROM emp; +``` + +For example, a client application that creates and maintains multiple connections (such as): + +```text +EXEC SQL CONNECT TO edb AS acctg_conn + USER 'alice' IDENTIFIED BY 'acctpwd'; +``` + +and + +```text +EXEC SQL CONNECT TO edb AS hr_conn + USER 'bob' IDENTIFIED BY 'hrpwd'; +``` + +Can change between the connections with the `SET CONNECTION` statement: + +```text +SET CONNECTION acctg_conn; +``` + +or + +```text +SET CONNECTION hr_conn; +``` + +The server will use the privileges associated with the connection when determining the privileges available to the connecting client. When using the `acctg_conn` connection, the client will have the privileges associated with the role, `alice`; when connected using `hr_conn`, the client will have the privileges associated with `bob`. + +### SET DESCRIPTOR + +Use the `SET DESCRIPTOR` statement to assign a value to a descriptor area using information provided by the client application in the form of a host variable or an integer value. The statement comes in two forms; the first form is: + +```text +EXEC SQL [FOR ] SET DESCRIPTOR + VALUE = ; +``` + +The second form is: + +```text +EXEC SQL [FOR ] SET DESCRIPTOR + COUNT = integer; +``` + +Where: + +`array_size` is an integer value or a host variable that contains an integer value specifying the number of rows to fetch. If you omit the `FOR` clause, the statement is executed once for each member of the array. + +`descriptor_name` specifies the name of a descriptor (as a single-quoted string literal), or a host variable that contains the name of a descriptor. + +Include the `VALUE` clause to describe the information stored in the descriptor. + +- `column_number` identifies the position of the variable within the descriptor. + +- `descriptor_item` specifies the type of the descriptor item. + +- `host_variable` specifies the name of the host variable that contains the value of the item. + +ECPGPlus implements the following `descriptor_item` types: + +- `TYPE` +- `LENGTH` +- `[REF] INDICATOR` +- `[REF] DATA` +- `[REF] RETURNED LENGTH` + +For example, a client application might prompt a user for a dynamically created query: + +```text +query_text = promptUser("Enter a query"); +``` + +To execute a dynamically created query, you must first `prepare` the query (parsing and validating the syntax of the query), and then `describe` the `input` parameters found in the query using the `EXEC SQL DESCRIBE INPUT` statement. + +```text +EXEC SQL ALLOCATE DESCRIPTOR query_params; +EXEC SQL PREPARE emp_query FROM :query_text; + +EXEC SQL DESCRIBE INPUT emp_query + USING SQL DESCRIPTOR 'query_params'; +``` + +After describing the query, the `query_params` descriptor contains information about each parameter required by the query. + +For this example, we'll assume that the user has entered: + +```text +SELECT ename FROM emp WHERE sal > ? AND job = ?;, +``` + +In this case, the descriptor describes two parameters, one for `sal > ?` and one for `job = ?`. + +To discover the number of parameter markers (question marks) in the query (and therefore, the number of values you must provide before executing the query), use: + +```text +EXEC SQL GET DESCRIPTOR … :host_variable = COUNT; +``` + +Then, you can use `EXEC SQL GET DESCRIPTOR` to retrieve the name of each parameter. You can also use `EXEC SQL GET DESCRIPTOR` to retrieve the type of each parameter (along with the number of parameters) from the descriptor, or you can supply each `value` in the form of a character string and ECPG will convert that string into the required data type. + +The data type of the first parameter is `numeric`; the type of the second parameter is `varchar`. The name of the first parameter is `sal`; the name of the second parameter is `job`. + +Next, loop through each parameter, prompting the user for a value, and store those values in host variables. You can use `GET DESCRIPTOR … COUNT` to find the number of parameters in the query. + +```text +EXEC SQL GET DESCRIPTOR 'query_params' + :param_count = COUNT; + +for(param_number = 1; + param_number <= param_count; + param_number++) +{ +``` + +Use `GET DESCRIPTOR` to copy the name of the parameter into the `param_name` host variable: + +```text +EXEC SQL GET DESCRIPTOR 'query_params' + VALUE :param_number :param_name = NAME; + +reply = promptUser(param_name); +if (reply == NULL) + reply_ind = 1; /* NULL */ +else + reply_ind = 0; /* NOT NULL */ +``` + +To associate a `value` with each parameter, you use the `EXEC SQL SET DESCRIPTOR` statement. For example: + +```text +EXEC SQL SET DESCRIPTOR 'query_params' + VALUE :param_number DATA = :reply; +EXEC SQL SET DESCRIPTOR 'query_params' + VALUE :param_number INDICATOR = :reply_ind; +} +``` + +Now, you can use the `EXEC SQL EXECUTE DESCRIPTOR` statement to execute the prepared statement on the server. + +### UPDATE + +Use an `UPDATE` statement to modify the data stored in a table. The syntax is: + +```text +EXEC SQL [AT ][FOR ] + UPDATE [ ONLY ] table [ [ AS ] alias ] + SET {column = { expression | DEFAULT } | + (column [, ...]) = ({ expression|DEFAULT } [, ...])} [, ...] + [ FROM from_list ] + [ WHERE condition | WHERE CURRENT OF cursor_name ] + [ RETURNING * | output_expression [[ AS ] output_name] [, ...] ] +``` + +Where: + +`database_name` is the name of the database (or host variable that contains the name of the database) in which the table resides. This value may take the form of an unquoted string literal, or of a host variable. + +Include the `FOR exec_count` clause to specify the number of times the statement will execute; this clause is valid only if the `SET` or `WHERE` clause contains an array. + +ECPGPlus provides support for the additional clauses of the SQL `UPDATE` statement as documented in the PostgreSQL Core documentation available at: + + + +A host variable can be used in any clause that specifies a value. To use a host variable, simply substitute a defined variable for any value associated with any of the documented `UPDATE` clauses. + +The following `UPDATE` statement changes the job description of an employee (identified by the `:ename` host variable) to the value contained in the `:new_job` host variable, and increases the employees salary, by multiplying the current salary by the value in the `:increase` host variable: + +```text +EXEC SQL UPDATE emp + SET job = :new_job, sal = sal * :increase + WHERE ename = :ename; +``` + +The enhanced `UPDATE` statement also allows you to include parameter markers (question marks) in any clause where an input value would be permitted. For example, we can write the same update statement with a parameter marker in the `WHERE` clause: + +```text +EXEC SQL UPDATE emp + SET job = ?, sal = sal * ? + WHERE ename = :ename; +``` + +This `UPDATE` statement could allow you to prompt the user for a new value for the `job` column and provide the amount by which the `sal` column is incremented for the employee specified by `:ename`. + +### WHENEVER + +Use the `WHENEVER` statement to specify the action taken by a client application when it encounters an SQL error or warning. The syntax is: + +```text +EXEC SQL WHENEVER ; +``` + +The following table describes the different conditions that might trigger an `action`: + +| **Condition** | **Description** | +| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | +| `NOT FOUND` | The server returns a `NOT FOUND` condition when it encounters a `SELECT` that returns no rows, or when a `FETCH` reaches the end of a result set. | +| `SQLERROR` | The server returns an `SQLERROR` condition when it encounters a serious error returned by an SQL statement. | +| `SQLWARNING` | The server returns an `SQLWARNING` condition when it encounters a non-fatal warning returned by an SQL statement. | + +The following table describes the actions that result from a client encountering a `condition`: + +| **Action** | **Description** | +| ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `CALL function [([args])]` | Instructs the client application to call the named `function`. | +| `CONTINUE` | Instructs the client application to proceed to the next statement. | +| `DO BREAK` | Instructs the client application to a C break statement. A break statement may appear in a `loop` or a `switch` statement. If executed, the break statement terminate the `loop` or the `switch` statement. | +| `DO CONTINUE` | Instructs the client application to emit a C `continue` statement. A `continue` statement may only exist within a loop, and if executed, will cause the flow of control to return to the top of the loop. | +| `DO function ([args])` | Instructs the client application to call the named `function`. | +| `GOTO label` or `GO TO label` | Instructs the client application to proceed to the statement that contains the `label`. | +| `SQLPRINT` | Instructs the client application to print a message to standard error. | +| `STOP` | Instructs the client application to stop execution. | + +The following code fragment prints a message if the client application encounters a warning, and aborts the application if it encounters an error: + +```text +EXEC SQL WHENEVER SQLWARNING SQLPRINT; +EXEC SQL WHENEVER SQLERROR STOP; +``` + +Include the following code to specify that a client should continue processing after warning a user of a problem: + +```text +EXEC SQL WHENEVER SQLWARNING SQLPRINT; +``` + +Include the following code to call a function if a query returns no rows, or when a cursor reaches the end of a result set: + +```text +EXEC SQL WHENEVER NOT FOUND CALL error_handler(__LINE__); +``` diff --git a/product_docs/docs/epas/12/ecpgplus_guide/images/ecpg_path.png b/product_docs/docs/epas/12/ecpgplus_guide/images/ecpg_path.png new file mode 100755 index 00000000000..419ef7d0202 Binary files /dev/null and b/product_docs/docs/epas/12/ecpgplus_guide/images/ecpg_path.png differ diff --git a/product_docs/docs/epas/12/ecpgplus_guide/images/edb_logo.png b/product_docs/docs/epas/12/ecpgplus_guide/images/edb_logo.png new file mode 100644 index 00000000000..39a54822d85 Binary files /dev/null and b/product_docs/docs/epas/12/ecpgplus_guide/images/edb_logo.png differ diff --git a/product_docs/docs/epas/12/ecpgplus_guide/images/edb_logo.svg b/product_docs/docs/epas/12/ecpgplus_guide/images/edb_logo.svg new file mode 100644 index 00000000000..f24d1dfefee --- /dev/null +++ b/product_docs/docs/epas/12/ecpgplus_guide/images/edb_logo.svg @@ -0,0 +1,19 @@ + + + edb-logo-disc-dark + + + + \ No newline at end of file diff --git a/product_docs/docs/epas/12/ecpgplus_guide/index.mdx b/product_docs/docs/epas/12/ecpgplus_guide/index.mdx new file mode 100644 index 00000000000..89311ae0fa3 --- /dev/null +++ b/product_docs/docs/epas/12/ecpgplus_guide/index.mdx @@ -0,0 +1,30 @@ +--- +navTitle: ECPGPlus +title: "ECPGPlus Guide" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/user-guides/ecpgplus-guide/13/index.html" + - "/edb-docs/d/edb-postgres-advanced-server/user-guides/ecpgplus-guide/13/conclusion.html" + - "/edb-docs/d/edb-postgres-advanced-server/user-guides/ecpgplus-guide/13/introduction.html" +--- + +EnterpriseDB has enhanced ECPG (the PostgreSQL pre-compiler) to create ECPGPlus. ECPGPlus allows you to include Pro\*C compatible embedded SQL commands in C applications when connected to an EDB Postgres Advanced Server (Advanced Server) database. When you use ECPGPlus to compile an application, the SQL code is syntax-checked and translated into C. + +ECPGPlus supports: + +- Oracle Dynamic SQL – Method 4 (ODS-M4). +- Pro\*C compatible anonymous blocks. +- A `CALL` statement compatible with Oracle databases. + +As part of ECPGPlus's Pro\*C compatibility, you do not need to include the `BEGIN DECLARE SECTION` and `END DECLARE SECTION` directives. + +**PostgreSQL Compatibility** + +While most ECPGPlus statements will work with community PostgreSQL, the `CALL` statement, and the `EXECUTE…END EXEC` statement work only when the client application is connected to EDB Postgres Advanced Server. + +
+ +introduction overview using_embedded_sql using_descriptors building_executing_dynamic_sql_statements error_handling reference conclusion + +
diff --git a/product_docs/docs/epas/12/edb_plus/02_edb_plus.mdx b/product_docs/docs/epas/12/edb_plus/02_edb_plus.mdx new file mode 100644 index 00000000000..60998c1669b --- /dev/null +++ b/product_docs/docs/epas/12/edb_plus/02_edb_plus.mdx @@ -0,0 +1,18 @@ +--- +title: "EDB*Plus" +legacyRedirects: + - "/edb-docs/d/edbplus/user-guides/edbplus-users-guide/39/edb_plus.html" +--- + + + +EDB\*Plus is a utility program that provides a command line user interface to EDB Postgres Advanced Server. EDB\*Plus accepts SQL commands, SPL anonymous blocks, and EDB\*Plus commands. + +EDB\*Plus commands are compatible with Oracle SQL\*Plus commands and provide various capabilities including: + +- Querying certain database objects +- Executing stored procedures +- Formatting output from SQL commands +- Executing batch scripts +- Executing OS commands +- Recording output diff --git a/product_docs/docs/epas/12/edb_plus/03_installing_edb_plus.mdx/01_installing_prereq.mdx b/product_docs/docs/epas/12/edb_plus/03_installing_edb_plus.mdx/01_installing_prereq.mdx new file mode 100644 index 00000000000..bfc707dd288 --- /dev/null +++ b/product_docs/docs/epas/12/edb_plus/03_installing_edb_plus.mdx/01_installing_prereq.mdx @@ -0,0 +1,45 @@ +--- +title: "Installation Prerequisites" + +legacyRedirects: + - "/edb-docs/d/edbplus/user-guides/edbplus-users-guide/38/01_installing_prereq.html" +--- + + + + +Before installing EDB\*Plus, you must first install Java (version 1.7 or later). On a Linux system, you can use the `yum` package manager to install Java. Open a terminal window, assume superuser privileges, and enter: + +- On RHEL or CentOS 7: + + ```text + # yum install java + ``` + +- On RHEL or CentOS 8: + + ```text + # dnf install java + ``` + +If you are using Windows, Java installers and instructions are available online at: + + + + +You must also have credentials that allow access to the EDB repository. For information about requesting credentials, visit: + + + + +After receiving your repository credentials: + +1. Create the repository configuration file. +2. Modify the file, providing your user name and password. +3. Install EDB\*Plus. + + + + + + diff --git a/product_docs/docs/epas/12/edb_plus/03_installing_edb_plus.mdx/02_rpm_installation.mdx b/product_docs/docs/epas/12/edb_plus/03_installing_edb_plus.mdx/02_rpm_installation.mdx new file mode 100644 index 00000000000..89f035a63b9 --- /dev/null +++ b/product_docs/docs/epas/12/edb_plus/03_installing_edb_plus.mdx/02_rpm_installation.mdx @@ -0,0 +1,144 @@ +--- +title: "Performing an RPM Installation" +legacyRedirects: + - "/edb-docs/d/edbplus/user-guides/edbplus-users-guide/38/rpm_installation" +--- + + + + +For detailed information about creating and using EDB repositories to install Advanced Server or its supporting components, see the *EDB Postgres Advanced Server Installation Guide available* at: + + + +**Creating a Repository Configuration File** + +To create the repository configuration file, assume superuser privileges, and invoke the following command: + +- On RHEL or CentOS 7: + + ```text + yum -y install https://yum.enterprisedb.com/edbrepos/edb-repo-latest.noarch.rpm + ``` + +- On RHEL or CentOS 8: + + ```text + dnf -y install https://yum.enterprisedb.com/edbrepos/edb-repo-latest.noarch.rpm + ``` + +The repository configuration file is named `edb.repo`. The file resides in `/etc/yum.repos.d`. + +After creating the `edb.repo` file, use your choice of editor to ensure that the value of the enabled parameter is 1, and +replace the `username` and `password` placeholders in the baseurl specification with the name and password of a +registered EDB user. + +``` +[edb] +name=EnterpriseDB RPMs $releasever - $basearch +baseurl=https://:@yum.enterprisedb.com/edb/redhat/rhel-$releasever-$basearch +enabled=1 +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/ENTERPRISEDB-GPG-KEY +``` +After saving your changes to the configuration file, you can use the following command to install EDB*Plus: + +- On RHEL or CentOS 7: + + ``` + yum install edb-asxx-edbplus + ``` + +- On RHEL or CentOS 8: + + ``` + dnf install edb-asxx-edbplus + ``` + +Where, `xx` is the Advanced Server version. + +When you install an RPM package that is signed by a source that is not recognized by your system, yum may ask for your permission to import the key to your local server. If prompted, and you are satisfied that the packages come from a trustworthy source, entery, and press `Return` to continue. + +During the installation, yum may encounter a dependency that it cannot resolve. If it does, it will provide a list of the required dependencies that you must manually resolve. + + +## Configuring an RPM Installation + +After performing an RPM installation of EDB\*Plus, you must set the values of environment variables that allow +EDB\*Plus to locate your Java installation. Use the following commands to set variable values: + +```text +export JAVA_HOME= +export PATH=/bin:$PATH +``` + +By default, the `pg_hba.conf` file for the RPM installer enforces `IDENT` authentication. Before invoking EDB*Plus, you must either modify the `pg_hba.conf` file, changing the authentication method to a form other than `IDENT` (and restarting the server), or perform the following steps to ensure that an `IDENT` server is accessible: + +You must confirm that an `identd` server is installed and running. You can use the `yum` package manager to install an `identd` server by invoking the command: + +- On RHEL or CentOS 7: + + ```text + yum install xinetd authd + ``` + +- On RHEL or CentOS 8: + + ```text + dnf install xinetd authd + ``` + +The command should create a file named ``/etc/xinetd.d/auth`` that contains: + +```text +service auth +{ + disable = yes + socket_type = stream +wait =no +user = ident +cps = 4096 10 +instances = UNLIMITED +server = /usr/sbin/in.authd server_args = -t60 --xerror -os +} +``` + +!!! Note + If the file includes a `-E` argument at the end of the server arguments, please erase `-E`. + +Then, to start the `identd` server, invoke the following commands: + +```text +systemctl enable xinetd +systemctl start xinetd +``` + +Open the `pg_ident.conf` file and create a user mapping: + +``` +# map_name system_username postgres_username + edbas enterprisedb enterprisedb +``` + +Where: + +- The name specified in the map_name column is a user-defined name that will identify the mapping in the `pg_hba.conf` file. +- The name specified in the system_username column is `enterprisedb`. +- The name specified in the `postgres_username` column is `enterprisedb`. + +Then, open the `pg_hba.conf` file and modify the `IDENT` entries: + +- If you are using an IPv4 local connection, modify the file entry to read: + + `host all all 127.0.0.0/0 ident map=edbas` + +- If you are using an IPv6 local connection, modify the file entry to read: + + `host all all ::1/128 ident map=edbas` + +You must restart the Advanced Server service before invoking EDB\*Plus. For detailed information about controlling the Advanced Server service, see the *EDB Postgres Advanced Server Installation Guide*, available at: + + + + + diff --git a/product_docs/docs/epas/12/edb_plus/03_installing_edb_plus.mdx/03_using_gui.mdx b/product_docs/docs/epas/12/edb_plus/03_installing_edb_plus.mdx/03_using_gui.mdx new file mode 100644 index 00000000000..c0925a39a0b --- /dev/null +++ b/product_docs/docs/epas/12/edb_plus/03_installing_edb_plus.mdx/03_using_gui.mdx @@ -0,0 +1,50 @@ +--- +title: "Using the Graphical Installer" +legacyRedirects: + - "/edb-docs/d/edbplus/user-guides/edbplus-users-guide/39/installing_edb_plus.html" +--- + + + + +Graphical installers for EDB\*Plus are available via StackBuilder Plus; you can access StackBuilder Plus through your Windows or Linux start menu. After opening StackBuilder Plus and selecting the installation for which you wish to install EDB\*Plus, expand the component selection screen tree control to select and download the EDB\*Plus installer. + +![The EDB\*Plus Welcome window](../images/edb_plus_welcome_1.png) + +
Fig. 1: The EDB*Plus Welcome window
+ + +The EDB\*Plus installer welcomes you to the setup wizard, as shown in the figure below. + +![The Installation Directory window](../images/installation_directory.png) + +
Fig. 2: The Installation Directory window
+ + +Use the `Installation Directory` field to specify the directory in which you wish to install the EDB\*Plus software. Then, click `Next` to continue. + +![The Advanced Server Installation Details window](../images/advanced_server_installation_details.png) + +
Fig. 3: The Advanced Server Installation Details window
+ + +Use fields on the `EDB Postgres Advanced Server Installation Details` window to identify the location of the Advanced Server host: + +- Use the `Host` field to identify the system on which Advanced Server resides. +- Use the `Port` field to identify the listener port that Advanced Server monitors for client connections. + +Then, click `Next` to continue. + +![The Ready to Install window](../images/ready_to_install.png) + +
Fig. 4: The Ready to Install window
+ + +The `Ready to Install` window notifies you when the installer has all of the information needed to install EDB\*Plus on your system. Click `Next` to install EDB\*Plus. + +![The installation is complete](../images/installation_complete.png) + +
Fig. 5: The installation is complete
+ + +The installer notifies you when the setup wizard has completed the EDB\*Plus installation. Click `Finish` to exit the installer. diff --git a/product_docs/docs/epas/12/edb_plus/03_installing_edb_plus.mdx/index.mdx b/product_docs/docs/epas/12/edb_plus/03_installing_edb_plus.mdx/index.mdx new file mode 100644 index 00000000000..9f951cd7871 --- /dev/null +++ b/product_docs/docs/epas/12/edb_plus/03_installing_edb_plus.mdx/index.mdx @@ -0,0 +1,15 @@ +--- +title: "Installing EDB*Plus" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/installation-getting-started/edb-plus/12/installing_edb_plus.html" +--- + +You can use an RPM installer or a graphical installer to add EDB*Plus to your Advanced Server installation. + +
+ +installing_prereq rpm_installation using_gui + +
\ No newline at end of file diff --git a/product_docs/docs/epas/12/edb_plus/04_using_edb_plus.mdx b/product_docs/docs/epas/12/edb_plus/04_using_edb_plus.mdx new file mode 100644 index 00000000000..b7940fea708 --- /dev/null +++ b/product_docs/docs/epas/12/edb_plus/04_using_edb_plus.mdx @@ -0,0 +1,141 @@ +--- +title: "Using EDB*Plus" +legacyRedirects: + - "/edb-docs/d/edbplus/user-guides/edbplus-users-guide/39/using_edb_plus.html" +--- + + + + + +To open an EDB\*Plus command line, navigate through the `Applications` or `Start` menu to the Advanced Server menu, to the `Run SQL Command Line` menu, and select the EDB\*Plus option. You can also invoke EDB\*Plus from the operating system command line with the following command: + +```text +edbplus [ -S[ILENT ] ] [ | /NOLOG ] [ @[. ] ] +``` + +`SILENT` + + If specified, the EDB\*Plus sign-on banner is suppressed along with all prompts. + +`login` + + Login information for connecting to the database server and database. `login` takes the following form; there must be no white space within the login information. + +```text +[/][@{ | } ] +``` + + Where: + + `username` is a database username with which to connect to the database. + + `password` is the password associated with the specified `username`. If a `password` is not provided, but a password is required for authentication, a password file is used if available. If there is no password file or no entry in the password file with the matching connection parameters, then EDB\*Plus will prompt for the password. + + `connectstring` is the database connection string with the following format: + +```text +[:][/][?ssl={true | false}] +``` + + Where: + + `host` is the hostname or IP address on which the database server resides. If neither `@connectstring` nor `@variable` nor `/NOLOG` is specified, the default host is assumed to be the localhost. `port` is the port number receiving connections on the database server. If not specified, the default is `5444`. `dbname` is the name of the database to connect to. If not specified the default is `edb`. If `Internet Protocol version 6` (IPv6) is used for the connection instead of IPv4, then the IP address must be enclosed within square brackets (that is, `[ipv6_address]`). The following is an example using an IPv6 connection: + +```text +edbplus.sh enterprisedb/password@[fe80::20c:29ff:fe7c:78b2]:5444/edb +``` + + The `pg_hba.conf` file for the database server must contain an appropriate entry for the IPv6 connection. The following example shows an entry that allows all addresses: + +```text +# TYPE DATABASE USER ADDRESS METHOD +host all all ::0/0 md5 +``` + +For more information about the `pg_hba.conf` file, see the PostgreSQL core documentation at: + + + + If an SSL connection is desired, then include the `?ssl=true` parameter in the connection string. In such a case, the connection string must minimally include `host:port`, with or without `/dbname`. If the `ssl` parameter is not specified, the default is `false`. See [Using a Secure Sockets Layer (SSL) Connection](05_using_edb_plus_with_ssl/#using_edb_plus_with_ssl) for instructions on setting up an SSL connection. + + `variable` is a variable defined in the `login.sql` file that contains a database connection string. The `login.sql` file can be found in the `edbplus` subdirectory of the Advanced Server home directory. + +`/NOLOG` + + Specify `/NOLOG` to start EDB\*Plus without establishing a database connection. SQL commands and EDB\*Plus commands that require a database connection cannot be used in this mode. The `CONNECT` command can be subsequently given to connect to a database after starting EDB\*Plus with the `/NOLOG` option. + +`scriptfile[.ext ]` + + `scriptfile` is the name of a file residing in the current working directory, containing SQL and/or EDB\*Plus commands that will be automatically executed after startup of EDB\*Plus. `ext` is the filename extension. If the filename extension is `sql`, then the `.sql` extension may be omitted when specifying `scriptfile`. When creating a script file, always name the file with an extension, otherwise it will not be accessible by EDB\*Plus. (EDB\*Plus will always assume a `.sql` extension on filenames that are specified with no extension.) + +The following example shows user `enterprisedb` with password `password`, connecting to database `edb` running on a database server on the `localhost` at port `5444`. + +```text +C:\Program Files\edb\as12\edbplus>edbplus enterprisedb/password +Connected to EnterpriseDB 12.0.1 (localhost:5444/edb) AS enterprisedb + +EDB*Plus: Release 12 (Build 38.0.0) +Copyright (c) 2008-2021, EnterpriseDB Corporation. All rights reserved. + +SQL> +``` + +The following example shows user `enterprisedb` with password, `password`, connecting to database `edb` running on a database server on the `localhost` at port `5445`. + +```text +C:\Program Files\edb\as12\edbplus>edbplus enterprisedb/password@localhost:5445/edb +Connected to EnterpriseDB 12.0.1 (localhost:5445/edb) AS enterprisedb + +EDB*Plus: Release 12 (Build 38.0.0) +Copyright (c) 2008-2021, EnterpriseDB Corporation. All rights reserved. + +SQL> +``` + +Using variable `hr_5445` in the `login.sql` file, the following illustrates how it is used to connect to database `hr` on localhost at port `5445`. + +```text +C:\Program Files\edb\as12\edbplus>edbplus enterprisedb/password@hr_5445 +Connected to EnterpriseDB 12.0.1 (localhost:5445/hr) AS enterprisedb + +EDB*Plus: Release 12 (Build 38.0.0) +Copyright (c) 2008-2021, EnterpriseDB Corporation. All rights reserved. + +SQL> +``` + +The following is the content of the `login.sql` file used in the previous example. + +```text +define edb="localhost:5445/edb" +define hr_5445="localhost:5445/hr" +``` + +The following example executes a script file, `dept_query.sql` after connecting to database `edb` on server localhost at port `5444`. + +```text +C:\Program Files\edb\as12\edbplus>edbplus enterprisedb/password @dept_query +Connected to EnterpriseDB 12.0.1 (localhost:5444/edb) AS enterprisedb + +SQL> SELECT * FROM dept; + +DEPTNO DNAME LOC +------ -------------- ------------- +10 ACCOUNTING NEW YORK +20 RESEARCH DALLAS +30 SALES CHICAGO +40 OPERATIONS BOSTON + +SQL> EXIT +Disconnected from EnterpriseDB Database. +``` + +The following is the content of file `dept_query.sql` used in the previous example. + +```text +SET PAGESIZE 9999 +SET ECHO ON +SELECT * FROM dept; +EXIT +``` diff --git a/product_docs/docs/epas/12/edb_plus/05_using_edb_plus_with_ssl.mdx b/product_docs/docs/epas/12/edb_plus/05_using_edb_plus_with_ssl.mdx new file mode 100644 index 00000000000..ebfaf9743aa --- /dev/null +++ b/product_docs/docs/epas/12/edb_plus/05_using_edb_plus_with_ssl.mdx @@ -0,0 +1,326 @@ +--- +title: "Using a Secure Sockets Layer (SSL) Connection" +legacyRedirects: + - "/edb-docs/d/edbplus/user-guides/edbplus-users-guide/39/using_edb_plus_with_ssl.html" +--- + + + + + +An EDB\*Plus connection to the Advanced Server database can be accomplished using secure sockets layer (SSL) connectivity. + +Using SSL requires various prerequisite configuration steps performed on the database server involved with the SSL connection as well as creation of the Java truststore and keystore on the host that will run EDB\*Plus. + +The Java *truststore* is the file containing the Certificate Authority (CA) certificates with which the Java client (EDB\*Plus) uses to verify the authenticity of the server to which it is initiating an SSL connection. + +The Java *keystore* is the file containing private and public keys and their corresponding certificates. The keystore is required for client authentication to the server, which is used for the EDB\*Plus connection. + +The following is material to which you can refer to for guidance in setting up the SSL connections: + +- For information on setting up SSL connectivity to the Advanced Server database, see the section about secure TCP connections with SSL in Chapter 18 “Server Setup and Operation” in the PostgreSQL Core Documentation located at: + + + +- For information on JDBC client connectivity using SSL, see the section on configuring the client in Chapter 4 “Using SSL” in The PostgreSQL JDBC Interface located at: + + + +The following sections provide information for the configuration steps of using SSL. + +- Configuring SSL on Advanced Server +- Configuring SSL for the EDB\*Plus client +- Requesting SSL connection to the Advanced Server database + +## Configuring SSL on Advanced Server + +This section provides an example of configuring SSL on a database server to demonstrate the use of SSL with EDB\*Plus. A self-signed certificate is used for this purpose. + +**Step 1:** Create the certificate signing request (CSR). + +In the following example the generated certificate signing request file is `server.csr`. The private key is generated as file `server.key`. + +```text +$ openssl req -new -nodes -text -out server.csr \ +> -keyout server.key -subj "/CN=enterprisedb" +Generating a 2048 bit RSA private key +.............................+++ +....................................................................+++ +writing new private key to 'server.key' +----- +``` + +!!! Note + When creating the certificate, the value specified for the common name field (designated as `CN=enterprisedb` in this example) must be the database user name that is specified when connecting to EDB\*Plus. + +In addition, user name maps can be used as defined in the `pg_ident.conf` file to permit more flexibility for the common name and database user name. Steps 8 and 9 describe the use of user name `maps`. + +**Step 2:** Generate the self-signed certificate. + +The following generates a self-signed certificate to file `server.crt` using the certificate signing request file, `server.csr`, and the private key, `server.key`, as input. + +```text +$ openssl x509 -req -days 365 -in server.csr -signkey server.key \ +> -out server.crt +Signature ok +subject=/CN=enterprisedb +Getting Private key +``` + +**Step 3:** Make a copy of the server certificate (`server.crt`) to be used as the root Certificate Authority (CA) file (`root.crt`). + +```text +$ cp server.crt root.crt +``` + +**Step 4:** Delete the now redundant certificate signing request (`server.csr`). + +```text +$ rm -f server.csr +``` + +**Step 5:** Move or copy the certificate and private key files to the Advanced Server data directory (for example, `/opt/edb/as12/data`). + +```text +$ mv root.crt /opt/edb/as12/data +$ mv server.crt /opt/edb/as12/data +$ mv server.key /opt/edb/as12/data +``` + +**Step 6:** Set the file ownership and permissions on the certificate files and private key file. + +Set the ownership to the operating system account that owns the data sub-directory of the database server. Set the permissions so that no other groups or accounts other than the owner can access these files. + +```text +$ chown enterprisedb root.crt server.crt server.key +$ chgrp enterprisedb root.crt server.crt server.key +$ chmod 600 root.crt server.crt server.key +$ ls -l +total 152 + . + . + . +-rw------- 1 enterprisedb enterprisedb 985 Aug 22 11:00 root.crt +-rw------- 1 enterprisedb enterprisedb 985 Aug 22 10:59 server.crt +-rw------- 1 enterprisedb enterprisedb 1704 Aug 22 10:58 server.key +``` + +**Step 7:** In the `postgresql.conf` file, make the following modifications. + +```text +ssl = on +ssl_cert_file = 'server.crt' +ssl_key_file = 'server.key' +ssl_ca_file = 'root.crt' +``` + +**Step 8:** Modify the `pg_hba.conf` file to enable SSL usage on the desired database to which EDB\*Plus is to make the SSL connection. + +In the `pg_hba.conf` file, the `hostssl` type indicates the entry is used to validate SSL connection attempts from the client (EDB\*Plus). + +The authentication method is set to cert with the option `clientcert=1` in order to require an SSL certificate from the client against which authentication is performed using the common name of the certificate (`enterprisedb` in this example). + +The `map=sslusers` option specifies that a mapping named `sslusers` defined in the `pg_ident.conf` file is to be used for authentication. This mapping allows a connection to the database if the common name from the certificate and the database user name attempting the connection match the `SYSTEM-USERNAME/PG-USERNAME` pair listed in the `pg_ident.conf` file. + +The following is an example of the settings in the `pg_hba.conf` file if the database `(edb)` must use SSL connections. + +```text +# TYPE DATABASE USER ADDRESS METHOD + +# "local" is for Unix domain socket connections only +local all all md5 +# IPv4 local connections: +hostssl edb all 192.168.2.0/24 cert clientcert=1 map=sslusers +``` + +**Step 9:** The following shows the user name maps in the `pg_ident.conf` file related to the `pg_hba.conf` file by the `map=sslusers` option. These user name maps permit you to specify database user names `edbuser`, `postgres`, or `enterprisedb` when connecting with EDB\*Plus. + +```text +# MAPNAME SYSTEM-USERNAME PG-USERNAME + sslusers enterprisedb edbuser + sslusers enterprisedb postgres + sslusers enterprisedb enterprisedb +``` + +**Step 10:** Restart the database server after you have made the changes to the configuration files. + +## Configuring SSL for the EDB\*Plus Client + +After you have configured SSL on the database server, the following steps provide an example of generating certificate and keystore files for EDB\*Plus (the JDBC client). + +**Step 1:** Using files `server.crt` and `server.key` located under the database server data sub-directory, create copies of these files and move them to the host where EDB\*Plus is to be running. + +Store these files in the desired directory to contain the trusted certificate and keystore files to be generated in the following steps. The suggested location is to create a `.postgresql` sub-directory under the home user account that will invoke EDB\*Plus. Thus, these files will be under the `~/.postgresql` directory of the user account that will run EDB\*Plus. + +For this example, assume file `edb.crt` is a copy of `server.crt` and `edb.key` is a copy of `server.key`. + +**Step 2:** Create an additional copy of `edb.crt`. + +```text +$ cp edb.crt edb_root.crt +$ ls -l +total 12 +-rw-r--r-- 1 user user 985 Aug 22 14:17 edb.crt +-rw-r--r-- 1 user user 1704 Aug 22 14:18 edb.key +-rw-r--r-- 1 user user 985 Aug 22 14:19 edb_root.crt +``` + +**Step 3:** Create a Distinguished Encoding Rules (DER) format of file `edb_root.crt`. The generated DER format of this file is `edb_root.crt.der`. The DER format of the file is required for the `keytool` program used in Step 4. + +```text +$ openssl x509 -in edb_root.crt -out edb_root.crt.der -outform der +$ ls -l +total 16 +-rw-r--r-- 1 user user 985 Aug 22 14:17 edb.crt +-rw-r--r-- 1 user user 1704 Aug 22 14:18 edb.key +-rw-r--r-- 1 user user 985 Aug 22 14:19 edb_root.crt +-rw-rw-r-- 1 user user 686 Aug 22 14:21 edb_root.crt.der +``` + +**Step 4:** Use the `keytool` program to create a keystore file `(postgresql.keystore)` using `edb_root.crt.der` as the input. This process adds the certificate of the Postgres database server to the keystore file. + +!!! Note + The file name `postgresql.keystore` is recommended so that it can be accessed in its default directory location `~/.postgresql postgresql.keystore`, which is under the home directory of the user account invoking EDB\*Plus. Also note that the file name suffix can be `.jks` instead of `.keystore` (thus, file name `postgresql.jks`). However, in the remainder of these examples, file name `postgresql.keystore` is used. + +**For Windows only:** The path is `%APPDATA%\.postgresql\postgresql.keystore` + +The `keytool` program can be found under the `bin` subdirectory of the Java Runtime Environment installation. + +You will be prompted for a new password. Save this password as it must be specified with the PGSSLCERTPASS environment variable. + +```text +$ /usr/java/jdk1.8.0_131/jre/bin/keytool -keystore postgresql.keystore \ +> -alias postgresqlstore -import -file edb_root.crt.der +Enter keystore password: +Re-enter new password: +Owner: CN=enterprisedb +Issuer: CN=enterprisedb +Serial number: c60f40256b0e8d53 +Valid from: Tue Aug 22 10:59:25 EDT 2017 until: Wed Aug 22 10:59:25 EDT 2018 +Certificate fingerprints: + MD5: 85:0B:E9:A7:6E:4F:7C:B0:9B:D6:3A:44:55:E2:E9:8E + SHA1: DD:A6:71:24:0B:6C:F8:BC:7A:4C:89:9B:DC:22:6A:6C:B0:F5:3F:7C + SHA256: +DC:02:64:E2:B0:E9:6F:1C:FC:4F:AE:E6:18:85:0B:79:57:43:C3:C5:AE:43:0D:37 +:49:53:6D:11:69:06:46:48 + Signature algorithm name: SHA1withRSA + Version: 1 +Trust this certificate? [no]: yes +Certificate was added to keystore +``` + +**Step 5:** Create a `PKCS #12` format of the keystore file `(postgresql.p12)` using files `edb.crt` and `edb.key` as input. + +!!! Note + The file name `postgresql.p12` is recommended so that it can be accessed in its default directory location `~/.postgresql/postgresql.p12`, which is under the home directory of the user account invoking EDB\*Plus. + +**For Windows only:** The path is `%APPDATA%\.postgresql\postgresql.p12` + +You will be prompted for a new password. Save this password as it must be specified with the PGSSLKEYPASS environment variable. + +```text +$ openssl pkcs12 -export -in edb.crt -inkey edb.key -out postgresql.p12 +Enter Export Password: +Verifying - Enter Export Password: +$ ls –l +total 24 +-rw-rw-r-- 1 user user 985 Aug 24 12:18 edb.crt +-rw-rw-r-- 1 user user 1704 Aug 24 12:18 edb.key +-rw-rw-r-- 1 user user 985 Aug 24 12:20 edb_root.crt +-rw-rw-r-- 1 user user 686 Aug 24 12:20 edb_root.crt.der +-rw-rw-r-- 1 user user 758 Aug 24 12:26 postgresql.keystore +-rw-rw-r-- 1 user user 2285 Aug 24 12:28 postgresql.p12 +``` + +**Step 6:** If the `postgresql.keystore` and `postgresql.p12` files are not already in the `~/.postgresql` directory, move or copy them to that location. + +**For Windows only:** The directory is `%APPDATA%\.postgresql` + +**Step 7:** If the default location `~/.postgresql` is not used, then the full path (including the file name) to the `postgresql.keystore` file must be set with the `PGSSLCERT` environment variable, and the full path (including the file name) to file `postgresql.p12` must be set with the `PGSSLKEY` environment variable before invoking EDB\*Plus. + +In addition, if the generated file from Step 4 was not named `postgresql.keystore` or `postgresql.jks` then, use the `PGSSLCERT` environment variable to designate the file name and its location. Similarly, if the generated file from Step 5 was not named `postgresql.p12` then, use the `PGSSLKEY` environment variable to designate the file name and its location. + +## Requesting an SSL Connection between EDB\*Plus and the Advanced Server Database + +Be sure the following topics have been addressed in order to perform an SSL connection: + +- The trusted certificate and keystore files have been generated for both the database server and the client host to be invoking EDB\*Plus. +- The `postgresql.conf` file for the database server contains the updated configuration parameters. +- The `pg_hba.conf` file for the database server contains the required entry for permitting the SSL connection. +- For the client host, either the client’s certificate and keystore files have been placed in the user account’s `~/.postgresql` directory or the environment variables `PGSSLCERT` and `PGSSLKEY` are set before invoking EDB\*Plus. +- The `PGSSLCERTPASS` environment variable is set with a password. +- The `PGSSLKEYPASS` environment variable is set with a password + +When invoking EDB\*Plus, include the `?ssl=true` parameter in the database connection string as shown for the `connectstring` option in [Using EDB\*Plus](04_using_edb_plus/#using_edb_plus). + +The following is an example where EDB\*Plus is invoked from a host that is remote to the database server. + +The `postgresql.conf` file of the database server contains the following modified parameters: + +```text +ssl = on +ssl_cert_file = 'server.crt' +ssl_key_file = 'server.key' +ssl_ca_file = 'root.crt' +``` + +The `pg_hba.conf` file of the database server contains the following entry for connecting from EDB\*Plus on the remote host: + +```text +# TYPE DATABASE USER ADDRESS METHOD + +# "local" is for Unix domain socket connections only +local all all md5 +# IPv4 local connections: +hostssl edb all 192.168.2.24/32 cert clientcert=1 +``` + +On the remote host where EDB\*Plus is to be invoked, the Linux user account named `user` contains the certificate and keystore files in its `~/.postgresql` directory: + +```text +[user@localhost ~]$ whoami +user +[user@localhost ~]$ cd .postgresql +[user@localhost .postgresql]$ pwd +/home/user/.postgresql +[user@localhost .postgresql]$ ls -l +total 8 +-rw-rw-r-- 1 user user 758 Aug 24 12:37 postgresql.keystore +-rw-rw-r-- 1 user user 2285 Aug 24 12:37 postgresql.p12 +``` + +Logged into Linux with the account named `user`, EDB\*Plus is successfully invoked with the `ssl=true` parameter: + +```text +$ export PGSSLCERTPASS=keypass +$ export PGSSLKEYPASS=exppass +$ cd /opt/edb/as12/edbplus +$ ./edbplus.sh enterprisedb/password@192.168.2.22:5444/edb?ssl=true +Connected to EnterpriseDB 12.0.1 (192.168.2.22:5444/edb) AS enterprisedb + +EDB*Plus: Release 12 (Build 38.0.0) +Copyright (c) 2008-2021, EnterpriseDB Corporation. All rights reserved. + +SQL> +``` + +Alternatively, without placing the certificate and keystore files in `~/.postgresql`, but in a different directory, EDB\*Plus can be invoked in the following manner: + +```text +$ export PGSSLCERT=/home/user/ssl/postgresql.keystore +$ export PGSSLKEY=/home/user/ssl/postgresql.p12 +$ export PGSSLCERTPASS=keypass +$ export PGSSLKEYPASS=exppass +$ cd /opt/edb/as12/edbplus +$ ./edbplus.sh enterprisedb/password@192.168.2.22:5444/edb?ssl=true +Connected to EnterpriseDB 12.0.1 (192.168.2.22:5444/edb) AS enterprisedb + +EDB*Plus: Release 12 (Build 38.0.0) +Copyright (c) 2008-2021, EnterpriseDB Corporation. All rights reserved. + +SQL> +``` + +Note that in both cases the database user name used to log into EDB\*Plus is `enterprisedb` as this is the user specified for the common name field when creating the certificate in Step 1 of [Configuring SSL on Advanced Server](#using_ssl_connection). + +Other database user names can be used if the `pg_hba.conf` file with the `map` option and the `pg_ident.conf` file are used as described in Steps 8 and 9 of [Configuring SSL on Advanced Server](#using_ssl_connection). diff --git a/product_docs/docs/epas/12/edb_plus/06_command_summary.mdx b/product_docs/docs/epas/12/edb_plus/06_command_summary.mdx new file mode 100644 index 00000000000..b27b366f2f2 --- /dev/null +++ b/product_docs/docs/epas/12/edb_plus/06_command_summary.mdx @@ -0,0 +1,994 @@ +--- +title: "Command Summary" +legacyRedirects: + - "/edb-docs/d/edbplus/user-guides/edbplus-users-guide/39/command_summary.html" +--- + + + +The following sections contains a summary of EDB\*Plus commands. + +## ACCEPT + +The `ACCEPT` command displays a prompt and waits for the user’s keyboard input. The value input by the user is placed in the specified variable. + +```text +ACC[EPT ] variable +``` + +The following example creates a new variable named `my_name`, accepts a value of John Smith, then displays the value using the `DEFINE` command. + +```text +SQL> ACCEPT my_name +Enter value for my_name: John Smith +SQL> DEFINE my_name +DEFINE MY_NAME = "John Smith" +``` + +## APPEND + +`APPEND` is a line editor command that appends the given text to the end of the current line in the SQL buffer. + +```text +A[PPEND ] text +``` + +In the following example, a `SELECT` command is built-in the SQL buffer using the `APPEND` command. Note that two spaces are placed between the `APPEND` command and the `WHERE` clause in order to separate `dept` and `WHERE` by one space in the SQL buffer. + +```text +SQL> APPEND SELECT * FROM dept +SQL> LIST + 1 SELECT * FROM dept +SQL> APPEND WHERE deptno = 10 +SQL> LIST + 1 SELECT * FROM dept WHERE deptno = 10 +``` + +## CHANGE + +`CHANGE` is a line editor command performs a search-and-replace on the current line in the SQL buffer. + +```text +C[HANGE ] /from/[to/ ] +``` + +If `to/` is specified, the first occurrence of text `from` in the current line is changed to text `to`. If `to/` is omitted, the first occurrence of text `from` in the current line is deleted. + +The following sequence of commands makes line 3 the current line, then changes the department number in the `WHERE` clause from 20 to 30. + +```text +SQL> LIST + 1 SELECT empno, ename, job, sal, comm + 2 FROM emp + 3 WHERE deptno = 20 + 4* ORDER BY empno +SQL> 3 + 3* WHERE deptno = 20 +SQL> CHANGE /20/30/ + 3* WHERE deptno = 30 +SQL> LIST + 1 SELECT empno, ename, job, sal, comm + 2 FROM emp + 3 WHERE deptno = 30 + 4* ORDER BY empno +``` + +## CLEAR + +The `CLEAR` command removes the contents of the SQL buffer, deletes all column definitions set with the `COLUMN` command, or clears the screen. + +```text +CL[EAR ] [ BUFF[ER ] | SQL | COL[UMNS ] | SCR[EEN ] ] +``` + +`BUFFER | SQL` + + Clears the SQL buffer. + +`COLUMNS` + + Removes column definitions. + +`SCREEN` + + Clears the screen. This is the default if no options are specified. + +## COLUMN + +The `COLUMN` command controls output formatting. The formatting attributes set by using the `COLUMN` command remain in effect only for the duration of the current session. + +```text +COL[UMN ] + [ column + { CLE[AR ] | + { FOR[MAT ] spec | + HEA[DING ] text | + { OFF | ON } + } [...] + } + ] +``` + +If the `COLUMN` command is specified with no subsequent options, formatting options for current columns in effect for the session are displayed. + +If the `COLUMN` command is followed by a column name, then the column name may be followed by one of the following: + +1. No other options +2. `CLEAR` +3. Any combination of `FORMAT`, `HEADING`, and one of `OFF` or `ON` + +`column` + + Name of a column in a table to which subsequent column formatting options are to apply. If no other options follow `column`, then the current column formatting options if any, of `column` are displayed. + +`CLEAR` + + The `CLEAR` option reverts all formatting options back to their defaults for `column`. If the `CLEAR` option is specified, it must be the only option specified. + +`spec` + + Format specification to be applied to `column`. For character columns, `spec` takes the following format: + +`n` + + `n` is a positive integer that specifies the column width in characters within which to display the data. Data in excess of `n` will wrap around with the specified column width. + + For numeric columns, `spec` is comprised of the following elements. + +| Element | Description | +| ------- | ------------------------------------------ | +| `$` | Display a leading dollar sign. | +| `,` | Display a comma in the indicated position. | +| `.` | Marks the location of the decimal point. | +| `0` | Display leading zeros. | +| `9` | Number of significant digits to display. | + + If loss of significant digits occurs due to overflow of the format, then all #’s are displayed. + +`text` + + Text to be used for the column heading of `column`. + +`OFF | ON` + + If `OFF` is specified, formatting options are reverted back to their defaults, but are still available within the session. If `ON` is specified, the formatting options specified by previous `COLUMN` commands for `column` within the session are re-activated. + +The following example shows the effect of changing the display width of the `job` column. + +```text +SQL> SET PAGESIZE 9999 +SQL> COLUMN job FORMAT A5 +SQL> COLUMN job +COLUMN JOB ON +FORMAT A5 +wrapped +SQL> SELECT empno, ename, job FROM emp; + +EMPNO ENAME JOB +----- ---------- ----- + 7369 SMITH CLERK + 7499 ALLEN SALES + MAN + + 7521 WARD SALES + MAN + + 7566 JONES MANAG + ER + + 7654 MARTIN SALES + MAN + + 7698 BLAKE MANAG + ER + + 7782 CLARK MANAG + ER + + 7788 SCOTT ANALY + ST + + 7839 KING PRESI + DENT + + 7844 TURNER SALES + MAN + + 7876 ADAMS CLERK + 7900 JAMES CLERK + 7902 FORD ANALY + ST + + 7934 MILLER CLERK + +14 rows retrieved. +``` + +The following example applies a format to the `sal` column. + +```text +SQL> COLUMN sal FORMAT $99,999.00 +SQL> COLUMN +COLUMN JOB ON +FORMAT A5 +wrapped + +COLUMN SAL ON +FORMAT $99,999.00 +wrapped +SQL> SELECT empno, ename, job, sal FROM emp; + +EMPNO ENAME JOB SAL +----- ---------- ----- ----------- + 7369 SMITH CLERK $800.00 + 7499 ALLEN SALES $1,600.00 + MAN + + 7521 WARD SALES $1,250.00 + MAN + + 7566 JONES MANAG $2,975.00 + ER + + 7654 MARTIN SALES $1,250.00 + MAN + + 7698 BLAKE MANAG $2,850.00 + ER + + 7782 CLARK MANAG $2,450.00 + ER + + 7788 SCOTT ANALY $3,000.00 + ST + + 7839 KING PRESI $5,000.00 + DENT + + 7844 TURNER SALES $1,500.00 + MAN + + 7876 ADAMS CLERK $1,100.00 + 7900 JAMES CLERK $950.00 + 7902 FORD ANALY $3,000.00 + ST + + 7934 MILLER CLERK $1,300.00 + +14 rows retrieved. +``` + +## CONNECT + +Change the database connection to a different user and/or connect to a different database. There must be no white space between any of the parameters following the `CONNECT` command. + +```text +CON[NECT] [/][@{ | } ] +``` + +Where: + + `username` is a database username with which to connect to the database. + + `password` is the password associated with the specified `username`. If a `password` is not provided, but a password is required for authentication, a search is made for a password file, first in the home directory of the Linux operating system account invoking EDB\*Plus (or in the `%APPDATA%\postgresql\` directory for Windows) and then at the location specified by the `PGPASSFILE` environment variable. The password file is `.pgpass` on Linux hosts and `pgpass.conf` on Windows hosts. The following is an example on a Windows host: + +```text +C:\Users\Administrator\AppData\Roaming\postgresql\pgpass.conf +``` + + If a password file cannot be located, or it does not have an entry matching the EDB\*Plus connection parameters, then EDB\*Plus will prompt for the password. For more information about password files, see the PostgreSQL core documentation at: + + + + **Note**: When a password is not required, EDB\*Plus does not prompt for a password such as when the `trust` authentication method is specified in the `pg_hba.conf` file. For more information about the `pg_hba.conf` file and authentication methods, see the PostgreSQL core documentation at + + `connectstring` is the database connection string. See [Using EDB\*Plus](04_using_edb_plus/#using_edb_plus) for further information on the database connection string. + + `variable` is a variable defined in the `login.sql` file that contains a database connection string. The `login.sql` file can be found in the `edbplus` subdirectory of the Advanced Server home directory. + +In the following example, the database connection is changed to database `edb` on the localhost at port `5445` with username `smith`. + +```text +SQL> CONNECT smith/mypassword@localhost:5445/edb +Disconnected from EnterpriseDB Database. +Connected to EnterpriseDB 12.0.1 (localhost:5445/edb) AS smith +``` + +From within the session shown above, the connection is changed to username `enterprisedb`. Also note that the host defaults to the localhost, the port defaults to `5444` (which is not the same as the port previously used), and the database defaults to `edb`. + +```text +SQL> CONNECT enterprisedb/password +Disconnected from EnterpriseDB Database. +Connected to EnterpriseDB 12.0.1 (localhost:5444/edb) AS enterprisedb +``` + +## DEFINE + +The `DEFINE` command creates or replaces the value of a *user variable* (also called a *substitution variable*). + +```text +DEF[INE ] [ variable [ = text ] ] +``` + +If the `DEFINE` command is given without any parameters, all current variables and their values are displayed. + +If `DEFINE variable` is given, only `variable` is displayed with its value. + +`DEFINE variable = text` assigns `text` to `variable.text` may be optionally enclosed within single or double quotation marks. Quotation marks must be used if `text` contains space characters. + +The following example defines two variables, `dept` and `name`. + +```text +SQL> DEFINE dept = 20 +SQL> DEFINE name = 'John Smith' +SQL> DEFINE +DEFINE EDB = "localhost:5445/edb" +DEFINE DEPT = "20" +DEFINE NAME = "John Smith" +``` + +!!! Note + The variable `EDB` is read from the `login.sql` file located in the `edbplus` subdirectory of the Advanced Server home directory. + +## DEL + +`DEL` is a line editor command that deletes one or more lines from the SQL buffer. + +```text +DEL [ n | n m | n * | n L[AST ] | * | * n | * L[AST ] | L[AST ] ] +``` + +The parameters specify which lines are to be deleted from the SQL buffer. Two parameters specify the start and end of a range of lines to be deleted. If the `DEL` command is given with no parameters, the current line is deleted. + +`n` + + n is an integer representing the `n`th line + +`n m` + + `n` and `m` are integers where `m` is greater than `n` representing the `n`th through the `m`th lines + +`*` + + Current line + +`LAST` + + Last line + +In the following example, the fifth and sixth lines containing columns `sal` and `comm`, respectively, are deleted from the `SELECT` command in the SQL buffer. + +```text +SQL> LIST + 1 SELECT + 2 empno + 3 ,ename + 4 ,job + 5 ,sal + 6 ,comm + 7 ,deptno + 8* FROM emp +SQL> DEL 5 6 +SQL> LIST + 1 SELECT + 2 empno + 3 ,ename + 4 ,job + 5 ,deptno + 6* FROM emp +``` + +## DESCRIBE + +The `DESCRIBE` command displays: + +- A list of columns, column data types, and column lengths for a table or view +- A list of parameters for a procedure or function +- A list of procedures and functions and their respective parameters for a package + +The `DESCRIBE` command will also display the structure of the database object referred to by a synonym. The syntax is: + +```text +DESC[RIBE] [ schema.]object +``` + +`schema` + + Name of the schema containing the object to be described. + +`object` + + Name of the table, view, procedure, function, or package to be displayed, or the synonym of an object. + +## DISCONNECT + +The `DISCONNECT` command closes the current database connection, but does not terminate EDB\*Plus. + +```text +DISC[ONNECT ] +``` + +## EDIT + +The `EDIT` command invokes an external editor to edit the contents of an operating system file or the SQL buffer. + +```text +ED[IT ] [ filename[.ext ] ] +``` + +`filename[.ext ]` + + `filename` is the name of the file to open with an external editor. `ext` is the filename extension. If the filename extension is `sql`, then the `.sql` extension may be omitted when specifying `filename`. `EDIT` always assumes a `.sql` extension on filenames that are specified with no extension. If the filename parameter is omitted from the `EDIT` command, the contents of the SQL buffer are brought into the editor. + +## EXECUTE + +The `EXECUTE` command executes an SPL procedure from EDB\*Plus. + +```text +EXEC[UTE ] spl_procedure [ ([ parameters ]) ] +``` + +`spl_procedure` + + The name of the SPL procedure to be executed. + +`parameters` + + Comma-delimited list of parameters. If there are no parameters, then a pair of empty parentheses may optionally be specified. + +## EXIT + +The `EXIT` command terminates the EDB\*Plus session and returns control to the operating system. `QUIT` is a synonym for `EXIT`. Specifying no parameters is equivalent to `EXIT SUCCESS COMMIT`. + +```text +{ EXIT | QUIT } +[ SUCCESS | FAILURE | WARNING | value | variable ] +[ COMMIT | ROLLBACK ]SUCCESS | FAILURE |WARNING] +``` + +Returns an operating system dependent return code indicating successful operation, failure, or warning for `SUCCESS, FAILURE`, and `WARNING`, respectively. The default is `SUCCESS`. + +`value` + + An integer value that is returned as the return code. + +`variable` + + A variable created with the `DEFINE` command whose value is returned as the return code. + +`COMMIT | ROLLBACK` + + If `COMMIT` is specified, uncommitted updates are committed upon exit. If `ROLLBACK` is specified, uncommitted updates are rolled back upon exit. The default is `COMMIT`. + +## GET + +The `GET` command loads the contents of the given file to the SQL buffer. + +```text +GET filename[.ext ] [ LIS[T ] | NOL[IST ] ] +``` + +`filename[.ext ]` + + `filename` is the name of the file to load into the SQL buffer. `ext` is the filename extension. If the filename extension is `sql`, then the `.sql` extension may be omitted when specifying `filename`. `GET` always assumes a `.sql` extension on filenames that are specified with no extension. + +`LIST | NOLIST` + + If `LIST` is specified, the content of the SQL buffer is displayed after the file is loaded. If `NOLIST` is specified, no listing is displayed. The default is `LIST`. + +## HELP + +The `HELP` command obtains an index of topics or help on a specific topic. The question mark `(?)` is synonymous with specifying `HELP`. + +```text +{ HELP | ? } { INDEX | topic } +``` + +`INDEX` + + Displays an index of available topics. + +`topic` + + The name of a specific topic – e.g., an EDB\*Plus command, for which help is desired. + +## HOST + +The `HOST` command executes an operating system command from EDB\*Plus. + +```text +HO[ST ] [os_command] +``` + +`os_command` + + The operating system command to be executed. If you do not provide an operating system command, EDB\*Plus pauses execution and opens a new shell prompt. When the shell exits, EDB\*Plus resumes execution. + +## INPUT + +The `INPUT` line editor command adds a line of text to the SQL buffer after the current line. + +```text +I[NPUT ] text +``` + +The following sequence of `INPUT` commands constructs a `SELECT` command. + +```text +SQL> INPUT SELECT empno, ename, job, sal, comm +SQL> INPUT FROM emp +SQL> INPUT WHERE deptno = 20 +SQL> INPUT ORDER BY empno +SQL> LIST + 1 SELECT empno, ename, job, sal, comm + 2 FROM emp + 3 WHERE deptno = 20 + 4* ORDER BY empno +``` + +## LIST + +`LIST` is a line editor command that displays the contents of the SQL buffer. + +```text +L[IST] [ n | n m | n * | n L[AST] | * | * n | * L[AST] | L[AST] ] +``` + +The buffer does not include a history of the EDB\*Plus commands. + +`n` + + `n` represents the buffer line number. + +`n m` + + `n m` displays a list of lines between `n` and `m`. + +`n *` + + `n *` displays a list of lines that range between line `n` and the current line. + +`n L[AST]` + + `n L[AST]` displays a list of lines that range from line `n` through the last line in the buffer. + +`*` + + `*` displays the current line. + +`* n` + + `* n` displays a list of lines that range from the current line through line `n`. + +`* L[AST]` + + `* L[AST]` displays a list of lines that range from the current line through the last line. + +`L[AST]` + + `L[AST]` displays the last line. + +## PASSWORD + +Use the `PASSWORD` command to change your database password. + +```text +PASSW[ORD] [user_name] +``` + +You must have sufficient privileges to use the `PASSWORD` command to change another user's password. The following example demonstrates using the `PASSWORD` command to change the password for a user named `acctg`: + +```text +SQL> PASSWORD acctg +Changing password for acctg + New password: + New password again: +Password successfully changed. +``` + +## PAUSE + +The `PAUSE` command displays a message, and waits for the user to press `ENTER`. + +```text +PAU[SE] [optional_text] +``` + +`optional_text` specifies the text that will be displayed to the user. If the `optional_text` is omitted, Advanced Server will display two blank lines. If you double quote the `optional_text` string, the quotes will be included in the output. + +## PROMPT + +The `PROMPT` command displays a message to the user before continuing. + +```text +PRO[MPT] [message_text] +``` + +`message_text` specifies the text displayed to the user. Double quote the string to include quotes in the output. + +## QUIT + +The `QUIT` command terminates the session and returns control to the operating system. `QUIT` is a synonym for `EXIT`. + +```text +QUIT + +[SUCCESS | FAILURE | WARNING | value | sub_variable] + +[COMMIT | ROLLBACK] +``` + +The default value is `QUIT SUCCESS COMMIT`. + +## REMARK + +Use `REMARK` to include comments in a script. + +```text +REM[ARK] [optional_text] +``` + +You may also use the following convention to include a comment: + +```text +/* + * This is an example of a three line comment. + */ +``` + +## SAVE + +Use the `SAVE` command to write the SQL Buffer to an operating system file. + +```text +SAV[E] file_name +[CRE[ATE] | REP[LACE] | APP[END]] +``` + +`file_name` + + `file_name` specifies the name of the file (including the path) where the buffer contents are written. If you do not provide a file extension, `.sql` is appended to the end of the file name. + +`CREATE` + + Include the `CREATE` keyword to create a new file. A new file is created *only* if a file with the specified name does not already exist. This is the default. + +`REPLACE` + + Include the `REPLACE` keyword to specify that Advanced Server should overwrite an existing file. + +`APPEND` + + Include the `APPEND` keyword to specify that Advanced Server should append the contents of the SQL buffer to the end of the specified file. + +The following example saves the contents of the SQL buffer to a file named `example.sql`, located in the `temp` directory: + +```text +SQL> SAVE C:\example.sql CREATE +File "example.sql" written. +``` + +## SET + +Use the `SET` command to specify a value for a session level variable that controls EDB\*Plus behavior. The following forms of the `SET` command are valid: + +**SET AUTOCOMMIT** + +Use the `SET AUTOCOMMIT` command to specify commit behavior for Advanced Server transactions. + +```text +SET AUTO[COMMIT] + +{ON | OFF | IMMEDIATE | statement_count} +``` + +Please note that EDB\*Plus always automatically commits DDL statements. + +`ON` + + Specify `ON` to turn `AUTOCOMMIT` behavior on. + +`OFF` + + Specify `OFF` to turn `AUTOCOMMIT` behavior off. + +`IMMEDIATE` + + `IMMEDIATE` has the same effect as `ON`. + +`statement_count` + + Include a value for `statement_count` to instruct EDB\*Plus to issue a commit after the specified count of successful SQL statements. + +**SET COLUMN SEPARATOR** + +Use the `SET COLUMN SEPARATOR` command to specify the text that Advanced Server displays between columns. + +```text +SET COLSEP column_separator +``` + +The default value of `column_separator` is a single space. + +**SET ECHO** + +Use the `SET ECHO` command to specify if SQL and EDB\*Plus script statements should be displayed onscreen as they are executed. + +```text +SET ECHO {ON | OFF} +``` + +The default value is `OFF`. + +**SET FEEDBACK** + +The `SET FEEDBACK` command controls the display of interactive information after a SQL statement executes. + +```text +SET FEED[BACK] {ON | OFF | row_threshold} +``` + +`row_threshold` + + Specify an integer value for `row_threshold`. Setting `row_threshold` to `0` is same as setting `FEEDBACK` to `OFF`. Setting `row_threshold` equal `1` effectively sets `FEEDBACK` to `ON`. + +**SET FLUSH** + +Use the `SET FLUSH` command to control display buffering. + +```text +SET FLU[SH] {ON | OFF} +``` + +Set `FLUSH` to `OFF` to enable display buffering. If you enable buffering, messages bound for the screen may not appear until the script completes. Please note that setting `FLUSH` to `OFF` will offer better performance. + +Set `FLUSH` to `ON` to disable display buffering. If you disable buffering, messages bound for the screen appear immediately. + +**SET HEADING** + +Use the `SET HEADING` variable to specify if Advanced Server should display column headings for `SELECT` statements. + +```text +SET HEA[DING] {ON | OFF} +``` + +**SET HEAD SEPARATOR** + +The `SET HEADSEP` command sets the new heading separator character used by the `COLUMN HEADING` command. The default is `'|'`. + +```text +SET HEADS[EP] +``` + +**SET LINESIZE** + +Use the `SET LINESIZE` command to specify the width of a line in characters. + +```text +SET LIN[ESIZE] width_of_line +``` + +`width_of_line` + + The default value of `width_of_line` is `132`. + +**SET NEWPAGE** + +Use the `SET NEWPAGE` command to specify how many blank lines are printed after a page break. + +```text +SET NEWP[AGE] lines_per_page +``` + +`lines_per_page` + + The default value of `lines_per_page` is `1`. + +**SET NULL** + +Use the `SET NULL` command to specify a string that is displayed to the user when a `NULL` column value is displayed in the output buffer. + +```text +SET NULL null_string +``` + +**SET PAGESIZE** + +Use the `SET PAGESIZE` command to specify the number of printed lines that fit on a page. + +```text +SET PAGES[IZE] line_count +``` + +Use the `line_count` parameter to specify the number of lines per page. + +**SET SQLCASE** + +The `SET SQLCASE` command specifies if SQL statements transmitted to the server should be converted to upper or lower case. + +```text +SET SQLC[ASE] {MIX[ED] | UP[PER] | LO[WER]} +``` + +`UPPER` + + Specify `UPPER` to convert the command text to uppercase. + +`LOWER` + + Specify `LOWER` to convert the command text to lowercase. + +`MIXED` + + Specify `MIXED` to leave the case of SQL commands unchanged. The default is `MIXED`. + +**SET PAUSE** + +The `SET PAUSE` command is most useful when included in a script; the command displays a prompt and waits for the user to press `Return`. + +```text +SET PAU[SE] {ON | OFF} +``` + +If `SET PAUSE` is `ON`, the message `Hit ENTER to continue…` will be displayed before each command is executed. + +**SET SPACE** + +Use the `SET SPACE` command to specify the number of spaces to display between columns: + +```text +SET SPACE number_of_spaces +``` + +**SET SQLPROMPT** + +Use `SET SQLPROMPT` to set a value for a user-interactive prompt: + +```text +SET SQLP[ROMPT] "prompt" +``` + +By default, `SQLPROMPT` is set to `"SQL> "` + +**SET TERMOUT** + +Use the `SET TERMOUT` command to specify if command output should be displayed onscreen. + +```text +SET TERM[OUT] {ON | OFF} +``` + +**SET TIMING** + +The `SET TIMING` command specifies if Advanced Server should display the execution time for each SQL statement after it is executed. + +```text +SET TIMI[NG] {ON | OFF} +``` + +**SET TRIMSPOOL** + +Use the `SET TRIMSPOOL` command to remove trailing spaces from each line in the output file specified by the `SPOOL` command. + +```text +SET TRIMS[POOL] {ON | OFF} +``` + +The default value is `OFF`. + +**SET VERIFY** + +Specifies if both the old and new values of a SQL statement are displayed when a substitution variable is encountered. + +```text +SET VER[IFY] { ON | OFF } +``` + +## SHOW + +Use the `SHOW` command to display current parameter values. + +```text +SHO[W] {ALL | parameter_name} +``` + +Display the current parameter settings by including the `ALL` keyword: + +```Text +SQL> SHOW ALL +autocommit OFF +colsep " " +define "&" +echo OFF +FEEDBACK ON for 6 row(s). +flush ON +heading ON +headsep "|" +linesize 78 +newpage 1 +null " " +pagesize 14 +pause OFF +serveroutput OFF +spool OFF +sqlcase MIXED +sqlprompt "SQL> " +sqlterminator ";" +suffix ".sql" +termout ON +timing OFF +verify ON +USER is "enterprisedb" +HOST is "localhost" +PORT is "5444" +DATABASE is "edb" +VERSION is "12.0.0" +``` + +Or display a specific parameter setting by including the `parameter_name` in the `SHOW` command: + +```text +SQL> SHOW VERSION +VERSION is "12.0.0" +``` + +## SPOOL + +The `SPOOL` command sends output from the display to a file. + +```text +SP[OOL] output_file | OFF +``` + +Use the `output_file` parameter to specify a path name for the output file. + +## START + +Use the `START` command to run an EDB\*Plus script file; `START` is an alias for `@` command. + +```text +STA[RT] script_file +``` + +Specify the name of a script file in the `script_file` parameter. + +## UNDEFINE + +The `UNDEFINE` command erases a user variable created by the `DEFINE` command. + +```text +UNDEF[INE] variable_name [ variable_name...] +``` + +Use the `variable_name` parameter to specify the name of a variable or variables. + +## WHENEVER SQLERROR + +The `WHENEVER SQLERROR` command provides error handling for SQL errors or PL/SQL block errors. The syntax is: + +```text +WHENEVER SQLERROR + {CONTINUE[COMMIT|ROLLBACK|NONE] + |EXIT[SUCCESS|FAILURE|WARNING|n|sub_variable] + [COMMIT|ROLLBACK]} +``` + +If Advanced Server encounters an error during the execution of a SQL command or PL/SQL block, EDB\*Plus performs the action specified in the `WHENEVER SQLERROR` command: + + Include the `CONTINUE` clause to instruct EDB\*Plus to perform the specified action before continuing. + + Include the `COMMIT` clause to instruct EDB\*Plus to `COMMIT` the current transaction before exiting or continuing. + + Include the `ROLLBACK` clause to instruct EDB\*Plus to `ROLLBACK` the current transaction before exiting or continuing. + + Include the `NONE` clause to instruct EDB\*Plus to continue without committing or rolling back the transaction. + + Include the `EXIT` clause to instruct EDB\*Plus to perform the specified action and exit if it encounters an error. + + Use the following options to specify a status code that EDB\*Plus will return before exiting: + +```text +[SUCCESS|FAILURE|WARNING|n|sub_variable] +``` + + Please note that EDB\*Plus supports substitution variables, but does not support bind variables. diff --git a/product_docs/docs/epas/12/edb_plus/images/advanced_server_installation_details.png b/product_docs/docs/epas/12/edb_plus/images/advanced_server_installation_details.png new file mode 100755 index 00000000000..37186541890 Binary files /dev/null and b/product_docs/docs/epas/12/edb_plus/images/advanced_server_installation_details.png differ diff --git a/product_docs/docs/epas/12/edb_plus/images/edb_logo.png b/product_docs/docs/epas/12/edb_plus/images/edb_logo.png new file mode 100644 index 00000000000..39a54822d85 Binary files /dev/null and b/product_docs/docs/epas/12/edb_plus/images/edb_logo.png differ diff --git a/product_docs/docs/epas/12/edb_plus/images/edb_logo.svg b/product_docs/docs/epas/12/edb_plus/images/edb_logo.svg new file mode 100644 index 00000000000..f24d1dfefee --- /dev/null +++ b/product_docs/docs/epas/12/edb_plus/images/edb_logo.svg @@ -0,0 +1,19 @@ + + + edb-logo-disc-dark + + + + \ No newline at end of file diff --git a/product_docs/docs/epas/12/edb_plus/images/edb_plus_welcome.png b/product_docs/docs/epas/12/edb_plus/images/edb_plus_welcome.png new file mode 100755 index 00000000000..11a788283cd Binary files /dev/null and b/product_docs/docs/epas/12/edb_plus/images/edb_plus_welcome.png differ diff --git a/product_docs/docs/epas/12/edb_plus/images/edb_plus_welcome_1.png b/product_docs/docs/epas/12/edb_plus/images/edb_plus_welcome_1.png new file mode 100755 index 00000000000..d2d142fcafb Binary files /dev/null and b/product_docs/docs/epas/12/edb_plus/images/edb_plus_welcome_1.png differ diff --git a/product_docs/docs/epas/12/edb_plus/images/installation_complete.png b/product_docs/docs/epas/12/edb_plus/images/installation_complete.png new file mode 100755 index 00000000000..1cc77277ecf Binary files /dev/null and b/product_docs/docs/epas/12/edb_plus/images/installation_complete.png differ diff --git a/product_docs/docs/epas/12/edb_plus/images/installation_directory.png b/product_docs/docs/epas/12/edb_plus/images/installation_directory.png new file mode 100755 index 00000000000..0ef60e60ef8 Binary files /dev/null and b/product_docs/docs/epas/12/edb_plus/images/installation_directory.png differ diff --git a/product_docs/docs/epas/12/edb_plus/images/ready_to_install.png b/product_docs/docs/epas/12/edb_plus/images/ready_to_install.png new file mode 100755 index 00000000000..5f6ec9c0e83 Binary files /dev/null and b/product_docs/docs/epas/12/edb_plus/images/ready_to_install.png differ diff --git a/product_docs/docs/epas/12/edb_plus/index.mdx b/product_docs/docs/epas/12/edb_plus/index.mdx new file mode 100644 index 00000000000..6014dc9d4cc --- /dev/null +++ b/product_docs/docs/epas/12/edb_plus/index.mdx @@ -0,0 +1,31 @@ +--- +navTitle: EDB*Plus — CLI +title: "EDB*Plus User's Guide" + +#legacyRedirects: + #- "/edb-docs/p/edbplus/39" + #- "/edb-docs/d/edbplus/user-guides/edbplus-users-guide/39/introduction.html" + #- "/edb-docs/d/edbplus/user-guides/edbplus-users-guide/39/conclusion.html" + +directoryDefaults: + description: "EDB*Plus Documentation and release notes." +--- + +This guide describes how to connect to an Advanced Server database using EDB\*Plus. EDB\*Plus provides a command line user interface to EDB Postgres Advanced Server that accepts SQL commands that allow you to: + +- Query certain database objects +- Execute stored procedures +- Format output from SQL commands +- Execute batch scripts +- Execute OS commands +- Record output + +For detailed information about the features supported by Advanced Server, consult the complete library of Advanced Server guides available at: + +[https://www.enterprisedb.com/docs](/epas/latest/) + +
+ +introduction edb_plus installing_edb_plus using_edb_plus using_edb_plus_with_ssl command_summary conclusion + +
diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/02_packages/01_package_components.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/02_packages/01_package_components.mdx new file mode 100644 index 00000000000..c9121f99266 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/02_packages/01_package_components.mdx @@ -0,0 +1,380 @@ +--- +title: "Package Components" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/package_components.html" +--- + +Packages consist of two main components: + +- The *package specification*: This is the public interface, (these are the elements which can be referenced outside the package). We declare all database objects that are to be a part of our package within the specification. +- The *package body*: This contains the actual implementation of all the database objects declared within the package specification. + +The package body implements the specifications in the package specification. It contains implementation details and private declarations which are invisible to the application. You can debug, enhance or replace a package body without changing the specifications. Similarly, you can change the body without recompiling the calling programs because the implementation details are invisible to the application. + +## Package Specification Syntax + +The package specification defines the user interface for a package (the API). The specification lists the functions, procedures, types, exceptions and cursors that are visible to a user of the package. + +The syntax used to define the interface for a package is: + +```text +CREATE [ OR REPLACE ] PACKAGE + [ ] + { IS | AS } + [ ; ] ... + [ ] ... +END [ ] ; +``` + +Where `authorization_clause` := + +```text +{ AUTHID DEFINER } | { AUTHID CURRENT_USER } +``` + +Where `procedure_or_function_declaration` := + +```text +procedure_declaration | function_declaration +``` + +Where `procedure_declaration` := + +```text +PROCEDURE proc_name [ argument_list ]; +[ restriction_pragma; ] +``` + +Where `function_declaration` := + +```text +FUNCTION func_name [ argument_list ] + RETURN rettype [ DETERMINISTIC ]; +[ restriction_pragma; ] +``` + +Where `argument_list` := + +```text +( argument_declaration [, ...] ) +``` + +Where `argument_declaration` := + +```text +argname [ IN | IN OUT | OUT ] argtype [ DEFAULT value ] +``` + +Where `restriction_pragma` := + +```text +PRAGMA RESTRICT_REFERENCES(name, restrictions) +``` + +Where `restrictions` := + +```text +restriction [, ... ] +``` + +**Parameters** + +`package_name` + + `package_name` is an identifier assigned to the package - each package must have a name unique within the schema. + +`AUTHID DEFINER` + + If you omit the `AUTHID` clause or specify `AUTHID DEFINER`, the privileges of the package owner are used to determine access privileges to database objects. + +`AUTHID CURRENT_USER` + + If you specify `AUTHID CURRENT_USER`, the privileges of the current user executing a program in the package are used to determine access privileges. + +`declaration` + + `declaration` is an identifier of a public variable. A public variable can be accessed from outside of the package using the syntax `package_name.variable`. There can be zero, one, or more public variables. Public variable definitions must come before procedure or function declarations. + + `declaration` can be any of the following: + +- Variable Declaration +- Record Declaration +- Collection Declaration +- `REF CURSOR` and Cursor Variable Declaration +- `TYPE` Definitions for Records, Collections, and `REF CURSORs` +- Exception +- Object Variable Declaration + +`proc_name` + + The name of a public procedure. + +`argname` + + The name of an argument. The argument is referenced by this name within the function or procedure body. + +`IN | IN OUT | OUT` + + The argument mode. `IN` declares the argument for input only. This is the default. `IN OUT` allows the argument to receive a value as well as return a value. `OUT` specifies the argument is for output only. + +`argtype` + + The data type(s) of an argument. An argument type may be a base data type, a copy of the type of an existing column using `%TYPE`, or a user-defined type such as a nested table or an object type. A length must not be specified for any base type - for example, specify `VARCHAR2`, not `VARCHAR2(10`). + + The type of a column is referenced by writing `tablename.columnname` `%TYPE`; using this can sometimes help make a procedure independent from changes to the definition of a table. + +`DEFAULT value` + + The `DEFAULT` clause supplies a default value for an input argument if one is not supplied in the invocation. `DEFAULT` may not be specified for arguments with modes `IN OUT` or `OUT`. + +`func_name` + + The name of a public function. + +`rettype` + + The return data type. + +`DETERMINISTIC` + + `DETERMINISTIC` is a synonym for `IMMUTABLE`. A `DETERMINISTIC` function cannot modify the database and always reaches the same result when given the same argument values; it does not do database lookups or otherwise use information not directly present in its argument list. If you include this clause, any call of the function with all-constant arguments can be immediately replaced with the function value. + +`restriction` + + The following keywords are accepted for compatibility and ignored: + + `RNDS` + + `RNPS` + + `TRUST` + + `WNDS` + + `WNPS` + +## Package Body Syntax + +Package implementation details reside in the package body; the package body may contain objects that are not visible to the package user. Advanced Server supports the following syntax for the package body: + +```text +CREATE [ OR REPLACE ] PACKAGE BODY + { IS | AS } + [ ; ] ... + [ ] ... + [ ] +END [ ] ; +``` + +Where `procedure_or_function_definition` := + +```text +procedure_definition | function_definition +``` + +Where `procedure_definition` := + +```text +PROCEDURE proc_name[ argument_list ] + [ options_list ] + { IS | AS } + procedure_body + END [ proc_name ] ; +``` + +Where `procedure_body` := + +```text +[ PRAGMA AUTONOMOUS_TRANSACTION; ] +[ declaration; ] [, ...] +BEGIN + statement; [...] +[ EXCEPTION + { WHEN exception [OR exception] [...]] THEN statement; } + [...] +] +``` + +Where `function_definition` := + +```text +FUNCTION func_name [ argument_list ] + RETURN rettype [ DETERMINISTIC ] + [ options_list ] + { IS | AS } + function_body + END [ func_name ] ; +``` + +Where `function_body` := + +```text +[ PRAGMA AUTONOMOUS_TRANSACTION; ] +[ declaration; ] [, ...] +BEGIN + statement; [...] +[ EXCEPTION + { WHEN exception [ OR exception ] [...] THEN statement; } + [...] +] +``` + +Where `argument_list` := + +```text +( argument_declaration [, ...] ) +``` + +Where `argument_declaration` := + +```text +argname [ IN | IN OUT | OUT ] argtype [ DEFAULT value ] +``` + +Where `options_list` := + +```text +option [ ... ] +``` + +Where `option` := + +```text +STRICT +LEAKPROOF +PARALLEL { UNSAFE | RESTRICTED | SAFE } +COST execution_cost +ROWS result_rows +SET config_param { TO value | = value | FROM CURRENT } +``` + +Where `package_initializer` := + +```text +BEGIN + statement; [...] +END; +``` + +**Parameters** + +`package_name` + + `package_name` is the name of the package for which this is the package body. There must be an existing package specification with this name. + +`private_declaration` + + `private_declaration` is an identifier of a private variable that can be accessed by any procedure or function within the package. There can be zero, one, or more private variables. `private_declaration` can be any of the following: + +- Variable Declaration +- Record Declaration +- Collection Declaration +- `REF CURSOR` and Cursor Variable Declaration +- `TYPE` Definitions for Records, Collections, and `REF CURSORs` +- Exception +- Object Variable Declaration + +`proc_name` + + The name of the procedure being created. + +`PRAGMA AUTONOMOUS_TRANSACTION` + + `PRAGMA AUTONOMOUS_TRANSACTION` is the directive that sets the procedure as an autonomous transaction. + +`declaration` + + A variable, type, `REF CURSOR`, or subprogram declaration. If subprogram declarations are included, they must be declared after all other variable, type, and `REF CURSOR` declarations. + +`statement` + + An SPL program statement. Note that a `DECLARE - BEGIN - END` block is considered an SPL statement unto itself. Thus, the function body may contain nested blocks. + +`exception` + + An exception condition name such as `NO_DATA_FOUND, OTHERS`, etc. + +`func_name` + + The name of the function being created. + +`rettype` + + The return data type, which may be any of the types listed for `argtype`. As for `argtype`, a length must not be specified for `rettype`. + +`DETERMINISTIC` + + Include `DETERMINISTIC` to specify that the function will always return the same result when given the same argument values. A `DETERMINISTIC` function must not modify the database. + + **Note**: The `DETERMINISTIC` keyword is equivalent to the PostgreSQL `IMMUTABLE` option. + + **Note**: If `DETERMINISTIC` is specified for a public function in the package body, it must also be specified for the function declaration in the package specification. (For private functions, there is no function declaration in the package specification.) + +`PRAGMA AUTONOMOUS_TRANSACTION` + + `PRAGMA AUTONOMOUS_TRANSACTION` is the directive that sets the function as an autonomous transaction. + +`argname` + + The name of a formal argument. The argument is referenced by this name within the procedure body. + +`IN | IN OUT | OUT` + + The argument mode. `IN` declares the argument for input only. This is the default. `IN OUT` allows the argument to receive a value as well as return a value. `OUT` specifies the argument is for output only. + +`argtype` + + The data type(s) of an argument. An argument type may be a base data type, a copy of the type of an existing column using `%TYPE`, or a user-defined type such as a nested table or an object type. A length must not be specified for any base type - for example, specify `VARCHAR2`, not `VARCHAR2(10)`. + + The type of a column is referenced by writing `tablename.columnname%TYPE`; using this can sometimes help make a procedure independent from changes to the definition of a table. + +`DEFAULT value` + + The `DEFAULT` clause supplies a default value for an input argument if one is not supplied in the procedure call. `DEFAULT` may not be specified for arguments with modes `IN OUT` or `OUT`. + + Please note: The following options are not compatible with Oracle databases; they are extensions to Oracle package syntax provided by Advanced Server only. + +`STRICT` + + The `STRICT` keyword specifies that the function will not be executed if called with a `NULL` argument; instead the function will return `NULL`. + +`LEAKPROOF` + + The `LEAKPROOF` keyword specifies that the function will not reveal any information about arguments, other than through a return value. + +`PARALLEL { UNSAFE | RESTRICTED | SAFE }` + + The `PARALLEL` clause enables the use of parallel sequential scans (parallel mode). A parallel sequential scan uses multiple workers to scan a relation in parallel during a query in contrast to a serial sequential scan. + + When set to `UNSAFE`, the procedure or function cannot be executed in parallel mode. The presence of such a procedure or function forces a serial execution plan. This is the default setting if the `PARALLEL` clause is omitted. + + When set to `RESTRICTED`, the procedure or function can be executed in parallel mode, but the execution is restricted to the parallel group leader. If the qualification for any particular relation has anything that is parallel restricted, that relation won't be chosen for parallelism. + + When set to `SAFE`, the procedure or function can be executed in parallel mode with no restriction. + +`execution_cost` + + `execution_cost` specifies a positive number giving the estimated execution cost for the function, in units of `cpu_operator_cost`. If the function returns a set, this is the cost per returned row. The default is `0.0025`. + +`result_rows` + + `result_rows` is the estimated number of rows that the query planner should expect the function to return. The default is `1000`. + +`SET` + + Use the `SET` clause to specify a parameter value for the duration of the function: + + `config_param` specifies the parameter name. + + `value` specifies the parameter value. + + `FROM CURRENT` guarantees that the parameter value is restored when the function ends. + +`package_initializer` + + The statements in the `package_initializer` are executed once per user’s session when the package is first referenced. + +!!! Note + The `STRICT, LEAKPROOF, PARALLEL, COST, ROWS` and `SET` keywords provide extended functionality for Advanced Server and are not supported by Oracle. diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/02_packages/02_creating_packages.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/02_packages/02_creating_packages.mdx new file mode 100644 index 00000000000..d009f08287b --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/02_packages/02_creating_packages.mdx @@ -0,0 +1,136 @@ +--- +title: "Creating Packages" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/creating_packages.html" +--- + +A package is not an executable piece of code; rather it is a repository of code. When you use a package, you actually execute or make reference to an element within a package. + +## Creating the Package Specification + +The package specification contains the definition of all the elements in the package that can be referenced from outside of the package. These are called the public elements of the package, and they act as the package interface. The following code sample is a package specification: + +```text +-- +-- Package specification for the 'emp_admin' package. +-- +CREATE OR REPLACE PACKAGE emp_admin +IS + FUNCTION get_dept_name ( + p_deptno NUMBER DEFAULT 10 + ) + RETURN VARCHAR2; + FUNCTION update_emp_sal ( + p_empno NUMBER, + p_raise NUMBER + ) + RETURN NUMBER; + PROCEDURE hire_emp ( + p_empno NUMBER, + p_ename VARCHAR2, + p_job VARCHAR2, + p_sal NUMBER, + p_hiredate DATE DEFAULT sysdate, + p_comm NUMBER DEFAULT 0, + p_mgr NUMBER, + p_deptno NUMBER DEFAULT 10 + ); + PROCEDURE fire_emp ( + p_empno NUMBER + ); +END emp_admin; +``` + +This code sample creates the `emp_admin` package specification. This package specification consists of two functions and two stored procedures. We can also add the `OR REPLACE` clause to the `CREATE PACKAGE` statement for convenience. + +## Creating the Package Body + +The body of the package contains the actual implementation behind the package specification. For the above `emp_admin` package specification, we shall now create a package body which will implement the specifications. The body will contain the implementation of the functions and stored procedures in the specification. + +```text +-- +-- Package body for the 'emp_admin' package. +-- +CREATE OR REPLACE PACKAGE BODY emp_admin +IS + -- + -- Function that queries the 'dept' table based on the department + -- number and returns the corresponding department name. + -- + FUNCTION get_dept_name ( + p_deptno IN NUMBER DEFAULT 10 + ) + RETURN VARCHAR2 + IS + v_dname VARCHAR2(14); + BEGIN + SELECT dname INTO v_dname FROM dept WHERE deptno = p_deptno; + RETURN v_dname; + EXCEPTION + WHEN NO_DATA_FOUND THEN + DBMS_OUTPUT.PUT_LINE('Invalid department number ' || p_deptno); + RETURN ''; + END; + -- + -- Function that updates an employee's salary based on the + -- employee number and salary increment/decrement passed + -- as IN parameters. Upon successful completion the function + -- returns the new updated salary. + -- + FUNCTION update_emp_sal ( + p_empno IN NUMBER, + p_raise IN NUMBER + ) + RETURN NUMBER + IS + v_sal NUMBER := 0; + BEGIN + SELECT sal INTO v_sal FROM emp WHERE empno = p_empno; + v_sal := v_sal + p_raise; + UPDATE emp SET sal = v_sal WHERE empno = p_empno; + RETURN v_sal; + EXCEPTION + WHEN NO_DATA_FOUND THEN + DBMS_OUTPUT.PUT_LINE('Employee ' || p_empno || ' not found'); + RETURN -1; + WHEN OTHERS THEN + DBMS_OUTPUT.PUT_LINE('The following is SQLERRM:'); + DBMS_OUTPUT.PUT_LINE(SQLERRM); + DBMS_OUTPUT.PUT_LINE('The following is SQLCODE:'); + DBMS_OUTPUT.PUT_LINE(SQLCODE); + RETURN -1; + END; + -- + -- Procedure that inserts a new employee record into the 'emp' table. + -- + PROCEDURE hire_emp ( + p_empno NUMBER, + p_ename VARCHAR2, + p_job VARCHAR2, + p_sal NUMBER, + p_hiredate DATE DEFAULT sysdate, + p_comm NUMBER DEFAULT 0, + p_mgr NUMBER, + p_deptno NUMBER DEFAULT 10 + ) + AS + BEGIN + INSERT INTO emp(empno, ename, job, sal, hiredate, comm, mgr, deptno) + VALUES(p_empno, p_ename, p_job, p_sal, + p_hiredate, p_comm, p_mgr, p_deptno); + END; + -- + -- Procedure that deletes an employee record from the 'emp' table based + -- on the employee number. + -- + PROCEDURE fire_emp ( + p_empno NUMBER + ) + AS + BEGIN + DELETE FROM emp WHERE empno = p_empno; + END; +END; +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/02_packages/03_referencing_a_package.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/02_packages/03_referencing_a_package.mdx new file mode 100644 index 00000000000..c2f3c6b5106 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/02_packages/03_referencing_a_package.mdx @@ -0,0 +1,23 @@ +--- +title: "Referencing a Package" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/referencing_a_package.html" +--- + +To reference the types, items and subprograms that are declared within a package specification, we use the dot notation. For example: + +`package_name.type_name` + +`package_name.item_name` + +`package_name.subprogram_name` + +To invoke a function from the `emp_admin` package specification, we will execute the following SQL command. + +```text +SELECT emp_admin.get_dept_name(10) FROM DUAL; +``` + +Here we are invoking the `get_dept_name` function declared within the package `emp_admin`. We are passing the department number as an argument to the function, which will return the name of the department. Here the value returned should be `ACCOUNTING`, which corresponds to department number `10`. diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/02_packages/04_using_packages_with_user_defined_types.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/02_packages/04_using_packages_with_user_defined_types.mdx new file mode 100644 index 00000000000..328388a8908 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/02_packages/04_using_packages_with_user_defined_types.mdx @@ -0,0 +1,182 @@ +--- +title: "Using Packages With User Defined Types" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/using_packages_with_user_defined_types.html" +--- + +The following example incorporates the various user-defined types discussed in earlier chapters within the context of a package. + +The package specification of `emp_rpt` shows the declaration of a record type, `emprec_typ`, and a weakly-typed `REF CURSOR, emp_refcur`, as publicly accessible along with two functions and two procedures. Function, `open_emp_by_dept`, returns the `REF CURSOR` type, `EMP_REFCUR`. Procedures, `fetch_emp` and `close_refcur`, both declare a weakly-typed `REF CURSOR` as a formal parameter. + +```text +CREATE OR REPLACE PACKAGE emp_rpt +IS + TYPE emprec_typ IS RECORD ( + empno NUMBER(4), + ename VARCHAR(10) + ); + TYPE emp_refcur IS REF CURSOR; + + FUNCTION get_dept_name ( + p_deptno IN NUMBER + ) RETURN VARCHAR2; + FUNCTION open_emp_by_dept ( + p_deptno IN emp.deptno%TYPE + ) RETURN EMP_REFCUR; + PROCEDURE fetch_emp ( + p_refcur IN OUT SYS_REFCURSOR + ); + PROCEDURE close_refcur ( + p_refcur IN OUT SYS_REFCURSOR + ); +END emp_rpt; +``` + +The package body shows the declaration of several private variables - a static cursor, `dept_cur`, a table type, `depttab_typ`, a table variable, `t_dept`, an integer variable, `t_dept_max`, and a record variable, `r_emp`. + +```text +CREATE OR REPLACE PACKAGE BODY emp_rpt +IS + CURSOR dept_cur IS SELECT * FROM dept; + TYPE depttab_typ IS TABLE of dept%ROWTYPE + INDEX BY BINARY_INTEGER; + t_dept DEPTTAB_TYP; + t_dept_max INTEGER := 1; + r_emp EMPREC_TYP; + + FUNCTION get_dept_name ( + p_deptno IN NUMBER + ) RETURN VARCHAR2 + IS + BEGIN + FOR i IN 1..t_dept_max LOOP + IF p_deptno = t_dept(i).deptno THEN + RETURN t_dept(i).dname; + END IF; + END LOOP; + RETURN 'Unknown'; + END; + + FUNCTION open_emp_by_dept( + p_deptno IN emp.deptno%TYPE + ) RETURN EMP_REFCUR + IS + emp_by_dept EMP_REFCUR; + BEGIN + OPEN emp_by_dept FOR SELECT empno, ename FROM emp + WHERE deptno = p_deptno; + RETURN emp_by_dept; + END; + + PROCEDURE fetch_emp ( + p_refcur IN OUT SYS_REFCURSOR + ) + IS + BEGIN + DBMS_OUTPUT.PUT_LINE('EMPNO ENAME'); + DBMS_OUTPUT.PUT_LINE('----- -------'); + LOOP + FETCH p_refcur INTO r_emp; + EXIT WHEN p_refcur%NOTFOUND; + DBMS_OUTPUT.PUT_LINE(r_emp.empno || ' ' || r_emp.ename); + END LOOP; + END; + + PROCEDURE close_refcur ( + p_refcur IN OUT SYS_REFCURSOR + ) + IS + BEGIN + CLOSE p_refcur; + END; +BEGIN + OPEN dept_cur; + LOOP + FETCH dept_cur INTO t_dept(t_dept_max); + EXIT WHEN dept_cur%NOTFOUND; + t_dept_max := t_dept_max + 1; + END LOOP; + CLOSE dept_cur; + t_dept_max := t_dept_max - 1; +END emp_rpt; +``` + +This package contains an initialization section that loads the private table variable, `t_dept`, using the private static cursor, `dept_cur.t_dept` serves as a department name lookup table in function, `get_dept_name`. + +Function, `open_emp_by_dept` returns a `REF CURSOR` variable for a result set of employee numbers and names for a given department. This `REF CURSOR` variable can then be passed to procedure, `fetch_emp`, to retrieve and list the individual rows of the result set. Finally, procedure, `close_refcur`, can be used to close the `REF CURSOR` variable associated with this result set. + +The following anonymous block runs the package function and procedures. In the anonymous block's declaration section, note the declaration of cursor variable, `v_emp_cur`, using the package’s public `REF CURSOR` type, `EMP_REFCUR. v_emp_cur` contains the pointer to the result set that is passed between the package function and procedures. + +```text +DECLARE + v_deptno dept.deptno%TYPE DEFAULT 30; + v_emp_cur emp_rpt.EMP_REFCUR; +BEGIN + v_emp_cur := emp_rpt.open_emp_by_dept(v_deptno); + DBMS_OUTPUT.PUT_LINE('EMPLOYEES IN DEPT #' || v_deptno || + ': ' || emp_rpt.get_dept_name(v_deptno)); + emp_rpt.fetch_emp(v_emp_cur); + DBMS_OUTPUT.PUT_LINE('**********************'); + DBMS_OUTPUT.PUT_LINE(v_emp_cur%ROWCOUNT || ' rows were retrieved'); + emp_rpt.close_refcur(v_emp_cur); +END; +``` + +The following is the result of this anonymous block. + +```text +EMPLOYEES IN DEPT #30: SALES +EMPNO ENAME +----- ------- +7499 ALLEN +7521 WARD +7654 MARTIN +7698 BLAKE +7844 TURNER +7900 JAMES +********************** +6 rows were retrieved +``` + +The following anonymous block illustrates another means of achieving the same result. Instead of using the package procedures, `fetch_emp` and `close_refcur`, the logic of these programs is coded directly into the anonymous block. In the anonymous block’s declaration section, note the addition of record variable, `r_emp`, declared using the package’s public record type, `EMPREC_TYP`. + +```text +DECLARE + v_deptno dept.deptno%TYPE DEFAULT 30; + v_emp_cur emp_rpt.EMP_REFCUR; + r_emp emp_rpt.EMPREC_TYP; +BEGIN + v_emp_cur := emp_rpt.open_emp_by_dept(v_deptno); + DBMS_OUTPUT.PUT_LINE('EMPLOYEES IN DEPT #' || v_deptno || + ': ' || emp_rpt.get_dept_name(v_deptno)); + DBMS_OUTPUT.PUT_LINE('EMPNO ENAME'); + DBMS_OUTPUT.PUT_LINE('----- -------'); + LOOP + FETCH v_emp_cur INTO r_emp; + EXIT WHEN v_emp_cur%NOTFOUND; + DBMS_OUTPUT.PUT_LINE(r_emp.empno || ' ' || + r_emp.ename); + END LOOP; + DBMS_OUTPUT.PUT_LINE('**********************'); + DBMS_OUTPUT.PUT_LINE(v_emp_cur%ROWCOUNT || ' rows were retrieved'); + CLOSE v_emp_cur; +END; +``` + +The following is the result of this anonymous block. + +```text +EMPLOYEES IN DEPT #30: SALES +EMPNO ENAME +----- ------- +7499 ALLEN +7521 WARD +7654 MARTIN +7698 BLAKE +7844 TURNER +7900 JAMES +********************** +6 rows were retrieved +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/02_packages/05_dropping_a_package.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/02_packages/05_dropping_a_package.mdx new file mode 100644 index 00000000000..6713ac7641a --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/02_packages/05_dropping_a_package.mdx @@ -0,0 +1,27 @@ +--- +title: "Dropping a Package" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/dropping_a_package.html" +--- + +The syntax for deleting an entire package or just the package body is as follows: + +```text +DROP PACKAGE [ BODY ] package_name; +``` + +If the keyword, `BODY`, is omitted, both the package specification and the package body are deleted - i.e., the entire package is dropped. If the keyword, `BODY`, is specified, then only the package body is dropped. The package specification remains intact. `package_name` is the identifier of the package to be dropped. + +Following statement will destroy only the package body of `emp_admin`: + +```text +DROP PACKAGE BODY emp_admin; +``` + +The following statement will drop the entire `emp_admin` package: + +```text +DROP PACKAGE emp_admin; +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/02_packages/index.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/02_packages/index.mdx new file mode 100644 index 00000000000..47d206de094 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/02_packages/index.mdx @@ -0,0 +1,20 @@ +--- +title: "Packages" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/packages.html" +--- + +This chapter discusses the concept of packages in Advanced Server. A *package* is a named collection of functions, procedures, variables, cursors, user-defined record types, and records that are referenced using a common qualifier – the package identifier. Packages have the following characteristics: + +- Packages provide a convenient means of organizing the functions and procedures that perform a related purpose. Permission to use the package functions and procedures is dependent upon one privilege granted to the entire package. All of the package programs must be referenced with a common name. +- Certain functions, procedures, variables, types, etc. in the package can be declared as *public*. Public entities are visible and can be referenced by other programs that are given `EXECUTE` privilege on the package. For public functions and procedures, only their signatures are visible - the program names, parameters if any, and return types of functions. The SPL code of these functions and procedures is not accessible to others, therefore applications that utilize a package are dependent only upon the information available in the signature – not in the procedural logic itself. +- Other functions, procedures, variables, types, etc. in the package can be declared as *private*. Private entities can be referenced and used by function and procedures within the package, but not by other external applications. Private entities are for use only by programs within the package. +- Function and procedure names can be overloaded within a package. One or more functions/procedures can be defined with the same name, but with different signatures. This provides the capability to create identically named programs that perform the same job, but on different types of input. + +
+ +package_components creating_packages referencing_a_package using_packages_with_user_defined_types dropping_a_package + +
diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/01_dbms_alert.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/01_dbms_alert.mdx new file mode 100644 index 00000000000..44bca71f7dc --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/01_dbms_alert.mdx @@ -0,0 +1,395 @@ +--- +title: "DBMS_ALERT" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/dbms_alert.html" +--- + +The `DBMS_ALERT` package provides the capability to register for, send, and receive alerts. The following table lists the supported procedures: + +| Function/Procedure | Return Type | Description | +| ----------------------------------------------------- | ----------- | --------------------------------------------------- | +| `REGISTER(name)` | n/a | Register to be able to receive alerts named, `name` | +| `REMOVE(name)` | n/a | Remove registration for the alert named, `name` | +| `REMOVEALL` | n/a | Remove registration for all alerts. | +| `SIGNAL(name, message)` | n/a | Signals the alert named, `name`, with `message` | +| `WAITANY(name OUT, message OUT, status OUT, timeout)` | n/a | Wait for any registered alert to occur. | +| `WAITONE(name, message OUT, status OUT, timeout)` | n/a | Wait for the specified alert, `name`, to occur. | + +Advanced Server's implementation of `DBMS_ALERT` is a partial implementation when compared to Oracle's version. Only those functions and procedures listed in the table above are supported. + +Advanced Server allows a maximum of `500` concurrent alerts. You can use the `dbms_alert.max_alerts` GUC variable (located in the `postgresql.conf` file) to specify the maximum number of concurrent alerts allowed on a system. + +To set a value for the `dbms_alert.max_alerts` variable, open the `postgresql.conf` file (located by default in `/opt/PostgresPlus/12AS/data`) with your choice of editor, and edit the `dbms_alert.max_alerts` parameter as shown: + +```text +dbms_alert.max_alerts = alert_count +``` + +`alert_count` + +`alert_count` specifies the maximum number of concurrent alerts. By default, the value of `dbms_alert.max_alerts` is `100`. To disable this feature, set `dbms_alert.max_alerts` to `0`. + +For the `dbms_alert.max_alerts` GUC to function correctly, the `custom_variable_classes` parameter must contain `dbms_alerts`: + +```text +custom_variable_classes = 'dbms_alert, …' +``` + +After editing the `postgresql.conf` file parameters, you must restart the server for the changes to take effect. + +## REGISTER + +The `REGISTER` procedure enables the current session to be notified of the specified alert. + +```text +REGISTER( VARCHAR2) +``` + +**Parameters** + +`name` + + Name of the alert to be registered. + +**Examples** + +The following anonymous block registers for an alert named, `alert_test`, then waits for the signal. + +```text +DECLARE + v_name VARCHAR2(30) := 'alert_test'; + v_msg VARCHAR2(80); + v_status INTEGER; + v_timeout NUMBER(3) := 120; +BEGIN + DBMS_ALERT.REGISTER(v_name); + DBMS_OUTPUT.PUT_LINE('Registered for alert ' || v_name); + DBMS_OUTPUT.PUT_LINE('Waiting for signal...'); + DBMS_ALERT.WAITONE(v_name,v_msg,v_status,v_timeout); + DBMS_OUTPUT.PUT_LINE('Alert name : ' || v_name); + DBMS_OUTPUT.PUT_LINE('Alert msg : ' || v_msg); + DBMS_OUTPUT.PUT_LINE('Alert status : ' || v_status); + DBMS_OUTPUT.PUT_LINE('Alert timeout: ' || v_timeout || ' seconds'); + DBMS_ALERT.REMOVE(v_name); +END; + +Registered for alert alert_test +Waiting for signal... +``` + +## REMOVE + +The `REMOVE` procedure unregisters the session for the named alert. + +```text +REMOVE( VARCHAR2) +``` + +**Parameters** + +`name` + + Name of the alert to be unregistered. + +## REMOVEALL + +The `REMOVEALL` procedure unregisters the session for all alerts. + +```text +REMOVEALL +``` + +## SIGNAL + +The `SIGNAL` procedure signals the occurrence of the named alert. + +```text +SIGNAL( VARCHAR2, VARCHAR2) +``` + +**Parameters** + +`name` + + Name of the alert. + +`message` + + Information to pass with this alert. + +**Examples** + +The following anonymous block signals an alert for `alert_test`. + +```text +DECLARE + v_name VARCHAR2(30) := 'alert_test'; +BEGIN + DBMS_ALERT.SIGNAL(v_name,'This is the message from ' || v_name); + DBMS_OUTPUT.PUT_LINE('Issued alert for ' || v_name); +END; +Issued alert for alert_test +``` + +## WAITANY + +The `WAITANY` procedure waits for any of the registered alerts to occur. + +```text +WAITANY( OUT VARCHAR2, OUT VARCHAR2, + OUT INTEGER, NUMBER) +``` + +**Parameters** + +`name` + + Variable receiving the name of the alert. + +`message` + + Variable receiving the message sent by the `SIGNAL` procedure. + +`status` + + Status code returned by the operation. Possible values are: 0 – alert occurred; 1 – timeout occurred. + +`timeout` + + Time to wait for an alert in seconds. + +**Examples** + +The following anonymous block uses the `WAITANY` procedure to receive an alert named, `alert_test` or `any_alert`: + +```text +DECLARE + v_name VARCHAR2(30); + v_msg VARCHAR2(80); + v_status INTEGER; + v_timeout NUMBER(3) := 120; +BEGIN + DBMS_ALERT.REGISTER('alert_test'); + DBMS_ALERT.REGISTER('any_alert'); + DBMS_OUTPUT.PUT_LINE('Registered for alert alert_test and any_alert'); + DBMS_OUTPUT.PUT_LINE('Waiting for signal...'); + DBMS_ALERT.WAITANY(v_name,v_msg,v_status,v_timeout); + DBMS_OUTPUT.PUT_LINE('Alert name : ' || v_name); + DBMS_OUTPUT.PUT_LINE('Alert msg : ' || v_msg); + DBMS_OUTPUT.PUT_LINE('Alert status : ' || v_status); + DBMS_OUTPUT.PUT_LINE('Alert timeout: ' || v_timeout || ' seconds'); + DBMS_ALERT.REMOVEALL; +END; + +Registered for alert alert_test and any_alert +Waiting for signal... +``` + +An anonymous block in a second session issues a signal for `any_alert`: + +```text +DECLARE + v_name VARCHAR2(30) := 'any_alert'; +BEGIN + DBMS_ALERT.SIGNAL(v_name,'This is the message from ' || v_name); + DBMS_OUTPUT.PUT_LINE('Issued alert for ' || v_name); +END; + +Issued alert for any_alert +``` + +Control returns to the first anonymous block and the remainder of the code is executed: + +```text +Registered for alert alert_test and any_alert +Waiting for signal... +Alert name : any_alert +Alert msg : This is the message from any_alert +Alert status : 0 +Alert timeout: 120 seconds +``` + +## WAITONE + +The `WAITONE` procedure waits for the specified registered alert to occur. + +```text +WAITONE( VARCHAR2, OUT VARCHAR2, + OUT INTEGER, NUMBER) +``` + +**Parameters** + +`name` + + Name of the alert. + +`message` + + Variable receiving the message sent by the `SIGNAL` procedure. + +`status` + + Status code returned by the operation. Possible values are: 0 – alert occurred; 1 – timeout occurred. + +`timeout` + + Time to wait for an alert in seconds. + +**Examples** + +The following anonymous block is similar to the one used in the `WAITANY` example except the `WAITONE` procedure is used to receive the alert named, `alert_test`. + +```text +DECLARE + v_name VARCHAR2(30) := 'alert_test'; + v_msg VARCHAR2(80); + v_status INTEGER; + v_timeout NUMBER(3) := 120; +BEGIN + DBMS_ALERT.REGISTER(v_name); + DBMS_OUTPUT.PUT_LINE('Registered for alert ' || v_name); + DBMS_OUTPUT.PUT_LINE('Waiting for signal...'); + DBMS_ALERT.WAITONE(v_name,v_msg,v_status,v_timeout); + DBMS_OUTPUT.PUT_LINE('Alert name : ' || v_name); + DBMS_OUTPUT.PUT_LINE('Alert msg : ' || v_msg); + DBMS_OUTPUT.PUT_LINE('Alert status : ' || v_status); + DBMS_OUTPUT.PUT_LINE('Alert timeout: ' || v_timeout || ' seconds'); + DBMS_ALERT.REMOVE(v_name); +END; + +Registered for alert alert_test +Waiting for signal... +``` + +Signal sent for `alert_test` sent by an anonymous block in a second session: + +```text +DECLARE + v_name VARCHAR2(30) := 'alert_test'; +BEGIN + DBMS_ALERT.SIGNAL(v_name,'This is the message from ' || v_name); + DBMS_OUTPUT.PUT_LINE('Issued alert for ' || v_name); +END; + +Issued alert for alert_test +``` + +First session is alerted, control returns to the anonymous block, and the remainder of the code is executed: + +```text +Registered for alert alert_test +Waiting for signal... +Alert name : alert_test +Alert msg : This is the message from alert_test +Alert status : 0 +Alert timeout: 120 seconds +``` + +## Comprehensive Example + +The following example uses two triggers to send alerts when the `dept` table or the `emp` table is changed. An anonymous block listens for these alerts and displays messages when an alert is received. + +The following are the triggers on the `dept` and `emp` tables: + +```text +CREATE OR REPLACE TRIGGER dept_alert_trig + AFTER INSERT OR UPDATE OR DELETE ON dept +DECLARE + v_action VARCHAR2(25); +BEGIN + IF INSERTING THEN + v_action := ' added department(s) '; + ELSIF UPDATING THEN + v_action := ' updated department(s) '; + ELSIF DELETING THEN + v_action := ' deleted department(s) '; + END IF; + DBMS_ALERT.SIGNAL('dept_alert',USER || v_action || 'on ' || + SYSDATE); +END; + +CREATE OR REPLACE TRIGGER emp_alert_trig + AFTER INSERT OR UPDATE OR DELETE ON emp +DECLARE + v_action VARCHAR2(25); +BEGIN + IF INSERTING THEN + v_action := ' added employee(s) '; + ELSIF UPDATING THEN + v_action := ' updated employee(s) '; + ELSIF DELETING THEN + v_action := ' deleted employee(s) '; + END IF; + DBMS_ALERT.SIGNAL('emp_alert',USER || v_action || 'on ' || + SYSDATE); +END; +``` + +The following anonymous block is executed in a session while updates to the `dept` and `emp` tables occur in other sessions: + +```text +DECLARE + v_dept_alert VARCHAR2(30) := 'dept_alert'; + v_emp_alert VARCHAR2(30) := 'emp_alert'; + v_name VARCHAR2(30); + v_msg VARCHAR2(80); + v_status INTEGER; + v_timeout NUMBER(3) := 60; +BEGIN + DBMS_ALERT.REGISTER(v_dept_alert); + DBMS_ALERT.REGISTER(v_emp_alert); + DBMS_OUTPUT.PUT_LINE('Registered for alerts dept_alert and emp_alert'); + DBMS_OUTPUT.PUT_LINE('Waiting for signal...'); + LOOP + DBMS_ALERT.WAITANY(v_name,v_msg,v_status,v_timeout); + EXIT WHEN v_status != 0; + DBMS_OUTPUT.PUT_LINE('Alert name : ' || v_name); + DBMS_OUTPUT.PUT_LINE('Alert msg : ' || v_msg); + DBMS_OUTPUT.PUT_LINE('Alert status : ' || v_status); + DBMS_OUTPUT.PUT_LINE('------------------------------------' || + '-------------------------'); + END LOOP; + DBMS_OUTPUT.PUT_LINE('Alert status : ' || v_status); + DBMS_ALERT.REMOVEALL; +END; + +Registered for alerts dept_alert and emp_alert +Waiting for signal... +``` + +The following changes are made by user, mary: + +```text +INSERT INTO dept VALUES (50,'FINANCE','CHICAGO'); +INSERT INTO emp (empno,ename,deptno) VALUES (9001,'JONES',50); +INSERT INTO emp (empno,ename,deptno) VALUES (9002,'ALICE',50); +``` + +The following change is made by user, john: + +```text +INSERT INTO dept VALUES (60,'HR','LOS ANGELES'); +``` + +The following is the output displayed by the anonymous block receiving the signals from the triggers: + +```text +Registered for alerts dept_alert and emp_alert +Waiting for signal... +Alert name : dept_alert +Alert msg : mary added department(s) on 25-OCT-07 16:41:01 +Alert status : 0 +------------------------------------------------------------- +Alert name : emp_alert +Alert msg : mary added employee(s) on 25-OCT-07 16:41:02 +Alert status : 0 +------------------------------------------------------------- +Alert name : dept_alert +Alert msg : john added department(s) on 25-OCT-07 16:41:22 +Alert status : 0 +------------------------------------------------------------- +Alert status : 1 +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/02_dbms_aq/01_enqueue.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/02_dbms_aq/01_enqueue.mdx new file mode 100644 index 00000000000..7487f87c635 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/02_dbms_aq/01_enqueue.mdx @@ -0,0 +1,120 @@ +--- +title: "ENQUEUE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/enqueue.html" +--- + +The `ENQUEUE` procedure adds an entry to a queue. The signature is: + +```text +ENQUEUE( + IN VARCHAR2, + IN DBMS_AQ.ENQUEUE_OPTIONS_T, + IN DBMS_AQ.MESSAGE_PROPERTIES_T, + IN , + OUT RAW) +``` + +**Parameters** + +`queue_name` + + The name (optionally schema-qualified) of an existing queue. If you omit the schema name, the server will use the schema specified in the `SEARCH_PATH`. Please note that unlike Oracle, unquoted identifiers are converted to lower case before storing. To include special characters or use a case-sensitive name, enclose the name in double quotes. + + For detailed information about creating a queue, see `DBMS_AQADM.CREATE_QUEUE`. + +`enqueue_options` + + `enqueue_options` is a value of the type, `enqueue_options_t`: + +```text +DBMS_AQ.ENQUEUE_OPTIONS_T IS RECORD( + visibility BINARY_INTEGER DEFAULT ON_COMMIT, + relative_msgid RAW(16) DEFAULT NULL, + sequence_deviation BINARY INTEGER DEFAULT NULL, + transformation VARCHAR2(61) DEFAULT NULL, + delivery_mode PLS_INTEGER NOT NULL DEFAULT PERSISTENT); +``` + +Currently, the only supported parameter values for `enqueue_options_t` are: + +| `visibility` | `ON_COMMIT`. | +| -------------------- | ------------ | +| `delivery_mode` | `PERSISTENT` | +| `sequence_deviation` | `NULL` | +| `transformation` | `NULL` | +| `relative_msgid` | `NULL` | + +`message_properties` + + `message_properties` is a value of the type, `message_properties_t`: + +```text +message_properties_t IS RECORD( + priority INTEGER, + delay INTEGER, + expiration INTEGER, + correlation CHARACTER VARYING(128) COLLATE pg_catalog.”C”, + attempts INTEGER, + recipient_list “AQ$_RECIPIENT_LIST_T”, + exception_queue CHARACTER VARYING(61) COLLATE pg_catalog.”C”, + enqueue_time TIMESTAMP WITHOUT TIME ZONE, + state INTEGER, + original_msgid BYTEA, + transaction_group CHARACTER VARYING(30) COLLATE pg_catalog.”C”, + delivery_mode INTEGER +DBMS_AQ.PERSISTENT); +``` + +The supported values for `message_properties_t` are: + +| | | +| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `priority` | If the queue table definition includes a `sort_list` that references `priority`, this parameter affects the order that messages are dequeued. A lower value indicates a higher dequeue priority. | +| `delay` | Specify the number of seconds that will pass before a message is available for dequeueing or `NO_DELAY`. | +| `expiration` | Use the expiration parameter to specify the number of seconds until a message expires. | +| `correlation` | Use correlation to specify a message that will be associated with the entry; the default is `NULL`. | +| `attempts` | This is a system-maintained value that specifies the number of attempts to dequeue the message. | +| `recipient_list` | This parameter is not supported. | +| `exception_queue` | Use the `exception_queue` parameter to specify the name of an exception queue to which a message will be moved if it expires or is dequeued by a transaction that rolls back too many times. | +| `enqueue_time` | `enqueue_time` is the time the record was added to the queue; this value is provided by the system. | +| `state` | This parameter is maintained by DBMS_AQ; state can be:

`DBMS_AQ.WAITING` – the delay has not been reached.

`DBMS_AQ.READY` – the queue entry is ready for processing.

`DBMS_AQ.PROCESSED` – the queue entry has been processed.

`DBMS_AQ.EXPIRED` – the queue entry has been moved to the exception queue. | +| `original_msgid` | This parameter is accepted for compatibility and ignored. | +| `transaction_group` | This parameter is accepted for compatibility and ignored. | +| `delivery_mode` | This parameter is not supported; specify a value of `DBMS_AQ.PERSISTENT`. | + +`payload` + + Use the `payload` parameter to provide the data that will be associated with the queue entry. The payload type must match the type specified when creating the corresponding queue table (see `DBMS_AQADM.CREATE_QUEUE_TABLE`). + +`msgid` + + Use the `msgid` parameter to retrieve a unique (system-generated) message identifier. + +**Example** + +The following anonymous block calls `DBMS_AQ.ENQUEUE`, adding a message to a queue named `work_order`: + +```text +DECLARE + + enqueue_options DBMS_AQ.ENQUEUE_OPTIONS_T; + message_properties DBMS_AQ.MESSAGE_PROPERTIES_T; + message_handle raw(16); + payload work_order; + +BEGIN + + payload := work_order('Smith', 'system upgrade'); + +DBMS_AQ.ENQUEUE( + queue_name => 'work_order', + enqueue_options => enqueue_options, + message_properties => message_properties, + payload => payload, + msgid => message_handle + ); + END; +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/02_dbms_aq/02_dequeue.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/02_dbms_aq/02_dequeue.mdx new file mode 100644 index 00000000000..4a45c6c09e5 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/02_dbms_aq/02_dequeue.mdx @@ -0,0 +1,132 @@ +--- +title: "DEQUEUE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/dequeue.html" +--- + +The `DEQUEUE` procedure dequeues a message. The signature is: + +```text +DEQUEUE( + IN VARCHAR2, + IN DBMS_AQ.DEQUEUE_OPTIONS_T, + OUT DBMS_AQ.MESSAGE_PROPERTIES_T, + OUT , + OUT RAW) +``` + +**Parameters** + +`queue_name` + + The name (optionally schema-qualified) of an existing queue. If you omit the schema name, the server will use the schema specified in the `SEARCH_PATH`. Please note that unlike Oracle, unquoted identifiers are converted to lower case before storing. To include special characters or use a case-sensitive name, enclose the name in double quotes. + + For detailed information about creating a queue, see `DBMS_AQADM.CREATE_QUEUE`. + +`dequeue_options` is a value of the type, `dequeue_options_t`: + +```text +DEQUEUE_OPTIONS_T IS RECORD( + consumer_name CHARACTER VARYING(30), + dequeue_mode INTEGER, + navigation INTEGER, + visibility INTEGER, + wait INTEGER, + msgid BYTEA, + correlation CHARACTER VARYING(128), + deq_condition CHARACTER VARYING(4000), + transformation CHARACTER VARYING(61), + delivery_mode INTEGER); +``` + +Currently, the supported parameter values for `dequeue_options_t` are: + +| | | +| ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `consumer_name` | Must be `NULL`. | +| `dequeue_mode` | The locking behavior of the dequeue operation. Must be either:

`DBMS_AQ.BROWSE` – Read the message without obtaining a lock.

`DBMS_AQ.LOCKED` – Read the message after acquiring a lock.

`DBMS_AQ.REMOVE` – Read the message before deleting the message.

`DBMS_AQ.REMOVE_NODATA` – Read the message, but do not delete the message. | +| `navigation` | Identifies the message that will be retrieved. Must be either:

`FIRST_MESSAGE` – The first message within the queue that matches the search term.

`NEXT_MESSAGE` – The next message that is available that matches the first term. | +| `visibility` | Must be `ON_COMMIT` – if you roll back the current transaction the dequeued item will remain in the queue. | +| `wait` | Must be a number larger than 0, or:

`DBMS_AQ.FOREVER` – Wait indefinitely.

`DBMS_AQ.NO_WAIT` – Do not wait. | +| `msgid` | The message ID of the message that will be dequeued. | +| `correlation` | Accepted for compatibility, and ignored. | +| `deq_condition` | A `VARCHAR2` expression that evaluates to a `BOOLEAN` value indicating if the message should be dequeued. | +| `transformation` | Accepted for compatibility, and ignored. | +| `delivery_mode` | Must be `PERSISTENT`; buffered messages are not supported at this time. | + +`message_properties` is a value of the type, `message_properties_t`: + +```text +message_properties_t IS RECORD( + priority INTEGER, + delay INTEGER, + expiration INTEGER, + correlation CHARACTER VARYING(128) COLLATE pg_catalog.”C”, + attempts INTEGER, + recipient_list “AQ$_RECIPIENT_LIST_T”, + exception_queue CHARACTER VARYING(61) COLLATE pg_catalog.”C”, + enqueue_time TIMESTAMP WITHOUT TIME ZONE, + state INTEGER, + original_msgid BYTEA, + transaction_group CHARACTER VARYING(30) COLLATE pg_catalog.”C”, + delivery_mode INTEGER +DBMS_AQ.PERSISTENT); +``` + +The supported values for `message_properties_t` are: + +| | | +| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `priority` | If the queue table definition includes a `sort_list` that references `priority`, this parameter affects the order that messages are dequeued. A lower value indicates a higher dequeue priority. | +| `delay` | Specify the number of seconds that will pass before a message is available for dequeueing or `NO_DELAY`. | +| `expiration` | Use the expiration parameter to specify the number of seconds until a message expires. | +| `correlation` | Use correlation to specify a message that will be associated with the entry; the default is `NULL`. | +| `attempts` | This is a system-maintained value that specifies the number of attempts to dequeue the message. | +| `recipient_list` | This parameter is not supported. | +| `exception_queue` | Use the `exception_queue` parameter to specify the name of an exception queue to which a message will be moved if it expires or is dequeued by a transaction that rolls back too many times. | +| `enqueue_time` | `enqueue_time` is the time the record was added to the queue; this value is provided by the system. | +| `state` | This parameter is maintained by DBMS_AQ; state can be:

`DBMS_AQ.WAITING` – the delay has not been reached.

`DBMS_AQ.READY` – the queue entry is ready for processing.

`DBMS_AQ.PROCESSED` – the queue entry has been processed.

`DBMS_AQ.EXPIRED` – the queue entry has been moved to the exception queue. | +| `original_msgid` | This parameter is accepted for compatibility and ignored. | +| `transaction_group` | This parameter is accepted for compatibility and ignored. | +| `delivery_mode` | This parameter is not supported; specify a value of `DBMS_AQ.PERSISTENT`. | + +`payload` + + Use the `payload` parameter to retrieve the payload of a message with a dequeue operation. The payload type must match the type specified when creating the queue table. + +`msgid` + + Use the `msgid` parameter to retrieve a unique message identifier. + +**Example** + +The following anonymous block calls `DBMS_AQ.DEQUEUE`, retrieving a message from the queue and a payload: + +```text +DECLARE + + dequeue_options DBMS_AQ.DEQUEUE_OPTIONS_T; + message_properties DBMS_AQ.MESSAGE_PROPERTIES_T; + message_handle raw(16); + payload work_order; + +BEGIN + dequeue_options.dequeue_mode := DBMS_AQ.BROWSE; + + DBMS_AQ.DEQUEUE( + queue_name => 'work_queue', + dequeue_options => dequeue_options, + message_properties => message_properties, + payload => payload, + msgid => message_handle + ); + + DBMS_OUTPUT.PUT_LINE( + 'The next work order is [' || payload.subject || '].' + ); +END; +``` + +The payload is displayed by `DBMS_OUTPUT.PUT_LINE`. diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/02_dbms_aq/03_register.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/02_dbms_aq/03_register.mdx new file mode 100644 index 00000000000..ac2bcd2df1d --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/02_dbms_aq/03_register.mdx @@ -0,0 +1,62 @@ +--- +title: "REGISTER" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/register.html" +--- + +Use the `REGISTER` procedure to register an email address, procedure or URL that will be notified when an item is enqueued or dequeued. The signature is: + +```text +REGISTER( + IN SYS.AQ$_REG_INFO_LIST, + IN NUMBER) +``` + +**Parameters** + +`reg_list` is a list of type `AQ$_REG_INFO_LIST`; that provides information about each subscription that you would like to register. Each entry within the list is of the type `AQ$_REG_INFO`, and may contain: + +
+ +
+ +| Attribute | Type | Description | +| ----------- | --------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `name` | VARCHAR2 (128) | The (optionally schema-qualified) name of the subscription. | +| `namespace` | NUMERIC | The only supported value is `DBMS_AQ.NAMESPACE_AQ (0)` | +| `callback` | VARCHAR2 (4000) | Describes the action that will be performed upon notification. Currently, only calls to PL/SQL procedures are supported. The call should take the form:

`plsql://schema.procedure`

Where:

schema specifies the schema in which the procedure resides.

procedure specifies the name of the procedure that will be notified. | +| `context` | RAW (16) | Any user-defined value required by the procedure. | + +`count` + + `count` is the number of entries in `reg_list`. + +**Example** + +The following anonymous block calls `DBMS_AQ.REGISTER`, registering procedures that will be notified when an item is added to or removed from a queue. A set of attributes (of `sys.aq$_reg_info` type) is provided for each subscription identified in the `DECLARE` section: + +```text +DECLARE + subscription1 sys.aq$_reg_info; + subscription2 sys.aq$_reg_info; + subscription3 sys.aq$_reg_info; + subscriptionlist sys.aq$_reg_info_list; +BEGIN + subscription1 := sys.aq$_reg_info('q', DBMS_AQ.NAMESPACE_AQ, +'plsql://assign_worker?PR=0',HEXTORAW('FFFF')); + subscription2 := sys.aq$_reg_info('q', DBMS_AQ.NAMESPACE_AQ, +'plsql://add_to_history?PR=1',HEXTORAW('FFFF')); + subscription3 := sys.aq$_reg_info('q', DBMS_AQ.NAMESPACE_AQ, +'plsql://reserve_parts?PR=2',HEXTORAW('FFFF')); + + subscriptionlist := sys.aq$_reg_info_list(subscription1, +subscription2, subscription3); + dbms_aq.register(subscriptionlist, 3); + commit; + END; + / +``` + +The `subscriptionlist` is of type `sys.aq$_reg_info_list`, and contains the previously described `sys.aq$_reg_info` objects. The list name and an object count are passed to `dbms_aq.register`. diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/02_dbms_aq/04_unregister.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/02_dbms_aq/04_unregister.mdx new file mode 100644 index 00000000000..762b412c003 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/02_dbms_aq/04_unregister.mdx @@ -0,0 +1,64 @@ +--- +title: "UNREGISTER" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/unregister.html" +--- + +Use the `UNREGISTER` procedure to turn off notifications related to enqueueing and dequeueing. The signature is: + +```text +UNREGISTER( + IN SYS.AQ$_REG_INFO_LIST, + IN NUMBER) +``` + +**Parameter** + +`reg_list` + +`reg_list` is a list of type `AQ$_REG_INFO_LIST`; that provides information about each subscription that you would like to register. Each entry within the list is of the type `AQ$_REG_INFO`, and may contain: + +
+ +
+ +| Attribute | Type | Description | +| ----------- | --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `name` | VARCHAR2 (128) | The (optionally schema-qualified) name of the subscription. | +| `namespace` | NUMERIC | The only supported value is `DBMS_AQ.NAMESPACE_AQ (0)` | +| `callback` | VARCHAR2 (4000) | Describes the action that will be performed upon notification. Currently, only calls to PL/SQL procedures are supported. The call should take the form:

`plsql://schema.procedure`

Where:

schema specifies the schema in which the procedure resides.

procedure specifies the name of the procedure that will be notified. | +| `context` | RAW (16) | Any user-defined value required by the procedure. | + +`count` + + `count` is the number of entries in `reg_list`. + +**Example** + +The following anonymous block calls `DBMS_AQ.UNREGISTER`, disabling the notifications specified in the example for `DBMS_AQ.REGISTER`: + +```text +DECLARE + subscription1 sys.aq$_reg_info; + subscription2 sys.aq$_reg_info; + subscription3 sys.aq$_reg_info; + subscriptionlist sys.aq$_reg_info_list; +BEGIN + subscription1 := sys.aq$_reg_info('q', DBMS_AQ.NAMESPACE_AQ, +'plsql://assign_worker?PR=0',HEXTORAW('FFFF')); + subscription2 := sys.aq$_reg_info('q', DBMS_AQ.NAMESPACE_AQ, +'plsql://add_to_history?PR=1',HEXTORAW('FFFF')); + subscription3 := sys.aq$_reg_info('q', DBMS_AQ.NAMESPACE_AQ, +'plsql://reserve_parts?PR=2',HEXTORAW('FFFF')); + + subscriptionlist := sys.aq$_reg_info_list(subscription1, +subscription2, subscription3); + dbms_aq.unregister(subscriptionlist, 3); + commit; + END; + / +``` + +The `subscriptionlist` is of type `sys.aq$_reg_info_list`, and contains the previously described `sys.aq$_reg_info` objects. The list name and an object count are passed to `dbms_aq.unregister`. diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/02_dbms_aq/index.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/02_dbms_aq/index.mdx new file mode 100644 index 00000000000..ffa9a23017d --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/02_dbms_aq/index.mdx @@ -0,0 +1,73 @@ +--- +title: "DBMS_AQ" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/dbms_aq.html" +--- + +EDB Postgres Advanced Server Advanced Queueing provides message queueing and message processing for the Advanced Server database. User-defined messages are stored in a queue; a collection of queues is stored in a queue table. Procedures in the `DBMS_AQADM` package create and manage message queues and queue tables. Use the `DBMS_AQ` package to add messages to a queue or remove messages from a queue, or register or unregister a PL/SQL callback procedure. + +Advanced Server also provides extended (non-compatible) functionality for the `DBMS_AQ` package with SQL commands, see the *Database Compatibility for Oracle Developers SQL Guide* for detailed information about the following SQL commands: + +- `ALTER QUEUE` +- `ALTER QUEUE TABLE` +- `CREATE QUEUE` +- `CREATE QUEUE TABLE` +- `DROP QUEUE` +- `DROP QUEUE TABLE` + +The `DBMS_AQ` package provides procedures that allow you to enqueue a message, dequeue a message, and manage callback procedures. The supported procedures are: + +| Function/Procedure | Return Type | Description | +| ------------------ | ----------- | ------------------------------------------------------------------ | +| `ENQUEUE` | n/a | Post a message to a queue. | +| `DEQUEUE` | n/a | Retrieve a message from a queue if or when a message is available. | +| `REGISTER` | n/a | Register a callback procedure. | +| `UNREGISTER` | n/a | Unregister a callback procedure. | + +Advanced Server's implementation of `DBMS_AQ` is a partial implementation when compared to Oracle's version. Only those procedures listed in the table above are supported. + +Advanced Server supports use of the constants listed below: + +| Constant | Description | For Parameters | +| --------------------------------- | --------------------------------------------------------------------------------- | ------------------------------------------------------------ | +| `DBMS_AQ.BROWSE (0)` | Read the message without locking. | `dequeue_options_t.dequeue_mode` | +| `DBMS_AQ.LOCKED (1)` | This constant is defined, but will return an error if used. | `dequeue_options_t.dequeue_mode` | +| `DBMS_AQ.REMOVE (2)` | Delete the message after reading; the default. | `dequeue_options_t.dequeue_mode` | +| `DBMS_AQ.REMOVE_NODATA (3)` | This constant is defined, but will return an error if used. | `dequeue_options_t.dequeue_mode` | +| `DBMS_AQ.FIRST_MESSAGE (0)` | Return the first available message that matches the search terms. | `dequeue_options_t.navigation` | +| `DBMS_AQ.NEXT_MESSAGE (1)` | Return the next available message that matches the search terms. | `dequeue_options_t.navigation` | +| `DBMS_AQ.NEXT_TRANSACTION (2)` | This constant is defined, but will return an error if used. | `dequeue_options_t.navigation` | +| `DBMS_AQ.FOREVER (-1)` | Wait forever if a message that matches the search term is not found, the default. | `dequeue_options_t.wait` | +| `DBMS_AQ.NO_WAIT (0)` | Do not wait if a message that matches the search term is not found. | `dequeue_options_t.wait` | +| `DBMS_AQ.ON_COMMIT (0)` | The dequeue is part of the current transaction. | `enqueue_options_t.visibility, dequeue_options_t.visibility` | +| `DBMS_AQ.IMMEDIATE (1)` | This constant is defined, but will return an error if used. | `enqueue_options_t.visibility, dequeue_options_t.visibility` | +| `DBMS_AQ.PERSISTENT (0)` | The message should be stored in a table. | `enqueue_options_t.delivery_mode` | +| `DBMS_AQ.BUFFERED (1)` | This constant is defined, but will return an error if used. | `enqueue_options_t.delivery_mode` | +| `DBMS_AQ.READY (0)` | Specifies that the message is ready to process. | `message_properties_t.state` | +| `DBMS_AQ.WAITING (1)` | Specifies that the message is waiting to be processed. | `message_properties_t.state` | +| `DBMS_AQ.PROCESSED (2)` | Specifies that the message has been processed. | `message_properties_t.state` | +| `DBMS_AQ.EXPIRED (3)` | Specifies that the message is in the exception queue. | `message_properties_t.state` | +| `DBMS_AQ.NO_DELAY (0)` | This constant is defined, but will return an error if used | `message_properties_t.delay` | +| `DBMS_AQ.NEVER (NULL)` | This constant is defined, but will return an error if used | `message_properties_t.expiration` | +| `DBMS_AQ.NAMESPACE_AQ (0)` | Accept notifications from `DBMS_AQ` queues. | `sys.aq$_reg_info.namespace` | +| `DBMS_AQ.NAMESPACE_ANONYMOUS (1)` | This constant is defined, but will return an error if used | `sys.aq$_reg_info.namespace` | + +The `DBMS_AQ` configuration parameters listed in the following table can be defined in the `postgresql.conf` file. After the configuration parameters are defined, you can invoke the `DBMS_AQ` package to use and manage messages held in queues and queue tables. + +| Parameter | Description | +| ----------------------------- | ------------------------------------------------------------------------------------------------ | +| `dbms_aq.max_workers` | The maximum number of workers to run. | +| `dbms_aq.max_idle_time` | The idle time a worker must wait before exiting. | +| `dbms_aq.min_work_time` | The minimum time a worker can run before exiting. | +| `dbms_aq.launch_delay` | The minimum time between creating workers. | +| `dbms_aq.batch_size` | The maximum number of messages to process in a single transaction. The default batch size is 10. | +| `dbms_aq.max_databases` | The size of `DBMS_AQ`’s hash table of databases. The default value is 1024. | +| `dbms_aq.max_pending_retries` | The size of `DBMS_AQ`’s hash table of pending retries. The default value is 1024. | + +
+ +enqueue dequeue register unregister + +
diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/03_dbms_aqadm/01_alter_queue.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/03_dbms_aqadm/01_alter_queue.mdx new file mode 100644 index 00000000000..eaa16d06d9d --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/03_dbms_aqadm/01_alter_queue.mdx @@ -0,0 +1,52 @@ +--- +title: "ALTER_QUEUE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/alter_queue.html" +--- + +Use the `ALTER_QUEUE` procedure to modify an existing queue. The signature is: + +```text +ALTER_QUEUE( + IN NUMBER DEFAULT NULL, + IN NUMBER DEFAULT 0 + IN NUMBER DEFAULT 0, + IN BOOLEAN DEFAULT TRUE) + IN VARCHAR2 DEFAULT NULL, +``` + +**Parameters** + +`queue_name` + + The name of the new queue. + +`max_retries` + + `max_retries` specifies the maximum number of attempts to remove a message with a dequeue statement. The value of `max_retries` is incremented with each `ROLLBACK` statement. When the number of failed attempts reaches the value specified by `max_retries`, the message is moved to the exception queue. Specify `0` to indicate that no retries are allowed. + +`retry_delay` + + `retry_delay` specifies the number of seconds until a message is scheduled for re-processing after a `ROLLBACK`. Specify `0` to indicate that the message should be retried immediately (the default). + +`retention_time` + + `retention_time` specifies the length of time (in seconds) that a message will be stored after being dequeued. You can also specify `0` (the default) to indicate the message should not be retained after dequeueing, or `INFINITE` to retain the message forever. + +`auto_commit` + + This parameter is accepted for compatibility and ignored. + +`comment` + + `comment` specifies a comment associated with the queue. + +**Example** + +The following command alters a queue named `work_order`, setting the `retry_delay` parameter to 5 seconds: + +```text +EXEC DBMS_AQADM.ALTER_QUEUE(queue_name => 'work_order', retry_delay => 5); +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/03_dbms_aqadm/02_alter_queue_table.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/03_dbms_aqadm/02_alter_queue_table.mdx new file mode 100644 index 00000000000..2301819a81b --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/03_dbms_aqadm/02_alter_queue_table.mdx @@ -0,0 +1,47 @@ +--- +title: "ALTER_QUEUE_TABLE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/alter_queue_table.html" +--- + +Use the `ALTER_QUEUE_TABLE` procedure to modify an existing queue table. The signature is: + +```text +ALTER_QUEUE_TABLE ( + IN VARCHAR2, + IN VARCHAR2 DEFAULT NULL, + IN BINARY_INTEGER DEFAULT 0, + IN BINARY_INTEGER DEFAULT 0, +``` + +**Parameters** + +`queue_table` + + The (optionally schema-qualified) name of the queue table. + +`comment` + + Use the `comment` parameter to provide a comment about the queue table. + +`primary_instance` + + `primary_instance` is accepted for compatibility and stored, but is ignored. + +`secondary_instance` + + `secondary_instance` is accepted for compatibility, but is ignored. + +**Example** + +The following command modifies a queue table named `work_order_table`: + +```text +EXEC DBMS_AQADM.ALTER_QUEUE_TABLE + (queue_table => 'work_order_table', comment => 'This queue table +contains work orders for the shipping department.'); +``` + +The queue table is named `work_order_table`; the command adds a comment to the definition of the queue table. diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/03_dbms_aqadm/03_create_queue.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/03_dbms_aqadm/03_create_queue.mdx new file mode 100644 index 00000000000..801c3e81d94 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/03_dbms_aqadm/03_create_queue.mdx @@ -0,0 +1,75 @@ +--- +title: "CREATE_QUEUE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/create_queue.html" +--- + +Use the `CREATE_QUEUE` procedure to create a queue in an existing queue table. The signature is: + +```text +CREATE_QUEUE( + IN VARCHAR2 + IN VARCHAR2, + IN BINARY_INTEGER DEFAULT NORMAL_QUEUE, + IN NUMBER DEFAULT 5, + IN NUMBER DEFAULT 0 + IN NUMBER DEFAULT 0, + IN BOOLEAN DEFAULT FALSE, + IN VARCHAR2 DEFAULT NULL, + IN BOOLEAN DEFAULT TRUE) +``` + +**Parameters** + +`queue_name` + + The name of the new queue. + +`queue_table` + + The name of the table in which the new queue will reside. + +`queue_type` + + The type of the new queue. The valid values for `queue_type` are: + + `DBMS_AQADM.NORMAL_QUEUE` – This value specifies a normal queue (the default). + + `DBMS_AQADM.EXCEPTION_QUEUE` – This value specifies that the new queue is an exception queue. An exception queue will support only dequeue operations. + +`max_retries` + + `max_retries` specifies the maximum number of attempts to remove a message with a dequeue statement. The value of `max_retries` is incremented with each `ROLLBACK` statement. When the number of failed attempts reaches the value specified by `max_retries`, the message is moved to the exception queue. The default value for a system table is `0`; the default value for a user created table is `5`. + +`retry_delay` + + `retry_delay` specifies the number of seconds until a message is scheduled for re-processing after a `ROLLBACK`. Specify `0` to indicate that the message should be retried immediately (the default). + +`retention_time` + + `retention_time` specifies the length of time (in seconds) that a message will be stored after being dequeued. You can also specify `0` (the default) to indicate the message should not be retained after dequeueing, or `INFINITE` to retain the message forever. + +`dependency_tracking` + + This parameter is accepted for compatibility and ignored. + +`comment` + + `comment` specifies a comment associated with the queue. + +`auto_commit` + + This parameter is accepted for compatibility and ignored. + +**Example** + +The following anonymous block creates a queue named `work_order` in the `work_order_table` table: + +```text +BEGIN +DBMS_AQADM.CREATE_QUEUE ( queue_name => 'work_order', queue_table => +'work_order_table', comment => 'This queue contains pending work orders.'); +END; +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/03_dbms_aqadm/04_create_queue_table.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/03_dbms_aqadm/04_create_queue_table.mdx new file mode 100644 index 00000000000..f5c7e82cba2 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/03_dbms_aqadm/04_create_queue_table.mdx @@ -0,0 +1,117 @@ +--- +title: "CREATE_QUEUE_TABLE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/create_queue_table.html" +--- + +Use the `CREATE_QUEUE_TABLE` procedure to create a queue table. The signature is: + +```text +CREATE_QUEUE_TABLE ( + IN VARCHAR2, + IN VARCHAR2, + IN VARCHAR2 DEFAULT NULL, + IN VARCHAR2 DEFAULT NULL, + IN BOOLEAN DEFAULT FALSE, + IN BINARY_INTEGER DEFAULT NONE, + IN VARCHAR2 DEFAULT NULL, + IN BOOLEAN DEFAULT TRUE, + IN BINARY_INTEGER DEFAULT 0, + IN BINARY_INTEGER DEFAULT 0, + IN VARCHAR2 DEFAULT NULL, + IN BOOLEAN DEFAULT FALSE) +``` + +**Parameters** + +`queue_table` + + The (optionally schema-qualified) name of the queue table. + +`queue_payload_type` + + The user-defined type of the data that will be stored in the queue table. Please note that to specify a `RAW` data type, you must create a user-defined type that identifies a `RAW` type. + +`storage_clause` + +Use the `storage_clause` parameter to specify attributes for the queue table. Please note that only the `TABLESPACE` option is enforced; all others are accepted for compatibility and ignored. Use the `TABLESPACE` clause to specify the name of a tablespace in which the table will be created. + + `storage_clause` may be one or more of the following: + +```text +TABLESPACE tablespace_name, PCTFREE integer, PCTUSED integer, +INITRANS integer, MAXTRANS integer or STORAGE storage_option. +``` + +`storage_option` may be one or more of the following: + +```text +MINEXTENTS integer, MAXEXTENTS integer, PCTINCREASE integer, INITIAL +size_clause, NEXT, FREELISTS integer, OPTIMAL size_clause, BUFFER_ +POOL {KEEP|RECYCLE|DEFAULT}. +``` + +`sort_list` + + `sort_list` controls the dequeueing order of the queue; specify the names of the column(s) that will be used to sort the queue (in ascending order). The currently accepted values are the following combinations of `enq_time` and `priority`: + +- `enq_time, priority` + +- `priority, enq_time` + +- `priority` + +- `enq_time` + +`multiple_consumers` + + `multiple_consumers` queue tables is not supported. + +`message_grouping` + + If specified, `message_grouping` must be `NONE`. + +`comment` + + Use the `comment` parameter to provide a comment about the queue table. + +`auto_commit` + + `auto_commit` is accepted for compatibility, but is ignored. + +`primary_instance` + + `primary_instance` is accepted for compatibility and stored, but is ignored. + +`secondary_instance` + + `secondary_instance` is accepted for compatibility, but is ignored. + +`compatible` + + `compatible` is accepted for compatibility, but is ignored. + +`secure` + + `secure` is accepted for compatibility, but is ignored. + +**Example** + +The following anonymous block first creates a type (`work_order`) with attributes that hold a name (a `VARCHAR2`), and a project description (a `TEXT`). The block then uses that type to create a queue table: + +```text +BEGIN + +CREATE TYPE work_order AS (name VARCHAR2, project TEXT, completed BOOLEAN); + +EXEC DBMS_AQADM.CREATE_QUEUE_TABLE + (queue_table => 'work_order_table', + queue_payload_type => 'work_order', + comment => 'Work order message queue table'); + +END; +``` + +The queue table is named `work_order_table`, and contains a payload of a type `work_order`. A comment notes that this is the `Work order message queue table`. diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/03_dbms_aqadm/05_drop_queue.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/03_dbms_aqadm/05_drop_queue.mdx new file mode 100644 index 00000000000..72b5c30d47c --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/03_dbms_aqadm/05_drop_queue.mdx @@ -0,0 +1,35 @@ +--- +title: "DROP_QUEUE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/drop_queue.html" +--- + +Use the `DROP_QUEUE` procedure to delete a queue. The signature is: + +```text +DROP_QUEUE( + IN VARCHAR2, + IN BOOLEAN DEFAULT TRUE) +``` + +**Parameters** + +`queue_name` + + The name of the queue that you wish to drop. + +`auto_commit` + + `auto_commit` is accepted for compatibility, but is ignored. + +**Example** + +The following anonymous block drops the queue named `work_order`: + +```text +BEGIN +DBMS_AQADM.DROP_QUEUE(queue_name => 'work_order'); +END; +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/03_dbms_aqadm/06_drop_queue_table.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/03_dbms_aqadm/06_drop_queue_table.mdx new file mode 100644 index 00000000000..5d3562e14b0 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/03_dbms_aqadm/06_drop_queue_table.mdx @@ -0,0 +1,44 @@ +--- +title: "DROP_QUEUE_TABLE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/drop_queue_table.html" +--- + +Use the `DROP_QUEUE_TABLE` procedure to delete a queue table. The signature is: + +```text +DROP_QUEUE_TABLE( + IN VARCHAR2, + IN BOOLEAN default FALSE, + IN BOOLEAN default TRUE) +``` + +**Parameters** + +`queue_table` + + The (optionally schema-qualified) name of the queue table. + +`force` + + The `force` keyword determines the behavior of the `DROP_QUEUE_TABLE` command when dropping a table that contain entries: + +- If the target table contains entries and force is `FALSE`, the command will fail, and the server will issue an error. + +- If the target table contains entries and force is `TRUE`, the command will drop the table and any dependent objects. + +`auto_commit` + + `auto_commit` is accepted for compatibility, but is ignored. + +**Example** + +The following anonymous block drops a table named `work_order_table`: + +```text +BEGIN + DBMS_AQADM.DROP_QUEUE_TABLE ('work_order_table', force => TRUE); +END; +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/03_dbms_aqadm/07_purge_queue_table.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/03_dbms_aqadm/07_purge_queue_table.mdx new file mode 100644 index 00000000000..7061fb9e725 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/03_dbms_aqadm/07_purge_queue_table.mdx @@ -0,0 +1,48 @@ +--- +title: "PURGE_QUEUE_TABLE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/purge_queue_table.html" +--- + +Use the `PURGE_QUEUE_TABLE` procedure to delete messages from a queue table. The signature is: + +```text +PURGE_QUEUE_TABLE( + IN VARCHAR2, + IN VARCHAR2, + IN aq$_purge_options_t) +``` + +**Parameters** + +`queue_table` + + `queue_table` specifies the name of the queue table from which you are deleting a message. + +`purge_condition` + + Use `purge_condition` to specify a condition (a SQL `WHERE` clause) that the server will evaluate when deciding which messages to purge. + +`purge_options` + + `purge_options` is an object of the type `aq$_purge_options_t`. An `aq$_purge_options_t` object contains: + +| Attribute | Type | Description | +| --------------- | ------- | ------------------------------------------------------------------------------------------------------------------- | +| `Block` | Boolean | Specify `TRUE` if an exclusive lock should be held on all queues within the table; the default is `FALSE`. | +| `delivery_mode` | INTEGER | `delivery_mode` specifies the type of message that will be purged. The only accepted value is `DBMS_AQ.PERSISTENT`. | + +**Example** + +The following anonymous block removes any messages from the `work_order_table` with a value in the `completed` column of `YES`: + +```text +DECLARE + purge_options dbms_aqadm.aq$_purge_options_t; +BEGIN + dbms_aqadm.purge_queue_table('work_order_table', 'completed = YES', +purge_options); + END; +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/03_dbms_aqadm/08_start_queue.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/03_dbms_aqadm/08_start_queue.mdx new file mode 100644 index 00000000000..255d0eb9fda --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/03_dbms_aqadm/08_start_queue.mdx @@ -0,0 +1,41 @@ +--- +title: "START_QUEUE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/start_queue.html" +--- + +Use the `START_QUEUE` procedure to make a queue available for enqueuing and dequeueing. The signature is: + +```text +START_QUEUE( + IN VARCHAR2, + IN BOOLEAN DEFAULT TRUE, + IN BOOLEAN DEFAULT TRUE) +``` + +**Parameters** + +`queue_name` + + `queue_name` specifies the name of the queue that you are starting. + +`enqueue` + + Specify `TRUE` to enable enqueueing (the default), or `FALSE` to leave the current setting unchanged. + +`dequeue` + + Specify `TRUE` to enable dequeueing (the default), or `FALSE` to leave the current setting unchanged. + +**Example** + +The following anonymous block makes a queue named `work_order` available for enqueueing: + +```text +BEGIN +DBMS_AQADM.START_QUEUE +(queue_name => 'work_order); +END; +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/03_dbms_aqadm/09_stop_queue.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/03_dbms_aqadm/09_stop_queue.mdx new file mode 100644 index 00000000000..d7f7ad97e81 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/03_dbms_aqadm/09_stop_queue.mdx @@ -0,0 +1,48 @@ +--- +title: "STOP_QUEUE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/stop_queue.html" +--- + +Use the `STOP_QUEUE` procedure to disable enqueuing or dequeueing on a specified queue. The signature is: + +```text +STOP_QUEUE( + IN VARCHAR2, + IN BOOLEAN DEFAULT TRUE, + IN BOOLEAN DEFAULT TRUE, + IN BOOLEAN DEFAULT TRUE) +``` + +**Parameters** + +`queue_name` + + `queue_name` specifies the name of the queue that you are stopping. + +`enqueue` + + Specify `TRUE` to disable enqueueing (the default), or `FALSE` to leave the current setting unchanged. + +`dequeue` + + Specify `TRUE` to disable dequeueing (the default), or `FALSE` to leave the current setting unchanged. + +`wait` + + Specify `TRUE` to instruct the server to wait for any uncompleted transactions to complete before applying the specified changes; while waiting to stop the queue, no transactions are allowed to enqueue or dequeue from the specified queue. Specify `FALSE` to stop the queue immediately. + +**Example** + +The following anonymous block disables enqueueing and dequeueing from the queue named `work_order`: + +```text +BEGIN +DBMS_AQADM.STOP_QUEUE(queue_name =>'work_order', enqueue=>TRUE, +dequeue=>TRUE, wait=>TRUE); +END; +``` + +Enqueueing and dequeueing will stop after any outstanding transactions complete. diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/03_dbms_aqadm/index.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/03_dbms_aqadm/index.mdx new file mode 100644 index 00000000000..eee3b80bf16 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/03_dbms_aqadm/index.mdx @@ -0,0 +1,53 @@ +--- +title: "DBMS_AQADM" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/dbms_aqadm.html" +--- + +EDB Postgres Advanced Server Advanced Queueing provides message queueing and message processing for the Advanced Server database. User-defined messages are stored in a queue; a collection of queues is stored in a queue table. Procedures in the `DBMS_AQADM` package create and manage message queues and queue tables. Use the `DBMS_AQ` package to add messages to a queue or remove messages from a queue, or register or unregister a PL/SQL callback procedure. + +Advanced Server also provides extended (non-compatible) functionality for the `DBMS_AQ` package with SQL commands, see the *Database Compatibility for Oracle Developers SQL Guide* for detailed information about the following SQL commands: + +- `ALTER QUEUE` +- `ALTER QUEUE TABLE` +- `CREATE QUEUE` +- `CREATE QUEUE TABLE` +- `DROP QUEUE` +- `DROP QUEUE TABLE` + +The `DBMS_AQADM` package provides procedures that allow you to create and manage queues and queue tables. + +| Function/Procedure | Return Type | Description | +| -------------------- | ----------- | ----------------------------------------------------------------- | +| `ALTER_QUEUE` | n/a | Modify an existing queue. | +| `ALTER_QUEUE_TABLE` | n/a | Modify an existing queue table. | +| `CREATE_QUEUE` | n/a | Create a queue. | +| `CREATE_QUEUE_TABLE` | n/a | Create a queue table. | +| `DROP_QUEUE` | n/a | Drop an existing queue. | +| `DROP_QUEUE_TABLE` | n/a | Drop an existing queue table. | +| `PURGE_QUEUE_TABLE` | n/a | Remove one or more messages from a queue table. | +| `START_QUEUE` | n/a | Make a queue available for enqueueing and dequeueing procedures. | +| `STOP_QUEUE` | n/a | Make a queue unavailable for enqueueing and dequeueing procedures | + +Advanced Server's implementation of `DBMS_AQADM` is a partial implementation when compared to Oracle's version. Only those functions and procedures listed in the table above are supported. + +Advanced Server supports use of the arguments listed below: + +| Constant | Description | For Parameters | +| --------------------------------------- | ----------------------------------------------------------- | --------------------------------- | +| `DBMS_AQADM.TRANSACTIONAL(1)` | This constant is defined, but will return an error if used. | `message_grouping` | +| `DBMS_AQADM.NONE(0)` | Use to specify message grouping for a queue table. | `message_grouping` | +| `DBMS_AQADM.NORMAL_QUEUE(0)` | Use with `create_queue` to `specify queue_type`. | `queue_type` | +| `DBMS_AQADM.EXCEPTION_QUEUE (1)` | Use with `create_queue` to specify `queue_type`. | `queue_type` | +| `DBMS_AQADM.INFINITE(-1)` | Use with `create_queue` to specify `retention_time`. | `retention_time` | +| `DBMS_AQADM.PERSISTENT (0)` | The message should be stored in a table. | `enqueue_options_t.delivery_mode` | +| `DBMS_AQADM.BUFFERED (1)` | This constant is defined, but will return an error if used. | `enqueue_options_t.delivery_mode` | +| `DBMS_AQADM.PERSISTENT_OR_BUFFERED (2)` | This constant is defined, but will return an error if used. | `enqueue_options_t.delivery_mode` | + +
+ +alter_queue alter_queue_table create_queue create_queue_table drop_queue drop_queue_table purge_queue_table start_queue stop_queue + +
diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/04_dbms_crypto/01_decrypt.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/04_dbms_crypto/01_decrypt.mdx new file mode 100644 index 00000000000..2a822fc109b --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/04_dbms_crypto/01_decrypt.mdx @@ -0,0 +1,98 @@ +--- +title: "DECRYPT" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/decrypt.html" +--- + +The `DECRYPT` function or procedure decrypts data using a user-specified cipher algorithm, key and optional initialization vector. The signature of the `DECRYPT` function is: + +```text +DECRYPT + ( IN RAW, IN INTEGER, IN RAW, IN RAW + DEFAULT NULL) RETURN RAW +``` + +The signature of the `DECRYPT` procedure is: + +```text +DECRYPT + ( INOUT BLOB, IN BLOB, IN INTEGER, IN RAW, + IN RAW DEFAULT NULL) +``` + +or + +```text +DECRYPT + ( INOUT CLOB, IN CLOB, IN INTEGER, IN RAW, + IN RAW DEFAULT NULL) +``` + +When invoked as a procedure, `DECRYPT` returns `BLOB` or `CLOB` data to a user-specified `BLOB`. + +**Parameters** + +`dst` + + `dst` specifies the name of a `BLOB` to which the output of the `DECRYPT` procedure will be written. The `DECRYPT` procedure will overwrite any existing data currently in `dst`. + +`src` + + `src` specifies the source data that will be decrypted. If you are invoking `DECRYPT` as a function, specify `RAW` data; if invoking `DECRYPT` as a procedure, specify `BLOB` or `CLOB` data. + +`typ` + + `typ` specifies the block cipher type and any modifiers. This should match the type specified when the `src` was encrypted. Advanced Server supports the following block cipher algorithms, modifiers and cipher suites: + +| **Block Cipher Algorithms** | | +| ---------------------------------- | ----------------------------------------------------------- | +| `ENCRYPT_DES` | `CONSTANT INTEGER := 1;` | +| `ENCRYPT_3DES` | `CONSTANT INTEGER := 3;` | +| `ENCRYPT_AES` | `CONSTANT INTEGER := 4;` | +| `ENCRYPT_AES128` | `CONSTANT INTEGER := 6;` | +| **Block Cipher Modifiers** | | +| `CHAIN_CBC` | `CONSTANT INTEGER := 256;` | +| `CHAIN_ECB` | `CONSTANT INTEGER := 768;` | +| **Block Cipher Padding Modifiers** | | +| `PAD_PKCS5` | `CONSTANT INTEGER := 4096;` | +| `PAD_NONE` | `CONSTANT INTEGER := 8192;` | +| **Block Cipher Suites** | | +| `DES_CBC_PKCS5` | `CONSTANT INTEGER := ENCRYPT_DES + CHAIN_CBC + PAD_PKCS5;` | +| `DES3_CBC_PKCS5` | `CONSTANT INTEGER := ENCRYPT_3DES + CHAIN_CBC + PAD_PKCS5;` | +| `AES_CBC_PKCS5` | `CONSTANT INTEGER := ENCRYPT_AES + CHAIN_CBC + PAD_PKCS5;` | + +`key` + + `key` specifies the user-defined decryption key. This should match the key specified when the `src` was encrypted. + +`iv` + + `iv` (optional) specifies an initialization vector. If an initialization vector was specified when the `src` was encrypted, you must specify an initialization vector when decrypting the `src`. The default is `NULL`. + +**Examples** + +The following example uses the `DBMS_CRYPTO.DECRYPT` function to decrypt an encrypted password retrieved from the `passwords` table: + +```text +CREATE TABLE passwords +( + principal VARCHAR2(90) PRIMARY KEY, -- username + ciphertext RAW(9) -- encrypted password +); + +CREATE FUNCTION get_password(username VARCHAR2) RETURN RAW AS + typ INTEGER := DBMS_CRYPTO.DES_CBC_PKCS5; + key RAW(128) := 'my secret key'; + iv RAW(100) := 'my initialization vector'; + password RAW(2048); +BEGIN + + SELECT ciphertext INTO password FROM passwords WHERE principal = username; + + RETURN dbms_crypto.decrypt(password, typ, key, iv); +END; +``` + +Note that when calling `DECRYPT`, you must pass the same cipher type, key value and initialization vector that was used when `ENCRYPTING` the target. diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/04_dbms_crypto/02_encrypt.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/04_dbms_crypto/02_encrypt.mdx new file mode 100644 index 00000000000..6152bf1f3f3 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/04_dbms_crypto/02_encrypt.mdx @@ -0,0 +1,95 @@ +--- +title: "ENCRYPT" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/encrypt.html" +--- + +The `ENCRYPT` function or procedure uses a user-specified algorithm, key, and optional initialization vector to encrypt `RAW`, `BLOB` or `CLOB` data. The signature of the `ENCRYPT` function is: + +```text +ENCRYPT + ( IN RAW, IN INTEGER, IN RAW, + IN RAW DEFAULT NULL) RETURN RAW +``` + +The signature of the `ENCRYPT` procedure is: + +```text +ENCRYPT + ( INOUT BLOB, IN BLOB, IN INTEGER, IN RAW, + IN RAW DEFAULT NULL) +``` + +or + +```text +ENCRYPT + ( INOUT BLOB, IN CLOB, IN INTEGER, IN RAW, + IN RAW DEFAULT NULL) +``` + +When invoked as a procedure, `ENCRYPT` returns `BLOB` or `CLOB` data to a user-specified `BLOB`. + +**Parameters** + +`dst` + + `dst` specifies the name of a `BLOB` to which the output of the `ENCRYPT` procedure will be written. The `ENCRYPT` procedure will overwrite any existing data currently in `dst`. + +`src` + + `src` specifies the source data that will be encrypted. If you are invoking `ENCRYPT` as a function, specify `RAW` data; if invoking `ENCRYPT` as a procedure, specify `BLOB` or `CLOB` data. + +`typ` + + `typ` specifies the block cipher type that will be used by `ENCRYPT`, and any modifiers. Advanced Server supports the block cipher algorithms, modifiers and cipher suites listed below: + +| **Block Cipher Algorithms** | | +| ---------------------------------- | ----------------------------------------------------------- | +| `ENCRYPT_DES` | `CONSTANT INTEGER := 1;` | +| `ENCRYPT_3DES` | `CONSTANT INTEGER := 3;` | +| `ENCRYPT_AES` | `CONSTANT INTEGER := 4;` | +| `ENCRYPT_AES128` | `CONSTANT INTEGER := 6;` | +| **Block Cipher Modifiers** | | +| `CHAIN_CBC` | `CONSTANT INTEGER := 256;` | +| `CHAIN_ECB` | `CONSTANT INTEGER := 768;` | +| **Block Cipher Padding Modifiers** | | +| `PAD_PKCS5` | `CONSTANT INTEGER := 4096;` | +| `PAD_NONE` | `CONSTANT INTEGER := 8192;` | +| **Block Cipher Suites** | | +| `DES_CBC_PKCS5` | `CONSTANT INTEGER := ENCRYPT_DES + CHAIN_CBC + PAD_PKCS5;` | +| `DES3_CBC_PKCS5` | `CONSTANT INTEGER := ENCRYPT_3DES + CHAIN_CBC + PAD_PKCS5;` | +| `AES_CBC_PKCS5` | `CONSTANT INTEGER := ENCRYPT_AES + CHAIN_CBC + PAD_PKCS5;` | + +`key` + + `key` specifies the encryption key. + +`iv` + + `iv` (optional) specifies an initialization vector. By default, `iv` is `NULL`. + +**Examples** + +The following example uses the `DBMS_CRYPTO.DES_CBC_PKCS5` Block Cipher Suite (a pre-defined set of algorithms and modifiers) to encrypt a value retrieved from the `passwords` table: + +```text +CREATE TABLE passwords +( + principal VARCHAR2(90) PRIMARY KEY, -- username + ciphertext RAW(9) -- encrypted password +); +CREATE PROCEDURE set_password(username VARCHAR2, cleartext RAW) AS + typ INTEGER := DBMS_CRYPTO.DES_CBC_PKCS5; + key RAW(128) := 'my secret key'; + iv RAW(100) := 'my initialization vector'; + encrypted RAW(2048); +BEGIN + encrypted := dbms_crypto.encrypt(cleartext, typ, key, iv); + UPDATE passwords SET ciphertext = encrypted WHERE principal = username; +END; +``` + +`ENCRYPT` uses a key value of `my secret key` and an initialization vector of `my initialization vector` when encrypting the `password`; specify the same key and initialization vector when decrypting the `password`. diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/04_dbms_crypto/03_hash.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/04_dbms_crypto/03_hash.mdx new file mode 100644 index 00000000000..32b5fdc2a02 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/04_dbms_crypto/03_hash.mdx @@ -0,0 +1,48 @@ +--- +title: "HASH" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/hash.html" +--- + +The `HASH` function uses a user-specified algorithm to return the hash value of a `RAW` or `CLOB` value. The `HASH` function is available in three forms: + +```text +HASH + ( IN RAW, IN INTEGER) RETURN RAW + +HASH + ( IN CLOB, IN INTEGER) RETURN RAW +``` + +**Parameters** + +`src` + + `src` specifies the value for which the hash value will be generated. You can specify a `RAW`, a `BLOB`, or a `CLOB` value. + +`typ` + + `typ` specifies the `HASH` function type. Advanced Server supports the `HASH` function types listed below: + +| **HASH Functions** | | +| ------------------ | ------------------------ | +| `HASH_MD4` | `CONSTANT INTEGER := 1;` | +| `HASH_MD5` | `CONSTANT INTEGER := 2;` | +| `HASH_SH1` | `CONSTANT INTEGER := 3;` | + +**Examples** + +The following example uses `DBMS_CRYPTO.HASH` to find the `md5` hash value of the string, `cleartext source`: + +```text +DECLARE + typ INTEGER := DBMS_CRYPTO.HASH_MD5; + hash_value RAW(100); +BEGIN + + hash_value := DBMS_CRYPTO.HASH('cleartext source', typ); + +END; +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/04_dbms_crypto/04_mac.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/04_dbms_crypto/04_mac.mdx new file mode 100644 index 00000000000..a726cb786a0 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/04_dbms_crypto/04_mac.mdx @@ -0,0 +1,54 @@ +--- +title: "MAC" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/mac.html" +--- + +The `MAC` function uses a user-specified `MAC` function to return the hashed `MAC` value of a `RAW` or `CLOB` value. The `MAC` function is available in three forms: + +```text +MAC + ( IN RAW, IN INTEGER, IN RAW) RETURN RAW + +MAC + ( IN CLOB, IN INTEGER, IN RAW) RETURN RAW +``` + +**Parameters** + +`src` + + `src` specifies the value for which the `MAC` value will be generated. Specify a `RAW`, `BLOB`, or `CLOB` value. + +`typ` + + `typ` specifies the `MAC` function used. Advanced Server supports the `MAC` functions listed below. + +| **MAC Functions** | | +| ----------------- | ------------------------ | +| `HMAC_MD5` | `CONSTANT INTEGER := 1;` | +| `HMAC_SH1` | `CONSTANT INTEGER := 2;` | + +`key` + + `key` specifies the key that will be used to calculate the hashed `MAC` value. + +**Examples** + +The following example finds the hashed `MAC` value of the string `cleartext source`: + +```text +DECLARE + typ INTEGER := DBMS_CRYPTO.HMAC_MD5; + key RAW(100) := 'my secret key'; + mac_value RAW(100); +BEGIN + + mac_value := DBMS_CRYPTO.MAC('cleartext source', typ, key); + +END; +``` + +`DBMS_CRYPTO.MAC` uses a key value of `my secret` key when calculating the `MAC` value of `cleartext source`. diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/04_dbms_crypto/05_randombytes.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/04_dbms_crypto/05_randombytes.mdx new file mode 100644 index 00000000000..980798e1957 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/04_dbms_crypto/05_randombytes.mdx @@ -0,0 +1,32 @@ +--- +title: "RANDOMBYTES" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/randombytes.html" +--- + +The `RANDOMBYTES` function returns a `RAW` value of the specified length, containing cryptographically random bytes. The signature is: + +```text +RANDOMBYTES + ( IN INTEGER) RETURNS RAW +``` + +**Parameter** + +`number_bytes` + + `number_bytes` specifies the number of random bytes to be returned + +**Examples** + +The following example uses `RANDOMBYTES` to return a value that is `1024` bytes long: + +```text +DECLARE + result RAW(1024); +BEGIN + result := DBMS_CRYPTO.RANDOMBYTES(1024); +END; +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/04_dbms_crypto/06_randominteger.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/04_dbms_crypto/06_randominteger.mdx new file mode 100644 index 00000000000..953cca23d6e --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/04_dbms_crypto/06_randominteger.mdx @@ -0,0 +1,26 @@ +--- +title: "RANDOMINTEGER" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/randominteger.html" +--- + +The `RANDOMINTEGER()` function returns a random `INTEGER` between `0` and `268,435,455`. The signature is: + +```text +RANDOMINTEGER() RETURNS INTEGER +``` + +**Examples** + +The following example uses the `RANDOMINTEGER` function to return a cryptographically strong random `INTEGER` value: + +```text +DECLARE + result INTEGER; +BEGIN + result := DBMS_CRYPTO.RANDOMINTEGER(); + DBMS_OUTPUT.PUT_LINE(result); +END; +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/04_dbms_crypto/07_randomnumber.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/04_dbms_crypto/07_randomnumber.mdx new file mode 100644 index 00000000000..a8653005477 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/04_dbms_crypto/07_randomnumber.mdx @@ -0,0 +1,26 @@ +--- +title: "RANDOMNUMBER" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/randomnumber.html" +--- + +The `RANDOMNUMBER()` function returns a random `NUMBER` between `0` and `268,435,455`. The signature is: + +```text +RANDOMNUMBER() RETURNS NUMBER +``` + +**Examples** + +The following example uses the `RANDOMNUMBER` function to return a cryptographically strong random number: + +```text +DECLARE + result NUMBER; +BEGIN + result := DBMS_CRYPTO.RANDOMNUMBER(); + DBMS_OUTPUT.PUT_LINE(result); +END; +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/04_dbms_crypto/index.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/04_dbms_crypto/index.mdx new file mode 100644 index 00000000000..a8ca3540d13 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/04_dbms_crypto/index.mdx @@ -0,0 +1,45 @@ +--- +title: "DBMS_CRYPTO" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/dbms_crypto.html" +--- + +The `DBMS_CRYPTO` package provides functions and procedures that allow you to encrypt or decrypt `RAW, BLOB` or `CLOB` data. You can also use `DBMS_CRYPTO` functions to generate cryptographically strong random values. + +The following table lists the `DBMS_CRYPTO` Functions and Procedures. + +| Function/Procedure | Return Type | Description | +| --------------------------------------- | ----------- | --------------------------------------------------------------------------------------------------- | +| `DECRYPT(src, typ, key, iv)` | `RAW` | Decrypts `RAW` data. | +| `DECRYPT(dst INOUT, src, typ, key, iv)` | N/A | Decrypts `BLOB` data. | +| `DECRYPT(dst INOUT, src, typ, key, iv)` | N/A | Decrypts `CLOB` data. | +| `ENCRYPT(src, typ, key, iv)` | `RAW` | Encrypts `RAW` data. | +| `ENCRYPT(dst INOUT, src, typ, key, iv)` | N/A | Encrypts `BLOB` data. | +| `ENCRYPT(dst INOUT, src, typ, key, iv)` | N/A | Encrypts `CLOB` data. | +| `HASH(src, typ)` | `RAW` | Applies a hash algorithm to `RAW` data. | +| `HASH(src)` | `RAW` | Applies a hash algorithm to `CLOB` data. | +| `MAC(src, typ, key)` | `RAW` | Returns the hashed `MAC` value of the given `RAW` data using the specified hash algorithm and key. | +| `MAC(src, typ, key)` | `RAW` | Returns the hashed `MAC` value of the given `CLOB` data using the specified hash algorithm and key. | +| `RANDOMBYTES(number_bytes)` | `RAW` | Returns a specified number of cryptographically strong random bytes. | +| `RANDOMINTEGER()` | `INTEGER` | Returns a random `INTEGER`. | +| `RANDOMNUMBER()` | `NUMBER` | Returns a random `NUMBER.` | + +`DBMS_CRYPTO` functions and procedures support the following error messages: + +`ORA-28239 - DBMS_CRYPTO.KeyNull` + +`ORA-28829 - DBMS_CRYPTO.CipherSuiteNull` + +`ORA-28827 - DBMS_CRYPTO.CipherSuiteInvalid` + +Unlike Oracle, Advanced Server will not return error `ORA-28233` if you re-encrypt previously encrypted information. + +Please note that `RAW` and `BLOB` are synonyms for the PostgreSQL `BYTEA` data type, and `CLOB` is a synonym for `TEXT`. + +
+ +decrypt encrypt hash mac randombytes randominteger randomnumber + +
diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/05_dbms_job/01_broken.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/05_dbms_job/01_broken.mdx new file mode 100644 index 00000000000..ea07992b686 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/05_dbms_job/01_broken.mdx @@ -0,0 +1,45 @@ +--- +title: "BROKEN" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/broken.html" +--- + +The `BROKEN` procedure sets the state of a job to either broken or not broken. A broken job cannot be executed except by using the `RUN` procedure. + +```text +BROKEN( BINARY_INTEGER, BOOLEAN [, DATE ]) +``` + +**Parameters** + +`job` + + Identifier of the job to be set as broken or not broken. + +`broken` + + If set to `TRUE` the job’s state is set to broken. If set to `FALSE` the job’s state is set to not broken. Broken jobs cannot be run except by using the `RUN` procedure. + +`next_date` + + Date/time when the job is to be run. The default is `SYSDATE`. + +**Examples** + +Set the state of a job with job identifier 104 to broken: + +```text +BEGIN + DBMS_JOB.BROKEN(104,true); +END; +``` + +Change the state back to not broken: + +```text +BEGIN + DBMS_JOB.BROKEN(104,false); +END; +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/05_dbms_job/02_change.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/05_dbms_job/02_change.mdx new file mode 100644 index 00000000000..7718400e8f7 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/05_dbms_job/02_change.mdx @@ -0,0 +1,51 @@ +--- +title: "CHANGE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/change.html" +--- + +The `CHANGE` procedure modifies certain job attributes including the stored procedure to be run, the next date/time the job is to be run, and how often it is to be run. + +```text +CHANGE( BINARY_INTEGER VARCHAR2, DATE, + VARCHAR2, BINARY_INTEGER, BOOLEAN) +``` + +**Parameters** + +`job` + + Identifier of the job to modify. + +`what` + + Stored procedure name. Set this parameter to null if the existing value is to remain unchanged. + +`next_date` + + Date/time when the job is to be run next. Set this parameter to null if the existing value is to remain unchanged. + +`interval` + + Date function that when evaluated, provides the next date/time the job is to run. Set this parameter to null if the existing value is to remain unchanged. + +`instance` + + This argument is ignored, but is included for compatibility. + +`force` + + This argument is ignored, but is included for compatibility. + +**Examples** + +Change the job to run next on December 13, 2007. Leave other parameters unchanged. + +```text +BEGIN + DBMS_JOB.CHANGE(104,NULL,TO_DATE('13-DEC-07','DD-MON-YY'),NULL, NULL, + NULL); +END; +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/05_dbms_job/03_interval.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/05_dbms_job/03_interval.mdx new file mode 100644 index 00000000000..5240748dea4 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/05_dbms_job/03_interval.mdx @@ -0,0 +1,33 @@ +--- +title: "INTERVAL" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/interval.html" +--- + +The `INTERVAL` procedure sets the frequency of how often a job is to be run. + +```text +INTERVAL( BINARY_INTEGER, VARCHAR2) +``` + +**Parameters** + +`job` + + Identifier of the job to modify. + +`interval` + + Date function that when evaluated, provides the next date/time the job is to be run. If `interval` is `NULL` and the job is complete, the job is removed from the queue. + +**Examples** + +Change the job to run once a week: + +```text +BEGIN + DBMS_JOB.INTERVAL(104,'SYSDATE + 7'); +END; +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/05_dbms_job/04_next_date.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/05_dbms_job/04_next_date.mdx new file mode 100644 index 00000000000..a7243eceb40 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/05_dbms_job/04_next_date.mdx @@ -0,0 +1,33 @@ +--- +title: "NEXT_DATE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/next_date.html" +--- + +The `NEXT_DATE` procedure sets the date/time of when the job is to be run next. + +```text +NEXT_DATE( BINARY_INTEGER, DATE) +``` + +**Parameters** + +`job` + + Identifier of the job whose next run date is to be set. + +`next_date` + + Date/time when the job is to be run next. + +**Examples** + +Change the job to run next on December 14, 2007: + +```text +BEGIN + DBMS_JOB.NEXT_DATE(104, TO_DATE('14-DEC-07','DD-MON-YY')); +END; +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/05_dbms_job/05_remove.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/05_dbms_job/05_remove.mdx new file mode 100644 index 00000000000..de817c8a22a --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/05_dbms_job/05_remove.mdx @@ -0,0 +1,29 @@ +--- +title: "REMOVE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/remove.html" +--- + +The `REMOVE` procedure deletes the specified job from the database. The job must be resubmitted using the `SUBMIT` procedure in order to have it executed again. Note that the stored procedure that was associated with the job is not deleted. + +```text +REMOVE( BINARY_INTEGER) +``` + +**Parameter** + +`job` + + Identifier of the job that is to be removed from the database. + +**Examples** + +Remove a job from the database: + +```text +BEGIN + DBMS_JOB.REMOVE(104); +END; +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/05_dbms_job/06_run.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/05_dbms_job/06_run.mdx new file mode 100644 index 00000000000..465309e4c23 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/05_dbms_job/06_run.mdx @@ -0,0 +1,29 @@ +--- +title: "RUN" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/run.html" +--- + +The `RUN` procedure forces the job to be run, even if its state is broken. + +```text +RUN( BINARY_INTEGER) +``` + +**Parameter** + +`job` + + Identifier of the job to be run. + +**Examples** + +Force a job to be run. + +```text +BEGIN + DBMS_JOB.RUN(104); +END; +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/05_dbms_job/07_submit.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/05_dbms_job/07_submit.mdx new file mode 100644 index 00000000000..95a1b199c10 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/05_dbms_job/07_submit.mdx @@ -0,0 +1,65 @@ +--- +title: "SUBMIT" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/submit.html" +--- + +The `SUBMIT` procedure creates a job definition and stores it in the database. A job consists of a job identifier, the stored procedure to be executed, when the job is to be first run, and a date function that calculates the next date/time the job is to be run. + +```text +SUBMIT( OUT BINARY_INTEGER, VARCHAR2 + [, DATE [, VARCHAR2 [, BOOLEAN ]]]) +``` + +**Parameters** + +`job` + + Identifier assigned to the job. + +`what` + + Name of the stored procedure to be executed by the job. + +`next_date` + + Date/time when the job is to be run next. The default is `SYSDATE`. + +`interval` + + Date function that when evaluated, provides the next date/time the job is to run. If `interval` is set to null, then the job is run only once. Null is the default. + +`no_parse` + + If set to `TRUE`, do not syntax-check the stored procedure upon job creation – check only when the job first executes. If set to `FALSE`, check the procedure upon job creation. The default is `FALSE`. + + **Note**: The `no_parse` option is not supported in this implementation of `SUBMIT()`. It is included for compatibility only. + +**Examples** + +The following example creates a job using stored procedure, `job_proc`. The job will execute immediately and run once a day thereafter as set by the `interval` parameter, `SYSDATE + 1`. + +```text +DECLARE + jobid INTEGER; +BEGIN + DBMS_JOB.SUBMIT(jobid,'job_proc;',SYSDATE, + 'SYSDATE + 1'); + DBMS_OUTPUT.PUT_LINE('jobid: ' || jobid); +END; + +jobid: 104 +``` + +The job immediately executes procedure, `job_proc`, populating table, `jobrun`, with a row: + +```text +SELECT * FROM jobrun; + + runtime +------------------------------------- + job_proc run at 2007-12-11 11:43:25 +(1 row) +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/05_dbms_job/08_what.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/05_dbms_job/08_what.mdx new file mode 100644 index 00000000000..9e324f51f85 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/05_dbms_job/08_what.mdx @@ -0,0 +1,33 @@ +--- +title: "WHAT" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/what.html" +--- + +The `WHAT` procedure changes the stored procedure that the job will execute. + +```text +WHAT( BINARY_INTEGER, VARCHAR2) +``` + +**Parameters** + +`job` + + Identifier of the job for which the stored procedure is to be changed. + +`what` + + Name of the stored procedure to be executed. + +**Examples** + +Change the job to run the `list_emp` procedure: + +```text +BEGIN + DBMS_JOB.WHAT(104,'list_emp;'); +END; +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/05_dbms_job/index.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/05_dbms_job/index.mdx new file mode 100644 index 00000000000..3f543d0a2ac --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/05_dbms_job/index.mdx @@ -0,0 +1,60 @@ +--- +title: "DBMS_JOB" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/dbms_job.html" +--- + +The `DBMS_JOB` package provides for the creation, scheduling, and managing of jobs. A job runs a stored procedure which has been previously stored in the database. The `SUBMIT` procedure is used to create and store a job definition. A job identifier is assigned to a job along with its associated stored procedure and the attributes describing when and how often the job is to be run. + +This package relies on the `pgAgent` scheduler. By default, the Advanced Server installer installs `pgAgent`, but you must start the `pgAgent` service manually prior to using `DBMS_JOB`. If you attempt to use this package to schedule a job after un-installing `pgAgent, DBMS_JOB` will throw an error. `DBMS_JOB` verifies that `pgAgent` is installed, but does not verify that the service is running. + +The following table lists the supported `DBMS_JOB` procedures: + +| Function/Procedure | Return Type | Description | +| ---------------------------------------------------------------- | ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `BROKEN(job, broken [, next_date ])` | n/a | Specify that a given job is either broken or not broken. | +| `CHANGE(job, what, next_date, interval, instance, force>)` | n/a | Change the job’s parameters. | +| `INTERVAL(job, interval)` | n/a | Set the execution frequency by means of a date function that is recalculated each time the job is run. This value becomes the next date/time for execution. | +| `NEXT_DATE(job, next_date)` | n/a | Set the next date/time the job is to be run. | +| `REMOVE(job)` | n/a | Delete the job definition from the database. | +| `RUN(job)` | n/a | Forces execution of a job even if it is marked broken. | +| `SUBMIT(job OUT, what [, next_date [, interval [, no_parse ]]])` | n/a | Creates a job and stores its definition in the database. | +| `WHAT(job, what)` | n/a | Change the stored procedure run by a job. | + +Advanced Server's implementation of `DBMS_JOB` is a partial implementation when compared to Oracle's version. Only those functions and procedures listed in the table above are supported. + +Before using `DBMS_JOB`, a database superuser must create the `pgAgent` extension. Use the `psql` client to connect to a database and invoke the command: + +```text +CREATE EXTENSION pgagent; +``` + +When and how often a job is run is dependent upon two interacting parameters – `next_date` and `interval`. The `next_date` parameter is a date/time value that specifies the next date/time when the job is to be executed. The `interval` parameter is a string that contains a date function that evaluates to a date/time value. + +Just prior to any execution of the job, the expression in the `interval` parameter is evaluated. The resulting value replaces the `next_date` value stored with the job. The job is then executed. In this manner, the expression in `interval` is repeatedly re-evaluated prior to each job execution, supplying the `next_date` date/time for the next execution. + +!!! Note + The database user must be the same that created a job and schedule to start the `pgAgent` server and execute the job. + +The following examples use the following stored procedure, `job_proc`, which simply inserts a timestamp into table, `jobrun`, containing a single `VARCHAR2` column. + +```text +CREATE TABLE jobrun ( + runtime VARCHAR2(40) +); + +CREATE OR REPLACE PROCEDURE job_proc +IS +BEGIN + INSERT INTO jobrun VALUES ('job_proc run at ' || TO_CHAR(SYSDATE, + 'yyyy-mm-dd hh24:mi:ss')); +END; +``` + +
+ +broken change interval next_date remove run submit what + +
diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/06_dbms_lob/01_append.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/06_dbms_lob/01_append.mdx new file mode 100644 index 00000000000..17591dfe6ca --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/06_dbms_lob/01_append.mdx @@ -0,0 +1,23 @@ +--- +title: "APPEND" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/append.html" +--- + +The `APPEND` procedure provides the capability to append one large object to another. Both large objects must be of the same type. + +```text +APPEND( IN OUT { BLOB | CLOB }, { BLOB | CLOB }) +``` + +**Parameters** + +`dest_lob` + + Large object locator for the destination object. Must be the same data type as `src_lob`. + +`src_lob` + + Large object locator for the source object. Must be the same data type as `dest_lob`. diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/06_dbms_lob/02_compare.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/06_dbms_lob/02_compare.mdx new file mode 100644 index 00000000000..fe149fb3ee8 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/06_dbms_lob/02_compare.mdx @@ -0,0 +1,41 @@ +--- +title: "COMPARE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/compare.html" +--- + +The `COMPARE` procedure performs an exact byte-by-byte comparison of two large objects for a given length at given offsets. The large objects being compared must be the same data type. + +```text + INTEGER COMPARE( { BLOB | CLOB }, + { BLOB | CLOB } + [, INTEGER [, INTEGER [, INTEGER ]]]) +``` + +**Parameters** + +`lob_1` + + Large object locator of the first large object to be compared. Must be the same data type as `lob_2`. + +`lob_2` + + Large object locator of the second large object to be compared. Must be the same data type as `lob_1`. + +`amount` + + If the data type of the large objects is `BLOB`, then the comparison is made for `amount` bytes. If the data type of the large objects is `CLOB`, then the comparison is made for `amount` characters. The default is the maximum size of a large object. + +`offset_1` + + Position within the first large object to begin the comparison. The first byte/character is offset 1. The default is 1. + +`offset_2` + + Position within the second large object to begin the comparison. The first byte/character is offset 1. The default is 1. + +`status` + + Zero if both large objects are exactly the same for the specified length for the specified offsets. Non-zero, if the objects are not the same. `NULL` if `amount`, `offset_1`, or `offset_2` are less than zero. diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/06_dbms_lob/03_converttoblob.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/06_dbms_lob/03_converttoblob.mdx new file mode 100644 index 00000000000..9079205ea70 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/06_dbms_lob/03_converttoblob.mdx @@ -0,0 +1,62 @@ +--- +title: "CONVERTTOBLOB" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/converttoblob.html" +--- + +The `CONVERTTOBLOB` procedure provides the capability to convert character data to binary. + +```text +CONVERTTOBLOB( IN OUT BLOB, CLOB, + INTEGER, IN OUT INTEGER, + IN OUT INTEGER, NUMBER, + IN OUT INTEGER, OUT INTEGER) +``` + +**Parameters** + +`dest_lob` + + `BLOB` large object locator to which the character data is to be converted. + +`src_clob` + + `CLOB` large object locator of the character data to be converted. + +`amount` + + Number of characters of `src_clob` to be converted. + +`dest_offset IN` + + Position in bytes in the destination `BLOB` where writing of the source `CLOB` should begin. The first byte is offset 1. + +`dest_offset OUT` + + Position in bytes in the destination `BLOB` after the write operation completes. The first byte is offset 1. + +`src_offset IN` + + Position in characters in the source `CLOB` where conversion to the destination `BLOB` should begin. The first character is offset 1. + +`src_offset OUT` + + Position in characters in the source `CLOB` after the conversion operation completes. The first character is offset 1. + +`blob_csid` + + Character set ID of the converted, destination `BLOB`. + +`lang_context IN` + + Language context for the conversion. The default value of 0 is typically used for this setting. + +`lang_context OUT` + + Language context after the conversion completes. + +`warning` + + 0 if the conversion was successful, 1 if an inconvertible character was encountered. diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/06_dbms_lob/04_converttoclob.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/06_dbms_lob/04_converttoclob.mdx new file mode 100644 index 00000000000..acf1b735881 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/06_dbms_lob/04_converttoclob.mdx @@ -0,0 +1,62 @@ +--- +title: "CONVERTTOCLOB" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/converttoclob.html" +--- + +The `CONVERTTOCLOB` procedure provides the capability to convert binary data to character. + +```text +CONVERTTOCLOB( IN OUT CLOB, BLOB, + INTEGER, IN OUT INTEGER, + IN OUT INTEGER, NUMBER, + IN OUT INTEGER, OUT INTEGER) +``` + +**Parameters** + +`dest_lob` + + `CLOB` large object locator to which the binary data is to be converted. + +`src_blob` + + `BLOB` large object locator of the binary data to be converted. + +`amount` + + Number of bytes of `src_blob` to be converted. + +`dest_offset IN` + + Position in characters in the destination `CLOB` where writing of the source `BLOB` should begin. The first character is offset 1. + +`dest_offset OUT` + + Position in characters in the destination `CLOB` after the write operation completes. The first character is offset 1. + +`src_offset IN` + + Position in bytes in the source `BLOB` where conversion to the destination `CLOB` should begin. The first byte is offset 1. + +`src_offset OUT` + + Position in bytes in the source `BLOB` after the conversion operation completes. The first byte is offset 1. + +`blob_csid` + + Character set ID of the converted, destination `CLOB`. + +`lang_context IN` + + Language context for the conversion. The default value of 0 is typically used for this setting. + +`lang_context OUT` + + Language context after the conversion completes. + +`warning` + + 0 if the conversion was successful, 1 if an inconvertible character was encountered. diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/06_dbms_lob/05_copy.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/06_dbms_lob/05_copy.mdx new file mode 100644 index 00000000000..5368bf6eaec --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/06_dbms_lob/05_copy.mdx @@ -0,0 +1,38 @@ +--- +title: "COPY" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/copy.html" +--- + +The `COPY` procedure provides the capability to copy one large object to another. The source and destination large objects must be the same data type. + +```text +COPY( IN OUT { BLOB | CLOB }, +{ BLOB | CLOB }, + INTEGER + [, INTEGER [, INTEGER ]]) +``` + +**Parameters** + +`dest_lob` + + Large object locator of the large object to which `src_lob` is to be copied. Must be the same data type as `src_lob`. + +`src_lob` + + Large object locator of the large object to be copied to `dest_lob`. Must be the same data type as `dest_lob`. + +`amount` + + Number of bytes/characters of `src_lob` to be copied. + +`dest_offset` + + Position in the destination large object where writing of the source large object should begin. The first position is offset 1. The default is 1. + +`src_offset` + + Position in the source large object where copying to the destination large object should begin. The first position is offset 1. The default is 1. diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/06_dbms_lob/06_erase.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/06_dbms_lob/06_erase.mdx new file mode 100644 index 00000000000..e9f196b273c --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/06_dbms_lob/06_erase.mdx @@ -0,0 +1,32 @@ +--- +title: "ERASE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/erase.html" +--- + +The `ERASE` procedure provides the capability to erase a portion of a large object. To erase a large object means to replace the specified portion with zero-byte fillers for `BLOBs` or with spaces for `CLOBs`. The actual size of the large object is not altered. + +```text +ERASE( IN OUT { BLOB | CLOB }, IN OUT INTEGER + [, INTEGER ]) +``` + +**Parameters** + +`lob_loc` + + Large object locator of the large object to be erased. + +`amount IN` + + Number of bytes/characters to be erased. + +`amount OUT` + + Number of bytes/characters actually erased. This value can be smaller than the input value if the end of the large object is reached before `amount` bytes/characters have been erased. + +`offset` + + Position in the large object where erasing is to begin. The first byte/character is position 1. The default is 1. diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/06_dbms_lob/07_get_storage_limit.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/06_dbms_lob/07_get_storage_limit.mdx new file mode 100644 index 00000000000..a6223b79e70 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/06_dbms_lob/07_get_storage_limit.mdx @@ -0,0 +1,25 @@ +--- +title: "GET_STORAGE_LIMIT" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/get_storage_limit.html" +--- + +The `GET_STORAGE_LIMIT` function returns the limit on the largest allowable large object. + +```text + INTEGER GET_STORAGE_LIMIT( BLOB) + + INTEGER GET_STORAGE_LIMIT( CLOB) +``` + +**Parameters** + +`size` + + Maximum allowable size of a large object in this database. + +`lob_loc` + + This parameter is ignored, but is included for compatibility. diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/06_dbms_lob/08_getlength.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/06_dbms_lob/08_getlength.mdx new file mode 100644 index 00000000000..06cf2c697a8 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/06_dbms_lob/08_getlength.mdx @@ -0,0 +1,25 @@ +--- +title: "GETLENGTH" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/getlength.html" +--- + +The `GETLENGTH` function returns the length of a large object. + +```text + INTEGER GETLENGTH( BLOB) + + INTEGER GETLENGTH( CLOB) +``` + +**Parameters** + +`lob_loc` + + Large object locator of the large object whose length is to be obtained. + +`amount` + + Length of the large object in bytes for `BLOBs` or characters for `CLOBs`. diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/06_dbms_lob/09_instr.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/06_dbms_lob/09_instr.mdx new file mode 100644 index 00000000000..dee4d8c1bda --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/06_dbms_lob/09_instr.mdx @@ -0,0 +1,36 @@ +--- +title: "INSTR" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/instr.html" +--- + +The `INSTR` function returns the location of the nth occurrence of a given pattern within a large object. + +```text + INTEGER INSTR( { BLOB | CLOB }, + { RAW | VARCHAR2 } [, INTEGER [, INTEGER ]]) +``` + +**Parameters** + +`lob_loc` + + Large object locator of the large object in which to search for pattern. + +`pattern` + + Pattern of bytes or characters to match against the large object, `lob. pattern` must be `RAW` if `lob_loc` is a `BLOB`. pattern must be `VARCHAR2` if `lob_loc` is a `CLOB`. + +`offset` + + Position within `lob_loc` to start search for `pattern`. The first byte/character is position 1. The default is 1. + +`nth` + + Search for `pattern`, `nth` number of times starting at the position given by `offset`. The default is 1. + +`position` + + Position within the large object where `pattern` appears the nth time specified by `nth` starting from the position given by `offset`. diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/06_dbms_lob/10_read.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/06_dbms_lob/10_read.mdx new file mode 100644 index 00000000000..603699500bd --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/06_dbms_lob/10_read.mdx @@ -0,0 +1,36 @@ +--- +title: "READ" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/read.html" +--- + +The `READ` procedure provides the capability to read a portion of a large object into a buffer. + +```text +READ( { BLOB | CLOB }, IN OUT BINARY_INTEGER, + INTEGER, OUT { RAW | VARCHAR2 }) +``` + +**Parameters** + +`lob_loc` + + Large object locator of the large object to be read. + +`amount IN` + + Number of bytes/characters to read. + +`amount OUT` + + Number of bytes/characters actually read. If there is no more data to be read, then `amount` returns 0 and a `DATA_NOT_FOUND` exception is thrown. + +`offset` + + Position to begin reading. The first byte/character is position 1. + +`buffer` + + Variable to receive the large object. If `lob_loc` is a `BLOB`, then `buffer` must be `RAW`. If `lob_loc` is a `CLOB`, then `buffer` must be `VARCHAR2`. diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/06_dbms_lob/11_substr.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/06_dbms_lob/11_substr.mdx new file mode 100644 index 00000000000..a8b713a6983 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/06_dbms_lob/11_substr.mdx @@ -0,0 +1,32 @@ +--- +title: "SUBSTR" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/substr.html" +--- + +The `SUBSTR` function provides the capability to return a portion of a large object. + +```text + { RAW | VARCHAR2 } SUBSTR( { BLOB | CLOB } + [, INTEGER [, INTEGER ]]) +``` + +**Parameters** + +`lob_loc` + + Large object locator of the large object to be read. + +`amount` + + Number of bytes/characters to be returned. Default is 32,767. + +`offset` + + Position within the large object to begin returning data. The first byte/character is position 1. The default is 1. + +`data` + + Returned portion of the large object to be read. If `lob_loc` is a `BLOB`, the return data type is `RAW`. If `lob_loc` is a `CLOB`, the return data type is `VARCHAR2`. diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/06_dbms_lob/12_trim.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/06_dbms_lob/12_trim.mdx new file mode 100644 index 00000000000..a7510fe814c --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/06_dbms_lob/12_trim.mdx @@ -0,0 +1,23 @@ +--- +title: "TRIM" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/trim.html" +--- + +The `TRIM` procedure provides the capability to truncate a large object to the specified length. + +```text +TRIM( IN OUT { BLOB | CLOB }, INTEGER) +``` + +**Parameters** + +`lob_loc` + + Large object locator of the large object to be trimmed. + +`newlen` + + Number of bytes/characters to which the large object is to be trimmed. diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/06_dbms_lob/13_write.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/06_dbms_lob/13_write.mdx new file mode 100644 index 00000000000..a989d3ea709 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/06_dbms_lob/13_write.mdx @@ -0,0 +1,33 @@ +--- +title: "WRITE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/write.html" +--- + +The `WRITE` procedure provides the capability to write data into a large object. Any existing data in the large object at the specified offset for the given length is overwritten by data given in the buffer. + +```text +WRITE( IN OUT { BLOB | CLOB }, + BINARY_INTEGER, + INTEGER, { RAW | VARCHAR2 }) +``` + +**Parameters** + +`lob_loc` + + Large object locator of the large object to be written. + +`amount` + + The number of bytes/characters in `buffer` to be written to the large object. + +`offset` + + The offset in bytes/characters from the beginning of the large object (origin is 1) for the write operation to begin. + +`buffer` + + Contains data to be written to the large object. If `lob_loc` is a `BLOB`, then `buffer` must be `RAW`. If `lob_loc` is a `CLOB`, then `buffer` must be `VARCHAR2`. diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/06_dbms_lob/14_writeappend.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/06_dbms_lob/14_writeappend.mdx new file mode 100644 index 00000000000..d05524a6238 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/06_dbms_lob/14_writeappend.mdx @@ -0,0 +1,28 @@ +--- +title: "WRITEAPPEND" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/writeappend.html" +--- + +The `WRITEAPPEND` procedure provides the capability to add data to the end of a large object. + +```text +WRITEAPPEND( IN OUT { BLOB | CLOB }, + BINARY_INTEGER, { RAW | VARCHAR2 }) +``` + +**Parameters** + +`lob_loc` + + Large object locator of the large object to which data is to be appended. + +`amount` + + Number of bytes/characters from `buffer` to be appended the large object. + +`buffer` + + Data to be appended to the large object. If `lob_loc` is a `BLOB`, then `buffer` must be `RAW`. If `lob_loc` is a `CLOB`, then `buffer` must be `VARCHAR2`. diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/06_dbms_lob/index.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/06_dbms_lob/index.mdx new file mode 100644 index 00000000000..3fc12d68d64 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/06_dbms_lob/index.mdx @@ -0,0 +1,58 @@ +--- +title: "DBMS_LOB" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/dbms_lob.html" +--- + +The `DBMS_LOB` package provides the capability to operate on large objects. The following table lists the supported functions and procedures: + +| Function/Procedure | Return Type | Description | +| -------------------------------------------------------------------------------------------------------------------------------------- | --------------- | -------------------------------------------------------------------------------------------- | +| `APPEND(dest_lob IN OUT, src_lob)` | n/a | Appends one large object to another. | +| `COMPARE(lob_1, lob_2 [, amount [, offset_1 [, offset_2 ]]])` | `INTEGER` | Compares two large objects. | +| `CONVERTOBLOB(dest_lob IN OUT, src_clob, amount, dest_offset IN OUT, src_offset IN OUT, blob_csid, lang_context IN OUT, warning OUT)` | n/a | Converts character data to binary. | +| `CONVERTTOCLOB(dest_lob IN OUT, src_blob, amount, dest_offset IN OUT, src_offset IN OUT, blob_csid, lang_context IN OUT, warning OUT)` | n/a | Converts binary data to character. | +| `COPY(dest_lob IN OUT, src_lob, amount [, dest_offset [, src_offset ]])` | n/a | Copies one large object to another. | +| `ERASE(lob_loc IN OUT, amount IN OUT [, offset ])` | n/a | Erase a large object. | +| `GET_STORAGE_LIMIT(lob_loc)` | `INTEGER` | Get the storage limit for large objects. | +| `GETLENGTH(lob_loc)` | `INTEGER` | Get the length of the large object. | +| `INSTR(lob_loc, pattern [, offset [, nth ]])` | `INTEGER` | Get the position of the nth occurrence of a pattern in the large object starting at `offset` | +| `READ(lob_loc, amount IN OUT, offset, buffer OUT)` | n/a | Read a large object. | +| `SUBSTR(lob_loc [, amount [, offset ]])` | `RAW, VARCHAR2` | Get part of a large object. | +| `TRIM(lob_loc IN OUT, newlen)` | n/a | Trim a large object to the specified length. | +| `WRITE(lob_loc IN OUT, amount, offset, buffer)` | n/a | Write data to a large object. | +| `WRITEAPPEND(lob_loc IN OUT, amount, buffer)` | n/a | Write data from the buffer to the end of a large object. | + +Advanced Server's implementation of `DBMS_LOB` is a partial implementation when compared to Oracle's version. Only those functions and procedures listed in the table above are supported. + +The following table lists the public variables available in the package. + +| **Public Variables** | **Data Type** | **Value** | +| ------------------------- | ------------- | ------------ | +| `compress off` | `INTEGER` | `0` | +| `compress_on` | `INTEGER` | `1` | +| `deduplicate_off` | `INTEGER` | `0` | +| `deduplicate_on` | `INTEGER` | `4` | +| `default_csid` | `INTEGER` | `0` | +| `default_lang_ctx` | `INTEGER` | `0` | +| `encrypt_off` | `INTEGER` | `0` | +| `encrypt_on` | `INTEGER` | `1` | +| `file_readonly` | `INTEGER` | `0` | +| `lobmaxsize` | `INTEGER` | `1073741823` | +| `lob_readonly` | `INTEGER` | `0` | +| `lob_readwrite` | `INTEGER` | `1` | +| `no_warning` | `INTEGER` | `0` | +| `opt_compress` | `INTEGER` | `1` | +| `opt_deduplicate` | `INTEGER` | `4` | +| `opt_encrypt` | `INTEGER` | `2` | +| `warn_inconvertible_char` | `INTEGER` | `1` | + +In the following sections, lengths and offsets are measured in bytes if the large objects are `BLOBs`. Lengths and offsets are measured in characters if the large objects are `CLOBs`. + +
+ +append compare converttoblob converttoclob copy erase get_storage_limit getlength instr read substr trim write writeappend + +
diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/07_dbms_lock.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/07_dbms_lock.mdx new file mode 100644 index 00000000000..7fd7ea735d7 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/07_dbms_lock.mdx @@ -0,0 +1,29 @@ +--- +title: "DBMS_LOCK" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/dbms_lock.html" +--- + +Advanced Server provides support for the `DBMS_LOCK.SLEEP` procedure. + +| Function/Procedure | Return Type | Description | +| ------------------ | ----------- | --------------------------------------------------------- | +| `SLEEP(seconds)` | n/a | Suspends a session for the specified number of `seconds`. | + +Advanced Server's implementation of `DBMS_LOCK` is a partial implementation when compared to Oracle's version. Only `DBMS_LOCK.SLEEP` is supported. + +## SLEEP + +The `SLEEP` procedure suspends the current session for the specified number of seconds. + +```text +SLEEP( NUMBER) +``` + +**Parameters** + +`seconds` + + `seconds` specifies the number of seconds for which you wish to suspend the session. `seconds` can be a fractional value; for example, enter `1.75` to specify one and three-fourths of a second. diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/08_dbms_mview/01_get_mv_dependencies.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/08_dbms_mview/01_get_mv_dependencies.mdx new file mode 100644 index 00000000000..5dd34b6c7c4 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/08_dbms_mview/01_get_mv_dependencies.mdx @@ -0,0 +1,40 @@ +--- +title: "GET_MV_DEPENDENCIES" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/get_mv_dependencies.html" +--- + +When given the name of a materialized view, `GET_MV_DEPENDENCIES` returns a list of items that depend on the specified view. The signature is: + +```text +GET_MV_DEPENDENCIES( + IN VARCHAR2, + OUT VARCHAR2); +``` + +**Parameters** + +`list` + + `list` specifies the name of a materialized view, or a comma-separated list of materialized view names. + +`deplist` + + `deplist` is a comma-separated list of schema-qualified dependencies. `deplist` is a `VARCHAR2` value. + +**Examples** + +The following example: + +```text +DECLARE + deplist VARCHAR2(1000); +BEGIN + DBMS_MVIEW.GET_MV_DEPENDENCIES('public.emp_view', deplist); + DBMS_OUTPUT.PUT_LINE('deplist: ' || deplist); +END; +``` + +Displays a list of the dependencies on a materialized view named `public.emp_view`. diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/08_dbms_mview/02_refresh.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/08_dbms_mview/02_refresh.mdx new file mode 100644 index 00000000000..53059a30189 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/08_dbms_mview/02_refresh.mdx @@ -0,0 +1,93 @@ +--- +title: "REFRESH" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/refresh.html" +--- + +Use the `REFRESH` procedure to refresh all views specified in either a comma-separated list of view names, or a table of `DBMS_UTILITY.UNCL_ARRAY` values. The procedure has two signatures; use the first form when specifying a comma-separated list of view names: + +```text +REFRESH( + IN VARCHAR2, + IN VARCHAR2 DEFAULT NULL, + IN VARCHAR2 DEFAULT NULL, + IN BOOLEAN DEFAULT TRUE, + IN BOOLEAN DEFAULT FALSE, + IN NUMBER DEFAULT 1, + IN NUMBER DEFAULT 0, + IN NUMBER DEFAULT 0, + IN BOOLEAN DEFAULT TRUE, + IN BOOLEAN DEFAULT FALSE); +``` + +Use the second form to specify view names in a table of `DBMS_UTILITY.UNCL_ARRAY` values: + +```text +REFRESH( + IN OUT DBMS_UTILITY.UNCL_ARRAY, + IN VARCHAR2 DEFAULT NULL, + IN VARCHAR2 DEFAULT NULL, + IN BOOLEAN DEFAULT TRUE, + IN BOOLEAN DEFAULT FALSE, + IN NUMBER DEFAULT 1, + IN NUMBER DEFAULT 0, + IN NUMBER DEFAULT 0, + IN BOOLEAN DEFAULT TRUE, + IN BOOLEAN DEFAULT FALSE); +``` + +**Parameters** + +`list` + + `list` is a `VARCHAR2` value that specifies the name of a materialized view, or a comma-separated list of materialized view names. The names may be schema-qualified. + +`tab` + + `tab` is a table of `DBMS_UTILITY.UNCL_ARRAY` values that specify the name (or names) of a materialized view. + +`method` + + `method` is a `VARCHAR2` value that specifies the refresh method that will be applied to the specified view (or views). The only supported method is `C`; this performs a complete refresh of the view. + +`rollback_seg` + + `rollback_seg` is accepted for compatibility and ignored. The default is `NULL`. + +`push_deferred_rpc` + + `push_deferred_rpc` is accepted for compatibility and ignored. The default is `TRUE`. + +`refresh_after_errors` + + `refresh_after_errors` is accepted for compatibility and ignored. The default is `FALSE`. + +`purge_option` + + `purge_option` is accepted for compatibility and ignored. The default is `1`. + +`parallelism` + + `parallelism` is accepted for compatibility and ignored. The default is `0`. + +`heap_size IN NUMBER DEFAULT 0`, + + `heap_size` is accepted for compatibility and ignored. The default is `0`. + +`atomic_refresh` + + `atomic_refresh` is accepted for compatibility and ignored. The default is `TRUE`. + +`nested` + + `nested` is accepted for compatibility and ignored. The default is `FALSE`. + +**Examples** + +The following example uses `DBMS_MVIEW.REFRESH` to perform a `COMPLETE` refresh on the `public.emp_view` materialized view: + +```text +EXEC DBMS_MVIEW.REFRESH(list => 'public.emp_view', method => 'C'); +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/08_dbms_mview/03_refresh_all_mviews.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/08_dbms_mview/03_refresh_all_mviews.mdx new file mode 100644 index 00000000000..c080ac9f30c --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/08_dbms_mview/03_refresh_all_mviews.mdx @@ -0,0 +1,54 @@ +--- +title: "REFRESH_ALL_MVIEWS" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/refresh_all_mviews.html" +--- + +Use the `REFRESH_ALL_MVIEWS` procedure to refresh any materialized views that have not been refreshed since the table or view on which the view depends has been modified. The signature is: + +```text +REFRESH_ALL_MVIEWS( + OUT BINARY_INTEGER, + IN VARCHAR2 DEFAULT NULL, + IN VARCHAR2 DEFAULT NULL, + IN BOOLEAN DEFAULT FALSE, + IN BOOLEAN DEFAULT TRUE); +``` + +**Parameters** + +`number_of_failures` + + `number_of_failures` is a `BINARY_INTEGER` that specifies the number of failures that occurred during the refresh operation. + +`method` + + `method` is a `VARCHAR2` value that specifies the refresh method that will be applied to the specified view (or views). The only supported method is `C;` this performs a complete refresh of the view. + +`rollback_seg` + + `rollback_seg` is accepted for compatibility and ignored. The default is `NULL`. + +`refresh_after_errors` + + `refresh_after_errors` is accepted for compatibility and ignored. The default is `FALSE`. + +`atomic_refresh` + + `atomic_refresh` is accepted for compatibility and ignored. The default is `TRUE`. + +**Examples** + +The following example performs a `COMPLETE` refresh on all materialized views: + +```text +DECLARE + errors INTEGER; +BEGIN + DBMS_MVIEW.REFRESH_ALL_MVIEWS(errors, method => 'C'); +END; +``` + +Upon completion, `errors` contains the number of failures. diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/08_dbms_mview/04_refresh_dependent.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/08_dbms_mview/04_refresh_dependent.mdx new file mode 100644 index 00000000000..ba3cacd3e11 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/08_dbms_mview/04_refresh_dependent.mdx @@ -0,0 +1,84 @@ +--- +title: "REFRESH_DEPENDENT" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/refresh_dependent.html" +--- + +Use the `REFRESH_DEPENDENT` procedure to refresh all material views that are dependent on the views specified in the call to the procedure. You can specify a comma-separated list or provide the view names in a table of `DBMS_UTILITY.UNCL_ARRAY` values. + +Use the first form of the procedure to refresh all material views that are dependent on the views specified in a comma-separated list: + +```text +REFRESH_DEPENDENT( + OUT BINARY_INTEGER, + IN VARCHAR2, + IN VARCHAR2 DEFAULT NULL, + IN VARCHAR2 DEFAULT NULL + IN BOOLEAN DEFAULT FALSE, + IN BOOLEAN DEFAULT TRUE, + IN BOOLEAN DEFAULT FALSE); +``` + +Use the second form of the procedure to refresh all material views that are dependent on the views specified in a table of `DBMS_UTILITY.UNCL_ARRAY` values: + +```text +REFRESH_DEPENDENT( + OUT BINARY_INTEGER, + IN DBMS_UTILITY.UNCL_ARRAY, + IN VARCHAR2 DEFAULT NULL, + IN VARCHAR2 DEFAULT NULL, + IN BOOLEAN DEFAULT FALSE, + IN BOOLEAN DEFAULT TRUE, + IN BOOLEAN DEFAULT FALSE); +``` + +**Parameters** + +`number_of_failures` + + `number_of_failures` is a `BINARY_INTEGER` that contains the number of failures that occurred during the refresh operation. + +`list` + + `list` is a `VARCHAR2` value that specifies the name of a materialized view, or a comma-separated list of materialized view names. The names may be schema-qualified. + +`tab` + + `tab` is a table of `DBMS_UTILITY.UNCL_ARRAY` values that specify the name (or names) of a materialized view. + +`method` + + `method` is a `VARCHAR2` value that specifies the refresh method that will be applied to the specified view (or views). The only supported method is `C`; this performs a complete refresh of the view. + +`rollback_seg` + + `rollback_seg` is accepted for compatibility and ignored. The default is `NULL`. + +`refresh_after_errors` + + `refresh_after_errors` is accepted for compatibility and ignored. The default is `FALSE`. + +`atomic_refresh` + + `atomic_refresh` is accepted for compatibility and ignored. The default is `TRUE`. + +`nested` + + `nested` is accepted for compatibility and ignored. The default is `FALSE`. + +**Examples** + +The following example performs a `COMPLETE` refresh on all materialized views dependent on a materialized view named `emp_view` that resides in the `public` schema: + +```text +DECLARE + errors INTEGER; +BEGIN + DBMS_MVIEW.REFRESH_DEPENDENT(errors, list => 'public.emp_view', method => +'C'); +END; +``` + +Upon completion, `errors` contains the number of failures. diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/08_dbms_mview/index.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/08_dbms_mview/index.mdx new file mode 100644 index 00000000000..f32afd6f152 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/08_dbms_mview/index.mdx @@ -0,0 +1,26 @@ +--- +title: "DBMS_MVIEW" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/dbms_mview.html" +--- + +Use procedures in the `DBMS_MVIEW` package to manage and refresh materialized views and their dependencies. Advanced Server provides support for the following `DBMS_MVIEW` procedures: + +| Procedure | Return Type | Description | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `GET_MV_DEPENDENCIES(list VARCHAR2, deplist VARCHAR2);` | n/a | The `GET_MV_DEPENDENCIES` procedure returns a list of dependencies for a specified view. | +| `REFRESH(list VARCHAR2, method VARCHAR2, rollback_seg VARCHAR2 , push_deferred_rpc BOOLEAN, refresh_after_errors BOOLEAN , purge_option NUMBER, parallelism NUMBER, heap_size NUMBER , atomic_refresh BOOLEAN , nested BOOLEAN);` | n/a | This variation of the `REFRESH` procedure refreshes all views named in a comma-separated list of view names. | +| `REFRESH(tab dbms_utility.uncl_array, method VARCHAR2, rollback_seg VARCHAR2, push_deferred_rpc BOOLEAN, refresh_after_errors BOOLEAN, purge_option NUMBER, parallelism NUMBER, heap_size NUMBER, atomic_refresh BOOLEAN, nested BOOLEAN);` | n/a | This variation of the `REFRESH` procedure refreshes all views named in a table of `dbms_utility.uncl_array` values. | +| `REFRESH_ALL_MVIEWS(number_of_failures BINARY_INTEGER, method VARCHAR2, rollback_seg VARCHAR2, refresh_after_errors BOOLEAN, atomic_refresh BOOLEAN);` | n/a | The `REFRESH_ALL_MVIEWS` procedure refreshes all materialized views. | +| `REFRESH_DEPENDENT(number_of_failures BINARY_INTEGER, list VARCHAR2, method VARCHAR2, rollback_seg VARCHAR2, refresh_after_errors BOOLEAN, atomic_refresh BOOLEAN, nested BOOLEAN);` | n/a | This variation of the `REFRESH_DEPENDENT` procedure refreshes all views that are dependent on the views listed in a comma-separated list. | +| `REFRESH_DEPENDENT(number_of_failures BINARY_INTEGER, tab dbms_utility.uncl_array, method VARCHAR2, rollback_seg VARCHAR2, refresh_after_errors BOOLEAN, atomic_refresh BOOLEAN, nested BOOLEAN);` | n/a | This variation of the `REFRESH_DEPENDENT` procedure refreshes all views that are dependent on the views listed in a table of `dbms_utility.uncl_array` values. | + +Advanced Server's implementation of `DBMS_MVIEW` is a partial implementation when compared to Oracle's version. Only those functions and procedures listed in the table above are supported. + +
+ +get_mv_dependencies refresh refresh_all_mviews refresh_dependent + +
diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/09_dbms_output.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/09_dbms_output.mdx new file mode 100644 index 00000000000..6aae5df5c95 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/09_dbms_output.mdx @@ -0,0 +1,426 @@ +--- +title: "DBMS_OUTPUT" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/dbms_output.html" +--- + +The `DBMS_OUTPUT` package provides the capability to send messages (lines of text) to a message buffer, or get messages from the message buffer. A message buffer is local to a single session. Use the `DBMS_PIPE` package to send messages between sessions. + +The procedures and functions available in the `DBMS_OUTPUT` package are listed in the following table. + +| Function/Procedure | Return Type | Description | +| --------------------------------------- | ----------- | ---------------------------------------------------------------------------------------------------- | +| `DISABLE` | n/a | Disable the capability to send and receive messages. | +| `ENABLE(buffer_size)` | n/a | Enable the capability to send and receive messages. | +| `GET_LINE(line OUT, status OUT)` | n/a | Get a line from the message buffer. | +| `GET_LINES(lines OUT, numlines IN OUT)` | n/a | Get multiple lines from the message buffer. | +| `NEW_LINE` | n/a | Puts an end-of-line character sequence. | +| `PUT(item)` | n/a | Puts a partial line without an end-of-line character sequence. | +| `PUT_LINE(item)` | n/a | Puts a complete line with an end-of-line character sequence. | +| `SERVEROUTPUT(stdout)` | n/a | Direct messages from `PUT, PUT_LINE,` or `NEW_LINE` to either standard output or the message buffer. | + +The following table lists the public variables available in the `DBMS_OUTPUT` package. + +| **Public Variables** | **Data Type** | **Value** | **Description** | +| -------------------- | ------------- | --------- | ------------------ | +| `chararr` | `TABLE` | | For message lines. | + +## CHARARR + +The `CHARARR` is for storing multiple message lines. + +```text +TYPE chararr IS TABLE OF VARCHAR2(32767) INDEX BY BINARY_INTEGER; +``` + +## DISABLE + +The `DISABLE` procedure clears out the message buffer. Any messages in the buffer at the time the `DISABLE` procedure is executed will no longer be accessible. Any messages subsequently sent with the `PUT, PUT_LINE,` or `NEW_LINE` procedures are discarded. No error is returned to the sender when the `PUT, PUT_LINE,` or `NEW_LINE` procedures are executed and messages have been disabled. + +Use the `ENABLE` procedure or `SERVEROUTPUT(TRUE)` procedure to re-enable the sending and receiving of messages. + +```text +DISABLE +``` + +**Examples** + +This anonymous block disables the sending and receiving messages in the current session. + +```text +BEGIN + DBMS_OUTPUT.DISABLE; +END; +``` + +## ENABLE + +The `ENABLE` procedure enables the capability to send messages to the message buffer or retrieve messages from the message buffer. Running `SERVEROUTPUT(TRUE)` also implicitly performs the `ENABLE` procedure. + +The destination of a message sent with `PUT, PUT_LINE,` or `NEW_LINE` depends upon the state of `SERVEROUTPUT`. + +- If the last state of `SERVEROUTPUT` is `TRUE`, the message goes to standard output of the command line. +- If the last state of `SERVEROUTPUT` is `FALSE`, the message goes to the message buffer. + +```text +ENABLE [ ( INTEGER) ] +``` + +**Parameter** + +`buffer_size` + + Maximum length of the message buffer in bytes. If a `buffer_size` of less than 2000 is specified, the buffer size is set to 2000. + +**Examples** + +The following anonymous block enables messages. Setting `SERVEROUTPUT(TRUE)` forces them to standard output. + +```text +BEGIN + DBMS_OUTPUT.ENABLE; + DBMS_OUTPUT.SERVEROUTPUT(TRUE); + DBMS_OUTPUT.PUT_LINE('Messages enabled'); +END; + +Messages enabled +``` + +The same effect could have been achieved by simply using `SERVEROUTPUT(TRUE)`. + +```text +BEGIN + DBMS_OUTPUT.SERVEROUTPUT(TRUE); + DBMS_OUTPUT.PUT_LINE('Messages enabled'); +END; + +Messages enabled +``` + +The following anonymous block enables messages, but setting `SERVEROUTPUT(FALSE)` directs messages to the message buffer. + +```text +BEGIN + DBMS_OUTPUT.ENABLE; + DBMS_OUTPUT.SERVEROUTPUT(FALSE); + DBMS_OUTPUT.PUT_LINE('Message sent to buffer'); +END; +``` + +## GET_LINE + +The `GET_LINE` procedure provides the capability to retrieve a line of text from the message buffer. Only text that has been terminated by an end-of-line character sequence is retrieved – that is complete lines generated using `PUT_LINE`, or by a series of `PUT` calls followed by a `NEW_LINE` call. + +```text +GET_LINE( OUT VARCHAR2, OUT INTEGER) +``` + +**Parameters** + +`line` + + Variable receiving the line of text from the message buffer. + +`status` + + 0 if a line was returned from the message buffer, 1 if there was no line to return. + +**Examples** + +The following anonymous block writes the `emp` table out to the message buffer as a comma-delimited string for each row. + +```text +EXEC DBMS_OUTPUT.SERVEROUTPUT(FALSE); + +DECLARE + v_emprec VARCHAR2(120); + CURSOR emp_cur IS SELECT * FROM emp ORDER BY empno; +BEGIN + DBMS_OUTPUT.ENABLE; + FOR i IN emp_cur LOOP + v_emprec := i.empno || ',' || i.ename || ',' || i.job || ',' || + NVL(LTRIM(TO_CHAR(i.mgr,'9999')),'') || ',' || i.hiredate || + ',' || i.sal || ',' || + NVL(LTRIM(TO_CHAR(i.comm,'9990.99')),'') || ',' || i.deptno; + DBMS_OUTPUT.PUT_LINE(v_emprec); + END LOOP; +END; +``` + +The following anonymous block reads the message buffer and inserts the messages written by the prior example into a table named `messages`. The rows in `messages` are then displayed. + +```text +CREATE TABLE messages ( + status INTEGER, + msg VARCHAR2(100) +); + +DECLARE + v_line VARCHAR2(100); + v_status INTEGER := 0; +BEGIN + DBMS_OUTPUT.GET_LINE(v_line,v_status); + WHILE v_status = 0 LOOP + INSERT INTO messages VALUES(v_status, v_line); + DBMS_OUTPUT.GET_LINE(v_line,v_status); + END LOOP; +END; + +SELECT msg FROM messages; + + msg +----------------------------------------------------------------- + 7369,SMITH,CLERK,7902,17-DEC-80 00:00:00,800.00,,20 + 7499,ALLEN,SALESMAN,7698,20-FEB-81 00:00:00,1600.00,300.00,30 + 7521,WARD,SALESMAN,7698,22-FEB-81 00:00:00,1250.00,500.00,30 + 7566,JONES,MANAGER,7839,02-APR-81 00:00:00,2975.00,,20 + 7654,MARTIN,SALESMAN,7698,28-SEP-81 00:00:00,1250.00,1400.00,30 + 7698,BLAKE,MANAGER,7839,01-MAY-81 00:00:00,2850.00,,30 + 7782,CLARK,MANAGER,7839,09-JUN-81 00:00:00,2450.00,,10 + 7788,SCOTT,ANALYST,7566,19-APR-87 00:00:00,3000.00,,20 + 7839,KING,PRESIDENT,,17-NOV-81 00:00:00,5000.00,,10 + 7844,TURNER,SALESMAN,7698,08-SEP-81 00:00:00,1500.00,0.00,30 + 7876,ADAMS,CLERK,7788,23-MAY-87 00:00:00,1100.00,,20 + 7900,JAMES,CLERK,7698,03-DEC-81 00:00:00,950.00,,30 + 7902,FORD,ANALYST,7566,03-DEC-81 00:00:00,3000.00,,20 + 7934,MILLER,CLERK,7782,23-JAN-82 00:00:00,1300.00,,10 +(14 rows) +``` + +## GET_LINES + +The `GET_LINES` procedure provides the capability to retrieve one or more lines of text from the message buffer into a collection. Only text that has been terminated by an end-of-line character sequence is retrieved – that is complete lines generated using `PUT_LINE`, or by a series of `PUT` calls followed by a `NEW_LINE` call. + +```text +GET_LINES( OUT CHARARR, IN OUT INTEGER) +``` + +**Parameters** + +`lines` + + Table receiving the lines of text from the message buffer. See `CHARARR` for a description of `lines.` + +`numlines IN` + + Number of lines to be retrieved from the message buffer. + +`numlines OUT` + + Actual number of lines retrieved from the message buffer. If the output value of `numlines` is less than the input value, then there are no more lines left in the message buffer. + +**Examples** + +The following example uses the `GET_LINES` procedure to store all rows from the `emp` table that were placed on the message buffer, into an array. + +```text +EXEC DBMS_OUTPUT.SERVEROUTPUT(FALSE); + +DECLARE + v_emprec VARCHAR2(120); + CURSOR emp_cur IS SELECT * FROM emp ORDER BY empno; +BEGIN + DBMS_OUTPUT.ENABLE; + FOR i IN emp_cur LOOP + v_emprec := i.empno || ',' || i.ename || ',' || i.job || ',' || + NVL(LTRIM(TO_CHAR(i.mgr,'9999')),'') || ',' || i.hiredate || + ',' || i.sal || ',' || + NVL(LTRIM(TO_CHAR(i.comm,'9990.99')),'') || ',' || i.deptno; + DBMS_OUTPUT.PUT_LINE(v_emprec); + END LOOP; +END; + +DECLARE + v_lines DBMS_OUTPUT.CHARARR; + v_numlines INTEGER := 14; + v_status INTEGER := 0; +BEGIN + DBMS_OUTPUT.GET_LINES(v_lines,v_numlines); + FOR i IN 1..v_numlines LOOP + INSERT INTO messages VALUES(v_numlines, v_lines(i)); + END LOOP; +END; + +SELECT msg FROM messages; + + msg +----------------------------------------------------------------- + 7369,SMITH,CLERK,7902,17-DEC-80 00:00:00,800.00,,20 + 7499,ALLEN,SALESMAN,7698,20-FEB-81 00:00:00,1600.00,300.00,30 + 7521,WARD,SALESMAN,7698,22-FEB-81 00:00:00,1250.00,500.00,30 + 7566,JONES,MANAGER,7839,02-APR-81 00:00:00,2975.00,,20 + 7654,MARTIN,SALESMAN,7698,28-SEP-81 00:00:00,1250.00,1400.00,30 + 7698,BLAKE,MANAGER,7839,01-MAY-81 00:00:00,2850.00,,30 + 7782,CLARK,MANAGER,7839,09-JUN-81 00:00:00,2450.00,,10 + 7788,SCOTT,ANALYST,7566,19-APR-87 00:00:00,3000.00,,20 + 7839,KING,PRESIDENT,,17-NOV-81 00:00:00,5000.00,,10 + 7844,TURNER,SALESMAN,7698,08-SEP-81 00:00:00,1500.00,0.00,30 + 7876,ADAMS,CLERK,7788,23-MAY-87 00:00:00,1100.00,,20 + 7900,JAMES,CLERK,7698,03-DEC-81 00:00:00,950.00,,30 + 7902,FORD,ANALYST,7566,03-DEC-81 00:00:00,3000.00,,20 + 7934,MILLER,CLERK,7782,23-JAN-82 00:00:00,1300.00,,10 +(14 rows) +``` + +## NEW_LINE + +The `NEW_LINE` procedure writes an end-of-line character sequence in the message buffer. + +```text +NEW_LINE +``` + +**Parameter** + +The `NEW_LINE` procedure expects no parameters. + +## PUT + +The `PUT` procedure writes a string to the message buffer. No end-of-line character sequence is written at the end of the string. Use the `NEW_LINE` procedure to add an end-of-line character sequence. + +```text +PUT( VARCHAR2) +``` + +**Parameter** + +`item` + + Text written to the message buffer. + +**Examples** + +The following example uses the `PUT` procedure to display a comma-delimited list of employees from the `emp` table. + +```text +DECLARE + CURSOR emp_cur IS SELECT * FROM emp ORDER BY empno; +BEGIN + FOR i IN emp_cur LOOP + DBMS_OUTPUT.PUT(i.empno); + DBMS_OUTPUT.PUT(','); + DBMS_OUTPUT.PUT(i.ename); + DBMS_OUTPUT.PUT(','); + DBMS_OUTPUT.PUT(i.job); + DBMS_OUTPUT.PUT(','); + DBMS_OUTPUT.PUT(i.mgr); + DBMS_OUTPUT.PUT(','); + DBMS_OUTPUT.PUT(i.hiredate); + DBMS_OUTPUT.PUT(','); + DBMS_OUTPUT.PUT(i.sal); + DBMS_OUTPUT.PUT(','); + DBMS_OUTPUT.PUT(i.comm); + DBMS_OUTPUT.PUT(','); + DBMS_OUTPUT.PUT(i.deptno); + DBMS_OUTPUT.NEW_LINE; + END LOOP; +END; + +7369,SMITH,CLERK,7902,17-DEC-80 00:00:00,800.00,,20 +7499,ALLEN,SALESMAN,7698,20-FEB-81 00:00:00,1600.00,300.00,30 +7521,WARD,SALESMAN,7698,22-FEB-81 00:00:00,1250.00,500.00,30 +7566,JONES,MANAGER,7839,02-APR-81 00:00:00,2975.00,,20 +7654,MARTIN,SALESMAN,7698,28-SEP-81 00:00:00,1250.00,1400.00,30 +7698,BLAKE,MANAGER,7839,01-MAY-81 00:00:00,2850.00,,30 +7782,CLARK,MANAGER,7839,09-JUN-81 00:00:00,2450.00,,10 +7788,SCOTT,ANALYST,7566,19-APR-87 00:00:00,3000.00,,20 +7839,KING,PRESIDENT,,17-NOV-81 00:00:00,5000.00,,10 +7844,TURNER,SALESMAN,7698,08-SEP-81 00:00:00,1500.00,0.00,30 +7876,ADAMS,CLERK,7788,23-MAY-87 00:00:00,1100.00,,20 +7900,JAMES,CLERK,7698,03-DEC-81 00:00:00,950.00,,30 +7902,FORD,ANALYST,7566,03-DEC-81 00:00:00,3000.00,,20 +7934,MILLER,CLERK,7782,23-JAN-82 00:00:00,1300.00,,10 +``` + +## PUT_LINE + +The `PUT_LINE` procedure writes a single line to the message buffer including an end-of-line character sequence. + +```text +PUT_LINE( VARCHAR2) +``` + +**Parameter** + +`item` + + Text to be written to the message buffer. + +**Examples** + +The following example uses the `PUT_LINE` procedure to display a comma-delimited list of employees from the `emp` table. + +```text +DECLARE + v_emprec VARCHAR2(120); + CURSOR emp_cur IS SELECT * FROM emp ORDER BY empno; +BEGIN + FOR i IN emp_cur LOOP + v_emprec := i.empno || ',' || i.ename || ',' || i.job || ',' || + NVL(LTRIM(TO_CHAR(i.mgr,'9999')),'') || ',' || i.hiredate || + ',' || i.sal || ',' || + NVL(LTRIM(TO_CHAR(i.comm,'9990.99')),'') || ',' || i.deptno; + DBMS_OUTPUT.PUT_LINE(v_emprec); + END LOOP; +END; + +7369,SMITH,CLERK,7902,17-DEC-80 00:00:00,800.00,,20 +7499,ALLEN,SALESMAN,7698,20-FEB-81 00:00:00,1600.00,300.00,30 +7521,WARD,SALESMAN,7698,22-FEB-81 00:00:00,1250.00,500.00,30 +7566,JONES,MANAGER,7839,02-APR-81 00:00:00,2975.00,,20 +7654,MARTIN,SALESMAN,7698,28-SEP-81 00:00:00,1250.00,1400.00,30 +7698,BLAKE,MANAGER,7839,01-MAY-81 00:00:00,2850.00,,30 +7782,CLARK,MANAGER,7839,09-JUN-81 00:00:00,2450.00,,10 +7788,SCOTT,ANALYST,7566,19-APR-87 00:00:00,3000.00,,20 +7839,KING,PRESIDENT,,17-NOV-81 00:00:00,5000.00,,10 +7844,TURNER,SALESMAN,7698,08-SEP-81 00:00:00,1500.00,0.00,30 +7876,ADAMS,CLERK,7788,23-MAY-87 00:00:00,1100.00,,20 +7900,JAMES,CLERK,7698,03-DEC-81 00:00:00,950.00,,30 +7902,FORD,ANALYST,7566,03-DEC-81 00:00:00,3000.00,,20 +7934,MILLER,CLERK,7782,23-JAN-82 00:00:00,1300.00,,10 +``` + +## SERVEROUTPUT + +The `SERVEROUTPUT` procedure provides the capability to direct messages to standard output of the command line or to the message buffer. Setting `SERVEROUTPUT(TRUE)` also performs an implicit execution of `ENABLE`. + +The default setting of `SERVEROUTPUT` is implementation dependent. For example, in Oracle SQL\*Plus, `SERVEROUTPUT(FALSE)` is the default. In PSQL, `SERVEROUTPUT(TRUE)` is the default. Also note that in Oracle SQL\*Plus, this setting is controlled using the SQL\*Plus `SET` command, not by a stored procedure as implemented in Advanced Server. + +```text +SERVEROUTPUT( BOOLEAN) +``` + +**Parameter** + +`stdout` + + Set to `TRUE` if subsequent `PUT, PUT_LINE`, or `NEW_LINE` commands are to send text directly to standard output of the command line. Set to `FALSE` if text is to be sent to the message buffer. + +**Examples** + +The following anonymous block sends the first message to the command line and the second message to the message buffer. + +```text +BEGIN + DBMS_OUTPUT.SERVEROUTPUT(TRUE); + DBMS_OUTPUT.PUT_LINE('This message goes to the command line'); + DBMS_OUTPUT.SERVEROUTPUT(FALSE); + DBMS_OUTPUT.PUT_LINE('This message goes to the message buffer'); +END; + +This message goes to the command line +``` + +If within the same session, the following anonymous block is executed, the message stored in the message buffer from the prior example is flushed and displayed on the command line as well as the new message. + +```text +BEGIN + DBMS_OUTPUT.SERVEROUTPUT(TRUE); + DBMS_OUTPUT.PUT_LINE('Flush messages from the buffer'); +END; + +This message goes to the message buffer +Flush messages from the buffer +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/10_dbms_pipe/01_create_pipe.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/10_dbms_pipe/01_create_pipe.mdx new file mode 100644 index 00000000000..2cd5b3db2f8 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/10_dbms_pipe/01_create_pipe.mdx @@ -0,0 +1,58 @@ +--- +title: "CREATE_PIPE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/create_pipe.html" +--- + +The `CREATE_PIPE` function creates an explicit public pipe or an explicit private pipe with a specified name. + +```text + INTEGER CREATE_PIPE( VARCHAR2 + [, INTEGER ] [, BOOLEAN ]) +``` + +**Parameters** + +`pipename` + + Name of the pipe. + +`maxpipesize` + + Maximum capacity of the pipe in bytes. Default is 8192 bytes. + +`private` + + Create a public pipe if set to `FALSE`. Create a private pipe if set to `TRUE.` This is the default. + +`status` + + Status code returned by the operation. 0 indicates successful creation. + +**Examples** + +The following example creates a private pipe named `messages:` + +```text +DECLARE + v_status INTEGER; +BEGIN + v_status := DBMS_PIPE.CREATE_PIPE('messages'); + DBMS_OUTPUT.PUT_LINE('CREATE_PIPE status: ' || v_status); +END; +CREATE_PIPE status: 0 +``` + +The following example creates a public pipe named `mailbox:` + +```text +DECLARE + v_status INTEGER; +BEGIN + v_status := DBMS_PIPE.CREATE_PIPE('mailbox',8192,FALSE); + DBMS_OUTPUT.PUT_LINE('CREATE_PIPE status: ' || v_status); +END; +CREATE_PIPE status: 0 +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/10_dbms_pipe/02_next_item_pipe.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/10_dbms_pipe/02_next_item_pipe.mdx new file mode 100644 index 00000000000..1b27aad104d --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/10_dbms_pipe/02_next_item_pipe.mdx @@ -0,0 +1,117 @@ +--- +title: "NEXT_ITEM_TYPE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/next_item_pipe.html" +--- + +The `NEXT_ITEM_TYPE` function returns an integer code identifying the data type of the next data item in a message that has been retrieved into the session’s local message buffer. As each item is moved off of the local message buffer with the `UNPACK_MESSAGE` procedure, the `NEXT_ITEM_TYPE` function will return the data type code for the next available item. A code of 0 is returned when there are no more items left in the message. + +```text + INTEGER NEXT_ITEM_TYPE +``` + +**Parameters** + +`typecode` + + Code identifying the data type of the next data item as shown in the following table. + +| Type Code | Data Type | +| --------- | ------------------ | +| `0` | No more data items | +| `9` | `NUMBER` | +| `11` | `VARCHAR2` | +| `13` | `DATE` | +| `23` | `RAW` | + + **Note**: The type codes list in the table are not compatible with Oracle databases. Oracle assigns a different numbering sequence to the data types. + +**Examples** + +The following example shows a pipe packed with a `NUMBER` item, a `VARCHAR2` item, a `DATE` item, and a `RAW` item. A second anonymous block then uses the `NEXT_ITEM_TYPE` function to display the type code of each item. + +```text +DECLARE + v_number NUMBER := 123; + v_varchar VARCHAR2(20) := 'Character data'; + v_date DATE := SYSDATE; + v_raw RAW(4) := '21222324'; + v_status INTEGER; +BEGIN + DBMS_PIPE.PACK_MESSAGE(v_number); + DBMS_PIPE.PACK_MESSAGE(v_varchar); + DBMS_PIPE.PACK_MESSAGE(v_date); + DBMS_PIPE.PACK_MESSAGE(v_raw); + v_status := DBMS_PIPE.SEND_MESSAGE('datatypes'); + DBMS_OUTPUT.PUT_LINE('SEND_MESSAGE status: ' || v_status); +EXCEPTION + WHEN OTHERS THEN + DBMS_OUTPUT.PUT_LINE('SQLERRM: ' || SQLERRM); + DBMS_OUTPUT.PUT_LINE('SQLCODE: ' || SQLCODE); +END; + +SEND_MESSAGE status: 0 + +DECLARE + v_number NUMBER; + v_varchar VARCHAR2(20); + v_date DATE; + v_timestamp TIMESTAMP; + v_raw RAW(4); + v_status INTEGER; +BEGIN + v_status := DBMS_PIPE.RECEIVE_MESSAGE('datatypes'); + DBMS_OUTPUT.PUT_LINE('RECEIVE_MESSAGE status: ' || v_status); + DBMS_OUTPUT.PUT_LINE('----------------------------------'); + + v_status := DBMS_PIPE.NEXT_ITEM_TYPE; + DBMS_OUTPUT.PUT_LINE('NEXT_ITEM_TYPE: ' || v_status); + DBMS_PIPE.UNPACK_MESSAGE(v_number); + DBMS_OUTPUT.PUT_LINE('NUMBER Item : ' || v_number); + DBMS_OUTPUT.PUT_LINE('----------------------------------'); + + v_status := DBMS_PIPE.NEXT_ITEM_TYPE; + DBMS_OUTPUT.PUT_LINE('NEXT_ITEM_TYPE: ' || v_status); + DBMS_PIPE.UNPACK_MESSAGE(v_varchar); + DBMS_OUTPUT.PUT_LINE('VARCHAR2 Item : ' || v_varchar); + DBMS_OUTPUT.PUT_LINE('----------------------------------'); + + v_status := DBMS_PIPE.NEXT_ITEM_TYPE; + DBMS_OUTPUT.PUT_LINE('NEXT_ITEM_TYPE: ' || v_status); + DBMS_PIPE.UNPACK_MESSAGE(v_date); + DBMS_OUTPUT.PUT_LINE('DATE Item : ' || v_date); + DBMS_OUTPUT.PUT_LINE('----------------------------------'); + + v_status := DBMS_PIPE.NEXT_ITEM_TYPE; + DBMS_OUTPUT.PUT_LINE('NEXT_ITEM_TYPE: ' || v_status); + DBMS_PIPE.UNPACK_MESSAGE(v_raw); + DBMS_OUTPUT.PUT_LINE('RAW Item : ' || v_raw); + DBMS_OUTPUT.PUT_LINE('----------------------------------'); + + v_status := DBMS_PIPE.NEXT_ITEM_TYPE; + DBMS_OUTPUT.PUT_LINE('NEXT_ITEM_TYPE: ' || v_status); + DBMS_OUTPUT.PUT_LINE('---------------------------------'); +EXCEPTION + WHEN OTHERS THEN + DBMS_OUTPUT.PUT_LINE('SQLERRM: ' || SQLERRM); + DBMS_OUTPUT.PUT_LINE('SQLCODE: ' || SQLCODE); +END; + +RECEIVE_MESSAGE status: 0 +---------------------------------- +NEXT_ITEM_TYPE: 9 +NUMBER Item : 123 +---------------------------------- +NEXT_ITEM_TYPE: 11 +VARCHAR2 Item : Character data +---------------------------------- +NEXT_ITEM_TYPE: 13 +DATE Item : 02-OCT-07 11:11:43 +---------------------------------- +NEXT_ITEM_TYPE: 23 +RAW Item : 21222324 +---------------------------------- +NEXT_ITEM_TYPE: 0 +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/10_dbms_pipe/03_pack_message.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/10_dbms_pipe/03_pack_message.mdx new file mode 100644 index 00000000000..88836cf3aad --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/10_dbms_pipe/03_pack_message.mdx @@ -0,0 +1,21 @@ +--- +title: "PACK_MESSAGE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/pack_message.html" +--- + +The `PACK_MESSAGE` procedure places an item of data in the session’s local message buffer. `PACK_MESSAGE` must be executed at least once before issuing a `SEND_MESSAGE` call. + +```text +PACK_MESSAGE( { DATE | NUMBER | VARCHAR2 | RAW }) +``` + +Use the `UNPACK_MESSAGE` procedure to obtain data items once the message is retrieved using a `RECEIVE_MESSAGE` call. + +**Parameters** + +`item` + + An expression evaluating to any of the acceptable parameter data types. The value is added to the session’s local message buffer. diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/10_dbms_pipe/04_purge.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/10_dbms_pipe/04_purge.mdx new file mode 100644 index 00000000000..ffc5d6f7806 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/10_dbms_pipe/04_purge.mdx @@ -0,0 +1,79 @@ +--- +title: "PURGE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/purge.html" +--- + +The `PURGE` procedure removes the unreceived messages from a specified implicit pipe. + +```text +PURGE( VARCHAR2) +``` + +Use the `REMOVE_PIPE` function to delete an explicit pipe. + +**Parameters** + +`pipename` + + Name of the pipe. + +**Examples** + +Two messages are sent on a pipe: + +```text +DECLARE + v_status INTEGER; +BEGIN + DBMS_PIPE.PACK_MESSAGE('Message #1'); + v_status := DBMS_PIPE.SEND_MESSAGE('pipe'); + DBMS_OUTPUT.PUT_LINE('SEND_MESSAGE status: ' || v_status); + + DBMS_PIPE.PACK_MESSAGE('Message #2'); + v_status := DBMS_PIPE.SEND_MESSAGE('pipe'); + DBMS_OUTPUT.PUT_LINE('SEND_MESSAGE status: ' || v_status); +END; + +SEND_MESSAGE status: 0 +SEND_MESSAGE status: 0 +``` + +Receive the first message and unpack it: + +```text +DECLARE + v_item VARCHAR2(80); + v_status INTEGER; +BEGIN + v_status := DBMS_PIPE.RECEIVE_MESSAGE('pipe',1); + DBMS_OUTPUT.PUT_LINE('RECEIVE_MESSAGE status: ' || v_status); + DBMS_PIPE.UNPACK_MESSAGE(v_item); + DBMS_OUTPUT.PUT_LINE('Item: ' || v_item); +END; + +RECEIVE_MESSAGE status: 0 +Item: Message #1 +``` + +Purge the pipe: + +```text +EXEC DBMS_PIPE.PURGE('pipe'); +``` + +Try to retrieve the next message. The `RECEIVE_MESSAGE` call returns status code 1 indicating it timed out because no message was available. + +```text +DECLARE + v_item VARCHAR2(80); + v_status INTEGER; +BEGIN + v_status := DBMS_PIPE.RECEIVE_MESSAGE('pipe',1); + DBMS_OUTPUT.PUT_LINE('RECEIVE_MESSAGE status: ' || v_status); +END; + +RECEIVE_MESSAGE status: 1 +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/10_dbms_pipe/05_receive_message.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/10_dbms_pipe/05_receive_message.mdx new file mode 100644 index 00000000000..8e191e84743 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/10_dbms_pipe/05_receive_message.mdx @@ -0,0 +1,36 @@ +--- +title: "RECEIVE_MESSAGE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/receive_message.html" +--- + +The `RECEIVE_MESSAGE` function obtains a message from a specified pipe. + +```text + INTEGER RECEIVE_MESSAGE( VARCHAR2 + [, INTEGER ]) +``` + +**Parameters** + +`pipename` + + Name of the pipe. + +`timeout` + + Wait time (seconds). Default is 86400000 (1000 days). + +`status` + + Status code returned by the operation. + + The possible status codes are: + +| Status Code | Description | +| ----------- | -------------------------------- | +| `0` | Success | +| `1` | Time out | +| `2` | Message too large for the buffer | diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/10_dbms_pipe/06_remove_pipe.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/10_dbms_pipe/06_remove_pipe.mdx new file mode 100644 index 00000000000..4da0593ff95 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/10_dbms_pipe/06_remove_pipe.mdx @@ -0,0 +1,92 @@ +--- +title: "REMOVE_PIPE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/remove_pipe.html" +--- + +The `REMOVE_PIPE` function deletes an explicit private or explicit public pipe. + +```text + INTEGER REMOVE_PIPE( VARCHAR2) +``` + +Use the `REMOVE_PIPE` function to delete explicitly created pipes – i.e., pipes created with the `CREATE_PIPE` function. + +**Parameters** + +`pipename` + + Name of the pipe. + +`status` + + Status code returned by the operation. A status code of 0 is returned even if the named pipe is non-existent. + +**Examples** + +Two messages are sent on a pipe: + +```text +DECLARE + v_status INTEGER; +BEGIN + v_status := DBMS_PIPE.CREATE_PIPE('pipe'); + DBMS_OUTPUT.PUT_LINE('CREATE_PIPE status : ' || v_status); + + DBMS_PIPE.PACK_MESSAGE('Message #1'); + v_status := DBMS_PIPE.SEND_MESSAGE('pipe'); + DBMS_OUTPUT.PUT_LINE('SEND_MESSAGE status: ' || v_status); + + DBMS_PIPE.PACK_MESSAGE('Message #2'); + v_status := DBMS_PIPE.SEND_MESSAGE('pipe'); + DBMS_OUTPUT.PUT_LINE('SEND_MESSAGE status: ' || v_status); +END; + +CREATE_PIPE status : 0 +SEND_MESSAGE status: 0 +SEND_MESSAGE status: 0 +``` + +Receive the first message and unpack it: + +```text +DECLARE + v_item VARCHAR2(80); + v_status INTEGER; +BEGIN + v_status := DBMS_PIPE.RECEIVE_MESSAGE('pipe',1); + DBMS_OUTPUT.PUT_LINE('RECEIVE_MESSAGE status: ' || v_status); + DBMS_PIPE.UNPACK_MESSAGE(v_item); + DBMS_OUTPUT.PUT_LINE('Item: ' || v_item); +END; + +RECEIVE_MESSAGE status: 0 +Item: Message #1 +``` + +Remove the pipe: + +```text +SELECT DBMS_PIPE.REMOVE_PIPE('pipe') FROM DUAL; + +remove_pipe +------------- + 0 +(1 row) +``` + +Try to retrieve the next message. The `RECEIVE_MESSAGE` call returns status code 1 indicating it timed out because the pipe had been deleted. + +```text +DECLARE + v_item VARCHAR2(80); + v_status INTEGER; +BEGIN + v_status := DBMS_PIPE.RECEIVE_MESSAGE('pipe',1); + DBMS_OUTPUT.PUT_LINE('RECEIVE_MESSAGE status: ' || v_status); +END; + +RECEIVE_MESSAGE status: 1 +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/10_dbms_pipe/07_reset_buffer.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/10_dbms_pipe/07_reset_buffer.mdx new file mode 100644 index 00000000000..bc115423fea --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/10_dbms_pipe/07_reset_buffer.mdx @@ -0,0 +1,54 @@ +--- +title: "RESET_BUFFER" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/reset_buffer.html" +--- + +The `RESET_BUFFER` procedure resets a “pointer” to the session’s local message buffer back to the beginning of the buffer. This has the effect of causing subsequent `PACK_MESSAGE` calls to overwrite any data items that existed in the message buffer prior to the `RESET_BUFFER` call. + +```text +RESET_BUFFER +``` + +**Examples** + +A message to John is written to the local message buffer. It is replaced by a message to Bob by calling `RESET_BUFFER`. The message is sent on the pipe. + +```text +DECLARE + v_status INTEGER; +BEGIN + DBMS_PIPE.PACK_MESSAGE('Hi, John'); + DBMS_PIPE.PACK_MESSAGE('Can you attend a meeting at 3:00, today?'); + DBMS_PIPE.PACK_MESSAGE('If not, is tomorrow at 8:30 ok with you?'); + DBMS_PIPE.RESET_BUFFER; + DBMS_PIPE.PACK_MESSAGE('Hi, Bob'); + DBMS_PIPE.PACK_MESSAGE('Can you attend a meeting at 9:30, tomorrow?'); + v_status := DBMS_PIPE.SEND_MESSAGE('pipe'); + DBMS_OUTPUT.PUT_LINE('SEND_MESSAGE status: ' || v_status); +END; + +SEND_MESSAGE status: 0 +``` + +The message to Bob is in the received message. + +```text +DECLARE + v_item VARCHAR2(80); + v_status INTEGER; +BEGIN + v_status := DBMS_PIPE.RECEIVE_MESSAGE('pipe',1); + DBMS_OUTPUT.PUT_LINE('RECEIVE_MESSAGE status: ' || v_status); + DBMS_PIPE.UNPACK_MESSAGE(v_item); + DBMS_OUTPUT.PUT_LINE('Item: ' || v_item); + DBMS_PIPE.UNPACK_MESSAGE(v_item); + DBMS_OUTPUT.PUT_LINE('Item: ' || v_item); +END; + +RECEIVE_MESSAGE status: 0 +Item: Hi, Bob +Item: Can you attend a meeting at 9:30, tomorrow? +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/10_dbms_pipe/08_send_message.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/10_dbms_pipe/08_send_message.mdx new file mode 100644 index 00000000000..72a215e9d5e --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/10_dbms_pipe/08_send_message.mdx @@ -0,0 +1,40 @@ +--- +title: "SEND_MESSAGE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/send_message.html" +--- + +The `SEND_MESSAGE` function sends a message from the session’s local message buffer to the specified pipe. + +```text + SEND_MESSAGE( VARCHAR2 [, INTEGER ] + [, INTEGER ]) +``` + +**Parameters** + +`pipename` + + Name of the pipe. + +`timeout` + + Wait time (seconds). Default is 86400000 (1000 days). + +`maxpipesize` + + Maximum capacity of the pipe in bytes. Default is 8192 bytes. + +`status` + + Status code returned by the operation. + + The possible status codes are: + +| Status Code | Description | +| ----------- | -------------------- | +| `0` | Success | +| `1` | Time out | +| `3` | Function interrupted | diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/10_dbms_pipe/09_unique_session_name.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/10_dbms_pipe/09_unique_session_name.mdx new file mode 100644 index 00000000000..2bd1aab8753 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/10_dbms_pipe/09_unique_session_name.mdx @@ -0,0 +1,34 @@ +--- +title: "UNIQUE_SESSION_NAME" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/unique_session_name.html" +--- + +The `UNIQUE_SESSION_NAME` function returns a name, unique to the current session. + +```text + VARCHAR2 UNIQUE_SESSION_NAME +``` + +**Parameters** + +`name` + + Unique session name. + +**Examples** + +The following anonymous block retrieves and displays a unique session name. + +```text +DECLARE + v_session VARCHAR2(30); +BEGIN + v_session := DBMS_PIPE.UNIQUE_SESSION_NAME; + DBMS_OUTPUT.PUT_LINE('Session Name: ' || v_session); +END; + +Session Name: PG$PIPE$5$2752 +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/10_dbms_pipe/10_unpack_message.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/10_dbms_pipe/10_unpack_message.mdx new file mode 100644 index 00000000000..8029ada211f --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/10_dbms_pipe/10_unpack_message.mdx @@ -0,0 +1,19 @@ +--- +title: "UNPACK_MESSAGE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/unpack_message.html" +--- + +The `UNPACK_MESSAGE` procedure copies the data items of a message from the local message buffer to a specified program variable. The message must be placed in the local message buffer with the `RECEIVE_MESSAGE` function before using `UNPACK_MESSAGE`. + +```text +UNPACK_MESSAGE( OUT { DATE | NUMBER | VARCHAR2 | RAW }) +``` + +**Parameters** + +`item` + + Type-compatible variable that receives a data item from the local message buffer. diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/10_dbms_pipe/11_comprehensive_example.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/10_dbms_pipe/11_comprehensive_example.mdx new file mode 100644 index 00000000000..be3b33e6939 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/10_dbms_pipe/11_comprehensive_example.mdx @@ -0,0 +1,158 @@ +--- +title: "Comprehensive Example" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/comprehensive_example.html" +--- + +The following example uses a pipe as a “mailbox”. The procedures to create the mailbox, add a multi-item message to the mailbox (up to three items), and display the full contents of the mailbox are enclosed in a package named, `mailbox`. + +```text +CREATE OR REPLACE PACKAGE mailbox +IS + PROCEDURE create_mailbox; + PROCEDURE add_message ( + p_mailbox VARCHAR2, + p_item_1 VARCHAR2, + p_item_2 VARCHAR2 DEFAULT 'END', + p_item_3 VARCHAR2 DEFAULT 'END' + ); + PROCEDURE empty_mailbox ( + p_mailbox VARCHAR2, + p_waittime INTEGER DEFAULT 10 + ); +END mailbox; + +CREATE OR REPLACE PACKAGE BODY mailbox +IS + PROCEDURE create_mailbox + IS + v_mailbox VARCHAR2(30); + v_status INTEGER; + BEGIN + v_mailbox := DBMS_PIPE.UNIQUE_SESSION_NAME; + v_status := DBMS_PIPE.CREATE_PIPE(v_mailbox,1000,FALSE); + IF v_status = 0 THEN + DBMS_OUTPUT.PUT_LINE('Created mailbox: ' || v_mailbox); + ELSE + DBMS_OUTPUT.PUT_LINE('CREATE_PIPE failed - status: ' || + v_status); + END IF; + END create_mailbox; + + PROCEDURE add_message ( + p_mailbox VARCHAR2, + p_item_1 VARCHAR2, + p_item_2 VARCHAR2 DEFAULT 'END', + p_item_3 VARCHAR2 DEFAULT 'END' + ) + IS + v_item_cnt INTEGER := 0; + v_status INTEGER; + BEGIN + DBMS_PIPE.PACK_MESSAGE(p_item_1); + v_item_cnt := 1; + IF p_item_2 != 'END' THEN + DBMS_PIPE.PACK_MESSAGE(p_item_2); + v_item_cnt := v_item_cnt + 1; + END IF; + IF p_item_3 != 'END' THEN + DBMS_PIPE.PACK_MESSAGE(p_item_3); + v_item_cnt := v_item_cnt + 1; + END IF; + v_status := DBMS_PIPE.SEND_MESSAGE(p_mailbox); + IF v_status = 0 THEN + DBMS_OUTPUT.PUT_LINE('Added message with ' || v_item_cnt || + ' item(s) to mailbox ' || p_mailbox); + ELSE + DBMS_OUTPUT.PUT_LINE('SEND_MESSAGE in add_message failed - ' || + 'status: ' || v_status); + END IF; + END add_message; + + PROCEDURE empty_mailbox ( + p_mailbox VARCHAR2, + p_waittime INTEGER DEFAULT 10 + ) + IS + v_msgno INTEGER DEFAULT 0; + v_itemno INTEGER DEFAULT 0; + v_item VARCHAR2(100); + v_status INTEGER; + BEGIN + v_status := DBMS_PIPE.RECEIVE_MESSAGE(p_mailbox,p_waittime); + WHILE v_status = 0 LOOP + v_msgno := v_msgno + 1; + DBMS_OUTPUT.PUT_LINE('****** Start message #' || v_msgno || + ' ******'); + BEGIN + LOOP + v_status := DBMS_PIPE.NEXT_ITEM_TYPE; + EXIT WHEN v_status = 0; + DBMS_PIPE.UNPACK_MESSAGE(v_item); + v_itemno := v_itemno + 1; + DBMS_OUTPUT.PUT_LINE('Item #' || v_itemno || ': ' || + v_item); + END LOOP; + DBMS_OUTPUT.PUT_LINE('******* End message #' || v_msgno || + ' *******'); + DBMS_OUTPUT.PUT_LINE('*'); + v_itemno := 0; + v_status := DBMS_PIPE.RECEIVE_MESSAGE(p_mailbox,1); + END; + END LOOP; + DBMS_OUTPUT.PUT_LINE('Number of messages received: ' || v_msgno); + v_status := DBMS_PIPE.REMOVE_PIPE(p_mailbox); + IF v_status = 0 THEN + DBMS_OUTPUT.PUT_LINE('Deleted mailbox ' || p_mailbox); + ELSE + DBMS_OUTPUT.PUT_LINE('Could not delete mailbox - status: ' + || v_status); + END IF; + END empty_mailbox; +END mailbox; +``` + +The following demonstrates the execution of the procedures in `mailbox`. The first procedure creates a public pipe using a name generated by the `UNIQUE_SESSION_NAME` function. + +```text +EXEC mailbox.create_mailbox; + +Created mailbox: PG$PIPE$13$3940 +``` + +Using the mailbox name, any user in the same database with access to the `mailbox` package and `DBMS_PIPE` package can add messages: + +```text +EXEC mailbox.add_message('PG$PIPE$13$3940','Hi, John','Can you attend a +meeting at 3:00, today?','-- Mary'); + +Added message with 3 item(s) to mailbox PG$PIPE$13$3940 + +EXEC mailbox.add_message('PG$PIPE$13$3940','Don''t forget to submit your +report','Thanks,','-- Joe'); + +Added message with 3 item(s) to mailbox PG$PIPE$13$3940 +``` + +Finally, the contents of the mailbox can be emptied: + +```text +EXEC mailbox.empty_mailbox('PG$PIPE$13$3940'); + +****** Start message #1 ****** +Item #1: Hi, John +Item #2: Can you attend a meeting at 3:00, today? +Item #3: -- Mary +******* End message #1 ******* +* +****** Start message #2 ****** +Item #1: Don't forget to submit your report +Item #2: Thanks, +Item #3: Joe +******* End message #2 ******* +* +Number of messages received: 2 +Deleted mailbox PG$PIPE$13$3940 +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/10_dbms_pipe/index.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/10_dbms_pipe/index.mdx new file mode 100644 index 00000000000..042a576782c --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/10_dbms_pipe/index.mdx @@ -0,0 +1,42 @@ +--- +title: "DBMS_PIPE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/dbms_pipe.html" +--- + +The `DBMS_PIPE` package provides the capability to send messages through a pipe within or between sessions connected to the same database cluster. + +The procedures and functions available in the `DBMS_PIPE` package are listed in the following table: + +| Function/Procedure | Return Type | Description | +| ------------------------------------------------------ | ----------- | --------------------------------------------------------------------------------------------------------------- | +| `CREATE_PIPE(pipename [, maxpipesize ] [, private ])` | `INTEGER` | Explicitly create a private pipe if `private` is “true” (the default) or a public pipe if `private` is “false”. | +| `NEXT_ITEM_TYPE` | `INTEGER` | Determine the data type of the next item in a received message. | +| `PACK_MESSAGE(item)` | n/a | Place `item` in the session’s local message buffer. | +| `PURGE(pipename)` | n/a | Remove unreceived messages from the specified pipe. | +| `RECEIVE_MESSAGE(pipename [, timeout ])` | `INTEGER` | Get a message from a specified pipe. | +| `REMOVE_PIPE(pipename)` | `INTEGER` | Delete an explicitly created pipe. | +| `RESET_BUFFER` | n/a | Reset the local message buffer. | +| `SEND_MESSAGE(pipename [, timeout ] [, maxpipesize ])` | `INTEGER` | Send a message on a pipe. | +| `UNIQUE_SESSION_NAME` | `VARCHAR2` | Obtain a unique session name. | +| `UNPACK_MESSAGE(item OUT)` | n/a | Retrieve the next data item from a message into a type-compatible variable, `item`. | + +Pipes are categorized as implicit or explicit. An *implicit pipe* is created if a reference is made to a pipe name that was not previously created by the `CREATE_PIPE` function. For example, if the `SEND_MESSAGE` function is executed using a non-existent pipe name, a new implicit pipe is created with that name. An *explicit pipe* is created using the `CREATE_PIPE` function whereby the first parameter specifies the pipe name for the new pipe. + +Pipes are also categorized as private or public. A *private pipe* can only be accessed by the user who created the pipe. Even a superuser cannot access a private pipe that was created by another user. A *public pipe* can be accessed by any user who has access to the `DBMS_PIPE` package. + +A public pipe can only be created by using the `CREATE_PIPE` function with the third parameter set to `FALSE`. The `CREATE_PIPE` function can be used to create a private pipe by setting the third parameter to `TRUE` or by omitting the third parameter. All implicit pipes are private. + +The individual data items or “lines” of a message are first built-in a *local message buffer*, unique to the current session. The `PACK_MESSAGE` procedure builds the message in the session’s local message buffer. The `SEND_MESSAGE` function is then used to send the message through the pipe. + +Receipt of a message involves the reverse operation. The `RECEIVE_MESSAGE` function is used to get a message from the specified pipe. The message is written to the session’s local message buffer. The `UNPACK_MESSAGE` procedure is then used to transfer the message data items from the message buffer to program variables. If a pipe contains multiple messages, `RECEIVE_MESSAGE` gets the messages in *FIFO* (first-in-first-out) order. + +Each session maintains separate message buffers for messages created with the `PACK_MESSAGE` procedure and messages retrieved by the `RECEIVE_MESSAGE` function. Thus messages can be both built and received in the same session. However, if consecutive `RECEIVE_MESSAGE` calls are made, only the message from the last `RECEIVE_MESSAGE` call will be preserved in the local message buffer. + +
+ +create_pipe next_item_pipe pack_message purge receive_message remove_pipe reset_buffer send_message unique_session_name unpack_message comprehensive_example + +
diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/11_dbms_profiler.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/11_dbms_profiler.mdx new file mode 100644 index 00000000000..aa11b637744 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/11_dbms_profiler.mdx @@ -0,0 +1,838 @@ +--- +title: "DBMS_PROFILER" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/dbms_profiler.html" +--- + +The `DBMS_PROFILER` package collects and stores performance information about the PL/pgSQL and SPL statements that are executed during a performance profiling session; use the functions and procedures listed below to control the profiling tool. + +| Function/Procedure | Return Type | Description | +| --------------------------------------------------------------- | ------------------------ | ---------------------------------------------------------------------------------------------------------------- | +| `FLUSH_DATA` | Status Code or Exception | Flushes performance data collected in the current session without terminating the session (profiling continues). | +| `GET_VERSION(major OUT, minor OUT)` | n/a | Returns the version number of this package. | +| `INTERNAL_VERSION_CHECK` | Status Code | Confirms that the current version of the profiler will work with the current database. | +| `PAUSE_PROFILER` | Status Code or Exception | Pause data collection. | +| `RESUME_PROFILER` | Status Code or Exception | Resume data collection. | +| `START_PROFILER(run_comment, run_comment1 [, run_number OUT ])` | Status Code or Exception | Start data collection. | +| `STOP_PROFILER` | Status Code or Exception | Stop data collection and flush performance data to the `PLSQL_PROFILER_RAWDATA` table. | + +The functions within the `DBMS_PROFILER` package return a status code to indicate success or failure; the `DBMS_PROFILER` procedures raise an exception only if they encounter a failure. The status codes and messages returned by the functions, and the exceptions raised by the procedures are listed in the table below. + +| Status Code | Message | Exception | Description | +| ----------- | --------------- | ------------------ | ------------------------------------------------------- | +| `-1` | `error version` | `version_mismatch` | The profiler version and the database are incompatible. | +| `0` | `success` | n/a | The operation completed successfully. | +| `1` | `error_param` | `profiler_error` | The operation received an incorrect parameter. | +| `2` | `error_io` | `profiler_error` | The data flush operation has failed. | + +## FLUSH_DATA + +The `FLUSH_DATA` function/procedure flushes the data collected in the current session without terminating the profiler session. The data is flushed to the tables described in the Advanced Server Performance Features Guide. The function and procedure signatures are: + +```text + INTEGER FLUSH_DATA + +FLUSH_DATA +``` + +**Parameters** + +`status` + + Status code returned by the operation. + +## GET_VERSION + +The `GET_VERSION` procedure returns the version of `DBMS_PROFILER`. The procedure signature is: + +```text +GET_VERSION( OUT INTEGER, OUT INTEGER) +``` + +**Parameters** + +`major` + + The major version number of `DBMS_PROFILER`. + +`minor` + + The minor version number of `DBMS_PROFILER`. + +## INTERNAL_VERSION_CHECK + +The `INTERNAL_VERSION_CHECK` function confirms that the current version of `DBMS_PROFILER` will work with the current database. The function signature is: + +```text + INTEGER INTERNAL_VERSION_CHECK +``` + +**Parameters** + +`status` + + Status code returned by the operation. + +## PAUSE_PROFILER + +The `PAUSE_PROFILER` function/procedure pauses a profiling session. The function and procedure signatures are: + +```text + INTEGER PAUSE_PROFILER + +PAUSE_PROFILER +``` + +**Parameters** + +`status` + + Status code returned by the operation. + +## RESUME_PROFILER + +The `RESUME_PROFILER` function/procedure pauses a profiling session. The function and procedure signatures are: + +```text + INTEGER RESUME_PROFILER + +RESUME_PROFILER +``` + +**Parameters** + +`status` + + Status code returned by the operation. + +## START_PROFILER + +The `START_PROFILER` function/procedure starts a data collection session. The function and procedure signatures are: + +```text + INTEGER START_PROFILER( TEXT := SYSDATE, + TEXT := '' [, OUT INTEGER ]) + +START_PROFILER( TEXT := SYSDATE, + TEXT := '' [, OUT INTEGER ]) +``` + +**Parameters** + +`run_comment` + + A user-defined comment for the profiler session. The default value is `SYSDATE`. + +`run_comment1` + + An additional user-defined comment for the profiler session. The default value is ''. + +`run_number` + + The session number of the profiler session. + +`status` + + Status code returned by the operation. + +## STOP_PROFILER + +The `STOP_PROFILER` function/procedure stops a profiling session and flushes the performance information to the `DBMS_PROFILER` tables and view. The function and procedure signatures are: + +```text + INTEGER STOP_PROFILER + +STOP_PROFILER +``` + +**Parameters** + +`status` + + Status code returned by the operation. + +## Using DBMS_PROFILER + +The `DBMS_PROFILER` package collects and stores performance information about the PL/pgSQL and SPL statements that are executed during a profiling session; you can review the performance information in the tables and views provided by the profiler. + +`DBMS_PROFILER` works by recording a set of performance-related counters and timers for each line of PL/pgSQL or SPL statement that executes within a profiling session. The counters and timers are stored in a table named `SYS.PLSQL_PROFILER_DATA`. When you complete a profiling session, `DBMS_PROFILER` will write a row to the performance statistics table for each line of PL/pgSQL or SPL code that executed within the session. For example, if you execute the following function: + +```text +1 - CREATE OR REPLACE FUNCTION getBalance(acctNumber INTEGER) +2 - RETURNS NUMERIC AS $$ +3 - DECLARE +4 - result NUMERIC; +5 - BEGIN +6 - SELECT INTO result balance FROM acct WHERE id = acctNumber; +7 - +8 - IF (result IS NULL) THEN +9 - RAISE INFO 'Balance is null'; +10- END IF; +11- +12- RETURN result; +13- END; +14- $$ LANGUAGE 'plpgsql'; +``` + +`DBMS_PROFILER` adds one `PLSQL_PROFILER_DATA` entry for each line of code within the `getBalance()` function (including blank lines and comments). The entry corresponding to the `SELECT` statement executed exactly one time; and required a very small amount of time to execute. On the other hand, the entry corresponding to the `RAISE INFO` statement executed once or not at all (depending on the value for the `balance` column). + +Some of the lines in this function contain no executable code so the performance statistics for those lines will always contain zero values. + +To start a profiling session, invoke the `DBMS_PROFILER.START_PROFILER` function (or procedure). Once you've invoked `START_PROFILER`, Advanced Server will profile every PL/pgSQL or SPL function, procedure, trigger, or anonymous block that your session executes until you either stop or pause the profiler (by calling `STOP_PROFILER` or `PAUSE_PROFILER`). + +It is important to note that when you start (or resume) the profiler, the profiler will only gather performance statistics for functions/procedures/triggers that start after the call to `START_PROFILER` (or `RESUME_PROFILER`). + +While the profiler is active, Advanced Server records a large set of timers and counters in memory; when you invoke the `STOP_PROFILER` (or `FLUSH_DATA`) function/procedure, `DBMS_PROFILER` writes those timers and counters to a set of three tables: + +- `SYS.PLSQL_PROFILER_RAWDATA` + + Contains the performance counters and timers for each statement executed within the session. + +- `SYS.PLSQL_PROFILER_RUNS` + + Contains a summary of each run (aggregating the information found in `PLSQL_PROFILER_RAWDATA`). + +- `SYS.PLSQL_PROFILER_UNITS` + + Contains a summary of each code unit (function, procedure, trigger, or anonymous block) executed within a session. + +In addition, `DBMS_PROFILER` defines a view, `SYS.PLSQL_PROFILER_DATA`, which contains a subset of the `PLSQL_PROFILER_RAWDATA` table. + +Please note that a non-superuser may gather profiling information, but may not view that profiling information unless a superuser grants specific privileges on the profiling tables (stored in the `SYS` schema). This permits a non-privileged user to gather performance statistics without exposing information that the administrator may want to keep secret. + +### Querying the DBMS_PROFILER Tables and View + +The following step-by-step example uses `DBMS_PROFILER` to retrieve performance information for procedures, functions, and triggers included in the sample data distributed with Advanced Server. + +1. Open the EDB-PSQL command line, and establish a connection to the Advanced Server database. Use an `EXEC` statement to start the profiling session: + +```text +acctg=# EXEC dbms_profiler.start_profiler('profile list_emp'); + +EDB-SPL Procedure successfully completed +``` + +!!! Note + (The call to `start_profiler()` includes a comment that `DBMS_PROFILER` associates with the profiler session). + +2. Then call the `list_emp` function: + +```text +acctg=# SELECT list_emp(); +INFO: EMPNO ENAME +INFO: ----- ------- +INFO: 7369 SMITH +INFO: 7499 ALLEN +INFO: 7521 WARD +INFO: 7566 JONES +INFO: 7654 MARTIN +INFO: 7698 BLAKE +INFO: 7782 CLARK +INFO: 7788 SCOTT +INFO: 7839 KING +INFO: 7844 TURNER +INFO: 7876 ADAMS +INFO: 7900 JAMES +INFO: 7902 FORD +INFO: 7934 MILLER + list_emp +---------- + +(1 row) +``` + +3. Stop the profiling session with a call to `dbms_profiler.stop_profiler:` + +```text +acctg=# EXEC dbms_profiler.stop_profiler; + +EDB-SPL Procedure successfully completed +``` + +4. Start a new session with the `dbms_profiler.start_profiler` function (followed by a new comment): + +```text +acctg=# EXEC dbms_profiler.start_profiler('profile get_dept_name and +emp_sal_trig'); + +EDB-SPL Procedure successfully completed +``` + +5. Invoke the `get_dept_name` function: + +```text +acctg=# SELECT get_dept_name(10); + get_dept_name +--------------- + ACCOUNTING +(1 row) +``` + +6. Execute an `UPDATE` statement that causes a trigger to execute: + +```text +acctg=# UPDATE memp SET sal = 500 WHERE empno = 7902; +INFO: Updating employee 7902 +INFO: ..Old salary: 3000.00 +INFO: ..New salary: 500.00 +INFO: ..Raise: -2500.00 +INFO: User enterprisedb updated employee(s) on 04-FEB-14 +UPDATE 1 +``` + +7. Terminate the profiling session and flush the performance information to the profiling tables: + +```text +acctg=# EXEC dbms_profiler.stop_profiler; + +EDB-SPL Procedure successfully completed +``` + +8. Now, query the `plsql_profiler_runs` table to view a list of the profiling sessions, arranged by `runid:` + +```text +acctg=# SELECT * FROM plsql_profiler_runs; + runid | related_run | run_owner | run_date + | run_comment | run_total_time | run_system_info + | run_comment1 | spare1 +-------+-------------+--------------+---------------------------+------------- +---------------------------+----------------+-----------------+-------------- ++-------- + 1 | | enterprisedb | 04-FEB-14 09:32:48.874315 | profile + list_emp | 4154 | + | | + 2 | | enterprisedb | 04-FEB-14 09:41:30.546503 | profile + get_dept_name and emp_sal_trig | 2088 | + | | +(2 rows) +``` + +9. Query the `plsql_profiler_units` table to view the amount of time consumed by each unit (each function, procedure, or trigger): + +```text +acctg=# SELECT * FROM plsql_profiler_units; + runid | unit_number | unit_type | unit_owner | + unit_name | unit_timestamp | total_time | spare1 | spare2 +-------+-------------+-----------+--------------+---------------------------- +-----+----------------+------------+--------+-------- + 1 | 16999 | FUNCTION | enterprisedb | + list_emp() | | 4 | | + 2 | 17002 | FUNCTION | enterprisedb | + user_audit_trig() | | 1 | | + 2 | 17000 | FUNCTION | enterprisedb | get_dept_name(p_deptno + numeric) | | 1 | | + 2 | 17004 | FUNCTION | enterprisedb | + emp_sal_trig() | | 1 | | +(4 rows) +``` + +10. Query the `plsql_profiler_rawdata` table to view a list of the wait event counters and wait event times: + +```text +acctg=# SELECT runid, sourcecode, func_oid, line_number, exec_count, +tuples_returned, time_total FROM plsql_profiler_rawdata; + + runid | sourcecode | + func_oid | line_number | exec_count | tuples_returned | time_total +-------+-----------------------------------------------------------------+--- +-------+-------------+------------+-----------------+------------ + 1 | DECLARE + | 16999 | 1 | 0 | 0 | 0 + 1 | v_empno NUMERIC(4); + | 16999 | 2 | 0 | 0 | 0 + 1 | v_ename VARCHAR(10); + | 16999 | 3 | 0 | 0 | 0 + 1 | emp_cur CURSOR FOR + | 16999 | 4 | 0 | 0 | 0 + 1 | SELECT empno, ename FROM memp ORDER BY empno; + | 16999 | 5 | 0 | 0 | 0 + 1 | BEGIN + | 16999 | 6 | 0 | 0 | 0 + 1 | OPEN emp_cur; + | 16999 | 7 | 0 | 0 | 0 + 1 | RAISE INFO 'EMPNO ENAME'; + | 16999 | 8 | 1 | 0 | 0.001621 + 1 | RAISE INFO '----- -------'; + | 16999 | 9 | 1 | 0 | 0.000301 + 1 | LOOP + | 16999 | 10 | 1 | 0 | 4.6e-05 + 1 | FETCH emp_cur INTO v_empno, v_ename; + | 16999 | 11 | 1 | 0 | 0.001114 + 1 | EXIT WHEN NOT FOUND; + | 16999 | 12 | 15 | 0 | 0.000206 + 1 | RAISE INFO '% %', v_empno, v_ename; + | 16999 | 13 | 15 | 0 | 8.3e-05 + 1 | END LOOP; + | 16999 | 14 | 14 | 0 | 0.000773 + 1 | CLOSE emp_cur; + | 16999 | 15 | 0 | 0 | 0 + 1 | RETURN; + | 16999 | 16 | 1 | 0 | 1e-05 + 1 | END; + | 16999 | 17 | 1 | 0 | 0 + 1 | + | 16999 | 18 | 0 | 0 | 0 + 2 | DECLARE + | 17002 | 1 | 0 | 0 | 0 + 2 | v_action VARCHAR(24); + | 17002 | 2 | 0 | 0 | 0 + 2 | v_text TEXT; + | 17002 | 3 | 0 | 0 | 0 + 2 | BEGIN + | 17002 | 4 | 0 | 0 | 0 + 2 | IF TG_OP = 'INSERT' THEN + | 17002 | 5 | 0 | 0 | 0 + 2 | v_action := ' added employee(s) on '; + | 17002 | 6 | 1 | 0 | 0.000143 + 2 | ELSIF TG_OP = 'UPDATE' THEN + | 17002 | 7 | 0 | 0 | 0 + 2 | v_action := ' updated employee(s) on '; + | 17002 | 8 | 0 | 0 | 0 + 2 | ELSIF TG_OP = 'DELETE' THEN + | 17002 | 9 | 1 | 0 | 3.2e-05 + 2 | v_action := ' deleted employee(s) on '; + | 17002 | 10 | 0 | 0 | 0 + 2 | END IF; + | 17002 | 11 | 0 | 0 | 0 + 2 | v_text := 'User ' || USER || v_action || CURRENT_DATE; + | 17002 | 12 | 0 | 0 | 0 + 2 | RAISE INFO ' %', v_text; + | 17002 | 13 | 1 | 0 | 0.000383 + 2 | RETURN NULL; + | 17002 | 14 | 1 | 0 | 6.3e-05 + 2 | END; + | 17002 | 15 | 1 | 0 | 3.6e-05 + 2 | + | 17002 | 16 | 0 | 0 | 0 + 2 | DECLARE + | 17000 | 1 | 0 | 0 | 0 + 2 | v_dname VARCHAR(14); + | 17000 | 2 | 0 | 0 | 0 + 2 | BEGIN + | 17000 | 3 | 0 | 0 | 0 + 2 | SELECT INTO v_dname dname FROM dept WHERE deptno = p_deptno; + | 17000 | 4 | 0 | 0 | 0 + 2 | RETURN v_dname; + | 17000 | 5 | 1 | 0 | 0.000647 + 2 | IF NOT FOUND THEN + | 17000 | 6 | 1 | 0 | 2.6e-05 + 2 | RAISE INFO 'Invalid department number %', p_deptno; + | 17000 | 7 | 0 | 0 | 0 + 2 | RETURN ''; + | 17000 | 8 | 0 | 0 | 0 + 2 | END IF; + | 17000 | 9 | 0 | 0 | 0 + 2 | END; + | 17000 | 10 | 0 | 0 | 0 + 2 | + | 17000 | 11 | 0 | 0 | 0 + 2 | DECLARE + | 17004 | 1 | 0 | 0 | 0 + 2 | sal_diff NUMERIC(7,2); + | 17004 | 2 | 0 | 0 | 0 + 2 | BEGIN + | 17004 | 3 | 0 | 0 | 0 + 2 | IF TG_OP = 'INSERT' THEN + | 17004 | 4 | 0 | 0 | 0 + 2 | RAISE INFO 'Inserting employee %', NEW.empno; + | 17004 | 5 | 1 | 0 | 8.4e-05 + 2 | RAISE INFO '..New salary: %', NEW.sal; + | 17004 | 6 | 0 | 0 | 0 + 2 | RETURN NEW; + | 17004 | 7 | 0 | 0 | 0 + 2 | END IF; + | 17004 | 8 | 0 | 0 | 0 + 2 | IF TG_OP = 'UPDATE' THEN + | 17004 | 9 | 0 | 0 | 0 + 2 | sal_diff := NEW.sal - OLD.sal; + | 17004 | 10 | 1 | 0 | 0.000355 + 2 | RAISE INFO 'Updating employee %', OLD.empno; + | 17004 | 11 | 1 | 0 | 0.000177 + 2 | RAISE INFO '..Old salary: %', OLD.sal; + | 17004 | 12 | 1 | 0 | 5.5e-05 + 2 | RAISE INFO '..New salary: %', NEW.sal; + | 17004 | 13 | 1 | 0 | 3.1e-05 + 2 | RAISE INFO '..Raise : %', sal_diff; + | 17004 | 14 | 1 | 0 | 2.8e-05 + 2 | RETURN NEW; + | 17004 | 15 | 1 | 0 | 2.7e-05 + 2 | END IF; + | 17004 | 16 | 1 | 0 | 1e-06 + 2 | IF TG_OP = 'DELETE' THEN + | 17004 | 17 | 0 | 0 | 0 + 2 | RAISE INFO 'Deleting employee %', OLD.empno; + | 17004 | 18 | 0 | 0 | 0 + 2 | RAISE INFO '..Old salary: %', OLD.sal; + | 17004 | 19 | 0 | 0 | 0 + 2 | RETURN OLD; + | 17004 | 20 | 0 | 0 | 0 + 2 | END IF; + | 17004 | 21 | 0 | 0 | 0 + 2 | END; + | 17004 | 22 | 0 | 0 | 0 + 2 | + | 17004 | 23 | 0 | 0 | 0 + (68 rows) +                                                                                                                    +``` + +11. Query the `plsql_profiler_data` view to review a subset of the information found in `plsql_profiler_rawdata` table: + +```text +acctg=# SELECT * FROM plsql_profiler_data; +runid | unit_number | line# | total_occur | total_time | min_time | max_time +| spare1 | spare2 | spare3 | spare4 +-------+-------------+-------+-------------+------------+----------+--------- +-+--------+--------+--------+-------- + 1 | 16999 | 1 | 0 | 0 | 0 | + 0 | | | | + 1 | 16999 | 2 | 0 | 0 | 0 | + 0 | | | | + 1 | 16999 | 3 | 0 | 0 | 0 | + 0 | | | | + 1 | 16999 | 4 | 0 | 0 | 0 | + 0 | | | | + 1 | 16999 | 5 | 0 | 0 | 0 | + 0 | | | | + 1 | 16999 | 6 | 0 | 0 | 0 | + 0 | | | | + 1 | 16999 | 7 | 0 | 0 | 0 | + 0 | | | | + 1 | 16999 | 8 | 1 | 0.001621 | 0.001621 | + 0.001621 | | | | + 1 | 16999 | 9 | 1 | 0.000301 | 0.000301 | + 0.000301 | | | | + 1 | 16999 | 10 | 1 | 4.6e-05 | 4.6e-05 | 4.6e- + 05 | | | | + 1 | 16999 | 11 | 1 | 0.001114 | 0.001114 | + 0.001114 | | | | + 1 | 16999 | 12 | 15 | 0.000206 | 5e-06 | 7.8e- + 05 | | | | + 1 | 16999 | 13 | 15 | 8.3e-05 | 2e-06 | 4.7e- + 05 | | | | + 1 | 16999 | 14 | 14 | 0.000773 | 4.7e-05 | + 0.000116 | | | | + 1 | 16999 | 15 | 0 | 0 | 0 | + 0 | | | | + 1 | 16999 | 16 | 1 | 1e-05 | 1e-05 | 1e- + 05 | | | | + 1 | 16999 | 17 | 1 | 0 | 0 | + 0 | | | | + 1 | 16999 | 18 | 0 | 0 | 0 | + 0 | | | | + 2 | 17002 | 1 | 0 | 0 | 0 | + 0 | | | | + 2 | 17002 | 2 | 0 | 0 | 0 | + 0 | | | | + 2 | 17002 | 3 | 0 | 0 | 0 | + 0 | | | | + 2 | 17002 | 4 | 0 | 0 | 0 | + 0 | | | | + 2 | 17002 | 5 | 0 | 0 | 0 | + 0 | | | | + 2 | 17002 | 6 | 1 | 0.000143 | 0.000143 | + 0.000143 | | | | + 2 | 17002 | 7 | 0 | 0 | 0 | + 0 | | | | + 2 | 17002 | 8 | 0 | 0 | 0 | + 0 | | | | + 2 | 17002 | 9 | 1 | 3.2e-05 | 3.2e-05 | 3.2e- + 05 | | | | + 2 | 17002 | 10 | 0 | 0 | 0 | + 0 | | | | + 2 | 17002 | 11 | 0 | 0 | 0 | + 0 | | | | + 2 | 17002 | 12 | 0 | 0 | 0 | + 0 | | | | + 2 | 17002 | 13 | 1 | 0.000383 | 0.000383 | + 0.000383 | | | | + 2 | 17002 | 14 | 1 | 6.3e-05 | 6.3e-05 | 6.3e- + 05 | | | | + 2 | 17002 | 15 | 1 | 3.6e-05 | 3.6e-05 | 3.6e- + 05 | | | | + 2 | 17002 | 16 | 0 | 0 | 0 | + 0 | | | | + 2 | 17000 | 1 | 0 | 0 | 0 | + 0 | | | | + 2 | 17000 | 2 | 0 | 0 | 0 | + 0 | | | | + 2 | 17000 | 3 | 0 | 0 | 0 | + 0 | | | | + 2 | 17000 | 4 | 0 | 0 | 0 | + 0 | | | | + 2 | 17000 | 5 | 1 | 0.000647 | 0.000647 | + 0.000647 | | | | + 2 | 17000 | 6 | 1 | 2.6e-05 | 2.6e-05 | 2.6e- + 05 | | | | + 2 | 17000 | 7 | 0 | 0 | 0 | + 0 | | | | + 2 | 17000 | 8 | 0 | 0 | 0 | + 0 | | | | + 2 | 17000 | 9 | 0 | 0 | 0 | + 0 | | | | + 2 | 17000 | 10 | 0 | 0 | 0 | + 0 | | | | + 2 | 17000 | 11 | 0 | 0 | 0 | + 0 | | | | + 2 | 17004 | 1 | 0 | 0 | 0 | + 0 | | | | + 2 | 17004 | 2 | 0 | 0 | 0 | + 0 | | | | + 2 | 17004 | 3 | 0 | 0 | 0 | + 0 | | | | + 2 | 17004 | 4 | 0 | 0 | 0 | + 0 | | | | + 2 | 17004 | 5 | 1 | 8.4e-05 | 8.4e-05 | 8.4e- + 05 | | | | + 2 | 17004 | 6 | 0 | 0 | 0 | + 0 | | | | + 2 | 17004 | 7 | 0 | 0 | 0 | + 0 | | | | + 2 | 17004 | 8 | 0 | 0 | 0 | + 0 | | | | + 2 | 17004 | 9 | 0 | 0 | 0 | + 0 | | | | + 2 | 17004 | 10 | 1 | 0.000355 | 0.000355 | + 0.000355 | | | | + 2 | 17004 | 11 | 1 | 0.000177 | 0.000177 | + 0.000177 | | | | + 2 | 17004 | 12 | 1 | 5.5e-05 | 5.5e-05 | 5.5e- + 05 | | | | + 2 | 17004 | 13 | 1 | 3.1e-05 | 3.1e-05 | 3.1e- + 05 | | | | + 2 | 17004 | 14 | 1 | 2.8e-05 | 2.8e-05 | 2.8e- + 05 | | | | + 2 | 17004 | 15 | 1 | 2.7e-05 | 2.7e-05 | 2.7e- + 05 | | | | + 2 | 17004 | 16 | 1 | 1e-06 | 1e-06 | 1e- + 06 | | | | + 2 | 17004 | 17 | 0 | 0 | 0 | + 0 | | | | + 2 | 17004 | 18 | 0 | 0 | 0 | + 0 | | | | + 2 | 17004 | 19 | 0 | 0 | 0 | + 0 | | | | + 2 | 17004 | 20 | 0 | 0 | 0 | + 0 | | | | + 2 | 17004 | 21 | 0 | 0 | 0 | + 0 | | | | + 2 | 17004 | 22 | 0 | 0 | 0 | + 0 | | | | + 2 | 17004 | 23 | 0 | 0 | 0 | + 0 | | | | +(68 rows) +``` + +### DBMS_PROFILER - Reference + +The Advanced Server installer creates the following tables and views that you can query to review PL/SQL performance profile information: + +| Table Name | Description | +| ------------------------ | -------------------------------------------------------------------------------------------------------------------- | +| `PLSQL_PROFILER_RUNS` | Table containing information about all profiler runs, organized by `runid`. | +| `PLSQL_PROFILER_UNITS` | Table containing information about all profiler runs, organized by unit. | +| `PLSQL_PROFILER_DATA` | View containing performance statistics. | +| `PLSQL_PROFILER_RAWDATA` | Table containing the performance statistics `and` the extended performance statistics for DRITA counters and timers. | + +#### PLSQL_PROFILER_RUNS + +The `PLSQL_PROFILER_RUNS` table contains the following columns: + +| Column | Data Type | Description | +| ----------------- | ----------------------------- | ---------------------------------------------- | +| `runid` | `INTEGER (NOT NULL)` | Unique identifier (`plsql_profiler_runnumber`) | +| `related_run` | `INTEGER` | The `runid` of a related run. | +| `run_owner` | `TEXT` | The role that recorded the profiling session. | +| `run_date` | `TIMESTAMP WITHOUT TIME ZONE` | The profiling session start time. | +| `run_comment` | `TEXT` | User comments relevant to this run | +| `run_total_time` | `BIGINT` | Run time (in microseconds) | +| `run_system_info` | `TEXT` | Currently Unused | +| `run_comment1` | `TEXT` | Additional user comments | +| `spare1` | `TEXT` | Currently Unused | + +#### PLSQL_PROFILER_UNITS + +The `PLSQL_PROFILER_UNITS` table contains the following columns: + +| Column | Data Type | Description | +| ---------------- | ----------------------------- | -------------------------------------------------------------------------------- | +| `runid` | `INTEGER` | Unique identifier (`plsql_profiler_runnumber`) | +| `unit_number` | `OID` | Corresponds to the OID of the row in the pg_proc table that identifies the unit. | +| `unit_type` | `TEXT` | PL/SQL function, procedure, trigger or anonymous block | +| `unit_owner` | `TEXT` | The identity of the role that owns the unit. | +| `unit_name` | `TEXT` | The complete signature of the unit. | +| `unit_timestamp` | `TIMESTAMP WITHOUT TIME ZONE` | Creation date of the unit (currently NULL). | +| `total_time` | `BIGINT` | Time spent within the unit (in milliseconds) | +| `spare1` | `BIGINT` | Currently Unused | +| `spare2` | `BIGINT` | Currently Unused | + +#### PLSQL_PROFILER_DATA + +The `PLSQL_PROFILER_DATA` view contains the following columns: + +| Column | Data Type | Description | +| ------------- | ------------------ | -------------------------------------------------------- | +| `runid` | `INTEGER` | Unique identifier (`plsql_profiler_runnumber`) | +| `unit_number` | `OID` | Object ID of the unit that contains the current line. | +| `line#` | `INTEGER` | Current line number of the profiled workload. | +| `total_occur` | `BIGINT` | The number of times that the line was executed. | +| `total_time` | `DOUBLE PRECISION` | The amount of time spent executing the line (in seconds) | +| `min_time` | `DOUBLE PRECISION` | The minimum execution time for the line. | +| `max_time` | `DOUBLE PRECISION` | The maximum execution time for the line. | +| `spare1` | `NUMBER` | Currently Unused | +| `spare2` | `NUMBER` | Currently Unused | +| `spare3` | `NUMBER` | Currently Unused | +| `spare4` | `NUMBER` | Currently Unused | + +#### PLSQL_PROFILER_RAWDATA + +The `PLSQL_PROFILER_RAWDATA` table contains the statistical and wait events information that is found in the `PLSQL_PROFILER_DATA` view, as well as the performance statistics returned by the DRITA counters and timers. + +| Column | Data Type | Description | +| ---------------------------------------- | ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `runid` | `INTEGER` | The run identifier `(plsql_profiler_runnumber)`. | +| `sourcecode` | `TEXT` | The individual line of profiled code. | +| `func_oid` | `OID` | Object ID of the unit that contains the current line. | +| `line_number` | `INTEGER` | Current line number of the profiled workload. | +| `exec_count` | `BIGINT` | The number of times that the line was executed. | +| `tuples_returned` | `BIGINT` | Currently Unused | +| `time_total` | `DOUBLE PRECISION` | The amount of time spent executing the line (in seconds) | +| `time_shortest` | `DOUBLE PRECISION` | The minimum execution time for the line. | +| `time_longest` | `DOUBLE PRECISION` | The maximum execution time for the line. | +| `num_scans` | `BIGINT` | Currently Unused | +| `tuples_fetched` | `BIGINT` | Currently Unused | +| `tuples_inserted` | `BIGINT` | Currently Unused | +| `tuples_updated` | `BIGINT` | Currently Unused | +| `tuples_deleted` | `BIGINT` | Currently Unused | +| `blocks_fetched` | `BIGINT` | Currently Unused | +| `blocks_hit` | `BIGINT` | Currently Unused | +| `wal_write` | `BIGINT` | A server has waited for a write to the write-ahead log buffer (expect this value to be high). | +| `wal_flush` | `BIGINT` | A server has waited for the write-ahead log to flush to disk. | +| `wal_file_sync` | `BIGINT` | A server has waited for the write-ahead log to sync to disk (related to the `wal_sync_method` parameter which, by default, is 'fsync' - better performance can be gained by changing this parameter to `open_sync`). | +| `db_file_read` | `BIGINT` | A server has waited for the completion of a read (from disk). | +| `db_file_write` | `BIGINT` | A server has waited for the completion of a write (to disk). | +| `db_file_sync` | `BIGINT` | A server has waited for the operating system to flush all changes to disk. | +| `db_file_extend` | `BIGINT` | A server has waited for the operating system while adding a new page to the end of a file. | +| `sql_parse` | `BIGINT` | Currently Unused. | +| `query_plan` | `BIGINT` | A server has generated a query plan. | +| `other_lwlock_acquire` | `BIGINT` | A server has waited for other light-weight lock to protect data. | +| `shared_plan_cache_collision` | `BIGINT` | A server has waited for the completion of the `shared_plan_cache_collision` event. | +| `shared_plan_cache_insert` | `BIGINT` | A server has waited for the completion of the `shared_plan_cache_insert` event. | +| `shared_plan_cache_hit` | `BIGINT` | A server has waited for the completion of the `shared_plan_cache_hit` event. | +| `shared_plan_cache_miss` | `BIGINT` | A server has waited for the completion of the `shared_plan_cache_miss` event. | +| `shared_plan_cache_lock` | `BIGINT` | A server has waited for the completion of the `shared_plan_cache_lock` event. | +| `shared_plan_cache_busy` | `BIGINT` | A server has waited for the completion of the `shared_plan_cache_busy` event. | +| `shmemindexlock` | `BIGINT` | A server has waited to find or allocate space in the shared memory. | +| `oidgenlock` | `BIGINT` | A server has waited to allocate or assign an OID. | +| `xidgenlock` | `BIGINT` | A server has waited to allocate or assign a transaction ID. | +| `procarraylock` | `BIGINT` | A server has waited to get a snapshot or clearing a transaction ID at transaction end. | +| `sinvalreadlock` | `BIGINT` | A server has waited to retrieve or remove messages from shared invalidation queue. | +| `sinvalwritelock` | `BIGINT` | A server has waited to add a message to the shared invalidation queue. | +| `walbufmappinglock` | `BIGINT` | A server has waited to replace a page in WAL buffers. | +| `walwritelock` | `BIGINT` | A server has waited for WAL buffers to be written to disk. | +| `controlfilelock` | `BIGINT` | A server has waited to read or update the control file or creation of a new WAL file. | +| `checkpointlock` | `BIGINT` | A server has waited to perform a checkpoint. | +| `clogcontrollock` | `BIGINT` | A server has waited to read or update the transaction status. | +| `subtranscontrollock` | `BIGINT` | A server has waited to read or update the sub-transaction information. | +| `multixactgenlock` | `BIGINT` | A server has waited to read or update the shared multixact state. | +| `multixactoffsetcontrollock` | `BIGINT` | A server has waited to read or update multixact offset mappings. | +| `multixactmembercontrollock` | `BIGINT` | A server has waited to read or update multixact member mappings. | +| `relcacheinitlock` | `BIGINT` | A server has waited to read or write the relation cache initialization file. | +| `checkpointercommlock` | `BIGINT` | A server has waited to manage the fsync requests. | +| `twophasestatelock` | `BIGINT` | A server has waited to read or update the state of prepared transactions. | +| `tablespacecreatelock` | `BIGINT` | A server has waited to create or drop the tablespace. | +| `btreevacuumlock` | `BIGINT` | A server has waited to read or update the vacuum related information for a B-tree index. | +| `addinshmeminitlock` | `BIGINT` | A server has waited to manage space allocation in shared memory. | +| `autovacuumlock` | `BIGINT` | The autovacuum launcher waiting to read or update the current state of autovacuum workers. | +| `autovacuumschedulelock` | `BIGINT` | A server has waited to ensure that the table selected for a vacuum still needs vacuuming. | +| `syncscanlock` | `BIGINT` | A server has waited to get the start location of a scan on a table for synchronized scans. | +| `relationmappinglock` | `BIGINT` | A server has waited to update the relation map file used to store catalog to file node mapping. | +| `asyncctllock` | `BIGINT` | A server has waited to read or update shared notification state. | +| `asyncqueuelock` | `BIGINT` | A server has waited to read or update the notification messages. | +| `serializablexacthashlock` | `BIGINT` | A server has waited to retrieve or store information about serializable transactions. | +| `serializablefinishedlistlock` | `BIGINT` | A server has waited to access the list of finished serializable transactions. | +| `serializablepredicatelocklistlock` | `BIGINT` | A server has waited to perform an operation on a list of locks held by serializable transactions. | +| `oldserxidlock` | `BIGINT` | A server has waited to read or record the conflicting serializable transactions. | +| `syncreplock` | `BIGINT` | A server has waited to read or update information about synchronous replicas. | +| `backgroundworkerlock` | `BIGINT` | A server has waited to read or update the background worker state. | +| `dynamicsharedmemorycontrollock` | `BIGINT` | A server has waited to read or update the dynamic shared memory state. | +| `autofilelock` | `BIGINT` | A server has waited to update the `postgresql.auto.conf` file. | +| `replicationslotallocationlock` | `BIGINT` | A server has waited to allocate or free a replication slot. | +| `replicationslotcontrollock` | `BIGINT` | A server has waited to read or update replication slot state. | +| `committscontrollock` | `BIGINT` | A server has waited to read or update transaction commit timestamps. | +| `committslock` | `BIGINT` | A server has waited to read or update the last value set for the transaction timestamp. | +| `replicationoriginlock` | `BIGINT` | A server has waited to set up, drop, or use replication origin. | +| `multixacttruncationlock` | `BIGINT` | A server has waited to read or truncate multixact information. | +| `oldsnapshottimemaplock` | `BIGINT` | A server has waited to read or update old snapshot control information. | +| `backendrandomlock` | `BIGINT` | A server has waited to generate a random number. | +| `logicalrepworkerlock` | `BIGINT` | A server has waited for the action on logical replication worker to finish. | +| `clogtruncationlock` | `BIGINT` | A server has waited to truncate the write-ahead log or waiting for write-ahead log truncation to finish. | +| `bulkloadlock` | `BIGINT` | A server has waited for the `bulkloadlock` to bulk upload the data. | +| `edbresourcemanagerlock` | `BIGINT` | The `edbresourcemanagerlock` provides detail about edb resource manager lock module. | +| `wal_write_time` | `BIGINT` | The amount of time that the server has waited for a `wal_write` wait event to write to the write-ahead log buffer (expect this value to be high). | +| `wal_flush_time` | `BIGINT` | The amount of time that the server has waited for a `wal_flush` wait event to write-ahead log to flush to disk. | +| `wal_file_sync_time` | `BIGINT` | The amount of time that the server has waited for a `wal_file_sync` wait event to write-ahead log to sync to disk (related to the wal_sync_method parameter which, by default, is 'fsync' - better performance can be gained by changing this parameter to open_sync). | +| `db_file_read_time` | `BIGINT` | The amount of time that the server has waited for the `db_file_read` wait event for completion of a read (from disk). | +| `db_file_write_time` | `BIGINT` | The amount of time that the server has waited for the `db_file_write` wait event for completion of a write (to disk). | +| `db_file_sync_time` | `BIGINT` | The amount of time that the server has waited for the `db_file_sync` wait event to sync all changes to disk. | +| `db_file_extend_time` | `BIGINT` | The amount of time that the server has waited for the `db_file_extend` wait event while adding a new page to the end of a file. | +| `sql_parse_time` | `BIGINT` | The amount of time that the server has waited for the `sql_parse` wait event to parse a SQL statement. | +| `query_plan_time` | `BIGINT` | The amount of time that the server has waited for the `query_plan` wait event to compute the execution plan for a SQL statement. | +| `other_lwlock_acquire_time` | `BIGINT` | The amount of time that the server has waited for the `other_lwlock_acquire` wait event to protect data. | +| `shared_plan_cache_collision_time` | `BIGINT` | The amount of time that the server has waited for the `shared_plan_cache_collision` wait event. | +| `shared_plan_cache_insert_time` | `BIGINT` | The amount of time that the server has waited for the `shared_plan_cache_insert` wait event. | +| `shared_plan_cache_hit_time` | `BIGINT` | The amount of time that the server has waited for the `shared_plan_cache_hit` wait event. | +| `shared_plan_cache_miss_time` | `BIGINT` | The amount of time that the server has waited for the `shared_plan_cache_miss` wait event. | +| `shared_plan_cache_lock_time` | `BIGINT` | The amount of time that the server has waited for the `shared_plan_cache_lock` wait event. | +| `shared_plan_cache_busy_time` | `BIGINT` | The amount of time that the server has waited for the `shared_plan_cache_busy` wait event. | +| `shmemindexlock_time` | `BIGINT` | The amount of time that the server has waited for the `shmemindexlock` wait event to find or allocate space in the shared memory. | +| `oidgenlock_time` | `BIGINT` | The amount of time that the server has waited for the `oidgenlock` wait event to allocate or assign an OID. | +| `xidgenlock_time` | `BIGINT` | The amount of time that the server has waited for `xidgenlock` wait event to allocate or assign a transaction ID. | +| `procarraylock_time` | `BIGINT` | The amount of time that the server has waited for a `procarraylock` wait event to clear a transaction ID at transaction end. | +| `sinvalreadlock_time` | `BIGINT` | The amount of time that the server has waited for a `sinvalreadlock` wait event to retrieve or remove messages from shared invalidation queue. | +| `sinvalwritelock_time` | `BIGINT` | The amount of time that the server has waited for a `sinvalwritelock` wait event to add a message to the shared invalidation queue. | +| `walbufmappinglock_time` | `BIGINT` | The amount of time that the server has waited for a `walbufmappinglock` wait event to replace a page in WAL buffers. | +| `walwritelock_time` | `BIGINT` | The amount of time that the server has waited for a `walwritelock` wait event to write the WAL buffers to disk. | +| `controlfilelock_time` | `BIGINT` | The amount of time that the server has waited for a `controlfilelock` wait event to read or update the control file or to create a new WAL file. | +| `checkpointlock_time` | `BIGINT` | The amount of time that the server has waited for a `checkpointlock` wait event to perform a checkpoint. | +| `clogcontrollock_time` | `BIGINT` | The amount of time that the server has waited for a `clogcontrollock` wait event to read or update the transaction status. | +| `subtranscontrollock_time` | `BIGINT` | The amount of time that the server has waited for the `subtranscontrollock` wait event to read or update the sub-transaction information. | +| `multixactgenlock_time` | `BIGINT` | The amount of time that the server has waited for the `multixactgenlock` wait event to read or update the shared multixact state. | +| `multixactoffsetcontrollock_time` | `BIGINT` | The amount of time that the server has waited for the `multixactoffsetcontrollock` wait event to read or update multixact offset mappings. | +| `multixactmembercontrollock_time` | `BIGINT` | The amount of time that the server has waited for the `multixactmembercontrollock` wait event to read or update multixact member mappings. | +| `relcacheinitlock_time` | `BIGINT` | The amount of time that the server has waited for the `relcacheinitlock` wait event to read or write the relation cache initialization file. | +| `checkpointercommlock_time` | `BIGINT` | The amount of time that the server has waited for the `checkpointercommlock` wait event to manage the fsync requests. | +| `twophasestatelock_time` | `BIGINT` | The amount of time that the server has waited for the `twophasestatelock` wait event to read or update the state of prepared transactions. | +| `tablespacecreatelock_time` | `BIGINT` | The amount of time that the server has waited for the `tablespacecreatelock` wait event to create or drop the tablespace. | +| `btreevacuumlock_time` | `BIGINT` | The amount of time that the server has waited for the `btreevacuumlock` wait event to read or update the vacuum related information for a B-tree index. | +| `addinshmeminitlock_time` | `BIGINT` | The amount of time that the server has waited for the `addinshmeminitlock` wait event to manage space allocation in shared memory. | +| `autovacuumlock_time` | `BIGINT` | The amount of time that the server has waited for the `autovacuumlock` wait event to read or update the current state of autovacuum workers. | +| `autovacuumschedulelock_time` | `BIGINT` | The amount of time that the server has waited for the `autovacuumschedulelock` wait event to ensure that the table selected for a vacuum still needs vacuuming. | +| `syncscanlock_time` | `BIGINT` | The amount of time that the server has waited for the `syncscanlock` wait event to get the start location of a scan on a table for synchronized scans. | +| `relationmappinglock_time` | `BIGINT` | The amount of time that the server has waited for the `relationmappinglock` wait event to update the relation map file used to store catalog to file node mapping. | +| `asyncctllock_time` | `BIGINT` | The amount of time that the server has waited for the `asyncctllock` wait event to read or update shared notification state. | +| `asyncqueuelock_time` | `BIGINT` | The amount of time that the server has waited for the `asyncqueuelock` wait event to read or update the notification messages. | +| `serializablexacthashlock_time` | `BIGINT` | The amount of time that the server has waited for the `serializablexacthashlock` wait event to retrieve or store information about serializable transactions. | +| `serializablefinishedlistlock_time` | `BIGINT` | The amount of time that the server has waited for the `serializablefinishedlistlock` wait event to access the list of finished serializable transactions. | +| `serializablepredicatelocklistlock_time` | `BIGINT` | The amount of time that the server has waited for the `serializablepredicatelocklistlock` wait event to perform an operation on a list of locks held by serializable transactions. | +| `oldserxidlock_time` | `BIGINT` | The amount of time that the server has waited for the `oldserxidlock` wait event to read or record the conflicting serializable transactions. | +| `syncreplock_time` | `BIGINT` | The amount of time that the server has waited for the `syncreplock` wait event to read or update information about synchronous replicas. | +| `backgroundworkerlock_time` | `BIGINT` | The amount of time that the server has waited for the `backgroundworkerlock` wait event to read or update the background worker state. | +| `dynamicsharedmemorycontrollock_time` | `BIGINT` | The amount of time that the server has waited for the `dynamicsharedmemorycontrollock` wait event to read or update the dynamic shared memory state. | +| `autofilelock_time` | `BIGINT` | The amount of time that the server has waited for the `autofilelock` wait event to update the `postgresql.auto.conf` file. | +| `replicationslotallocationlock_time` | `BIGINT` | The amount of time that the server has waited for the `replicationslotallocationlock` wait event to allocate or free a replication slot. | +| `replicationslotcontrollock_time` | `BIGINT` | The amount of time that the server has waited for the `replicationslotcontrollock` wait event to read or update replication slot state. | +| `committscontrollock_time` | `BIGINT` | The amount of time that the server has waited for the `committscontrollock` wait event to read or update transaction commit timestamps. | +| `committslock_time` | `BIGINT` | The amount of time that the server has waited for the `committslock` wait event to read or update the last value set for the transaction timestamp. | +| `replicationoriginlock_time` | `BIGINT` | The amount of time that the server has waited for the `replicationoriginlock` wait event to set up, drop, or use replication origin. | +| `multixacttruncationlock_time` | `BIGINT` | The amount of time that the server has waited for the `multixacttruncationlock` wait event to read or truncate multixact information. | +| `oldsnapshottimemaplock_time` | `BIGINT` | The amount of time that the server has waited for the `oldsnapshottimemaplock` wait event to read or update old snapshot control information. | +| `backendrandomlock_time` | `BIGINT` | The amount of time that the server has waited for the `backendrandomlock` wait event to generate a random number. | +| `logicalrepworkerlock_time` | `BIGINT` | The amount of time that the server has waited for the `logicalrepworkerlock` wait event for an action on logical replication worker to finish. | +| `clogtruncationlock_time` | `BIGINT` | The amount of time that the server has waited for the `clogtruncationlock` wait event to truncate the write-ahead log or waiting for write-ahead log truncation to finish. | +| `bulkloadlock_time` | `BIGINT` | The amount of time that the server has waited for the `bulkloadlock` wait event to bulk upload the data. | +| `edbresourcemanagerlock_time` | `BIGINT` | The amount of time that the server has waited for the `edbresourcemanagerlock` wait event. | +| `totalwaits` | `BIGINT` | The total number of event waits. | +| `totalwaittime` | `BIGINT` | The total time spent waiting for an event. | diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/12_dbms_random.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/12_dbms_random.mdx new file mode 100644 index 00000000000..2a237c8fc29 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/12_dbms_random.mdx @@ -0,0 +1,235 @@ +--- +title: "DBMS_RANDOM" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/dbms_random.html" +--- + +The `DBMS_RANDOM` package provides a number of methods to generate random values. The procedures and functions available in the `DBMS_RANDOM` package are listed in the following table. + +| Function/Procedure | Return Type | Description | +| ------------------ | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | +| `INITIALIZE(val)` | n/a | Initializes the `DBMS_RANDOM` package with the specified seed `value`. Deprecated, but supported for backward compatibility. | +| `NORMAL()` | `NUMBER` | Returns a random `NUMBER`. | +| `RANDOM` | `INTEGER` | Returns a random `INTEGER` with a value greater than or equal to -2^31 and less than 2^31. Deprecated, but supported for backward compatibility. | +| `SEED(val)` | n/a | Resets the seed with the specified `value`. | +| `SEED(val)` | n/a | Resets the seed with the specified `value`. | +| `STRING(opt, len)` | `VARCHAR2` | Returns a random string. | +| `TERMINATE` | n/a | `TERMINATE` has no effect. Deprecated, but supported for backward compatibility. | +| `VALUE` | `NUMBER` | Returns a random number with a value greater than or equal to `0` and less than `1`, with 38 digit precision. | +| `VALUE(low, high)` | `NUMBER` | Returns a random number with a value greater than or equal to `low` and less than `high`. | + +## INITIALIZE + +The `INITIALIZE` procedure initializes the `DBMS_RANDOM` package with a seed value. The signature is: + +```text +INITIALIZE( IN INTEGER) +``` + +This procedure should be considered deprecated; it is included for backward compatibility only. + +**Parameters** + +`val` + + `val` is the seed value used by the `DBMS_RANDOM` package algorithm. + +**Example** + +The following code snippet demonstrates a call to the `INITIALIZE` procedure that initializes the `DBMS_RANDOM` package with the seed value, `6475`. + +```text +DBMS_RANDOM.INITIALIZE(6475); +``` + +## NORMAL + +The `NORMAL` function returns a random number of type `NUMBER`. The signature is: + +```text + NUMBER NORMAL() +``` + +**Parameters** + +`result` + + `result` is a random value of type `NUMBER`. + +**Example** + +The following code snippet demonstrates a call to the `NORMAL` function: + +```text +x:= DBMS_RANDOM.NORMAL(); +``` + +## RANDOM + +The `RANDOM` function returns a random `INTEGER` value that is greater than or equal to -2 ^31 and less than 2 ^31. The signature is: + +```text + INTEGER RANDOM() +``` + +This function should be considered deprecated; it is included for backward compatibility only. + +**Parameters** + +`result` + + `result` is a random value of type `INTEGER`. + +**Example** + +The following code snippet demonstrates a call to the `RANDOM` function. The call returns a random number: + +```text +x := DBMS_RANDOM.RANDOM(); +``` + +## SEED + +The first form of the `SEED` procedure resets the seed value for the `DBMS_RANDOM` package with an `INTEGER` value. The `SEED` procedure is available in two forms; the signature of the first form is: + +```text +SEED( IN INTEGER) +``` + +**Parameters** + +`val` + + `val` is the seed value used by the `DBMS_RANDOM` package algorithm. + +**Example** + +The following code snippet demonstrates a call to the `SEED` procedure; the call sets the seed value at `8495`. + +```text +DBMS_RANDOM.SEED(8495); +``` + +## SEED + +The second form of the `SEED` procedure resets the seed value for the `DBMS_RANDOM` package with a string value. The `SEED` procedure is available in two forms; the signature of the second form is: + +```text +SEED( IN VARCHAR2) +``` + +**Parameters** + +`val` + + `val` is the seed value used by the `DBMS_RANDOM` package algorithm. + +**Example** + +The following code snippet demonstrates a call to the `SEED` procedure; the call sets the seed value to `abc123`. + +```text +DBMS_RANDOM.SEED('abc123'); +``` + +## STRING + +The `STRING` function returns a random `VARCHAR2` string in a user-specified format. The signature of the `STRING` function is: + +```text + VARCHAR2 STRING( IN CHAR, IN NUMBER) +``` + +**Parameters** + +`opt` + + Formatting option for the returned string. `option` may be: + +| **Option** | **Specifies Formatting Option** | +| ---------- | ------------------------------- | +| `u` or `U` | Uppercase alpha string | +| `l` or `L` | Lowercase alpha string | +| `a` or `A` | Mixed case string | +| `x` or `X` | Uppercase alpha-numeric string | +| `p` or `P` | Any printable characters | + +`len` + + The length of the returned string. + +`result` + + `result` is a random value of type `VARCHAR2`. + +**Example** + +The following code snippet demonstrates a call to the `STRING` function; the call returns a random alpha-numeric character string that is 10 characters long. + +```text +x := DBMS_RANDOM.STRING('X', 10); +``` + +## TERMINATE + +The `TERMINATE` procedure has no effect. The signature is: + +```text +TERMINATE +``` + +The `TERMINATE` procedure should be considered deprecated; the procedure is supported for compatibility only. + +## VALUE + +The `VALUE` function returns a random `NUMBER` that is greater than or equal to 0, and less than 1, with 38 digit precision. The `VALUE` function has two forms; the signature of the first form is: + +```text + NUMBER VALUE() +``` + +**Parameters** + +`result` + + `result` is a random value of type `NUMBER`. + +**Example** + +The following code snippet demonstrates a call to the `VALUE` function. The call returns a random `NUMBER`: + +```text +x := DBMS_RANDOM.VALUE(); +``` + +## VALUE + +The `VALUE` function returns a random `NUMBER` with a value that is between user-specified boundaries. The `VALUE` function has two forms; the signature of the second form is: + +```text + NUMBER VALUE( IN NUMBER, IN NUMBER) +``` + +**Parameters** + +`low` + + `low` specifies the lower boundary for the random value. The random value may be equal to `low`. + +`high` + + `high` specifies the upper boundary for the random value; the random value will be less than `high`. + +`result` + + `result` is a random value of type `NUMBER`. + +**Example** + +The following code snippet demonstrates a call to the `VALUE` function. The call returns a random `NUMBER` with a value that is greater than or equal to 1 and less than 100: + +```text +x := DBMS_RANDOM.VALUE(1, 100); +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/13_dbms_redact.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/13_dbms_redact.mdx new file mode 100644 index 00000000000..a3e0d5d3981 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/13_dbms_redact.mdx @@ -0,0 +1,708 @@ +--- +title: "DBMS_REDACT" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/dbms_redact.html" +--- + +The `DBMS_REDACT` package enables the redacting or masking of data returned by a query. The `DBMS_REDACT` package provides a procedure to create policies, alter policies, enable policies, disable policies, and drop policies. The procedures available in the `DBMS_REDACT` package are listed in the following table. + +| Function/Procedure | Function or Procedure | Return Type | Description | +| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------- | ----------- | --------------------------------------------------------------------- | +| `ADD_POLICY(object_schema, object_name, policy_name, policy_description, column_name, column_description, function_type, function_parameters, expression, enable, regexp_pattern, regexp_replace_string, regexp_position, regexp_occurence, regexp_match_parameter, custom_function_expression)` | Procedure | n/a | Adds a data redaction policy. | +| `ALTER_POLICY(object_schema, object_name, policy_name, action, column_name, function_type, function_parameters, expression, regexp_pattern, regexp_replace_string, regexp_position, regexp_occurence, regexp_match_parameter, policy_description, column_description, custom_function_expression)` | Procedure | n/a | Alters the existing data redaction policy. | +| `DISABLE_POLICY(object_schema, object_name, policy_name)` | Procedure | n/a | Disables the existing data redaction policy. | +| `ENABLE_POLICY(object_schema, object_name, policy_name)` | Procedure | n/a | Enables a previously disabled data redaction policy. | +| `DROP_POLICY(object_schema, object_name, policy_name)` | Procedure | n/a | Drops a data redaction policy. | +| `UPDATE_FULL_REDACTION_VALUES(number_val, binfloat_val, bindouble_val, char_val, varchar_val, nchar_val, nvarchar_val, datecol_val, ts_val, tswtz_val, blob_val, clob_val, nclob_val)` | Procedure | n/a | Updates the full redaction default values for the specified datatype. | + +The data redaction feature uses the `DBMS_REDACT` package to define policies or conditions to redact data in a column based on the table column type and redaction type. + +Note that you must be the owner of the table to create or change the data redaction policies. The users are exempted from all the column redaction policies, which the table owner or super-user is by default. + +## Using DBMS_REDACT Constants and Function Parameters + +The `DBMS_REDACT` package uses the constants and redacts the column data by using any one of the data redaction types. The redaction type can be decided based on the `function_type` parameter of `dbms_redact.add_policy` and `dbms_redact.alter_policy` procedure. The below table highlights the values for `function_type` parameters of `dbms_redact.add_policy` and `dbms_redact.alter_policy`. + +| Constant | Type | Value | Description | +| --------- | --------- | ----- | --------------------------------------------------------------------------------------------------------- | +| `NONE` | `INTEGER` | `0` | No redaction, zero effect on the result of a query against table. | +| `FULL` | `INTEGER` | `1` | Full redaction, redacts full values of the column data. | +| `PARTIAL` | `INTEGER` | `2` | Partial redaction, redacts a portion of the column data. | +| `RANDOM` | `INTEGER` | `4` | Random redaction, each query results in a different random value depending on the datatype of the column. | +| `REGEXP` | `INTEGER` | `5` | Regular Expression based redaction, searches for the pattern of data to redact. | +| `CUSTOM` | `INTEGER` | `99` | Custom redaction type. | + +The following table shows the values for the `action` parameter of `dbms_redact.alter_policy`. + +| Constant | Type | Value | Description | +| ------------------------ | --------- | ----- | --------------------------------------------------------------------------------------------------------------------------------------- | +| `ADD_COLUMN` | `INTEGER` | `1` | Adds a column to the redaction policy. | +| `DROP_COLUMN` | `INTEGER` | `2` | Drops a column from the redaction policy. | +| `MODIFY_EXPRESSION` | `INTEGER` | `3` | Modifies the expression of a redaction policy. The redaction is applied when the expression evaluates to the `BOOLEAN` value to `TRUE`. | +| `MODIFY_COLUMN` | `INTEGER` | `4` | Modifies a column in the redaction policy to change the redaction function type or function parameter. | +| `SET_POLICY_DESCRIPTION` | `INTEGER` | `5` | Sets the redaction policy description. | +| `SET_COLUMN_DESCRIPTION` | `INTEGER` | `6` | Sets a description for the redaction performed on the column. | + +The partial data redaction enables you to redact only a portion of the column data. To use partial redaction, you must set the `dbms_redact.add_policy` procedure `function_type` parameter to `dbms_redact.partial` and use the `function_parameters` parameter to specify the partial redaction behavior. + +The data redaction feature provides a predefined format to configure policies that use the following datatype: + +- `Character` +- `Number` +- `Datetime` + +The following table highlights the format descriptor for partial redaction with respect to datatype. The example described below shows how to perform a redaction for a string datatype (in this scenario, a Social Security Number (SSN)), a `Number` datatype, and a `DATE` datatype. + +| Datatype | Format Descriptor | Description | Examples | +| --------- | ------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Character | `REDACT_PARTIAL_INPUT_FORMAT` | Specifies the input format. Enter `V` for each character from the input string to be possibly redacted. Enter `F` for each character from the input string that can be considered as a separator such as blank spaces or hyphens. | Consider `'VVVFVVFVVVV,VVV-VV-VVVV,X,1,5'` for masking first 5 digits of SSN strings such as `123-45-6789`, adding hyphen to format it and thereby resulting in strings such as `XXX-XX-6789.` The field value `VVVFVVFVVVV` for matching SSN strings such as `123-45-6789`. | +| | `REDACT_PARTIAL_OUTPUT_FORMAT` | Specifies the output format. Enter `V` for each character from the input string to be possibly redacted. Replace each `F` character from the input format with a character such as a hyphen or any other separator. | The field value `VVV-VV-VVVV` can be used to redact SSN strings into `XXX-XX-6789` where `X` comes from `REDACT_PARTIAL_MASKCHAR` field. | +| | `REDACT_PARTIAL_MASKCHAR` | Specifies the character to be used for redaction. | The value `X` for redacting SSN strings into `XXX-XX-6789`. | +| | `REDACT_PARTIAL_MASKFROM` | Specifies which `V` within the input format from which to start the redaction. | The value `1` for redacting SSN strings starting at the first `V` of the input format of `VVVFVVFVVVV` into strings such as `XXX-XX-6789`. | +| | `REDACT_PARTIAL_MASKTO` | Specifies which `V` within the input format at which to end the redaction. | The value `5` for redacting SSN strings up to and including the fifth `V` within the input format of `VVVFVVFVVVV` into strings such as `XXX-XX-6789`. | +| Number | `REDACT_PARTIAL_MASKCHAR` | Specifies the character to be displayed in the range between 0 and 9. | `‘9, 1, 5’` for redacting the first five digits of the Social Security Number `123456789` into `999996789`. | +| | `REDACT_PARTIAL_MASKFROM` | Specifies the start digit position for redaction. | | +| | `REDACT_PARTIAL_MASKTO` | Specifies the end digit position for redaction. | | +| Datetime | `REDACT_PARTIAL_DATE_MONTH` | `‘m’` redacts the month. To mask a specific month, specify `‘m#’` where # indicates the month specified by its number between `1` and `12`. | `m3` displays as March. | +| | `REDACT_PARTIAL_DATE_DAY` | `‘d’` redacts the day of the month. To mask with a day of the month, append `1-31` to a lowercase `d`. | `d3` displays as `03`. | +| | `REDACT_PARTIAL_DATE_YEAR` | `‘y’` redacts the year. To mask with a year, append `1-9999` to a lowercase `y`. | `y1960` displays as `60`. | +| | `REDACT_PARTIAL_DATE_HOUR` | `‘h’` redacts the hour. To mask with an hour, append `0-23` to a lowercase `h`. | `h18` displays as `18`. | +| | `REDACT_PARTIAL_DATE_MINUTE` | `‘m’` redacts the minute. To mask with a minute, append `0-59` to a lowercase `m`. | `m20` displays as `20`. | +| | `REDACT_PARTIAL_DATE_SECOND` | `‘s’` redacts the second. To mask with a second, append `0-59` to a lowercase `s`. | `s40` displays as `40`. | + +The following table represents `function_parameters` values that can be used in partial redaction. + +| Function Parameter | Data Type | Value | Description | +| ----------------------------- | ---------- | -------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `REDACT_US_SSN_F5` | `VARCHAR2` | `'VVVFVVFVVVV,VVV-VV-VVVV,X,1,5'` | Redacts the first 5 numbers of SSN. **Example:** The number `123-45-6789` becomes `XXX-XX-6789`. | +| `REDACT_US_SSN_L4` | `VARCHAR2` | `'VVVFVVFVVVV,VVV-VV-VVVV,X,6,9'` | Redacts the last 4 numbers of SSN. **Example:** The number `123-45-6789` becomes `123-45-XXXX`. | +| `REDACT_US_SSN_ENTIRE` | `VARCHAR2` | `'VVVFVVFVVVV,VVV-VV-VVVV,X,1,9'` | Redacts the entire SSN. **Example:** The number `123-45-6789` becomes `XXX-XX-XXXX`. | +| `REDACT_NUM_US_SSN_F5` | `VARCHAR2` | `'9,1,5'` | Redacts the first 5 numbers of SSN when the column is a number datatype. **Example:** The number `123456789` becomes `999996789`. | +| `REDACT_NUM_US_SSN_L4` | `VARCHAR2` | `'9,6,9'` | Redacts the last 4 numbers of SSN when the column is a number datatype. **Example:** The number `123456789` becomes `123459999`. | +| `REDACT_NUM_US_SSN_ENTIRE` | `VARCHAR2` | `'9,1,9'` | Redacts the entire SSN when the column is a number datatype. **Example:** The number `123456789` becomes `999999999`. | +| `REDACT_ZIP_CODE` | `VARCHAR2` | `'VVVVV,VVVVV,X,1,5'` | Redacts a 5 digit zip code. **Example:** `12345`becomes `XXXXX`. | +| `REDACT_NUM_ZIP_CODE` | `VARCHAR2` | `'9,1,5'` | Redacts a 5 digit zip code when the column is a number datatype. **Example:** `12345`becomes `99999`. | +| `REDACT_CCN16_F12` | `VARCHAR2` | `'VVVVFVVVVFVVVVFVVVV,VVVV-VVVV-VVVV-VVVV,*,1,12'` | Redacts a 16 digit credit card number and displays only 4 digits. **Example:** `1234 5678 9000 2358` becomes `****-****-****-2358`. | +| `REDACT_DATE_MILLENNIUM` | `VARCHAR2` | `'m1d1y2000'` | Redacts a date that is in the `DD-MM-YY` format. **Example:** Redacts all date to `01-JAN-2000`. | +| `REDACT_DATE_EPOCH` | `VARCHAR2` | `'m1d1y1970'` | Redacts all dates to `01-JAN-70`. | +| `REDACT_AMEX_CCN_FORMATTED` | `VARCHAR2` | `'VVVVFVVVVVVFVVVVV,VVVV-VVVVVV-VVVVV,*,1,10'` | Redacts the Amercian Express credit card number and replaces the digit with `*` except for the last 5 digits. **Example:** The credit card number `1234 567890 34500` becomes `**** ****** 34500`. | +| `REDACT_AMEX_CCN_NUMBER` | `VARCHAR2` | `'0,1,10'` | Redacts the Amercian Express credit card number and replaces the digit with `0` except for the last 5 digits. **Example:** The credit card number `1234 567890 34500` becomes `0000 000000 34500`. | +| `REDACT_SIN_FORMATTED` | `VARCHAR2` | `'VVVFVVVFVVV,VVV-VVV-VVV,*,1,6'` | Redacts the Social Insurance Number by replacing the first 6 digits by `*`. **Example:** `123-456-789` becomes `***-***-789`. | +| `REDACT_SIN_NUMBER` | `VARCHAR2` | `'9,1,6'` | Redacts the Social Insurance Number by replacing the first 6 digits by `9`. **Example:** `123456789` becomes `999999789`. | +| `REDACT_SIN_UNFORMATTED` | `VARCHAR2` | `'VVVVVVVVV,VVVVVVVVV,*,1,6'` | Redacts the Social Insurance Number by replacing the first 6 digits by `*`. **Example:** `123456789` becomes `******789`. | +| `REDACT_CCN_FORMATTED` | `VARCHAR2` | `'VVVVFVVVVFVVVVFVVVV,VVVV-VVVV-VVVV-VVVV,*,1,12'` | Redacts a credit card number by `*` and displays only 4 digits. **Example:** The credit card number `1234-5678-9000-4671` becomes `****-****-****-4671`. | +| `REDACT_CCN_NUMBER` | `VARCHAR2` | `'9,1,12'` | Redacts a credit card number by `0` except the last 4 digits. **Example:** The credit card number `1234567890004671` becomes `0000000000004671`. | +| `REDACT_NA_PHONE_FORMATTED` | `VARCHAR2` | `‘VVVFVVVFVVVV,VVV-VVV-VVVV,X,4,10'` | Redacts the North American phone number by `X` leaving the area code. **Example:** `123-456-7890` becomes `123-XXX-XXXX`. | +| `REDACT_NA_PHONE_NUMBER` | `VARCHAR2` | `'0,4,10'` | Redacts the North American phone number by `0` leaving the area code. **Example:** `1234567890` becomes `1230000000`. | +| `REDACT_NA_PHONE_UNFORMATTED` | `VARCHAR2` | `'VVVVVVVVVV,VVVVVVVVVV,X,4,10'` | Redacts the North American phone number by `X` leaving the area code. **Example:** `1234567890` becomes `123XXXXXXX`. | +| `REDACT_UK_NIN_FORMATTED` | `VARCHAR2` | `'VVFVVFVVFVVFV,VV VV VV VV V,X,3,8'` | Redacts the UK National Insurance Number by `X` but leaving the alphabetic characters. **Example:** `NY 22 01 34 D` becomes `NY XX XX XX D`. | +| `REDACT_UK_NIN_UNFORMATTED` | `VARCHAR2` | `'VVVVVVVVV,VVVVVVVVV,X,3,8'` | Redacts the UK National Insurance Number by `X` but leaving the alphabetic characters. **Example:** `NY220134D` becomes `NYXXXXXXD`. | + +A regular expression-based redaction searches for patterns of data to redact. The `regexp_pattern` search the values in order for the `regexp_replace_string` to change the value. The following table illustrates the `regexp_pattern` values that you can use during `REGEXP` based redaction. + +| Function Parameter and Description | Data Type | Value | +| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------: | :----------------------------------------------------: | +| `RE_PATTERN_CC_L6_T4`: Searches for the middle digits of a credit card number that includes 6 leading digits and 4 trailing digits.
The `regexp_replace_string` setting to use with the format is `RE_REDACT_CC_MIDDLE_DIGITS` that replaces the identified pattern with the characters specified by the `RE_REDACT_CC_MIDDLE_DIGITS` parameter. | `VARCHAR2` | `'(\d\d\d\d\d\d)(\d\d\d*)(\d\d\d\d)'` | +| `RE_PATTERN_ANY_DIGIT`: Searches for any digit and replaces the identified pattern with the characters specified by the following values of the `regexp_replace_string` parameter.
`regexp_replace_string=> RE_REDACT_WITH_SINGLE_X`
(replaces any matched digit with the `X` character).
`regexp_replace_string=> RE_REDACT_WITH_SINGLE_1`
(replaces any matched digit with the `1` character). | `VARCHAR2` | `'\d'` | +| `RE_PATTERN_US_PHONE`: Searches for the U.S phone number and replaces the identified pattern with the characters specified by the `regexp_replace_string` parameter.
`regexp_replace_string=> RE_REDACT_US_PHONE_L7`
(searches the phone number and then replaces the last 7 digits). | `VARCHAR2` | `'(\(\d\d\d\)\|\d\d\d)-(\d\d\d)-(\d\d\d\d)'` | +| `RE_PATTERN_EMAIL_ADDRESS`: Searches for the email address and replaces the identified pattern with the characters specified by the following values of the `regexp_replace_string` parameter.
`regexp_replace_string=> RE_REDACT_EMAIL_NAME`
(finds the email address and redacts the email username).
`regexp_replace_string=> RE_REDACT_EMAIL_DOMAIN`
(finds the email address and redacts the email domain).
`regexp_replace_string=> RE_REDACT_EMAIL_ENTIRE`
(finds the email address and redacts the entire email address). | `VARCHAR2` | `'([A-Za-z0-9._%+-]+)@([A-Za-z0-9.-]+\.[A-Za-z]{2,4})'` | +| `RE_PATTERN_IP_ADDRESS`: Searches for an IP address and replaces the identified pattern with the characters specified by the `regexp_replace_string` parameter. The `regexp_replace_string` parameter to be used is `RE_REDACT_IP_L3` that replaces the last section of an IP address with `999` and indicates it is redacted. | `VARCHAR2` | `'(\d{1,3}\.\d{1,3}\.\d{1,3})\.\d{1,3}'` | +| `RE_PATTERN_AMEX_CCN`: Searches for the American Express credit card number. The `regexp_replace_string` parameter to be used is `RE_REDACT_AMEX_CCN` that redacts all of the digits except the last 5. | `VARCHAR2` | `'.*(\d\d\d\d\d)$'` | +| `RE_PATTERN_CCN`: Searches for the credit card number other than American Express credit cards. The `regexp_replace_string` parameter to be used is `RE_REDACT_CCN` that redacts all of the digits except the last 4. | `VARCHAR2` | `'.*(\d\d\d\d)$'` | +| `RE_PATTERN_US_SSN`: Searches the SSN number and replaces the identified pattern with the characters specified by the `regexp_replace_string` parameter.
`'\1-XXX-XXXX'` or `'XXX-XXX-\3'` will return `123-XXX-XXXX` or `XXX-XXX-6789` for the value `'123-45-6789'` respectively. | `VARCHAR2` | `'(\d\d\d)-(\d\d)-(\d\d\d\d)'` | +| | | | + +The below table illustrates the `regexp_replace_string` values that you can use during `REGEXP` based redaction. + +| Function Parameter | Data Type | Value | Description | +| ---------------------------- | ---------- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `RE_REDACT_CC_MIDDLE_DIGITS` | `VARCHAR2` | `'\1XXXXXX\3'` | Redacts the middle digits of a credit card number according to the `regexp_pattern` parameter with the `RE_PATTERN_CC_L6_T4` format and replaces each redacted character with an `X`.

**Example:** The credit card number `1234 5678 9000 2490` becomes `1234 56XX XXXX 2490`. | +| `RE_REDACT_WITH_SINGLE_X` | `VARCHAR2` | `'X'` | Replaces the data with a single `X` character for each matching pattern as specified by setting the `regexp_pattern` parameter with the `RE_PATTERN_ANY_DIGIT` format.

**Example:** The credit card number `1234 5678 9000 2490` becomes `XXXX XXXX XXXX XXXX`. | +| `RE_REDACT_WITH_SINGLE_1` | `VARCHAR2` | `'1'` | Replaces the data with a single `1` digit for each of the data digits as specified by setting the `regexp_pattern` parameter with the `RE_PATTERN_ANY_DIGIT` format.

**Example:** The credit card number `1234 5678 9000 2490` becomes `1111 1111 1111 1111`. | +| `RE_REDACT_US_PHONE_L7` | `VARCHAR2` | `'\1-XXX-XXXX'` | Redacts the last 7 digits of U.S phone number according to the `regexp_pattern` parameter with the `RE_PATTERN_US_PHONE` format and replaces each redacted character with an `X`.

**Example:** The phone number `123-444-5900` becomes `123-XXX-XXXX`. | +| `RE_REDACT_EMAIL_NAME` | `VARCHAR2` | `'xxxx@\2'` | Redacts the email name according to the `regexp_pattern` parameter with the `RE_PATTERN_EMAIL_ADDRESS` format and replaces the email username with the four `x` characters.

**Example:** The email address `sjohn@example.com` becomes `xxxx@example.com`. | +| `RE_REDACT_EMAIL_DOMAIN` | `VARCHAR2` | `'\1@xxxxx.com'` | Redacts the email domain name according to the `regexp_pattern` parameter with the `RE_PATTERN_EMAIL_ADDRESS` format and replaces the domain with the five `x` characters.

**Example:** The email address `sjohn@example.com` becomes `sjohn@xxxxx.com`. | +| `RE_REDACT_EMAIL_ENTIRE` | `VARCHAR2` | `'xxxx@xxxxx.com'` | Redacts the entire email address according to the `regexp_pattern` parameter with the `RE_PATTERN_EMAIL_ADDRESS` format and replaces the email address with the `x` characters.

**Example:** The email address `sjohn@example.com` becomes `xxxx@xxxxx.com`. | +| `RE_REDACT_IP_L3` | `VARCHAR2` | `'\1.999'` | Redacts the last 3 digits of an IP address according to the `regexp_pattern` parameter with the `RE_PATTERN_IP_ADDRESS` format.

**Example:** The IP address `172.0.1.258` becomes `172.0.1.999`, which is an invalid IP address. | +| `RE_REDACT_AMEX_CCN` | `VARCHAR2` | `'**********\1'` | Redacts the first 10 digits of an American Express credit card number according to the `regexp_pattern` parameter with the `RE_PATTERN_AMEX_CCN` format.

**Example:** `123456789062816` becomes `**********62816`. | +| `RE_REDACT_CCN` | `VARCHAR2` | `'************\1'` | Redacts the first 12 digits of a credit card number as specified by the `regexp_pattern` parameter with the `RE_PATTERN_CCN` format.

**Example:** `8749012678345671` becomes `************5671`. | + +The following tables show the `regexp_position` value and `regexp_occurence` values that you can use during `REGEXP` based redaction. + +| Function Parameter | Data Type | Value | Description | +| ------------------ | --------- | ----- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `RE_BEGINNING` | `INTEGER` | `1` | Specifies the position of a character where search must begin. By default, the value is `1` that indicates the search begins at the first character of `source_char`. | + +| Function Parameter | Data Type | Value | Description | +| ------------------ | --------- | ----- | -------------------------------------------------------------------------------------------------------------------------------------- | +| `RE_ALL` | `INTEGER` | `0` | Specifies the replacement occurrence of a substring. If the value is `0`, then the replacement of each matching substring occurs. | +| `RE_FIRST` | `INTEGER` | `1` | Specifies the replacement occurrence of a substring. If the value is `1`, then the replacement of the first matching substring occurs. | + +The following table shows the `regexp_match_parameter` values that you can use during `REGEXP` based redaction which lets you change the default matching behavior of a function. + +| Function Parameter | Data Type | Value | Description | +| ---------------------- | ---------- | ----- | --------------------------------------------------------------------------------------------------------------- | +| `RE_CASE_SENSITIVE` | `VARCHAR2` | `'c'` | Specifies the case-sensitive matching. | +| `RE_CASE_INSENSITIVE` | `VARCHAR2` | `'i'` | Specifies the case-insensitive matching. | +| `RE_MULTIPLE_LINES` | `VARCHAR2` | `'m'` | Treats the source string as multiple lines but if you omit this parameter, then it indicates as a single line. | +| `RE_NEWLINE_WILDCARD` | `VARCHAR2` | `'n'` | Specifies the period (.), but if you omit this parameter, then the period does not match the newline character. | +| `RE_IGNORE_WHITESPACE` | `VARCHAR2` | `'x'` | Ignores the whitespace characters. | + +!!! Note + If you create a redaction policy based on a numeric type column, then make sure that the result after redaction is a number and accordingly set the replacement string to avoid runtime errors. + +!!! Note + If you create a redaction policy based on a character type column, then make sure that a length of the result after redaction is compatible with the column type and accordingly set the replacement string to avoid runtime errors. + +## ADD_POLICY + +The `add_policy` procedure creates a new data redaction policy for a table. + +```text +PROCEDURE add_policy ( + IN VARCHAR2 DEFAULT NULL, + IN VARCHAR2, + IN VARCHAR2, + IN VARCHAR2 DEFAULT NULL, + IN VARCHAR2 DEFAULT NULL, + IN VARCHAR2 DEFAULT NULL, + IN INTEGER DEFAULT DBMS_REDACT.FULL, + IN VARCHAR2 DEFAULT NULL, + IN VARCHAR2, + IN BOOLEAN DEFAULT TRUE, + IN VARCHAR2 DEFAULT NULL, + IN VARCHAR2 DEFAULT NULL, + IN INTEGER DEFAULT DBMS_REDACT.RE_BEGINNING, + IN INTEGER DEFAULT DBMS_REDACT.RE_ALL, + IN VARCHAR2 DEFAULT NULL, + IN VARCHAR2 DEFAULT NULL + ) +``` + +**Parameters** + +`object_schema` + + Specifies the name of the schema in which the object resides and on which the data redaction policy will be applied. If you specify `NULL` then the given object is searched by the order specified by `search_path` setting. + +`object_name` + + Name of the table on which the data redaction policy is created. + +`policy_name` + + Name of the policy to be added. Ensure that the `policy_name` is unique for the table on which the policy is created. + +`policy_description` + + Specify the description of a redaction policy. + +`column_name` + + Name of the column to which the redaction policy applies. To redact more than one column, use the `alter_policy` procedure to add additional columns. + +`column_description` + + Description of the column to be redacted. The `column_description` is not supported, but if you specify the description for a column then, you will get a warning message. + +`function_type` + + The type of redaction function to be used. The possible values are `NONE, FULL, PARTIAL, RANDOM, REGEXP`, and `CUSTOM`. + +`function_parameters` + + Specifies the function parameters for the partition redaction and is applicable only for partial redaction. + +`expression` + + Specifies the Boolean expression for the table and determines how the policy is to be applied. The redaction occurs if this policy expression is evaluated to `TRUE`. + +`enable` + + When set to `TRUE`, the policy is enabled upon creation. The default is set as `TRUE`. When set to `FALSE`, the policy is disabled but the policy can be enabled by calling the `enable_policy` procedure. + +`regexp_pattern` + + Specifies the regular expression pattern to redact data. If the `regexp_pattern` does not match, then the `NULL` value is returned. + +`regexp_replace_string` + + Specifies the replacement string value. + +`regexp_position` + + Specifies the position of a character where search must begin. By default, the function parameter is `RE_BEGINNING`. + +`regexp_occurrence` + + Specifies the replacement occurrence of a substring. If the constant is `RE_ALL`, then the replacement of each matching substring occurs. If the constant is `RE_FIRST`, then the replacement of the first matching substring occurs. + +`regexp_match_parameter` + + Changes the default matching behavior of a function. The possible regexp_match_parameter constants can be `‘RE_CASE_SENSITIVE’, ‘RE_CASE_INSENSITIVE’, ‘RE_MULTIPLE_LINES’, ‘RE_NEWLINE_WILDCARD’, ‘RE_IGNORE_WHITESPACE’`. + + **Note**: For more information on `constants`, `function_parameters`, or `regexp` (regular expressions) see, Using `DBMS_REDACT Constants and Function Parameters`. + +`custom_function_expression` + + The `custom_function_expression` is applicable only for the `CUSTOM` redaction type. The `custom_function_expression` is a function expression that is, schema-qualified function with a parameter such as `schema_name.function_name (argument1, …)` that allows a user to use their redaction logic to redact the column data. + +**Example** + +The following example illustrates how to create a policy and use full redaction for values in the `payment_details_tab` table `customer id` column. + +```text +edb=# CREATE TABLE payment_details_tab ( +customer_id NUMBER NOT NULL, +card_string VARCHAR2(19) NOT NULL); +CREATE TABLE + +edb=# BEGIN + INSERT INTO payment_details_tab VALUES (4000, '1234-1234-1234-1234'); + INSERT INTO payment_details_tab VALUES (4001, '2345-2345-2345-2345'); +END; + +EDB-SPL Procedure successfully completed + +edb=# CREATE USER redact_user; +CREATE ROLE +edb=# GRANT SELECT ON payment_details_tab TO redact_user; +GRANT + +\c edb base_user + +BEGIN + DBMS_REDACT.add_policy( + object_schema => 'public', + object_name => 'payment_details_tab', + policy_name => 'redactPolicy_001', + policy_description => 'redactPolicy_001 for payment_details_tab table', + column_name => 'customer_id', + function_type => DBMS_REDACT.full, + expression => '1=1', + enable => TRUE); +END; +``` + +Redacted Result: + +```text +edb=# \c edb redact_user +You are now connected to database "edb" as user "redact_user". + +edb=> select customer_id from payment_details_tab order by 1; + customer_id +------------- + 0 + 0 +(2 rows) +``` + +## ALTER_POLICY + +The `alter_policy` procedure alters or modifies an existing data redaction policy for a table. + +```text +PROCEDURE alter_policy ( + IN VARCHAR2 DEFAULT NULL, + IN VARCHAR2, + IN VARCHAR2, + IN INTEGER DEFAULT DBMS_REDACT.ADD_COLUMN, + IN VARCHAR2 DEFAULT NULL, + IN INTEGER DEFAULT DBMS_REDACT.FULL, + IN VARCHAR2 DEFAULT NULL, + IN VARCHAR2 DEFAULT NULL, + IN VARCHAR2 DEFAULT NULL, + IN VARCHAR2 DEFAULT NULL, + IN INTEGER DEFAULT DBMS_REDACT.RE_BEGINNING, + IN INTEGER DEFAULT DBMS_REDACT.RE_ALL, + IN VARCHAR2 DEFAULT NULL, + IN VARCHAR2 DEFAULT NULL, + IN VARCHAR2 DEFAULT NULL, + IN VARCHAR2 DEFAULT NULL + ) +``` + +**Parameters** + +`object_schema` + + Specifies the name of the schema in which the object resides and on which the data redaction policy will be altered. If you specify `NULL` then the given object is searched by the order specified by `search_path` setting. + +`object_name` + + Name of the table to which to alter a data redaction policy. + +`policy_name` + + Name of the policy to be altered. + +`action` + + The action to perform. For more information about action parameters see, `DBMS_REDACT Constants and Function Parameters`. + +`column_name` + + Name of the column to which the redaction policy applies. + +`function_type` + + The type of redaction function to be used. The possible values are `NONE, FULL, PARTIAL, RANDOM, REGEXP`, and `CUSTOM`. + +`function_parameters` + + Specifies the function parameters for the redaction function. + +`expression` + + Specifies the Boolean expression for the table and determines how the policy is to be applied. The redaction occurs if this policy expression is evaluated to `TRUE`. + +`regexp_pattern` + + Enables the use of regular expressions to redact data. If the `regexp_pattern` does not match the data, then the `NULL` value is returned. + +`regexp_replace_string` + + Specifies the replacement string value. + +`regexp_position` + + Specifies the position of a character where search must begin. By default, the function parameter is `RE_BEGINNING`. + +`regexp_occurence` + + Specifies the replacement occurrence of a substring. If the constant is `RE_ALL`, then the replacement of each matching substring occurs. If the constant is `RE_FIRST`, then the replacement of the first matching substring occurs. + +`regexp_match_parameter` + + Changes the default matching behavior of a function. The possible regexp_match_parameter constants can be `‘RE_CASE_SENSITIVE’, ‘RE_CASE_INSENSITIVE’, ‘RE_MULTIPLE_LINES’, ‘RE_NEWLINE_WILDCARD’, ‘RE_IGNORE_WHITESPACE’`. + + **Note**: For more information on `constants, function_parameters`, or `regexp` (regular expressions) see, `Using DBMS_REDACT Constants and Function Parameters`. + +`policy_description` + + Specify the description of a redaction policy. + +`column_description` + + Description of the column to be redacted. The `column_description` is not supported, but if you specify the description for a column then, you will get a warning message. + +`custom_function_expression` + + The `custom_function_expression` is applicable only for the `CUSTOM` redaction type. The `custom_function_expression` is a function expression that is, schema-qualified function with a parameter such as `schema_name.function_name (argument1, …)` that allows a user to use their redaction logic to redact the column data. + +**Example** + +The following example illustrates to alter a policy using partial redaction for values in the `payment_details_tab` table `card_string` (usually a credit card number) column. + +```text +\c edb base _user + +BEGIN + DBMS_REDACT.alter_policy ( + object_schema => 'public', + object_name => 'payment_details_tab', + policy_name => 'redactPolicy_001', + action => DBMS_REDACT.ADD_COLUMN, + column_name => 'card_string', + function_type => DBMS_REDACT.partial, + function_parameters => DBMS_REDACT.REDACT_CCN16_F12); +END; +``` + +Redacted Result: + +```text +edb=# \c - redact_user +You are now connected to database "edb" as user "redact_user". +edb=> SELECT * FROM payment_details_tab; + customer_id | card_string +-------------+--------------------- + 0 | ****-****-****-1234 + 0 | ****-****-****-2345 +(2 rows) +``` + +## DISABLE_POLICY + +The `disable_policy` procedure disables an existing data redaction policy. + +```text +PROCEDURE disable_policy ( + IN VARCHAR2 DEFAULT NULL, + IN VARCHAR2, + IN VARCHAR2 + ) +``` + +**Parameters** + +`object_schema` + + Specifies the name of the schema in which the object resides and on which the data redaction policy will be applied. If you specify `NULL` then the given object is searched by the order specified by `search_path` setting. + +`object_name` + + Name of the table for which to disable a data redaction policy. + +`policy_name` + + Name of the policy to be disabled. + +**Example** + +The following example illustrates how to disable a policy. + +```text +\c edb base_user + +BEGIN + DBMS_REDACT.disable_policy( + object_schema => 'public', + object_name => 'payment_details_tab', + policy_name => 'redactPolicy_001'); +END; +``` + +Redacted Result: Data is no longer redacted after disabling a policy. + +## ENABLE_POLICY + +The `enable_policy` procedure enables the previously disabled data redaction policy. + +```text +PROCEDURE enable_policy ( + IN VARCHAR2 DEFAULT NULL, + IN VARCHAR2, + IN VARCHAR2 + ) +``` + +**Parameters** + +`object_schema` + + Specifies the name of the schema in which the object resides and on which the data redaction policy will be applied. If you specify `NULL` then the given object is searched by the order specified by `search_path` setting. + +`object_name` + + Name of the table to which to enable a data redaction policy. + +`policy_name` + + Name of the policy to be enabled. + +**Example** + +The following example illustrates how to enable a policy. + +```text +\c edb base_user + +BEGIN + DBMS_REDACT.enable_policy( + object_schema => 'public', + object_name => 'payment_details_tab', + policy_name => 'redactPolicy_001'); +END; +``` + +Redacted Result: Data is redacted after enabling a policy. + +## DROP_POLICY + +The `drop_policy` procedure drops a data redaction policy by removing the masking policy from a table. + +```text +PROCEDURE drop_policy ( + IN VARCHAR2 DEFAULT NULL, + IN VARCHAR2, + IN VARCHAR2 + ) +``` + +**Parameters** + +`object_schema` + + Specifies the name of the schema in which the object resides and on which the data redaction policy will be applied. If you specify `NULL` then the given object is searched by the order specified by `search_path` setting. + +`object_name` + + Name of the table from which to drop a data redaction policy. + +`policy_name` + + Name of the policy to be dropped. + +**Example** + +The following example illustrates how to drop a policy. + +```text +\c edb base_user + +BEGIN + DBMS_REDACT.drop_policy( + object_schema => 'public', + object_name => 'payment_details_tab', + policy_name => 'redactPolicy_001'); +END; +``` + +Redacted Result: The server drops the specified policy. + +## UPDATE_FULL_REDACTION_VALUES + +The `update_full_redaction_values` procedure updates the default displayed values for a data redaction policy and these default values can be viewed using the `redaction_values_for_type_full` view that use the full redaction type. + +```TEXT +PROCEDURE update_full_redaction_values ( + IN NUMBER DEFAULT NULL, + IN FLOAT4 DEFAULT NULL, + IN FLOAT8 DEFAULT NULL, + IN CHAR DEFAULT NULL, + IN VARCHAR2 DEFAULT NULL, + IN NCHAR DEFAULT NULL, + IN NVARCHAR2 DEFAULT NULL, + IN DATE DEFAULT NULL, + IN TIMESTAMP DEFAULT NULL, + IN TIMESTAMPTZ DEFAULT NULL, + IN BLOB DEFAULT NULL, + IN CLOB DEFAULT NULL, + IN CLOB DEFAULT NULL + ) +``` + +**Parameters** + +`number_val` + + Updates the default value for columns of the `NUMBER` datatype. + +`binfloat_val` + + The `FLOAT4` datatype is a random value. The binary float datatype is not supported. + +`bindouble_val` + + The `FLOAT8` datatype is a random value. The binary double datatype is not supported. + +`char_val` + + Updates the default value for columns of the `CHAR` datatype. + +`varchar_val` + + Updates the default value for columns of the `VARCHAR2` datatype. + +`nchar_val` + + The `nchar_val` is mapped to `CHAR` datatype and returns the `CHAR` value. + +`nvarchar_val` + + The `nvarchar_val` is mapped to `VARCHAR2` datatype and returns the `VARCHAR` value. + +`datecol_val` + + Updates the default value for columns of the `DATE` datatype. + +`ts_val` + + Updates the default value for columns of the `TIMESTAMP` datatype. + +`tswtz_val` + + Updates the default value for columns of the `TIMESTAMPTZ` datatype. + +`blob_val` + + Updates the default value for columns of the `BLOB` datatype. + +`clob_val` + + Updates the default value for columns of the `CLOB` datatype. + +`nclob_val` + + The `nclob_val` is mapped to `CLOB` datatype and returns the `CLOB` value. + +**Example** + +The following example illustrates how to update the full redaction values but before updating the values, you can: + +View the default values using `redaction_values_for_type_full` view as shown below: + +```text +edb=# \x +Expanded display is on. +edb=# SELECT number_value, char_value, varchar_value, date_value, + timestamp_value, timestamp_with_time_zone_value, blob_value, +clob_value +FROM redaction_values_for_type_full; +-[ RECORD 1 ]------------------+-------------------------- +number_value | 0 +char_value | +varchar_value | +date_value | 01-JAN-01 00:00:00 +timestamp_value | 01-JAN-01 01:00:00 +timestamp_with_time_zone_value | 31-DEC-00 20:00:00 -05:00 +blob_value | \x5b72656461637465645d +clob_value | [redacted] +(1 row) +``` + +Now, update the default values for full redaction type. The `NULL` values will be ignored. + +```text +\c edb base_user + +edb=# BEGIN + DBMS_REDACT.update_full_redaction_values ( + number_val => 9999999, + char_val => 'Z', + varchar_val => 'V', + datecol_val => to_date('17/10/2018', 'DD/MM/YYYY'), + ts_val => to_timestamp('17/10/2018 11:12:13', 'DD/MM/YYYY HH24:MI:SS'), + tswtz_val => NULL, + blob_val => 'NEW REDACTED VALUE', + clob_val => 'NEW REDACTED VALUE'); +END; +``` + +You can now see the updated values using `redaction_values_for_type_full` view. + +```text +EDB-SPL Procedure successfully completed +edb=# SELECT number_value, char_value, varchar_value, date_value, + timestamp_value, timestamp_with_time_zone_value, blob_value, +clob_value +FROM redaction_values_for_type_full; +-[ RECORD 1 ]------------------+--------------------------------------- +number_value | 9999999 +char_value | Z +varchar_value | V +date_value | 17-OCT-18 00:00:00 +timestamp_value | 17-OCT-18 11:12:13 +timestamp_with_time_zone_value | 31-DEC-00 20:00:00 -05:00 +blob_value | \x4e45572052454441435445442056414c5545 +clob_value | NEW REDACTED VALUE +(1 row) +``` + +Redacted Result: + +```text +edb=# \c edb redact_user +You are now connected to database "edb" as user "redact_user". + +edb=> select * from payment_details_tab order by 1; + customer_id | card_string +-------------+------------- + 9999999 | V + 9999999 | V +(2 rows) +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/14_dbms_rls.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/14_dbms_rls.mdx new file mode 100644 index 00000000000..d1973406417 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/14_dbms_rls.mdx @@ -0,0 +1,498 @@ +--- +title: "DBMS_RLS" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/dbms_rls.html" +--- + +The `DBMS_RLS` package enables the implementation of Virtual Private Database on certain Advanced Server database objects. + +| Function/Procedure | Function or Procedure | Return Type | Description | +| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------- | ----------- | ------------------------------------------------ | +| `ADD_POLICY(object_schema, object_name, policy_name, function_schema, policy_function [, statement_types [, update_check [, enable [, static_policy [, policy_type [, long_predicate [, sec_relevant_cols [, sec_relevant_cols_opt ]]]]]]]])` | Procedure | n/a | Add a security policy to a database object. | +| `DROP_POLICY(object_schema, object_name, policy_name)` | Procedure | n/a | Remove a security policy from a database object. | +| `ENABLE_POLICY(object_schema, object_name, policy_name, enable)` | Procedure | n/a | Enable or disable a security policy. | + +Advanced Server's implementation of `DBMS_RLS` is a partial implementation when compared to Oracle's version. Only those functions and procedures listed in the table above are supported. + +*Virtual Private Database* is a type of fine-grained access control using security policies. *Fine-grained access control* in Virtual Private Database means that access to data can be controlled down to specific rows as defined by the security policy. + +The rules that encode a security policy are defined in a *policy function*, which is an SPL function with certain input parameters and return value. The *security policy* is the named association of the policy function to a particular database object, typically a table. + +!!! Note + In Advanced Server, the policy function can be written in any language supported by Advanced Server such as SQL, PL/pgSQL and SPL. + +!!! Note + The database objects currently supported by Advanced Server Virtual Private Database are tables. Policies cannot be applied to views or synonyms. + +The advantages of using Virtual Private Database are the following: + +- Provides a fine-grained level of security. Database object level privileges given by the `GRANT` command determine access privileges to the entire instance of a database object, while Virtual Private Database provides access control for the individual rows of a database object instance. +- A different security policy can be applied depending upon the type of SQL command (`INSERT, UPDATE, DELETE`, or `SELECT`). +- The security policy can vary dynamically for each applicable SQL command affecting the database object depending upon factors such as the session user of the application accessing the database object. +- Invocation of the security policy is transparent to all applications that access the database object and thus, individual applications do not have to be modified to apply the security policy. +- Once a security policy is enabled, it is not possible for any application (including new applications) to circumvent the security policy except by the system privilege noted by the following. +- Even superusers cannot circumvent the security policy except by the system privilege noted by the following. + +!!! Note + The only way security policies can be circumvented is if the `EXEMPT ACCESS POLICY` system privilege has been granted to a user. The `EXEMPT ACCESS POLICY` privilege should be granted with extreme care as a user with this privilege is exempted from all policies in the database. + +The `DBMS_RLS` package provides procedures to create policies, remove policies, enable policies, and disable policies. + +The process for implementing Virtual Private Database is as follows: + +- Create a policy function. The function must have two input parameters of type `VARCHAR2`. The first input parameter is for the schema containing the database object to which the policy is to apply and the second input parameter is for the name of that database object. The function must have a `VARCHAR2` return type. The function must return a string in the form of a `WHERE` clause predicate. This predicate is dynamically appended as an `AND` condition to the SQL command that acts upon the database object. Thus, rows that do not satisfy the policy function predicate are filtered out from the SQL command result set. +- Use the `ADD_POLICY` procedure to define a new policy, which is the association of a policy function with a database object. With the `ADD_POLICY` procedure, you can also specify the types of SQL commands (`INSERT, UPDATE, DELETE`, or `SELECT`) to which the policy is to apply, whether or not to enable the policy at the time of its creation, and if the policy should apply to newly inserted rows or the modified image of updated rows. +- Use the `ENABLE_POLICY` procedure to disable or enable an existing policy. +- Use the `DROP_POLICY` procedure to remove an existing policy. The `DROP_POLICY` procedure does not drop the policy function or the associated database object. + +Once policies are created, they can be viewed in the catalog views, compatible with Oracle databases: `ALL_POLICIES, DBA_POLICIES`, or `USER_POLICIES`. The supported compatible views are listed in the *Database Compatibility for Oracle Developers Catalog Views Guide*, available at the EDB website at: + +[https://www.enterprisedb.com/docs/](/epas/latest/epas_compat_cat_views/) + +The `SYS_CONTEXT` function is often used with `DBMS_RLS`. The signature is: + +```text +SYS_CONTEXT(, ) +``` + +Where: + + `namespace` is a `VARCHAR2`; the only accepted value is `USERENV`. Any other value will return `NULL`. + + `attribute` is a `VARCHAR2`. `attribute` may be: + +| attribute Value | Equivalent Value | +| ---------------- | ----------------------------- | +| `SESSION_USER` | `pg_catalog.session_user` | +| `CURRENT_USER` | `pg_catalog.current_user` | +| `CURRENT_SCHEMA` | `pg_catalog.current_schema` | +| `HOST` | `pg_catalog.inet_host` | +| `IP_ADDRESS` | `pg_catalog.inet_client_addr` | +| `SERVER_HOST` | `pg_catalog.inet_server_addr` | + +!!! Note + The examples used to illustrate the `DBMS_RLS` package are based on a modified copy of the sample `emp` table provided with Advanced Server along with a role named `salesmgr` that is granted all privileges on the table. You can create the modified copy of the `emp` table named `vpemp` and the `salesmgr` role as shown by the following: + +```text +CREATE TABLE public.vpemp AS SELECT empno, ename, job, sal, comm, deptno +FROM emp; +ALTER TABLE vpemp ADD authid VARCHAR2(12); +UPDATE vpemp SET authid = 'researchmgr' WHERE deptno = 20; +UPDATE vpemp SET authid = 'salesmgr' WHERE deptno = 30; +SELECT * FROM vpemp; + +empno | ename | job | sal | comm | deptno | authid +-------+--------+-----------+---------+---------+--------+------------- + 7782 | CLARK | MANAGER | 2450.00 | | 10 | + 7839 | KING | PRESIDENT | 5000.00 | | 10 | + 7934 | MILLER | CLERK | 1300.00 | | 10 | + 7369 | SMITH | CLERK | 800.00 | | 20 | researchmgr + 7566 | JONES | MANAGER | 2975.00 | | 20 | researchmgr + 7788 | SCOTT | ANALYST | 3000.00 | | 20 | researchmgr + 7876 | ADAMS | CLERK | 1100.00 | | 20 | researchmgr + 7902 | FORD | ANALYST | 3000.00 | | 20 | researchmgr + 7499 | ALLEN | SALESMAN | 1600.00 | 300.00 | 30 | salesmgr + 7521 | WARD | SALESMAN | 1250.00 | 500.00 | 30 | salesmgr + 7654 | MARTIN | SALESMAN | 1250.00 | 1400.00 | 30 | salesmgr + 7698 | BLAKE | MANAGER | 2850.00 | | 30 | salesmgr + 7844 | TURNER | SALESMAN | 1500.00 | 0.00 | 30 | salesmgr + 7900 | JAMES | CLERK | 950.00 | | 30 | salesmgr +(14 rows) + +CREATE ROLE salesmgr WITH LOGIN PASSWORD 'password'; +GRANT ALL ON vpemp TO salesmgr; +``` + +## ADD_POLICY + +The `ADD_POLICY` procedure creates a new policy by associating a policy function with a database object. + +You must be a superuser to execute this procedure. + +```text +ADD_POLICY( VARCHAR2, VARCHAR2, + VARCHAR2, VARCHAR2, + VARCHAR2 + [, VARCHAR2 + [, BOOLEAN + [, BOOLEAN + [, BOOLEAN + [, INTEGER + [, BOOLEAN + [, VARCHAR2 + [, INTEGER ]]]]]]]]) +``` + +**Parameters** + +`object_schema` + + Name of the schema containing the database object to which the policy is to be applied. + +`object_name` + + Name of the database object to which the policy is to be applied. A given database object may have more than one policy applied to it. + +`policy_name` + + Name assigned to the policy. The combination of database object (identified by `object_schema` and `object_name`) and policy name must be unique within the database. + +`function_schema` + + Name of the schema containing the policy function. + + **Note**: The policy function may belong to a package in which case `function_schema` must contain the name of the schema in which the package is defined. + +`policy_function` + + Name of the SPL function that defines the rules of the security policy. The same function may be specified in more than one policy. + + **Note**: The policy function may belong to a package in which case `policy_function` must also contain the package name in dot notation (that is, `package_name.function_name`). + +`statement_types` + + Comma-separated list of SQL commands to which the policy applies. Valid SQL commands are `INSERT, UPDATE, DELETE`, and `SELECT`. The default is `INSERT,UPDATE,DELETE,SELECT`. + + **Note**: Advanced Server accepts `INDEX` as a statement type, but it is ignored. Policies are not applied to index operations in Advanced Server. + +`update_check` + + Applies to `INSERT` and `UPDATE` SQL commands only. + +- When set to `TRUE`, the policy is applied to newly inserted rows and to the modified image of updated rows. If any of the new or modified rows do not qualify according to the policy function predicate, then the `INSERT` or `UPDATE` command throws an exception and no rows are inserted or modified by the `INSERT` or `UPDATE` command. + +- When set to `FALSE`, the policy is not applied to newly inserted rows or the modified image of updated rows. Thus, a newly inserted row may not appear in the result set of a subsequent SQL command that invokes the same policy. Similarly, rows which qualified according to the policy prior to an `UPDATE` command may not appear in the result set of a subsequent SQL command that invokes the same policy. + +- The default is `FALSE`. + +`enable` + + When set to `TRUE`, the policy is enabled and applied to the SQL commands given by the `statement_types` parameter. When set to `FALSE` the policy is disabled and not applied to any SQL commands. The policy can be enabled using the `ENABLE_POLICY` procedure. The default is `TRUE`. + +`static_policy` + + In Oracle, when set to `TRUE`, the policy is *static*, which means the policy function is evaluated once per database object the first time it is invoked by a policy on that database object. The resulting policy function predicate string is saved in memory and reused for all invocations of that policy on that database object while the database server instance is running. + +- When set to `FALSE`, the policy is *dynamic*, which means the policy function is re-evaluated and the policy function predicate string regenerated for all invocations of the policy. + +- The default is `FALSE`. + + !!! Note + In Oracle 10g, the `policy_type` parameter was introduced, which is intended to replace the `static_policy` parameter. In Oracle, if the `policy_type` parameter is not set to its default value of `NULL`, the `policy_type` parameter setting overrides the `static_policy` setting. + + !!! Note + The setting of `static_policy` is ignored by Advanced Server. Advanced Server implements only the dynamic policy, regardless of the setting of the `static_policy` parameter. + +`policy_type` + + In Oracle, determines when the policy function is re-evaluated, and hence, if and when the predicate string returned by the policy function changes. The default is `NULL`. + + **Note**: The setting of this parameter is ignored by Advanced Server. Advanced Server always assumes a dynamic policy. + +`long_predicate` + + In Oracle, allows predicates up to 32K bytes if set to `TRUE`, otherwise predicates are limited to 4000 bytes. The default is `FALSE`. + + **Note**: The setting of this parameter is ignored by Advanced Server. An Advanced Server policy function can return a predicate of unlimited length for all practical purposes. + +`sec_relevant_cols` + + Comma-separated list of columns of `object_name`. Provides *column-level Virtual Private Database* for the listed columns. The policy is enforced if any of the listed columns are referenced in a SQL command of a type listed in `statement_types`. The policy is not enforced if no such columns are referenced. + + The default is `NULL`, which has the same effect as if all of the database object’s columns were included in `sec_relevant_cols`. + +`sec_relevant_cols_opt` + + In Oracle, if `sec_relevant_cols_opt` is set to `DBMS_RLS.ALL_ROWS (INTEGER` constant of value 1), then the columns listed in `sec_relevant_cols` return `NULL` on all rows where the applied policy predicate is false. (If `sec_relevant_cols_opt` is not set to `DBMS_RLS.ALL_ROWS`, these rows would not be returned at all in the result set.) The default is `NULL`. + + **Note**: Advanced Server does not support the `DBMS_RLS.ALL_ROWS` functionality. Advanced Server throws an error if `sec_relevant_cols_opt` is set to `DBMS_RLS.ALL_ROWS (INTEGER` value of 1). + +**Examples** + +This example uses the following policy function: + +```text +CREATE OR REPLACE FUNCTION verify_session_user ( + p_schema VARCHAR2, + p_object VARCHAR2 +) +RETURN VARCHAR2 +IS +BEGIN + RETURN 'authid = SYS_CONTEXT(''USERENV'', ''SESSION_USER'')'; +END; +``` + +This function generates the predicate `authid = SYS_CONTEXT('USERENV', 'SESSION_USER')`, which is added to the `WHERE` clause of any SQL command of the type specified in the `ADD_POLICY` procedure. + +This limits the effect of the SQL command to those rows where the content of the `authid` column is the same as the session user. + +!!! Note + This example uses the `SYS_CONTEXT` function to return the login user name. In Oracle the `SYS_CONTEXT` function is used to return attributes of an *application context*. The first parameter of the `SYS_CONTEXT` function is the name of an application context while the second parameter is the name of an attribute set within the application context. `USERENV` is a special built-in namespace that describes the current session. Advanced Server does not support application contexts, but only this specific usage of the `SYS_CONTEXT` function. + +The following anonymous block calls the `ADD_POLICY` procedure to create a policy named `secure_update` to be applied to the `vpemp` table using function `verify_session_user` whenever an `INSERT, UPDATE`, or `DELETE` SQL command is given referencing the `vpemp` table. + +```text +DECLARE + v_object_schema VARCHAR2(30) := 'public'; + v_object_name VARCHAR2(30) := 'vpemp'; + v_policy_name VARCHAR2(30) := 'secure_update'; + v_function_schema VARCHAR2(30) := 'enterprisedb'; + v_policy_function VARCHAR2(30) := 'verify_session_user'; + v_statement_types VARCHAR2(30) := 'INSERT,UPDATE,DELETE'; + v_update_check BOOLEAN := TRUE; + v_enable BOOLEAN := TRUE; +BEGIN + DBMS_RLS.ADD_POLICY( + v_object_schema, + v_object_name, + v_policy_name, + v_function_schema, + v_policy_function, + v_statement_types, + v_update_check, + v_enable + ); +END; +``` + +After successful creation of the policy, a terminal session is started by user `salesmgr`. The following query shows the content of the `vpemp` table: + +```text +edb=# \c edb salesmgr +Password for user salesmgr: +You are now connected to database "edb" as user "salesmgr". +edb=> SELECT * FROM vpemp; + empno | ename | job | sal | comm | deptno | authid +-------+--------+-----------+---------+---------+--------+------------- + 7782 | CLARK | MANAGER | 2450.00 | | 10 | + 7839 | KING | PRESIDENT | 5000.00 | | 10 | + 7934 | MILLER | CLERK | 1300.00 | | 10 | + 7369 | SMITH | CLERK | 800.00 | | 20 | researchmgr + 7566 | JONES | MANAGER | 2975.00 | | 20 | researchmgr + 7788 | SCOTT | ANALYST | 3000.00 | | 20 | researchmgr + 7876 | ADAMS | CLERK | 1100.00 | | 20 | researchmgr + 7902 | FORD | ANALYST | 3000.00 | | 20 | researchmgr + 7499 | ALLEN | SALESMAN | 1600.00 | 300.00 | 30 | salesmgr + 7521 | WARD | SALESMAN | 1250.00 | 500.00 | 30 | salesmgr + 7654 | MARTIN | SALESMAN | 1250.00 | 1400.00 | 30 | salesmgr + 7698 | BLAKE | MANAGER | 2850.00 | | 30 | salesmgr + 7844 | TURNER | SALESMAN | 1500.00 | 0.00 | 30 | salesmgr + 7900 | JAMES | CLERK | 950.00 | | 30 | salesmgr +(14 rows) +``` + +An unqualified `UPDATE` command (no `WHERE` clause) is issued by the `salesmgr` user: + +```text +edb=> UPDATE vpemp SET comm = sal * .75; +UPDATE 6 +``` + +Instead of updating all rows in the table, the policy restricts the effect of the update to only those rows where the `authid` column contains the value `salesmgr` as specified by the policy function predicate `authid = SYS_CONTEXT('USERENV', 'SESSION_USER')`. + +The following query shows that the `comm` column has been changed only for those rows where `authid` contains `salesmgr`. All other rows are unchanged. + +```text +edb=> SELECT * FROM vpemp; + empno | ename | job | sal | comm | deptno | authid +-------+--------+-----------+---------+---------+--------+------------- + 7782 | CLARK | MANAGER | 2450.00 | | 10 | + 7839 | KING | PRESIDENT | 5000.00 | | 10 | + 7934 | MILLER | CLERK | 1300.00 | | 10 | + 7369 | SMITH | CLERK | 800.00 | | 20 | researchmgr + 7566 | JONES | MANAGER | 2975.00 | | 20 | researchmgr + 7788 | SCOTT | ANALYST | 3000.00 | | 20 | researchmgr + 7876 | ADAMS | CLERK | 1100.00 | | 20 | researchmgr + 7902 | FORD | ANALYST | 3000.00 | | 20 | researchmgr + 7499 | ALLEN | SALESMAN | 1600.00 | 1200.00 | 30 | salesmgr + 7521 | WARD | SALESMAN | 1250.00 | 937.50 | 30 | salesmgr + 7654 | MARTIN | SALESMAN | 1250.00 | 937.50 | 30 | salesmgr + 7698 | BLAKE | MANAGER | 2850.00 | 2137.50 | 30 | salesmgr + 7844 | TURNER | SALESMAN | 1500.00 | 1125.00 | 30 | salesmgr + 7900 | JAMES | CLERK | 950.00 | 712.50 | 30 | salesmgr +(14 rows) +``` + +Furthermore, since the `update_check` parameter was set to `TRUE` in the `ADD_POLICY` procedure, the following `INSERT` command throws an exception since the value given for the `authid` column, `researchmgr`, does not match the session user, which is `salesmgr`, and hence, fails the policy. + +```text +edb=> INSERT INTO vpemp VALUES (9001,'SMITH','ANALYST',3200.00,NULL,20, +'researchmgr'); +ERROR: policy with check option violation +DETAIL: Policy predicate was evaluated to FALSE with the updated values +``` + +If `update_check` was set to `FALSE`, the preceding `INSERT` command would have succeeded. + +The following example illustrates the use of the `sec_relevant_cols` parameter to apply a policy only when certain columns are referenced in the SQL command. The following policy function is used for this example, which selects rows where the employee salary is less than `2000`. + +```text +CREATE OR REPLACE FUNCTION sal_lt_2000 ( + p_schema VARCHAR2, + p_object VARCHAR2 +) +RETURN VARCHAR2 +IS +BEGIN + RETURN 'sal < 2000'; +END +``` + +The policy is created so that it is enforced only if a `SELECT` command includes columns `sal` or `comm`: + +```text +DECLARE + v_object_schema VARCHAR2(30) := 'public'; + v_object_name VARCHAR2(30) := 'vpemp'; + v_policy_name VARCHAR2(30) := 'secure_salary'; + v_function_schema VARCHAR2(30) := 'enterprisedb'; + v_policy_function VARCHAR2(30) := 'sal_lt_2000'; + v_statement_types VARCHAR2(30) := 'SELECT'; + v_sec_relevant_cols VARCHAR2(30) := 'sal,comm'; +BEGIN + DBMS_RLS.ADD_POLICY( + v_object_schema, + v_object_name, + v_policy_name, + v_function_schema, + v_policy_function, + v_statement_types, + sec_relevant_cols => v_sec_relevant_cols + ); +END; +``` + +If a query does not reference columns `sal` or `comm`, then the policy is not applied. The following query returns all 14 rows of table `vpemp`: + +```text +edb=# SELECT empno, ename, job, deptno, authid FROM vpemp; + empno | ename | job | deptno | authid +-------+--------+-----------+--------+------------- + 7782 | CLARK | MANAGER | 10 | + 7839 | KING | PRESIDENT | 10 | + 7934 | MILLER | CLERK | 10 | + 7369 | SMITH | CLERK | 20 | researchmgr + 7566 | JONES | MANAGER | 20 | researchmgr + 7788 | SCOTT | ANALYST | 20 | researchmgr + 7876 | ADAMS | CLERK | 20 | researchmgr + 7902 | FORD | ANALYST | 20 | researchmgr + 7499 | ALLEN | SALESMAN | 30 | salesmgr + 7521 | WARD | SALESMAN | 30 | salesmgr + 7654 | MARTIN | SALESMAN | 30 | salesmgr + 7698 | BLAKE | MANAGER | 30 | salesmgr + 7844 | TURNER | SALESMAN | 30 | salesmgr + 7900 | JAMES | CLERK | 30 | salesmgr +(14 rows) +``` + +If the query references the `sal` or `comm` columns, then the policy is applied to the query eliminating any rows where `sal` is greater than or equal to `2000` as shown by the following: + +```text +edb=# SELECT empno, ename, job, sal, comm, deptno, authid FROM vpemp; + empno | ename | job | sal | comm | deptno | authid +-------+--------+----------+---------+---------+--------+------------- + 7934 | MILLER | CLERK | 1300.00 | | 10 | + 7369 | SMITH | CLERK | 800.00 | | 20 | researchmgr + 7876 | ADAMS | CLERK | 1100.00 | | 20 | researchmgr + 7499 | ALLEN | SALESMAN | 1600.00 | 1200.00 | 30 | salesmgr + 7521 | WARD | SALESMAN | 1250.00 | 937.50 | 30 | salesmgr + 7654 | MARTIN | SALESMAN | 1250.00 | 937.50 | 30 | salesmgr + 7844 | TURNER | SALESMAN | 1500.00 | 1125.00 | 30 | salesmgr + 7900 | JAMES | CLERK | 950.00 | 712.50 | 30 | salesmgr +(8 rows) +``` + +## DROP_POLICY + +The `DROP_POLICY` procedure deletes an existing policy. The policy function and database object associated with the policy are not deleted by the `DROP_POLICY` procedure. + +You must be a superuser to execute this procedure. + +```text +DROP_POLICY( VARCHAR2, VARCHAR2, + VARCHAR2) +``` + +**Parameters** + +`object_schema` + + Name of the schema containing the database object to which the policy applies. + +`object_name` + + Name of the database object to which the policy applies. + +`policy_name` + + Name of the policy to be deleted. + +**Examples** + +The following example deletes policy `secure_update` on table `public.vpemp`: + +```text +DECLARE + v_object_schema VARCHAR2(30) := 'public'; + v_object_name VARCHAR2(30) := 'vpemp'; + v_policy_name VARCHAR2(30) := 'secure_update'; +BEGIN + DBMS_RLS.DROP_POLICY( + v_object_schema, + v_object_name, + v_policy_name + ); +END; +``` + +## ENABLE_POLICY + +The `ENABLE_POLICY` procedure enables or disables an existing policy on the specified database object. + +You must be a superuser to execute this procedure. + +```text +ENABLE_POLICY( VARCHAR2, VARCHAR2, + VARCHAR2, BOOLEAN) +``` + +**Parameters** + +`object_schema` + + Name of the schema containing the database object to which the policy applies. + +`object_name` + + Name of the database object to which the policy applies. + +`policy_name` + + Name of the policy to be enabled or disabled. + +`enable` + + When set to `TRUE`, the policy is enabled. When set to `FALSE`, the policy is disabled. + +**Examples** + +The following example disables policy secure_update on table `public.vpemp`: + +```text +DECLARE + v_object_schema VARCHAR2(30) := 'public'; + v_object_name VARCHAR2(30) := 'vpemp'; + v_policy_name VARCHAR2(30) := 'secure_update'; + v_enable BOOLEAN := FALSE; +BEGIN + DBMS_RLS.ENABLE_POLICY( + v_object_schema, + v_object_name, + v_policy_name, + v_enable + ); +END; +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/15_dbms_scheduler/01_using_calendar_syntax_to_specify_a_repeating_interval.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/15_dbms_scheduler/01_using_calendar_syntax_to_specify_a_repeating_interval.mdx new file mode 100644 index 00000000000..ab386d98016 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/15_dbms_scheduler/01_using_calendar_syntax_to_specify_a_repeating_interval.mdx @@ -0,0 +1,38 @@ +--- +title: "Using Calendar Syntax to Specify a Repeating Interval" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/using_calendar_syntax_to_specify_a_repeating_interval.html" +--- + +The `CREATE_JOB` and `CREATE_SCHEDULE` procedures use Oracle-styled calendar syntax to define the interval with which a job or schedule is repeated. You should provide the scheduling information in the `repeat_interval` parameter of each procedure. + +`repeat_interval` is a value (or series of values) that define the interval between the executions of the scheduled job. Each value is composed of a token, followed by an equal sign, followed by the unit (or units) on which the schedule will execute. Multiple token values must be separated by a semi-colon (;). + +For example, the following value: + + `FREQ=DAILY;BYDAY=MON,TUE,WED,THU,FRI;BYHOUR=17;BYMINUTE=45` + +Defines a schedule that is executed each weeknight at 5:45. + +The token types and syntax described in the table below are supported by Advanced Server: + +| Token type | Syntax | Valid Values | +| ------------ | ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `FREQ` | `FREQ=predefined_interval` | Where `predefined_interval` is one of the following: `YEARLY, MONTHLY, WEEKLY, DAILY, HOURLY, MINUTELY`. The `SECONDLY` keyword is not supported. | +| `BYMONTH` | `BYMONTH=month(, month)...` | Where `month` is the three-letter abbreviation of the month name: `JAN \| FEB \| MAR \| APR \| MAY \| JUN \| JUL \| AUG \| SEP \| OCT \| NOV \| DEC` | +| `BYMONTH` | `BYMONTH=month (, month)...` | Where `month` is the numeric value representing the month: `1 \| 2 \| 3 \| 4 \| 5 \| 6 \| 7 \| 8 \| 9 \| 10 \| 11 \| 12` | +| `BYMONTHDAY` | `BYMONTHDAY=day_of_month` | Where `day_of_month` is a value from `1` through `31` | +| `BYDAY` | `BYDAY=weekday` | Where `weekday` is a three-letter abbreviation or single-digit value representing the day of the week. | +| | | `Monday` \| `MON` \| `1` \| | +| | | `Tuesday` \| `TUE` \| `2` \| | +| | | `Wednesday` \| `WED` \| `3` \| | +| | | `Thursday` \| `THU` \| `4` \| | +| | | `Friday` \| `FRI` \| `5` \| | +| | | `Saturday` \| `SAT` \| `6` \| | +| | | `Sunday` \| `SUN` \| `7` \| | +| `BYDATE` | `BYDATE=date(, date)...` | Where date is `YYYYMMDD`.

`YYYY` is a four-digit year representation of the year,
`MM` is a two-digit representation of the month,
and `DD` is a two-digit day representation of the day. | +| `BYDATE` | `BYDATE=date(, date)...` | Where date is `MMDD`.

`MM` is a two-digit representation of the month,
and `DD` is a two-digit day representation of the day | +| `BYHOUR` | `BYHOUR=hour` | Where `hour` is a value from `0` through `23`. | +| `BYMINUTE` | `BYMINUTE=minute` | Where `minute` is a value from `0` through `59`. | diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/15_dbms_scheduler/02_create_job.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/15_dbms_scheduler/02_create_job.mdx new file mode 100644 index 00000000000..96f287ba26b --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/15_dbms_scheduler/02_create_job.mdx @@ -0,0 +1,115 @@ +--- +title: "CREATE_JOB" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/create_job.html" +--- + +Use the `CREATE_JOB` procedure to create a job. The procedure comes in two forms; the first form of the procedure specifies a schedule within the job definition, as well as a job action that will be invoked when the job executes: + +```text +CREATE_JOB( + IN VARCHAR2, + IN VARCHAR2, + IN VARCHAR2, + IN PLS_INTEGER DEFAULT 0, + IN TIMESTAMP WITH TIME ZONE DEFAULT NULL, + IN VARCHAR2 DEFAULT NULL, + IN TIMESTAMP WITH TIME ZONE DEFAULT NULL, + IN VARCHAR2 DEFAULT 'DEFAULT_JOB_CLASS', + IN BOOLEAN DEFAULT FALSE, + IN BOOLEAN DEFAULT TRUE, + IN VARCHAR2 DEFAULT NULL) +``` + +The second form uses a job schedule to specify the schedule on which the job will execute, and specifies the name of a program that will execute when the job runs: + +```text +CREATE_JOB( + IN VARCHAR2, + IN VARCHAR2, + IN VARCHAR2, + IN VARCHAR2 DEFAULT 'DEFAULT_JOB_CLASS', + IN BOOLEAN DEFAULT FALSE, + IN BOOLEAN DEFAULT TRUE, + IN VARCHAR2 DEFAULT NULL) +``` + +**Parameters** + +`job_name` + + `job_name` specifies the optionally schema-qualified name of the job being created. + +`job_type` + + `job_type` specifies the type of job. The current implementation of `CREATE_JOB` supports a job type of `PLSQL_BLOCK` or `STORED_PROCEDURE`. + +`job_action` + +- If `job_type` is `PLSQL_BLOCK`, `job_action` specifies the content of the PL/SQL block that will be invoked when the job executes. The block must be terminated with a semi-colon (;). + +- If `job_type` is `STORED_PROCEDURE`, `job_action` specifies the optionally schema-qualified name of the procedure. + +`number_of_arguments` + + `number_of_arguments` is an `INTEGER` value that specifies the number of arguments expected by the job. The default is `0`. + +`start_date` + + `start_date` is a `TIMESTAMP WITH TIME ZONE` value that specifies the first time that the job is scheduled to execute. The default value is `NULL`, indicating that the job should be scheduled to execute when the job is enabled. + +`repeat_interval` + + `repeat_interval` is a `VARCHAR2` value that specifies how often the job will repeat. If a `repeat_interval` is not specified, the job will execute only once. The default value is `NULL`. + +`end_date` + + `end_date` is a `TIMESTAMP WITH TIME ZONE` value that specifies a time after which the job will no longer execute. If a date is specified, the `end_date` must be after `start_date`. The default value is `NULL`. + + Please note that if an `end_date` is not specified and a `repeat_interval` is specified, the job will repeat indefinitely until it is disabled. + +`program_name` + + `program_name` is the name of a program that will be executed by the job. + +`schedule_name` + + `schedule_name` is the name of the schedule associated with the job. + +`job_class` + + `job_class` is accepted for compatibility and ignored. + +`enabled` + + `enabled` is a `BOOLEAN` value that specifies if the job is enabled when created. By default, a job is created in a disabled state, with `enabled` set to `FALSE`. To enable a job, specify a value of `TRUE` when creating the job, or enable the job with the `DBMS_SCHEDULER.ENABLE` procedure. + +`auto_drop` + + The `auto_drop` parameter is accepted for compatibility and is ignored. By default, a job's status will be changed to `DISABLED` after the time specified in `end_date`. + +`comments` + + Use the `comments` parameter to specify a comment about the job. + +**Example** + +The following example demonstrates a call to the `CREATE_JOB` procedure: + +```text +EXEC + DBMS_SCHEDULER.CREATE_JOB ( + job_name => 'update_log', + job_type => 'PLSQL_BLOCK', + job_action => 'BEGIN INSERT INTO my_log VALUES(current_timestamp); + END;', + start_date => '01-JUN-15 09:00:00.000000', + repeat_interval => 'FREQ=DAILY;BYDAY=MON,TUE,WED,THU,FRI;BYHOUR=17;', + end_date => NULL, + enabled => TRUE, + comments => 'This job adds a row to the my_log table.'); +``` + +The code fragment creates a job named `update_log` that executes each weeknight at 5:00. The job executes a PL/SQL block that inserts the current timestamp into a logfile (`my_log`). Since no `end_date` is specified, the job will execute until it is disabled by the `DBMS_SCHEDULER.DISABLE` procedure. diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/15_dbms_scheduler/03_create_program.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/15_dbms_scheduler/03_create_program.mdx new file mode 100644 index 00000000000..639fbb972d0 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/15_dbms_scheduler/03_create_program.mdx @@ -0,0 +1,71 @@ +--- +title: "CREATE_PROGRAM" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/create_program.html" +--- + +Use the `CREATE_PROGRAM` procedure to create a `DBMS_SCHEDULER` program. The signature is: + +```text +CREATE_PROGRAM( + IN VARCHAR2, + IN VARCHAR2, + IN VARCHAR2, + IN PLS_INTEGER DEFAULT 0, + IN BOOLEAN DEFAULT FALSE, + IN VARCHAR2 DEFAULT NULL) +``` + +**Parameters** + +`program_name` + + `program_name` specifies the name of the program that is being created. + +`program_type` + + `program_type` specifies the type of program. The current implementation of `CREATE_PROGRAM` supports a `program_type` of `PLSQL_BLOCK` or `PROCEDURE`. + +`program_action` + +- If `program_type` is `PLSQL_BLOCK, program_action` contains the PL/SQL block that will execute when the program is invoked. The PL/SQL block must be terminated with a semi-colon (;). + +- If `program_type` is `PROCEDURE`, `program_action` contains the name of the stored procedure. + +`number_of_arguments` + +- If `program_type` is `PLSQL_BLOCK`, this argument is ignored. + +- If `program_type` is `PROCEDURE`, `number_of_arguments` specifies the number of arguments required by the procedure. The default value is `0`. + +`enabled` + + `enabled` specifies if the program is created enabled or disabled: + +- If `enabled` is `TRUE`, the program is created enabled. +- If `enabled` is `FALSE`, the program is created disabled; use the `DBMS_SCHEDULER.ENABLE` program to enable a disabled program. + + The default value is `FALSE`. + +`comments` + + Use the `comments` parameter to specify a comment about the program; by default, this parameter is `NULL`. + +**Example** + +The following call to the `CREATE_PROGRAM` procedure creates a program named `update_log`: + +```text +EXEC + DBMS_SCHEDULER.CREATE_PROGRAM ( + program_name => 'update_log', + program_type => 'PLSQL_BLOCK', + program_action => 'BEGIN INSERT INTO my_log VALUES(current_timestamp); + END;', + enabled => TRUE, + comment => 'This program adds a row to the my_log table.'); +``` + +`update_log` is a PL/SQL block that adds a row containing the current date and time to the `my_log` table. The program will be enabled when the `CREATE_PROGRAM` procedure executes. diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/15_dbms_scheduler/04_create_schedule.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/15_dbms_scheduler/04_create_schedule.mdx new file mode 100644 index 00000000000..5cc8d9e5c42 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/15_dbms_scheduler/04_create_schedule.mdx @@ -0,0 +1,59 @@ +--- +title: "CREATE_SCHEDULE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/create_schedule.html" +--- + +Use the `CREATE_SCHEDULE` procedure to create a job schedule. The signature of the `CREATE_SCHEDULE` procedure is: + +```text +CREATE_SCHEDULE( + IN VARCHAR2, + IN TIMESTAMP WITH TIME ZONE DEFAULT NULL, + IN VARCHAR2, + IN TIMESTAMP WITH TIME ZONE DEFAULT NULL, + IN VARCHAR2 DEFAULT NULL) +``` + +**Parameters** + +`schedule_name` + + `schedule_name` specifies the name of the schedule. + +`start_date` + + `start_date` is a `TIMESTAMP WITH TIME ZONE` value that specifies the date and time that the schedule is eligible to execute. If a `start_date` is not specified, the date that the job is enabled is used as the `start_date`. By default, `start_date` is `NULL`. + +`repeat_interval` + + `repeat_interval` is a `VARCHAR2` value that specifies how often the job will repeat. If a `repeat_interval` is not specified, the job will execute only once, on the date specified by `start_date`. + + **Note**: You must provide a value for either `start_date` or `repeat_interval`; if both `start_date` and `repeat_interval` are `NULL`, the server will return an error. + +`end_date` + + `end_date` is a `TIMESTAMP WITH TIME ZONE` value that specifies a time after which the schedule will no longer execute. If a date is specified, the `end_date` must be after the `start_date`. The default value is `NULL`. + + **Note**: If a `repeat_interval` is specified and an `end_date` is not specified, the schedule will repeat indefinitely until it is disabled. + +`comments` + + Use the `comments` parameter to specify a comment about the schedule; by default, this parameter is `NULL`. + +**Example** + +The following code fragment calls `CREATE_SCHEDULE` to create a schedule named `weeknights_at_5`: + +```text +EXEC + DBMS_SCHEDULER.CREATE_SCHEDULE ( + schedule_name => 'weeknights_at_5', + start_date => '01-JUN-13 09:00:00.000000' + repeat_interval => 'FREQ=DAILY;BYDAY=MON,TUE,WED,THU,FRI;BYHOUR=17;', + comments => 'This schedule executes each weeknight at 5:00'); +``` + +The schedule executes each weeknight, at 5:00 pm, effective after June 1, 2013. Since no `end_date` is specified, the schedule will execute indefinitely until it is disabled with `DBMS_SCHEDULER.DISABLE`. diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/15_dbms_scheduler/05_define_program_argument.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/15_dbms_scheduler/05_define_program_argument.mdx new file mode 100644 index 00000000000..b023f316224 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/15_dbms_scheduler/05_define_program_argument.mdx @@ -0,0 +1,78 @@ +--- +title: "DEFINE_PROGRAM_ARGUMENT" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/define_program_argument.html" +--- + +Use the `DEFINE_PROGRAM_ARGUMENT` procedure to define a program argument. The `DEFINE_PROGRAM_ARGUMENT` procedure comes in two forms; the first form defines an argument with a default value: + +```text +DEFINE_PROGRAM_ARGUMENT( + IN VARCHAR2, + IN PLS_INTEGER, + IN VARCHAR2 DEFAULT NULL, + IN VARCHAR2, + IN VARCHAR2, + IN BOOLEAN DEFAULT FALSE) +``` + +The second form defines an argument without a default value: + +```text +DEFINE_PROGRAM_ARGUMENT( + IN VARCHAR2, + IN PLS_INTEGER, + IN VARCHAR2 DEFAULT NULL, + IN VARCHAR2, + IN BOOLEAN DEFAULT FALSE) +``` + +**Parameters** + +`program_name` + + `program_name` is the name of the program to which the arguments belong. + +`argument_position` + + `argument_position` specifies the position of the argument as it is passed to the program. + +`argument_name` + + `argument_name` specifies the optional name of the argument. By default, `argument_name` is `NULL`. + +`argument_type IN VARCHAR2` + + `argument_type` specifies the data type of the argument. + +`default_value` + + `default_value` specifies the default value assigned to the argument. `default_value` will be overridden by a value specified by the job when the job executes. + +`out_argument IN BOOLEAN DEFAULT FALSE` + + `out_argument` is not currently used; if specified, the value must be `FALSE`. + +**Example** + +The following code fragment uses the `DEFINE_PROGRAM_ARGUMENT` procedure to define the first and second arguments in a program named `add_emp`: + +```text +EXEC + DBMS_SCHEDULER.DEFINE_PROGRAM_ARGUMENT( + program_name => 'add_emp', + argument_position => 1, + argument_name => 'dept_no', + argument_type => 'INTEGER, + default_value => '20'); +EXEC + DBMS_SCHEDULER.DEFINE_PROGRAM_ARGUMENT( + program_name => 'add_emp', + argument_position => 2, + argument_name => 'emp_name', + argument_type => 'VARCHAR2'); +``` + +The first argument is an `INTEGER` value named `dept_no` that has a default value of `20`. The second argument is a `VARCHAR2` value named `emp_name`; the second argument does not have a default value. diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/15_dbms_scheduler/06_dbms_scheduler_disable.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/15_dbms_scheduler/06_dbms_scheduler_disable.mdx new file mode 100644 index 00000000000..dc0981c03fe --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/15_dbms_scheduler/06_dbms_scheduler_disable.mdx @@ -0,0 +1,42 @@ +--- +title: "DISABLE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/dbms_scheduler_disable.html" +--- + + + +Use the `DISABLE` procedure to disable a program or a job. The signature of the `DISABLE` procedure is: + +```text +DISABLE( + IN VARCHAR2, + IN BOOLEAN DEFAULT FALSE, + IN VARCHAR2 DEFAULT 'STOP_ON_FIRST_ERROR') +``` + +**Parameters** + +`name` + + `name` specifies the name of the program or job that is being disabled. + +`force` + + `force` is accepted for compatibility, and ignored. + +`commit_semantics` + + `commit_semantics` instructs the server how to handle an error encountered while disabling a program or job. By default, `commit_semantics` is set to `STOP_ON_FIRST_ERROR`, instructing the server to stop when it encounters an error. Any programs or jobs that were successfully disabled prior to the error will be committed to disk. + + The `TRANSACTIONAL` and `ABSORB_ERRORS` keywords are accepted for compatibility, and ignored. + +**Example** + +The following call to the `DISABLE` procedure disables a program named `update_emp`: + +```text +DBMS_SCHEDULER.DISABLE('update_emp'); +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/15_dbms_scheduler/07_drop_job.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/15_dbms_scheduler/07_drop_job.mdx new file mode 100644 index 00000000000..05f4d823e4c --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/15_dbms_scheduler/07_drop_job.mdx @@ -0,0 +1,45 @@ +--- +title: "DROP_JOB" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/drop_job.html" +--- + +Use the `DROP_JOB` procedure to `DROP` a job, `DROP` any arguments that belong to the job, and eliminate any future job executions. The signature of the procedure is: + +```text +DROP_JOB( + IN VARCHAR2, + IN BOOLEAN DEFAULT FALSE, + IN BOOLEAN DEFAULT FALSE, + IN VARCHAR2 DEFAULT 'STOP_ON_FIRST_ERROR') +``` + +**Parameters** + +`job_name` + + `job_name` specifies the name of the job that is being dropped. + +`force` + + `force` is accepted for compatibility, and ignored. + +`defer` + + `defer` is accepted for compatibility, and ignored. + +`commit_semantics` + + `commit_semantics` instructs the server how to handle an error encountered while dropping a program or job. By default, `commit_semantics` is set to `STOP_ON_FIRST_ERROR`, instructing the server to stop when it encounters an error. + + The `TRANSACTIONAL` and `ABSORB_ERRORS` keywords are accepted for compatibility, and ignored. + +**Example** + +The following call to `DROP_JOB` drops a job named `update_log`: + +```text +DBMS_SCHEDULER.DROP_JOB('update_log'); +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/15_dbms_scheduler/08_drop_program.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/15_dbms_scheduler/08_drop_program.mdx new file mode 100644 index 00000000000..d51e87cafef --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/15_dbms_scheduler/08_drop_program.mdx @@ -0,0 +1,39 @@ +--- +title: "DROP_PROGRAM" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/drop_program.html" +--- + +The `DROP_PROGRAM` procedure to drop a program. The signature of the `DROP_PROGRAM` procedure is: + +```text +DROP_PROGRAM( + IN VARCHAR2, + IN BOOLEAN DEFAULT FALSE) +``` + +**Parameters** + +`program_name` + + `program_name` specifies the name of the program that is being dropped. + +`force` + + `force` is a `BOOLEAN` value that instructs the server how to handle programs with dependent jobs. + +- Specify `FALSE` to instruct the server to return an error if the program is referenced by a job. + +- Specify `TRUE` to instruct the server to disable any jobs that reference the program before dropping the program. + + The default value is `FALSE`. + +**Example** + +The following call to `DROP_PROGRAM` drops a job named `update_emp`: + +```text +DBMS_SCHEDULER.DROP_PROGRAM('update_emp'); +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/15_dbms_scheduler/09_drop_program_argument.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/15_dbms_scheduler/09_drop_program_argument.mdx new file mode 100644 index 00000000000..2b7e5cf43e6 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/15_dbms_scheduler/09_drop_program_argument.mdx @@ -0,0 +1,51 @@ +--- +title: "DROP_PROGRAM_ARGUMENT" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/drop_program_argument.html" +--- + +Use the `DROP_PROGRAM_ARGUMENT` procedure to drop a program argument. The `DROP_PROGRAM_ARGUMENT` procedure comes in two forms; the first form uses an argument position to specify which argument to drop: + +```text +DROP_PROGRAM_ARGUMENT( + IN VARCHAR2, + IN PLS_INTEGER) +``` + +The second form takes the argument name: + +```text +DROP_PROGRAM_ARGUMENT( + IN VARCHAR2, + IN VARCHAR2) +``` + +**Parameters** + +`program_name` + + `program_name` specifies the name of the program that is being modified. + +`argument_position` + + `argument_position` specifies the position of the argument that is being dropped. + +`argument_name` + + `argument_name` specifies the name of the argument that is being dropped. + +**Examples** + +The following call to `DROP_PROGRAM_ARGUMENT` drops the first argument in the `update_emp` program: + +```text +DBMS_SCHEDULER.DROP_PROGRAM_ARGUMENT('update_emp', 1); +``` + +The following call to `DROP_PROGRAM_ARGUMENT` drops an argument named `emp_name`: + +```text +DBMS_SCHEDULER.DROP_PROGRAM_ARGUMENT(update_emp', 'emp_name'); +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/15_dbms_scheduler/10_drop_schedule.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/15_dbms_scheduler/10_drop_schedule.mdx new file mode 100644 index 00000000000..0079e41d2ca --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/15_dbms_scheduler/10_drop_schedule.mdx @@ -0,0 +1,38 @@ +--- +title: "DROP_SCHEDULE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/drop_schedule.html" +--- + +Use the `DROP_SCHEDULE` procedure to drop a schedule. The signature is: + +```text +DROP_SCHEDULE( + IN VARCHAR2, + IN BOOLEAN DEFAULT FALSE) +``` + +**Parameters** + +`schedule_name` + + `schedule_name` specifies the name of the schedule that is being dropped. + +`force` + + `force` specifies the behavior of the server if the specified schedule is referenced by any job: + +- Specify `FALSE` to instruct the server to return an error if the specified schedule is referenced by a job. This is the default behavior. +- Specify `TRUE` to instruct the server to disable to any jobs that use the specified schedule before dropping the schedule. Any running jobs will be allowed to complete before the schedule is dropped. + +**Example** + +The following call to `DROP_SCHEDULE` drops a schedule named `weeknights_at_5`: + +```text +DBMS_SCHEDULER.DROP_SCHEDULE('weeknights_at_5', TRUE); +``` + +The server will disable any jobs that use the schedule before dropping the schedule. diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/15_dbms_scheduler/11_dbms_scheduler_enable.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/15_dbms_scheduler/11_dbms_scheduler_enable.mdx new file mode 100644 index 00000000000..71c15a3825c --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/15_dbms_scheduler/11_dbms_scheduler_enable.mdx @@ -0,0 +1,39 @@ +--- +title: "ENABLE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/dbms_scheduler_enable.html" +--- + + + +Use the `ENABLE` procedure to enable a disabled program or job. + +The signature of the `ENABLE` procedure is: + +```text +ENABLE( + IN VARCHAR2, + IN VARCHAR2 DEFAULT 'STOP_ON_FIRST_ERROR') +``` + +**Parameters** + +`name` + + `name` specifies the name of the program or job that is being enabled. + +`commit_semantics` + + `commit_semantics` instructs the server how to handle an error encountered while enabling a program or job. By default, `commit_semantics` is set to `STOP_ON_FIRST_ERROR`, instructing the server to stop when it encounters an error. + + The `TRANSACTIONAL` and `ABSORB_ERRORS` keywords are accepted for compatibility, and ignored. + +**Example** + +The following call to `DBMS_SCHEDULER.ENABLE` enables the `update_emp` program: + +```text +DBMS_SCHEDULER.ENABLE('update_emp'); +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/15_dbms_scheduler/12_evaluate_calendar_string.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/15_dbms_scheduler/12_evaluate_calendar_string.mdx new file mode 100644 index 00000000000..ffd2132e69d --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/15_dbms_scheduler/12_evaluate_calendar_string.mdx @@ -0,0 +1,63 @@ +--- +title: "EVALUATE_CALENDAR_STRING" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/evaluate_calendar_string.html" +--- + +Use the `EVALUATE_CALENDAR_STRING` procedure to evaluate the `repeat_interval` value specified when creating a schedule with the `CREATE_SCHEDULE` procedure. The `EVALUATE_CALENDAR_STRING` procedure will return the date and time that a specified schedule will execute without actually scheduling the job. + +The signature of the `EVALUATE_CALENDAR_STRING` procedure is: + +```text +EVALUATE_CALENDAR_STRING( + IN VARCHAR2, + IN TIMESTAMP WITH TIME ZONE, + IN TIMESTAMP WITH TIME ZONE, + OUT TIMESTAMP WITH TIME ZONE) +``` + +**Parameters** + +`calendar_string` + + `calendar_string` is the calendar string that describes a `repeat_interval` that is being evaluated. + +`start_date IN TIMESTAMP WITH TIME ZONE` + + `start_date` is the date and time after which the `repeat_interval` will become valid. + +`return_date_after` + + Use the `return_date_after` parameter to specify the date and time that `EVALUATE_CALENDAR_STRING` should use as a starting date when evaluating the `repeat_interval`. + + For example, if you specify a `return_date_after` value of `01-APR-13 09.00.00.000000, EVALUATE_CALENDAR_STRING` will return the date and time of the first iteration of the schedule after April 1st, 2013. + +`next_run_date OUT TIMESTAMP WITH TIME ZONE` + + `next_run_date` is an `OUT` parameter that will contain the first occurrence of the schedule after the date specified by the `return_date_after` parameter. + +**Example** + +The following example evaluates a calendar string and returns the first date and time that the schedule will be executed after June 15, 2013: + +```text +DECLARE + result TIMESTAMP; +BEGIN + + DBMS_SCHEDULER.EVALUATE_CALENDAR_STRING + ( + 'FREQ=DAILY;BYDAY=MON,TUE,WED,THU,FRI;BYHOUR=17;', + '15-JUN-2013', NULL, result + ); + + DBMS_OUTPUT.PUT_LINE('next_run_date: ' || result); +END; +/ + +next_run_date: 17-JUN-13 05.00.00.000000 PM +``` + +June 15, 2013 is a Saturday; the schedule will not execute until Monday, June 17, 2013 at 5:00 pm. diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/15_dbms_scheduler/13_run_job.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/15_dbms_scheduler/13_run_job.mdx new file mode 100644 index 00000000000..5e00845397e --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/15_dbms_scheduler/13_run_job.mdx @@ -0,0 +1,35 @@ +--- +title: "RUN_JOB" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/run_job.html" +--- + +Use the `RUN_JOB` procedure to execute a job immediately. The signature of the `RUN_JOB` procedure is: + +```text +RUN_JOB( + IN VARCHAR2, + IN BOOLEAN DEFAULT TRUE +``` + +**Parameters** + +`job_name` + + `job_name` specifies the name of the job that will execute. + +`use_current_session` + + By default, the job will execute in the current session. If specified, `use_current_session` must be set to `TRUE` ; if `use_current_session` is set to `FALSE`, Advanced Server will return an error. + +**Example** + +The following call to `RUN_JOB` executes a job named `update_log`: + +```text +DBMS_SCHEDULER.RUN_JOB('update_log', TRUE); +``` + +Passing a value of `TRUE` as the second argument instructs the server to invoke the job in the current session. diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/15_dbms_scheduler/14_set_job_argument_value.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/15_dbms_scheduler/14_set_job_argument_value.mdx new file mode 100644 index 00000000000..f3151869b7a --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/15_dbms_scheduler/14_set_job_argument_value.mdx @@ -0,0 +1,59 @@ +--- +title: "SET_JOB_ARGUMENT_VALUE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/set_job_argument_value.html" +--- + +Use the `SET_JOB_ARGUMENT_VALUE` procedure to specify a value for an argument. The `SET_JOB_ARGUMENT_VALUE` procedure comes in two forms; the first form specifies which argument should be modified by position: + +```text +SET_JOB_ARGUMENT_VALUE( + IN VARCHAR2, + IN PLS_INTEGER, + IN VARCHAR2) +``` + +The second form uses an argument name to specify which argument to modify: + +```text +SET_JOB_ARGUMENT_VALUE( + IN VARCHAR2, + IN VARCHAR2, + IN VARCHAR2) +``` + +Argument values set by the `SET_JOB_ARGUMENT_VALUE` procedure override any values set by default. + +**Parameters** + +`job_name` + + `job_name` specifies the name of the job to which the modified argument belongs. + +`argument_position` + + Use `argument_position` to specify the argument position for which the value will be set. + +`argument_name` + + Use `argument_name` to specify the argument by name for which the value will be set. + +`argument_value` + + `argument_value` specifies the new value of the argument. + +**Examples** + +The following example assigns a value of `30` to the first argument in the `update_emp` job: + +```text +DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE('update_emp', 1, '30'); +``` + +The following example sets the `emp_name` argument to `SMITH`: + +```text +DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE('update_emp', 'emp_name', 'SMITH'); +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/15_dbms_scheduler/index.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/15_dbms_scheduler/index.mdx new file mode 100644 index 00000000000..7c9a17bf0e5 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/15_dbms_scheduler/index.mdx @@ -0,0 +1,49 @@ +--- +title: "DBMS_SCHEDULER" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/dbms_scheduler.html" +--- + +The `DBMS_SCHEDULER` package provides a way to create and manage Oracle-styled jobs, programs and job schedules. The `DBMS_SCHEDULER` package implements the following functions and procedures: + +| Function/Procedure | Return Type | Description | +| ------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------- | +| `CREATE_JOB(job_name, job_type, job_action, number_of_arguments, start_date, repeat_interval, end_date, job_class, enabled, auto_drop, comments)` | n/a | Use the first form of the `CREATE_JOB` procedure to create a job, specifying program and schedule details by means of parameters. | +| `CREATE_JOB(job_name, program_name, schedule_name, job_class, enabled, auto_drop, comments)` | n/a | Use the second form of `CREATE_JOB` to create a job that uses a named program and named schedule. | +| `CREATE_PROGRAM(program_name, program_type, program_action, number_of_arguments, enabled, comments)` | n/a | Use `CREATE_PROGRAM` to create a program. | +| `CREATE_SCHEDULE(schedule_name, start_date, repeat_interval, end_date, comments)` | n/a | Use the `CREATE_SCHEDULE` procedure to create a schedule. | +| `DEFINE_PROGRAM_ARGUMENT(program_name, argument_position, argument_name, argument_type, default_value, out_argument)` | n/a | Use the first form of the `DEFINE_PROGRAM_ARGUMENT` procedure to define a program argument that has a default value. | +| `DEFINE_PROGRAM_ARGUMENT(program_name, argument_position, argument_name, argument_type, out_argument)` | n/a | Use the first form of the `DEFINE_PROGRAM_ARGUMENT` procedure to define a program argument that does not have a default value. | +| `DISABLE(name, force, commit_semantics)` | n/a | Use the `DISABLE` procedure to disable a job or program. | +| `DROP_JOB(job_name, force, defer, commit_semantics)` | n/a | Use the `DROP_JOB` procedure to drop a job. | +| `DROP_PROGRAM(program_name, force)` | n/a | Use the `DROP_PROGRAM` procedure to drop a program. | +| `DROP_PROGRAM_ARGUMENT(program_name, argument_position)` | n/a | Use the first form of `DROP_PROGRAM_ARGUMENT` to drop a program argument by specifying the argument position. | +| `DROP_PROGRAM_ARGUMENT(program_name, argument_name)` | n/a | Use the second form of `DROP_PROGRAM_ARGUMENT` to drop a program argument by specifying the argument name. | +| `DROP_SCHEDULE(schedule_name, force)` | n/a | Use the `DROP SCHEDULE` procedure to drop a schedule. | +| `ENABLE(name, commit_semantics)` | n/a | Use the `ENABLE` command to enable a program or job. | +| `EVALUATE_CALENDAR_STRING(calendar_string, start_date, return_date_after, next_run_date)` | n/a | Use `EVALUATE_CALENDAR_STRING` to review the execution date described by a user-defined calendar schedule. | +| `RUN_JOB(job_name, use_current_session, manually)` | n/a | Use the `RUN_JOB` procedure to execute a job immediately. | +| `SET_JOB_ARGUMENT_VALUE(job_name, argument_position, argument_value)` | n/a | Use the first form of `SET_JOB_ARGUMENT` value to set the value of a job argument described by the argument's position. | +| `SET_JOB_ARGUMENT_VALUE(job_name, argument_name, argument_value)` | n/a | Use the second form of `SET_JOB_ARGUMENT` value to set the value of a job argument described by the argument's name. | + +Advanced Server's implementation of `DBMS_SCHEDULER` is a partial implementation when compared to Oracle's version. Only those functions and procedures listed in the table above are supported. + +The `DBMS_SCHEDULER` package is dependent on the pgAgent service; you must have a pgAgent service installed and running on your server before using `DBMS_SCHEDULER`. + +Before using `DBMS_SCHEDULER`, a database superuser must create the catalog tables in which the `DBMS_SCHEDULER` programs, schedules and jobs are stored. Use the `psql` client to connect to the database, and invoke the command: + +```text +CREATE EXTENSION dbms_scheduler; +``` + +By default, the `dbms_scheduler` extension resides in the `contrib/dbms_scheduler_ext` subdirectory (under the Advanced Server installation). + +Note that after creating the `DBMS_SCHEDULER` tables, only a superuser will be able to perform a dump or reload of the database. + +
+ +using_calendar_syntax_to_specify_a_repeating_interval create_job create_program create_schedule define_program_argument dbms_scheduler_disable drop_job drop_program drop_program_argument drop_schedule dbms_scheduler_enable evaluate_calendar_string run_job set_job_argument_value + +
diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/16_dbms_session.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/16_dbms_session.mdx new file mode 100644 index 00000000000..d3bd0b4ca40 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/16_dbms_session.mdx @@ -0,0 +1,39 @@ +--- +title: "DBMS_SESSION" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/dbms_session.html" +--- + +Advanced Server provides support for the following `DBMS_SESSION.SET_ROLE` procedure: + +| Function/Procedure | Return Type | Description | +| -------------------- | ----------- | ------------------------------------------------------------------------------------- | +| `SET_ROLE(role_cmd)` | n/a | Executes a `SET ROLE` statement followed by the string value specified in `role_cmd`. | + +Advanced Server's implementation of `DBMS_SESSION` is a partial implementation when compared to Oracle's version. Only `DBMS_SESSION.SET_ROLE` is supported. + +## SET_ROLE + +The `SET_ROLE` procedure sets the current session user to the role specified in `role_cmd`. After invoking the `SET_ROLE` procedure, the current session will use the permissions assigned to the specified role. The signature of the procedure is: + +```text +SET_ROLE() +``` + +The `SET_ROLE` procedure appends the value specified for `role_cmd` to the `SET ROLE` statement, and then invokes the statement. + +**Parameters** + +`role_cmd` + + `role_cmd` specifies a role name in the form of a string value. + +**Example** + +The following call to the `SET_ROLE` procedure invokes the `SET ROLE` command to set the identity of the current session user to manager: + +```text +edb=# exec DBMS_SESSION.SET_ROLE('manager'); +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/01_bind_variable.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/01_bind_variable.mdx new file mode 100644 index 00000000000..624e43d670b --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/01_bind_variable.mdx @@ -0,0 +1,79 @@ +--- +title: "BIND_VARIABLE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/bind_variable.html" +--- + +The `BIND_VARIABLE` procedure provides the capability to associate a value with an `IN` or `IN OUT` bind variable in a SQL command. + +```text +BIND_VARIABLE( INTEGER, VARCHAR2, + { BLOB | CLOB | DATE | FLOAT | INTEGER | NUMBER | TIMESTAMP | VARCHAR2 } + [, INTEGER ]) +``` + +**Parameters** + +`c` + + Cursor ID of the cursor for the SQL command with bind variables. + +`name` + + Name of the bind variable in the SQL command. + +`value` + + Value to be assigned. + +`out_value_size` + + If `name` is an `IN OUT` variable, defines the maximum length of the output value. If not specified, the length of `value` is assumed. + +**Examples** + +The following anonymous block uses bind variables to insert a row into the `emp` table. + +```text +DECLARE + curid INTEGER; + v_sql VARCHAR2(150) := 'INSERT INTO emp VALUES ' || + '(:p_empno, :p_ename, :p_job, :p_mgr, ' || + ':p_hiredate, :p_sal, :p_comm, :p_deptno)'; + v_empno emp.empno%TYPE; + v_ename emp.ename%TYPE; + v_job emp.job%TYPE; + v_mgr emp.mgr%TYPE; + v_hiredate emp.hiredate%TYPE; + v_sal emp.sal%TYPE; + v_comm emp.comm%TYPE; + v_deptno emp.deptno%TYPE; + v_status INTEGER; +BEGIN + curid := DBMS_SQL.OPEN_CURSOR; + DBMS_SQL.PARSE(curid,v_sql,DBMS_SQL.native); + v_empno := 9001; + v_ename := 'JONES'; + v_job := 'SALESMAN'; + v_mgr := 7369; + v_hiredate := TO_DATE('13-DEC-07','DD-MON-YY'); + v_sal := 8500.00; + v_comm := 1500.00; + v_deptno := 40; + DBMS_SQL.BIND_VARIABLE(curid,':p_empno',v_empno); + DBMS_SQL.BIND_VARIABLE(curid,':p_ename',v_ename); + DBMS_SQL.BIND_VARIABLE(curid,':p_job',v_job); + DBMS_SQL.BIND_VARIABLE(curid,':p_mgr',v_mgr); + DBMS_SQL.BIND_VARIABLE(curid,':p_hiredate',v_hiredate); + DBMS_SQL.BIND_VARIABLE(curid,':p_sal',v_sal); + DBMS_SQL.BIND_VARIABLE(curid,':p_comm',v_comm); + DBMS_SQL.BIND_VARIABLE(curid,':p_deptno',v_deptno); + v_status := DBMS_SQL.EXECUTE(curid); + DBMS_OUTPUT.PUT_LINE('Number of rows processed: ' || v_status); + DBMS_SQL.CLOSE_CURSOR(curid); +END; + +Number of rows processed: 1 +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/02_bind_variable_char.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/02_bind_variable_char.mdx new file mode 100644 index 00000000000..29ee06e5dd7 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/02_bind_variable_char.mdx @@ -0,0 +1,32 @@ +--- +title: "BIND_VARIABLE_CHAR" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/bind_variable_char.html" +--- + +The `BIND_VARIABLE_CHAR` procedure provides the capability to associate a `CHAR` value with an `IN` or `IN OUT` bind variable in a SQL command. + +```text +BIND_VARIABLE_CHAR( INTEGER, VARCHAR2, CHAR + [, INTEGER ]) +``` + +**Parameters** + +`c` + + Cursor ID of the cursor for the SQL command with bind variables. + +`name` + + Name of the bind variable in the SQL command. + +`value` + + Value of type `CHAR` to be assigned. + +`out_value_size` + + If `name` is an `IN OUT` variable, defines the maximum length of the output value. If not specified, the length of `value` is assumed. diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/03_bind_variable_raw.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/03_bind_variable_raw.mdx new file mode 100644 index 00000000000..03b58486c96 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/03_bind_variable_raw.mdx @@ -0,0 +1,32 @@ +--- +title: "BIND_VARIABLE_RAW" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/bind_variable_raw.html" +--- + +The `BIND_VARIABLE_RAW` procedure provides the capability to associate a `RAW` value with an `IN` or `IN OUT` bind variable in a SQL command. + +```text +BIND_VARIABLE_RAW( INTEGER, VARCHAR2, RAW + [, INTEGER ]) +``` + +**Parameters** + +`c` + + Cursor ID of the cursor for the SQL command with bind variables. + +`name` + + Name of the bind variable in the SQL command. + +`value` + + Value of type `RAW` to be assigned. + +`out_value_size` + + If `name` is an `IN OUT` variable, defines the maximum length of the output value. If not specified, the length of `value` is assumed. diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/04_close_cursor.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/04_close_cursor.mdx new file mode 100644 index 00000000000..fb7feb134c2 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/04_close_cursor.mdx @@ -0,0 +1,35 @@ +--- +title: "CLOSE_CURSOR" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/close_cursor.html" +--- + +The `CLOSE_CURSOR` procedure closes an open cursor. The resources allocated to the cursor are released and it can no longer be used. + +```text +CLOSE_CURSOR( IN OUT INTEGER) +``` + +**Parameters** + +`c` + + Cursor ID of the cursor to be closed. + +**Examples** + +The following example closes a previously opened cursor: + +```text +DECLARE + curid INTEGER; +BEGIN + curid := DBMS_SQL.OPEN_CURSOR; + . + . + . + DBMS_SQL.CLOSE_CURSOR(curid); +END; +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/05_column_value.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/05_column_value.mdx new file mode 100644 index 00000000000..eca9c17e056 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/05_column_value.mdx @@ -0,0 +1,74 @@ +--- +title: "COLUMN_VALUE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/column_value.html" +--- + +The `COLUMN_VALUE` procedure defines a variable to receive a value from a cursor. + +```text +COLUMN_VALUE( INTEGER, INTEGER, OUT { BLOB | + CLOB | DATE | FLOAT | INTEGER | NUMBER | TIMESTAMP | VARCHAR2 } + [, OUT NUMBER [, OUT INTEGER ]]) +``` + +**Parameters** + +`c` + + Cursor id of the cursor returning data to the variable being defined. + +`position` + + Position within the cursor of the returned data. The first value in the cursor is position 1. + +`value` + + Variable receiving the data returned in the cursor by a prior fetch call. + +`column_error` + + Error number associated with the column, if any. + +`actual_length` + + Actual length of the data prior to any truncation. + +**Examples** + +The following example shows the portion of an anonymous block that receives the values from a cursor using the `COLUMN_VALUE` procedure. + +```text +DECLARE + curid INTEGER; + v_empno NUMBER(4); + v_ename VARCHAR2(10); + v_hiredate DATE; + v_sal NUMBER(7,2); + v_comm NUMBER(7,2); + v_sql VARCHAR2(50) := 'SELECT empno, ename, hiredate, sal, ' || + 'comm FROM emp'; + v_status INTEGER; +BEGIN + . + . + . + LOOP + v_status := DBMS_SQL.FETCH_ROWS(curid); + EXIT WHEN v_status = 0; + DBMS_SQL.COLUMN_VALUE(curid,1,v_empno); + DBMS_SQL.COLUMN_VALUE(curid,2,v_ename); + DBMS_SQL.COLUMN_VALUE(curid,3,v_hiredate); + DBMS_SQL.COLUMN_VALUE(curid,4,v_sal); + DBMS_SQL.COLUMN_VALUE(curid,4,v_sal); + DBMS_SQL.COLUMN_VALUE(curid,5,v_comm); + DBMS_OUTPUT.PUT_LINE(v_empno || ' ' || RPAD(v_ename,10) || ' ' || + TO_CHAR(v_hiredate,'yyyy-mm-dd') || ' ' || + TO_CHAR(v_sal,'9,999.99') || ' ' || + TO_CHAR(NVL(v_comm,0),'9,999.99')); + END LOOP; + DBMS_SQL.CLOSE_CURSOR(curid); +END; +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/06_column_value_char.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/06_column_value_char.mdx new file mode 100644 index 00000000000..45d646c68f0 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/06_column_value_char.mdx @@ -0,0 +1,36 @@ +--- +title: "COLUMN_VALUE_CHAR" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/column_value_char.html" +--- + +The `COLUMN_VALUE_CHAR` procedure defines a variable to receive a `CHAR` value from a cursor. + +```text +COLUMN_VALUE_CHAR( INTEGER, INTEGER, OUT CHAR + [, OUT NUMBER [, OUT INTEGER ]]) +``` + +**Parameters** + +`c` + + Cursor id of the cursor returning data to the variable being defined. + +`position` + + Position within the cursor of the returned data. The first value in the cursor is position 1. + +`value` + + Variable of data type `CHAR` receiving the data returned in the cursor by a prior fetch call. + +`column_error` + + Error number associated with the column, if any. + +`actual_length` + + Actual length of the data prior to any truncation. diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/07_column_value_raw.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/07_column_value_raw.mdx new file mode 100644 index 00000000000..90fcefa99b7 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/07_column_value_raw.mdx @@ -0,0 +1,37 @@ +--- +title: "COLUMN_VALUE_RAW" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/column_value_raw.html" +--- + +The `COLUMN_VALUE_RAW` procedure defines a variable to receive a `RAW` value from a cursor. + +```text +COLUMN_VALUE_RAW( INTEGER, INTEGER, OUT RAW + [, OUT NUMBER [, OUT INTEGER ]]) +``` + +**Parameters** + +`c` + + Cursor id of the cursor returning data to the variable being defined. + +`position` + + Position within the cursor of the returned data. The first value in the cursor is position 1. + +`value` + + Variable of data type `RAW` receiving the data returned in the cursor by a prior fetch call. + +`column_error` + + Error number associated with the column, if any. + +`actual_length` + + Actual length of the data prior to any truncation. + diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/08_define_column.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/08_define_column.mdx new file mode 100644 index 00000000000..cd005bbb71f --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/08_define_column.mdx @@ -0,0 +1,87 @@ +--- +title: "DEFINE_COLUMN" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/define_column.html" +--- + +The `DEFINE_COLUMN` procedure defines a column or expression in the `SELECT` list that is to be returned and retrieved in a cursor. + +```text +DEFINE_COLUMN( INTEGER, INTEGER, { BLOB | + CLOB | DATE | FLOAT | INTEGER | NUMBER | TIMESTAMP | VARCHAR2 } + [, INTEGER ]) +``` + +**Parameters** + +`c` + + Cursor id of the cursor associated with the `SELECT` command. + +`position` + + Position of the column or expression in the `SELECT` list that is being defined. + +`column` + + A variable that is of the same data type as the column or expression in position `position` of the `SELECT` list. + +`column_size` + + The maximum length of the returned data. `column_size` must be specified only if `column` is `VARCHAR2`. Returned data exceeding `column_size` is truncated to `column_size` characters. + +**Examples** + +The following shows how the `empno, ename, hiredate, sal`, and `comm` columns of the `emp` table are defined with the `DEFINE_COLUMN` procedure. + +```text +DECLARE + curid INTEGER; + v_empno NUMBER(4); + v_ename VARCHAR2(10); + v_hiredate DATE; + v_sal NUMBER(7,2); + v_comm NUMBER(7,2); + v_sql VARCHAR2(50) := 'SELECT empno, ename, hiredate, sal, ' || + 'comm FROM emp'; + v_status INTEGER; +BEGIN + curid := DBMS_SQL.OPEN_CURSOR; + DBMS_SQL.PARSE(curid,v_sql,DBMS_SQL.native); + DBMS_SQL.DEFINE_COLUMN(curid,1,v_empno); + DBMS_SQL.DEFINE_COLUMN(curid,2,v_ename,10); + DBMS_SQL.DEFINE_COLUMN(curid,3,v_hiredate); + DBMS_SQL.DEFINE_COLUMN(curid,4,v_sal); + DBMS_SQL.DEFINE_COLUMN(curid,5,v_comm); + . + . + . +END; +``` + +The following shows an alternative to the prior example that produces the exact same results. Note that the lengths of the data types are irrelevant – the `empno, sal`, and `comm` columns will still return data equivalent to `NUMBER(4)` and `NUMBER(7,2)`, respectively, even though `v_num` is defined as `NUMBER(1)` (assuming the declarations in the `COLUMN_VALUE` procedure are of the appropriate maximum sizes). The `ename` column will return data up to ten characters in length as defined by the `length` parameter in the `DEFINE_COLUMN` call, not by the data type declaration, `VARCHAR2(1)` declared for `v_varchar`. The actual size of the returned data is dictated by the `COLUMN_VALUE` procedure. + +```text +DECLARE + curid INTEGER; + v_num NUMBER(1); + v_varchar VARCHAR2(1); + v_date DATE; + v_sql VARCHAR2(50) := 'SELECT empno, ename, hiredate, sal, ' || + 'comm FROM emp'; + v_status INTEGER; +BEGIN + curid := DBMS_SQL.OPEN_CURSOR; + DBMS_SQL.PARSE(curid,v_sql,DBMS_SQL.native); + DBMS_SQL.DEFINE_COLUMN(curid,1,v_num); + DBMS_SQL.DEFINE_COLUMN(curid,2,v_varchar,10); + DBMS_SQL.DEFINE_COLUMN(curid,3,v_date); + DBMS_SQL.DEFINE_COLUMN(curid,4,v_num); + DBMS_SQL.DEFINE_COLUMN(curid,5,v_num); + . + . + . +END; +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/09_define_column_char.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/09_define_column_char.mdx new file mode 100644 index 00000000000..df66ccdc881 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/09_define_column_char.mdx @@ -0,0 +1,32 @@ +--- +title: "DEFINE_COLUMN_CHAR" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/define_column_char.html" +--- + +The `DEFINE_COLUMN_CHAR` procedure defines a `CHAR` column or expression in the `SELECT` list that is to be returned and retrieved in a cursor. + +```text +DEFINE_COLUMN_CHAR( INTEGER, INTEGER, +CHAR, INTEGER) +``` + +**Parameters** + +`c` + + Cursor id of the cursor associated with the `SELECT` command. + +`position` + + Position of the column or expression in the `SELECT` list that is being defined. + +`column` + + A `CHAR` variable. + +`column_size` + + The maximum length of the returned data. Returned data exceeding `column_size` is truncated to `column_size` characters. diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/10_define_column_raw.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/10_define_column_raw.mdx new file mode 100644 index 00000000000..5882316926a --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/10_define_column_raw.mdx @@ -0,0 +1,34 @@ +--- +title: "DEFINE_COLUMN_RAW" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/define_column_raw.html" +--- + +The `DEFINE_COLUMN_RAW` procedure defines a `RAW` column or expression in the `SELECT` list that is to be returned and retrieved in a cursor. + +```text +DEFINE_COLUMN_RAW( INTEGER, INTEGER, RAW, + INTEGER) +``` + +**Parameters** + +`c` + + Cursor id of the cursor associated with the `SELECT` command. + +`position` + + Position of the column or expression in the `SELECT` list that is being defined. + +`column` + + A `RAW` variable. + +`column_size` + + The maximum length of the returned data. Returned data exceeding `column_size` is truncated to `column_size` characters. + + diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/11_describe_columns.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/11_describe_columns.mdx new file mode 100644 index 00000000000..2497f5296d6 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/11_describe_columns.mdx @@ -0,0 +1,42 @@ +--- +title: "DESCRIBE_COLUMNS" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/describe_columns.html" +--- + +The `DESCRIBE_COLUMNS` procedure describes the columns returned by a cursor. + +```text +DESCRIBE_COLUMNS( INTEGER, OUT INTEGER, OUT + DESC_TAB); +``` + +**Parameters** + +`c` + + The cursor ID of the cursor. + +`col_cnt` + + The number of columns in cursor result set. + +`desc_tab` + + The table that contains a description of each column returned by the cursor. The descriptions are of type `DESC_REC`, and contain the following values: + +| Column Name | Type | +| --------------------- | --------------- | +| `col_type` | `INTEGER` | +| `col_max_len` | `INTEGER` | +| `col_name` | `VARCHAR2(128)` | +| `col_name_len` | `INTEGER` | +| `col_schema_name` | `VARCHAR2(128)` | +| `col_schema_name_len` | `INTEGER` | +| `col_precision` | `INTEGER` | +| `col_scale` | `INTEGER` | +| `col_charsetid` | `INTEGER` | +| `col_charsetform` | `INTEGER` | +| `col_null_ok` | `BOOLEAN` | diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/12_execute.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/12_execute.mdx new file mode 100644 index 00000000000..f61a096de6d --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/12_execute.mdx @@ -0,0 +1,42 @@ +--- +title: "EXECUTE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/execute.html" +--- + +The `EXECUTE` function executes a parsed SQL command or SPL block. + +```text + INTEGER EXECUTE( INTEGER) +``` + +**Parameters** + +`c` + + Cursor ID of the parsed SQL command or SPL block to be executed. + +`status` + + Number of rows processed if the SQL command was `DELETE, INSERT`, or `UPDATE`. `status` is meaningless for all other commands. + +**Examples** + +The following anonymous block inserts a row into the `dept` table. + +```text +DECLARE + curid INTEGER; + v_sql VARCHAR2(50); + v_status INTEGER; +BEGIN + curid := DBMS_SQL.OPEN_CURSOR; + v_sql := 'INSERT INTO dept VALUES (50, ''HR'', ''LOS ANGELES'')'; + DBMS_SQL.PARSE(curid, v_sql, DBMS_SQL.native); + v_status := DBMS_SQL.EXECUTE(curid); + DBMS_OUTPUT.PUT_LINE('Number of rows processed: ' || v_status); + DBMS_SQL.CLOSE_CURSOR(curid); +END; +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/13_execute_and_fetch.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/13_execute_and_fetch.mdx new file mode 100644 index 00000000000..a5ae0eb400a --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/13_execute_and_fetch.mdx @@ -0,0 +1,98 @@ +--- +title: "EXECUTE_AND_FETCH" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/execute_and_fetch.html" +--- + +Function `EXECUTE_AND_FETCH` executes a parsed `SELECT` command and fetches one row. + +```text + INTEGER EXECUTE_AND_FETCH( INTEGER [, BOOLEAN ]) +``` + +**Parameters** + +`c` + + Cursor id of the cursor for the `SELECT` command to be executed. + +`exact` + + If set to `TRUE`, an exception is thrown if the number of rows in the result set is not exactly equal to 1. If set to `FALSE`, no exception is thrown. The default is `FALSE`. A `NO_DATA_FOUND` exception is thrown if `exact` is `TRUE` and there are no rows in the result set. A `TOO_MANY_ROWS` exception is thrown if `exact` is `TRUE` and there is more than one row in the result set. + +`status` + + Returns 1 if a row was successfully fetched, 0 if no rows to fetch. If an exception is thrown, no value is returned. + +**Examples** + +The following stored procedure uses the `EXECUTE_AND_FETCH` function to retrieve one employee using the employee’s name. An exception will be thrown if the employee is not found, or there is more than one employee with the same name. + +```text +CREATE OR REPLACE PROCEDURE select_by_name( + p_ename emp.ename%TYPE +) +IS + curid INTEGER; + v_empno emp.empno%TYPE; + v_hiredate emp.hiredate%TYPE; + v_sal emp.sal%TYPE; + v_comm emp.comm%TYPE; + v_dname dept.dname%TYPE; + v_disp_date VARCHAR2(10); + v_sql VARCHAR2(120) := 'SELECT empno, hiredate, sal, ' || + 'NVL(comm, 0), dname ' || + 'FROM emp e, dept d ' || + 'WHERE ename = :p_ename ' || + 'AND e.deptno = d.deptno'; + v_status INTEGER; +BEGIN + curid := DBMS_SQL.OPEN_CURSOR; + DBMS_SQL.PARSE(curid,v_sql,DBMS_SQL.native); + DBMS_SQL.BIND_VARIABLE(curid,':p_ename',UPPER(p_ename)); + DBMS_SQL.DEFINE_COLUMN(curid,1,v_empno); + DBMS_SQL.DEFINE_COLUMN(curid,2,v_hiredate); + DBMS_SQL.DEFINE_COLUMN(curid,3,v_sal); + DBMS_SQL.DEFINE_COLUMN(curid,4,v_comm); + DBMS_SQL.DEFINE_COLUMN(curid,5,v_dname,14); + v_status := DBMS_SQL.EXECUTE_AND_FETCH(curid,TRUE); + DBMS_SQL.COLUMN_VALUE(curid,1,v_empno); + DBMS_SQL.COLUMN_VALUE(curid,2,v_hiredate); + DBMS_SQL.COLUMN_VALUE(curid,3,v_sal); + DBMS_SQL.COLUMN_VALUE(curid,4,v_comm); + DBMS_SQL.COLUMN_VALUE(curid,5,v_dname); + v_disp_date := TO_CHAR(v_hiredate, 'MM/DD/YYYY'); + DBMS_OUTPUT.PUT_LINE('Number : ' || v_empno); + DBMS_OUTPUT.PUT_LINE('Name : ' || UPPER(p_ename)); + DBMS_OUTPUT.PUT_LINE('Hire Date : ' || v_disp_date); + DBMS_OUTPUT.PUT_LINE('Salary : ' || v_sal); + DBMS_OUTPUT.PUT_LINE('Commission: ' || v_comm); + DBMS_OUTPUT.PUT_LINE('Department: ' || v_dname); + DBMS_SQL.CLOSE_CURSOR(curid); +EXCEPTION + WHEN NO_DATA_FOUND THEN + DBMS_OUTPUT.PUT_LINE('Employee ' || p_ename || ' not found'); + DBMS_SQL.CLOSE_CURSOR(curid); + WHEN TOO_MANY_ROWS THEN + DBMS_OUTPUT.PUT_LINE('Too many employees named, ' || + p_ename || ', found'); + DBMS_SQL.CLOSE_CURSOR(curid); + WHEN OTHERS THEN + DBMS_OUTPUT.PUT_LINE('The following is SQLERRM:'); + DBMS_OUTPUT.PUT_LINE(SQLERRM); + DBMS_OUTPUT.PUT_LINE('The following is SQLCODE:'); + DBMS_OUTPUT.PUT_LINE(SQLCODE); + DBMS_SQL.CLOSE_CURSOR(curid); +END; + +EXEC select_by_name('MARTIN') + +Number : 7654 +Name : MARTIN +Hire Date : 09/28/1981 +Salary : 1250 +Commission: 1400 +Department: SALES +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/14_fetch_rows.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/14_fetch_rows.mdx new file mode 100644 index 00000000000..ba50e238475 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/14_fetch_rows.mdx @@ -0,0 +1,86 @@ +--- +title: "FETCH_ROWS" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/fetch_rows.html" +--- + +The `FETCH_ROWS` function retrieves a row from a cursor. + +```text + INTEGER FETCH_ROWS( INTEGER) +``` + +**Parameters** + +`c` + + Cursor ID of the cursor from which to fetch a row. + +`status` + + Returns `1` if a row was successfully fetched, `0` if no more rows to fetch. + +**Examples** + +The following examples fetches the rows from the `emp` table and displays the results. + +```text +DECLARE + curid INTEGER; + v_empno NUMBER(4); + v_ename VARCHAR2(10); + v_hiredate DATE; + v_sal NUMBER(7,2); + v_comm NUMBER(7,2); + v_sql VARCHAR2(50) := 'SELECT empno, ename, hiredate, sal, ' || + 'comm FROM emp'; + v_status INTEGER; +BEGIN + curid := DBMS_SQL.OPEN_CURSOR; + DBMS_SQL.PARSE(curid,v_sql,DBMS_SQL.native); + DBMS_SQL.DEFINE_COLUMN(curid,1,v_empno); + DBMS_SQL.DEFINE_COLUMN(curid,2,v_ename,10); + DBMS_SQL.DEFINE_COLUMN(curid,3,v_hiredate); + DBMS_SQL.DEFINE_COLUMN(curid,4,v_sal); + DBMS_SQL.DEFINE_COLUMN(curid,5,v_comm); + + v_status := DBMS_SQL.EXECUTE(curid); + DBMS_OUTPUT.PUT_LINE('EMPNO ENAME HIREDATE SAL COMM'); + DBMS_OUTPUT.PUT_LINE('----- ---------- ---------- -------- ' || + '--------'); + LOOP + v_status := DBMS_SQL.FETCH_ROWS(curid); + EXIT WHEN v_status = 0; + DBMS_SQL.COLUMN_VALUE(curid,1,v_empno); + DBMS_SQL.COLUMN_VALUE(curid,2,v_ename); + DBMS_SQL.COLUMN_VALUE(curid,3,v_hiredate); + DBMS_SQL.COLUMN_VALUE(curid,4,v_sal); + DBMS_SQL.COLUMN_VALUE(curid,4,v_sal); + DBMS_SQL.COLUMN_VALUE(curid,5,v_comm); + DBMS_OUTPUT.PUT_LINE(v_empno || ' ' || RPAD(v_ename,10) || ' ' || + TO_CHAR(v_hiredate,'yyyy-mm-dd') || ' ' || + TO_CHAR(v_sal,'9,999.99') || ' ' || + TO_CHAR(NVL(v_comm,0),'9,999.99')); + END LOOP; + DBMS_SQL.CLOSE_CURSOR(curid); +END; + +EMPNO ENAME HIREDATE SAL COMM +----- ---------- ---------- -------- -------- +7369 SMITH 1980-12-17 800.00 .00 +7499 ALLEN 1981-02-20 1,600.00 300.00 +7521 WARD 1981-02-22 1,250.00 500.00 +7566 JONES 1981-04-02 2,975.00 .00 +7654 MARTIN 1981-09-28 1,250.00 1,400.00 +7698 BLAKE 1981-05-01 2,850.00 .00 +7782 CLARK 1981-06-09 2,450.00 .00 +7788 SCOTT 1987-04-19 3,000.00 .00 +7839 KING 1981-11-17 5,000.00 .00 +7844 TURNER 1981-09-08 1,500.00 .00 +7876 ADAMS 1987-05-23 1,100.00 .00 +7900 JAMES 1981-12-03 950.00 .00 +7902 FORD 1981-12-03 3,000.00 .00 +7934 MILLER 1982-01-23 1,300.00 .00 +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/15_is_open.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/15_is_open.mdx new file mode 100644 index 00000000000..a345784cda1 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/15_is_open.mdx @@ -0,0 +1,23 @@ +--- +title: "IS_OPEN" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/is_open.html" +--- + +The `IS_OPEN` function provides the capability to test if the given cursor is open. + +```text + BOOLEAN IS_OPEN( INTEGER) +``` + +**Parameters** + +`c` + + Cursor ID of the cursor to be tested. + +`status` + + Set to `TRUE` if the cursor is open, set to `FALSE` if the cursor is not open. diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/16_last_row_count.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/16_last_row_count.mdx new file mode 100644 index 00000000000..be85eb5de86 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/16_last_row_count.mdx @@ -0,0 +1,86 @@ +--- +title: "LAST_ROW_COUNT" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/last_row_count.html" +--- + +The `LAST_ROW_COUNT` function returns the number of rows that have been currently fetched. + +```text + INTEGER LAST_ROW_COUNT +``` + +**Parameters** + +`rowcnt` + + Number of row fetched thus far. + +**Examples** + +The following example uses the `LAST_ROW_COUNT` function to display the total number of rows fetched in the query. + +```text +DECLARE + curid INTEGER; + v_empno NUMBER(4); + v_ename VARCHAR2(10); + v_hiredate DATE; + v_sal NUMBER(7,2); + v_comm NUMBER(7,2); + v_sql VARCHAR2(50) := 'SELECT empno, ename, hiredate, sal, ' || + 'comm FROM emp'; + v_status INTEGER; +BEGIN + curid := DBMS_SQL.OPEN_CURSOR; + DBMS_SQL.PARSE(curid,v_sql,DBMS_SQL.native); + DBMS_SQL.DEFINE_COLUMN(curid,1,v_empno); + DBMS_SQL.DEFINE_COLUMN(curid,2,v_ename,10); + DBMS_SQL.DEFINE_COLUMN(curid,3,v_hiredate); + DBMS_SQL.DEFINE_COLUMN(curid,4,v_sal); + DBMS_SQL.DEFINE_COLUMN(curid,5,v_comm); + + v_status := DBMS_SQL.EXECUTE(curid); + DBMS_OUTPUT.PUT_LINE('EMPNO ENAME HIREDATE SAL COMM'); + DBMS_OUTPUT.PUT_LINE('----- ---------- ---------- -------- ' || + '--------'); + LOOP + v_status := DBMS_SQL.FETCH_ROWS(curid); + EXIT WHEN v_status = 0; + DBMS_SQL.COLUMN_VALUE(curid,1,v_empno); + DBMS_SQL.COLUMN_VALUE(curid,2,v_ename); + DBMS_SQL.COLUMN_VALUE(curid,3,v_hiredate); + DBMS_SQL.COLUMN_VALUE(curid,4,v_sal); + DBMS_SQL.COLUMN_VALUE(curid,4,v_sal); + DBMS_SQL.COLUMN_VALUE(curid,5,v_comm); + DBMS_OUTPUT.PUT_LINE(v_empno || ' ' || RPAD(v_ename,10) || ' ' || + TO_CHAR(v_hiredate,'yyyy-mm-dd') || ' ' || + TO_CHAR(v_sal,'9,999.99') || ' ' || + TO_CHAR(NVL(v_comm,0),'9,999.99')); + END LOOP; + DBMS_OUTPUT.PUT_LINE('Number of rows: ' || DBMS_SQL.LAST_ROW_COUNT); + DBMS_SQL.CLOSE_CURSOR(curid); +END; + +EMPNO ENAME HIREDATE SAL COMM +----- ---------- ---------- -------- -------- +7369 SMITH 1980-12-17 800.00 .00 +7499 ALLEN 1981-02-20 1,600.00 300.00 +7521 WARD 1981-02-22 1,250.00 500.00 +7566 JONES 1981-04-02 2,975.00 .00 +7654 MARTIN 1981-09-28 1,250.00 1,400.00 +7698 BLAKE 1981-05-01 2,850.00 .00 +7782 CLARK 1981-06-09 2,450.00 .00 +7788 SCOTT 1987-04-19 3,000.00 .00 +7839 KING 1981-11-17 5,000.00 .00 +7844 TURNER 1981-09-08 1,500.00 .00 +7876 ADAMS 1987-05-23 1,100.00 .00 +7900 JAMES 1981-12-03 950.00 .00 +7902 FORD 1981-12-03 3,000.00 .00 +7934 MILLER 1982-01-23 1,300.00 .00 +Number of rows: 14 +``` + + diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/17_open_cursor.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/17_open_cursor.mdx new file mode 100644 index 00000000000..e763dc58026 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/17_open_cursor.mdx @@ -0,0 +1,34 @@ +--- +title: "OPEN_CURSOR" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/open_cursor.html" +--- + +The `OPEN_CURSOR` function creates a new cursor. A cursor must be used to parse and execute any dynamic SQL statement. Once a cursor has been opened, it can be re-used with the same or different SQL statements. The cursor does not have to be closed and re-opened in order to be re-used. + +```text + INTEGER OPEN_CURSOR +``` + +**Parameters** + +`c` + + Cursor ID number associated with the newly created cursor. + +**Examples** + +The following example creates a new cursor: + +```text +DECLARE + curid INTEGER; +BEGIN + curid := DBMS_SQL.OPEN_CURSOR; + . + . + . +END; +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/18_parse.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/18_parse.mdx new file mode 100644 index 00000000000..84b004c4d1f --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/18_parse.mdx @@ -0,0 +1,85 @@ +--- +title: "PARSE" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/parse.html" +--- + +The `PARSE` procedure parses a SQL command or SPL block. If the SQL command is a DDL command, it is immediately executed and does not require running the `EXECUTE` function. + +```text +PARSE( INTEGER, VARCHAR2, INTEGER) +``` + +**Parameters** + +`c` + + Cursor ID of an open cursor. + +`statement` + + SQL command or SPL block to be parsed. A SQL command must not end with the semi-colon terminator, however an SPL block does require the semi-colon terminator. + +`language_flag` + + Language flag provided for compatibility with Oracle syntax. Use `DBMS_SQL.V6, DBMS_SQL.V7` or `DBMS_SQL.native`. This flag is ignored, and all syntax is assumed to be in EnterpriseDB Advanced Server form. + +**Examples** + +The following anonymous block creates a table named, `job`. Note that DDL statements are executed immediately by the `PARSE` procedure and do not require a separate `EXECUTE` step. + +```text +DECLARE + curid INTEGER; +BEGIN + curid := DBMS_SQL.OPEN_CURSOR; + DBMS_SQL.PARSE(curid, 'CREATE TABLE job (jobno NUMBER(3), ' || + 'jname VARCHAR2(9))',DBMS_SQL.native); + DBMS_SQL.CLOSE_CURSOR(curid); +END; +``` + +The following inserts two rows into the `job` table. + +```text +DECLARE + curid INTEGER; + v_sql VARCHAR2(50); + v_status INTEGER; +BEGIN + curid := DBMS_SQL.OPEN_CURSOR; + v_sql := 'INSERT INTO job VALUES (100, ''ANALYST'')'; + DBMS_SQL.PARSE(curid, v_sql, DBMS_SQL.native); + v_status := DBMS_SQL.EXECUTE(curid); + DBMS_OUTPUT.PUT_LINE('Number of rows processed: ' || v_status); + v_sql := 'INSERT INTO job VALUES (200, ''CLERK'')'; + DBMS_SQL.PARSE(curid, v_sql, DBMS_SQL.native); + v_status := DBMS_SQL.EXECUTE(curid); + DBMS_OUTPUT.PUT_LINE('Number of rows processed: ' || v_status); + DBMS_SQL.CLOSE_CURSOR(curid); +END; + +Number of rows processed: 1 +Number of rows processed: 1 +``` + +The following anonymous block uses the `DBMS_SQL` package to execute a block containing two `INSERT` statements. Note that the end of the block contains a terminating semi-colon, while in the prior example, each individual `INSERT` statement does not have a terminating semi-colon. + +```text +DECLARE + curid INTEGER; + v_sql VARCHAR2(100); + v_status INTEGER; +BEGIN + curid := DBMS_SQL.OPEN_CURSOR; + v_sql := 'BEGIN ' || + 'INSERT INTO job VALUES (300, ''MANAGER''); ' || + 'INSERT INTO job VALUES (400, ''SALESMAN''); ' || + 'END;'; + DBMS_SQL.PARSE(curid, v_sql, DBMS_SQL.native); + v_status := DBMS_SQL.EXECUTE(curid); + DBMS_SQL.CLOSE_CURSOR(curid); +END; +``` diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/index.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/index.mdx new file mode 100644 index 00000000000..67be14f4d83 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/17_dbms_sql/index.mdx @@ -0,0 +1,48 @@ +--- +title: "DBMS_SQL" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/dbms_sql.html" +--- + +The `DBMS_SQL` package provides an application interface compatible with Oracle databases to the EnterpriseDB dynamic SQL functionality. With `DBMS_SQL` you can construct queries and other commands at run time (rather than when you write the application). EnterpriseDB Advanced Server offers native support for dynamic SQL; `DBMS_SQL` provides a way to use dynamic SQL in a fashion compatible with Oracle databases without modifying your application. + +`DBMS_SQL` assumes the privileges of the current user when executing dynamic SQL statements. + +| Function/Procedure | Function or Procedure | Return Type | Description | +| --------------------------------------------------------------------------------------- | --------------------- | ----------- | ---------------------------------------------------------------------- | +| `BIND_VARIABLE(c, name, value [, out_value_size ])` | Procedure | n/a | Bind a value to a variable. | +| `BIND_VARIABLE_CHAR(c, name, value [, out_value_size ])` | Procedure | n/a | Bind a `CHAR` value to a variable. | +| `BIND_VARIABLE_RAW(c, name, value [, out_value_size ])` | Procedure | n/a | Bind a `RAW` value to a variable. | +| `CLOSE_CURSOR(c IN OUT)` | Procedure | n/a | Close a cursor. | +| `COLUMN_VALUE(c, position, value OUT [, column_error OUT [, actual_length OUT ]])` | Procedure | n/a | Return a column value into a variable. | +| `COLUMN_VALUE_CHAR(c, position, value OUT [, column_error OUT [, actual_length OUT ]])` | Procedure | n/a | Return a `CHAR` column value into a variable. | +| `COLUMN_VALUE_RAW(c, position, value OUT [, column_error OUT [, actual_length OUT ]])` | Procedure | n/a | Return a `RAW` column value into a variable. | +| `DEFINE_COLUMN(c, position, column [, column_size ])` | Procedure | n/a | Define a column in the `SELECT` list. | +| `DEFINE_COLUMN_CHAR(c, position, column, column_size)` | Procedure | n/a | Define a `CHAR` column in the `SELECT` list. | +| `DEFINE_COLUMN_RAW(c, position, column, column_size)` | Procedure | n/a | Define a `RAW` column in the `SELECT` list. | +| `DESCRIBE_COLUMNS` | Procedure | n/a | Defines columns to hold a cursor result set. | +| `EXECUTE(c)` | Function | `INTEGER` | Execute a cursor. | +| `EXECUTE_AND_FETCH(c [, exact ])` | Function | `INTEGER` | Execute a cursor and fetch a single row. | +| `FETCH_ROWS(c)` | Function | `INTEGER` | Fetch rows from the cursor. | +| `IS_OPEN(c)` | Function | `BOOLEAN` | Check if a cursor is open. | +| `LAST_ROW_COUNT` | Function | `INTEGER` | Return cumulative number of rows fetched. | +| `OPEN_CURSOR` | Function | `INTEGER` | Open a cursor. | +| `PARSE(c, statement, language_flag)` | Procedure | n/a | Parse a statement. | + +Advanced Server's implementation of `DBMS_SQL` is a partial implementation when compared to Oracle's version. Only those functions and procedures listed in the table above are supported. + +The following table lists the public variable available in the `DBMS_SQL` package. + +| Public Variables | Data Type | Value | Description | +| ---------------- | --------- | ----- | ----------------------------------------------------------------------------------------- | +| `native` | `INTEGER` | `1` | Provided for compatibility with Oracle syntax. See `DBMS_SQL.PARSE` for more information. | +| `V6` | `INTEGER` | `2` | Provided for compatibility with Oracle syntax. See `DBMS_SQL.PARSE` for more information. | +| `V7` | `INTEGER` | `3` | Provided for compatibility with Oracle syntax. See `DBMS_SQL.PARSE` for more information | + +
+ +bind_variable bind_variable_char bind_variable_raw close_cursor column_value column_value_char column_value_raw define_column define_column_char define_column_raw describe_columns execute execute_and_fetch fetch_rows is_open last_row_count open_cursor parse + +
diff --git a/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/18_dbms_utility.mdx b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/18_dbms_utility.mdx new file mode 100644 index 00000000000..0c89d7f24a6 --- /dev/null +++ b/product_docs/docs/epas/12/epas_compat_bip_guide/03_built-in_packages/18_dbms_utility.mdx @@ -0,0 +1,783 @@ +--- +title: "DBMS_UTILITY" + +legacyRedirectsGenerated: + # This list is generated by a script. If you need add entries, use the `legacyRedirects` key. + - "/edb-docs/d/edb-postgres-advanced-server/reference/database-compatibility-for-oracle-developers-built-in-package-guide/13/dbms_utility.html" +--- + +The `DBMS_UTILITY` package provides support for the following various utility programs: + +| Function/Procedure | Function or Procedure | Return Type | Description | +| -------------------------------------------------------------------------------------------------------------- | --------------------- | ---------------- | ------------------------------------------------------------ | +| `ANALYZE_DATABASE(method [, estimate_rows [, estimate_percent [, method_opt ]]])` | Procedure | n/a | Analyze database tables. | +| `ANALYZE_PART_OBJECT(schema, object_name [, object_type [, command_type [, command_opt [, sample_clause ]]]])` | Procedure | n/a | Analyze a partitioned table. | +| `ANALYZE_SCHEMA(schema, method [, estimate_rows [, estimate_percent [, method_opt ]]])` | Procedure | n/a | Analyze schema tables. | +| `CANONICALIZE(name, canon_name OUT, canon_len)` | Procedure | n/a | Canonicalizes a string – e.g., strips off white space. | +| `COMMA_TO_TABLE(list, tablen OUT, tab OUT)` | Procedure | n/a | Convert a comma-delimited list of names to a table of names. | +| `DB_VERSION(version OUT, compatibility OUT)` | Procedure | n/a | Get the database version. | +| `EXEC_DDL_STATEMENT (parse_string)` | Procedure | n/a | Execute a DDL statement. | +| `FORMAT_CALL_STACK` | Function | `TEXT` | Formats the current call stack. | +| `GET_CPU_TIME` | Function | `NUMBER` | Get the current CPU time. | +| `GET_DEPENDENCY(type, schema, name)` | Procedure | n/a | Get objects that are dependent upon the given object.. | +| `GET_HASH_VALUE(name, base, hash_size)` | Function | `NUMBER` | Compute a hash value. | +| `GET_PARAMETER_VALUE(parnam, intval OUT, strval OUT)` | Procedure | `BINARY_INTEGER` | Get database initialization parameter settings. | +| `GET_TIME` | Function | `NUMBER` | Get the current time. | +| `NAME_TOKENIZE(name, a OUT, b OUT, c OUT, dblink OUT, nextpos OUT)` | Procedure | n/a | Parse the given name into its component parts. | +| `TABLE_TO_COMMA(tab, tablen OUT, list OUT)` | Procedure | n/a | Convert a table of names to a comma-delimited list. | + +Advanced Server's implementation of `DBMS_UTILITY` is a partial implementation when compared to Oracle's version. Only those functions and procedures listed in the table above are supported. + +The following table lists the public variables available in the `DBMS_UTILITY` package. + +| Public Variables | Data Type | Value | Description | +| --------------------------- | ------------- | ----- | ----------------------------------- | +| `inv_error_on_restrictions` | `PLS_INTEGER` | `1` | Used by the `INVALIDATE` procedure. | +| `lname_array` | `TABLE` | | For lists of long names. | +| `uncl_array` | `TABLE` | | For lists of users and names. | + + + +## LNAME_ARRAY + +The `LNAME_ARRAY` is for storing lists of long names including fully-qualified names. + +```text +TYPE lname_array IS `TABLE OF VARCHAR2(4000) INDEX BY BINARY_INTEGER; +``` + + + +## UNCL_ARRAY + +The `UNCL_ARRAY` is for storing lists of users and names. + +```text +TYPE uncl_array IS TABLE OF VARCHAR2(227) INDEX BY BINARY_INTEGER; +``` + +## ANALYZE_DATABASE, ANALYZE SCHEMA and ANALYZE PART_OBJECT + +The `ANALYZE_DATABASE(), ANALYZE_SCHEMA() and ANALYZE_PART_OBJECT()` procedures provide the capability to gather statistics on tables in the database. When you execute the `ANALYZE` statement, Postgres samples the data in a table and records distribution statistics in the `pg_statistics system` table. + +`ANALYZE_DATABASE, ANALYZE_SCHEMA`, and `ANALYZE_PART_OBJECT` differ primarily in the number of tables that are processed: + +- `ANALYZE_DATABASE` analyzes all tables in all schemas within the current database. +- `ANALYZE_SCHEMA` analyzes all tables in a given schema (within the current database). +- `ANALYZE_PART_OBJECT` analyzes a single table. + +The syntax for the `ANALYZE` commands are: + +```text +ANALYZE_DATABASE( VARCHAR2 [, NUMBER + [, NUMBER [, VARCHAR2 ]]]) + +ANALYZE_SCHEMA( VARCHAR2, VARCHAR2 + [, NUMBER [, NUMBER + [, VARCHAR2 ]]]) + +ANALYZE_PART_OBJECT( VARCHAR2, VARCHAR2 + [, CHAR [, CHAR + [, VARCHAR2 [, ]]]]) +``` + +**Parameters** - `ANALYZE_DATABASE` and `ANALYZE_SCHEMA` + +`method` + + method determines whether the `ANALYZE` procedure populates the `pg_statistics` table or removes entries from the `pg_statistics` table. If you specify a method of `DELETE`, the `ANALYZE` procedure removes the relevant rows from `pg_statistics`. If you specify a method of `COMPUTE` or `ESTIMATE`, the `ANALYZE` procedure analyzes a table (or multiple tables) and records the distribution information in `pg_statistics`. There is no difference between `COMPUTE` and `ESTIMATE`; both methods execute the Postgres `ANALYZE` statement. All other parameters are validated and then ignored. + +`estimate_rows` + + Number of rows upon which to base estimated statistics. One of `estimate_rows` or `estimate_percent` must be specified if method is `ESTIMATE`. + + This argument is ignored, but is included for compatibility. + +`estimate_percent` + + Percentage of rows upon which to base estimated statistics. One of `estimate_rows` or `estimate_percent` must be specified if method is `ESTIMATE`. + + This argument is ignored, but is included for compatibility. + +`method_opt` + + Object types to be analyzed. Any combination of the following: + +``` +[ FOR TABLE ] + +[ FOR ALL [ INDEXED ] COLUMNS ] [ SIZE n ] + +[ FOR ALL INDEXES ] +``` + + This argument is ignored, but is included for compatibility. + +**Parameters** - `ANALYZE_PART_OBJECT` + +`schema` + + Name of the schema whose objects are to be analyzed. + +`object_name` + + Name of the partitioned object to be analyzed. + +`object_type` + + Type of object to be analyzed. Valid values are: `T` – table, `I` – index. + + This argument is ignored, but is included for compatibility. + +`command_type` + + Type of analyze functionality to perform. Valid values are: `E` - gather estimated statistics based upon on a specified number of rows or a percentage of rows in the `sample_clause` clause; `C` - compute exact statistics; or `V` – validate the structure and integrity of the partitions. + + This argument is ignored, but is included for compatibility. + +`command_opt` + + For `command_type` `C` or `E`, can be any combination of: + +``` +[ FOR TABLE ] + +[ FOR ALL COLUMNS ] + +[ FOR ALL LOCAL INDEXES ] +``` + + For `command_type V`, can be `CASCADE` if `object_type` is `T`. + + This argument is ignored, but is included for compatibility. + +`sample_clause` + + If `command_type` is `E`, contains the following clause to specify the number of rows or percentage or rows on which to base the estimate. + + `SAMPLE n { ROWS | PERCENT }` + + This argument is ignored, but is included for compatibility. + +## CANONICALIZE + +The `CANONICALIZE` procedure performs the following operations on an input string: + +- If the string is not double-quoted, verifies that it uses the characters of a legal identifier. If not, an exception is thrown. If the string is double-quoted, all characters are allowed. +- If the string is not double-quoted and does not contain periods, uppercases all alphabetic characters and eliminates leading and trailing spaces. +- If the string is double-quoted and does not contain periods, strips off the double quotes. +- If the string contains periods and no portion of the string is double-quoted, uppercases each portion of the string and encloses each portion in double quotes. +- If the string contains periods and portions of the string are double-quoted, returns the double-quoted portions unchanged including the double quotes and returns the non-double-quoted portions uppercased and enclosed in double quotes. + +```text +CANONICALIZE( VARCHAR2, OUT VARCHAR2, + BINARY_INTEGER) +``` + +**Parameters** + +`name` + + String to be canonicalized. + +`canon_name` + + The canonicalized string. + +`canon_len` + + Number of bytes in `name` to canonicalize starting from the first character. + +**Examples** + +The following procedure applies the `CANONICALIZE` procedure on its input parameter and displays the results. + +```text +CREATE OR REPLACE PROCEDURE canonicalize ( + p_name VARCHAR2, + p_length BINARY_INTEGER DEFAULT 30 +) +IS + v_canon VARCHAR2(100); +BEGIN + DBMS_UTILITY.CANONICALIZE(p_name,v_canon,p_length); + DBMS_OUTPUT.PUT_LINE('Canonicalized name ==>' || v_canon || '<=='); + DBMS_OUTPUT.PUT_LINE('Length: ' || LENGTH(v_canon)); +EXCEPTION + WHEN OTHERS THEN + DBMS_OUTPUT.PUT_LINE('SQLERRM: ' || SQLERRM); + DBMS_OUTPUT.PUT_LINE('SQLCODE: ' || SQLCODE); +END; + +EXEC canonicalize('Identifier') +Canonicalized name ==>IDENTIFIER<== +Length: 10 + +EXEC canonicalize('"Identifier"') +Canonicalized name ==>Identifier<== +Length: 10 + +EXEC canonicalize('"_+142%"') +Canonicalized name ==>_+142%<== +Length: 6 + +EXEC canonicalize('abc.def.ghi') +Canonicalized name ==>"ABC"."DEF"."GHI"<== +Length: 17 + +EXEC canonicalize('"abc.def.ghi"') +Canonicalized name ==>abc.def.ghi<== +Length: 11 + +EXEC canonicalize('"abc".def."ghi"') +Canonicalized name ==>"abc"."DEF"."ghi"<== +Length: 17 + +EXEC canonicalize('"abc.def".ghi') +Canonicalized name ==>"abc.def"."GHI"<== +Length: 15 +``` + +## COMMA_TO_TABLE + +The `COMMA_TO_TABLE` procedure converts a comma-delimited list of names into a table of names. Each entry in the list becomes a table entry. The names must be formatted as valid identifiers. + +```text +COMMA_TO_TABLE( VARCHAR2, OUT BINARY_INTEGER, + OUT { LNAME_ARRAY | UNCL_ARRAY }) +``` + +**Parameters** + +`list` + + Comma-delimited list of names. + +`tablen` + + Number of entries in `tab`. + +`tab` + + Table containing the individual names in `list`. + +`LNAME_ARRAY` + + A `DBMS_UTILITY LNAME_ARRAY` (as described in the [LNAME_ARRAY](#lname_array) section). + +`UNCL_ARRAY` + + A `DBMS_UTILITY UNCL_ARRAY` (as described in the [UNCL_ARRAY](#uncl_array) section). + +**Examples** + +The following procedure uses the `COMMA_TO_TABLE` procedure to convert a list of names to a table. The table entries are then displayed. + +```text +CREATE OR REPLACE PROCEDURE comma_to_table ( + p_list VARCHAR2 +) +IS + r_lname DBMS_UTILITY.LNAME_ARRAY; + v_length BINARY_INTEGER; +BEGIN + DBMS_UTILITY.COMMA_TO_TABLE(p_list,v_length,r_lname); + FOR i IN 1..v_length LOOP + DBMS_OUTPUT.PUT_LINE(r_lname(i)); + END LOOP; +END; + +EXEC comma_to_table('edb.dept, edb.emp, edb.jobhist') + +edb.dept +edb.emp +edb.jobhist +``` + +## DB_VERSION + +The `DB_VERSION` procedure returns the version number of the database. + +```text +DB_VERSION( OUT VARCHAR2, OUT VARCHAR2) +``` + +**Parameters** + +`version` + + Database version number. + +`compatibility` + + Compatibility setting of the database. (To be implementation-defined as to its meaning.) + +**Examples** + +The following anonymous block displays the database version information. + +```text +DECLARE + v_version VARCHAR2(150); + v_compat VARCHAR2(150); +BEGIN + DBMS_UTILITY.DB_VERSION(v_version,v_compat); + DBMS_OUTPUT.PUT_LINE('Version: ' || v_version); + DBMS_OUTPUT.PUT_LINE('Compatibility: ' || v_compat); +END; + +Version: EnterpriseDB 12.0.0 on i686-pc-linux-gnu, compiled by GCC gcc +(GCC) 4.1.2 20080704 (Red Hat 4.1.2-48), 32-bit +Compatibility: EnterpriseDB 12.0.0 on i686-pc-linux-gnu, compiled by GCC +gcc (GCC) 4.1.220080704 (Red Hat 4.1.2-48), 32-bit +``` + +## EXEC_DDL_STATEMENT + +The `EXEC_DDL_STATEMENT` provides the capability to execute a `DDL` command. + +```text +EXEC_DDL_STATEMENT( VARCHAR2) +``` + +**Parameters** + +`parse_string` + + The DDL command to be executed. + +**Examples** + +The following anonymous block creates the `job` table. + +```text +BEGIN + DBMS_UTILITY.EXEC_DDL_STATEMENT( + 'CREATE TABLE job (' || + 'jobno NUMBER(3),' || + 'jname VARCHAR2(9))' + ); +END; +``` + +If the `parse_string` does not include a valid DDL statement, Advanced Server returns the following error: + +```text +edb=#  exec dbms_utility.exec_ddl_statement('select rownum from dual'); +ERROR:  EDB-20001: 'parse_string' must be a valid DDL statement +``` + +In this case, Advanced Server's behavior differs from Oracle's; Oracle accepts the invalid `parse_string` without complaint. + +## FORMAT_CALL_STACK + +The `FORMAT_CALL_STACK` function returns the formatted contents of the current call stack. + +```text +DBMS_UTILITY.FORMAT_CALL_STACK +return VARCHAR2 +``` + +This function can be used in a stored procedure, function or package to return the current call stack in a readable format. This function is useful for debugging purposes. + +## GET_CPU_TIME + +The `GET_CPU_TIME` function returns the CPU time in hundredths of a second from some arbitrary point in time. + +```text + NUMBER GET_CPU_TIME +``` + +**Parameters** + +`cputime` + + Number of hundredths of a second of CPU time. + +**Examples** + +The following `SELECT` command retrieves the current CPU time, which is 603 hundredths of a second or .0603 seconds. + +```text +SELECT DBMS_UTILITY.GET_CPU_TIME FROM DUAL; + +get_cpu_time +-------------- + 603 +``` + +## GET_DEPENDENCY + +The `GET_DEPENDENCY` procedure provides the capability to list the objects that are dependent upon the specified object. `GET_DEPENDENCY` does not show dependencies for functions or procedures. + +```text +GET_DEPENDENCY( VARCHAR2, VARCHAR2, + VARCHAR2) +``` + +**Parameters** + +`type` + + The object type of `name`. Valid values are `INDEX, PACKAGE, PACKAGE BODY, SEQUENCE, TABLE, TRIGGER, TYPE` and `VIEW`. + +`schema` + + Name of the schema in which `name` exists. + +`name` + + Name of the object for which dependencies are to be obtained. + +**Examples** + +The following anonymous block finds dependencies on the `EMP` table. + +```text +BEGIN + DBMS_UTILITY.GET_DEPENDENCY('TABLE','public','EMP'); +END; + +DEPENDENCIES ON public.EMP +------------------------------------------------------------------ +*TABLE public.EMP() +* CONSTRAINT c public.emp() +* CONSTRAINT f public.emp() +* CONSTRAINT p public.emp() +* TYPE public.emp() +* CONSTRAINT c public.emp() +* CONSTRAINT f public.jobhist() +* VIEW .empname_view() +``` + +## GET_HASH_VALUE + +The `GET_HASH_VALUE` function provides the capability to compute a hash value for a given string. + +```text + NUMBER GET_HASH_VALUE( VARCHAR2, NUMBER, + NUMBER) +``` + +**Parameters** + +`name` + + The string for which a hash value is to be computed. + +`base` + + Starting value at which hash values are to be generated. + +`hash_size` + + The number of hash values for the desired hash table. + +`hash` + + The generated hash value. + +**Examples** + +The following anonymous block creates a table of hash values using the `ename` column of the `emp` table and then displays the key along with the hash value. The hash values start at 100 with a maximum of 1024 distinct values. + +```text +DECLARE + v_hash NUMBER; + TYPE hash_tab IS TABLE OF NUMBER INDEX BY VARCHAR2(10); + r_hash HASH_TAB; + CURSOR emp_cur IS SELECT ename FROM emp; +BEGIN + FOR r_emp IN emp_cur LOOP + r_hash(r_emp.ename) := + DBMS_UTILITY.GET_HASH_VALUE(r_emp.ename,100,1024); + END LOOP; + FOR r_emp IN emp_cur LOOP + DBMS_OUTPUT.PUT_LINE(RPAD(r_emp.ename,10) || ' ' || + r_hash(r_emp.ename)); + END LOOP; +END; + +SMITH 377 +ALLEN 740 +WARD 718 +JONES 131 +MARTIN 176 +BLAKE 568 +CLARK 621 +SCOTT 1097 +KING 235 +TURNER 850 +ADAMS 156 +JAMES 942 +FORD 775 +MILLER 148 +``` + +## GET_PARAMETER_VALUE + +The `GET_PARAMETER_VALUE` procedure provides the capability to retrieve database initialization parameter settings. + +```text + BINARY_INTEGER GET_PARAMETER_VALUE( VARCHAR2, + OUT INTEGER, OUT VARCHAR2) +``` + +**Parameters** + +`parnam` + + Name of the parameter whose value is to be returned. The parameters are listed in the `pg_settings` system view. + +`intval` + + Value of an integer parameter or the length of `strval`. + +`strval` + + Value of a string parameter. + +`status` + + Returns 0 if the parameter value is `INTEGER` or `BOOLEAN`. Returns 1 if the parameter value is a string. + +**Examples** + +The following anonymous block shows the values of two initialization parameters. + +```text +DECLARE + v_intval INTEGER; + v_strval VARCHAR2(80); +BEGIN + DBMS_UTILITY.GET_PARAMETER_VALUE('max_fsm_pages', v_intval, v_strval); + DBMS_OUTPUT.PUT_LINE('max_fsm_pages' || ': ' || v_intval); + DBMS_UTILITY.GET_PARAMETER_VALUE('client_encoding', v_intval, v_strval); + DBMS_OUTPUT.PUT_LINE('client_encoding' || ': ' || v_strval); +END; + +max_fsm_pages: 72625 +client_encoding: SQL_ASCII +``` + +## GET_TIME + +The `GET_TIME` function provides the capability to return the current time in hundredths of a second. + +```text +
...
) + // - a table wrapped in
+ let table = null; + for (let node of root.children) + { + if (node.type === 'text' && !node.value.trim()) continue; + if (node.tagName === 'table') + table = node; + else if (node.tagName === 'div' && node?.properties?.className?.includes('table-with-scroll')) + table = getTable(node); + else + { + table = null; + break; + } + } + + return table; +} + +function convertTable(hastTable) +{ + // fail if any colspan or rowspan + let convertible = true; + visit(hastTable, node => { + if (node.properties && (node.properties.colSpan || node.properties.rowSpan)) + convertible = false; + }); + if (!convertible) return null; + + const options = { + handlers: { + br: (h, node) => { + return {type: 'jsx', value: '
'}; + }, + }, + }; + + // this does all the heavy lifting + mdast = hast2mdast(hastTable, options); + const br = {type: 'jsx', value: '
'}; + visit(mdast, function(node, index, parent) + { + // strip blockquotes; can't support those + if (is(node, 'blockquote')) + { + parent.children.splice(index, 1, br, ...node.children); + } + // we kinda need paragraphs in cells; simulate with linebreak elements + if (is(node, 'paragraph')) + { + let replace = index > 0 + ? [br, br, ...node.children] + : node.children; + if (index === parent.children.length-1) + replace.push(br); + parent.children.splice(index, 1, ...replace); + } + }); + + return mdast; +} + +module.exports = tableFormatter; diff --git a/scripts/normalize/markdown.js b/scripts/normalize/markdown.js new file mode 100644 index 00000000000..2b028413caa --- /dev/null +++ b/scripts/normalize/markdown.js @@ -0,0 +1,97 @@ +// run: node scripts/normalize/markdown.js "product_docs/**/*.mdx" +// purpose: +// read in mdx files, parse them, stringify them, write them back out again +// optionally, do some other stuff to the AST in between parsing and stringifying. +// +const {read, write} = require('to-vfile') +const remarkParse = require('@mdx-js/mdx/node_modules/remark-parse') +const mdx = require('remark-mdx') +const unified = require('@mdx-js/mdx/node_modules/unified') +const remarkFrontmatter = require('remark-frontmatter') +const glob = require('fast-glob') +const remarkMdxEmbeddedHast = require('./lib/mast-embedded-hast') +const {linkTargetIndexer, relativeLinkRewriter, index} = require('./lib/relativelinks') +const remarkStringify = require('remark-stringify') +const noEscapeImageAlt = require('./lib/no-escape-image-alt') +//const stripImageAlt = require('./lib/strip-image-alt') +const tableFormatter = require('./lib/table-formatter') +const {docs1LinkRewriter, linkStats} = require('./lib/docs1-link-rewriter') +const noteRewriter = require('./lib/note-rewriter.js') +const codeInTables = require('../../src/plugins/code-in-tables.js') +const admonitions = require('remark-admonitions') + +;(async () => { + + if (!process.argv[2]) + { + console.log(`usage: + ${process.argv[1]} [glob pattern rewrite] + + (if no rewrite pattern is given, all indexed files will be rewritten) +example: + ${process.argv[1]} "product_docs/**/*.mdx" product_docs/docs/pem/8.0/index.mdx`); + return; + } + + const parser = unified() + .use(remarkParse) + .use(admonitions, { tag: '!!!', icons: 'none', infima: true }) + .use(mdx) + .use(remarkFrontmatter) + const indexing = unified() + .use(remarkMdxEmbeddedHast) + .use(linkTargetIndexer) + .use(codeInTables) + const transformer = unified() + .use(remarkMdxEmbeddedHast) + .use(noteRewriter) + .use(relativeLinkRewriter) + .use(tableFormatter) + .use(codeInTables) + .use(docs1LinkRewriter) +// .use(stripImageAlt) + const compiler = unified() + .use(remarkParse) + .use(remarkStringify, {emphasis: '*', bullet: '-', fences: true}) + .use(mdx) + .use(remarkFrontmatter) + .use(remarkMdxEmbeddedHast) + .use(admonitions, { tag: '!!!', icons: 'none', infima: true }) + .use(noteRewriter) + .use(codeInTables) + .use(noEscapeImageAlt) + + const mdxesToIndex = await glob(process.argv[2]); + const mdxesToWrite = (process.argv[3] && await glob(process.argv[3])) || mdxesToIndex; + + // indexing + for (const mdxPath of mdxesToIndex) + { + const file = await read(mdxPath); + const ast = await parser.parse(file); + await indexing.run(ast, file); + } + + // analysis / rewriting + for (const mdxPath of mdxesToWrite) + { + const file = await read(mdxPath); + let ast = await parser.parse(file); + ast = await transformer.run(ast, file); + const normalized = await compiler.stringify(ast); + + if (normalized !== file.contents.toString()) + { + console.log("writing: " + mdxPath) + await write({ + path: mdxPath, + contents: normalized + }) + } + + } + + console.log(index.stats, linkStats) + +})() + diff --git a/scripts/normalize/tables.js b/scripts/normalize/tables.js new file mode 100644 index 00000000000..fb3befe45ab --- /dev/null +++ b/scripts/normalize/tables.js @@ -0,0 +1,104 @@ +// run: node scripts/normalize/tables.js "product_docs/**/*.mdx" +// purpose: +// GFM tables require pipe characters in cells to be escaped EVEN IF WITHIN INLINE CODE +// Ref: https://github.github.com/gfm/#example-200 +// The juicer scripts did not do this correctly; this resulted in tables with implicit columns, +// which the renderer would silently drop. Round-tripping through the parser -> stringifier would +// retain the columns, but now the table would look odd with cell contents split across columns and +// headers not matching up. +// Attempt to mitigate this by escaping pipe characters correctly. +// This must be run on juiced content BEFORE the markdown normalizer. +// It should do no harm if run twice. + +const { read, write } = require('to-vfile'); +const glob = require('fast-glob'); + +;(async () => { + + if (!process.argv[2]) { + console.log(`usage: + ${process.argv[1]} "glob pattern" +example: + ${process.argv[1]} "product_docs/**/*.mdx"`) + return; + } + + const files = await glob(process.argv[2]); + + for (const filepath of files) { + // This is NOT a full GFM table parser, nor can it be + // it assumes that whatever generated the markdown correctly indicated the cell structure + // in the layout of the table itself: there will be a header-body separator of the form, + // |-------------------------|-----------------------|-----------------------| + // (where each run of dashes separated by pipes is EXACTLY the width of a column) + // To make this a bit more effective, I allow column widths to vary from the header by *up to* 10% + // Rows matching this layout that have pipes *within* the cells will have those pipes escaped. + // ... + // BUT WAIT, THERE'S MORE! + // GFM doesn't support merged cells in tables, or any block-level formatting in cells... + // ...it *will* allow you to insert a newline via a
tag however. + // Whatever pandoc was targetting thinks you can do this with extra pipe characters, as follows: + // `| |` at the start of a table cell introduces a multiline cell; within that cell, further + // pipe characters indicate paragraph breaks. + // Gatsby doesn't recognize this at all. So we gotta fix that up too, with strategic replacement + // of that format with
tags. + // ONE MORE FLY in the ointment here: per the GFM spec, \| should be de-escaped on render, + // *even within inline code* - but our current renderer does not do this. + // For now, I'm not trying to work around that; we need to update our renderer, and getting + // a clean round-trip through the parser is a first step in that process. + // rebuilding a car while going 70 down the interestate or something. + + const tableFmtRegex = /\|( *-{3,} *)(?=\|)/g; + const file = await read(filepath); + const lines = file.contents.toString().split('\n'); + let rowFormatRegex = null; + for (let i = 0; i < lines.length; ++i) { + if (!lines[i].trim().length) rowFormatRegex = null; + + if (rowFormatRegex) + { + const row = lines[i].match(rowFormatRegex); + if (row) + { + lines[i] = row[1] + '|' + row.slice(2).map(c => { + // rewrite multiline cells with
tags + if (c.startsWith(" |")) + c = c.replace(/^ \|/, '') + .replace(/\|/g, '

'); + // escape any other pipes + return c.replace(/(? + c.replace(/\|/g, '(?... elements left by the juicer +// with either inline code or links + +const { read, write } = require('to-vfile'); +const glob = require('fast-glob'); +const isAbsoluteUrl = require('is-absolute-url'); + +;(async () => { + + if (!process.argv[2]) { + console.log(`usage: + ${process.argv[1]} "glob pattern" +example: + ${process.argv[1]} "product_docs/**/*.mdx"`) + return; + } + + const files = await glob(process.argv[2]); + const titleRef = /([^<]*?)(?:(?:<|<)+(.*?)(?:>|>)+)*?<\/span>|`` `([^`]*?)`` <([^>]*?)>([^<]*?)<\/span>|`` `([^`]+)`` <([^>]*)>\\/g; + const cleanup1 = /\\`\\` *([^\\]+) *\\`\\`/g; + const cleanup2 = /`?`([^\n`]{3,}?)`\\?`/g; + const replaceRefs = (_, text1, href1, text2, href2, prologue, text3, href3) => + { + let textContent = (text1 || text2 || text3 || "").replace(/\\\\/g, '\\').trim(); + let href = (href1 || href2 || href3 || "").replace(/[\s\\]/g, '').replace(/^<|>$/g, ''); + prologue = prologue || ""; + if (!textContent && href) + { + textContent = `<${href}>`; + href = ""; + } + if (href && !isAbsoluteUrl(href)) + href = '#' + href; + + let result = ""; + if(href) + result = `[${textContent}](${href})` + prologue; + else + result = '`' + textContent + '`' + prologue; + return result; + }; + + for (const filepath of files) { + + const file = await read(filepath); + + let normalized = file.contents.toString().replace(titleRef, replaceRefs); + + if (normalized !== file.contents.toString()) { + + normalized = normalized.replace(cleanup1, '`$1`').replace(cleanup2, ' `$1` ') + + console.log(filepath); + await write({ + path: filepath, + contents: normalized + }) + } + } + +})() diff --git a/scripts/pdf/Signika-Light-modified.ttf b/scripts/pdf/Signika-Light-modified.ttf new file mode 100644 index 00000000000..d516397b2b6 Binary files /dev/null and b/scripts/pdf/Signika-Light-modified.ttf differ diff --git a/scripts/pdf/Signika-Regular.ttf b/scripts/pdf/Signika-Regular.ttf new file mode 100755 index 00000000000..ca37f24925d Binary files /dev/null and b/scripts/pdf/Signika-Regular.ttf differ diff --git a/scripts/pdf/SourceCodePro-Regular.ttf b/scripts/pdf/SourceCodePro-Regular.ttf new file mode 100755 index 00000000000..3563e7347be Binary files /dev/null and b/scripts/pdf/SourceCodePro-Regular.ttf differ diff --git a/scripts/pdf/cover.html b/scripts/pdf/cover.html new file mode 100644 index 00000000000..4f9af16c492 --- /dev/null +++ b/scripts/pdf/cover.html @@ -0,0 +1,42 @@ + + + + + + +
[PRODUCT]
+
Version [VERSION]
+ + diff --git a/scripts/pdf/generate_pdf.py b/scripts/pdf/generate_pdf.py new file mode 100755 index 00000000000..f9082851c7b --- /dev/null +++ b/scripts/pdf/generate_pdf.py @@ -0,0 +1,284 @@ +#!/usr/bin/env python3 + +import os +import re +import sys +from datetime import datetime +from itertools import chain +from pathlib import Path +from subprocess import run + +BASE_DIR = Path(__file__).resolve().parent + +ANSI_STOP = "\033[0m" +ANSI_BLUE = "\033[34m" +ANSI_GREEN = "\033[32m" +ANSI_YELLOW = "\033[33m" +ANSI_RED = "\033[31m" + + +# magic snippet for inline repl +# import code; code.interact(local=dict(globals(), **locals())) + + +class ToCItem: + def __init__(self, filename, chapter): + self.filename = filename + self.chapter = chapter + self.title = "" + self.anchor = "" + + +def putIndexFirst(e): + return e.filename.replace("index.mdx", "00_index.mdx") + + +def putIndexFirst2(e): + return e.replace("index.mdx", "00_index.mdx") + + +def getFilename(file): + return file.filename + + +def filterList(filename): + if ".png" in filename or "images" in filename or ".DS_Store" in filename: + return False + else: + return True + + +def getTitle(dirName): + indexPath = dirName + "/index.mdx" + if os.path.exists(indexPath): + indexFile = open(indexPath, "r") + for line in indexFile.readlines(): + if "title: " in line: + return stripQuotes(line.replace("title: ", "")) + return None + + +def stripQuotes(str): + return str.strip().strip("'").strip('"') + + +def getListOfFiles(dirName, parentChapter): + # create a list of file and sub directories + # names in the given directory + listOfFiles = list(filter(filterList, os.listdir(dirName))) + listOfFiles.sort(key=putIndexFirst2) + allFiles = list() + chapter = 0 + + # Iterate over all the entries + for entry in listOfFiles: + # Create full path + fullPath = os.path.join(dirName, entry) + # If entry is a directory then get the list of files in this directory + if os.path.isdir(fullPath): + allFiles = allFiles + getListOfFiles( + fullPath, parentChapter + str(chapter) + "." + ) + elif ".mdx" in entry or ".md" in entry: + allFiles.append(ToCItem(fullPath, parentChapter + str(chapter))) + + chapter += 1 + return allFiles + + +def main(): + dirName = "" + try: + dirName = sys.argv[1] + dirName = re.sub(r"\/$", "", dirName) + except BaseException: + print("directory not passed in") + print("if running from yarn use `yarn build-pdf directory/path/here`") + sys.exit(1) + + openPdf = False + html = False + try: + html = sys.argv[2] == "--html" + openPdf = sys.argv[2] == "--open" + except BaseException: + pass + + splitDirName = dirName.split("/") + product = splitDirName[2] + version = splitDirName[3] + + fullProductPdf = True + guide = None + if len(splitDirName) > 4: + fullProductPdf = False + guide = splitDirName[4] + + _file_prefix = f"{dirName}/{product}_v{version}" + _doc_prefix = f"{_file_prefix}_documentation" + mdxFilePath = f"{_doc_prefix}.mdx" + htmlFilePath = f"{_doc_prefix}.html" + coverFilePath = f"{_doc_prefix}_cover.html" + pdfFilePath = f"{_file_prefix}" "_{}documentation.pdf".format( + guide + "_" if guide else "" + ) + + print(f"{ANSI_BLUE}building {pdfFilePath}{ANSI_STOP}") + + if not os.path.exists(dirName): + raise Exception("directory does not exist") + + if os.path.exists(mdxFilePath): + os.remove(mdxFilePath) + + # Get the list of all files in directory tree at given path + listOfFiles = getListOfFiles(dirName, "") + if len(listOfFiles) == 0: + raise Exception(f"no files in {dirName}") + if fullProductPdf: + listOfFiles.pop(0) # remove base product index page, which are empty + + for elem in listOfFiles: + g = open(elem.filename, "r") + for line in g.readlines(): + if "title: " in line: + elem.title = line[7:].replace('"', "").replace("\n", "") + pattern = re.compile('div id="(.*?)" class="registered_link"') + + tag = pattern.search(line) + if tag and len(elem.anchor) == 0: + elem.anchor = tag.group(1) + + resourceSearchPaths = {dirName} + + # Print the files + with open(mdxFilePath, "w") as fp: + for elem in listOfFiles: + g = open(elem.filename, "r") + + baseImagePath = os.path.split(elem.filename)[0] + resourceSearchPaths.add(baseImagePath) + + frontmatterCount = 2 + for line in g.readlines(): + newLine = line + + if line[0:2] == "# ": + newLine = "##" + line + if line[0:3] == "## ": + newLine = "#" + line + if "toctree" in line: + frontmatterCount = 3 + if frontmatterCount == 0: + fp.write(newLine) + if "title: " in line: + newLine = ( + re.sub(r"\.0", "", elem.chapter) + + (" " * 10) + + stripQuotes(line[7:]) + + "\n" + ) + fp.write(newLine) + if "---" in line and frontmatterCount > 0: + frontmatterCount -= 1 + fp.write(newLine) + fp.write("\n") + + title = getTitle(dirName) or product + + print("generating docs html") + output = run( + [ + "pandoc", + mdxFilePath, + "--from=gfm", + "--self-contained", + "--highlight-style=tango", + f"--css={BASE_DIR / 'pdf-styles.css'}", + f"--resource-path={':'.join(resourceSearchPaths)}", + f"--output={htmlFilePath}", + ] + ) + output.check_returncode() + + if not os.path.exists(htmlFilePath): + os.remove(mdxFilePath) + raise Exception( + f"\033[91m html file failed to generate for {mdxFilePath} \033[0m" + ) + + if html: + run(["open", htmlFilePath]) + else: + print("generating cover page") + with open(BASE_DIR / "cover.html") as source, open( + coverFilePath, "w" + ) as output: + data = source.read() + data = data.replace("[PRODUCT]", title) + data = data.replace("[VERSION]", version) + output.write(data) + + headerFooterCommon = [ + "--header-font-name", + "Signika", + "--header-font-size", + "8", + "--header-spacing", + "7", + "--footer-font-name", + "Signika", + "--footer-font-size", + "8", + "--footer-spacing", + "7", + "--footer-left", + f"Copyright © 2009 - {datetime.now().year} EnterpriseDB Corporation. " + "All rights reserved.", + ] + + headerFooterOptions = [ + "--header-right", + "[doctitle]", + "--footer-right", + "[page]", + ] + + print("converting html to pdf") + output = run( + [ + "wkhtmltopdf", + "--log-level", + "error", + "--title", + title, + "--margin-top", + "15mm", + "--margin-bottom", + "15mm", + *headerFooterCommon, + coverFilePath, + "--footer-right", + f"Built at {datetime.utcnow().replace(microsecond=0).isoformat()}", + "toc", + "--xsl-style-sheet", + "scripts/pdf/toc-style.xsl", + *headerFooterOptions, + htmlFilePath, + *headerFooterOptions, + pdfFilePath, + ] + ) + output.check_returncode() + + if openPdf: + run(["open", pdfFilePath]) + + os.remove(mdxFilePath) + if not html: + os.remove(htmlFilePath) + os.remove(coverFilePath) + + +if __name__ == "__main__": + main() diff --git a/scripts/pdf/pdf-styles.css b/scripts/pdf/pdf-styles.css new file mode 100644 index 00000000000..7ef55ce70bc --- /dev/null +++ b/scripts/pdf/pdf-styles.css @@ -0,0 +1,124 @@ +@font-face { + font-family: "SignikaRegular"; + src: url("Signika-Regular.ttf") format("truetype"); + font-weight: normal; +} + +@font-face { + /* + To get multiple Signika fonts to work with wkhtmltopdf, I needed to edit the font + using FontForge. You need to change the "Preferred Family" attribute to be unique, + otherwise wkhtmltopdf will only use one of the fonts. See https://stackoverflow.com/a/45524377 + */ + + font-family: "SignikaLight"; + src: url("Signika-Light-modified.ttf") format("truetype"); + font-weight: 300; +} + +@font-face { + font-family: "Source Code Pro"; + src: url("SourceCodePro-Regular.ttf") format("truetype"); + font-style: normal; +} + +body { + font-size: 28px; + font-weight: 300; + font-family: SignikaLight; +} + +body::before { + content: ' '; /* this is needed to fix some font rendering quirk */ + font-family: SignikaLight; +} + +h1, h2, h3, h4, h5, h6, th { + font-family: SignikaRegular; + font-weight: normal; +} + +h2 { + margin: 4rem 0; +} + +h3 { + margin-top: 5rem; + margin-bottom: 3rem; +} + +h4, h5, h6 { + margin-top: 4rem; + margin-bottom: 2.5rem; +} + +p, ul { + margin-bottom: 2rem; +} + +a { + text-decoration: none; +} + +hr { + margin-top: 7rem; + border-top: 1px solid #ebeff2; +} + +blockquote { + border-left: 5px solid #ebeff2; + padding-left: 1rem; + margin-left: 0; +} + +img { + max-width: 100%; +} + + +/* Code */ +pre, code { + font-family: Source Code Pro; + font-weight: normal; + padding: .3rem; + border-radius: .2rem; +} + +code { + color: #457a00; + background-color: #f0f4f7; + white-space: pre-wrap !important; /* SourceCode pandoc will override otherwise */ +} + +pre { + background-color: #f8f8f8; /* match SourceCode pandoc highlighting colors */ + margin-bottom: 2rem; +} + +pre code { + color: black; + background-color: #f8f8f8; /* match SourceCode pandoc highlighting colors */ +} + + +/* Tables */ +table { + margin: 3rem 0; + text-align: left; + border-collapse: collapse; + width: 100% !important; + /*word-break: break-word;*/ +} + +thead { + font-weight: bold; +} + +tbody tr { + border-top: 1px solid #ebeff2; +} + +th, td { + padding: 0.3rem 0; + padding-right: 1.5rem; +} diff --git a/scripts/pdf/toc-style.xsl b/scripts/pdf/toc-style.xsl new file mode 100644 index 00000000000..5943d1e97ae --- /dev/null +++ b/scripts/pdf/toc-style.xsl @@ -0,0 +1,64 @@ + + + + + + + Table of Contents + + + + + +
+ + +
+ +
+ + diff --git a/scripts/source/config_sources.py b/scripts/source/config_sources.py new file mode 100644 index 00000000000..6087356a245 --- /dev/null +++ b/scripts/source/config_sources.py @@ -0,0 +1,93 @@ +import json + +ANSI_STOP = '\033[0m' +ANSI_BLUE = '\033[34m' +ANSI_GREEN = '\033[32m' +ANSI_YELLOW = '\033[33m' +ANSI_RED = '\033[31m' + +PRODUCT_DOCS = [ + 'ark', + 'bart', + 'efm', + 'epas', + 'eprs', + 'hadoop_data_adapter', + 'jdbc_connector', + 'migration_portal', + 'migration_toolkit', + 'mongo_data_adapter', + 'mysql_data_adapter', + 'net_connector', + 'ocl_connector', + 'odbc_connector', + 'pem', + 'pgbouncer', + 'pgpool', + 'postgis', + 'slony', +] + +BASE_OUTPUT = {} +BASE_OUTPUT.update({ doc : False for doc in PRODUCT_DOCS }) + +OPTIONS = [ + { 'index': 0, 'name': 'None (load `advocacy_docs` only)', 'key': None }, + { 'index': 1, 'name': 'All EDB Product Docs', 'output': { doc : True for doc in PRODUCT_DOCS } }, + { 'index': '1a', 'name': 'Ark Platform', 'key': 'ark', 'indent': True }, + { 'index': '1b', 'name': 'Backup and Recovery Tool', 'key': 'bart', 'indent': True }, + { 'index': '1c', 'name': 'Failover Manager', 'key': 'efm', 'indent': True }, + { 'index': '1d', 'name': 'EDB Postgres Advanced Server', 'key': 'epas', 'indent': True }, + { 'index': '1e', 'name': 'Hadoop Data Adapter', 'key': 'hadoop_data_adapter', 'indent': True }, + { 'index': '1f', 'name': 'JDBC Connector', 'key': 'jdbc_connector', 'indent': True }, + { 'index': '1g', 'name': 'Migration Portal', 'key': 'migration_portal', 'indent': True }, + { 'index': '1h', 'name': 'Migration Toolkit', 'key': 'migration_toolkit', 'indent': True }, + { 'index': '1i', 'name': '.NET Connector', 'key': 'net_connector', 'indent': True }, + { 'index': '1j', 'name': 'OCL Connector', 'key': 'ocl_connector', 'indent': True }, + { 'index': '1k', 'name': 'ODBC Connector', 'key': 'odbc_connector', 'indent': True }, + { 'index': '1l', 'name': 'Postgres Enterprise Manager', 'key': 'pem', 'indent': True }, + { 'index': '1m', 'name': 'PgBouncer', 'key': 'pgbouncer', 'indent': True }, + { 'index': '1n', 'name': 'Pgpool-II', 'key': 'pgpool', 'indent': True }, + { 'index': '1o', 'name': 'PostGIS', 'key': 'postgis', 'indent': True }, + { 'index': '1p', 'name': 'Slony Replication', 'key': 'slony', 'indent': True }, + { 'index': '1q', 'name': 'Mongo Data Adapter', 'key': 'mongo_data_adapter', 'indent': True }, + { 'index': '1r', 'name': 'MySQL Data Adapter', 'key': 'mysql_data_adapter', 'indent': True }, + { 'index': '1s', 'name': 'Replication Server', 'key': 'eprs', 'indent': True }, +] + +print('Which sources would you like loaded when you run `yarn develop`?') +for i, option in enumerate(OPTIONS): + print("{2}{0}: {1}".format( + option['index'], + option['name'], + ' ' if option.get('indent') else '', + ) +) + +selections = [] +while len(selections) == 0: + user_input = input('Enter your choices separated by commas, e.g. "1b,1m": ') + + split_user_input = user_input.strip().split(',') + for selection_index in split_user_input: + for option in OPTIONS: + if str(option['index']) == selection_index: + selections.append(option) + break + + if len(selections) != len(split_user_input): + print(ANSI_RED + 'Invalid input' + ANSI_STOP) + +for option in selections: + print(ANSI_BLUE + 'Selected {0}'.format(option['name']) + ANSI_STOP) + +with open('dev-sources.json', 'w') as outfile: + output = BASE_OUTPUT.copy() + for option in selections: + if option.get('output'): + output.update(option['output']) + elif option.get('key'): + output[option['key']] = True + json.dump(output, outfile, indent=2) + print(ANSI_GREEN + 'Wrote to dev-sources.json' + ANSI_STOP) + diff --git a/scripts/source/git-restore-mtime.py b/scripts/source/git-restore-mtime.py new file mode 100644 index 00000000000..d375990437d --- /dev/null +++ b/scripts/source/git-restore-mtime.py @@ -0,0 +1,418 @@ +# Version v2020.09 pulled on Oct 9 2020 + +#!/usr/bin/env python3 +# +# git-restore-mtime - Change mtime of files based on commit date of last change +# +# Copyright (C) 2012 Rodrigo Silva (MestreLion) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. See +# +""" +Change the modification time (mtime) of all files in work tree, based on the +date of the most recent commit that modified the file. + +Useful prior to generating release tarballs, so each file is archived with a +date that is similar to the date when the file was actually last modified, +assuming the actual modification date and its commit date are close. + +By default ignores all ignored and untracked files, and also refuses to work +on trees with uncommitted changes. +""" + +# TODO: +# - Add -z on git whatchanged/ls-files so we don't deal with filename decode/OS normalization +# - When Python is bumped to 3.7, use text instead of universal_newlines on subprocess +# - Update "Statistics for some large projects" with modern hardware and repositories. +# - Create a README.md for git-restore-mtime alone. It deserves extensive documentation +# - Move Statistics there + +# FIXME: +# - When current dir is outside the worktree, e.g. using --work-tree, `git ls-files` +# assume any relative pathspecs are to worktree root, not the current dir. As such, +# relative pathspecs may not work. +# - Renames and mode changes should not change file mtime: +# - Must check on status 'R100' and mode changes with same blobs +# - Should require status to be (A, C, M, R<100, T). D will never be processed as +# filelist is a subset of lsfileslist. +# - Check file (A, D) for directory mtime is not sufficient: +# - Renames also change dir mtime, unless rename was on a parent dir +# - If most recent change of all files in a dir was a [M]odification, +# dir might not be touched at all. +# - Dirs containing only subdirectories but no direct files will also +# not be touched. They're files' [grand]parent dir, but never their dirname(). +# - Some solutions: +# - After files done, perform some dir processing for missing dirs, finding latest +# file (A, D, R) +# - Simple approach: dir mtime is most recent child (dir or file) mtime +# - Use a virtual concept of "created at most at" to fill missing info, bubble up +# to parents and grandparents +# - When handling [grand]parent dirs, stay inside +# - Better handling of merge commits. `-m` is plain *wrong*. `-c/--cc` is perfect, but +# painfully slow. First pass without merge commits is not accurate. Maybe add a new +# `--accurate` mode for `--cc`? + +if __name__ != "__main__": + raise ImportError("{} should not be used as a module.".format(__name__)) + +import subprocess, shlex +import sys, os.path +import logging +import argparse +import time + + +# Update symlinks only if the OS supports not following them +UPDATE_SYMLINKS = bool(os.utime in getattr(os, 'supports_follow_symlinks', [])) +STEPMISSING = 100 + + +# Command-line interface ###################################################### + +def parse_args(): + parser = argparse.ArgumentParser( + description="""Restore original modification time of files based on the date of the + most recent commit that modified them. Useful when generating release tarballs.""") + + group = parser.add_mutually_exclusive_group() + group.add_argument('--quiet', '-q', dest='loglevel', + action="store_const", const=logging.WARNING, default=logging.INFO, + help="Suppress informative messages and summary statistics.") + group.add_argument('--verbose', '-v', action="count", + help="Print additional information for each processed file.") + + parser.add_argument('--force', '-f', action="store_true", + help="Force execution on trees with uncommitted changes.") + + parser.add_argument('--merge', '-m', action="store_true", + help="""Include merge commits. Leads to more recent mtimes and more files per + commit, thus with the same mtime (which may or may not be what you want). Including + merge commits may lead to less commits being evaluated (all files are found sooner), + which improves performance, sometimes substantially. But since merge commits are + usually huge, processing them may also take longer, sometimes substantially. + By default merge logs are only used for files missing from regular commit logs.""") + + parser.add_argument('--first-parent', action="store_true", + help="""Consider only the first parent, the "main branch", when parsing merge + commit logs. Only effective when merge commits are included in the log, either + by --merge or to find missing files after first log parse. See --skip-missing.""") + + parser.add_argument('--skip-missing', '-s', + action="store_false", default=True, dest="missing", + help="""Do not try to find missing files. If some files were not found in regular + commit logs, by default it re-tries using merge commit logs for these files (if + --merge was not already used). This option disables this behavior, which may slightly + improve performance, but files found only in merge commits will not be updated.""") + + parser.add_argument('--no-directories', '-D', + action="store_false", default=True, dest='dirs', + help="""Do not update directory mtime for files created, renamed or deleted in it. + Note: just modifying a file will not update its directory mtime.""") + + parser.add_argument('--test', '-t', action="store_true", default=False, + help="Test run: do not actually update any file") + + parser.add_argument('--commit-time', '-c', + action='store_true', default=False, dest='commit_time', + help="Use commit time instead of author time") + + parser.add_argument('--oldest-time', '-o', + action='store_true', default=False, dest='reverse_order', + help="""Set the mtime to the time of the first commit to mention a given file + instead of the most recent. This works by reversing the order in which the git + log is processed (i.e. from oldest to most recent commit on the current branch, + instead of from most recent to oldest). This may result in incorrect behaviour + if there are multiple files which have been renamed with the same name in the + current branch's history.""") + + parser.add_argument('pathspec', nargs='*', metavar='PATH', + help="""Only modify paths matching PATH, directories or files, relative to current + directory. Default is to modify all files handled by git, ignoring untracked files + and submodules.""") + + parser.add_argument('--work-tree', dest='workdir', + help="Path to the work tree, if not current directory or one of its parents.") + + parser.add_argument('--git-dir', dest='gitdir', + help="Path to the git repository, if not the default /.git") + + parser.add_argument('--skip-older-than', metavar='SECONDS', type=int, + help="""Do not modify files that are older than %(metavar)s. + It can significantly improve performance if fewer files are processed. + Useful on CI builds, which can eventually switch workspace to different branch, + but mostly performs builds on the same one (e.g. master). + """) + + return parser.parse_args() + + +# Helper functions ############################################################ + +def setup_logging(args): + TRACE = logging.DEBUG // 2 + logging.Logger.trace = lambda _, m, *a, **k: _.log(TRACE, m, *a, **k) + level = (args.verbose and max(TRACE, logging.DEBUG // args.verbose)) or args.loglevel + logging.basicConfig(level=level, format='%(message)s') + return logging.getLogger() + + +def normalize(path): + """Normalize paths from git, handling non-ASCII characters. + + Git for Windows, as of v1.7.10, stores paths as UTF-8 normalization form C. If path + contains non-ASCII or non-printable chars it outputs the UTF-8 in octal-escaped + notation, double-quoting the whole path. Double-quotes and backslashes are also escaped. + + https://git-scm.com/docs/git-config#Documentation/git-config.txt-corequotePath + https://github.com/msysgit/msysgit/wiki/Git-for-Windows-Unicode-Support + https://github.com/git/git/blob/master/Documentation/i18n.txt + + Example on git output, this function reverts this: + r'back\slash_double"quote_açaí' -> r'"back\\slash_double\"quote_a\303\247a\303\255"' + """ + if path and path[0] == '"': + # Python 2: path = path[1:-1].decode("string-escape") + # Python 3: https://stackoverflow.com/a/46650050/624066 + path = (path[1:-1] # Remove enclosing double quotes + .encode('latin1') # Convert to bytes, required 'unicode-escape' + .decode('unicode-escape') # Perform the actual octal-escaping decode + .encode('latin1') # 1:1 mapping to bytes, forming UTF-8 encoding + .decode('utf8')) # Decode from UTF-8 + # Make sure the slash matches the OS; for Windows we need a backslash + return os.path.normpath(path) + + +if UPDATE_SYMLINKS: + def touch(path, mtime, test=False): + """The actual mtime update""" + if test: return + os.utime(path, (mtime, mtime), follow_symlinks=False) +else: + def touch(path, mtime, test=False): + """The actual mtime update""" + if test: return + os.utime(path, (mtime, mtime)) + + +def isodate(secs): + return time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(secs)) + + +# Git class and parselog(), the heart of the script ########################### + +class Git(): + def __init__(self, workdir=None, gitdir=None): + self.gitcmd = ['git'] + if workdir: self.gitcmd.extend(('--work-tree', workdir)) + if gitdir : self.gitcmd.extend(('--git-dir', gitdir)) + self.workdir, self.gitdir = self._repodirs() + + def ls_files(self, pathlist=None): + return (normalize(_) for _ in self._run('ls-files --full-name', pathlist)) + + def is_dirty(self): + return bool(self._run('diff --no-ext-diff --quiet', output=False)) + + def log(self, merge=False, first_parent=False, commit_time=False, reverse_order=False, + pathlist=None): + cmd = 'whatchanged --pretty={}'.format('%ct' if commit_time else '%at') + if merge: cmd += ' -m' + if first_parent: cmd += ' --first-parent' + if reverse_order: cmd += ' --reverse' + return self._run(cmd, pathlist) + + def _repodirs(self): + return (os.path.normpath(_) for _ in + self._run('rev-parse --show-toplevel --absolute-git-dir', check=True)) + + def _run(self, cmdstr, pathlist=None, output=True, check=False): + cmdlist = self.gitcmd + shlex.split(cmdstr) + if pathlist: + cmdlist.append('--') + cmdlist.extend(pathlist) + log.trace("Executing: %s", ' '.join(cmdlist)) + if not output: + return subprocess.call(cmdlist) + if check: + try: + stdout = subprocess.check_output(cmdlist, universal_newlines=True) + return stdout.splitlines() + except subprocess.CalledProcessError as e: + raise self.Error(e.returncode, e.cmd, e.output, e.stderr) + self.proc = subprocess.Popen(cmdlist, stdout=subprocess.PIPE, universal_newlines=True) + return (_.strip() for _ in self.proc.stdout) + + class Error(subprocess.CalledProcessError): pass + + +def parselog(filelist, dirlist, stats, git, merge=False, filterlist=None): + mtime = 0 + for line in git.log(merge, args.first_parent, args.commit_time, args.reverse_order, + filterlist): + stats['loglines'] += 1 + + # Blank line between Date and list of files + if not line: continue + + # File line + if line[0] == ':': # Faster than line.startswith(':') + # If line describes a rename, linetok has three tokens, otherwise two + linetok = line.split('\t') + status = linetok[0] + file = linetok[-1] + + # Handles non-ASCII chars and OS path separator + file = normalize(file) + + if file in filelist: + stats['files'] -= 1 + log.debug("%d\t%d\t%d\t%s\t%s", + stats['loglines'], stats['commits'], stats['files'], + isodate(mtime), file) + filelist.remove(file) + try: + touch(os.path.join(git.workdir, file), mtime, args.test) + stats['touches'] += 1 + except Exception as e: + log.error("ERROR: %s", e) + stats['errors'] += 1 + + if args.dirs: + dirname = os.path.dirname(file) + if status[-1] in ('A', 'D') and dirname in dirlist: + log.debug("%d\t%d\t-\t%s\t%s", + stats['loglines'], stats['commits'], + isodate(mtime), "{}/".format(dirname or '.')) + dirlist.remove(dirname) + try: + touch(os.path.join(git.workdir, dirname), mtime, args.test) + stats['dirtouches'] += 1 + except Exception as e: + log.error("ERROR: %s", e) + stats['direrrors'] += 1 + + # Date line + else: + stats['commits'] += 1 + mtime = int(line) + + # All files done? + if not stats['files']: + git.proc.terminate() # hackish, but does the job. Not needed anyway + return + + +# Main Logic ################################################################## + +def main(): + start = time.time() # yes, Wall time. CPU time is not realistic for users. + stats = {_: 0 for _ in ('loglines', 'commits', 'touches', 'errors', 'dirtouches', 'direrrors')} + + # First things first: Where and Who are we? + try: + git = Git(args.workdir, args.gitdir) + except Git.Error as e: + # Not in a git repository, and git already informed user on stderr. So we just... + return e.returncode + + # Do not work on dirty repositories, unless --force + if not args.force and git.is_dirty(): + log.critical( + "ERROR: There are local changes in the working directory.\n" + "This could lead to undesirable results for modified files.\n" + "Please, commit your changes (or use --force) and try again.\n" + "Aborting") + return 1 + + # Get the files managed by git and build file and dir list to be processed + filelist = set() + dirlist = set() + if UPDATE_SYMLINKS and not args.skip_older_than: + filelist = set(git.ls_files(args.pathspec)) + dirlist = set(os.path.dirname(_) for _ in filelist) + else: + for path in git.ls_files(args.pathspec): + fullpath = os.path.join(git.workdir, path) + + # Symlink (to file, to dir or broken - git handles the same way) + if not UPDATE_SYMLINKS and os.path.islink(fullpath): + log.warning("WARNING: Skipping symlink, OS does not support update: %s", path) + continue + + # skip files which are older than given threshold + if args.skip_older_than and start - os.path.getmtime(fullpath) > args.skip_older_than: + continue + + # Always add them relative to worktree root + filelist.add(path) + dirlist.add(os.path.dirname(path)) + + stats['totalfiles'] = stats['files'] = len(filelist) + log.info("{0:,} files to be processed in work dir".format(stats['totalfiles'])) + + if not filelist: + # Nothing to do. Exit silently and without errors, just like git does + return + + # Process the log until all files are 'touched' + log.debug("Line #\tLog #\tF.Left\tModification Time\tFile Name") + parselog(filelist, dirlist, stats, git, args.merge, args.pathspec) + + # Missing files + if filelist: + # Try to find them in merge logs, if not done already + # (usually HUGE, thus MUCH slower!) + if args.missing and not args.merge: + filterlist = list(filelist) + for i in range(0, len(filterlist), STEPMISSING): + parselog(filelist, dirlist, stats, git, + merge=True, filterlist=filterlist[i:i+STEPMISSING]) + + # Still missing some? + for file in filelist: + log.warning("WARNING: not found in log: %s", file) + + # Final statistics + # Suggestion: use git-log --before=mtime to brag about skipped log entries + log.info( + "Statistics:\n" + "{:13,.2f} seconds\n" + "{:13,} log lines processed\n" + "{:13,} commits evaluated" + "".format(time.time()-start, stats['loglines'], stats['commits'])) + + if args.dirs: + if stats['direrrors']: log.info("{:13,} directory update errors".format(stats['direrrors'])) + log.info("{:13,} directories updated".format(stats['dirtouches'])) + + if stats['touches'] != stats['totalfiles']: log.info("{:13,} files".format(stats['totalfiles'])) + if stats['files']: log.info("{:13,} files missing".format(stats['files'])) + if stats['errors']: log.info("{:13,} file update errors".format(stats['errors'])) + + log.info("{:13,} files updated".format(stats['touches'])) + + if args.test: + log.info("TEST RUN - No files modified!") + + +args = parse_args() +log = setup_logging(args) +log.trace("Arguments: %s", args) + +# UI done, it's show time! +try: + sys.exit(main()) +except KeyboardInterrupt: + log.info("Aborting") + sys.exit(-1) diff --git a/scripts/source/source_cloud_native_operator.py b/scripts/source/source_cloud_native_operator.py new file mode 100644 index 00000000000..63c7c0ada85 --- /dev/null +++ b/scripts/source/source_cloud_native_operator.py @@ -0,0 +1,102 @@ +import os +import re +from pathlib import Path + +STANDARD_FRONTMATTER = """--- +title: '{0}' +originalFilePath: '{1}' +product: 'Cloud Native Operator'{2} +--- +""" + +INDEX_FRONTMATTER = """ +indexCards: none +directoryDefaults: + prevNext: true + iconName: kubernetes + +navigation: +{0}""" + + +def rewrite_yaml_links(line): + match = re.search(r"\[.+\]\((.+)\)", line) + if match and match[1] and match[1].endswith(".yaml"): + return line.replace(match[1], match[1].replace("samples/", "../samples/")) + return line + + +def index_frontmatter(): + nav = [] + with open("temp_kubernetes/docs/mkdocs.yml") as mkdocs: + readingNav = False + for line in mkdocs: + if "-" not in line: + readingNav = False + if line.startswith("nav"): + readingNav = True + elif readingNav: + nav.append(line.replace(".md", "")) + if "quickstart.md" in line: + nav.append(" - interactive_demo\n") + + return INDEX_FRONTMATTER.format("".join(nav)) + + +def process_md(file_path): + new_file_path = file_path.with_suffix(".mdx") + + with open(new_file_path, "w") as new_file: + with open(file_path, "r") as md_file: + copying = False + quickstart = file_path.name == "quickstart.md" + paragraph = 0 + gh_relative_path = Path("src/") / file_path.relative_to("temp_kubernetes/build/") + + for line in md_file: + if quickstart and not line.strip(): + paragraph = paragraph + 1 + + if paragraph == 2: + line = """ + + +!!! Tip "Live demonstration" + Don't want to install anything locally just yet? Try a demonstration directly in your browser: + + [Cloud Native PostgreSQL Operator Interactive Quickstart](interactive_demo) + + +""" + elif copying: + line = rewrite_yaml_links(line) + elif line.startswith("#"): + copying = True + line = STANDARD_FRONTMATTER.format( + re.sub(r"#+ ", "", line).strip(), + gh_relative_path, + index_frontmatter() + if new_file_path.name == "index.mdx" + else "", + ) + + new_file.write(line) + + os.remove(file_path) + + +def source_cloud_native_postgresql_docs(): + os.system("rm -r temp_kubernetes/build") + os.system("cp -r temp_kubernetes/docs/src temp_kubernetes/build") + os.system( + "cp -r merge_sources/kubernetes/cloud_native_postgresql/* temp_kubernetes/build" + ) + + print("Processing cloud_native_postgresql...") + files = Path("temp_kubernetes/build/").glob("**/*.md") + for file_path in files: + process_md(file_path) + + +if __name__ == "__main__": + source_cloud_native_postgresql_docs() diff --git a/src/components/advanced-search/filtering.js b/src/components/advanced-search/filtering.js new file mode 100644 index 00000000000..7be1256fb8e --- /dev/null +++ b/src/components/advanced-search/filtering.js @@ -0,0 +1,214 @@ +import React, { useEffect } from 'react'; +import { Badge } from 'react-bootstrap'; +import { + connectMenu, + connectCurrentRefinements, + connectRefinementList, +} from 'react-instantsearch-dom'; +import { products } from '../../constants/products'; +import { capitalize } from '../../constants/utils'; + +const typeToContentType = { + doc: { name: 'Documentation' }, + guide: { name: 'Guides' }, +}; + +const labelForItem = (item, translation) => { + return translation[item.label] + ? translation[item.label].name + : capitalize(item.label); +}; + +const versionSort = (a, b) => { + return b.label.localeCompare(a.label, undefined, { numeric: true }); +}; + +const RadioInput = ({ + labelText, + badgeNumber, + showBadge, + id, + name, + onChange, + checked, +}) => ( +
+ + +
+); + +const RadioRefinement = ({ + attribute, + heading, + items, + queryActive, + refine, + show, + sortFunction, + translation = {}, +}) => { + if (items == null) { + return null; + } + + const radioName = `radio-refinement-${attribute}`; + const refinedItem = items.find((item) => item.isRefined); + const sortedItems = items.sort( + sortFunction || + ((a, b) => { + const aLabel = labelForItem(a, translation); + const bLabel = labelForItem(b, translation); + return aLabel.toLowerCase() > bLabel.toLowerCase() ? 1 : -1; + }), + ); + + return ( +
+
+ {heading || capitalize(attribute)} +
+ total + item.count, 0)} + showBadge={queryActive} + onChange={() => refine('')} + checked={!refinedItem} + /> + {sortedItems.map((item) => ( + refine(item.label)} + checked={refinedItem === item} + /> + ))} +
+ ); +}; + +/* eslint-disable no-unused-vars */ +const ContentTypeRefinement = connectMenu( + /* eslint-enable */ + ({ items, currentRefinement, refine, queryActive }) => ( + + ), +); + +const SingleFacetRefinement = connectRefinementList( + ({ + items, + refine, + queryActive, + show, + attribute, + sortFunction, + hideIfEmpty = false, + }) => { + const empty = !items || items.length === 0; + + return ( + + ); + }, +); + +const ClearRefinements = connectCurrentRefinements(({ items, refine }) => { + const clear = (e) => { + refine(items); + e.preventDefault(); + }; + + if (items.length > 0) { + return ( + + Clear Filters + + ); + } + return null; +}); + +export const AdvancedSearchFiltering = connectCurrentRefinements( + ({ items, queryActive, refine }) => { + const showProductVersionFilters = !items.find((item) => { + return item.attribute === 'type' && item.currentRefinement === 'guide'; + }); + + const productFilterApplied = items.some( + (item) => item.attribute === 'product', + ); + const versionFilterApplied = items.some( + (item) => item.attribute === 'version', + ); + + // if we don't have a product filter applied, wipe any version filters + useEffect(() => { + if (versionFilterApplied && !productFilterApplied) { + const versionFilter = items.find( + (item) => item.attribute === 'version', + ); + if (versionFilter.items[0]) { + refine(versionFilter.items[0].value); + } + } + }); + + return ( + <> + + + + + ); + }, +); diff --git a/src/components/advanced-search/form.js b/src/components/advanced-search/form.js new file mode 100644 index 00000000000..ac599174b39 --- /dev/null +++ b/src/components/advanced-search/form.js @@ -0,0 +1,73 @@ +import React, { useEffect, useCallback, createRef } from 'react'; +import { connectSearchBox } from 'react-instantsearch-dom'; +import Icon, { iconNames } from '../icon'; +import { SlashIndicator, ClearButton } from '../search/formComps'; + +export const AdvancedSearchForm = connectSearchBox( + ({ currentRefinement, refine, query }) => { + const queryLength = (query || '').length; + + const inputRef = createRef(); + const searchKeyboardShortcuts = useCallback( + e => { + const inputFocused = inputRef.current.id === document.activeElement.id; + + if (e.key === '/' && !inputFocused) { + inputRef.current.focus(); + e.preventDefault(); + } + if (e.key === 'Escape' && inputFocused) { + inputRef.current.blur(); + e.preventDefault(); + } + }, + [inputRef], + ); + + useEffect(() => { + document.addEventListener('keydown', searchKeyboardShortcuts); + return () => { + document.removeEventListener('keydown', searchKeyboardShortcuts); + }; + }, [searchKeyboardShortcuts]); + + useEffect(() => { + inputRef.current.focus(); + }, []); // eslint-disable-line react-hooks/exhaustive-deps + + return ( +
e.preventDefault()} + > + + refine(e.currentTarget.value)} + ref={inputRef} + /> + { + refine(''); + }} + className={`${queryLength === 0 && 'd-none'}`} + /> + + + ); + }, +); diff --git a/src/components/advanced-search/hitComps.js b/src/components/advanced-search/hitComps.js new file mode 100644 index 00000000000..5c4353ba0f6 --- /dev/null +++ b/src/components/advanced-search/hitComps.js @@ -0,0 +1,18 @@ +import React from 'react'; +import { Highlight, Snippet } from 'react-instantsearch-dom'; +import { Link } from '../'; + +export const AdvancedPageHit = ({ hit }) => ( + <> + + +
{hit.path}
+ + + +); diff --git a/src/components/advanced-search/index.js b/src/components/advanced-search/index.js new file mode 100644 index 00000000000..b30713d5a7c --- /dev/null +++ b/src/components/advanced-search/index.js @@ -0,0 +1,17 @@ +import { AdvancedPageHit } from './hitComps'; +import { AdvancedSearchResults } from './results'; +import { AdvancedSearchForm } from './form'; +import { AdvancedSearchFiltering } from './filtering'; +import { + queryParamsToState, + writeStateToQueryParams, +} from './queryParams'; + +export { + AdvancedPageHit, + AdvancedSearchFiltering, + AdvancedSearchResults, + AdvancedSearchForm, + queryParamsToState, + writeStateToQueryParams, +}; diff --git a/src/components/advanced-search/queryParams.js b/src/components/advanced-search/queryParams.js new file mode 100644 index 00000000000..c483a025027 --- /dev/null +++ b/src/components/advanced-search/queryParams.js @@ -0,0 +1,58 @@ +export const queryParamsToState = (query) => { + const params = new URLSearchParams(query); + + const searchState = {}; + if (params.get('query')) { + searchState.query = params.get('query'); + } + if (params.get('product')) { + searchState.refinementList = { + ...searchState.refinementList, + product: params.get('product'), + }; + } + if (params.get('version')) { + searchState.refinementList = { + ...searchState.refinementList, + version: params.get('version'), + }; + } + if (params.get('page')) { + searchState.page = params.get('page'); + } + if (params.get('content')) { + searchState.menu = { type: params.get('content') }; + } + + return searchState; +}; + +export const writeStateToQueryParams = (searchState) => { + const params = new URLSearchParams(); + + if (searchState.query && searchState.query.length > 0) { + setOrRemove(params, 'query', searchState.query); + } + if (searchState.refinementList) { + setOrRemove(params, 'product', searchState.refinementList.product); + setOrRemove(params, 'version', searchState.refinementList.version); + } + if (searchState.page > 1) { + setOrRemove(params, 'page', searchState.page); + } + if (searchState.menu) { + setOrRemove(params, 'content', searchState.menu.type); + } + + if (window && window.history) { + window.history.replaceState('', searchState.query, `?${params.toString()}`); + } +}; + +const setOrRemove = (params, key, value) => { + if (value && value.length > 0) { + params.set(key, value); + } else { + params.delete(key); + } +}; diff --git a/src/components/advanced-search/results.js b/src/components/advanced-search/results.js new file mode 100644 index 00000000000..53d57605498 --- /dev/null +++ b/src/components/advanced-search/results.js @@ -0,0 +1,123 @@ +import React from 'react'; +import { + Hits, + connectStateResults, + connectPagination, + connectCurrentRefinements, +} from 'react-instantsearch-dom'; +import { AdvancedPageHit } from './index'; +import { products } from '../../constants/products'; +import { capitalize } from '../../constants/utils'; + +const prettyProductName = (product) => { + return products[product] ? products[product].name : capitalize(product); +}; + +const ResultsSummary = connectCurrentRefinements( + connectStateResults(({ searchResults: res, items }) => { + const resultCount = res && res.nbHits; + const query = res && res.query; + + const productRefinement = items.find( + (item) => item.attribute === 'product', + ); + const versionRefinement = items.find( + (item) => item.attribute === 'version', + ); + + const productName = productRefinement + ? prettyProductName(productRefinement.currentRefinement[0]) + : null; + const version = versionRefinement + ? versionRefinement.currentRefinement[0] + : null; + + return ( +

+ {resultCount} result{resultCount !== 1 && 's'} for "{query}" + {productName && ' in '} + {productName && {productName}} + {version && ' and '} + {version && Version {version}} +

+ ); + }), +); + +const Pagination = connectPagination( + ({ currentRefinement, nbPages, refine }) => { + const previousEnabled = currentRefinement > 1; + const nextEnabled = currentRefinement < nbPages; + const goPrevious = (e) => { + refine(currentRefinement - 1); + e.preventDefault(); + }; + const goNext = (e) => { + refine(currentRefinement + 1); + e.preventDefault(); + }; + + if (previousEnabled || nextEnabled) { + return ( +
+
+
+ +
+ {currentRefinement} / {nbPages} +
+ +
+
+ ); + } + return null; + }, +); + +const ResultsContent = ({ children }) => ( +
{children}
+); + +export const AdvancedSearchResults = connectStateResults( + ({ searchResults, query }) => { + const queryLength = (query || '').length; + const showPagination = searchResults && searchResults.nbPages > 1; + + if (queryLength === 0) { + return ( +

Enter a search query to begin.

+ ); + } + + return ( + + + + {showPagination && } + + ); + }, +); diff --git a/src/components/back-button.js b/src/components/back-button.js new file mode 100644 index 00000000000..d060c8d57a6 --- /dev/null +++ b/src/components/back-button.js @@ -0,0 +1,19 @@ +import React from 'react'; +import { Link } from './'; +import Icon, { iconNames } from './icon/'; + +const BackButton = () => ( +
  • + + + Back + +
  • +); + +export default BackButton; diff --git a/src/components/card-decks.js b/src/components/card-decks.js new file mode 100644 index 00000000000..e512d5e3fb8 --- /dev/null +++ b/src/components/card-decks.js @@ -0,0 +1,91 @@ +import React from 'react'; +import { Link } from '../components/'; +import { Col } from 'react-bootstrap'; +import Icon, { iconNames } from '../components/icon/'; + +const KatacodaBadge = () => Demo; + +const showInteractiveBadge = (frontmatter) => + frontmatter.showInteractiveBadge != null + ? frontmatter.showInteractiveBadge + : !!frontmatter.katacodaPanel; + +const FullCard = ({ card }) => { + const iconName = card.frontmatter.iconName || iconNames.DOTTED_BOX; + + return ( +
    + + + +
    +

    + + {card.frontmatter.navTitle || card.frontmatter.title} + +

    + +

    {card.frontmatter.description}

    + + {card.children.map((child) => ( + + {child.frontmatter.navTitle || child.frontmatter.title} + {showInteractiveBadge(child.frontmatter) && } + + ))} +
    +
    + ); +}; + +const SimpleCard = ({ card }) => ( +
    +
    +

    + + {card.frontmatter.navTitle || card.frontmatter.title} + {showInteractiveBadge(card.frontmatter) && } + +

    + +

    {card.frontmatter.description}

    +
    +
    +); + +const CardDecks = ({ cards, cardType = 'simple' }) => { + return ( +
    + {cards.map((card) => { + return ( + + {cardType === 'full' ? ( + + ) : ( + + )} + + ); + })} +
    + ); +}; + +export default CardDecks; diff --git a/src/components/code-block.js b/src/components/code-block.js new file mode 100644 index 00000000000..05bb5de83ae --- /dev/null +++ b/src/components/code-block.js @@ -0,0 +1,163 @@ +import React, { useState } from 'react'; +import { Button } from 'react-bootstrap'; + +const childToString = (child) => { + if (typeof child === 'string') { + return child; // hit string, unroll + } else if (child && child.props) { + return childToString(child.props.children); + } + + return ''; +}; + +const popExtraNewLines = (code) => { + while ( + code.length - 1 > 0 && + childToString(code[code.length - 1]).trim() === '' + ) { + code.pop(); + } +}; + +const splitChildrenIntoCodeAndOutput = (rawChildren) => { + if (!rawChildren) { + return [[], []]; + } + + const splitRegex = /(?:\s+|^)__OUTPUT__(?:\s+|$)/; + const code = []; + const output = []; + + const children = Array.isArray(rawChildren) ? rawChildren : [rawChildren]; + + let splitFound = false; + for (let i = 0; i < children.length; i++) { + const child = children[i]; + + if (splitFound) { + // we've already split, toss it into output and move on + output.push(childToString(child)); + continue; + } + + const sChild = childToString(child); + const splitChild = sChild.split(splitRegex); + if (splitChild.length > 1) { + // found split location + code.push(splitChild[0].replace(/(\n|\r\n)*$/g, '')); // will convert token to pure text, seems to be okay in practice + output.push(splitChild[1].replace(/^(\n|\r\n)*/g, '')); + popExtraNewLines(code); + splitFound = true; + } else { + code.push(child); + } + } + + return [code, output]; +}; + +const CodePre = ({ className, content, runnable }) => { + const codeRef = React.createRef(); + const [copyButtonText, setCopyButtonText] = useState('Copy'); + const copyClick = (e) => { + const text = codeRef.current && codeRef.current.textContent; + navigator.clipboard.writeText(text).then(() => { + setCopyButtonText('Copied!'); + setTimeout(() => { + setCopyButtonText('Copy'); + }, 3000); + }); + e.target.blur(); + }; + + const [wrap, setWrap] = useState(false); + const wrapClick = (e) => { + setWrap(!wrap); + e.target.blur(); + }; + + const [canRun, setCanRun] = useState(true); + const runClick = (e) => { + const text = codeRef.current && codeRef.current.textContent; + window.katacoda.write(text); + setCanRun(false); + setTimeout(() => { + setCanRun(true); + }, 3000); + e.target.blur(); + }; + + return ( + <> +
    +
    + + +
    + + {runnable && ( + + )} +
    + +
    +        {content}
    +      
    + + ); +}; + +const OutputPre = ({ content }) => ( +
    +
    Output
    +
    {content}
    +
    +); + +const CodeBlock = ({ children, codeLanguages, ...otherProps }) => { + const childIsComponent = !!children.props; // true in normal usage, false if raw
     tags are used
    +
    +  const [codeContent, outputContent] = childIsComponent
    +    ? splitChildrenIntoCodeAndOutput(children.props.children)
    +    : [children, ''];
    +  const language = childIsComponent
    +    ? (children.props.className || '').replace('language-', '')
    +    : 'text';
    +
    +  const execLanguages = codeLanguages
    +    ? ['shell'].concat(codeLanguages?.split(',')?.map((l) => l.trim()))
    +    : [];
    +
    +  if (codeContent.length > 0) {
    +    return (
    +      
    + + {outputContent.length > 0 && } +
    + ); + } else { + return null; + } +}; + +export default CodeBlock; diff --git a/src/components/dark-mode-toggle.js b/src/components/dark-mode-toggle.js new file mode 100644 index 00000000000..de104e9d9f3 --- /dev/null +++ b/src/components/dark-mode-toggle.js @@ -0,0 +1,40 @@ +import React from 'react'; +import { Form } from 'react-bootstrap'; +import Icon, { iconNames } from '../components/icon/'; +import { LayoutContext } from '../components'; + +const DarkModeToggle = ({ className = '' }) => ( + + {({ dark, toggleDark }) => ( +
  • + + + + +
  • + )} +
    +); + +export default DarkModeToggle; diff --git a/src/components/dev-frontmatter.js b/src/components/dev-frontmatter.js new file mode 100644 index 00000000000..a443653de10 --- /dev/null +++ b/src/components/dev-frontmatter.js @@ -0,0 +1,28 @@ +import React from 'react'; +import DevOnly from './dev-only'; + +const DevFrontmatter = ({ frontmatter }) => { + let keys = Object.keys(frontmatter); + return ( + +
    +
    Page frontmatter
    +
    + {keys.map((key) => { + let val = frontmatter[key]; + if (typeof val !== 'string') { + val = JSON.stringify(val); + } + + return ( +
    + {key}: {val} +
    + ); + })} +
    +
    + ); +}; + +export default DevFrontmatter; diff --git a/src/components/dev-only.js b/src/components/dev-only.js new file mode 100644 index 00000000000..733c4018232 --- /dev/null +++ b/src/components/dev-only.js @@ -0,0 +1,8 @@ +const DevOnly = ({ children }) => { + if (process.env.NODE_ENV === 'development') { + return children; + } + return null; +}; + +export default DevOnly; diff --git a/src/components/footer.js b/src/components/footer.js new file mode 100644 index 00000000000..6c2633dc770 --- /dev/null +++ b/src/components/footer.js @@ -0,0 +1,63 @@ +import React from 'react'; +import { Link } from './'; + +const TimestampLink = ({ timestamp, githubFileLink }) => { + if (timestamp) { + return ( + <> + · +
    + {githubFileLink ? ( + Modified {timestamp.split('T')[0]} + ) : ( + Modified {timestamp.split('T')[0]} + )} +
    + + ); + } else if (githubFileLink) { + return ( + <> + · + + + ); + } else { + return null; + } +}; + +const Footer = ({ timestamp, githubFileLink }) => ( +
    + © EDB· + + GDPR + + · + + Privacy Policy + + · + + Terms of Use + + · + + Trademarks + + +
    +); + +export default Footer; diff --git a/src/components/icon/iconList.js b/src/components/icon/iconList.js new file mode 100644 index 00000000000..ab3ffb9c9b8 --- /dev/null +++ b/src/components/icon/iconList.js @@ -0,0 +1,14 @@ +import React from 'react'; + +import Icon, { iconNames } from '../icon/'; + +export const IconList = () => ( +
    + {Object.keys(iconNames).map(key => ( +
    + + {iconNames[key]} +
    + ))} +
    +); diff --git a/src/components/icon/iconNames.js b/src/components/icon/iconNames.js new file mode 100644 index 00000000000..a0378a5d2d2 --- /dev/null +++ b/src/components/icon/iconNames.js @@ -0,0 +1,186 @@ +const iconNames = { + ALERT: 'alert', + ANGULARJS_COLOR: 'angularjscolor', + ANNOUNCE: 'announce', + ARROW_LEFT: 'arrowleft', + ARROW_RIGHT: 'arrowright', + BARMAN: 'barman', + BIG_DATA: 'bigdata', + BRAIN_CIRCUIT: 'braincircuit', + BRIEFCASE: 'briefcase', + BUSINESSMAN: 'businessman', + BUSINESSWOMAN: 'businesswoman', + C_COLOR: 'ccolor', + C_PLUS_PLUS_COLOR: 'cpluspluscolor', + C_SHARP_COLOR: 'csharpcolor', + C_SHARP: 'csharp', + CASE_STUDY: 'casestudy', + CENTOS_COLOR: 'centoscolor', + CERTIFICATE: 'certificate', + CHANGE: 'change', + CHECKMARK: 'checkmark', + CHEVRON_DOWN: 'chevrondown', + CHEVRON_RIGHT: 'chevronright', + CLOSE: 'close', + CLOUD_CHECKED: 'cloudchecked', + CLOUD_DB: 'clouddb', + CLOUD_DBA: 'clouddba', + CLOUD_PRIVATE: 'cloudprivate', + CLOUD_PUBLIC: 'cloudpublic', + CODE_WRITING: 'codewriting', + COFFEE: 'coffee', + CONFIG_MANAGEMENT: 'configmanagement', + CONFLICT: 'conflict', + CONNECT: 'connect', + CONSOLE: 'console', + CONTACT: 'contact', + CONTAINER: 'container', + CONTROL: 'control', + CONVERT: 'convert', + CROWN: 'crown', + CUBES: 'cubes', + CYCLE: 'cycle', + DATA_TRANSFER: 'datatransfer', + DATABASE_ADMIN: 'databaseadmin', + DATABASE_BACKUP: 'databasebackup', + DATABASE: 'database', + DEBIAN_COLOR: 'debiancolor', + DELIVER_LOVE: 'deliverlove', + DESIGN: 'design', + DEVELOPER: 'developer', + DIPLOMA: 'diploma', + DJANGO_COLOR: 'djangocolor', + DOCKER_COLOR: 'dockercolor', + DOCKER_CONTAINER: 'dockercontainer', + DOCS: 'docs', + DOT_NET_COLOR: 'dotnetcolor', + DOTTED_BOX: 'dottedbox', + DOWNLOAD: 'download', + DRIVES: 'drives', + DUPLICATE: 'duplicate', + EARTH: 'earth', + EASY: 'easy', + EDB_ARK: 'edbark', + EDB_BADGE: 'edbbadge', + EDB_BART: 'edbbart', + EDB_DASHBOARD: 'edbdashboard', + EDB_DOCS_LOGO_DISC_DARK: 'edbdocslogodiscdark', + EDB_EFM: 'edbefm', + EDB_EPAS: 'edbepas', + EDB_KUBERNETES: 'edbkubernetes', + EDB_LOGO_DISC_DARK: 'edblogodiscdark', + EDB_LOGO_SYMBOL_BADGE: 'edblogosymbolbadge', + EDB_MIGRATION_PORTAL: 'edbmigrationportal', + EDB_MIGRATION_TOOLKIT: 'edbmigrationtoolkit', + EDB_PEM: 'edbpem', + EDB_REPLICATE: 'edbreplicate', + EDB_REPLICATION: 'edbreplication', + EDB_SYMBOL: 'edbsymbol', + ELLIPSIS: 'ellipsis', + ENERGY: 'energy', + ENTERPRISE: 'enterprise', + EXPORT: 'export', + EXTERNAL_LINK: 'externallink', + FILE: 'file', + GLOBE: 'globe', + GOLANG_COLOR: 'golangcolor', + GUI: 'gui', + HADOOP: 'hadoop', + HAMBURGER: 'hamburger', + HANDSHAKE: 'handshake', + HARD_TO_FIND: 'hardtofind', + HASKELL_COLOR: 'haskellcolor', + HIGH_AVAILABILITY: 'highavailability', + HTML_COLOR: 'htmlcolor', + IDEA_SHARING: 'ideasharing', + IMPROVE: 'improve', + INSTALL: 'install', + INSTANCES: 'instances', + IOS_COLOR: 'ioscolor', + JAVA_COLOR: 'javacolor', + JAVA: 'java', + JAVASCRIPT_COLOR: 'javascriptcolor', + JQUERY_COLOR: 'jquerycolor', + KNIGHT: 'knight', + KOTLIN_COLOR: 'kotlincolor', + KUBERNETES: 'kubernetes', + LAPTOP_CONFIG: 'laptopconfig', + LARAVEL: 'laravel', + LEADER: 'leader', + LEARNING: 'learning', + LINKEDIN: 'linkedin', + LINUX_COLOR: 'linuxcolor', + MACOS_COLOR: 'macoscolor', + MANAGED_OPERATIONS: 'managedoperations', + MIGRATE: 'migrate', + MISSION: 'mission', + MODULE: 'module', + MOON: 'moon', + MORE_TEAM: 'moreteam', + NAME_TAG: 'nametag', + NETWORK: 'network', + NETWORK2: 'network2', + NEW_WINDOW: 'newwindow', + NEWS: 'news', + NODEJS_COLOR: 'nodejscolor', + NODEJS: 'nodejs', + NOT_FOUND: 'notfound', + OPTIONS: 'options', + PANDAS: 'pandas', + PARTNER: 'partner', + PDF: 'pdf', + PEOPLE: 'people', + PERL_COLOR: 'perlcolor', + PHP_COLOR: 'phpcolor', + PHP: 'php', + PIGGY_BANK: 'piggybank', + PLANNER: 'planner', + POSTGRES_SUPPORT: 'postgressupport', + POSTGRESQL: 'postgresql', + PRESENTATION: 'presentation', + PROCESS_IMPROVEMENT: 'processimprovement', + PULSE: 'pulse', + PYTHON_COLOR: 'pythoncolor', + PYTHON: 'python', + QUOTE_LEFT: 'quoteleft', + QUOTE_RIGHT: 'quoteright', + REACT_NATIVE_COLOR: 'reactnativecolor', + REDHAT_COLOR: 'redhatcolor', + REDHAT: 'redhat', + REMOTE_DBA: 'remotedba', + REPLICATION: 'replication', + ROCKET: 'rocket', + RUBY_COLOR: 'rubycolor', + RUBY: 'ruby', + SEARCH: 'search', + SECURITY_CONFIG: 'securityconfig', + SERVER_ERROR: 'servererror', + SPEED: 'speed', + SQL: 'sql', + STACK: 'stack', + STAR: 'star', + STORE: 'store', + SUBSET: 'subset', + SUN: 'sun', + SUPPORT_PORTAL: 'supportportal', + SUPPORT: 'support', + SUSE_COLOR: 'susecolor', + SWIFT_COLOR: 'swiftcolor', + SYNCHRONIZE: 'synchronize', + TEN_YEARS: 'tenyears', + TICKET_STAR: 'ticketstar', + TICKET: 'ticket', + TOOLS: 'tools', + TRAINING: 'training', + TREEHOUSE: 'treehouse', + TUTORIAL: 'tutorial', + TYPESCRIPT_COLOR: 'typescriptcolor', + UBUNTU_COLOR: 'ubuntucolor', + UNLOCK: 'unlock', + VENN: 'venn', + VUE_JS_COLOR: 'vuejscolor', + WEB_SECURITY: 'websecurity', + WEBINAR: 'webinar', + WINDOWS_COLOR: 'windowscolor', +}; +export default iconNames; diff --git a/src/components/icon/iconType.js b/src/components/icon/iconType.js new file mode 100644 index 00000000000..d4a7c33e320 --- /dev/null +++ b/src/components/icon/iconType.js @@ -0,0 +1,563 @@ +import React from 'react'; +import iconNames from './iconNames'; + +import AlertSvg from '../../../static/edb-icons/alert.svg'; +import AngularjsColorSvg from '../../../static/edb-icons/angularjs-color.svg'; +import AnnounceSvg from '../../../static/edb-icons/announce.svg'; +import ArrowLeftSvg from '../../../static/edb-icons/arrow-left.svg'; +import ArrowRightSvg from '../../../static/edb-icons/arrow-right.svg'; +import BarmanSvg from '../../../static/edb-icons/barman.svg'; +import BigDataSvg from '../../../static/edb-icons/big-data.svg'; +import BrainCircuitSvg from '../../../static/edb-icons/brain-circuit.svg'; +import BriefcaseSvg from '../../../static/edb-icons/briefcase.svg'; +import BusinessmanSvg from '../../../static/edb-icons/businessman.svg'; +import BusinesswomanSvg from '../../../static/edb-icons/businesswoman.svg'; +import CColorSvg from '../../../static/edb-icons/c-color.svg'; +import CPlusPlusColorSvg from '../../../static/edb-icons/c-plus-plus-color.svg'; +import CSharpColorSvg from '../../../static/edb-icons/c-sharp-color.svg'; +import CSharpSvg from '../../../static/edb-icons/c-sharp.svg'; +import CaseStudySvg from '../../../static/edb-icons/case-study.svg'; +import CentosColorSvg from '../../../static/edb-icons/centos-color.svg'; +import CertificateSvg from '../../../static/edb-icons/certificate.svg'; +import ChangeSvg from '../../../static/edb-icons/change.svg'; +import CheckmarkSvg from '../../../static/edb-icons/checkmark.svg'; +import ChevronDownSvg from '../../../static/edb-icons/chevron-down.svg'; +import ChevronRightSvg from '../../../static/edb-icons/chevron-right.svg'; +import CloseSvg from '../../../static/edb-icons/close.svg'; +import CloudCheckedSvg from '../../../static/edb-icons/cloud-checked.svg'; +import CloudDbSvg from '../../../static/edb-icons/cloud-db.svg'; +import CloudDbaSvg from '../../../static/edb-icons/cloud-dba.svg'; +import CloudPrivateSvg from '../../../static/edb-icons/cloud-private.svg'; +import CloudPublicSvg from '../../../static/edb-icons/cloud-public.svg'; +import CodeWritingSvg from '../../../static/edb-icons/code-writing.svg'; +import CoffeeSvg from '../../../static/edb-icons/coffee.svg'; +import ConfigManagementSvg from '../../../static/edb-icons/config-management.svg'; +import ConflictSvg from '../../../static/edb-icons/conflict.svg'; +import ConnectSvg from '../../../static/edb-icons/connect.svg'; +import ConsoleSvg from '../../../static/edb-icons/console.svg'; +import ContactSvg from '../../../static/edb-icons/contact.svg'; +import ContainerSvg from '../../../static/edb-icons/container.svg'; +import ControlSvg from '../../../static/edb-icons/control.svg'; +import ConvertSvg from '../../../static/edb-icons/convert.svg'; +import CrownSvg from '../../../static/edb-icons/crown.svg'; +import CubesSvg from '../../../static/edb-icons/cubes.svg'; +import CycleSvg from '../../../static/edb-icons/cycle.svg'; +import DataTransferSvg from '../../../static/edb-icons/data-transfer.svg'; +import DatabaseAdminSvg from '../../../static/edb-icons/database-admin.svg'; +import DatabaseBackupSvg from '../../../static/edb-icons/database-backup.svg'; +import DatabaseSvg from '../../../static/edb-icons/database.svg'; +import DebianColorSvg from '../../../static/edb-icons/debian-color.svg'; +import DeliverLoveSvg from '../../../static/edb-icons/deliver-love.svg'; +import DesignSvg from '../../../static/edb-icons/design.svg'; +import DeveloperSvg from '../../../static/edb-icons/developer.svg'; +import DiplomaSvg from '../../../static/edb-icons/diploma.svg'; +import DjangoColorSvg from '../../../static/edb-icons/django-color.svg'; +import DockerColorSvg from '../../../static/edb-icons/docker-color.svg'; +import DockerContainerSvg from '../../../static/edb-icons/docker-container.svg'; +import DocsSvg from '../../../static/edb-icons/docs.svg'; +import DotNetColorSvg from '../../../static/edb-icons/dot-net-color.svg'; +import DottedBoxSvg from '../../../static/edb-icons/dotted-box.svg'; +import DownloadSvg from '../../../static/edb-icons/download.svg'; +import DrivesSvg from '../../../static/edb-icons/drives.svg'; +import DuplicateSvg from '../../../static/edb-icons/duplicate.svg'; +import EarthSvg from '../../../static/edb-icons/earth.svg'; +import EasySvg from '../../../static/edb-icons/easy.svg'; +import EdbArkSvg from '../../../static/edb-icons/edb-ark.svg'; +import EdbBadgeSvg from '../../../static/edb-icons/edb-badge.svg'; +import EdbBartSvg from '../../../static/edb-icons/edb-bart.svg'; +import EdbDashboardSvg from '../../../static/edb-icons/edb-dashboard.svg'; +import EdbDocsLogoDiscDarkSvg from '../../../static/edb-icons/edb-docs-logo-disc-dark.svg'; +import EdbEfmSvg from '../../../static/edb-icons/edb-efm.svg'; +import EdbEpasSvg from '../../../static/edb-icons/edb-epas.svg'; +import EdbKubernetesSvg from '../../../static/edb-icons/edb-kubernetes.svg'; +import EdbLogoDiscDarkSvg from '../../../static/edb-icons/edb-logo-disc-dark.svg'; +import EdbLogoSymbolBadgeSvg from '../../../static/edb-icons/edb-logo-symbol-badge.svg'; +import EdbMigrationPortalSvg from '../../../static/edb-icons/edb-migration-portal.svg'; +import EdbMigrationToolkitSvg from '../../../static/edb-icons/edb-migration-toolkit.svg'; +import EdbPemSvg from '../../../static/edb-icons/edb-pem.svg'; +import EdbReplicateSvg from '../../../static/edb-icons/edb-replicate.svg'; +import EdbReplicationSvg from '../../../static/edb-icons/edb-replication.svg'; +import EdbSymbolSvg from '../../../static/edb-icons/edb-symbol.svg'; +import EllipsisSvg from '../../../static/edb-icons/ellipsis.svg'; +import EnergySvg from '../../../static/edb-icons/energy.svg'; +import EnterpriseSvg from '../../../static/edb-icons/enterprise.svg'; +import ExportSvg from '../../../static/edb-icons/export.svg'; +import ExternalLinkSvg from '../../../static/edb-icons/external-link.svg'; +import FileSvg from '../../../static/edb-icons/file.svg'; +import GlobeSvg from '../../../static/edb-icons/globe.svg'; +import GolangColorSvg from '../../../static/edb-icons/golang-color.svg'; +import GuiSvg from '../../../static/edb-icons/gui.svg'; +import HadoopSvg from '../../../static/edb-icons/hadoop.svg'; +import HamburgerSvg from '../../../static/edb-icons/hamburger.svg'; +import HandshakeSvg from '../../../static/edb-icons/handshake.svg'; +import HardToFindSvg from '../../../static/edb-icons/hard-to-find.svg'; +import HaskellColorSvg from '../../../static/edb-icons/haskell-color.svg'; +import HighAvailabilitySvg from '../../../static/edb-icons/high-availability.svg'; +import HtmlColorSvg from '../../../static/edb-icons/html-color.svg'; +import IdeaSharingSvg from '../../../static/edb-icons/idea-sharing.svg'; +import ImproveSvg from '../../../static/edb-icons/improve.svg'; +import InstallSvg from '../../../static/edb-icons/install.svg'; +import InstancesSvg from '../../../static/edb-icons/instances.svg'; +import IosColorSvg from '../../../static/edb-icons/ios-color.svg'; +import JavaColorSvg from '../../../static/edb-icons/java-color.svg'; +import JavaSvg from '../../../static/edb-icons/java.svg'; +import JavascriptColorSvg from '../../../static/edb-icons/javascript-color.svg'; +import JqueryColorSvg from '../../../static/edb-icons/jquery-color.svg'; +import KnightSvg from '../../../static/edb-icons/knight.svg'; +import KotlinColorSvg from '../../../static/edb-icons/kotlin-color.svg'; +import KubernetesSvg from '../../../static/edb-icons/kubernetes.svg'; +import LaptopConfigSvg from '../../../static/edb-icons/laptop-config.svg'; +import LaravelSvg from '../../../static/edb-icons/laravel.svg'; +import LeaderSvg from '../../../static/edb-icons/leader.svg'; +import LearningSvg from '../../../static/edb-icons/learning.svg'; +import LinkedinSvg from '../../../static/edb-icons/linkedin.svg'; +import LinuxColorSvg from '../../../static/edb-icons/linux-color.svg'; +import MacosColorSvg from '../../../static/edb-icons/macos-color.svg'; +import ManagedOperationsSvg from '../../../static/edb-icons/managed-operations.svg'; +import MigrateSvg from '../../../static/edb-icons/migrate.svg'; +import MissionSvg from '../../../static/edb-icons/mission.svg'; +import ModuleSvg from '../../../static/edb-icons/module.svg'; +import MoonSvg from '../../../static/edb-icons/moon.svg'; +import MoreTeamSvg from '../../../static/edb-icons/more-team.svg'; +import NameTagSvg from '../../../static/edb-icons/name-tag.svg'; +import NetworkSvg from '../../../static/edb-icons/network.svg'; +import Network2Svg from '../../../static/edb-icons/network2.svg'; +import NewWindowSvg from '../../../static/edb-icons/new-window.svg'; +import NewsSvg from '../../../static/edb-icons/news.svg'; +import NodejsColorSvg from '../../../static/edb-icons/nodejs-color.svg'; +import NodejsSvg from '../../../static/edb-icons/nodejs.svg'; +import NotFoundSvg from '../../../static/edb-icons/not-found.svg'; +import OptionsSvg from '../../../static/edb-icons/options.svg'; +import PandasSvg from '../../../static/edb-icons/pandas.svg'; +import PartnerSvg from '../../../static/edb-icons/partner.svg'; +import PdfSvg from '../../../static/edb-icons/pdf.svg'; +import PeopleSvg from '../../../static/edb-icons/people.svg'; +import PerlColorSvg from '../../../static/edb-icons/perl-color.svg'; +import PhpColorSvg from '../../../static/edb-icons/php-color.svg'; +import PhpSvg from '../../../static/edb-icons/php.svg'; +import PiggyBankSvg from '../../../static/edb-icons/piggy-bank.svg'; +import PlannerSvg from '../../../static/edb-icons/planner.svg'; +import PostgresSupportSvg from '../../../static/edb-icons/postgres-support.svg'; +import PostgresqlSvg from '../../../static/edb-icons/postgresql.svg'; +import PresentationSvg from '../../../static/edb-icons/presentation.svg'; +import ProcessImprovementSvg from '../../../static/edb-icons/process-improvement.svg'; +import PulseSvg from '../../../static/edb-icons/pulse.svg'; +import PythonColorSvg from '../../../static/edb-icons/python-color.svg'; +import PythonSvg from '../../../static/edb-icons/python.svg'; +import QuoteLeftSvg from '../../../static/edb-icons/quote-left.svg'; +import QuoteRightSvg from '../../../static/edb-icons/quote-right.svg'; +import ReactNativeColorSvg from '../../../static/edb-icons/react-native-color.svg'; +import RedhatColorSvg from '../../../static/edb-icons/redhat-color.svg'; +import RedhatSvg from '../../../static/edb-icons/redhat.svg'; +import RemoteDbaSvg from '../../../static/edb-icons/remote-dba.svg'; +import ReplicationSvg from '../../../static/edb-icons/replication.svg'; +import RocketSvg from '../../../static/edb-icons/rocket.svg'; +import RubyColorSvg from '../../../static/edb-icons/ruby-color.svg'; +import RubySvg from '../../../static/edb-icons/ruby.svg'; +import SearchSvg from '../../../static/edb-icons/search.svg'; +import SecurityConfigSvg from '../../../static/edb-icons/security-config.svg'; +import ServerErrorSvg from '../../../static/edb-icons/server-error.svg'; +import SpeedSvg from '../../../static/edb-icons/speed.svg'; +import SqlSvg from '../../../static/edb-icons/sql.svg'; +import StackSvg from '../../../static/edb-icons/stack.svg'; +import StarSvg from '../../../static/edb-icons/star.svg'; +import StoreSvg from '../../../static/edb-icons/store.svg'; +import SubsetSvg from '../../../static/edb-icons/subset.svg'; +import SunSvg from '../../../static/edb-icons/sun.svg'; +import SupportPortalSvg from '../../../static/edb-icons/support-portal.svg'; +import SupportSvg from '../../../static/edb-icons/support.svg'; +import SuseColorSvg from '../../../static/edb-icons/suse-color.svg'; +import SwiftColorSvg from '../../../static/edb-icons/swift-color.svg'; +import SynchronizeSvg from '../../../static/edb-icons/synchronize.svg'; +import TenYearsSvg from '../../../static/edb-icons/ten-years.svg'; +import TicketStarSvg from '../../../static/edb-icons/ticket-star.svg'; +import TicketSvg from '../../../static/edb-icons/ticket.svg'; +import ToolsSvg from '../../../static/edb-icons/tools.svg'; +import TrainingSvg from '../../../static/edb-icons/training.svg'; +import TreehouseSvg from '../../../static/edb-icons/treehouse.svg'; +import TutorialSvg from '../../../static/edb-icons/tutorial.svg'; +import TypescriptColorSvg from '../../../static/edb-icons/typescript-color.svg'; +import UbuntuColorSvg from '../../../static/edb-icons/ubuntu-color.svg'; +import UnlockSvg from '../../../static/edb-icons/unlock.svg'; +import VennSvg from '../../../static/edb-icons/venn.svg'; +import VueJsColorSvg from '../../../static/edb-icons/vue-js-color.svg'; +import WebSecuritySvg from '../../../static/edb-icons/web-security.svg'; +import WebinarSvg from '../../../static/edb-icons/webinar.svg'; +import WindowsColorSvg from '../../../static/edb-icons/windows-color.svg'; + +function formatIconName(name) { + return name && name.replace(/ /g, '').toLowerCase(); +} + +export default function IconType({ iconName, ...rest }) { + switch (formatIconName(iconName)) { + case iconNames.ALERT: + return ; + case iconNames.ANGULARJS_COLOR: + return ; + case iconNames.ANNOUNCE: + return ; + case iconNames.ARROW_LEFT: + return ; + case iconNames.ARROW_RIGHT: + return ; + case iconNames.BARMAN: + return ; + case iconNames.BIG_DATA: + return ; + case iconNames.BRAIN_CIRCUIT: + return ; + case iconNames.BRIEFCASE: + return ; + case iconNames.BUSINESSMAN: + return ; + case iconNames.BUSINESSWOMAN: + return ; + case iconNames.C_COLOR: + return ; + case iconNames.C_PLUS_PLUS_COLOR: + return ; + case iconNames.C_SHARP_COLOR: + return ; + case iconNames.C_SHARP: + return ; + case iconNames.CASE_STUDY: + return ; + case iconNames.CENTOS_COLOR: + return ; + case iconNames.CERTIFICATE: + return ; + case iconNames.CHANGE: + return ; + case iconNames.CHECKMARK: + return ; + case iconNames.CHEVRON_DOWN: + return ; + case iconNames.CHEVRON_RIGHT: + return ; + case iconNames.CLOSE: + return ; + case iconNames.CLOUD_CHECKED: + return ; + case iconNames.CLOUD_DB: + return ; + case iconNames.CLOUD_DBA: + return ; + case iconNames.CLOUD_PRIVATE: + return ; + case iconNames.CLOUD_PUBLIC: + return ; + case iconNames.CODE_WRITING: + return ; + case iconNames.COFFEE: + return ; + case iconNames.CONFIG_MANAGEMENT: + return ; + case iconNames.CONFLICT: + return ; + case iconNames.CONNECT: + return ; + case iconNames.CONSOLE: + return ; + case iconNames.CONTACT: + return ; + case iconNames.CONTAINER: + return ; + case iconNames.CONTROL: + return ; + case iconNames.CONVERT: + return ; + case iconNames.CROWN: + return ; + case iconNames.CUBES: + return ; + case iconNames.CYCLE: + return ; + case iconNames.DATA_TRANSFER: + return ; + case iconNames.DATABASE_ADMIN: + return ; + case iconNames.DATABASE_BACKUP: + return ; + case iconNames.DATABASE: + return ; + case iconNames.DEBIAN_COLOR: + return ; + case iconNames.DELIVER_LOVE: + return ; + case iconNames.DESIGN: + return ; + case iconNames.DEVELOPER: + return ; + case iconNames.DIPLOMA: + return ; + case iconNames.DJANGO_COLOR: + return ; + case iconNames.DOCKER_COLOR: + return ; + case iconNames.DOCKER_CONTAINER: + return ; + case iconNames.DOCS: + return ; + case iconNames.DOT_NET_COLOR: + return ; + case iconNames.DOTTED_BOX: + return ; + case iconNames.DOWNLOAD: + return ; + case iconNames.DRIVES: + return ; + case iconNames.DUPLICATE: + return ; + case iconNames.EARTH: + return ; + case iconNames.EASY: + return ; + case iconNames.EDB_ARK: + return ; + case iconNames.EDB_BADGE: + return ; + case iconNames.EDB_BART: + return ; + case iconNames.EDB_DASHBOARD: + return ; + case iconNames.EDB_DOCS_LOGO_DISC_DARK: + return ; + case iconNames.EDB_EFM: + return ; + case iconNames.EDB_EPAS: + return ; + case iconNames.EDB_KUBERNETES: + return ; + case iconNames.EDB_LOGO_DISC_DARK: + return ; + case iconNames.EDB_LOGO_SYMBOL_BADGE: + return ; + case iconNames.EDB_MIGRATION_PORTAL: + return ; + case iconNames.EDB_MIGRATION_TOOLKIT: + return ; + case iconNames.EDB_PEM: + return ; + case iconNames.EDB_REPLICATE: + return ; + case iconNames.EDB_REPLICATION: + return ; + case iconNames.EDB_SYMBOL: + return ; + case iconNames.ELLIPSIS: + return ; + case iconNames.ENERGY: + return ; + case iconNames.ENTERPRISE: + return ; + case iconNames.EXPORT: + return ; + case iconNames.EXTERNAL_LINK: + return ; + case iconNames.FILE: + return ; + case iconNames.GLOBE: + return ; + case iconNames.GOLANG_COLOR: + return ; + case iconNames.GUI: + return ; + case iconNames.HADOOP: + return ; + case iconNames.HAMBURGER: + return ; + case iconNames.HANDSHAKE: + return ; + case iconNames.HARD_TO_FIND: + return ; + case iconNames.HASKELL_COLOR: + return ; + case iconNames.HIGH_AVAILABILITY: + return ; + case iconNames.HTML_COLOR: + return ; + case iconNames.IDEA_SHARING: + return ; + case iconNames.IMPROVE: + return ; + case iconNames.INSTALL: + return ; + case iconNames.INSTANCES: + return ; + case iconNames.IOS_COLOR: + return ; + case iconNames.JAVA_COLOR: + return ; + case iconNames.JAVA: + return ; + case iconNames.JAVASCRIPT_COLOR: + return ; + case iconNames.JQUERY_COLOR: + return ; + case iconNames.KNIGHT: + return ; + case iconNames.KOTLIN_COLOR: + return ; + case iconNames.KUBERNETES: + return ; + case iconNames.LAPTOP_CONFIG: + return ; + case iconNames.LARAVEL: + return ; + case iconNames.LEADER: + return ; + case iconNames.LEARNING: + return ; + case iconNames.LINKEDIN: + return ; + case iconNames.LINUX_COLOR: + return ; + case iconNames.MACOS_COLOR: + return ; + case iconNames.MANAGED_OPERATIONS: + return ; + case iconNames.MIGRATE: + return ; + case iconNames.MISSION: + return ; + case iconNames.MODULE: + return ; + case iconNames.MOON: + return ; + case iconNames.MORE_TEAM: + return ; + case iconNames.NAME_TAG: + return ; + case iconNames.NETWORK: + return ; + case iconNames.NETWORK2: + return ; + case iconNames.NEW_WINDOW: + return ; + case iconNames.NEWS: + return ; + case iconNames.NODEJS_COLOR: + return ; + case iconNames.NODEJS: + return ; + case iconNames.NOT_FOUND: + return ; + case iconNames.OPTIONS: + return ; + case iconNames.PANDAS: + return ; + case iconNames.PARTNER: + return ; + case iconNames.PDF: + return ; + case iconNames.PEOPLE: + return ; + case iconNames.PERL_COLOR: + return ; + case iconNames.PHP_COLOR: + return ; + case iconNames.PHP: + return ; + case iconNames.PIGGY_BANK: + return ; + case iconNames.PLANNER: + return ; + case iconNames.POSTGRES_SUPPORT: + return ; + case iconNames.POSTGRESQL: + return ; + case iconNames.PRESENTATION: + return ; + case iconNames.PROCESS_IMPROVEMENT: + return ; + case iconNames.PULSE: + return ; + case iconNames.PYTHON_COLOR: + return ; + case iconNames.PYTHON: + return ; + case iconNames.QUOTE_LEFT: + return ; + case iconNames.QUOTE_RIGHT: + return ; + case iconNames.REACT_NATIVE_COLOR: + return ; + case iconNames.REDHAT_COLOR: + return ; + case iconNames.REDHAT: + return ; + case iconNames.REMOTE_DBA: + return ; + case iconNames.REPLICATION: + return ; + case iconNames.ROCKET: + return ; + case iconNames.RUBY_COLOR: + return ; + case iconNames.RUBY: + return ; + case iconNames.SEARCH: + return ; + case iconNames.SECURITY_CONFIG: + return ; + case iconNames.SERVER_ERROR: + return ; + case iconNames.SPEED: + return ; + case iconNames.SQL: + return ; + case iconNames.STACK: + return ; + case iconNames.STAR: + return ; + case iconNames.STORE: + return ; + case iconNames.SUBSET: + return ; + case iconNames.SUN: + return ; + case iconNames.SUPPORT_PORTAL: + return ; + case iconNames.SUPPORT: + return ; + case iconNames.SUSE_COLOR: + return ; + case iconNames.SWIFT_COLOR: + return ; + case iconNames.SYNCHRONIZE: + return ; + case iconNames.TEN_YEARS: + return ; + case iconNames.TICKET_STAR: + return ; + case iconNames.TICKET: + return ; + case iconNames.TOOLS: + return ; + case iconNames.TRAINING: + return ; + case iconNames.TREEHOUSE: + return ; + case iconNames.TUTORIAL: + return ; + case iconNames.TYPESCRIPT_COLOR: + return ; + case iconNames.UBUNTU_COLOR: + return ; + case iconNames.UNLOCK: + return ; + case iconNames.VENN: + return ; + case iconNames.VUE_JS_COLOR: + return ; + case iconNames.WEB_SECURITY: + return ; + case iconNames.WEBINAR: + return ; + case iconNames.WINDOWS_COLOR: + return ; + default: + return null; + } +} diff --git a/src/components/icon/index.js b/src/components/icon/index.js new file mode 100644 index 00000000000..183f18462ee --- /dev/null +++ b/src/components/icon/index.js @@ -0,0 +1,34 @@ +import React from 'react'; +import IconType from './iconType'; +import iconNames from './iconNames'; + +function Icon({ circle, circleClassName, circleDiameter, circleAutoMargin, ...rest }) { + if (circle && circleDiameter) { + return ( +
    + {IconType(rest)} +
    + ); + } else { + return IconType(rest); + } +} + +Icon.defaultProps = { + className: 'dottedbox', + circleClassName: '', + circleDiameter: 100, + circleAutoMargin: true, + circle: false, + width: 100, + height: 100, +}; + +export { + iconNames, +}; + +export default Icon; diff --git a/src/components/index-links.js b/src/components/index-links.js new file mode 100644 index 00000000000..168c6e83764 --- /dev/null +++ b/src/components/index-links.js @@ -0,0 +1,34 @@ +import React from 'react'; +import { Link } from './'; +import Icon, { iconNames } from './icon/'; + +const IndexLinks = ({ indexLinkList }) => ( + <> + {indexLinkList.map(section => { + return ( +
      +
    • + {section.sectionName} +
    • + {section.links.map(link => { + return ( +
    • + + + {link.title} + +
    • + ); + })} +
    + ); + })} + +); + +export default IndexLinks; diff --git a/src/components/index-sub-nav.js b/src/components/index-sub-nav.js new file mode 100644 index 00000000000..3029e45f8ac --- /dev/null +++ b/src/components/index-sub-nav.js @@ -0,0 +1,28 @@ +import React from 'react'; +import { DarkModeToggle, Link } from '../components'; + +const IndexSubLink = ({ url, children }) => ( +
  • + + {children} + +
  • +); + +const IndexSubNav = () => ( +
    +
      + EDB Home + + Support + + + Contact Us + + Have feedback? +
    + +
    +); + +export default IndexSubNav; diff --git a/src/components/index.js b/src/components/index.js new file mode 100644 index 00000000000..f8be29077e0 --- /dev/null +++ b/src/components/index.js @@ -0,0 +1,61 @@ +import BackButton from './back-button'; +import CardDecks from './card-decks'; +import CodeBlock from './code-block'; +import DarkModeToggle from './dark-mode-toggle'; +import DevOnly from './dev-only'; +import DevFrontmatter from './dev-frontmatter'; +import Footer from './footer'; +import IndexLinks from './index-links'; +import IndexSubNav from './index-sub-nav'; +import KatacodaPageEmbed from './katacoda-page-embed'; +import KatacodaPageLink from './katacoda-page-link'; +import KatacodaPanel from './katacoda-panel'; +import Layout from './layout'; +import LayoutContext from './layout-context'; +import LeftNav from './left-nav'; +import Link from './link'; +import Logo from './logo'; +import MainContent from './main-content'; +import PdfDownload from './pdf-download.js'; +import PrevNext from './prev-next'; +import SearchNavigationLinks from './search-navigation-links'; +import SearchNavigation from './search-navigation'; +import SideNavigation from './side-navigation'; +import StubCards from './stub-cards'; +import TableOfContents from './table-of-contents'; +import TextBalancer from './text-balancer'; +import TopBar from './top-bar'; +import TreeNode from './tree-node'; +import VersionDropdown from './version-dropdown'; + +export { + BackButton, + CardDecks, + CodeBlock, + DarkModeToggle, + DevOnly, + DevFrontmatter, + Footer, + IndexLinks, + IndexSubNav, + KatacodaPageEmbed, + KatacodaPageLink, + KatacodaPanel, + Layout, + LayoutContext, + LeftNav, + Link, + Logo, + MainContent, + PdfDownload, + PrevNext, + SearchNavigationLinks, + SearchNavigation, + SideNavigation, + StubCards, + TableOfContents, + TextBalancer, + TopBar, + TreeNode, + VersionDropdown, +}; diff --git a/src/components/katacoda-page-embed.js b/src/components/katacoda-page-embed.js new file mode 100644 index 00000000000..125cdd108b9 --- /dev/null +++ b/src/components/katacoda-page-embed.js @@ -0,0 +1,22 @@ +import React from 'react'; +import { Helmet } from 'react-helmet'; + +const KatacodaPageEmbed = ({ account, scenario }) => { + const scenarioId = account ? [account, scenario].join('/') : scenario; + + return ( + <> + +
  • + + + +
      + added to prevent self-closing tags in QtXmlPatterns + +
    +