/usr/sbin/cleandb is in hybserv 1.9.5-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | #!/bin/sh
#
# Hybserv2 Services by Hybserv2 team
#
# This script will remove all backup directories created
# from past months. Directories created in the current month
# will not be touched. The idea is to keep the backup
# directory looking neat, instead of having hundreds of
# different directories with similar database backups :-)
#
# Usage: ./cleandb [[ -h | --help ] | [[ -c | --confirm]
# [backup-directory]]]
#
# The --confirm option will cause the script to ask for
# confirmation for each directory being deleted.
# Set this to the default backup directory
BackupDir="/var/backups/hybserv/"
# Don't touch anything below here
# Initialize some variables
confirm=""
datecheck="$(date '+%Y%m')"
default="y"
count=0
if [ "x$1" != "x" ]; then
  case "$1" in
    -c | --confirm)
      confirm="yes"
      if [ "x$2" != "x" ]; then
        BackupDir="$2"
      fi
    ;;
    -h | --help)
      echo "Usage: $0 [-h | -c] [backup-dir]"
      echo "  -h | --help    : display this help screen"
      echo "  -c | --confirm : ask for confirmation before deleting directories"
      exit 0
    ;;
    *)
      BackupDir="$1"
    ;;
  esac
fi
if [ ! -d "$BackupDir" ]; then
  echo "Invalid directory: $BackupDir"
  exit 0
fi
cd "$BackupDir"
# Use echo here to take the \n characters out of the ls output
# and replace them with spaces. This probably isn't the best
# way to do it :-/
directories=`echo *`
for backdir in $directories; do
  # If the length of $backdir is not 8, it does not satisfy
  # the YYYYMMDD form, assume we are in the wrong directory and
  # exit because we don't want to delete something important, etc
  if [ "${#backdir}" != "8" ]; then
    echo "$BackupDir: $backdir is an invalid backup directory, exiting"
    exit 1
  fi
  # Check to make sure the file we're about to delete is
  # actually a directory. The backup directory should contain
  # ONLY sub-directories, so if we come across a regular file etc,
  # we are probably in the wrong place.
  if [ ! -d "${backdir}" ]; then
    echo "$BackupDir: $backdir is an invalid backup directory, exiting"
    exit 1
  fi
  # Set tmp to the first 6 letters of $backdir (the first
  # six letters will be the year and month: YYYYMM)
  tmp=`echo "$backdir" | cut -c1-6`
  # If the YYYYMM of the current directory does not match
  # the current year/month ($datecheck) delete the directory
  if [ "$tmp" != "$datecheck" ]; then
    if [ "x$confirm" = "xyes" ]; then
      gotyn=0
      while [ $gotyn -eq 0 ]; do
        echo -n "Remove $backdir? [$default] "
        read Input
        if [ "x$Input" != "x" ]; then
          Input="$default"
        fi
        case "$Input" in
          n* | N* | y* | Y*)
            gotyn=1
            ;;
          *)
            echo "Please enter \"yes\" or \"no\""
            ;;
        esac
      done
      case "$Input" in
        n* | N*)
          echo "Skipping $backdir..."
          continue
          ;;
      esac
    fi
    # Delete the old directory
    echo "Removing $backdir..."
    rm -rf $backdir
    count=`expr $count + 1`
  fi
done
echo "Deleted $count directories in $BackupDir"
 |