LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Is it possible to access samba server from command line? (https://www.linuxquestions.org/questions/linux-general-1/is-it-possible-to-access-samba-server-from-command-line-410142/)

RodWC 01-31-2006 05:26 PM

Is it possible to access samba server from command line?
 
Hi all, the subject already asks the question. :) The reason I ask is that I would like to be able to set something up (like cron, or just a "clickable" script) to backup/synchronize certain directories on my computer with a server. I can do it through KDE with drag and drop, but that is not a very good solution for me. Something along the lines of "SyncBack" (http://www.2brightsparks.com/syncbac...back-hub.html). If I could write a script that would be able to copy files back and forth via samba, that would work too. such as: "cp -a /home/rodney/documents smb://debian/Disk-2/documents". Obviously, that does not work! But that's generally the idea of what I want to accomplish.

Any suggestions appreciated.

Brian1 01-31-2006 05:50 PM

For a script use the mount command to mount the share, copy files to the share mount location, and then umount the share. I think this is what you are after.

Brian1

haertig 01-31-2006 06:33 PM

Quote:

Originally Posted by RodWC
... such as: "cp -a /home/rodney/documents smb://debian/Disk-2/documents".

Do you have a regular user account on the remote server?

If so, something like this would probably do the trick:
Code:

rsync -ave ssh /home/rodney/documents/ userid@remote_server:/backup_directory/documents/

haertig 01-31-2006 07:02 PM

I am writing my own backup script that sounds similar to what you're attempting to do. Below is what I've gotten written so far. It is a "proof of concept" framework only. I HAVE NOT TRIED EXECUTING IT YET! But you can get the general idea of where I'm heading by looking at the (possibly incorrect - no, PROBABLY incorrect!) code below. I just threw in likely looking candidate parameters into my proof-of-concept so I will remember to investigate them further. I may have specificed some incompatible options. Run "man rsync" to see all the neat things you can do with this command.

You might be able to beef it up and use something similar. I will be using my script locally, but since you want to go over a network you'd need to add something like this to the rsync command: "--rsh=ssh". And also modify the lines mentioning "destination" below to some other form consistant with a remote server as the destination.

Code:

rm -rf /destination/snapshot.3
mv /destination/snapshot.2 /destination/snapshot.3
mv /destination/snapshot.1 /destination/snapshot.2
mv /destination/snapshot.0 /destination/snapshot.1

rsync --verbose \
      --archive \
      --one-file-system \
      --modify-window=1 \
      --link-dest=/destination/snapshot.1 \
      --delete \
      --delete-after \
      --delete-excluded \
      --filter="merge /etc/rsync/default.rules" \
      --filter="dir-merge /.rsync_filter" \
        /source/directory/ \
        /destination/snapshot.0

touch /destination/snapshot.0


RodWC 02-01-2006 04:33 PM

Thank you very much! I've been toying around with it so far, and it seems to work fine (with a few quirks, but most of those are cause by me!). Don't have much time at this point to put together a script with every little thing I want to do, but I think if I save yours for reference that will help too.

I will likely be back at another date to ask some more questions, so I'll save this thread and come back to it later.

Brian, I'm not sure what you mean; can you actually mount a samba share locally (from another computer)?

Nylex 02-02-2006 02:35 AM

Quote:

Originally Posted by RodWC
Brian, I'm not sure what you mean; can you actually mount a samba share locally (from another computer)?

You can, with the smbmount command.


All times are GMT -5. The time now is 03:17 AM.