Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm looking for a way to keep a desktop and a laptop in sync. What I want to keep in sync are some folders, mainly ~/Documents, that are changed often when working on them.

If it matters I can connect to my desktop from anywhere via an URL but my laptop is harder to access since it might be behind NAT and such.

I have been looking at Ubuntu One but it seems to not go well with working on documents written in LaTeX. If I work on a .tex file in the Ubuntu One directory and compile it (with pdflatex) every now and then (as often as every 10 sec when working) it will create several new files including a pdf which are uploaded to Ubuntu One and this seems stupid since it will create continuous upload when working on .tex files. I also usually keep .tex documents version controlled by git and then every commit (which also can happen frequently) will cause upload (by changes in ./.git) so that it happens continuously when working. Another example is editing images that are saved often. What I think would be best is for sync to happen every tenth minute or at the end of every working session (but there might be some other way to handle this?).

share|improve this question
    
I think it'd be useful to split these up into individual questions as each one would have a likely different answer. –  Jorge Castro Jun 29 '11 at 10:10
    
@Jorge Castro Done! –  N.N. Jun 29 '11 at 10:26
add comment

3 Answers 3

I think you do not need to add the generated (PDF, dvi or Postscript) files to the version control system; however it makes sense to copy them to a synced directory or other server. I usually make this sort of things with the make command.

I have a Makefile like this in the directory where the LaTeX files are (indents are tabs, not spaces). See GNU Make Manual.

%.pdf: %.tex
        pdflatex  $<
        pdflatex  $<

store_pdf:
        cp example*.pdf path/to/synced_directory

upload_pdf:
        scp example*.pdf user@server.name.com:path/to/directory

clean:
        rm *.log *.aux *.nav *.vrb *.out *.snm *.toc

If you want to move the files to a synced directory or to a server where you have ssh access, you need to type:

make store_pdf
make upload_pdf

If you want to generate the example1.pdf from example1.tex, you need to type:

make example1.pdf

If you want to remove the files you do not need, you need to type:

make clean
share|improve this answer
    
Interesting. Maybe it's worth extending this solution from make to latexmk to able to take advantage of the latter's features. –  N.N. Jun 30 '11 at 11:13
add comment

You already use git, to that makes things easier. A solution here would be to use 2 git repositories, one that is synced by Ubuntu One and one that is not. You can then push your changes to the synced folder when, and only when, you want the synchronisation to happen.

You probably want to keep the version in ~/Documents synced along with all of your other documents (enable Ubuntu One sync for ~/Documents if you haven't already), so create a clone in a non-synced folder:

mkdir ~/nonsynced
cd ~/nonsynced
git clone ~/Documents/LATEX_PROJECT

You can then work on the files in ~/nonsynced/LATEX_PROJECT. When you want to synchronise, push to ~/Documents/LATEX_PROJECT:

git push ~/Documents/LATEX_PROJECT

If you then work on another synchronised computer you can get the up to date version by running:

git pull ~/Documents/LATEX_PROJECT

from ~/nonsynced/LATEX_PROJECT.

You will need to replace LATEX_PROJECT with the name of your version controlled folder in ~/Documents.

share|improve this answer
    
Just to clarify. The folder in your example that is synced with Ubuntu One is ~/Documents/LATEX_PROJECT, right? So a step that is not explicit in your example is activating Ubuntu One sync for ~/Documents/LATEX_PROJECT? –  N.N. Jun 29 '11 at 12:17
    
Yes, I was assuming the whole of ~/Documents was already being synced. –  dv3500ea Jun 29 '11 at 12:20
    
Have you got any suggestion for syncing other file types than those in LaTeX projects, e.g. images? –  N.N. Jun 29 '11 at 13:05
add comment
up vote 0 down vote accepted

This is a solution based on fossfreedom's answer to another question, Synchronizing 2 Ubuntu Systems with Unison, the Unison manual and my answer to another question.

Setup

Both computers

  1. sudo apt-get install openssh-server unison
  2. Test the SSH link from each computer to the other.

On the computer that might be behind NAT

  1. mkdir ~/.unison
  2. nano default.prf – Create a profile file named default.
  3. Write the profile file, e.g.:

    root = /home/user
    
    root = ssh://user@user.dyndns-ip.com//home/user
    
    path = Documents
    

Sync

Sync the computers by running unison -auto default on the computer that might be behind NAT. This will sync ~/Documents. I do this before and after my laptop leaves the LAN with my desktop to keep their documents in sync.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.