Last active
October 23, 2023 13:38
-
-
Save joeperpetua/5f41020cd85058600d7eaa75b9031fa3 to your computer and use it in GitHub Desktop.
This script helps you to change the usbshare destination for all Hyper Backup tasks that share the same current destination. For example, task A and B where made in usbshare1, but then the USB disk is mounted as usbshare2, then running this script will change the destination for task A and B to usbshare2.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
HELP='false'; | |
DSM_MAJOR=0; | |
DSM_MINOR=0; | |
CONF_PATH=''; | |
while getopts ":ho:n:" flag | |
do | |
case "${flag}" in | |
h) HELP='true';; | |
o) ORIGINAL=${OPTARG};; | |
n) NEW=${OPTARG};; | |
\?) echo "Invalid option: -$OPTARG" >&2; exit 1;; | |
:) echo "Option -$OPTARG requires an argument."; exit 1;; | |
esac | |
done | |
if ${HELP} || [ "$#" == 0 ]; then | |
echo -e "\nThis script helps you to change the usbshare destination for all Hyper Backup tasks that share the same current destination. For example, task A and B where made in usbshare1, but then the USB disk is mounted as usbshare2, then running this script will change the destination for task A and B to usbshare2.\n"; | |
echo -e "\nUsage:"; | |
echo -e " sh ./hb_dest_fix.sh [-h] -o ORIGINAL -n NEW" | |
echo -e "\nOptions:"; | |
echo -e " -h Shows this message"; | |
echo -e " -o ORIGINAL Original location for the tasks, ie: usbshare{1|2|3|X}"; | |
echo -e " -n NEW New location for the USB drive, ie: usbshare{1|2|3|X}"; | |
echo -e "\nExample:"; | |
echo -e " - Change usbshare1 to usbshare2:"; | |
echo -e " sh ./hb_dest_fix.sh -o usbshare1 -n usbshare2"; | |
echo -e "\n - Change usbshare2 to usbshare1:"; | |
echo -e " sh ./hb_dest_fix.sh -o usbshare2 -n usbshare1"; | |
exit 1; | |
fi | |
: ${ORIGINAL:?Missing original location, please specify the -o argument.}; | |
: ${NEW:?Missing new location, please specify the -n argument.}; | |
echo "Getting DSM version..."; | |
DSM_MAJOR=$(grep majorversion /etc/VERSION | sed 's/[a-z]*=//g' | sed 's/"//g'); | |
DSM_MINOR=$(grep minorversion /etc/VERSION | sed 's/[a-z]*=//g' | sed 's/"//g'); | |
if [ ${DSM_MAJOR} -lt 7 ]; | |
then | |
echo "Detected DSM 6 or lower..."; | |
CONF_PATH='/usr/syno/etc/synobackup.conf'; | |
fi | |
if [ ${DSM_MAJOR} -eq 7 ]; | |
then | |
if [ ${DSM_MINOR} -lt 2 ]; | |
then | |
echo "Detected DSM 7..."; | |
CONF_PATH='/usr/syno/etc/synobackup.conf'; | |
else | |
echo "Detected DSM 7.2 or above..."; | |
CONF_PATH='/var/packages/HyperBackup/etc/synobackup.conf'; | |
fi | |
fi | |
echo "Changing location from ${ORIGINAL} to ${NEW}..."; | |
sed -i "s/remote_share=\"${ORIGINAL}\"/remote_share=\"${NEW}\"/" $CONF_PATH; | |
echo "Process finished."; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OLD='usbshare1'; | |
NEW='usbshare2'; | |
wget https://gist.githubusercontent.com/joeperpetua/5f41020cd85058600d7eaa75b9031fa3/raw/7c50baa5cd27eea57443f7ed57d513495a1b5a06/hb_dest_fix.sh; | |
sh /tmp/hb_dest_fix.sh -o $OLD -n $NEW; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment