delete backup readme
This commit is contained in:
parent
23858a2a81
commit
3c42621a95
37
README.md
37
README.md
@ -12,21 +12,22 @@
|
||||
|
||||
## Arguments
|
||||
|
||||
| Flag | Example | Parameter | Description |
|
||||
|----------- |------------------------ |----------- |----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| --restore | --restore | None | Restore HeavyScript specific `ix-applications dataset` snapshot |
|
||||
| --mount | --mount | None | Initiates mounting feature Choose between unmounting and mounting PVC data |
|
||||
| --dns | --dns | None | list all of your applications DNS names and their web port |
|
||||
| -U | -U | None | Update applications, ignoring major version changes |
|
||||
| -u | -u | None | Update applications, do NOT update if there was a major version change |
|
||||
| -b | -b 14 | Integer | Backup `ix-appliactions` dataset Creates backups up to the number you've chosen |
|
||||
| -i | -i nextcloud -i sonarr | String | Applications listed will be ignored during updating List one application after another as shown in the example |
|
||||
| (-R\|-r) | -r | None | Monitors applications after they update If the app does not become "ACTIVE" after either: The custom Timeout, or Default Timeout, rollback the application. Warning: deprecating `-R` please begin using `-r` instead |
|
||||
| -v | -v | None | Verbose Output Look at the bottom of this page for an example |
|
||||
| -S | -S | None | Shutdown the application prior to updating it |
|
||||
| -t | -t 150 | Integer | Set a custom timeout to be used with either: `-m` - Time the script will wait for application to be "STOPPED" or `-(u\|U)` - Time the script will wait for application to be either "STOPPED" or "ACTIVE" |
|
||||
| -s | -s | None | Sync Catalogs prior to updating |
|
||||
| -p | -p | None | Prune old/unused docker images |
|
||||
| Flag | Example | Parameter | Description |
|
||||
|----------------- |------------------------ |----------- |------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| --delete-backup | --delete-backup | None | Opens a menu to delete backups >Useful if you need to delete old system backups or backups from other scripts |
|
||||
| --restore | --restore | None | Restore HeavyScript specific `ix-applications dataset` snapshot |
|
||||
| --mount | --mount | None | Initiates mounting feature Choose between unmounting and mounting PVC data |
|
||||
| --dns | --dns | None | list all of your applications DNS names and their web ports |
|
||||
| -U | -U | None | Update applications, ignoring major version changes |
|
||||
| -u | -u | None | Update applications, do NOT update if there was a major version change |
|
||||
| -b | -b 14 | Integer | Backup `ix-appliactions` dataset Creates backups up to the number you've chosen |
|
||||
| -i | -i nextcloud -i sonarr | String | Applications listed will be ignored during updating List one application after another as shown in the example |
|
||||
| (-R\|-r) | -r | None | Monitors applications after they update If the app does not become "ACTIVE" after either: The custom Timeout, or Default Timeout, rollback the application. >Warning: deprecating `-R` please begin using `-r` instead |
|
||||
| -v | -v | None | Verbose Output Look at the bottom of this page for an example |
|
||||
| -S | -S | None | Shutdown the application prior to updating it |
|
||||
| -t | -t 150 | Integer | Set a custom timeout to be used with either: `-m` - Time the script will wait for application to be "STOPPED" or `-(u\|U)` - Time the script will wait for application to be either "STOPPED" or "ACTIVE" |
|
||||
| -s | -s | None | Sync Catalogs prior to updating |
|
||||
| -p | -p | None | Prune old/unused docker images |
|
||||
|
||||
<br>
|
||||
<br>
|
||||
@ -63,6 +64,12 @@ bash /mnt/tank/scripts/heavy_script.sh -t 300 --mount
|
||||
bash /mnt/tank/scripts/heavy_script/heavy_script.sh --restore
|
||||
```
|
||||
|
||||
#### Deleting Backups
|
||||
|
||||
```
|
||||
bash /mnt/tank/scripts/heavy_script/heavy_script.sh --backup-delete
|
||||
```
|
||||
|
||||
#### List All DNS Names
|
||||
|
||||
```
|
||||
|
104
heavy_script.sh
104
heavy_script.sh
@ -105,6 +105,27 @@ do
|
||||
esac
|
||||
done
|
||||
|
||||
|
||||
deleteBackup(){
|
||||
clear -x && echo "pulling all restore points.."
|
||||
list_backups=$(cli -c 'app kubernetes list_backups' | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl | column -t)
|
||||
clear -x
|
||||
[[ -z "$list_backups" ]] && echo "No restore points available" && exit || { title; echo -e "Choose a restore point to delete\nThese may be out of order if they are not HeavyScript backups" ; }
|
||||
echo "$list_backups" && read -p "Please type a number: " selection && restore_point=$(echo "$list_backups" | grep ^"$selection " | awk '{print $2}')
|
||||
[[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script
|
||||
[[ -z "$restore_point" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script
|
||||
echo -e "\nWARNING:\nYou CANNOT go back after deleting your restore point" || { echo "FAILED"; exit; }
|
||||
echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?" && echo -e "1 Yes\n2 No" && read -p "Please type a number: " yesno || { echo "FAILED"; exit; }
|
||||
if [[ $yesno == "1" ]]; then
|
||||
echo -e "\nDeleting $restore_point" && cli -c 'app kubernetes delete_backup backup_name=''"'"$restore_point"'"' &>/dev/null && echo "Sucessfully deleted" || echo "Deletion Failed"
|
||||
elif [[ $yesno == "2" ]]; then
|
||||
echo "You've chosen NO, killing script."
|
||||
else
|
||||
echo "Invalid Selection"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
backup(){
|
||||
echo -e "\nNumber of backups was set to $number_of_backups"
|
||||
date=$(date '+%Y_%m_%d_%H_%M_%S')
|
||||
@ -124,6 +145,7 @@ fi
|
||||
}
|
||||
export -f backup
|
||||
|
||||
|
||||
restore(){
|
||||
clear -x && echo "pulling restore points.."
|
||||
list_backups=$(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl | column -t)
|
||||
@ -144,6 +166,33 @@ fi
|
||||
}
|
||||
export -f restore
|
||||
|
||||
|
||||
dns(){
|
||||
clear -x
|
||||
echo "Generating DNS Names.."
|
||||
#ignored dependency pods, No change required
|
||||
dep_ignore="cron|kube-system|nvidia|svclb|NAME|memcached"
|
||||
|
||||
# Pulling pod names
|
||||
mapfile -t main < <(k3s kubectl get pods -A | grep -Ev "$dep_ignore" | sort)
|
||||
|
||||
# Pulling all ports
|
||||
all_ports=$(k3s kubectl get service -A)
|
||||
|
||||
clear -x
|
||||
count=0
|
||||
for i in "${main[@]}"
|
||||
do
|
||||
[[ count -le 0 ]] && echo -e "\n" && ((count++))
|
||||
appName=$(echo "$i" | awk '{print $2}' | sed 's/-[^-]*-[^-]*$//' | sed 's/-0//')
|
||||
ixName=$(echo "$i" | awk '{print $1}')
|
||||
port=$(echo "$all_ports" | grep -E "\s$appName\s" | awk '{print $6}' | grep -Eo "^[[:digit:]]+{1}")
|
||||
echo -e "$appName.$ixName.svc.cluster.local $port"
|
||||
done | uniq | nl -b t | sed 's/\s\s\s$/- -------- ----/' | column -t -R 1 -N "#,DNS_Name,Port" -L
|
||||
}
|
||||
export -f dns
|
||||
|
||||
|
||||
mount(){
|
||||
clear -x
|
||||
title
|
||||
@ -199,15 +248,12 @@ fi
|
||||
}
|
||||
export -f mount
|
||||
|
||||
|
||||
sync(){
|
||||
echo -e "\nSyncing all catalogs, please wait.." && cli -c 'app catalog sync_all' &> /dev/null && echo -e "Catalog sync complete"
|
||||
}
|
||||
export -f sync
|
||||
|
||||
prune(){
|
||||
echo -e "\nPruning Docker Images" && docker image prune -af | grep "^Total" || echo "Failed to Prune Docker Images"
|
||||
}
|
||||
export -f prune
|
||||
|
||||
update_apps(){
|
||||
mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | grep -E ",true(,|$)" | sort)
|
||||
@ -334,29 +380,12 @@ else
|
||||
fi
|
||||
fi
|
||||
}
|
||||
export -f prune
|
||||
export -f after_update_actions
|
||||
|
||||
|
||||
deleteBackup(){
|
||||
clear -x && echo "pulling restore points.."
|
||||
list_backups=$(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl | column -t)
|
||||
clear -x
|
||||
[[ -z "$list_backups" ]] && echo "No HeavyScript restore points available" && exit || { title; echo "Choose a restore point" ; }
|
||||
echo "$list_backups" && read -p "Please type a number: " selection && restore_point=$(echo "$list_backups" | grep ^"$selection " | awk '{print $2}')
|
||||
[[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script
|
||||
[[ -z "$restore_point" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script
|
||||
echo -e "\nWARNING:\nYou CANNOT go back after deleting your restore point" || { echo "FAILED"; exit; }
|
||||
echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?" && echo -e "1 Yes\n2 No" && read -p "Please type a number: " yesno || { echo "FAILED"; exit; }
|
||||
if [[ $yesno == "1" ]]; then
|
||||
echo -e "\nDeleting $restore_point" && cli -c 'app kubernetes delete_backup backup_name=''"'"$restore_point"'"' &>/dev/null && echo "Sucessfully deleted $restore_point" || echo "Deletion Failed"
|
||||
elif [[ $yesno == "2" ]]; then
|
||||
echo "You've chosen NO, killing script."
|
||||
else
|
||||
echo "Invalid Selection"
|
||||
fi
|
||||
prune(){
|
||||
echo -e "\nPruning Docker Images" && docker image prune -af | grep "^Total" || echo "Failed to Prune Docker Images"
|
||||
}
|
||||
|
||||
|
||||
export -f prune
|
||||
|
||||
title(){
|
||||
echo ' _ _ _____ _ _ '
|
||||
@ -371,31 +400,6 @@ echo
|
||||
}
|
||||
export -f title
|
||||
|
||||
dns(){
|
||||
clear -x
|
||||
echo "Generating DNS Names.."
|
||||
#ignored dependency pods, No change required
|
||||
dep_ignore="cron|kube-system|nvidia|svclb|NAME|memcached"
|
||||
|
||||
# Pulling pod names
|
||||
mapfile -t main < <(k3s kubectl get pods -A | grep -Ev "$dep_ignore" | sort)
|
||||
|
||||
# Pulling all ports
|
||||
all_ports=$(k3s kubectl get service -A)
|
||||
|
||||
clear -x
|
||||
count=0
|
||||
for i in "${main[@]}"
|
||||
do
|
||||
[[ count -le 0 ]] && echo -e "\n" && ((count++))
|
||||
appName=$(echo "$i" | awk '{print $2}' | sed 's/-[^-]*-[^-]*$//' | sed 's/-0//')
|
||||
ixName=$(echo "$i" | awk '{print $1}')
|
||||
port=$(echo "$all_ports" | grep -E "\s$appName\s" | awk '{print $6}' | grep -Eo "^[[:digit:]]+{1}")
|
||||
echo -e "$appName.$ixName.svc.cluster.local $port"
|
||||
done | uniq | nl -b t | sed 's/\s\s\s$/- -------- ----/' | column -t -R 1 -N "#,DNS_Name,Port" -L
|
||||
}
|
||||
export -f dns
|
||||
|
||||
#exit if incompatable functions are called
|
||||
[[ "$restore" == "true" && "$mount" == "true" ]] && echo -e "The Restore Function(-r)\nand\nMount Function(-m)\nCannot both be called at the same time." && exit
|
||||
[[ "$update_all_apps" == "true" && "$update_apps" == "true" ]] && echo -e "-U and -u cannot BOTH be called" && exit
|
||||
|
Loading…
Reference in New Issue
Block a user