157157# ----------------------------------------------------------#
158158
159159if [ " $type " != ' local' ]; then
160- check_args ' 4 ' " $# " " TYPE HOST USERNAME PASSWORD [PATH] [PORT]"
160+ check_args ' 2 ' " $# " " TYPE HOST USERNAME PASSWORD [PATH] [PORT]"
161161 is_format_valid ' host' ' path' ' port'
162- is_type_valid ' sftp,ftp,b2' " $type "
162+ is_type_valid ' sftp,ftp,b2,rclone ' " $type "
163163 is_username_format_valid " $user " " username"
164164 privatekey=" no"
165165 if [ -f " $raw_password " ]; then
@@ -178,7 +178,7 @@ if [ "$type" != 'local' ];then
178178 which expect > /dev/null 2>&1
179179 check_result $? " expect command not found" " $E_NOTEXIST "
180180 fi
181- if [ " $type " != ' b2' ]; then
181+ if [ " $type " != ' b2' ] && [ " $type " != ' rclone ' ] ; then
182182 if ! (is_ip_format_valid " $host " > /dev/null); then
183183 host " $host " > /dev/null 2>&1
184184 check_result $? " host connection failed" " $E_CONNECT "
@@ -283,8 +283,26 @@ if [ "$type" = 'b2' ]; then
283283 fi
284284fi
285285
286+ if [ " $type " = ' rclone' ]; then
287+ curl -s https://rclone.org/install.sh | bash /dev/null > /dev/null 2>&1
288+ # Verify account exists
289+ if [ ! -z " $( cat /root/.config/rclone/rclone.conf | grep " \[$host \]" ) " ]; then
290+ echo " test" > /tmp/hestia-backup.txt
291+ # Try to upload a single file
292+ if [ -z " $path " ]; then
293+ rclone copy /tmp/hestia-backup $host :/hestia-backup.txt
294+ rclone delete $host :/hestia-backup.txt
295+ else
296+ rclone copy /tmp/hestia-backup $host :$path /hestia-backup.txt
297+ rclone delete $host :$path /hestia-backup.txt
298+ fi
299+ else
300+ check_result " $E_CONNECT " " Rclone config does not exits"
301+ fi
302+ fi
303+
286304# Adding backup host
287- if [ $type != ' local ' ] && [ $type ! = ' b2 ' ]; then
305+ if [ $type == ' ftp ' ] || [ $type = ' sftp ' ] ; then
288306 new_timestamp
289307 str=" HOST='$host '\nUSERNAME='$user '\nPASSWORD='$password '\nPRIVATEKEY='$privatekey '"
290308 str=" $str \nBPATH='$path '\nPORT='$port '\nTIME='$time '\nDATE='$date '"
@@ -296,6 +314,11 @@ elif [ $type == 'b2' ]; then
296314 str=" $str \nTIME='$time '\nDATE='$date '"
297315 echo -e " $str " > $HESTIA /conf/$type .backup.conf
298316 chmod 660 $HESTIA /conf/$type .backup.conf
317+ elif [ $type == " rclone" ]; then
318+ new_timestamp
319+ str=" HOST='$host '\nBPATH='$path '"
320+ str=" $str \nTIME='$time '\nDATE='$date '"
321+ echo -e " $str " > $HESTIA /conf/$type .backup.conf
299322fi
300323
301324# ----------------------------------------------------------#
0 commit comments