* org back up
@ 2012-10-17 18:25 Sanjib Sikder
2012-10-17 18:41 ` Teemu Likonen
2012-10-17 19:25 ` Achim Gratz
0 siblings, 2 replies; 11+ messages in thread
From: Sanjib Sikder @ 2012-10-17 18:25 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 828 bytes --]
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*
*
[-- Attachment #2: Type: text/html, Size: 2771 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: org back up
2012-10-17 18:25 org back up Sanjib Sikder
@ 2012-10-17 18:41 ` Teemu Likonen
2012-10-17 19:02 ` Sanjib Sikder
2012-10-17 19:25 ` Achim Gratz
1 sibling, 1 reply; 11+ messages in thread
From: Teemu Likonen @ 2012-10-17 18:41 UTC (permalink / raw)
To: Sanjib Sikder; +Cc: emacs-orgmode
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" {} +
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: org back up
2012-10-17 18:41 ` Teemu Likonen
@ 2012-10-17 19:02 ` Sanjib Sikder
2012-10-17 19:08 ` Teemu Likonen
0 siblings, 1 reply; 11+ messages in thread
From: Sanjib Sikder @ 2012-10-17 19:02 UTC (permalink / raw)
To: Teemu Likonen; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1398 bytes --]
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 user command
26 * * * * root cd / && 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 <tlikonen@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" {} +
>
[-- Attachment #2: Type: text/html, Size: 2201 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: org back up
2012-10-17 19:02 ` Sanjib Sikder
@ 2012-10-17 19:08 ` Teemu Likonen
2012-10-17 19:26 ` Sanjib Sikder
2012-10-17 19:36 ` Nick Dokos
0 siblings, 2 replies; 11+ messages in thread
From: Teemu Likonen @ 2012-10-17 19:08 UTC (permalink / raw)
To: Sanjib Sikder; +Cc: emacs-orgmode
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.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: org back up
2012-10-17 19:08 ` Teemu Likonen
@ 2012-10-17 19:26 ` Sanjib Sikder
2012-10-17 19:41 ` Teemu Likonen
2012-10-17 19:36 ` Nick Dokos
1 sibling, 1 reply; 11+ messages in thread
From: Sanjib Sikder @ 2012-10-17 19:26 UTC (permalink / raw)
To: Teemu Likonen; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 995 bytes --]
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 <tlikonen@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.
>
[-- Attachment #2: Type: text/html, Size: 2262 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: org back up
2012-10-17 19:26 ` Sanjib Sikder
@ 2012-10-17 19:41 ` Teemu Likonen
0 siblings, 0 replies; 11+ messages in thread
From: Teemu Likonen @ 2012-10-17 19:41 UTC (permalink / raw)
To: Sanjib Sikder; +Cc: emacs-orgmode
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" {} +
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: org back up
2012-10-17 19:08 ` Teemu Likonen
2012-10-17 19:26 ` Sanjib Sikder
@ 2012-10-17 19:36 ` Nick Dokos
2012-10-17 19:38 ` Sanjib Sikder
2012-10-18 0:14 ` Suvayu Ali
1 sibling, 2 replies; 11+ messages in thread
From: Nick Dokos @ 2012-10-17 19:36 UTC (permalink / raw)
To: Teemu Likonen; +Cc: emacs-orgmode, Sanjib Sikder
Teemu Likonen <tlikonen@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
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: org back up
2012-10-17 19:36 ` Nick Dokos
@ 2012-10-17 19:38 ` Sanjib Sikder
2012-10-18 0:14 ` Suvayu Ali
1 sibling, 0 replies; 11+ messages in thread
From: Sanjib Sikder @ 2012-10-17 19:38 UTC (permalink / raw)
To: nicholas.dokos; +Cc: Teemu Likonen, emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1397 bytes --]
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.dokos@hp.com> wrote:
> Teemu Likonen <tlikonen@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
>
[-- Attachment #2: Type: text/html, Size: 2153 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: org back up
2012-10-17 19:36 ` Nick Dokos
2012-10-17 19:38 ` Sanjib Sikder
@ 2012-10-18 0:14 ` Suvayu Ali
1 sibling, 0 replies; 11+ messages in thread
From: Suvayu Ali @ 2012-10-18 0:14 UTC (permalink / raw)
To: emacs-orgmode
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 <tlikonen@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.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: org back up
2012-10-17 18:25 org back up Sanjib Sikder
2012-10-17 18:41 ` Teemu Likonen
@ 2012-10-17 19:25 ` Achim Gratz
2012-10-17 20:05 ` Russell Adams
1 sibling, 1 reply; 11+ messages in thread
From: Achim Gratz @ 2012-10-17 19:25 UTC (permalink / raw)
To: emacs-orgmode
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
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: org back up
2012-10-17 19:25 ` Achim Gratz
@ 2012-10-17 20:05 ` Russell Adams
0 siblings, 0 replies; 11+ messages in thread
From: Russell Adams @ 2012-10-17 20:05 UTC (permalink / raw)
To: emacs-orgmode
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 Adams RLAdams@AdamsInfoServ.com
PGP Key ID: 0x1160DCB3 http://www.adamsinfoserv.com/
Fingerprint: 1723 D8CA 4280 1EC9 557F 66E8 1154 E018 1160 DCB3
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2012-10-18 0:14 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-17 18:25 org back up Sanjib Sikder
2012-10-17 18:41 ` Teemu Likonen
2012-10-17 19:02 ` Sanjib Sikder
2012-10-17 19:08 ` Teemu Likonen
2012-10-17 19:26 ` Sanjib Sikder
2012-10-17 19:41 ` Teemu Likonen
2012-10-17 19:36 ` Nick Dokos
2012-10-17 19:38 ` Sanjib Sikder
2012-10-18 0:14 ` Suvayu Ali
2012-10-17 19:25 ` Achim Gratz
2012-10-17 20:05 ` Russell Adams
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).