Page 1 of 1

rsync - syncronising two directories passwordless

PostPosted: Jul 15th, '14, 12:54
by MrTempleDene
My problem is I have two computers, I edit my php source on both of them and want some way to set up both machines to quietly, in the background, make sure the two source directories keep in sync whenever both machines are on my local network.

I've been reading about rsyncd, unison and various other solutions until my head hurts with no real progress

Both machines run Mageia the laptop is on 4 and the PC is on 3 (and needs updating I know)

I don't want to have to do anything more than just boot up both machines.

I just get the feeling I have missed something obvious. Do feel free to tell me how stupid I am.

Re: synchronishing two directories

PostPosted: Jul 15th, '14, 15:19
by MrTempleDene
Well I have now got this far

rsync -h --progress --stats -r -tgo -p -l -D --update --protect-args /home/pete/Documents/rsynctest/ pete@192.168.1.202:/home/pete/Documents/rsynctest/

And I can run that as a cron job, but it asks for a password every time, working on that now.

Re: synchronishing two directories

PostPosted: Jul 15th, '14, 15:24
by napcok
I think you can just configure NFS for that. http://nfs.sourceforge.net/nfs-howto/ar ... whatis_nfs

Re: synchronishing two directories

PostPosted: Jul 15th, '14, 16:39
by Lebarhon
Hi,
Did you try LuckyBackup? It is in the Mageia depositories.
http://luckybackup.sourceforge.net/features.html

Re: synchronishing two directories

PostPosted: Jul 15th, '14, 16:49
by MrTempleDene
Thank you napcok, of course then the mounted directory just appears local, now why didn't I think of that. See I told you I could be called an idiot.

Re: synchronishing two directories

PostPosted: Jul 15th, '14, 16:51
by isadora
Please don't forget to mark the topic [SOLVED].
You can do so, by editing the subject/title in the first message in this topic.
Write [SOLVED] to the left of subject/title, thanks ahead. ;)

Re: synchronishing two directories

PostPosted: Jul 15th, '14, 16:52
by MrTempleDene
Lebarhon, Thanks for your suggestion, it was LuckyBackup that gave me help with the synatx for rsync.

My quest though would be for it to be totally automatic, I'm not totally happy about running a cron job for this really, but it will do for now.

Re: synchronishing two directories

PostPosted: Jul 15th, '14, 19:53
by doktor5000
MrTempleDene wrote:rsync -h --progress --stats -r -tgo -p -l -D --update --protect-args /home/pete/Documents/rsynctest/ pete@192.168.1.202:/home/pete/Documents/rsynctest/


Why all those flags? Are you really sure you need each of those? Just asking ...
Usually rsync -avz is totally sufficient. Add --progress if you want verbose progress output, and --dry-run if you only want to see what rsync would do, but don't change anything.

MrTempleDene wrote:And I can run that as a cron job, but it asks for a password every time, working on that now.

You want to enable key-based ssh authentication, that is pretty easy. Then instruct rsync to use ssh as transport and you're done.

What you want to do (if you want to enable passwordless login for the root user, more steps may be required)
Code: Select all
ssh-keygen -t rsa -b 2048
enter
enter
enter
ssh-copy-id user@targetmachine

ssh user@targetmachine


The last ssh command should not ask for password. This is the most simple scenario. There are plenty of howtos for that:
http://www.debian-administration.org/ar ... th_OpenSSH
http://askubuntu.com/questions/46930/ho ... -ssh-login
http://www.thegeekstuff.com/2008/11/3-s ... h-copy-id/
http://www.linuxproblem.org/art_9.html

Then use the option -e ssh for your rsync command. For more help and rsnyc examples check e.g.
https://wiki.archlinux.org/index.php/rsync

Re: rsync - syncronising two directories passwordless

PostPosted: Jul 16th, '14, 01:14
by MrTempleDene
It was luckybackup suggested all those, I have to admit to being in a hurry at that point so stuck with what worked.

But will azh sync both directories bidirectionally? I am not looking to just copy the files to a backup directory, I have two "live" directories and need them to sync "automagically" in both directions whenever the two computers are on the same network.

Re: rsync - syncronising two directories passwordless

PostPosted: Jul 16th, '14, 01:16
by MrTempleDene
And thanks for the ssh information, I will try that tomorrow.

Re: synchronishing two directories

PostPosted: Jul 16th, '14, 01:18
by MrTempleDene
isadora wrote:Please don't forget to mark the topic [SOLVED].
You can do so, by editing the subject/title in the first message in this topic.
Write [SOLVED] to the left of subject/title, thanks ahead. ;)


Don't worry, I will once it's all working and I can do a quick write up in case it is useful for anyone else. This may be basic stuff for some of you but it's all new to me.