Problems with Rsync from OMV to Qnap

    • OMV 2.x
    • Resolved

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Problems with Rsync from OMV to Qnap

      Hi.

      Hopefully somebody can help me. I want to backup folders from my OMV to a Qnap. I set up a rsync-job. But when I start it I get this error:

      rsync: connection unexpectedly closed (0 bytes received so far) [sender]
      rsync error: unexplained error (code 255) at io.c(605) [sender=3.0.9]

      Does anybody know why?

      Rsync Server is activated on Qnap, also user and password is set in Qnap on the rsync server tab.

      Thanks a lot.

      Regards lulu
    • hi,

      do you have rsync server enabled on QNAP?




      i ´m using a small bash-script on my omv for that.
      it makes:

      - first of all check if qnap is online with wget
      - when its online

      rsync the hole raid5 to QNAP
      - when its offline .. wake it up and wait 5 minutes then check again with wget
      - when its online
      rsync the .....

      - after this send email with:
      success
      or
      failed

      copy the script if you like it to your omv ... make it executeable ... and create a crontab entry:

      like:

      00 22 * * * /bin/bash /root/nas2nas_sync.sh

      Script will start at 22 o´clock

      On the qnap i have run another script who is checking the discs every 5 minutes. if all discs in sleep ... send qnap to sleep (think S3) :D

      OMV Script:

      Shell-Script: nas2nas-rsync.sh

      1. #!/bin/bash
      2. ## rowie - v1.0 - NAS2NAS rsync Backup-Script
      3. ############################################
      4. ##
      5. #
      6. #
      7. ## VARIABLES
      8. #
      9. # Set source location
      10. BACKUP_FROM="/srv/dev-disk-by-label-RAID5/"
      11. #
      12. # Set target location
      13. BACKUP_TO="rsync://nas-backup@192.168.115.17/NAS-Backup" ##<- Replace with QNAP rsync user@IP/rsync FOLDER##
      14. #
      15. #Backup destination
      16. BACKUP_EXCLUDE_BIN="/.*" #Exclude the hidden files, such as recycle bin or other
      17. #
      18. # target URL to check if up
      19. URL="http://192.168.115.17" ##<- Replace it with the QNAP IP##
      20. TIMEOUT="300"
      21. RETRY="2"
      22. reached="0"
      23. retryCnt="1"
      24. #
      25. # Log file
      26. LOG_FILE="/var/log/nas2nas-rsync.log"
      27. ###########################################
      28. #
      29. ##
      30. ## SCRIPT
      31. ##
      32. # Check if the log file exists and then delete it
      33. if [ -e "$LOG_FILE" ]; then
      34. rm -rf "$LOG_FILE"
      35. fi
      36. # Check that the log file exists
      37. if [ ! -e "$LOG_FILE" ]; then
      38. touch "$LOG_FILE"
      39. fi
      40. # Check that source dir exists and is readable.
      41. if [ ! -r "$BACKUP_FROM" ]; then
      42. echo "$(date "+%Y-%m-%d %k:%M:%S") - ERROR: Unable to read source dir." >> "$LOG_FILE"
      43. echo "$(date "+%Y-%m-%d %k:%M:%S") - ERROR: Unable to read source dir."
      44. echo "$(date "+%Y-%m-%d %k:%M:%S") - ERROR: Unable to sync." >> "$LOG_FILE"
      45. echo "$(date "+%Y-%m-%d %k:%M:%S") - ERROR: Unable to sync. Check the log file..."
      46. echo "" >> "$LOG_FILE"
      47. exit 1
      48. fi
      49. # Check that Backup destination is up and if not Wake it up (with etherwake)
      50. while [ $reached -eq 0 -a $retryCnt -le $RETRY ]
      51. do
      52. wget -q -S --spider $URL 2>&1 | grep "HTTP/1.1 302 Found" >/dev/null
      53. if [ $? -eq 0 ]
      54. then
      55. reached=1;
      56. else
      57. /usr/sbin/etherwake xx:xx:xx:xx:xx:xx ##<- Insert QNAP MAC-Adresse##
      58. sleep $TIMEOUT;
      59. fi
      60. retryCnt=`expr $retryCnt + 1`;
      61. done
      62. # Start entry in the log
      63. echo "$(date "+%Y-%m-%d %k:%M:%S") - Sync started." >> "$LOG_FILE"
      64. echo "$(date "+%Y-%m-%d %k:%M:%S") - Sync started... Please wait."
      65. # Start sync
      66. export RSYNC_PASSWORD=lamepassword #<- QNAP rsync-ServerPassword
      67. if rsync -av --exclude "$BACKUP_EXCLUDE_BIN" "$BACKUP_FROM" "$BACKUP_TO" &>> "$LOG_FILE"; then
      68. echo "$(date "+%Y-%m-%d %k:%M:%S") - Sync completed succesfully." >> "$LOG_FILE"
      69. echo "$(date "+%Y-%m-%d %k:%M:%S") - Sync completed succesfully."
      70. else
      71. echo "$(date "+%Y-%m-%d %k:%M:%S") - ERROR: rsync-command failed." >> "$LOG_FILE"
      72. echo "$(date "+%Y-%m-%d %k:%M:%S") - ERROR: Unable to sync." >> "$LOG_FILE"
      73. echo "$(date "+%Y-%m-%d %k:%M:%S") - ERROR: Unable to sync. Check the log file."
      74. echo "" >> "$LOG_FILE"
      75. exit 1
      76. fi
      77. sendEmail -f from@example -t to@example.com -s smtp.example.com:587 -o tls=auto -xu from@example.com -xp lamepassword -a "$LOG_FILE" -m NAS2NAS sync Successful: $(date)
      78. # End entry in the log
      79. echo "" >> "$LOG_FILE"
      80. exit 0
      Display All
      QNAP Script:


      Shell-Script: send_nas_to_sleep_if_idle.sh

      1. #!/bin/bash
      2. lines=`hdparm -C /dev/sd[a-f]|grep "active/idle"|wc -l|tr -d ' '|cut -f1 -d' '`
      3. if [ $lines == "0" ]; then
      4. cat /etc/config/sleepmail.txt|sendmail -t
      5. ntpdate time.euro.apple.com 2>/dev/null >/dev/null
      6. hwclock --systohc
      7. sleep 30
      8. echo mem >/sys/power/state
      9. fi

      crontab on QNAP:

      */5 * * * * /etc/config/send_nas_to_sleep_if_idle.sh



      the scripts are certainly not perfect ... but they work! :)

      br,
      rowie
      HP Proliant Gen8 with ESXi6.5

      Storage - Raid5 with 4 x 3TB WDRed - System on microSD / Datastore on Samsung 850Pro - 250GB