Vertica Backup script
search cancel

Vertica Backup script

book

Article ID: 281805

calendar_today

Updated On: 06-20-2024

Products

Network Observability

Issue/Introduction

Backing up your Vertica database is essential for data protection and disaster recovery. This Knowledge Base article

provides step-by-step instructions for setting up a backup script for your Vertica database using the vbr.py utility.

Environment

DX NetOps Performance Management All Releases

Resolution

Prerequisites:

  • Access to the Vertica database server
  • Basic knowledge of Linux shell scripting

Steps:

  1. Create a Backup Script:
  2. Open a text editor on your Vertica database server.
  3. Copy and paste the following script into the text editor:

#!/bin/bash

# Define variables
VERTICA_USER="dbadmin"
VERTICA_PASSWORD="your_password"
BACKUP_DESTINATION="/path/to/backup/directory"
LOG_FILE="/path/to/log/backup.log"
CONFIG_FILE="/etc/vbr.ini"

# Set the environment variables
export VERTICADATA=/your/vertica/data/directory

# Run the backup using vbr.py utility
/usr/local/vertica/bin/vbr.py --task backup --config-file $CONFIG_FILE --backup-target $BACKUP_DESTINATION --no-validation -p $VERTICA_PASSWORD -d

# Check the backup status
if [ $? -eq 0 ]; then
    echo "$(date +"%Y-%m-%d %H:%M:%S") Backup succeeded" >> $LOG_FILE
    # Validate backup integrity
    /usr/local/vertica/bin/vbr.py --task full-check --config-file $CONFIG_FILE
    # Compress the backup file
    tar -czf $BACKUP_DESTINATION/backup_$(date +"%Y%m%d%H%M%S").tar.gz $BACKUP_DESTINATION/*.tar
    # Remove uncompressed backup file
    rm $BACKUP_DESTINATION/*.tar
else
    echo "$(date +"%Y-%m-%d %H:%M:%S") Backup failed" >> $LOG_FILE
fi

  • Modify Script Variables:
  • Replace VERTICA_PASSWORD, BACKUP_DESTINATION, LOG_FILE, and CONFIG_FILE with appropriate values.
  • Ensure that VERTICADATA points to your Vertica data directory.
  • Save and Make the Script Executable:
  • Save the script with a .sh extension (e.g., backup_script.sh).
  • Make the script executable by running the following command:
  • chmod +x backup_script.sh
  • Schedule Backup:
  • Use cron or another scheduling tool to schedule the script to run at appropriate intervals (e.g., daily).

 

Additional Information

NOTE -

  • The script is provided as is and may need adjustments based on your environment and we do not support the script or enhancements to the script.
  • Ensure proper permissions are set for accessing backup locations and executing the script.
  • Test the backup script in a non-production environment before deploying it in production.
  • For further assistance or troubleshooting, refer to Vertica documentation or consult with your Linux administrator.