XYBRCODE

RANDOM BITS

Search Results

Installing MS SQL Drivers for PHP on Mac OS

  1. brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release
  2. brew update
  3. brew install –no-sandbox msodbcsql
  4. brew install php@7.2
  5. sudo pecl install sqlsrv pdo_sqlsrv
  6. edit /etc/php.ini.default & add extension=sqlsrv.so and extension=pdo_sqlsrv.so

Wildfly Swarm Self-Signed SSL Config

Maven Dependency

<dependency>
    <groupId>org.wildfly.swarm</groupId>
    <artifactId>management</artifactId>
    <version>${version.wildfly.swarm}</version>
</dependency>

project-defaults.yml

swarm:
  https:
    certificate:
      generate: true
    keystore:
      embedded: true

Wildfly takes care of the rest!

Linux Mysql Backup Script

Use with cron on a daily schedule and to keep 90 days worth of dumps

#!/bin/bash
SERVER=$1
DATABASE=$2
PASSWORD=$3
EMAIL=$4
DATE=$(date +%Y-%m-%d) # TODAYS DATE
FOLDER=/backups/$SERVER/$DATABASE # FOLDER FOR BACKUPS
FILENAME=$FOLDER/$DATE.sql # FILENAME FOR BACKUPS
NUMDAYS=90 # NUMBER OF DAYS TO KEEP

mkdir -p $FOLDER

echo "CREATE DATABASE $DATABASE;" > $filename
echo "USE $DATABASE;" >>  $filename
mysqldump -q --routines --skip-triggers -h $SERVER -u root -p$PASSWORD $DATABASE  >> $FILENAME
EXITCODE=$?

if [ $EXITCODE -ne 0 ] ; then

        #EMAIL
        cat << EOF |
        Subject:$DATABASE Backup Failed
        Backup Failed with exit code $EXITCODE
        EOF
        /usr/sbin/ssmtp $EMAIL
        
else

        FILESIZE=$(du -h $FILENAME)
        
        #CLEAN UP
        NUMFILES=$(find $FOLDER -type f | wc -l)
        DIF=$(expr $NUMFILES - $NUMDAYS)
        
        if [ $DIF -gt 0 ] ; then
                find $FOLDER -type f | sort -r | tail -n $DIF > tmp.txt
                FILESTOREMOVE=$(<tmp.txt)
                cat tmp.txt | xargs rm
                rm tmp.txt
        fi
        
        #EMAIL
        cat << EOF |
        Subject:$DATABASE Backup Complete
        Backup Completed Successfully ($FILESIZE)
        
        Files Removed:
        $FILESTOREMOVE
        EOF
        /usr/sbin/ssmtp $EMAIL
        
fi