LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 11-01-2009, 09:40 AM   #1
netimen
Member
 
Registered: May 2009
Posts: 43

Rep: Reputation: 15
mirroring a directory


I have a desktop under kubuntu 9.04 but I work mostly on a notebook under ubuntu 9.10 which is connected to the desktop via wi-fi

I want to have on the desktop a mirror of my notebook's working directory, so that every week (or day, or whatever) they synchronize automatically

What's the best way to do this?
 
Old 11-01-2009, 12:01 PM   #2
bertl
Member
 
Registered: May 2004
Location: Amsterdam, Holland
Distribution: Ubuntu, Redhat, Angstrom (others in the past)
Posts: 36

Rep: Reputation: 22
rsync is your friend. I don't remember whether rsync is installed by default. I tend to use rsync over ssh (safer, very easy), for that you need the openssh daemon running - let's say on your desktop.

On your desktop, then:

Code:
sudo apt-get install rsync openssh-server
On your notebook:

Code:
sudo apt-get install rsync
Because the ssh server is now running on your desktop, you'll need to run rsync commands from your laptop. From very safe (never overwrite anything newer) up to very exact (make sure the two trees are 100% the same):

1. Never overwrite anything on the desktop that looks more recent; never delete in general

Code:
notebookuser@notebook:~$ rsync -e ssh -avzP --update /on/notebook/documentdir desktopuser@ip-of-desktop:/on/desktop/
This synchronizes /on/notebook/documentdir with all its subfolders to /on/desktop/documentdir. If nothing was there before it comes down to a copy. Be careful with directory names in rsync: best to always have source dir without a / appended, and destination parent dir with a / appended. If usernames on notebook and desktop are the same you can leave the desktopuser@ part out. Use either the IP address of the desktop, or if you have working dns, the name.

2. Sync everything from notebook to desktop including files that look newer on the desktop, but don't delete stuff

Code:
notebookuser@notebook:~$ rsync -e ssh -avzP /on/notebook/documentdir desktopuser@ip-of-desktop:/on/desktop/
3. Sync the tree completely, make the desktop dir a clone of the notebook one. Delete files on the desktop that don't exist on the notebook.

Code:
notebookuser@notebook:~$ rsync -e ssh -avzP --delete /on/notebook/documentdir desktopuser@ip-of-desktop:/on/desktop/
4. Paranoid mode: Be even more exact and don't trust file modification times and sizes; read and compare all blocks on both sides and make absolutely sure the clone doesn't have any imperfections. This can be a lot slower. Also potentially delete stuff, like in (3).

Code:
notebookuser@notebook:~$ rsync -e ssh -avzP --checksum --delete /on/notebook/documentdir desktopuser@ip-of-desktop:/on/desktop/
If you want to do this every day/week whatever, you would have to make it a crontab entry, with the slight complication of needing a trusted key without password (private key on notebook in ~/.ssh, public key on desktop in ~/.ssh/authorized_keys).

Hope this helps - Bert.
 
Old 11-01-2009, 02:15 PM   #3
netimen
Member
 
Registered: May 2009
Posts: 43

Original Poster
Rep: Reputation: 15
thank you!

Can I have on my desktop sth like svn-repository for my notebook working directory? So I could look what I had in the directory a month ago
 
Old 11-01-2009, 02:37 PM   #4
bertl
Member
 
Registered: May 2004
Location: Amsterdam, Holland
Distribution: Ubuntu, Redhat, Angstrom (others in the past)
Posts: 36

Rep: Reputation: 22
Not really, with rsync - you'd need a versioning control system for that. Systems that are good at keeping track of changes, and systems that are good at syncing trees with potentially big files in them, are different beasts usually, although I'm not especially up to date with this.

What you can do is make weekly or monthly snapshots (copies, really, such as 'cp -a tree tree-20091101' ) of the tree on the desktop, if you have the space.

There are also tools around that use hardlinks to do this with less space. You'd have to google around for that, I haven't used those myself.
 
Old 11-01-2009, 02:39 PM   #5
bertl
Member
 
Registered: May 2004
Location: Amsterdam, Holland
Distribution: Ubuntu, Redhat, Angstrom (others in the past)
Posts: 36

Rep: Reputation: 22
You could have a look at http://blog.interlinked.org/tutorial...e_machine.html
 
Old 11-01-2009, 03:30 PM   #6
netimen
Member
 
Registered: May 2009
Posts: 43

Original Poster
Rep: Reputation: 15
Great!
 
Old 11-01-2009, 04:11 PM   #7
netimen
Member
 
Registered: May 2009
Posts: 43

Original Poster
Rep: Reputation: 15
How can I exclude from backup all subdirs named .svn?
 
Old 11-01-2009, 04:16 PM   #8
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
If you use rsync
Code:
--exclude=.svn
 
Old 11-01-2009, 05:11 PM   #9
netimen
Member
 
Registered: May 2009
Posts: 43

Original Poster
Rep: Reputation: 15
thx!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Mirroring a directory as read-only (mount --bind, kind of) sauce Linux - General 5 01-30-2008 04:06 AM
Mirroring Fedora Directory Server (FC3,FC4) gyankosh Linux - Software 1 09-27-2005 10:20 AM
Directory/folder mirroring utility? paulsh2k4 Linux - Software 2 09-14-2004 02:44 PM
Directory mirroring? Narooze Linux - Software 2 07-01-2004 08:51 AM
rync (mirroring a directory) bkeating Programming 2 06-25-2003 05:22 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 08:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration