403Webshell
Server IP : 188.151.22.197  /  Your IP : 216.73.217.74
Web Server : Apache/2.4.62 (Rocky Linux) OpenSSL/3.5.5
System : Linux wsten.se 5.14.0-687.30.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Jul 27 13:09:21 UTC 2026 x86_64
User : apache ( 48)
PHP Version : 8.1.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /proc/self/root/usr/bin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/self/root/usr/bin/gitlab-backup
#!/usr/bin/env bash

VERBOSE=1

##
## usage [SUBCOMMAND]
##
##   Prints out SUBCOMMAND usage and exits with code `0`. Prints the general
##   usage when SUBCOMMAND is missing.
##
usage() {
  case "${1}" in
    create)
      echo 'Usage: gitlab-backup create [OPTIONS]'
      echo
      echo "  Create a new backup. Wrapper for \`gitlab-rake gitlab:backup:create\`."
      echo
      echo 'OPTIONS:'
      echo
      echo '  -h, --help    Display this help message and exits,'
      echo
      echo '  Additional OPTIONS are passed to the underlying command.'
      ;;
    restore)
      echo 'Usage: gitlab-backup restore [OPTIONS]'
      echo
      echo "  Restore from a backup. Wrapper for \`gitlab-rake gitlab:backup:restore\`."
      echo
      echo '  Automatically changes the ownership of registry directory (when enabled)'
      echo '  to ensure filesytem permissions are correct.'
      echo
      echo 'OPTIONS:'
      echo
      echo '  -h, --help    Display this help message and exits.'
      echo
      echo '  Additional OPTIONS passed to the underlying command.'
      ;;
    *)
      echo 'Usage: gitlab-backup COMMAND [OPTIONS]'
      echo
      echo 'OPTIONS:'
      echo
      echo "  -h, --help    Display this help message and exits. Use \`COMMAND --help\`"
      echo '                for more information on a command.'
      echo
      echo 'COMMANDS:'
      echo '  create        Creates a new backup.'
      echo '  restore       Restores from a backup.'
      ;;
  esac
  exit 0
}

##
## chown_registry USER
##
##   Transfers ownership of registry directory to USER.
##
chown_registry() {
  [ ${VERBOSE} -gt 0 ] && printf 'Transfering ownership of %s to %s\n' "${registry_dir}" "${1}"
  chown -R "${1}" "${registry_dir}"
}

##
## backup_create ARGS 
##
##   Calls `gitlab-rake gitlab:backup:create` and passess ARGS to it.
##
backup_create() {

  # Print usage if help flag is present.
  case "${1}" in
    -h|--help)
      shift
      usage 'create'
      ;;
    *)
      ;;
  esac

  /opt/gitlab/bin/gitlab-rake gitlab:backup:create ${@}
}

##
## backup_restore ARGS 
##
##   Calls `gitlab-rake gitlab:backup:restore` and passess ARGS to it. Also,
##   registers hooks to change ownership of registry directory before and 
##   after restore.
##
backup_restore() {

  # Print usage if help flag is present.
  case "${1}" in
    -h|--help)
      shift
      usage 'restore'
      ;;
    *)
      ;;
  esac

  if [ -n "${registry_dir}" ]; then
    # Transfer ownership to git user to ensure that recovery won't fail on 
    # the existing registry
    chown_registry ${gitlab_user}

    # Transfer ownership back to registry user when restore task is finished.
    trap "chown_registry ${registry_user}" EXIT
  fi

  /opt/gitlab/bin/gitlab-rake gitlab:backup:restore ${@}
}

# Load gitlab-rails-rc
gitlab_rails_rc='/opt/gitlab/etc/gitlab-rails-rc'
if ! [ -f ${gitlab_rails_rc} ] ; then
  >&2 echo "${0} error: could not load ${gitlab_rails_rc}"
  >&2 echo 'Either you are not allowed to read the file, or it does not exist yet.'
  >&2 echo "You can generate it with \`sudo gitlab-ctl reconfigure\`"
  exit 2
fi

. ${gitlab_rails_rc}

# Parse general options and sub-command.
while (( "${#}" )); do
  case "${1}" in
    -h|--help)
      shift
      usage
      ;;
    --)
      shift
      break
      ;;
    -*|--*)
      >&2 echo "Unsupported option: ${1}"
      exit 1
      ;;
    *)
      break
      ;;
  esac
done

subcommand=${1:-create}
shift

# Run subcommand
case "${subcommand}" in
  create)
    backup_create ${@}
    ;;
  restore)
    backup_restore ${@}
    ;;
  *)
    >&2 echo "Unknown command: ${subcommand}"
    exit 1
    ;;
esac

Youez - 2016 - github.com/yon3zu
LinuXploit