LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-13-2005, 11:15 PM   #1
bardanes
LQ Newbie
 
Registered: Jun 2004
Posts: 7

Rep: Reputation: 0
Linux-to-Linux smb copy (cron job)?


Hi,

Somewhat noob here.

I have a Debian Sarge Samba server and I want to backup files to a Buffalo LinkStation, which I have ordered. I don't know much about the Buffalo, but Buffalo tech support states that it runs a Linux kernel. Tech support knows nothing about accessing the Linkstation from Linux. I'm assuming that I can access the Linkstation by using smbmount with the appropriate user name and password in the following manner:

# mount -t smbfs -o username=name,password=pass //buffaloname/share /mountpnt/share

I want to set up a cron job to perform the backup described previously. I only want the Linkstation to be accessible when the cron job runs to do the copy.

Would the best approach be to write a script with something like:

#!/bin/sh -e
#
# cron copy script
#
mount -t smbfs -o username=name,password=pass //buffaloname/share /mountpnt/dest
cp -R sourcedir/* /mountpnt/dest
umount /mountpnt/dest

Is there a Samba/smb command that will combine the mount and copy? And is there a way that I can avoid having to put the password in the mount command?

Thanks.
 
Old 10-14-2005, 12:42 AM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Read the man pages for mount and smb
passwd program = /usr/bin/passwd %umount. There is a "credentials=<filename>" option.
Quote:
credentials=<filename>
specifies a file that contains a username and/or password. The
format of the file is:

username = <value>
password = <value>
Make sure that only root can read the credentials file.

You might want to use the "find" command to return the names of files changed after the last backup. That way, you won't be rewriting the same files over and over, and hopefully save time. Also, you may want to use the return value
of the mount command before attempting to perform the backup. Suppose the mount fails and you proceed to write to /mountpnt/dest. This will write files to the mount point directory instead of to the share. If there is an error mounting the share, you can log a message based on the return value. The man pages lists them:
Quote:
RETURN CODES
mount has the following return codes (the bits can be ORed):

0 success
1 incorrect invocation or permissions
2 system error (out of memory, cannot fork, no more loop devices)
4 internal mount bug or missing nfs support in mount
8 user interrupt
16 problems writing or locking /etc/mtab
32 mount failure
64 some mount succeeded
 
Old 10-14-2005, 12:32 PM   #3
JDaniels
LQ Newbie
 
Registered: Jun 2004
Location: Salt Lake City, UT
Distribution: Slackware
Posts: 24

Rep: Reputation: Disabled
rsync would work well. It only transfers updates, and it can transfer over different hosts. An example would be:

Code:
rsync -vaz /path/to/dir/ host:/path/to/dir
This would transfer files from /path/to/dir on the local machine, to /path/to/dir on host.
 
Old 10-17-2005, 12:08 PM   #4
bardanes
LQ Newbie
 
Registered: Jun 2004
Posts: 7

Original Poster
Rep: Reputation: 0
Thanks for the quick replies! I really appreciate the help!

I got the Buffalo and set up the copy script. rsync is great, but I couldn't use rsync because I couldn't open port 22 or install software on the Buffalo system partition without root privileges. I haven't found a way to hack into root on the Buffalo yet, but I'm still playing with it. So,

The initial script starts out like this facsimile (will be changed to use a case statement). I'm going to move the user/password information to an encrpyted file shortly.

#!/bin/sh -e
#
# Basic Buffalo link copy
#
DATER=`date +%b%_3d%_9T`
#
# Mount the Buffalo drive
#
echo $DATER buffalocopy: starting procedure
if !(/bin/mount -t smb -o user=bozo,password=theclown //buffalosoldier/backemup /mnt/dest)
then
echo $DATER buffalocopy: mount failed: could not mount remote share
echo $DATER buffalocopy: terminated with error 1
exit 1
fi

and so forth...any other comments or remarks? If not, thanks again!
 
Old 10-17-2005, 12:52 PM   #5
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 234Reputation: 234Reputation: 234
Not familiar w/ the Buffalo, could you post a link?
 
Old 10-17-2005, 03:45 PM   #6
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Although the Buffalo device may be running Linux, don't assume that it is running on a 32bit x86 processor. Adding software to it might void your warranty also.

Consider looking at the manual for the tar command. This is the command that is usually used for making backups. Also, the manual for find (includes find, locate and xargs) could help you in writing a cron script that performs selective incremental backups.

You may need to go to the source to obtain the manuals. The source files that are used to produce the info files can also produce pdf/dvi/ps versions of the manuals. Running "./configure && make pdf" in the source directory will produce the manuals. These are targets in the generated Makefile that are not run by default.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cron job? dr_zayus69 Linux - Newbie 14 12-01-2004 06:16 PM
cron job sanjith11 Linux - General 5 07-14-2004 01:06 PM
cron job ? johnyy Linux - Software 3 12-10-2003 06:00 PM
Cron job from linux box to windows box vadertech Linux - Networking 2 07-05-2003 11:22 AM
Using SMB to copy files from one linux machine to second linux machine. coppersky Linux - Networking 9 06-24-2003 12:07 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:49 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration