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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
10-13-2005, 11:15 PM
|
#1
|
LQ Newbie
Registered: Jun 2004
Posts: 7
Rep:
|
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.
|
|
|
10-14-2005, 12:42 AM
|
#2
|
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733
|
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
|
|
|
|
10-14-2005, 12:32 PM
|
#3
|
LQ Newbie
Registered: Jun 2004
Location: Salt Lake City, UT
Distribution: Slackware
Posts: 24
Rep:
|
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.
|
|
|
10-17-2005, 12:08 PM
|
#4
|
LQ Newbie
Registered: Jun 2004
Posts: 7
Original Poster
Rep:
|
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!
|
|
|
10-17-2005, 12:52 PM
|
#5
|
Senior Member
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
|
Not familiar w/ the Buffalo, could you post a link?
|
|
|
10-17-2005, 03:45 PM
|
#6
|
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733
|
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.
|
|
|
All times are GMT -5. The time now is 08:49 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|