Buffalo NAS-Central Forums

Welcome to the Linkstation Wiki community
It is currently Sat Aug 30, 2014 7:18 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 11 posts ] 
Author Message
PostPosted: Wed Mar 27, 2013 8:03 pm 
Offline
Newbie

Joined: Tue Feb 12, 2013 6:46 pm
Posts: 12
I configured ssh access to my Buffalo Linkstation Duo LS-WXL (firmware version 1.64), and then tried to change my backup scripts from using SMB-shares
Code:
rsync  /local/src/path  //dsthost/share/

to
Code:
rsync  -e "ssh -i /home/root/.ssh/id_rsa"  /local/src/path  root@dsthost:/mnt/array1/shareDir


Allthough /mnt/array1/shareDir on root@dsthost is fully writable when using ssh from any remote host, it is not when a cron-started script tries to access it, even if it uses the same private/public key pair to access.

Any idea?


(edit: fixed second rsync call cmd)


Top
 Profile  
 
PostPosted: Thu Mar 28, 2013 9:13 am 
Offline
Moderator

Joined: Fri Jun 29, 2007 10:39 am
Posts: 2588
The crontab script line is working when called on the
local command line manually as user "root"?
Your ssh-key is NOT password protected?

_________________
Please do not use private mail (PN/M) to ask questions. Use the proper forum instead. (me)

If there is no verified backup of a dataset, the dataset, by definition, is unimportant. (c't 2012)

RAID (no matter which level) never ever substitutes a backup. (me)


Top
 Profile  
 
PostPosted: Thu Mar 28, 2013 8:33 pm 
Offline
Newbie

Joined: Tue Feb 12, 2013 6:46 pm
Posts: 12
Thanks for your answer.

Quote:
The crontab script line is working when called on the
local command line manually as user "root"?

yes

Quote:
Your ssh-key is NOT password protected?

no.
Is this relevant for the problem?


Top
 Profile  
 
PostPosted: Fri Mar 29, 2013 7:42 am 
Offline
Moderator

Joined: Fri Jun 29, 2007 10:39 am
Posts: 2588
If the ssh key is password protected, you can't use it in this scenario,
because there is noone entering the password. ;-)
Could you please use the COMPLETE path for rsync and retry?
E.g. /mnt/.optware/bin/rsync (your path may be different).

_________________
Please do not use private mail (PN/M) to ask questions. Use the proper forum instead. (me)

If there is no verified backup of a dataset, the dataset, by definition, is unimportant. (c't 2012)

RAID (no matter which level) never ever substitutes a backup. (me)


Top
 Profile  
 
PostPosted: Sat Mar 30, 2013 11:26 pm 
Offline
Newbie

Joined: Tue Feb 12, 2013 6:46 pm
Posts: 12
Quote:
If the ssh key is password protected, you can't use it in this scenario,
because there is noone entering the password. ;-)

Of course, this is clear, I thought you know something like 'rsync does not accept passphrase-less keys' when I asked for the relevance. My key is WITHOUT passphrase (allthough there would actually be ways to pass one to ssh without a roboter sitting in front of the pc, eg sshpass)
Quote:
Could you please use the COMPLETE path for rsync and retry?

To be honest, my script never reached the point where rsync is invoked. The best is to show you a part of the code (the variable identifiers are self-explaining, I think):
Code:
  test -d "$SRC_BASEPATH"  ||  xc=51
  test -r "$SRC_BASEPATH"  ||  xc=52
  test "`ssh -f $DST_LOGIN_SSH_USER@$DST_HOST "test -d '$dstBasePath' && echo true"`" == true  ||  xc=53
  test "`ssh -f $DST_LOGIN_SSH_USER@$DST_HOST "test -w '$dstBasePath' && echo true"`" == true  ||  xc=54

  if (( xc > 0 )); then
    errlog="${ERRLOG}${ERRLOG[$xc]}"
    errmail="${ERRMAIL[$xc]}${NL}    "
    do_log "$errlog" "$errmail" $xc
    exit $xc
  fi


The test -d '$dstBasePath' check passed ok, but test -w '$dstBasePath' sets $xc (== eXitCode) to value 54, which then makes the script to log an error and send me an e-mail with an appropriate error message. Then it exits.

In the meantime, I added the following lines to the script for some more testing (please note the fully qualified filename of the executable :) )
Code:
/usr/bin/ssh  $DST_LOGIN_SSH_USER@$DST_HOST "test -d '$dstBasePath' && echo true" >>$LOG_FILE
/usr/bin/ssh  $DST_LOGIN_SSH_USER@$DST_HOST "echo '$dstBasePath'" >>$LOG_FILE
/usr/bin/ssh  $DST_LOGIN_SSH_USER@$DST_HOST "test -w '$dstBasePath' && echo true || echo false" >>$LOG_FILE

And it's crazy:
If cron starts the script, I get no output written into $LOG_FILE, if I start it on the cmdline, I get
true
/mnt/array1/hMail
true
,
as one would expect it.

If somebody can help with this, I would highly appreciate it, but I now think it is rather a cron than a Buffalo NAS thing.


Top
 Profile  
 
PostPosted: Sun Mar 31, 2013 10:49 am 
Offline
Moderator

Joined: Fri Jun 29, 2007 10:39 am
Posts: 2588
Are you sure, the script has all the necessary infos when running
as a cron script?
You are aware, that within cron scripts, you have to load the user
profile explicitly or you won't have a proper environment?

_________________
Please do not use private mail (PN/M) to ask questions. Use the proper forum instead. (me)

If there is no verified backup of a dataset, the dataset, by definition, is unimportant. (c't 2012)

RAID (no matter which level) never ever substitutes a backup. (me)


Top
 Profile  
 
PostPosted: Sun Mar 31, 2013 6:48 pm 
Offline
Newbie

Joined: Tue Feb 12, 2013 6:46 pm
Posts: 12
Thanks for your reply, this one sounds very interesting to me.
Quote:
you have to load the user
profile explicitly or you won't have a proper environment?

What do you mean with this? Do I have to source e.g. ~/.bashrc within the script that is startet by cron?
Maybe it's important to say that:
1) it is a user crontab starting the script, not /etc/crontab
2) the script worked without problems when I used Win shares as destination paths, i.e.
Code:
test -w "//$DST_HOST/SHARE"   ||  xc=54
...
rsync $RSYNC_OPTIONS "$srcPath" "//$DST_HOST/SHARE/20130219"
instead of
Code:
test "`ssh -f $DST_LOGIN_SSH_USER@$DST_HOST "test -w '/mnt/array1/hMail' && echo true"`" == true  ||  xc=54
...
rsync $RSYNC_OPTIONS -e "ssh -i $DST_LOGIN_SSH_PRIVATE_KEY" "$srcPath" $DST_LOGIN_SSH_USER@$DST_HOST:/mnt/array1/hMail/20130219
I realy appreciate your support, thank you.


Top
 Profile  
 
PostPosted: Mon Apr 01, 2013 11:08 am 
Offline
Moderator

Joined: Fri Jun 29, 2007 10:39 am
Posts: 2588
If there is no secret information in your script, could you
please post the complete script?
It is hard to find a problem, if one can't look at the full
scenario.

_________________
Please do not use private mail (PN/M) to ask questions. Use the proper forum instead. (me)

If there is no verified backup of a dataset, the dataset, by definition, is unimportant. (c't 2012)

RAID (no matter which level) never ever substitutes a backup. (me)


Top
 Profile  
 
PostPosted: Mon Apr 01, 2013 10:00 pm 
Offline
Newbie

Joined: Tue Feb 12, 2013 6:46 pm
Posts: 12
The script is quite long, so I exported it as syntax-highlighted HTML-file. Here you can view it:
http://cs.sdf-eu.org/tmp/bkp_hmail_data.sh.html
As there are several backup-scripts for the same server, they all source a config-file with data which is the same for all of them:
http://cs.sdf-eu.org/tmp/bkp_svr_data.conf.html

(EDIT: The config-file was written and still is true for scripts using Win-shares as destination, so the error-messages within the config-files may be wrong for this very script. All the other variables should be ok for either versions.)

If you prefer to download the text files:
http://cs.sdf-eu.org/tmp/bkp_hmail_data.sh
http://cs.sdf-eu.org/tmp/bkp_svr_data.conf

As basic information: The scripts are running on a Win 2008 Server OS under Cygwin.

And if you really prefer to have the files posted here, I can of course do that.

.


Top
 Profile  
 
PostPosted: Tue Apr 02, 2013 12:07 pm 
Offline
Moderator

Joined: Fri Jun 29, 2007 10:39 am
Posts: 2588
Sorry, but it may be a completely different cause, because
you are running Cygwin on a Windows Server Environment.

Check if "/var/log" and "/var/log/bkp_hmail_data.log" has
sufficient user rights (read: is read- and writeable for everyone).
Check if bash can really be accessed via /bin/bash. You are
using this in the shebang line.

For everything else, I can't help, because I have absolutely no
clue of neither Windows Server OS nor Cygwin specialities.
Sorry.

_________________
Please do not use private mail (PN/M) to ask questions. Use the proper forum instead. (me)

If there is no verified backup of a dataset, the dataset, by definition, is unimportant. (c't 2012)

RAID (no matter which level) never ever substitutes a backup. (me)


Top
 Profile  
 
PostPosted: Tue Apr 02, 2013 10:18 pm 
Offline
Newbie

Joined: Tue Feb 12, 2013 6:46 pm
Posts: 12
@kenatonline: Many thanks anyway for your effort.

Anyone else with an idea? What kenatonline says is of course true: Cygwin tries to map Unix privileges to Windows privileges, which is not possible 1:1, so there might be a reason for this problem. But as the script is running flawlessly from (Cygwin-) commandline, but not as (Cygwin-) cron job, I think I have to look for a solution in cron direction.

PS (for future support):
Quote:
Check if "/var/log" and "/var/log/bkp_hmail_data.log" has
sufficient user rights (read: is read- and writeable for everyone).
Check if bash can really be accessed via /bin/bash

My script is running, and the mentioned log file is full of success messages before I switched to accessing the destination path by ssh and full of error messages afterwards. So all of these questions can be answered with yes. But to be sure, I checked it again:
Code:
root@touhot-svr ~ # type -a bash
bash ist /usr/bin/bash
bash ist /usr/bin/bash
bash ist /bin/bash
root@touhot-svr ~ # ls -dl /var/log
drwxrwxrwx+ 1 root none 0 29. Jan 01:30 /var/log
root@touhot-svr ~ # ls -l /var/log/bkp_hmail_data.log
-rw-rw-rw- 1 root admins 252226  2. Apr 03:11 /var/log/bkp_hmail_data.log

(The script is run by root)

.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google [Bot] and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:

Protected by Anti-Spam ACP
Protected by Anti-Spam ACP Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group