#!/bin/bash USER_ROOT=/home/fasoonli CONFIG_FILE="$USER_ROOT/backup-config" . $CONFIG_FILE if [ $# -eq 0 ]; then echo -e "Usage: $0 BACKUP_NAME\nPlease use ./$SCRIPT_LIST to view available backups" exit 1 fi BACKUP_NAME="$1" FOUND=$(find_backup_by_name "$BACKUP_NAME") if [[ "$FOUND" == "" ]]; then echo -e "No backup \"$BACKUP_NAME\" found.\nPlease use ./$SCRIPT_LIST to view available backups" exit 2 fi BACKUP_NAME_Q="$FOUND" BACKUP_PATH="$BACKUP_ROOT/$BACKUP_NAME_Q" BACKUP_PATH_FILES="$BACKUP_PATH/files" BACKUP_PATH_DB="$BACKUP_PATH/db" #echo "--> $BACKUP_PATH <--" #good to go #restore databases #uses credentials from .my.cnf for db_name in $DB_NAMES; do echo Restoring "$db_name" #echo "$ZCAT "'"'"$BACKUP_PATH_DB/$db_name.sql.gz"'"'" | $MYSQL "'"'"$db_name"'"' $ZCAT "$BACKUP_PATH_DB/$db_name.sql.gz" | $MYSQL "$db_name" done #restore files, only public_html for now $RSYNC -av --delete "$BACKUP_PATH_FILES/public_html/" "$USER_ROOT/public_html/" echo Done!