BDS Software

Linux Server bash Scripts

Here are some representative bash scripts which I use on my primary onsite Linux server (aka "Sleepy").

These are presented solely as examples for your reference, and completely without external comment.

-----

#! /usr/bin/bash

#####
#
# backupKJVData.bsh
# MDJ 2022/04/06
#
# Backs Up the KJVData
# database to the
# /home/mdavidjohnson/Backups
# directory
#
# To Run:
# backupKJVData.bsh
#
# ** WARNING **
# When saving bash scripts in
# Textpad, you ** MUST ** use
# the "Save As" command and
# change the Line Ending Box
# to "UNIX".
#
# Otherwise, you get:
# /usr/bin/bash^M No such file
# ( ^M = \r\n ).
#
#####

echo "\nStarting backup of KJVData database\n"
dateToday=$(date +%Y-%m-%d)

echo "Raw Section\n"
echo " ** sudo password required\n"
sourceDir='/var/lib/mysql/KJVData'
rawLoc='/home/mdavidjohnson/Backups/DatabaseBackups/KJVData/Raw/'
rawDir=$rawLoc'KJVData'$dateToday
# Effectively cp and chown at the same time:
sudo rsync -air --chown=mdavidjohnson $sourceDir $rawDir

echo "Dump Section\n"
echo " ** mysql password required\n"
sourceDB='KJVData'
dumpLoc='/home/mdavidjohnson/Backups/DatabaseBackups/KJVData/Dumps/'
dumpFile='KJVData'$dateToday
/usr/bin/mysqldump --user='mdavidjohnson' --password \
--databases $sourceDB > $dumpLoc$dumpFile

# Copy the backups to the External 4TB HDD
echo "External Section\n"
sudo cp -uR /home/mdavidjohnson/Backups \
/media/mdavidjohnson/Elements/workingdir/BackupOfBackups

echo "Backup complete\n\n"

#####
#
# EOF
#
#####

-----

#! /usr/bin/bash

#####
#
# cdMiscTesting.bsh
# MDJ 2022/05/30
#
# Changes working directory to
# external drive's MiscTesting
# subdirectory.
#
# To Run, execute source command, i.e.
# . cdMiscTesting.bsh
#
# ** WARNING **
# When saving bash scripts in
# Textpad, you ** MUST ** use
# the "Save As" command and
# change the Line Ending Box
# to "UNIX".
#
# Otherwise, you get:
# /usr/bin/bash^M No such file
# ( ^M = \r\n ).
#
#####

cd "/media/mdavidjohnson/Elements/workingdir/MiscTesting";

#####
#
# EOF
#
#####

-----

#! /usr/bin/bash

#####
#
# cdTenMinute.bsh
# MDJ 2022/05/30
#
# Changes working directory to
# external drive's
# TenMinuteSeries subdirectory.
#
# To Run, execute source command, i.e.
# . cdTenMinute.bsh
#
# ** WARNING **
# When saving bash scripts in
# Textpad, you ** MUST ** use
# the "Save As" command and
# change the Line Ending Box
# to "UNIX".
#
# Otherwise, you get:
# /usr/bin/bash^M No such file
# ( ^M = \r\n ).
#
#####

cd "/media/mdavidjohnson/Elements/workingdir/Bible/TenMinuteSeries";

#####
#
# EOF
#
#####

-----

#! /usr/bin/bash

#####
#
# tenMinSetUp.bsh
# MDJ 2022/05/30
#
# Cycles through the
# external drive's
# TenMinuteSeries directory's.
# subdirectories and runs
# setup.pl on each
#
# To Run:
# . cdTenMinute.bsh
# tenMinSetUp.bsh
#
# ** WARNING **
# When saving bash scripts in
# Textpad, you ** MUST ** use
# the "Save As" command and

# change the Line Ending Box
# to "UNIX".
#
# Otherwise, you get:
# /usr/bin/bash^M No such file
# ( ^M = \r\n ).
#
#####

cd "01GENPartA";
#setup.pl;
cd "../01GENPartB";
#setup.pl;
cd "../01GENPartC";
#setup.pl;
cd "../01GENPartD";
#setup.pl;
cd "../01GENPartE";
#setup.pl;
cd "../02EXOPartA";
setup.pl;
cd "../02EXOPartB";
setup.pl;
cd "../02EXOPartC";
setup.pl;
cd "../02EXOPartD";
setup.pl;
cd "../03LEVPartA";
setup.pl;
cd "../03LEVPartB";
setup.pl;
cd "../03LEVPartC";
setup.pl;
cd "../04NUMPartA";
setup.pl;
cd "../04NUMPartB";
setup.pl;
cd "../04NUMPartC";
setup.pl;
cd "../04NUMPartD";
setup.pl;
cd "../05DEUPartA";
setup.pl;
cd "../05DEUPartB";
setup.pl;
cd "../05DEUPartC";
setup.pl;
cd "../06JOSPartA";
setup.pl;
cd "../06JOSPartB";
setup.pl;
cd "../07JDGPartA";
setup.pl;
cd "../07JDGPartB";
setup.pl;
cd "../08RUTPartA";
setup.pl;
cd "../09A1SAPartA";
setup.pl;
cd "../09A1SAPartB";
setup.pl;
cd "../09A1SAPartC";
setup.pl;
cd "../10A2SAPartA";
setup.pl;
cd "../10A2SAPartB";
setup.pl;
cd "../11A1KIPartA";
setup.pl;
cd "../11A1KIPartB";
setup.pl;
cd "../11A1KIPartC";
setup.pl;
cd "../12A2KIPartA";
setup.pl;
cd "../12A2KIPartB";
setup.pl;
cd "../12A2KIPartC";
setup.pl;
cd "../13A1CHPartA";
setup.pl;
cd "../13A1CHPartB";
setup.pl;
cd "../13A1CHPartC";
setup.pl;
cd "../14A2CHPartA";
setup.pl;
cd "../14A2CHPartB";
setup.pl;
cd "../14A2CHPartC";
setup.pl;
cd "../15EZRPartA";
setup.pl;
cd "../16NEHPartA";
setup.pl;
cd "../16NEHPartB";
setup.pl;
cd "../17ESTPartA";
setup.pl;
cd "../18JOBPartA";
setup.pl;
cd "../18JOBPartB";
setup.pl;
cd "../18JOBPartC";
setup.pl;
cd "../18JOBPartD";
setup.pl;
cd "../19PSAPartA";
setup.pl;
cd "../19PSAPartB";
setup.pl;
cd "../19PSAPartC";
setup.pl;
cd "../19PSAPartD";
setup.pl;
cd "../19PSAPartE";
setup.pl;
cd "../19PSAPartF";
setup.pl;
cd "../19PSAPartG";
setup.pl;
cd "../19PSAPartH";
setup.pl;
cd "../20PROPartA";
setup.pl;
cd "../20PROPartB";
setup.pl;
cd "../20PROPartC";
setup.pl;
cd "../21ECCPartA";
setup.pl;
cd "../22SONPartA";
setup.pl;
cd "../23ISAPartA";
setup.pl;
cd "../23ISAPartB";
setup.pl;
cd "../23ISAPartC";
setup.pl;
cd "../23ISAPartD";
setup.pl;
cd "../24JERPartA";
setup.pl;
cd "../24JERPartB";
setup.pl;
cd "../24JERPartC";
setup.pl;
cd "../24JERPartD";
setup.pl;
cd "../24JERPartE";
setup.pl;
cd "../25LAMPartA";
setup.pl;
cd "../26EZEPartA";
setup.pl;
cd "../26EZEPartB";
setup.pl;
cd "../26EZEPartC";
setup.pl;
cd "../26EZEPartD";
setup.pl;
cd "../27DANPartA";
setup.pl;
cd "../27DANPartB";
setup.pl;
cd "../28HOSPartA";
setup.pl;
cd "../29JOE-32JON";
setup.pl;
cd "../33MIC-37HAG";
setup.pl;
cd "../38ZEC-39MAL";
setup.pl;
cd "../40MATPartA";
setup.pl;
cd "../40MATPartB";
setup.pl;
cd "../40MATPartC";
setup.pl;
cd "../40MATPartD";
setup.pl;
cd "../41MARPartA";
setup.pl;
cd "../41MARPartB";
setup.pl;
cd "../42LUKPartA";
setup.pl;
cd "../42LUKPartB";
setup.pl;
cd "../42LUKPartC";
setup.pl;
cd "../42LUKPartD";
setup.pl;
cd "../43JOHPartA";
setup.pl;
cd "../43JOHPartB";
setup.pl;
cd "../43JOHPartC";
setup.pl;
cd "../44ACTPartA";
setup.pl;
cd "../44ACTPartB";
setup.pl;
cd "../44ACTPartC";
setup.pl;
cd "../45ROMPartA";
setup.pl;
cd "../45ROMPartB";
setup.pl;
cd "../46A1COPartA";
setup.pl;
cd "../46A1COPartB";
setup.pl;
cd "../47A2COPartA";
setup.pl;
cd "../48GAL-49EPH";
setup.pl;
cd "../50PHP-51COL";
setup.pl;
cd "../52A1TH-53A2TH";
setup.pl;
cd "../54A1TI-57PHM";
setup.pl;
cd "../58HEBPartA";
setup.pl;
cd "../59JAM-61A2PE";
setup.pl;
cd "../62A1JO-65JUD";
setup.pl;
cd "../66REVPartA";
setup.pl;
cd "../66REVPartB";
setup.pl;
cd "../66REVPartC";
setup.pl;

#####
#
# EOF
#
#####

-----