WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: rsync wont start on schedule and boolocal  (Read 5015 times)

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11629
Re: rsync wont start on schedule and boolocal
« Reply #15 on: July 31, 2019, 12:13:10 AM »
Hi aris
Sorry, my fault. Change this line from:
Code: [Select]
echo -e "\n`date`\n >> /home/tc/rsync.logto:
Code: [Select]
echo -e "\n`date`\n" >> /home/tc/rsync.log

Offline aris

  • Newbie
  • *
  • Posts: 49
Re: rsync wont start on schedule and boolocal
« Reply #16 on: July 31, 2019, 12:51:21 AM »
Hi Rich,
tried manually and its working
Code: [Select]
cat /home/tc/cpdr33.sh

#!/bin/sh -x
#copy files download an dr 3.3
ifconfig eth0:0 | grep -q "Bcast:" || echo "Network is down" >> /home/tc/rsync.log
rsync -avh -e "ssh -p 2112" root@192.168.3.3:/mnt/sda2/remote_source/ /mnt/sda1/local_destionation >> /home/tc/rsync.log  2>&1 &
tc@box:~$ ./cpdr33.sh
tc@box:~$ cat rsync.log

Wed Jul 31 11:33:01 UTC 2019

receiving incremental file list

sent 20 bytes  received 53 bytes  16.22 bytes/sec

Tried on reboot
Code: [Select]
tc@box:~$ cat /home/tc/rsync.log

Wed Jul 31 11:40:32 UTC 2019

Host key verification failed.
rsync: connection unexpectedly closed (0 bytes received so far) [Receiver]
rsync error: unexplained error (code 255) at io.c(226) [Receiver=3.1.2]

Offline aris

  • Newbie
  • *
  • Posts: 49
Re: rsync wont start on schedule and boolocal
« Reply #17 on: July 31, 2019, 12:59:21 AM »
So may be its because cron and manual .sh command is run by tc, as well as keypair generation, but bootlocal is run by root, so it doesnt know the key generated key by tc/ doesnt have the file (rsa file generate by tc).

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11629
Re: rsync wont start on schedule and boolocal
« Reply #18 on: July 31, 2019, 01:09:11 AM »
Hi aris
Try changing this:
Code: [Select]
rsync -avh -e "ssh -p 2112" root@192.168.3.3:/mnt/sda2/remote_source/ /mnt/sda1/local_destionation >> /home/tc/rsync.log  2>&1 &to this:
Code: [Select]
sudo -u tc rsync -avh -e "ssh -p 2112" root@192.168.3.3:/mnt/sda2/remote_source/ /mnt/sda1/local_destionation >> /home/tc/rsync.log  2>&1 &

Offline aris

  • Newbie
  • *
  • Posts: 49
Re: rsync wont start on schedule and boolocal
« Reply #19 on: July 31, 2019, 01:43:13 AM »
Hi Rich
thats working perfectly...so its sudo -u...thank you very much
this is what I need
Code: [Select]
sudo -u tc rsync -avh -e "ssh -p 2112" root@192.168.3.3:/mnt/sda2/remote_source/ /mnt/sda1/local_destionation >> /home/tc/rsync.log  2>&1 &
tried to specify the key before but still Host key verification failed.
Doesnt matter..
Code: [Select]
rsync -avh -e "ssh -p 2112 -i /home/tc/id_rsa" root@192.168.3.3:/mnt/sda2/remote_source/ /mnt/sda1/local_destionation >> /home/tc/rsync.log  2>&1 &
again thank you..
« Last Edit: July 31, 2019, 01:47:44 AM by aris »

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11629
Re: rsync wont start on schedule and boolocal
« Reply #20 on: July 31, 2019, 01:46:12 AM »
Hi aris
You're welcome. Glad I could help.