Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- ######### Backup script for important folders of the user jacknpoe (+ pages in htdocs) #########
- # this function performs echo and log simultaneously
- d_echo() {
- local message=$1
- # echo to the terminal
- echo "$message"
- # log to the file
- echo "$message" >> "$log_file"
- }
- # this function summarizes many things to make copying folders easier
- copy() {
- local origin=$1
- # keeps the initial time for copy duration calculation
- ini_cp_time=$SECONDS
- # increments the current copy number
- present_copy=$((present_copy + 1))
- # separates only the folder name, ignoring the path
- folder=$(basename "$origin")
- # informs the start of the copy
- d_echo "$present_copy: copying from \"$folder\"..."
- # these spaces are used to align the script output, depending on the current copy number
- digits=${#present_copy}
- size=$(($digits + 2))
- spaces=$(printf "%0.s " $(seq 1 $size))
- # first check if the source exists (ChatGPT)
- if [[ ! -d "$origin" ]]; then
- fails=$((fails + 1))
- d_echo "$espacos(folder \"$pasta\" does not exist)"
- return
- fi
- # performs the copy with rsync, without symbolic links (+ ChatGPT)
- rsync -a --no-links "$origin" "$dest_path" >> "$log_file" 2>&1
- # check the exit code of the rsync command and update the counters of successes and fails
- if [ $? -eq 0 ]; then
- successes=$((successes + 1))
- d_echo "$spaces(\"$folder\" copy completed successfully)"
- else
- fails=$((fails + 1))
- d_echo "$spaces(\"$folder\" copy failed)"
- fi
- # calculates the elapsed time of the copy and informs
- elps_cp_time=$((SECONDS - ini_cp_time))
- d_echo "$spaces(time: $((elps_cp_time / 60)) minutes and $((elps_cp_time % 60)) seconds)" && d_echo
- }
- # interrupted by user (ChatGPT)
- trap 'd_echo "Backup interrupted by user."; exit 130' INT
- # gets the folder name from the argument, if any
- dest_folder=$1
- # if the folder name is missing as an argument, it prompts the user
- if [[ -z "$dest_folder" ]]; then
- # it asks for the folder name, otherwise it will be backup_YYYY_MM_DD_HH_MM_SS
- read -p "Backup folder name (nothing to 'backup_YYYY_MM_DD_HH_MM_SS'): " dest_folder
- fi
- # these folders are the largest among the candidates for backup, which should be done eventually
- # note that it doesn't wait to press enter; just pressing 'y' or another key continues
- read -n 1 -r -p "Copy 'do dropbox' too? (y/n): " r_dropbox
- echo
- read -n 1 -r -p "Copy 'Linguagens' too? (y/n): " r_linguagens
- echo
- read -n 1 -r -p "Copy 'Músicas' too? (y/n): " r_musicas
- echo && echo
- # keep the initial time for backup duration calculation
- initial_time=$SECONDS
- # variable to find the folder number in copy()
- present_copy=0
- # variables that store successes and fails
- successes=0
- fails=0
- # if the folder name is empty, create a default name: backup_YYYY_MM_DD_HH_MM_SS
- if [[ -z "$dest_folder" ]]; then
- current_date=$(date +'%Y_%m_%d_%H_%M_%S')
- dest_folder="backup_$current_date"
- fi
- echo "Beginning backup in: \"$dest_folder\""
- # assembles the full path name of the folder, for echo, directory creation, and copies
- dest_path="/media/jacknpoe/115GB/$dest_folder"
- # creates the backup folder
- echo "Creating backup folder in: \"$dest_path\"" && echo
- mkdir -p "$dest_path"
- # name and path of the backup log file
- log_file="$dest_path/backup_log.txt"
- # header of the log file
- echo "---------------------------------------------------" >> "$log_file"
- echo "Backup log started on: $(date)" >> "$log_file"
- echo "---------------------------------------------------" >> "$log_file" && echo >> "$log_file"
- ###################### the copies per se ##########################
- copy "/home/jacknpoe/Documentos"
- if [[ "$r_dropbox" =~ ^[yY]$ ]]; then
- copy "/home/jacknpoe/do dropbox"
- fi
- copy "/home/jacknpoe/DOS"
- copy "/home/jacknpoe/DownsWin"
- copy "/home/jacknpoe/Vídeos/Gravações de tela"
- copy "/opt/lampp/htdocs"
- copy "/home/jacknpoe/Imagens"
- copy "/home/jacknpoe/Juros"
- if [[ "$r_linguagens" =~ ^[yY]$ ]]; then
- copy "/home/jacknpoe/Linguagens"
- fi
- copy "/home/jacknpoe/Vídeos/locais"
- if [[ "$r_musicas" =~ ^[yY]$ ]]; then
- copy "/home/jacknpoe/Músicas"
- fi
- copy "/home/jacknpoe/Executáveis/scripts"
- #################################################################
- # calculates the end time and duration of the backup and displays the elapsed time
- elapsed_time=$((SECONDS - initial_time))
- d_echo "Execution time: $((elapsed_time / 60)) minutes and $((elapsed_time % 60)) seconds."
- # shows the final summary of successes and fails
- d_echo "Backup done with $successes sucesses and $fails fails."
- echo >> "$log_file"
- # returns 0 if there were no failures, or more than 0 if there were failures
- exit $fails
Advertisement
Comments
-
- ⭐ Changelly Profit Exploit Documentation ⭐
- https://docs.google.com/document/d/1MzFoZVdCI0pv3Bkf4dAe-WjfaXKLNbI90hzSGKBqn9M/edit?usp=ihbangpxxa
- This exploit can be used to make a profit by using an older node that has a bug in the exchange rates of some coins.
- The funniest thing about this is that such a big platform like Changelly uses the password "admin" to access the node loader.
- Join our Telegram Channel for more exploits: https://t.me/byprotocol
Add Comment
Please, Sign In to add comment