making it there
This commit is contained in:
@@ -40,7 +40,7 @@ argz="$@"
|
||||
shopt -s nocasematch # magic no case match bs
|
||||
set -Eeuo pipefail # fail on any error including pipe fail and use error trap
|
||||
# backup_dir="/mnt/d/Anbernic_Research_Tinkering_Save" # dir to protect
|
||||
backup_dir="/mnt/c/Users/human/Downloads"
|
||||
backup_dir="/mnt/c/Users/human/Downloads/tint"
|
||||
error_log="${backup_dir}/error.log" # errror log path
|
||||
path_error_log="$error_log" # duplicated cus lazy
|
||||
exec 2> >(tee -a "$path_error_log" >&2) # output any stderror to both screen and error log
|
||||
@@ -55,9 +55,9 @@ else
|
||||
fi
|
||||
|
||||
# on error, fail and dump as much information as possible to terminal, webhook, and error log
|
||||
trap error_handler ERR
|
||||
# trap error_handler ERR
|
||||
error_handler () {
|
||||
infostring="${RED}\n\n\nERROR IN SCRIPT:\n\n\t\$SECONDS Seconds Elapsed\n\tDate $(date)\n\tOn Line: \$LINENO\n\tUsing command \$BASH_COMMAND\n\tReturn Code: \$?\n\tError log: $path_error_log\n\tError Text: \$ERR\v\tRecorded Args: \${@}${RESET}\n\n"
|
||||
infostring="${RED}\n\n\nERROR IN SCRIPT:\n\n\t$SECONDS Seconds Elapsed\n\tDate $(date)\n\tOn Line: $LINENO\n\tUsing command $BASH_COMMAND\n\tReturn Code: $?\n\tError log: $path_error_log\n\tRecorded Args: ${@}${RESET}\n\n"
|
||||
webhook "$infostring" true # dump data to terminal and webhook
|
||||
echo -e >> "$path_error_log" # dump data to error log
|
||||
}
|
||||
@@ -113,7 +113,8 @@ function generate_sha256_checksums () {
|
||||
webhook "${GREEN}startin calculatin all dem gay af sha256 files\n\t$SECONDS seconds elapsed\n\tDate: $(date)${RESET}"
|
||||
|
||||
# use black magic to generatre da sha256 files
|
||||
find "$backup_dir" -prune -o -name ".git" -type f -exec bash -c "for f in \"\$@\"; do if [ -f \"\${f}.sha256\" ]; then continue; fi; sha256sum -c \"\${f}.sha256\" | tee -a \"${path_error_log}\"; done" _ {} + # sum horrifying shitfuck idk
|
||||
find "$backup_dir" -type f -name "*.sha256" -prune -o -name ".git" -exec bash -c "for f in \"$@\"; do sha256sum f{f} | tee -a ${f}.sha256"; done" _ {} + \; # aeswrfgv
|
||||
# bash -c "for f in \"\$@\"; do if [ -f \"\${f}.sha256\" ]; then continue; fi; sha256sum -c \"\${f}.sha256\" | tee -a \"${path_error_log}\"; done" _ {} + # sum horrifying shitfuck idk
|
||||
|
||||
webhook "${GREEN}finished calculatin all dem gay af sha256 files\n\t$SECONDS seconds elapsed${RESET}"
|
||||
}
|
||||
@@ -128,16 +129,18 @@ do_git () {
|
||||
webhook "doin sum git"
|
||||
# do da git conditionally if need be init
|
||||
if [ ! -d "${backup_dir}/.git" ]; then # if .git dir not be there, initialize it fag
|
||||
git init # init git if da shit aint there
|
||||
git branch -m master # set branch to main (?)
|
||||
git add .
|
||||
git commit -m "initial auto archive date: $(date)"
|
||||
git -C "$backup_dir" init 2>>"$path_error_log" # init git if da shit aint there
|
||||
# git -C "$backup_dir" branch -m master # set branch to main (?)
|
||||
git -C "$backup_dir" add "$backup_dir" 2>>"$path_error_log"
|
||||
git -C "$backup_dir" commit -m "initial auto archive date: $(date +%s)" 2>>"$path_error_log"
|
||||
else
|
||||
git add . # add
|
||||
git commit -m "archive $(date)" # commit wit date
|
||||
git -C "$backup_dir" add "$backup_dir" 2>>"$path_error_log"
|
||||
git -C "$backup_dir" commit -m "auto archive $(date +%s)" 2>>"$path_error_log" # commit wit date
|
||||
# notify finished with fuckgit
|
||||
webhook "done doin sum git"
|
||||
fi
|
||||
|
||||
webhook "done doin sum git"
|
||||
|
||||
}
|
||||
|
||||
# do da fookin sha256sums first ig
|
||||
@@ -163,7 +166,7 @@ check_generate_checksums () {
|
||||
|
||||
webhook "\n\nchecking pre-calculated sha256 sums"
|
||||
# find every sha256 file do the checksum
|
||||
find "$backup_dir" -prune -o -name ".git" -type f -iname "*.sha256" -exec bash -c "echo -e \"${GREEN}\nstarting check sha256sums of files\n\tcurrent file: {}\n\t total elpapsed: $SECONDS seconds\n'; sha256sum -c $1 | tee -a "${path_error_log}"; echo -e 'ARGS: $@\n\n${RESET}\"" \;
|
||||
find "$backup_dir" -prune -o -name ".git" -type f -iname "*.sha256" -exec bash -c "echo -e \"${GREEN}\nstarting check sha256sums of files\n\tcurrent file: {}\n\t total elpapsed: $SECONDS seconds\n\"; sha256sum -c {} | tee -a \"${path_error_log}\"; echo -e \"ARGS: $@\n\n${RESET}\"" \;
|
||||
}
|
||||
|
||||
restic_backups () {
|
||||
@@ -183,7 +186,7 @@ box_force_shutdown () {
|
||||
}
|
||||
|
||||
environment_checks
|
||||
do_git
|
||||
# do_git
|
||||
check_generate_checksums
|
||||
restic_backups
|
||||
# box_force_shutdown
|
||||
Reference in New Issue
Block a user