403Webshell
Server IP : 216.92.14.13  /  Your IP : 216.73.216.171
Web Server : Apache
System : Linux vps4089.pairvps.com 5.15.0-190-generic #200-Ubuntu SMP Fri Aug 7 15:06:04 UTC 2026 x86_64
User : rmlac2fmr ( 1040637)
PHP Version : 8.2.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/local/bin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/local/bin/surrogate
#!/bin/bash
# surrogate
# loren carvalho, 2012

# explain the usage
function usage() { 
cat <<-EOF
	usage: $0 options

	This script must be run with sudo or as root, 
  it also expects some arguments, please oblige!

	OPTIONS:

	-h	Shows this message
	-b	Backup, either incremental or full, 
      "surrogate -b full" or "surrogate -b inc"
	-r 	Restore using default digest location
	-c 	Restore, accepts a file containing a list of directories to restore.
	
EOF
exit 1
}

# if there is no input, barf
[[ -z "$1" ]] && { usage; }

set -u

which innobackupex &> /dev/null

if [ $? -gt 0 ]; then
  echo "Can not find innobackupex!"
  echo "Please install Percona XtraBackup and try again"
  exit 1
fi

if [ "$(whoami)" != "root" ]; then
  if [ -f `which sudo` ]; then
    sudo $0 "$@"
    exit $?
  else
    usage
  fi
fi

# configs
source /etc/surrogate/surrogate.conf
source /etc/surrogate/xtrabackup.conf
source /usr/local/libexec/surrogate/surrogate

# create any missing directories
for dir in monthly weekly daily/Mon daily/Tue daily/Wed daily/Thu daily/Fri daily/Sat daily/Sun; do
  mkdir -p /usr/local/var/backups/$dir
done

# empty vars on initial call, can reuse init() if needed
function init() {
  type=""
  restore=""
  promote=""
}

init

# quietly run the rotation function
rotate_backups

function rebuild_configs_for_instance(){
  instance=$1
  echo "REBUILDING CONFIGS FOR $instance"
  mysql_data_path="$original_data_path/$instance"
  backup_directory="$original_backup_dir/$instance"
  mysql_collapse_path="$original_collapse_path/$instance"
  mysql_sanity_path="$original_sanity_path/$instance"
  inc_backup_path="$backup_directory/$today/inc_$now"
  last_backup=`tail -n1 $backup_directory/.digest`
  restore="$backup_directory/.digest"
}

# get input
while getopts "hb:rc:" option
do
  case $option in
  h)
    usage
  ;;
  b)
    type=$OPTARG
    if [[ "$type" == "full" ]]; then
      source /usr/local/libexec/surrogate/actions/full
    elif [[ "$type" == "inc" ]]; then
      source /usr/local/libexec/surrogate/actions/inc
    fi
  ;;
  r)
    source /usr/local/libexec/surrogate/actions/restore
  ;;
  c)
    restore=$OPTARG
    source /usr/local/libexec/surrogate/actions/restore
  ;;
  esac
done

count=0
for instance in $mysql_instances; do
  count=`expr $count + 1` 
done

# Check vars & perform the loaded action
original_data_path=$mysql_data_path
original_backup_dir=$backup_directory
original_collapse_path=$mysql_collapse_path
original_sanity_path=$mysql_sanity_path

if [ $count -gt 1 ]; then
  for instance in $mysql_instances; do
    echo "Processing instance: $instance"
    rebuild_configs_for_instance $instance
    perform_action $instance
  done
else
  socket=$mysql_socket
  if type perform_action 2>&1 > /dev/null; then
    perform_action $mysql_instances
  fi
fi

# fin

Youez - 2016 - github.com/yon3zu
LinuXploit