Linux-to-Linux smb copy (cron job)?
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:
# cron copy script
mount -t smbfs -o username=name,password=pass //buffaloname/share /mountpnt/dest
cp -R sourcedir/* /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?
Read the man pages for mount and smb
passwd program = /usr/bin/passwd %umount. There is a "credentials=<filename>" option.
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:
rsync would work well. It only transfers updates, and it can transfer over different hosts. An example would be:
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.
# Basic Buffalo link copy
# Mount the Buffalo drive
echo $DATER buffalocopy: starting procedure
if !(/bin/mount -t smb -o user=bozo,password=theclown //buffalosoldier/backemup /mnt/dest)
echo $DATER buffalocopy: mount failed: could not mount remote share
echo $DATER buffalocopy: terminated with error 1
and so forth...any other comments or remarks? If not, thanks again!
Not familiar w/ the Buffalo, could you post a link?
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 07:06 AM.|