.
This commit is contained in:
parent
ebf4b84c5d
commit
942bc651a9
117
backup.sh
Normal file
117
backup.sh
Normal file
@ -0,0 +1,117 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Interactive backup script written by Skylar Grant
|
||||
#
|
||||
# GitHub: https://github.com/voidf1sh/backup-script
|
||||
# File: backup.sh
|
||||
# Version: 0.0.1
|
||||
# Date: 2021.09.21
|
||||
####################################################
|
||||
|
||||
####################################################
|
||||
# Formatting Tips:
|
||||
# (Tips found at : https://misc.flogisoft.com/bash/tip_colors_and_formatting)
|
||||
#
|
||||
# Formatting:
|
||||
# \e[1m - Bold
|
||||
# \e[2m - Dim
|
||||
# \e[8m - Hidden (passwords)
|
||||
#
|
||||
# Reset:
|
||||
# \e[0m - Reset All Attributes
|
||||
# \e[21m - Reset Bold/Bright
|
||||
# \e[22m - Reset Dim
|
||||
# \e[28m - Reset Hidden
|
||||
#
|
||||
# Colors:
|
||||
# \e[39m - Default Foreground Color
|
||||
# \e[30m - Black
|
||||
# \e[31m - Red
|
||||
# \e[32m - Green
|
||||
# \e[34m - Blue
|
||||
####################################################
|
||||
|
||||
# Some initial variables to work with
|
||||
# Note: this isn't ideal, this is going to name the
|
||||
# backup according to the time the script is launched
|
||||
# not according to the time the actual backup was initiated
|
||||
backupdir="$(pwd)/backups"
|
||||
timestamp=$(date "+%Y%m%d_%H%M")
|
||||
filename="backup_$timestamp.tar.gz"
|
||||
|
||||
# Initial Prompt
|
||||
# Bash allows for linebreaks in string literals and will
|
||||
# break lines accordingly in the shell
|
||||
echo -e "
|
||||
\e[1m\e[32m[ Skylar's Backup Script ]\e[0m
|
||||
|
||||
\e[32mThis script is being run from: \e[0m'$(pwd)'
|
||||
\e[32mBackup Filename: \e[0m'$filename'
|
||||
\e[32mCurrent Backup Location: \e[0m'$backupdir'
|
||||
\e[32mDirectories to Backup: \e[0m'/var/www', '$HOME'
|
||||
|
||||
\e[34mPlease enter an option from below:\e[0m
|
||||
|
||||
\e[34m[1] \e[0mCreate a new backup.
|
||||
\e[34m[2] \e[0mList saved backups.
|
||||
\e[34m[3] \e[0mCheck /tmp for any rogue backups.
|
||||
\e[34m[4] \e[0mChange backup directory.
|
||||
\e[34m[5] \e[0mGenerate a reusable backup script using these settings.
|
||||
|
||||
\e[34m[0] \e[31mExit\e[0m
|
||||
"
|
||||
|
||||
if ! test -d "$backupdir"; then
|
||||
echo -e "\e[31mError: The backup directory does not exist.
|
||||
\e[0mWould you like to create it? [y/n]"
|
||||
read -p "[y/n]: " yesno
|
||||
|
||||
case "$yesno" in
|
||||
"y")
|
||||
mkdir -p "$backupdir"
|
||||
;;
|
||||
"n")
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Wait for input
|
||||
read -p " Option: " opt
|
||||
|
||||
# Execute the correct commands based on input.
|
||||
case "$opt" in
|
||||
1)
|
||||
# Create new backup
|
||||
clear
|
||||
tar -czf "/tmp/$filename" /var/www $HOME
|
||||
mv "$filename" "$backupdir"
|
||||
;;
|
||||
2)
|
||||
# List saved backups
|
||||
clear
|
||||
ls -al "$backupdir" | grep "backup"
|
||||
;;
|
||||
3)
|
||||
# Check /tmp for any rogue backups.
|
||||
clear
|
||||
ls -al /tmp | grep backup
|
||||
;;
|
||||
4)
|
||||
# Change backup directory
|
||||
read -p " New directory: " newdir
|
||||
backupdir=$newdir
|
||||
;;
|
||||
0)
|
||||
# Exit the script
|
||||
echo "!! Quitting !!"
|
||||
sleep 0.4s
|
||||
clear
|
||||
exit
|
||||
;;
|
||||
*)
|
||||
clear
|
||||
echo "!! Invalid Option !!"
|
||||
;;
|
||||
esac
|
||||
|
||||
exec ./backup.sh
|
BIN
backups/backup_20210921_2110.tar.gz
Normal file
BIN
backups/backup_20210921_2110.tar.gz
Normal file
Binary file not shown.
69
botcp.sh
Normal file
69
botcp.sh
Normal file
@ -0,0 +1,69 @@
|
||||
#!/bin/bash
|
||||
|
||||
# UI/Prompt
|
||||
echo -e "
|
||||
\e[0mDiscord Bot Control Panel\e[32m
|
||||
Options:
|
||||
\e[35m[1] \e[32mStart all bots.
|
||||
\e[35m[2] \e[32mStop all bots.
|
||||
\e[35m[3] \e[32mBot 1 Log
|
||||
\e[35m[4] \e[32mBot 2 Log
|
||||
\e[35m[5] \e[32mBot 3 Log
|
||||
\e[35m[6] \e[32mBot 4 Log
|
||||
|
||||
\e[35m[0] \e[31mExit \e[32m
|
||||
|
||||
Bot 1 PID: \e[0m`pgrep -f "[n]ode /home/ubuntu/bot1/bot.js"`
|
||||
Bot 2 PID: \e[0m`pgrep -f "[n]ode /home/ubuntu/bot2/bot.js"`
|
||||
Bot 3 PID: \e[0m`pgrep -f "[n]ode /home/ubuntu/bot3/bot.js"`
|
||||
Bot 4 PID: \e[0m`pgrep -f "[n]ode /home/ubuntu/bot4/bot.js"`"
|
||||
|
||||
# Bot PIDs
|
||||
bbotPID=`pgrep -f "[n]ode /home/ubuntu/bot1/bot.js"`
|
||||
vbotPID=`pgrep -f "[n]ode /home/ubuntu/bot2/bot.js"`
|
||||
sbotPID=`pgrep -f "[n]ode /home/ubuntu/bot3/bot.js"`
|
||||
abotPID=`pgrep -f "[n]ode /home/ubuntu/bot4/bot.js"`
|
||||
|
||||
# Wait for input
|
||||
read -p " Option: " opt
|
||||
|
||||
# Execute commands based on input.
|
||||
case "$opt" in
|
||||
1)
|
||||
echo " Starting all bots..."
|
||||
node /home/ubuntu/bot1/bot.js &>> /home/ubuntu/logs/bot1.log &
|
||||
node /home/ubuntu/bot2/bot.js &>> /home/ubuntu/logs/bot2.log &
|
||||
node /home/ubuntu/bot3/bot.js &>> /home/ubuntu/logs/bot3.log &
|
||||
node /home/ubuntu/bot4/bot.js &>> /home/ubuntu/logs/bot4.log &
|
||||
sleep 0.4s
|
||||
clear
|
||||
;;
|
||||
2)
|
||||
echo " Stopping all bots..."
|
||||
kill -9 $bbotPID
|
||||
kill -9 $vbotPID
|
||||
kill -9 $sbotPID
|
||||
kill -9 $abotPID
|
||||
sleep 0.4s
|
||||
clear
|
||||
;;
|
||||
3)
|
||||
;;
|
||||
4)
|
||||
;;
|
||||
5)
|
||||
;;
|
||||
6)
|
||||
;;
|
||||
0)
|
||||
echo " Quitting this script..."
|
||||
sleep 0.4s
|
||||
clear
|
||||
exit
|
||||
;;
|
||||
*)
|
||||
clear
|
||||
;;
|
||||
esac
|
||||
|
||||
exec ./botcp
|
Loading…
Reference in New Issue
Block a user