Linux - GeneralThis 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.
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.
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:
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?
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
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!
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.