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

14
yams
View File

@ -5,11 +5,13 @@ dc="docker compose -f <filename> -f <custom_file_filename>"
install_directory="<install_directory>"
option=${1:-"--help"}
destination=${2:-"."}
destination=$(realpath "$destination")
help() {
echo "yams - Yet Another Media Server"
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 "--help displays this help message"
echo "restart restarts yams services"
@ -17,6 +19,7 @@ help() {
echo "start starts yams services"
echo "destroy destroy yams services so you can start from scratch"
echo "check-vpn checks if the VPN is working as expected"
echo "backup [destination] backs up yams to the destination location"
echo "update updates YAMS (deprecated)"
}
@ -114,3 +117,12 @@ fi
if [ "$option" == "update" ]; then
echo "This command is deprecated. Please update YAMS manually."
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