Jump to content

File Sharing/Sync


Guest ron67
 Share

Recommended Posts

Guest ron67

Hi I am totally new to this (Linux) and have a question about the best way to sync files between linux & XP.

 

I have a machine set up with Mandriva LE and an xp machine and each has a directory with mp3 files. What I want is to sync the directories, so if file A is added to the xp machine and file B is added to linux machine the end result is both directories have both files A & B. (On a nightly basis??)

 

What would the best way or software to implement this type of file sync????

 

I currently have samba set up (although it is currently only working one way: XP to linux - That will be a different post...)

 

Thanks in advance,

 

Ron

Link to comment
Share on other sites

If you want to automate the task make a bash script using the "rsync" command and run he script nightly as a cron job. The basic syntax is:

 

$ rsync -av <path to source> <path to destination>

 

The "-a" preseves permissions, symlinks, dates, etc. The "-v" is for verbose output. You can also add a "--delete" flag which will cause any files not in the source to be deleted from the destination, thus keeping the two directories perfectly in sync. That doesn't seem to be what you want so leave "delete" out of it

 

Example:

 

$ rysnc -av /home/patrick/music/ /mnt/net/music/

$ rsync -av /mnt/net/music/ /home/patrick/music/

 

where /mnt/net/music/ is the mount point and location of your mp3s on the networked XP box. All this assume you have your samba problems worked out. I think that would accomplish what you want. Leaving the trailing "/" is important IIRC which is one of the rsync nuances. See man rysnc for more details. Play around with the commands some on some test directories and you will get the hang of it. Once you understand the commands, making a bash script to automate the process is very simple. It consists of making a text file which we can call "msync" like so:

 

#!/bin/bash

rysnc -av /home/patrick/music/ /mnt/net/music/

rsync -av /mnt/net/music/ /home/patrick/music/

 

then make the text file executable with:

 

$ chmod +x </path/to/msync>

 

Once you have a script that will do what you want, you can set it up to run automatically at set times with "cron". Here's a little tutorial on that:

 

http://www.lysator.liu.se/~forsberg/linux/cron.html

 

There's the theory. Essentially you need to just copy the script to /etc/cron.daily/ and it will run every day automatically.

Edited by pmpatrick
Link to comment
Share on other sites

Guest cokelid

I've done this myself using rsync. You'd need to install cygwin (Unix tools for Windows) on XP and then you connect to the Linux box from XP via ssh. I.e. XP is your 'local' machine below, and Mandrake your remote machine.

 

This command will sync all files from the dir ~/mp3 on the remote machine to ./mp3 on the local box:

rsync -avuzb -e ssh login@my.remote.com:~/mp3 .

 

This command will sync all files from the lcoal machine to the remote box:

rsync -avuzb -e ssh mp3 login@my.remote.com:~

 

This would mean you wouldn't need samba and could sync the machines outside of a local network. You could also get fancy as setup Mandrake as an rsync server. This could allow connections from specified addresses without requiring passwords.

 

You could also use rsync on the samba directories (without the -e ssh). If you could get samba working both ways it would be very simple to add a cron job to the Mandrake machine to rsync the files each night ia samba and this wouldn't require any login passwords too...

 

HTH

 

Justin

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...