[O] org back up

2012-10-17 Thread Sanjib Sikder
Hi,

I wanted to set a cron job for backing up all my org files as suggested by
Suvayu Ali.

#!/bin/bash

mkdir -p ~/org/backup  \
find $HOME -type f -name '*\.org' ! -path $HOME/org/backup/* \
-exec cp -t ~/org/backup/ \{\} \;


In Ubuntu I have put the bash file in cron.daily but it seems it is not
working. A little googling says I need to give full path for directories.
may I modify it like this ? I am not sure about the find $HOME part and
guess rest of the paths are correct.

#!/bin/bash

mkdir -p /home/USERNAME/org/backup  \
find $HOME -type f -name '*\.org' ! -path /home/USERNAME/org/backup/* \
-exec cp -t /home/USERNAME/org/backup/ \{\} \;

Can anybody confirm the correctness of this code?

Thanks
-
*Sanjib Sikder
*Ph.D. Fellow
Chemical Engineering
IIT Bombay*

*


Re: [O] org back up

2012-10-17 Thread Teemu Likonen
Sanjib Sikder [2012-10-17 23:55:12 +0530] wrote:

 #!/bin/bash

 mkdir -p /home/USERNAME/org/backup  \
 find $HOME -type f -name '*\.org' ! -path /home/USERNAME/org/backup/* \
 -exec cp -t /home/USERNAME/org/backup/ \{\} \;

How about this:


#!/bin/sh

target=$HOME/org/backup
mkdir -p $target  \
find $HOME -type f -name '*.org' ! -path $target/* \
-exec cp -t $target {} +



Re: [O] org back up

2012-10-17 Thread Sanjib Sikder
Hi,

No it is not working.

I copied the code in the backup.sh file and put into /etc/cron.hourly
---
#!/bin/sh

target=$HOME/org/backupOrg
mkdir -p $target  \
find $HOME -type f -name '*.org' ! -path $target/* \
-exec cp -t $target {} +

echo Daily Org Files Backup Successful: $(date) 
/home/USERNAME/mybackupOrg.log
---
And then changed the crontab hourly setting to 26.

/etc/crontab
# m h dom mon dow usercommand
26 ** * *rootcd /  run-parts --report /etc/cron.hourly
---

Even after 26th minute, there is no sign of the code in work. Is it that
$HOME is not allowed and I need to give full path ?

Thanks

-
*Sanjib Sikder
*Ph.D. Fellow
Chemical Engineering
IIT Bombay*

*



On Thu, Oct 18, 2012 at 12:11 AM, Teemu Likonen tliko...@iki.fi wrote:

 Sanjib Sikder [2012-10-17 23:55:12 +0530] wrote:

  #!/bin/bash
 
  mkdir -p /home/USERNAME/org/backup  \
  find $HOME -type f -name '*\.org' ! -path /home/USERNAME/org/backup/* \
  -exec cp -t /home/USERNAME/org/backup/ \{\} \;

 How about this:


 #!/bin/sh

 target=$HOME/org/backup
 mkdir -p $target  \
 find $HOME -type f -name '*.org' ! -path $target/* \
 -exec cp -t $target {} +



Re: [O] org back up

2012-10-17 Thread Teemu Likonen
Sanjib Sikder [2012-10-18 00:32:00 +0530] wrote:

 Even after 26th minute, there is no sign of the code in work. Is it that
 $HOME is not allowed and I need to give full path ?

Ah, I thought that you'd run it from your personal crontab. So yes,
write paths from root's point of view.



Re: [O] org back up

2012-10-17 Thread Achim Gratz
Sanjib Sikder writes:
 I wanted to set a cron job for backing up all my org files as
 suggested by Suvayu Ali.

Please don't.  If you consider this a viable backup strategy, you might
just as well have no backup at all.  You should use a VCS like Git to be
able to revert to an earlier version of your files.  If necessary, make
Org a sub-project (that's specific to Git of course) so that not only
your files but also Org will move back in time when you request that.
Defending against loss of data is only really possible if you copy them
to a different medium in a different location.  Again, Git would help
you do that by allowing you to use a remote repository on some server
you can access.


Regards,
Achim.
-- 
+[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]+

Factory and User Sound Singles for Waldorf Blofeld:
http://Synth.Stromeko.net/Downloads.html#WaldorfSounds




Re: [O] org back up

2012-10-17 Thread Sanjib Sikder
Hi,

I do not find personal crontab file. how do I create it ? crontab -e says
my personal file is not there

If I want to run it as root then how do modify the following code as it is
nor working ..
---
#!/bin/bash

mkdir -p /home/USERNAME/org/backup  \
find $HOME -type f -name '*\.org' ! -path /home/USERNAME/org/backup/* \
-exec cp -t /home/USERNAME/org/backup/ \{\} \;
echo Daily Org Files Backup Successful: $(date) 
/home/USERNAME/mybackupOrg.log
-


Thanks

-
*Sanjib Sikder
*Ph.D. Fellow
Chemical Engineering
IIT Bombay*

*



On Thu, Oct 18, 2012 at 12:38 AM, Teemu Likonen tliko...@iki.fi wrote:

 Sanjib Sikder [2012-10-18 00:32:00 +0530] wrote:

  Even after 26th minute, there is no sign of the code in work. Is it that
  $HOME is not allowed and I need to give full path ?

 Ah, I thought that you'd run it from your personal crontab. So yes,
 write paths from root's point of view.



Re: [O] org back up

2012-10-17 Thread Nick Dokos
Teemu Likonen tliko...@iki.fi wrote:

 Sanjib Sikder [2012-10-18 00:32:00 +0530] wrote:
 
  Even after 26th minute, there is no sign of the code in work. Is it that
  $HOME is not allowed and I need to give full path ?
 
 Ah, I thought that you'd run it from your personal crontab. So yes,
 write paths from root's point of view.
 

[I replied to Sanjib privately on the grounds that it's OT for the list,
 but let me add a couple of notes to this thread before we shut it off
 as completely OT: cron issues are hardly germane to org.]

o Adding personal items to root-owned crontabs is a *bad idea* indeed.

o One should try the script by hand before trying to incorporate it into cron:
  much easier to debug.

o cron operates in a restricted environment: just run `env' as a cron job to
  find out what it knows (hint: not much).

o Quite apart from cron issues, the backup method in the script is
  fundamentally flawed in my opinion: iiuc, it flattens the hierarchy,
  so if you have org files with the same name in different directories,
  only *one* will be saved into the backup directory - hardly a reliable
  backup.

Nick



Re: [O] org back up

2012-10-17 Thread Sanjib Sikder
Hi,

Thanks a lot.

-
*Sanjib Sikder
*Ph.D. Fellow
Chemical Engineering
IIT Bombay*

*



On Thu, Oct 18, 2012 at 1:06 AM, Nick Dokos nicholas.do...@hp.com wrote:

 Teemu Likonen tliko...@iki.fi wrote:

  Sanjib Sikder [2012-10-18 00:32:00 +0530] wrote:
 
   Even after 26th minute, there is no sign of the code in work. Is it
 that
   $HOME is not allowed and I need to give full path ?
 
  Ah, I thought that you'd run it from your personal crontab. So yes,
  write paths from root's point of view.
 

 [I replied to Sanjib privately on the grounds that it's OT for the list,
  but let me add a couple of notes to this thread before we shut it off
  as completely OT: cron issues are hardly germane to org.]

 o Adding personal items to root-owned crontabs is a *bad idea* indeed.

 o One should try the script by hand before trying to incorporate it into
 cron:
   much easier to debug.

 o cron operates in a restricted environment: just run `env' as a cron job
 to
   find out what it knows (hint: not much).

 o Quite apart from cron issues, the backup method in the script is
   fundamentally flawed in my opinion: iiuc, it flattens the hierarchy,
   so if you have org files with the same name in different directories,
   only *one* will be saved into the backup directory - hardly a reliable
   backup.

 Nick



Re: [O] org back up

2012-10-17 Thread Teemu Likonen
Sanjib Sikder [2012-10-18 00:56:46 +0530] wrote:

 I do not find personal crontab file. how do I create it ? crontab -e says
 my personal file is not there

With crontab -e in Debian system.

 If I want to run it as root then how do modify the following code as
 it is nor working ..

You should probably read the manual page of find and learn all the
relevant options. But here's my new version which uses full paths.


#!/bin/sh

dir=/home/USERNAME
target=$dir/org/backup

mkdir -p $target  \
find $dir -type f -name '*.org' ! -path $target/* \
-exec cp -t $target {} +



Re: [O] org back up

2012-10-17 Thread Russell Adams
I second using a VCS instead. I have my Org files in a Bazaar repo,
and a cron job setup to commit hourly if changes occur.



On Wed, Oct 17, 2012 at 09:25:15PM +0200, Achim Gratz wrote:
 Sanjib Sikder writes:
  I wanted to set a cron job for backing up all my org files as
  suggested by Suvayu Ali.

 Please don't.  If you consider this a viable backup strategy, you might
 just as well have no backup at all.  You should use a VCS like Git to be
 able to revert to an earlier version of your files.  If necessary, make
 Org a sub-project (that's specific to Git of course) so that not only
 your files but also Org will move back in time when you request that.
 Defending against loss of data is only really possible if you copy them
 to a different medium in a different location.  Again, Git would help
 you do that by allowing you to use a remote repository on some server
 you can access.


 Regards,
 Achim.
 --
 +[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]+

 Factory and User Sound Singles for Waldorf Blofeld:
 http://Synth.Stromeko.net/Downloads.html#WaldorfSounds




--
Russell Adamsrlad...@adamsinfoserv.com

PGP Key ID: 0x1160DCB3   http://www.adamsinfoserv.com/

Fingerprint:1723 D8CA 4280 1EC9 557F  66E8 1154 E018 1160 DCB3



Re: [O] org back up

2012-10-17 Thread Suvayu Ali
Hello Sanjib and others,

Sorry to continue with this terribly off-topic thread, but as the person
who wrote that snippet I felt I should clarify.

On Wed, Oct 17, 2012 at 03:36:42PM -0400, Nick Dokos wrote:
 Teemu Likonen tliko...@iki.fi wrote:
 
  Sanjib Sikder [2012-10-18 00:32:00 +0530] wrote:
  
   Even after 26th minute, there is no sign of the code in work. Is it that
   $HOME is not allowed and I need to give full path ?
  
  Ah, I thought that you'd run it from your personal crontab. So yes,
  write paths from root's point of view.
  
 
 o Quite apart from cron issues, the backup method in the script is
   fundamentally flawed in my opinion: iiuc, it flattens the hierarchy,
   so if you have org files with the same name in different directories,
   only *one* will be saved into the backup directory - hardly a reliable
   backup.
 

If you look at the original thread, my solution was a suggestion for the
specific case[1] of the original poster of that thread.  This is _not_ a
reliable way to back up your files.  As others have mentioned, a
distributed version control system like git, mercurial or bazar would be
well suited.  However I personally believe in redundancy being the best
backup and use at least 3 ways to backup my org files: git, dropbox and
rsync to a different physical drive.


Footnotes:

[1] The OP wanted to aggregate all org files in his home area to a
specific backup directory.

-- 
Suvayu

Open source is the future. It sets us free.