Add backup functionality to YAMS script

This commit is contained in:
Roger Gonzalez 2024-12-23 11:44:51 -03:00
parent 1b48411ddb
commit ffdb38293b
Signed by: rogs
GPG Key ID: C7ECE9C6C36EC2E6

28
yams
View File

@ -5,19 +5,22 @@ dc="docker compose -f <filename> -f <custom_file_filename>"
install_directory="<install_directory>" install_directory="<install_directory>"
option=${1:-"--help"} option=${1:-"--help"}
destination=${2:-"."}
destination=$(realpath "$destination")
help() { help() {
echo "yams - Yet Another Media Server" echo "yams - Yet Another Media Server"
echo echo
echo "Usage: yams [--help|restart|stop|start|destroy|check-vpn|update (deprecated)]" echo "Usage: yams [--help|restart|stop|start|destroy|check-vpn|backup [destination]|update (deprecated)]"
echo "options:" echo "options:"
echo "--help displays this help message" echo "--help displays this help message"
echo "restart restarts yams services" echo "restart restarts yams services"
echo "stop stops all yams services" echo "stop stops all yams services"
echo "start starts yams services" echo "start starts yams services"
echo "destroy destroy yams services so you can start from scratch" echo "destroy destroy yams services so you can start from scratch"
echo "check-vpn checks if the VPN is working as expected" echo "check-vpn checks if the VPN is working as expected"
echo "update updates YAMS (deprecated)" echo "backup [destination] backs up yams to the destination location"
echo "update updates YAMS (deprecated)"
} }
send_success_message() { send_success_message() {
@ -114,3 +117,12 @@ fi
if [ "$option" == "update" ]; then if [ "$option" == "update" ]; then
echo "This command is deprecated. Please update YAMS manually." echo "This command is deprecated. Please update YAMS manually."
fi fi
if [ "$option" == "backup" ]; then
echo "Backing up YAMS to $destination..."
echo "This may take a while depending on the size of your installation."
echo "Please wait... ⌛"
tar --exclude='transcoding-temp' -cavf $destination/yams-backup-$(date '+%Y-%m-%d-%s').tar.gz $install_directory/
send_success_message "Backup completed successfully! 🎉"
echo "Backup file: $destination/yams-backup-$(date '+%Y-%m-%d-%s').tar.gz"
fi