emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Advice needed: Cant find a decent way to autosync my work TODO org file between laptop and work pc
@ 2014-05-24  5:11 Xebar Saram
  2014-05-24 16:49 ` Richard Lawrence
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Xebar Saram @ 2014-05-24  5:11 UTC (permalink / raw)
  To: org mode

[-- Attachment #1: Type: text/plain, Size: 770 bytes --]

Hi all

i need to sync my main work TODO org file between my work PC and laptop i
carry around on work related trips and when im at home. i have tried
several methods buy really none of them work.

i mainly used git over the last 6 months but that forces me to
pull/commit/push manually each time i add something to either machine and
that is really annoying. plus i get merge conflicts all the time

I have tried dropbox at the past but again this causes conflicts,
isntreliable to me (on my
linux laptop it doesn't always resume sync after sleep)

I am using linux (arch linux on laptop  and debian on work PC to be precise)

Also i use mobileorg on phones/tablets which works with various levels of
success :)

any advice would be hugely appreciated!

thanks alot

Z

[-- Attachment #2: Type: text/html, Size: 1218 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Advice needed: Cant find a decent way to autosync my work TODO org file between laptop and work pc
  2014-05-24  5:11 Advice needed: Cant find a decent way to autosync my work TODO org file between laptop and work pc Xebar Saram
@ 2014-05-24 16:49 ` Richard Lawrence
       [not found]   ` <CAHxk2pAX=dM_iAJEpTUaeYjPKVm8wELYBgkHZd=cPK__KPmDBw@mail.gmail.com>
  2014-05-24 22:54 ` Ken Mankoff
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Richard Lawrence @ 2014-05-24 16:49 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Xebar Saram

Hi Xebar,

Xebar Saram <zeltakc@gmail.com> writes:

> i mainly used git over the last 6 months but that forces me to
> pull/commit/push manually each time i add something to either machine and
> that is really annoying. plus i get merge conflicts all the time
>
> I have tried dropbox at the past but again this causes conflicts,
> isntreliable to me (on my
> linux laptop it doesn't always resume sync after sleep)

If neither git nor Dropbox works for you, I'm not sure this will be
helpful, but...

I personally use git for this.  To keep the effort of syncing and
merging low, I have a cron job set up to automatically commit in certain
repositories containing my Org files every hour.  It's just a
quick-and-dirty hack, but here it is:

#+BEGIN_SRC bash
#!/bin/bash
# Add org file changes to the repository
ROOT=$HOME
REPOS="org Documents/philosophy/dissertation Documents/philosophy/teaching Documents/philosophy/reading src/emacs"

commit_and_push()
{
  for REPO in $REPOS
  do
      echo "Repository: $ROOT/$REPO"
      cd $ROOT/$REPO

      if [ ! -d .git ]; then
	  echo "Not a git repository; skipping"
	  continue
      fi
      if [ ! -r autocommits ]; then
	  echo "No autocommits file found; skipping"
	  continue
      fi

      # Remove deleted files
      git ls-files --deleted -z | xargs -0 git rm >/dev/null 2>&1

      # Add files on whitelist to commit for current branch
      while read FILE
      do
	  git add $FILE
      done < autocommits

      git commit -m "$(date) from $(hostname) by autocommit.sh"
      STATUS=$?
      if [ $STATUS != 0 ]; then
	  echo "git commit failed with exit status $STATUS"
      fi

      # Push the current branch
      # requires branch.<name>.remote to be specified in git config
      # and ideally push.default = tracking 
      git push --porcelain
      STATUS=$?
      if [ $STATUS != 0 ]; then
	  echo "git push failed with exit status $STATUS"
      fi

  done
}

pull()
{
  for REPO in $REPOS
  do
      echo "Repository: $REPO"
      cd $ROOT/$REPO

      git status | grep 'modified:'
      if [ $? == 0 ]; then
	  echo "modified files present; fetching, but not pulling."
	  CMD="fetch"
      else
	  CMD="pull"
      fi

      git $CMD
      STATUS=$?
      if [ $STATUS != 0 ]; then
	  echo "git $CMD failed with exit status $STATUS"
      fi
  done
}

case "$1" in
  commit)
      commit_and_push
      ;;
  pull)
      pull
      ;;
  *)
      echo "Usage: $0 {commit|pull}"
      exit 1
      ;;
esac

exit 0
#+END_SRC

This script requires a file called "autocommits" in each repository in
$REPOS which is a whitelist of files to autocommit changes in.  Most of
my Org files are on such a list.

I run this from Cron like:
#+BEGIN_SRC cron
0 * * * * ~/bin/autocommits.sh commit >/dev/null 2>&1 
#+END_SRC

To make sure my changes are saved before this script runs, I have in my .emacs:
#+BEGIN_SRC elisp
(run-at-time "00:59" 3600 'org-save-all-org-buffers) ; cron commits on the hour
(add-hook 'before-save-hook 'org-update-all-dblocks)
#+END_SRC

And finally, to pull the autocommitted changes on a new machine:
$ autocommits.sh pull

So you still have to manually pull and fix any merge conflicts, but I
find that committing often generally keeps the work involved here
minimal (because I can't usually work on two machines at once!).

Hope that helps!

Best,
Richard

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Advice needed: Cant find a decent way to autosync my work TODO org file between laptop and work pc
       [not found]   ` <CAHxk2pAX=dM_iAJEpTUaeYjPKVm8wELYBgkHZd=cPK__KPmDBw@mail.gmail.com>
@ 2014-05-24 21:51     ` Richard Lawrence
  2014-05-24 22:30       ` Melleus
  0 siblings, 1 reply; 9+ messages in thread
From: Richard Lawrence @ 2014-05-24 21:51 UTC (permalink / raw)
  To: Martin Schöön; +Cc: emacs-orgmode

Martin Schöön <martin.schoon@gmail.com> writes:

> What if, as is the case for me, work computer runs Win7 and home computer
> runs Linux?
> Now I use a manual 'system' which shouldn't be necessary, I think.

Well, I don't run Windows on any of my systems, so someone else probably
has better advice here.

I'm pretty sure git runs on Windows, and in theory you should be able to
do something similar to the Bash script/cron job setup I described using
batch files.  But I'm no expert on that.

Another alternative would be to write a short ELisp program to do the
same thing, using `run-at-time' and `shell-command'...though I don't
know how shell-command works on Windows.

Also, Unison (http://www.cis.upenn.edu/~bcpierce/unison/) promises to do
two-way file sync between *nix and Windows.  I've never tried it; has
anyone else?

-- 
Best,
Richard


(If possible, please encrypt your reply to me using my PGP key:
Key ID: CF6FA646
Fingerprint: 9969 43E1 CF6F A646.
See http://www.ocf.berkeley.edu/~rwl/encryption.html for more information.)

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Advice needed: Cant find a decent way to autosync my work TODO org file between laptop and work pc
  2014-05-24 21:51     ` Richard Lawrence
@ 2014-05-24 22:30       ` Melleus
  2014-05-26  7:42         ` Samuel Loury
  0 siblings, 1 reply; 9+ messages in thread
From: Melleus @ 2014-05-24 22:30 UTC (permalink / raw)
  To: emacs-orgmode

Richard Lawrence <richard.lawrence@berkeley.edu> writes:

> Also, Unison (http://www.cis.upenn.edu/~bcpierce/unison/) promises to do
> two-way file sync between *nix and Windows.  I've never tried it; has
> anyone else?

I can recommend rsync (you can get it from Cygwin for Windows) for such
things. No fancy GUIs though. It just works.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Advice needed: Cant find a decent way to autosync my work TODO org file between laptop and work pc
  2014-05-24  5:11 Advice needed: Cant find a decent way to autosync my work TODO org file between laptop and work pc Xebar Saram
  2014-05-24 16:49 ` Richard Lawrence
@ 2014-05-24 22:54 ` Ken Mankoff
       [not found]   ` <CAHxk2pAR-8jAdtS1BdxxsCtfHo--km2HDhaWVQmA8RfcB+kKJQ@mail.gmail.com>
  2014-05-25 12:13 ` Josh Berry
  2014-05-26 18:08 ` Thierry Banel
  3 siblings, 1 reply; 9+ messages in thread
From: Ken Mankoff @ 2014-05-24 22:54 UTC (permalink / raw)
  To: Xebar Saram; +Cc: org mode


Do you have auto-revert enabled for that file? At the top of a
dropbox-shared Org file I have this:

# -*- coding: utf-8; eval: (auto-revert-mode 1); -*-

I still find it a bit buggy, and also have this code snippet which I
execute whenever I begin editing in that Org file. I also try to
remember to save it when done.

#+BEGIN_SRC emacs-lisp :results none
(revert-buffer nil t)
#+END_SRC

  -k.

On 2014-05-24 at 01:11, Xebar Saram <zeltakc@gmail.com> wrote:
> Hi all
>
> i need to sync my main work TODO org file between my work PC and laptop i
> carry around on work related trips and when im at home. i have tried
> several methods buy really none of them work.
>
> i mainly used git over the last 6 months but that forces me to
> pull/commit/push manually each time i add something to either machine and
> that is really annoying. plus i get merge conflicts all the time
>
> I have tried dropbox at the past but again this causes conflicts,
> isntreliable to me (on my
> linux laptop it doesn't always resume sync after sleep)
>
> I am using linux (arch linux on laptop  and debian on work PC to be precise)
>
> Also i use mobileorg on phones/tablets which works with various levels of
> success :)
>
> any advice would be hugely appreciated!
>
> thanks alot
>
> Z

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Advice needed: Cant find a decent way to autosync my work TODO org file between laptop and work pc
  2014-05-24  5:11 Advice needed: Cant find a decent way to autosync my work TODO org file between laptop and work pc Xebar Saram
  2014-05-24 16:49 ` Richard Lawrence
  2014-05-24 22:54 ` Ken Mankoff
@ 2014-05-25 12:13 ` Josh Berry
  2014-05-26 18:08 ` Thierry Banel
  3 siblings, 0 replies; 9+ messages in thread
From: Josh Berry @ 2014-05-25 12:13 UTC (permalink / raw)
  To: Xebar Saram; +Cc: org mode

[-- Attachment #1: Type: text/plain, Size: 1036 bytes --]

On Sat, May 24, 2014 at 1:11 AM, Xebar Saram <zeltakc@gmail.com> wrote:

>  need to sync my main work TODO org file between my work PC and laptop i
> carry around on work related trips and when im at home. i have tried
> several methods buy really none of them work.
>
> i mainly used git over the last 6 months but that forces me to
> pull/commit/push manually each time i add something to either machine and
> that is really annoying. plus i get merge conflicts all the time
>

I can't really help for the other items too easily, but have you tried
*not* syncing edits between a single files?  This would at least stop the
merge conflicts.

That is, if you had two sets of all of your .org files, one under
"desktop/" and the other under "laptop/", then you could setup a basic hook
in git that pushes/pulls on every change.  I believe org is good with the
refile commands that moving between the flies shouldn't be that much of a
burden, if you do that often.  Otherwise, things definitely work well for
agenda mode and such.

-josh

[-- Attachment #2: Type: text/html, Size: 1489 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Fwd: Advice needed: Cant find a decent way to autosync my work TODO org file between laptop and work pc
       [not found]   ` <CAHxk2pAR-8jAdtS1BdxxsCtfHo--km2HDhaWVQmA8RfcB+kKJQ@mail.gmail.com>
@ 2014-05-25 12:44     ` Martin Schöön
  0 siblings, 0 replies; 9+ messages in thread
From: Martin Schöön @ 2014-05-25 12:44 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org

[-- Attachment #1: Type: text/plain, Size: 773 bytes --]

I sent the following to the wrong recipient earlier today:

---------- Forwarded message ----------

Programs such as rsync and BittorrentSync only work if both computers are
up and running.
My computer at home is switched off when I don't use it and the same goes
for my
computer at work...

I have experimented a little with WebDAV but have failed to automate
syncing to the server.
I have not spent a lot of time on this so I don't say it isn't possible.

--------- Added comment: --------------

Commercial services such as Dropbox may not be OK for company sensitive
material.
Your mileage on this may differ depending on your company, where you live
and the
service provider.

-- 
Martin Schöön

http://hem.bredband.net/b262106/index.html

[-- Attachment #2: Type: text/html, Size: 1476 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Advice needed: Cant find a decent way to autosync my work TODO org file between laptop and work pc
  2014-05-24 22:30       ` Melleus
@ 2014-05-26  7:42         ` Samuel Loury
  0 siblings, 0 replies; 9+ messages in thread
From: Samuel Loury @ 2014-05-26  7:42 UTC (permalink / raw)
  To: Melleus, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 852 bytes --]

Melleus <melleus@openmailbox.org> writes:

> Richard Lawrence <richard.lawrence@berkeley.edu> writes:
>
>> Also, Unison (http://www.cis.upenn.edu/~bcpierce/unison/) promises to do
>> two-way file sync between *nix and Windows.  I've never tried it; has
>> anyone else?
>
> I can recommend rsync (you can get it from Cygwin for Windows) for such
> things. No fancy GUIs though. It just works.
I have not tried it yet, but
https://github.com/dooblem/bsync/blob/master/README.md could be of some
help. I guess it does like unison but using rsync.

Also, if you handle big files also, you may try git-annex
(http://git-annex.branchable.com/). I could be used to simply
synchronize files with "git config annex.largefiles 'exclude=*'" and
"git annex sync".

--
Konubinix
GPG Key    : 7439106A
Fingerprint: 5993 BE7A DA65 E2D9 06CE  5C36 75D2 3CED 7439 106A

[-- Attachment #2: Type: application/pgp-signature, Size: 472 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Advice needed: Cant find a decent way to autosync my work TODO org file between laptop and work pc
  2014-05-24  5:11 Advice needed: Cant find a decent way to autosync my work TODO org file between laptop and work pc Xebar Saram
                   ` (2 preceding siblings ...)
  2014-05-25 12:13 ` Josh Berry
@ 2014-05-26 18:08 ` Thierry Banel
  3 siblings, 0 replies; 9+ messages in thread
From: Thierry Banel @ 2014-05-26 18:08 UTC (permalink / raw)
  To: emacs-orgmode

You can try GIT-ANNEX
https://git-annex.branchable.com/

It is a synchronizer built on top of GIT



Le 24/05/2014 07:11, Xebar Saram a écrit :
> Hi all
>
> i need to sync my main work TODO org file between my work PC and
> laptop i carry around on work related trips and when im at home. i
> have tried several methods buy really none of them work.
>
> i mainly used git over the last 6 months but that forces me to
> pull/commit/push manually each time i add something to either machine
> and that is really annoying. plus i get merge conflicts all the time
>
> I have tried dropbox at the past but again this causes conflicts, isnt
> reliable to me (on my linux laptop it doesn't always resume sync after
> sleep)
>
> I am using linux (arch linux on laptop  and debian on work PC to be
> precise)
>
> Also i use mobileorg on phones/tablets which works with various levels
> of success :)
>
> any advice would be hugely appreciated!
>
> thanks alot
>
> Z

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-05-26 18:09 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-24  5:11 Advice needed: Cant find a decent way to autosync my work TODO org file between laptop and work pc Xebar Saram
2014-05-24 16:49 ` Richard Lawrence
     [not found]   ` <CAHxk2pAX=dM_iAJEpTUaeYjPKVm8wELYBgkHZd=cPK__KPmDBw@mail.gmail.com>
2014-05-24 21:51     ` Richard Lawrence
2014-05-24 22:30       ` Melleus
2014-05-26  7:42         ` Samuel Loury
2014-05-24 22:54 ` Ken Mankoff
     [not found]   ` <CAHxk2pAR-8jAdtS1BdxxsCtfHo--km2HDhaWVQmA8RfcB+kKJQ@mail.gmail.com>
2014-05-25 12:44     ` Fwd: " Martin Schöön
2014-05-25 12:13 ` Josh Berry
2014-05-26 18:08 ` Thierry Banel

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).