On a linux system we are unable to run ghost
search cancel

On a linux system we are unable to run ghost

book

Article ID: 278064

calendar_today

Updated On:

Products

Ghost Solution Suite

Issue/Introduction

Unable to run ghost on a Linux machine

Environment

GSS 3.x

DS 8.x

Cause

Using non-supported drives

Resolution

Use tar commands to image the drive

Example backup script to use: (also attached at bottom of this document )

#!/usr/bin/env bash

print_help() {
    echo "Usage: $0 [OPTIONS]"
    echo "  -h          Display this help message"
    echo "  -s DEVICE   Specify source device to backup"
    echo "  -d DIR      Specify output directory"
    echo ""
    echo "Example: $0 -s /dev/sda -d /mnt/gss/backup"
    exit 0
}

cleanup () {
    if [ ! -z ${MOUNTPOINT} ] && [ -d ${MOUNTPOINT} ]; then
        if grep -qs ${MOUNTPOINT} /proc/mounts; then    
            umount ${MOUNTPOINT}
        fi
        rmdir ${MOUNTPOINT}
    fi
}

try_backup_partition() {
    PARTITION=$1

    if mount ${PARTITION} ${MOUNTPOINT} 2> /dev/null ; then
        backup_partition ${PARTITION}
        umount ${MOUNTPOINT}
    fi
}

backup_partition() {
    PARTITION=$1
    #detect filesystem
    FS_TYPE=$(blkid -o value -s TYPE ${PARTITION})

    DEST_FILE_NAME=${DESTINATION_FOLDER}/$(basename ${PARTITION}).tgz

    #test that tar has checkpoint support
    TAR_ADDITIONAL_OPTIONS=""
    CHECKPOINT_SUPPORT=$(tar --help | grep -c checkpoint)
    if [ ! ${CHECKPOINT_SUPPORT} -eq 0 ]; then
        TAR_ADDITIONAL_OPTIONS="--checkpoint=1000 --checkpoint-action=dot"
    fi

    echo "Backing up ${PARTITION} (${FS_TYPE}) to ${DEST_FILE_NAME} ..."
    #tar backup
    tar -cpzf ${DEST_FILE_NAME} ${TAR_ADDITIONAL_OPTIONS} -C ${MOUNTPOINT} .

    echo ""
}

backup_device() {
    #enumerate all physical devices
    for part in $(ls ${SOURCE_DEVICE}?)
    do
        try_backup_partition ${part}
    done

    #enumerate lvm devices
    for part in $(ls /dev/mapper/*)
    do
        try_backup_partition ${part}
    done
}

SOURCE_DEVICE=""
DESTINATION_FOLDER=""

while getopts "hs:d:" opt; do
    case "$opt" in
    h)  print_help
        exit 0
        ;;
    s)  SOURCE_DEVICE="$OPTARG"
        ;;
    d)  DESTINATION_FOLDER="$OPTARG"
        ;;
    *)  # Any other option will exit with an error
        echo "Invalid option or option requires an argument."
        echo "Use -h for help."
        exit 1
        ;;
    esac
done

#check for root
if [ "$(id -u)" != "0" ]; then
    echo "This script must be run as root."
    exit 1
fi

#check source device
if [ -z "${SOURCE_DEVICE}" ]; then
    echo "Source device not specified."
    echo "Use -h for help."
    exit 1
fi

#chech that source device is a block device
if [ ! -b "${SOURCE_DEVICE}" ]; then
    echo "Source device is not a block device."
    echo "Use -h for help."
    exit 1
fi

#check destination folder
if [ -z "${DESTINATION_FOLDER}" ]; then
    echo "Destination folder not specified."
    echo "Use -h for help."
    exit 1
fi

#check that destination folder exists
if [ ! -d "${DESTINATION_FOLDER}" ]; then
    echo "Destination folder does not exist."
    echo "Use -h for help."
    exit 1
fi

#crreate temporary folder in /mnt
MOUNTPOINT=$(mktemp -d /mnt/dbackup.XXXXXX)

#set trap for cleanup
trap cleanup EXIT

backup_device

Additional Information

Download gssbackup.sh

Attachments

gssbackup.sh get_app