<commit_before>#!/bin/bash
# Quick backup report script
#
# Description: https://staffwiki.cpanel.net/bin/view/LinuxSupport/CPanelBackups
#
# How to run this script:
# curl -s --insecure https://raw.github.com/cPMarco/cpm/master/backup_report.sh | sh

# this shows backups enabled or disabled but i need to return the value to the check functions

backlogdir=/usr/local/cpanel/logs/cpbackup;

# check if new backups are enabled
function check_new_backups() {
 new_enabled=$(grep BACKUPENABLE /var/cpanel/backups/config 2>/dev/null | awk -F"'" '{print $2}')
 if [ "$new_enabled" == "yes" ]; then new_status='\033[1;32m'Enabled'\033[0m'
 else new_status='\033[1;31m'Disabled'\033[0m'
 fi
 echo -e "\nNew Backups = $new_status"
}

# check if legacy or new backups are enabled.  if each one is, then show how many users are skipped
function check_legacy_backups() {
 legacy_enabled=$(grep BACKUPENABLE /etc/cpbackup.conf | awk '{print $2'})
 if [ $legacy_enabled == "yes" ]; then legacy_status='\033[1;32m'Enabled'\033[0m'
 else legacy_status='\033[1;31m'Disabled'\033[0m'
 fi
 echo -e "Legacy Backups = $legacy_status";
}

# look at start, end times.  print number of users where backup was attempted
function print_start_end_times () {
echo -e "\nCurrent Backup Logs in "$backlogdir":\n"
if [ -e $backlogdir ]; then
 cd $backlogdir;
 for i in `\ls`; do
  echo -n $i": "; grep "Started" $i; echo -n "Ended ";
  \ls -lrth | grep $i | awk '{print $6" "$7" "$8}';
  echo -ne " Number of users backed up:\t";  grep "user :" $i | wc -l;
 done;
 echo -e "\nTotal users:"; wc -l /etc/trueuserdomains;
fi;
}

function list_legacy_exceptions() {
legacy_users=$(grep "LEGACY_BACKUP=1" /var/cpanel/users/* | wc -l);
if [ $legacy_enabled == "yes" ]; then
 echo -e "\nLegacy Backups Exceptions";
 oldxs=$(egrep "LEGACY_BACKUP=0" /var/cpanel/users/* | wc -l);
 if [ $oldxs -gt 0 ]; then echo "Number of real Legacy backup exceptions: "$oldxs; fi;
 skip_file_ct=$(wc -l /etc/cpbackup-userskip.conf 2>/dev/null)
 if [ -n "$skip_file_ct" ]; then echo -e "\nExtra Information: This skip file should no longer be used"$skip_file_ct; fi
elif [ $legacy_users -gt 0 -a $legacy_status == "Disabled" ]; then
 echo -e "\nExtra Information: Legacy Backups aren't enabled, but there are $legacy_users users ready to use them."
fi<commit_msg>changing == to = for posix compliance<commit_after>#!/bin/bash
# Quick backup report script
#
# Description: https://staffwiki.cpanel.net/bin/view/LinuxSupport/CPanelBackups
#
# How to run this script:
# curl -s --insecure https://raw.github.com/cPMarco/cpm/master/backup_report.sh | sh

# this shows backups enabled or disabled but i need to return the value to the check functions

backlogdir=/usr/local/cpanel/logs/cpbackup;

# check if new backups are enabled
function check_new_backups() {
 new_enabled=$(grep BACKUPENABLE /var/cpanel/backups/config 2>/dev/null | awk -F"'" '{print $2}')
 if [ "$new_enabled" = "yes" ]; then new_status='\033[1;32m'Enabled'\033[0m'
 else new_status='\033[1;31m'Disabled'\033[0m'
 fi
 echo -e "\nNew Backups = $new_status"
}

# check if legacy or new backups are enabled.  if each one is, then show how many users are skipped
function check_legacy_backups() {
 legacy_enabled=$(grep BACKUPENABLE /etc/cpbackup.conf | awk '{print $2'})
 if [ $legacy_enabled = "yes" ]; then legacy_status='\033[1;32m'Enabled'\033[0m'
 else legacy_status='\033[1;31m'Disabled'\033[0m'
 fi
 echo -e "Legacy Backups = $legacy_status";
}

# look at start, end times.  print number of users where backup was attempted
function print_start_end_times () {
echo -e "\nCurrent Backup Logs in "$backlogdir":\n"
if [ -e $backlogdir ]; then
 cd $backlogdir;
 for i in `\ls`; do
  echo -n $i": "; grep "Started" $i; echo -n "Ended ";
  \ls -lrth | grep $i | awk '{print $6" "$7" "$8}';
  echo -ne " Number of users backed up:\t";  grep "user :" $i | wc -l;
 done;
 echo -e "\nTotal users:"; wc -l /etc/trueuserdomains;
fi;
}

function list_legacy_exceptions() {
legacy_users=$(grep "LEGACY_BACKUP=1" /var/cpanel/users/* | wc -l);
if [ $legacy_enabled == "yes" ]; then
 echo -e "\nLegacy Backups Exceptions";
 oldxs=$(egrep "LEGACY_BACKUP=0" /var/cpanel/users/* | wc -l);
 if [ $oldxs -gt 0 ]; then echo "Number of real Legacy backup exceptions: "$oldxs; fi;
 skip_file_ct=$(wc -l /etc/cpbackup-userskip.conf 2>/dev/null)
 if [ -n "$skip_file_ct" ]; then echo -e "\nExtra Information: This skip file should no longer be used"$skip_file_ct; fi
elif [ $legacy_users -gt 0 -a $legacy_status == "Disabled" ]; then
 echo -e "\nExtra Information: Legacy Backups aren't enabled, but there are $legacy_users users ready to use them."
fi
{'fraction_non_alphanumeric': 0.15008613264427217, 'fraction_numerical': 0.021963824289405683, 'mean_word_length': 4.272417707150965, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '757006', 'n_tokens_mistral': 1742, 'n_tokens_neox': 1671, 'n_words': 519}